Added cost of units recruited, recalled, killed, and lost,

...to the statistics window (patch #1190 by lizard).
This commit is contained in:
Guillaume Melquiond 2009-07-14 17:35:32 +00:00
parent 80714cbb5e
commit d10602a789
5 changed files with 38 additions and 7 deletions

View file

@ -18,6 +18,7 @@ Version 1.7.1+svn:
* Added support for desktop notifications using KDE's
org.kde.VisualNotifications DBus service
* Changed "Toggle Full Screen" button to say "Full Screen" (bug #13909)
* Added cost of units recruited, recalled, killed, and lost, to the statistics window (patch #1190)
* Miscellaneous and bugfixes:
* Fixed language switch not affecting unit descriptions (bug #13827)
* Fixed teleporting to impassable terrain (bug #13795)

View file

@ -911,6 +911,9 @@
[entry]
name = "Rocco J Carello (rogue)"
[/entry]
[entry]
name = "Rolf Sievers (Lizard)"
[/entry]
[entry]
name = "Ronny Standtke"
[/entry]

View file

@ -669,5 +669,15 @@ int sum_str_int_map(const stats::str_int_map& m)
return res;
}
int sum_cost_str_int_map(const stats::str_int_map &m)
{
int cost = 0;
for (stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) {
cost += i->second * unit_type_data::types().find_unit_type(i->first)->second.cost();
}
return cost;
}
} // end namespace statistics

View file

@ -66,6 +66,7 @@ namespace statistics
};
int sum_str_int_map(const stats::str_int_map& m);
int sum_cost_str_int_map(const stats::str_int_map &m);
struct disabler
{

View file

@ -115,48 +115,64 @@ statistics_dialog::statistics_dialog(game_display &disp,
gui::dialog::BUTTON_STANDARD);
stats_ = statistics::calculate_stats(0, team_id);
int n;
int n, cost;
std::vector<std::string> items;
// Prepare the menu items
{
std::stringstream str;
n = statistics::sum_str_int_map(stats_.recruits);
cost = stats_.recruit_cost;
unit_count_[0] = n;
str << _("Recruits") << COLUMN_SEPARATOR << n;
str << _("Recruits") << COLUMN_SEPARATOR << n
<< COLUMN_SEPARATOR
<< COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png"
<< COLUMN_SEPARATOR << cost;
items.push_back(str.str());
}
{
std::stringstream str;
n = statistics::sum_str_int_map(stats_.recalls);
cost = stats_.recall_cost;
unit_count_[1] = n;
str << _("Recalls") << COLUMN_SEPARATOR << n;
str << _("Recalls") << COLUMN_SEPARATOR << n
<< COLUMN_SEPARATOR
<< COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png"
<< COLUMN_SEPARATOR << cost;
items.push_back(str.str());
}
{
std::stringstream str;
n = statistics::sum_str_int_map(stats_.advanced_to);
unit_count_[2] = n;
str << _("Advancements") << COLUMN_SEPARATOR << n;
str << _("Advancements") << COLUMN_SEPARATOR << n;
items.push_back(str.str());
}
{
std::stringstream str;
n = statistics::sum_str_int_map(stats_.deaths);
unit_count_[3] = n;
str << _("Losses") << COLUMN_SEPARATOR << n;
cost = statistics::sum_cost_str_int_map(stats_.deaths);
str << _("Losses") << COLUMN_SEPARATOR << n
<< COLUMN_SEPARATOR
<< COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png"
<< COLUMN_SEPARATOR << cost;
items.push_back(str.str());
}
{
std::stringstream str;
n = statistics::sum_str_int_map(stats_.killed);
unit_count_[4] = n;
str << _("Kills") << COLUMN_SEPARATOR << n;
cost = statistics::sum_cost_str_int_map(stats_.killed);
str << _("Kills") << COLUMN_SEPARATOR << n
<< COLUMN_SEPARATOR
<< COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png"
<< COLUMN_SEPARATOR << cost;
items.push_back(str.str());
}
items.push_back("");
{
std::stringstream str;
str << font::BOLD_TEXT << _("Damage")
str << font::BOLD_TEXT << _("Damage")
<< COLUMN_SEPARATOR << _("Over All") << COLUMN_SEPARATOR
<< COLUMN_SEPARATOR
<< COLUMN_SEPARATOR << _("This Turn");