45 #define ERR_NG LOG_STREAM(err, log_engine)
46 #define LOG_NG LOG_STREAM(info, log_engine)
62 return std::string(
"menu item") + (
id.empty() ?
"" :
' ' +
id);
85 event_name_(make_item_name(id)),
86 hotkey_id_(make_item_hotkey(id)),
87 image_(cfg[
"image"].str()),
88 description_(cfg[
"description"].t_str()),
89 needs_select_(cfg[
"needs_select"].to_bool(false)),
90 show_if_(cfg.child_or_empty(
"show_if"), true),
91 filter_location_(cfg.child_or_empty(
"filter_location"), true),
92 command_(cfg.child_or_empty(
"command")),
93 default_hotkey_(cfg.child_or_empty(
"default_hotkey")),
94 use_hotkey_(cfg[
"use_hotkey"].to_bool(true)),
95 use_wml_menu_(cfg[
"use_hotkey"].str() !=
"only"),
96 is_synced_(cfg[
"synced"].to_bool(true))
109 event_name_(make_item_name(id)),
110 hotkey_id_(make_item_hotkey(id)),
113 needs_select_(false),
114 show_if_(
vconfig::empty_vconfig()),
115 filter_location_(
vconfig::empty_vconfig()),
141 event_name_(make_item_name(id)),
142 hotkey_id_(make_item_hotkey(id)),
144 description_(original.description_),
145 needs_select_(original.needs_select_),
146 show_if_(original.show_if_),
147 filter_location_(original.filter_location_),
148 command_(original.command_),
149 default_hotkey_(original.default_hotkey_),
150 use_hotkey_(original.use_hotkey_),
151 use_wml_menu_(original.use_wml_menu_),
152 is_synced_(original.is_synced_)
276 cfg[
"use_hotkey"] =
true;
278 cfg[
"use_hotkey"] =
"only";
280 cfg[
"use_hotkey"] =
false;
283 ERR_NG <<
"Bad data: wml_menu_item with both use_wml_menu and use_hotkey set to false is not supposed to be possible.";
284 cfg[
"use_hotkey"] =
false;
304 bool hotkey_updated =
false;
307 image_ = vcfg[
"image"].str();
311 hotkey_updated =
true;
324 if (
const vconfig & child = vcfg.
child(
"filter_location") ) {
329 if (
const vconfig & child = vcfg.
child(
"default_hotkey") ) {
331 hotkey_updated =
true;
342 const bool delayed = cmd[
"delayed_variable_substitution"].to_bool(
true);
343 update_command(delayed ? cmd.get_config() : cmd.get_parsed_config());
372 if ( hand->is_menu_item() ) {
381 if ( new_command.
empty() )
392 command_[
"first_time_only"] =
false;
void remove_event_handler(const std::string &id)
Removes an event handler.
map_location last_selected
the last location where a select event fired.
vconfig child(const std::string &key) const
Returns a child of *this whose key is key.
bool to_bool(bool def=false) const
void add_wml_hotkey(const std::string &id, const t_string &description, const config &default_hotkey)
adds a new wml hotkey to the list, but only if there is no hotkey with that id yet on the list...
surface image_
The image is cached in this surface.
bool fire(const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
Function to fire an event.
an object to leave the synced context during draw or unsynced wml items when we don’t know whether w...
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
bool empty() const
Tests for an attribute that either was never set or was set to "".
This file implements all the hotkey handling and menu details for play controller.
Variant for storing WML attributes.
filter_context * filter_con
config & add_child(const std::string &key)
game_events::manager * game_events
static const std::string wml_menu_hotkey_prefix
Encapsulates the map of the game.
Define conditionals for the game's events mechanism, a.k.a.
void add_event_handler(const config &handler, bool is_menu_item=false)
Create an event handler.
const config & get_config() const
Define the game's event mechanism.
This class is similar to an input iterator through event handlers, except each instance knows its own...
game_events::t_pump & pump()
static bool run_and_throw(const std::string &commandname, const config &data, bool use_undo=true, bool show=true, synced_command::error_handler_function error_handler=default_error_function)
bool conditional_passed(const vconfig &cond)
Define the handlers for the game's events mechanism.
static bool run_in_synced_context_if_not_already(const std::string &commandname, const config &data, bool use_undo=true, bool show=true, synced_command::error_handler_function error_handler=default_error_function)
checks whether we are currently running in a synced context, and if not we enters it...
A variable-expanding proxy for the config class.
Various functions that implement the undoing (and redoing) of in-game commands.
Standard logging facilities (interface).
A config object defines a single node in a WML file, with access to child nodes.
static config get_event(const std::string &name, const map_location &loc, const map_location *last_select_loc)
void make_safe() const
instruct the vconfig to make a private copy of its underlying data.
bool remove_wml_hotkey(const std::string &id)
removes a wml hotkey with the given id, returns true if the deletion was successful ...
GLsizei const GLcharARB ** string
bool has_attribute(const std::string &key) const
< Synonym for operator[]