support for saving WML menu items
(still need to add support for loading them)
This commit is contained in:
parent
8c65338fdd
commit
33389cb140
1 changed files with 29 additions and 0 deletions
|
@ -627,6 +627,21 @@ void write_game(const game_state& gamestate, config& cfg, WRITE_GAME_MODE mode)
|
|||
cfg["campaign_define"] = gamestate.campaign_define;
|
||||
|
||||
cfg.add_child("variables",gamestate.get_variables());
|
||||
cfg.add_child("menu_items",gamestate.get_variables());
|
||||
for(std::map<std::string, wml_menu_item *>::const_iterator j=gamestate.wml_menu_items.begin();
|
||||
j!=gamestate.wml_menu_items.end(); ++j) {
|
||||
config new_cfg;
|
||||
new_cfg["id"]=j->first;
|
||||
new_cfg["image"]=j->second->image;
|
||||
new_cfg["description"]=j->second->description;
|
||||
if(!j->second->show_if.empty())
|
||||
new_cfg.add_child("show_if", j->second->show_if);
|
||||
if(!j->second->location_filter.empty())
|
||||
new_cfg.add_child("location_filter", j->second->location_filter);
|
||||
if(!j->second->command.empty())
|
||||
new_cfg.add_child("command", j->second->command);
|
||||
cfg.add_child("set_menu_item", new_cfg);
|
||||
}
|
||||
|
||||
for(std::map<std::string, player_info>::const_iterator i=gamestate.players.begin();
|
||||
i!=gamestate.players.end(); ++i) {
|
||||
|
@ -659,6 +674,20 @@ void write_game(config_writer &out, const game_state& gamestate, WRITE_GAME_MODE
|
|||
out.write_key_val("difficulty", gamestate.difficulty);
|
||||
out.write_key_val("campaign_define", gamestate.campaign_define);
|
||||
out.write_child("variables", gamestate.get_variables());
|
||||
for(std::map<std::string, wml_menu_item *>::const_iterator j=gamestate.wml_menu_items.begin();
|
||||
j!=gamestate.wml_menu_items.end(); ++j) {
|
||||
out.open_child("set_menu_item");
|
||||
out.write_key_val("id", j->first);
|
||||
out.write_key_val("image", j->second->image);
|
||||
out.write_key_val("description", j->second->description);
|
||||
if(!j->second->show_if.empty())
|
||||
out.write_child("show_if", j->second->show_if);
|
||||
if(!j->second->location_filter.empty())
|
||||
out.write_child("location_filter", j->second->location_filter);
|
||||
if(!j->second->command.empty())
|
||||
out.write_child("command", j->second->command);
|
||||
out.close_child("set_menu_item");
|
||||
}
|
||||
|
||||
for(std::map<std::string, player_info>::const_iterator i=gamestate.players.begin();
|
||||
i!=gamestate.players.end(); ++i) {
|
||||
|
|
Loading…
Add table
Reference in a new issue