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)) {
116 std::vector<config>& items,
141 && item->can_show(hex,
gamedata, fc)) {
143 items.emplace_back(
"id", item->hotkey_id() ,
"label", item->menu_text(),
"icon", item->image());
174 unsigned wmi_count = 0;
179 item.second->init_handler(lk);
187 LOG_NG << wmi_count <<
" WML menu items found, loaded.";
196 item.second->to_config(cfg.
add_child(
"menu_item"));
206 auto [iter, success] =
wml_menu_items_.emplace(
id, std::make_shared<wml_menu_item>(
id, menu_item));
212 iter->second.reset(
new wml_menu_item(
id, menu_item, *iter->second));
223 if(!item.has_attribute(
"id")) {
227 const std::string&
id = item[
"id"];
230 std::tie(std::ignore, success) =
wml_menu_items_.emplace(
id, std::make_shared<wml_menu_item>(
id, item));
233 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< config > &items, 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.
Definitions for the interface to Wesnoth Markup Language (WML).
Standard logging facilities (interface).
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.