Add current gold and troops count to Load Game dialog (resolves #4180)
I'll let @vultraz pretty it up a little if he wants. Note that old saves won't show this info; it'll only show up in new saves. It might show up for old saves if you clear your cache, though.
This commit is contained in:
parent
6ea57e78f4
commit
99693041b1
3 changed files with 96 additions and 7 deletions
|
@ -47,10 +47,78 @@
|
|||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[label]
|
||||
id = "leader_name"
|
||||
definition = "default_small"
|
||||
[/label]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
id = "leader_name"
|
||||
definition = "default_small"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
label = _"Gold Left:"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[label]
|
||||
id = "leader_gold"
|
||||
definition = "default_small"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
#po: Refers to units on the map
|
||||
label = _"Active Troops:"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[label]
|
||||
id = "leader_troops"
|
||||
definition = "default_small"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
#po: Refers to units on the recall list
|
||||
label = _"Reserve Troops:"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[label]
|
||||
id = "leader_reserves"
|
||||
definition = "default_small"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
|
|
|
@ -198,6 +198,15 @@ void game_load::display_savegame(window& window)
|
|||
item["label"] = leader["leader_name"];
|
||||
data.emplace("leader_name", item);
|
||||
|
||||
item["label"] = leader["gold"];
|
||||
data.emplace("leader_gold", item);
|
||||
|
||||
item["label"] = leader["units"];
|
||||
data.emplace("leader_troops", item);
|
||||
|
||||
item["label"] = leader["recall_units"];
|
||||
data.emplace("leader_reserves", item);
|
||||
|
||||
leader_list.add_row(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -373,6 +373,8 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
|||
std::string leader_image;
|
||||
std::string leader_image_tc_modifier;
|
||||
std::string leader_name;
|
||||
int gold = side["gold"];
|
||||
int units = 0, recall_units = 0;
|
||||
|
||||
if(side["controller"] != team::CONTROLLER::enum_to_string(team::CONTROLLER::HUMAN)) {
|
||||
continue;
|
||||
|
@ -383,16 +385,23 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
|||
}
|
||||
|
||||
for(const config &u : side.child_range("unit")) {
|
||||
if(!u["canrecruit"].to_bool()) {
|
||||
if(u.has_attribute("x") && u.has_attribute("y")) {
|
||||
units++;
|
||||
} else {
|
||||
recall_units++;
|
||||
}
|
||||
|
||||
// Only take the first leader
|
||||
if(!leader.empty() || !u["canrecruit"].to_bool()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't count it among the troops
|
||||
units--;
|
||||
leader = u["id"].str();
|
||||
leader_name = u["name"].str();
|
||||
leader_image = u["image"].str();
|
||||
leader_image_tc_modifier = "~RC(" + u["flag_rgb"].str() + ">" + u["side"].str() + ")";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// We need a binary path-independent path to the leader image here so it can be displayed
|
||||
|
@ -413,6 +422,9 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
|||
leader_config["leader_name"] = leader_name;
|
||||
leader_config["leader_image"] = leader_image;
|
||||
leader_config["leader_image_tc_modifier"] = leader_image_tc_modifier;
|
||||
leader_config["gold"] = gold;
|
||||
leader_config["units"] = units;
|
||||
leader_config["recall_units"] = recall_units;
|
||||
|
||||
cfg_summary.add_child("leader", leader_config);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue