The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
game_events::wmi_container Class Reference

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_typepointer
 
typedef value_typereference
 
typedef const value_typeconst_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_
 

Detailed Description

A container of wml_menu_item.

Definition at line 44 of file wmi_container.hpp.

Member Typedef Documentation

Definition at line 66 of file wmi_container.hpp.

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.

Pointers to our elements.

Definition at line 46 of file wmi_container.hpp.

Definition at line 65 of file wmi_container.hpp.

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

iterator game_events::wmi_container::begin ( )
inline

Definition at line 102 of file wmi_container.hpp.

References wml_menu_items_.

Referenced by get_items().

const_iterator game_events::wmi_container::begin ( ) const
inline

Definition at line 104 of file wmi_container.hpp.

References wml_menu_items_.

bool game_events::wmi_container::empty ( ) const
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().

iterator game_events::wmi_container::end ( )
inline
const_iterator game_events::wmi_container::end ( ) const
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().

iterator game_events::wmi_container::find ( const std::string id)
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().

const_iterator game_events::wmi_container::find ( const std::string id) const
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.

Returns
true if a matching item was found (even if it could not be fired). NOTE: The return value could be altered if it is decided that play_controller::execute_command() needs something different.

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.

Parameters
[out]itemsPointers to applicable menu items will be pushed onto items.
[out]descriptionsMenu 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().

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
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().

void game_events::wmi_container::set_menu_items ( const config cfg)

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().

size_t game_events::wmi_container::size ( ) const
inline

Definition at line 107 of file wmi_container.hpp.

References wml_menu_items_.

void game_events::wmi_container::to_config ( config cfg) const

Definition at line 165 of file wmi_container.cpp.

References config::add_child().

Referenced by game_events::manager::write_events().

Member Data Documentation

map_t game_events::wmi_container::wml_menu_items_
private

Definition at line 109 of file wmi_container.hpp.

Referenced by begin(), empty(), end(), erase(), find(), set_item(), set_menu_items(), and size().


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