#include <wmi_manager.hpp>
Public Types | |
| using | item_ptr = std::shared_ptr< wml_menu_item > |
| wml_menu_item pointers More... | |
Public Member Functions | |
| wmi_manager () | |
| ~wmi_manager () | |
| Destructor. More... | |
| bool | empty () const |
| Returns true if no menu items are being managed. More... | |
| bool | erase (const std::string &id) |
| Erases the item with the provided id. More... | |
| bool | fire_item (const std::string &id, const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units, bool is_key_hold_repeat=false) const |
| Fires the menu item with the given id. More... | |
| item_ptr | get_item (const std::string &id) const |
| Gets the menu item with the specified ID. More... | |
| void | get_items (const map_location &hex, std::vector< config > &items, filter_context &fc, game_data &gamedata, unit_map &units) const |
| Returns the menu items that can be shown for the given location. More... | |
| void | init_handlers (game_lua_kernel &lk) const |
| Initializes the implicit event handlers for inlined [command]s. More... | |
| void | to_config (config &cfg) const |
| void | set_item (const std::string &id, const vconfig &menu_item) |
| Updates or creates (as appropriate) the menu item with the given id. More... | |
| void | set_menu_items (const config &cfg) |
| Sets the current menu items to the "menu_item" children of cfg. More... | |
| std::size_t | size () const |
| Gets the number of menu items owned. More... | |
Private Attributes | |
| std::map< std::string, item_ptr > | wml_menu_items_ |
Definition at line 40 of file wmi_manager.hpp.
| using game_events::wmi_manager::item_ptr = std::shared_ptr<wml_menu_item> |
wml_menu_item pointers
Definition at line 44 of file wmi_manager.hpp.
| game_events::wmi_manager::wmi_manager | ( | ) |
Definition at line 38 of file wmi_manager.cpp.
| game_events::wmi_manager::~wmi_manager | ( | ) |
Destructor.
Default implementation, but defined here because this function needs to be able to see wml_menu_item's destructor.
Definition at line 48 of file wmi_manager.cpp.
|
inline |
Returns true if no menu items are being managed.
Definition at line 50 of file wmi_manager.hpp.
References wml_menu_items_.
Referenced by get_items().
| bool game_events::wmi_manager::erase | ( | const std::string & | id | ) |
Erases the item with the provided id.
Erases the item with id key.
Definition at line 53 of file wmi_manager.cpp.
References wml_menu_items_, and WRN_NG.
Referenced by game_lua_kernel::intf_clear_menu_item().
| bool game_events::wmi_manager::fire_item | ( | const std::string & | id, |
| const map_location & | hex, | ||
| game_data & | gamedata, | ||
| filter_context & | fc, | ||
| unit_map & | units, | ||
| bool | is_key_hold_repeat = false |
||
| ) | const |
Fires the menu item with the given id.
Definition at line 78 of file wmi_manager.cpp.
References gamedata, get_item(), map_location::wml_x(), and map_location::wml_y().
Referenced by play_controller::hotkey_handler::do_execute_command(), and game_lua_kernel::intf_fire_wml_menu_item().
| wmi_manager::item_ptr game_events::wmi_manager::get_item | ( | const std::string & | id | ) | const |
Gets the menu item with the specified ID.
| id | Item id. |
Definition at line 151 of file wmi_manager.cpp.
References wml_menu_items_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), and fire_item().
| void game_events::wmi_manager::get_items | ( | const map_location & | hex, |
| std::vector< config > & | items, | ||
| filter_context & | fc, | ||
| game_data & | gamedata, | ||
| unit_map & | units | ||
| ) | const |
Returns the menu items that can be shown for the given location.
| hex | The current hex. | |
| [out] | items | Menu items. consisting of menu text, menu icons, and action ids. |
| fc | Used to check whether the menu's filter matches. | |
| gamedata | Used to check whether to show if selecting is required. | |
| units | Used to highlight a unit if needed. |
Definition at line 114 of file wmi_manager.cpp.
References play_controller::can_use_synced_wml_menu(), resources::controller, empty(), gamedata, utils::interpolate_variables_into_string(), wml_menu_items_, map_location::wml_x(), and map_location::wml_y().
Referenced by play_controller::hotkey_handler::expand_wml_commands().
| void game_events::wmi_manager::init_handlers | ( | game_lua_kernel & | lk | ) | const |
Initializes the implicit event handlers for inlined [command]s.
Definition at line 164 of file wmi_manager.cpp.
References LOG_NG, and wml_menu_items_.
Referenced by game_events::manager::read_scenario().
| void game_events::wmi_manager::set_item | ( | const std::string & | id, |
| const vconfig & | menu_item | ||
| ) |
Updates or creates (as appropriate) the menu item with the given id.
Definition at line 195 of file wmi_manager.cpp.
References wml_menu_items_.
Referenced by game_lua_kernel::intf_set_menu_item().
| void game_events::wmi_manager::set_menu_items | ( | const config & | cfg | ) |
Sets the current menu items to the "menu_item" children of cfg.
Definition at line 211 of file wmi_manager.cpp.
References cfg, config::child_range(), wml_menu_items_, and WRN_NG.
Referenced by game_events::manager::read_scenario().
|
inline |
Gets the number of menu items owned.
Definition at line 93 of file wmi_manager.hpp.
References wml_menu_items_.
| void game_events::wmi_manager::to_config | ( | config & | cfg | ) | const |
Definition at line 184 of file wmi_manager.cpp.
References config::add_child(), cfg, and wml_menu_items_.
Referenced by game_events::manager::write_events().
|
private |
Definition at line 99 of file wmi_manager.hpp.
Referenced by empty(), erase(), get_item(), get_items(), init_handlers(), set_item(), set_menu_items(), size(), and to_config().