Let event handlers of menu item commands have an id.

Unless both the menu item and its command tag didn't have an id.

Makes it possible to remove the resulting event handler
in the same way [event]remove=yes removes events.
Unless I'm badly mistaken, event handlers caused by a menu item's command
should already be unique, so no id collisions are expected.
This commit is contained in:
Anonymissimus 2012-01-29 22:50:47 +00:00
parent b99a21ad96
commit 229d764a3e
3 changed files with 8 additions and 0 deletions

View File

@ -2979,6 +2979,12 @@ static void commit_wmi_commands() {
wml_menu_item*& mref = resources::state_of_game->wml_menu_items[wcc.first];
const bool has_current_handler = !mref->command.empty();
config::attribute_value event_id = (*wcc.second)["id"];
if(event_id.empty()) {
event_id = mref->event_id;
if(!event_id.empty())
(*wcc.second)["id"] = event_id;
}
mref->command = *(wcc.second);
mref->command["name"] = mref->name;
mref->command["first_time_only"] = false;

View File

@ -1001,6 +1001,7 @@ void game_state::write_config(config_writer& out, bool write_variables) const
wml_menu_item::wml_menu_item(const std::string& id, const config* cfg) :
name(),
event_id(id),
image(),
description(),
needs_select(false),

View File

@ -69,6 +69,7 @@ struct wml_menu_item
{
wml_menu_item(const std::string& id, const config* cfg=NULL);
std::string name;
const std::string event_id;
std::string image;
t_string description;
bool needs_select;