#include <editor_palettes.hpp>
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_specs & | size_specs_ |
display & | gui_ |
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_group > | terrain_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::button * | checked_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 gamemap & | map_ |
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_ |
Definition at line 49 of file editor_palettes.hpp.
map_editor::terrain_palette::terrain_palette | ( | display & | gui, | |
const size_specs & | sizes, | |||
const gamemap & | map, | |||
const config & | cfg | |||
) |
Definition at line 47 of file editor_palettes.cpp.
References checked_group_btn_, terrain_type::editor_group(), config::get_children(), gamemap::get_terrain_info(), gamemap::get_terrain_list(), terrain_type::is_combined(), map_editor::is_invalid_terrain(), map_, selected_bg_terrain_, selected_fg_terrain_, utils::split(), terrain_groups_, terrain_map_, terrains_, and update_report().
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 |
) |
Draw the palette.
If force is true everything will be redrawn, even though it is not invalidated.
Definition at line 346 of file editor_palettes.cpp.
References surface::assign(), bot_button_, checked_group_btn_, terrain_type::default_base(), gui::widget::dirty(), draw_rectangle(), terrain_type::editor_image(), image::get_image(), gamemap::get_terrain_info(), CVideo::getSurface(), gui_, loc, gui::widget::location(), map_, t_translation::NONE_TERRAIN, nterrains_, num_terrains(), gui::button::pressed(), scale_surface(), screen, scroll_down(), scroll_up(), selected_bg_terrain(), selected_fg_terrain(), gui::button::set_check(), set_dirty(), set_group(), size_specs_, terrain_groups_, map_editor::size_specs::terrain_size, map_editor::size_specs::terrain_space, terrain_start_, map_editor::size_specs::terrain_width, terrains_, top_button_, tstart_, update_rect(), and display::video().
void map_editor::terrain_palette::draw | ( | ) | [virtual] |
void map_editor::terrain_palette::handle_event | ( | const SDL_Event & | event | ) | [virtual] |
Reimplemented from gui::widget.
Definition at line 305 of file editor_palettes.cpp.
References gui::widget::focus(), left_mouse_click(), point_in_rect(), right_mouse_click(), scroll_down(), scroll_up(), SDL_BUTTON_WHEELDOWN, SDL_BUTTON_WHEELUP, and gui::widget::set_focus().
void map_editor::terrain_palette::set_dirty | ( | bool | dirty = true |
) |
Reimplemented from gui::widget.
Definition at line 165 of file editor_palettes.cpp.
References bot_button_, gui::widget::set_dirty(), terrain_groups_, and top_button_.
Referenced by adjust_size(), draw(), scroll_down(), scroll_top(), scroll_up(), select_bg_terrain(), select_fg_terrain(), and update_selected_terrains().
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 | ( | ) |
Update the size of this widget.
Use if the size_specs have changed.
Definition at line 112 of file editor_palettes.cpp.
References gui::widget::bg_register(), bot_button_, bot_button_y_, button_x_, nterrains_, num_terrains(), map_editor::size_specs::palette_h, map_editor::size_specs::palette_w, map_editor::size_specs::palette_x, map_editor::size_specs::palette_y, rect, scroll_top(), set_dirty(), gui::widget::set_location(), size_specs_, terrain_groups_, map_editor::size_specs::terrain_space, terrain_start_, map_editor::size_specs::terrain_width, top_button_, and top_button_y_.
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] |
Definition at line 289 of file editor_palettes.cpp.
References gui_, display::invalidate_game_status(), select_bg_terrain(), terrains_, tile_selected(), and tstart_.
Referenced by handle_event().
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] |
Update the report with the currently selected terrains.
Definition at line 460 of file editor_palettes.cpp.
References _, get_terrain_string(), gui_, selected_bg_terrain(), selected_fg_terrain(), reports::SELECTED_TERRAIN, and display::set_report_content().
Referenced by select_bg_terrain(), select_fg_terrain(), terrain_palette(), and update_selected_terrains().
const size_specs& map_editor::terrain_palette::size_specs_ [private] |
Definition at line 119 of file editor_palettes.hpp.
Referenced by adjust_size(), draw(), scroll_down(), scroll_up(), and tile_selected().
display& map_editor::terrain_palette::gui_ [private] |
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] |
Definition at line 121 of file editor_palettes.hpp.
Referenced by draw(), left_mouse_click(), right_mouse_click(), scroll_bottom(), scroll_down(), scroll_top(), and scroll_up().
std::map<std::string, t_translation::t_list> map_editor::terrain_palette::terrain_map_ [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().
std::vector<terrain_group> map_editor::terrain_palette::terrain_groups_ [private] |
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().
const gamemap& map_editor::terrain_palette::map_ [private] |
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().
size_t map_editor::terrain_palette::button_x_ [private] |
size_t map_editor::terrain_palette::top_button_y_ [private] |
size_t map_editor::terrain_palette::bot_button_y_ [private] |
size_t map_editor::terrain_palette::nterrains_ [private] |
Definition at line 146 of file editor_palettes.hpp.
Referenced by adjust_size(), draw(), scroll_down(), scroll_up(), and tile_selected().
size_t map_editor::terrain_palette::terrain_start_ [private] |
Definition at line 146 of file editor_palettes.hpp.
Referenced by adjust_size(), draw(), and tile_selected().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |