mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 02:01:15 +00:00
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:
parent
b99a21ad96
commit
229d764a3e
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user