map_editor::terrain_palette Class Reference

Palette where the terrain to be drawn can be selected. More...

#include <editor_palettes.hpp>

Inheritance diagram for map_editor::terrain_palette:

Inheritance graph
[legend]
Collaboration diagram for map_editor::terrain_palette:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 terrain_palette (display &gui, const size_specs &sizes, const gamemap &map, const config &cfg)
void scroll_up ()
 Scroll the terrain-palette up one step if possible.
void scroll_down ()
 Scroll the terrain-palette down one step if possible.
void scroll_top ()
 Scroll the terrain-palette to the top.
void scroll_bottom ()
 Scroll the terrain-palette to the bottom.
void set_group (const std::string &id)
 Sets a group active id == terrain_map_->first The selected terrains remain the same, this can result in no visible selected items.
t_translation::t_terrain selected_fg_terrain () const
 Return the currently selected foreground terrain.
t_translation::t_terrain selected_bg_terrain () const
 Return the currently selected background terrain.
void select_fg_terrain (t_translation::t_terrain)
 Select a foreground terrain.
void select_bg_terrain (t_translation::t_terrain)
void update_selected_terrains (void)
 Update the selected terrains strings.
void draw (bool force=false)
 Draw the palette.
virtual void draw ()
virtual void handle_event (const SDL_Event &event)
void set_dirty (bool dirty=true)
size_t num_terrains () const
 Return the number of terrains in the palette.
void adjust_size ()
 Update the size of this widget.
void load_tooltips ()
 Sets the tooltips used in the palette.

Private Member Functions

void draw_old (bool)
void left_mouse_click (const int mousex, const int mousey)
 To be called when a mouse click occurs.
void right_mouse_click (const int mousex, const int mousey)
int tile_selected (const int x, const int y) const
 Return the number of the tile that is at coordinates (x, y) in the panel.
std::string get_terrain_string (const t_translation::t_terrain)
 Return a string represeting the terrain and the underlying ones.
void update_report ()
 Update the report with the currently selected terrains.

Private Attributes

const size_specssize_specs_
displaygui_
unsigned int tstart_
std::map< std::string,
t_translation::t_list
terrain_map_
 This map contains all editor_group as defined in terrain.cfg and associate with the group there.
t_translation::t_list terrains_
 A copy from the terrain_map_->second for the current active group.
std::vector< terrain_groupterrain_groups_
 The editor_groups as defined in editor-groups.cfg Note the user must make sure the id's here are the same as the editor_group in terrain.cfg.
gui::buttonchecked_group_btn_
 The group buttons behave like a radio group.
t_translation::t_terrain selected_fg_terrain_
t_translation::t_terrain selected_bg_terrain_
const gamemapmap_
gui::button top_button_
gui::button bot_button_
size_t button_x_
size_t top_button_y_
size_t bot_button_y_
size_t nterrains_
size_t terrain_start_


Detailed Description

Palette where the terrain to be drawn can be selected.

Definition at line 49 of file editor_palettes.hpp.


Constructor & Destructor Documentation

map_editor::terrain_palette::terrain_palette ( display gui,
const size_specs sizes,
const gamemap map,
const config cfg 
)


Member Function Documentation

void map_editor::terrain_palette::scroll_up (  ) 

Scroll the terrain-palette up one step if possible.

Definition at line 189 of file editor_palettes.cpp.

References gui::widget::bg_restore(), nterrains_, num_terrains(), set_dirty(), size_specs_, map_editor::size_specs::terrain_width, and tstart_.

Referenced by draw(), and handle_event().

void map_editor::terrain_palette::scroll_down (  ) 

Scroll the terrain-palette down one step if possible.

Definition at line 176 of file editor_palettes.cpp.

References gui::widget::bg_restore(), nterrains_, num_terrains(), set_dirty(), size_specs_, map_editor::size_specs::terrain_width, and tstart_.

Referenced by draw(), handle_event(), and scroll_bottom().

void map_editor::terrain_palette::scroll_top (  ) 

Scroll the terrain-palette to the top.

Definition at line 201 of file editor_palettes.cpp.

References gui::widget::bg_restore(), set_dirty(), and tstart_.

Referenced by adjust_size(), and set_group().

void map_editor::terrain_palette::scroll_bottom (  ) 

Scroll the terrain-palette to the bottom.

Definition at line 207 of file editor_palettes.cpp.

References num_terrains(), scroll_down(), and tstart_.

void map_editor::terrain_palette::set_group ( const std::string &  id  ) 

Sets a group active id == terrain_map_->first The selected terrains remain the same, this can result in no visible selected items.

Definition at line 215 of file editor_palettes.cpp.

References scroll_top(), terrain_map_, and terrains_.

Referenced by draw().

t_translation::t_terrain map_editor::terrain_palette::selected_fg_terrain (  )  const

Return the currently selected foreground terrain.

Definition at line 224 of file editor_palettes.cpp.

References selected_fg_terrain_.

Referenced by draw(), and update_report().

t_translation::t_terrain map_editor::terrain_palette::selected_bg_terrain (  )  const

Return the currently selected background terrain.

Definition at line 229 of file editor_palettes.cpp.

References selected_bg_terrain_.

Referenced by draw(), and update_report().

void map_editor::terrain_palette::select_fg_terrain ( t_translation::t_terrain  terrain  ) 

Select a foreground terrain.

Definition at line 234 of file editor_palettes.cpp.

References selected_fg_terrain_, set_dirty(), and update_report().

Referenced by left_mouse_click().

void map_editor::terrain_palette::select_bg_terrain ( t_translation::t_terrain  terrain  ) 

Definition at line 243 of file editor_palettes.cpp.

References selected_bg_terrain_, set_dirty(), and update_report().

Referenced by right_mouse_click().

void map_editor::terrain_palette::update_selected_terrains ( void   ) 

Update the selected terrains strings.

After the language is changed, the selected terrains needs an update.

Definition at line 254 of file editor_palettes.cpp.

References set_dirty(), and update_report().

void map_editor::terrain_palette::draw ( bool  force = false  ) 

void map_editor::terrain_palette::draw (  )  [virtual]

Reimplemented from gui::widget.

Definition at line 301 of file editor_palettes.cpp.

void map_editor::terrain_palette::handle_event ( const SDL_Event &  event  )  [virtual]

void map_editor::terrain_palette::set_dirty ( bool  dirty = true  ) 

size_t map_editor::terrain_palette::num_terrains (  )  const

Return the number of terrains in the palette.

Definition at line 297 of file editor_palettes.cpp.

References terrains_.

Referenced by adjust_size(), draw(), scroll_bottom(), scroll_down(), and scroll_up().

void map_editor::terrain_palette::adjust_size (  ) 

void map_editor::terrain_palette::load_tooltips ( void   ) 

Sets the tooltips used in the palette.

Definition at line 468 of file editor_palettes.cpp.

References tooltips::add_tooltip(), terrain_groups_, and text.

void map_editor::terrain_palette::draw_old ( bool   )  [private]

void map_editor::terrain_palette::left_mouse_click ( const int  mousex,
const int  mousey 
) [private]

To be called when a mouse click occurs.

Check if the coordinates is a terrain that may be chosen, and select the terrain if that is the case.

Definition at line 281 of file editor_palettes.cpp.

References gui_, display::invalidate_game_status(), select_fg_terrain(), terrains_, tile_selected(), and tstart_.

Referenced by handle_event().

void map_editor::terrain_palette::right_mouse_click ( const int  mousex,
const int  mousey 
) [private]

int map_editor::terrain_palette::tile_selected ( const int  x,
const int  y 
) const [private]

Return the number of the tile that is at coordinates (x, y) in the panel.

Definition at line 446 of file editor_palettes.cpp.

References nterrains_, map_editor::size_specs::palette_x, size_specs_, map_editor::size_specs::terrain_space, terrain_start_, and map_editor::size_specs::terrain_width.

Referenced by left_mouse_click(), and right_mouse_click().

std::string map_editor::terrain_palette::get_terrain_string ( const t_translation::t_terrain  t  )  [private]

Return a string represeting the terrain and the underlying ones.

Definition at line 260 of file editor_palettes.cpp.

References gamemap::get_terrain_info(), map_, terrain_type::name(), name, t_string::str(), and gamemap::underlying_union_terrain().

Referenced by update_report().

void map_editor::terrain_palette::update_report (  )  [private]


Member Data Documentation

Definition at line 119 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), scroll_down(), scroll_up(), and tile_selected().

Definition at line 120 of file editor_palettes.hpp.

Referenced by draw(), left_mouse_click(), right_mouse_click(), and update_report().

unsigned int map_editor::terrain_palette::tstart_ [private]

This map contains all editor_group as defined in terrain.cfg and associate with the group there.

The group 'all' is added automatically, and all terrains are also automatically stored in this group.

Definition at line 127 of file editor_palettes.hpp.

Referenced by set_group(), and terrain_palette().

A copy from the terrain_map_->second for the current active group.

Definition at line 130 of file editor_palettes.hpp.

Referenced by draw(), left_mouse_click(), num_terrains(), right_mouse_click(), set_group(), and terrain_palette().

The editor_groups as defined in editor-groups.cfg Note the user must make sure the id's here are the same as the editor_group in terrain.cfg.

Definition at line 135 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), load_tooltips(), set_dirty(), and terrain_palette().

The group buttons behave like a radio group.

This one points to the selected button, this value should not be 0 otherwise things will fail. Thus should be set in constructor.

Definition at line 140 of file editor_palettes.hpp.

Referenced by draw(), and terrain_palette().

Definition at line 142 of file editor_palettes.hpp.

Referenced by select_fg_terrain(), selected_fg_terrain(), and terrain_palette().

Definition at line 142 of file editor_palettes.hpp.

Referenced by select_bg_terrain(), selected_bg_terrain(), and terrain_palette().

Definition at line 143 of file editor_palettes.hpp.

Referenced by draw(), get_terrain_string(), and terrain_palette().

Definition at line 144 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), and set_dirty().

Definition at line 144 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), and set_dirty().

Definition at line 145 of file editor_palettes.hpp.

Referenced by adjust_size().

Definition at line 145 of file editor_palettes.hpp.

Referenced by adjust_size().

Definition at line 145 of file editor_palettes.hpp.

Referenced by adjust_size().

Definition at line 146 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), scroll_down(), scroll_up(), and tile_selected().

Definition at line 146 of file editor_palettes.hpp.

Referenced by adjust_size(), draw(), and tile_selected().


The documentation for this class was generated from the following files:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs