Palette where the terrain to be drawn can be selected. More...
#include <unit_palette.hpp>
Public Member Functions | |
unit_palette (editor_display &gui, editor_toolkit &toolkit) | |
virtual void | setup (const game_config_view &cfg) override |
Setup the internal data structure. More... | |
virtual std::string | get_help_string () const override |
virtual bool | supports_swap () override |
Whether the hotkey system should the enable GUI button connected to swap(). More... | |
const std::set< std::string > & | get_selected_bg_items () |
Public Member Functions inherited from editor::editor_palette< const unit_type & > | |
editor_palette (editor_display &gui, int item_size, std::size_t columns, editor_toolkit &toolkit) | |
virtual sdl_handler_vector | handler_members () override |
void | set_start_item (std::size_t index) override |
std::size_t | start_num (void) override |
void | expand_palette_groups_menu (std::vector< config > &items, int i) override |
Menu expanding for palette group list. More... | |
void | set_group (std::size_t index) override |
const std::vector< item_group > & | get_groups () const override |
virtual void | layout () override |
Called by draw_manager to validate layout before drawing. More... | |
virtual void | draw_contents () override |
Called by widget::draw() More... | |
void | next_group () override |
void | prev_group () override |
void | adjust_size (const SDL_Rect &target) override |
Update the size of this widget. More... | |
virtual bool | scroll_up () override |
Scroll the editor-palette up one step if possible. More... | |
virtual bool | can_scroll_up () override |
virtual bool | scroll_down () override |
Scroll the editor-palette down one step if possible. More... | |
virtual bool | can_scroll_down () override |
void | swap () override |
For tools which support fg and bg items, exchange the two items. More... | |
const const unit_type & & | selected_fg_item () const |
Return the currently selected foreground/background item. More... | |
const const unit_type & & | selected_bg_item () const |
Public Member Functions inherited from editor::tristate_palette | |
tristate_palette () | |
Public Member Functions inherited from editor::common_palette | |
common_palette () | |
virtual | ~common_palette () |
virtual std::vector< std::string > | action_pressed () const |
Public Member Functions inherited from gui::widget | |
const rect & | location () const |
virtual void | set_location (const SDL_Rect &rect) |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | queue_redraw () |
Indicate that the widget should be redrawn. More... | |
void | queue_redraw (const rect &) |
Indicate that a specific region of the screen should be redrawn. More... | |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_tooltip_string (int mousex, int mousey) override |
virtual bool | expose (const rect ®ion) override |
Called by draw_manager when it believes a redraw is necessary. More... | |
virtual rect | screen_location () override |
The current draw location of the display, on the screen. More... | |
Public Member Functions inherited from events::sdl_handler | |
virtual void | handle_window_event (const SDL_Event &) |
virtual void | process_event () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
virtual bool | has_joined () |
virtual bool | has_joined_global () |
sdl_handler & | operator= (sdl_handler &&)=delete |
Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More... | |
sdl_handler (sdl_handler &&)=delete | |
Public Member Functions inherited from gui2::top_level_drawable | |
virtual void | update () |
Update state and any parameters that may effect layout, or any of the later stages. More... | |
virtual void | render () |
Perform any internal rendering necessary to prepare the drawable. More... | |
Private Member Functions | |
virtual const std::string & | get_id (const unit_type &terrain) override |
virtual void | setup_item (const unit_type &item, texture &item_base_image, texture &item_overlay_image, std::stringstream &tooltip) override |
virtual bool | is_selected_bg_item (const std::string &id) override |
virtual void | select_bg_item (const std::string &item_id) override |
Private Attributes | |
std::set< std::string > | selected_bg_items_ |
Additional Inherited Members | |
Protected Types inherited from editor::editor_palette< const unit_type & > | |
typedef std::map< std::string, const unit_type & > | item_map |
Protected Member Functions inherited from editor::editor_palette< const unit_type & > | |
virtual void | set_group (const std::string &id) |
Sets a group active id. More... | |
const std::vector< std::string > & | active_group () |
virtual void | select_fg_item (const std::string &item_id) override |
Select a foreground item. More... | |
Protected Member Functions inherited from gui::widget | |
widget (const bool auto_join=true) | |
virtual | ~widget () |
virtual void | update_location (const SDL_Rect &) |
virtual void | handle_event (const SDL_Event &) override |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
sdl_handler (const sdl_handler &) | |
sdl_handler & | operator= (const sdl_handler &) |
virtual | ~sdl_handler () |
Protected Member Functions inherited from gui2::top_level_drawable | |
top_level_drawable () | |
virtual | ~top_level_drawable () |
top_level_drawable (const top_level_drawable &) | |
top_level_drawable & | operator= (const top_level_drawable &) |
top_level_drawable (top_level_drawable &&) | |
top_level_drawable & | operator= (top_level_drawable &&) |
Protected Attributes inherited from editor::editor_palette< const unit_type & > | |
std::vector< item_group > | groups_ |
The editor_groups as defined in editor-groups.cfg. More... | |
editor_display & | gui_ |
int | item_size_ |
Both the width and the height of the square buttons. More... | |
int | item_space_ |
item_size_ plus some padding. More... | |
std::size_t | columns_ |
Number of items per row. More... | |
std::map< std::string, std::vector< std::string > > | group_map_ |
item_map | item_map_ |
std::size_t | items_start_ |
Index of the item at the top-left of the visible area, used for scrolling up and down. More... | |
std::set< std::string > | non_core_items_ |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
Palette where the terrain to be drawn can be selected.
Definition at line 33 of file unit_palette.hpp.
editor::unit_palette::unit_palette | ( | editor_display & | gui, |
editor_toolkit & | toolkit | ||
) |
Definition at line 96 of file unit_palette.cpp.
|
overridevirtual |
Implements editor::editor_palette< const unit_type & >.
Definition at line 31 of file unit_palette.cpp.
References editor::editor_palette< const unit_type & >::selected_fg_item(), and unit_type::type_name().
|
overrideprivatevirtual |
Definition at line 103 of file unit_palette.cpp.
References unit_type::id().
|
inline |
Definition at line 44 of file unit_palette.hpp.
References selected_bg_items_.
|
overrideprivatevirtual |
Reimplemented from editor::editor_palette< const unit_type & >.
Definition at line 108 of file unit_palette.cpp.
References selected_bg_items_.
|
overrideprivatevirtual |
Reimplemented from editor::editor_palette< const unit_type & >.
Definition at line 113 of file unit_palette.cpp.
References selected_bg_items_, and gui::widget::set_dirty().
Referenced by setup().
|
overridevirtual |
Setup the internal data structure.
Implements editor::editor_palette< const unit_type & >.
Definition at line 35 of file unit_palette.cpp.
References editor::editor_palette< const unit_type & >::active_group(), ERR_ED, editor::editor_palette< const unit_type & >::group_map_, editor::editor_palette< const unit_type & >::groups_, i, editor::editor_palette< const unit_type & >::item_map_, unit_type_data::races(), select_bg_item(), editor::editor_palette< const unit_type & >::select_fg_item(), editor::editor_palette< const unit_type & >::set_group(), unit_type_data::types(), and unit_types.
|
overrideprivatevirtual |
Definition at line 72 of file unit_palette.cpp.
References ERR_ED, filename, unit_type::flag_rgb(), team::get_side_color_id(), image::get_texture(), editor::editor_palette< const unit_type & >::gui_, unit_type::image(), game_config::images::missing, team::side(), unit_type::type_name(), and display::viewing_team().
|
inlineoverridevirtual |
Whether the hotkey system should the enable GUI button connected to swap().
Reimplemented from editor::common_palette.
Definition at line 42 of file unit_palette.hpp.
|
private |
Definition at line 60 of file unit_palette.hpp.
Referenced by get_selected_bg_items(), is_selected_bg_item(), and select_bg_item().