a fifth step towards supporting WML menu items

- complete the local firing mechanism
This commit is contained in:
Patrick Parker 2007-03-26 06:30:41 +00:00
parent 980cad8a2f
commit b5ad057b8b
3 changed files with 18 additions and 3 deletions

View file

@ -1721,9 +1721,10 @@ bool event_handler::handle_event_command(const queued_event& event_info,
[/command]
[/set_menu_item]
*/
wml_menu_item*& mref = state_of_game->wml_menu_items[cfg["id"]];
std::string id = cfg["id"];
wml_menu_item*& mref = state_of_game->wml_menu_items[id];
if(mref == NULL) {
mref = new wml_menu_item();
mref = new wml_menu_item(id);
}
if(cfg.has_attribute("image")) {
mref->image = cfg["image"];
@ -1739,6 +1740,11 @@ bool event_handler::handle_event_command(const queued_event& event_info,
}
if(cfg.has_child("command")) {
mref->command = cfg.child("command").get_config();
mref->command["name"] = mref->name;
mref->command["first_time_only"] = "no";
event_handler new_handler(mref->command);
events_map.insert(std::pair<std::string,event_handler>(
new_handler.name(), new_handler));
}
}
//unit serialization to and from variables

View file

@ -50,6 +50,15 @@ struct time_of_day
struct wml_menu_item
{
wml_menu_item(const std::string& id) {
std::stringstream temp;
temp << "menu item";
if(!id.empty()) {
temp << ' ' << id;
}
name = temp.str();
}
std::string name;
std::string image;
t_string description;
config show_if;

View file

@ -460,7 +460,7 @@ bool play_controller::execute_command(hotkey::HOTKEY_COMMAND command, int index)
throw game::load_game_exception(savenames_[i],false);
} else if (i < wml_commands_.size() && wml_commands_[i] != NULL) {
//TODO: wml command execute
game_events::fire(wml_commands_[i]->name, mouse_handler_.get_last_hex());
return true;
}
}