32 #define WRN_NG LOG_STREAM(warn, log_engine)
33 #define LOG_NG LOG_STREAM(info, log_engine)
59 WRN_NG <<
"Trying to remove non-existent menu item '" <<
id <<
"'; ignoring.";
65 iter->second->finish_handler();
86 }
else if(is_key_hold_repeat && !wmi->hotkey_repeat()) {
98 if(wmi->can_show(hex,
gamedata, fc)) {
117 std::vector<std::shared_ptr<const wml_menu_item>>&
items,
118 std::vector<config>& descriptions,
146 descriptions.emplace_back(
"id",
item->menu_text());
177 unsigned wmi_count = 0;
182 item.second->init_handler(lk);
190 LOG_NG << wmi_count <<
" WML menu items found, loaded.";
209 auto [iter, success] =
wml_menu_items_.emplace(
id, std::make_shared<wml_menu_item>(
id, menu_item));
215 iter->second.reset(
new wml_menu_item(
id, menu_item, *iter->second));
226 if(!
item.has_attribute(
"id")) {
230 const std::string&
id =
item[
"id"];
233 std::tie(std::ignore, success) =
wml_menu_items_.emplace(
id, std::make_shared<wml_menu_item>(
id,
item));
236 WRN_NG <<
"duplicate menu item (" <<
id <<
") while loading from config";
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
config & add_child(config_key_type key)
void get_items(const map_location &hex, std::vector< std::shared_ptr< const wml_menu_item >> &items, std::vector< config > &descriptions, filter_context &fc, game_data &gamedata, unit_map &units) const
Returns the menu items that can be shown for the given location.
void init_handlers(game_lua_kernel &lk) const
Initializes the implicit event handlers for inlined [command]s.
bool empty() const
Returns true if no menu items are being managed.
std::shared_ptr< wml_menu_item > item_ptr
wml_menu_item pointers
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.
std::map< std::string, item_ptr > wml_menu_items_
bool erase(const std::string &id)
Erases the item with the provided id.
void to_config(config &cfg) const
item_ptr get_item(const std::string &id) const
Gets the menu item with the specified ID.
void set_item(const std::string &id, const vconfig &menu_item)
Updates or creates (as appropriate) the menu item with the given id.
~wmi_manager()
Destructor.
void set_menu_items(const config &cfg)
Sets the current menu items to the "menu_item" children of cfg.
bool can_use_synced_wml_menu() const
Container associating units to locations.
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
std::pair< std::string, unsigned > item
const std::vector< std::string > items
play_controller * controller
Encapsulates the map of the game.
const std::string & gamedata
static lg::log_domain log_engine("engine")
Declarations for a container for wml_menu_item.