A container of wml_menu_item. More...
#include <wmi_container.hpp>
Classes | |
struct | key |
The key for interaction with our iterators. More... | |
Public Types | |
typedef item_ptr | value_type |
typedef value_type * | pointer |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef map_t::difference_type | difference_type |
typedef map_t::size_type | size_type |
typedef util::iterator_extend < value_type, map_t, key, key > | iterator |
typedef util::const_iterator_extend < value_type, map_t, key, key > | const_iterator |
Public Member Functions | |
wmi_container () | |
~wmi_container () | |
Destructor. More... | |
bool | empty () const |
Returns true if *this contains no data. More... | |
size_type | 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) const |
Fires the menu item with the given id. More... | |
std::vector< std::pair < boost::shared_ptr< const wml_menu_item >, std::string > > | get_items (const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units, const_iterator start, const_iterator finish) const |
Returns the menu items that can be shown for the given location. More... | |
std::vector< std::pair < boost::shared_ptr< const wml_menu_item >, std::string > > | get_items (const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units) const |
Range over all items by default. More... | |
void | init_handlers () 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... | |
const_iterator | find (const std::string &id) const |
Returns an iterator to a menu item with the given id, if one exists. More... | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
size_t | size () const |
Private Types | |
typedef boost::shared_ptr < wml_menu_item > | item_ptr |
Pointers to our elements. More... | |
typedef std::map< std::string, item_ptr > | map_t |
The underlying storage type. More... | |
Private Member Functions | |
iterator | find (const std::string &id) |
Returns an iterator to a menu item with the given id, if one exists. More... | |
Private Attributes | |
map_t | wml_menu_items_ |
A container of wml_menu_item.
Definition at line 44 of file wmi_container.hpp.
typedef util::const_iterator_extend<value_type, map_t, key, key> game_events::wmi_container::const_iterator |
Definition at line 66 of file wmi_container.hpp.
typedef const value_type& game_events::wmi_container::const_reference |
Definition at line 61 of file wmi_container.hpp.
typedef map_t::difference_type game_events::wmi_container::difference_type |
Definition at line 62 of file wmi_container.hpp.
|
private |
Pointers to our elements.
Definition at line 46 of file wmi_container.hpp.
Definition at line 65 of file wmi_container.hpp.
|
private |
The underlying storage type.
Definition at line 48 of file wmi_container.hpp.
Definition at line 59 of file wmi_container.hpp.
Definition at line 60 of file wmi_container.hpp.
typedef map_t::size_type game_events::wmi_container::size_type |
Definition at line 63 of file wmi_container.hpp.
Definition at line 58 of file wmi_container.hpp.
game_events::wmi_container::wmi_container | ( | ) |
Definition at line 40 of file wmi_container.cpp.
game_events::wmi_container::~wmi_container | ( | ) |
Destructor.
Default implementation, but defined here because this function needs to be able to see wml_menu_item's destructor.
Definition at line 49 of file wmi_container.cpp.
|
inline |
Definition at line 102 of file wmi_container.hpp.
References wml_menu_items_.
Referenced by get_items().
|
inline |
Definition at line 104 of file wmi_container.hpp.
References wml_menu_items_.
|
inline |
Returns true if *this contains no data.
Definition at line 74 of file wmi_container.hpp.
References wml_menu_items_.
Referenced by get_items().
|
inline |
Definition at line 103 of file wmi_container.hpp.
References wml_menu_items_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), fire_item(), and get_items().
|
inline |
Definition at line 105 of file wmi_container.hpp.
References wml_menu_items_.
wmi_container::size_type game_events::wmi_container::erase | ( | const std::string & | id | ) |
Erases the item with the provided id.
Erases the item with id key.
Definition at line 55 of file wmi_container.cpp.
References wml_menu_items_, and WRN_NG.
Referenced by game_lua_kernel::intf_clear_menu_item().
|
inlineprivate |
Returns an iterator to a menu item with the given id, if one exists.
Definition at line 97 of file wmi_container.hpp.
References wml_menu_items_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), and fire_item().
|
inline |
Returns an iterator to a menu item with the given id, if one exists.
Definition at line 100 of file wmi_container.hpp.
References wml_menu_items_.
bool game_events::wmi_container::fire_item | ( | const std::string & | id, |
const map_location & | hex, | ||
game_data & | gamedata, | ||
filter_context & | fc, | ||
unit_map & | units | ||
) | const |
Fires the menu item with the given id.
Definition at line 81 of file wmi_container.cpp.
References game_events::wml_menu_item::can_show(), end(), find(), game_events::wml_menu_item::fire_event(), game_data::get_variable(), map_location::x, and map_location::y.
Referenced by play_controller::hotkey_handler::execute_command(), and game_lua_kernel::intf_fire_wml_menu_item().
std::vector< std::pair< boost::shared_ptr< const wml_menu_item >, std::string > > game_events::wmi_container::get_items | ( | const map_location & | hex, |
game_data & | gamedata, | ||
filter_context & | fc, | ||
unit_map & | units, | ||
const_iterator | start, | ||
const_iterator | finish | ||
) | const |
Returns the menu items that can be shown for the given location.
Should be used with a wmi_pager to limit the number of items displayed at once.
[out] | items | Pointers to applicable menu items will be pushed onto items. |
[out] | descriptions | Menu item text will be pushed onto descriptions (in the same order as items). |
Definition at line 109 of file wmi_container.cpp.
References play_controller::can_use_synced_wml_menu(), resources::controller, empty(), game_data::get_variable(), map_location::x, and map_location::y.
Referenced by wmi_pager::get_items(), and get_items().
|
inline |
Range over all items by default.
Definition at line 84 of file wmi_container.hpp.
References begin(), end(), and get_items().
void game_events::wmi_container::init_handlers | ( | ) | const |
Initializes the implicit event handlers for inlined [command]s.
Definition at line 138 of file wmi_container.cpp.
References LOG_NG.
Referenced by game_events::manager::read_scenario().
void game_events::wmi_container::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 178 of file wmi_container.cpp.
References wml_menu_items_.
Referenced by game_lua_kernel::intf_set_menu_item().
Sets the current menu items to the "menu_item" children of cfg.
Definition at line 196 of file wmi_container.cpp.
References config::child_range(), wml_menu_items_, and WRN_NG.
Referenced by game_events::manager::read_scenario().
|
inline |
Definition at line 107 of file wmi_container.hpp.
References wml_menu_items_.
Definition at line 165 of file wmi_container.cpp.
References config::add_child().
Referenced by game_events::manager::write_events().
|
private |
Definition at line 109 of file wmi_container.hpp.
Referenced by begin(), empty(), end(), erase(), find(), set_item(), set_menu_items(), and size().