Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void statistics_dialog::pre_show(window& window)
- {
- const bool show_this_turn = use_campaign_ || scenario_index_ + 1 == scenarios_.size();
- std::vector<config> menu_items;
- for(const auto& scenario : scenarios_) {
- menu_items.push_back(config_of("label", *scenario.first));
- }
- find_widget<menu_button>(&window, "scenario_list", false).set_values(menu_items, scenario_index_);
- const statistics::stats& stats = current_stats();
- listbox& stat_list = find_widget<listbox>(&window, "stats_list_main", false);
- std::map<std::string, string_map> data;
- string_map item;
- const auto add_stat_row = [&](const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost = true) {
- item["label"] = type;
- data.emplace("stat_type", item);
- item["label"] = std::to_string(statistics::sum_str_int_map(value));
- data.emplace("stat_detail", item);
- item["label"] = has_cost ? std::to_string(statistics::sum_cost_str_int_map(value)) : font::unicode_em_dash;
- data.emplace("stat_cost", item);
- stat_list.add_row(data);
- data.clear();
- item.clear();
- };
- add_stat_row(_("Recruits"), stats.recruits);
- add_stat_row(_("Recalls"), stats.recalls);
- add_stat_row(_("Advancements"), stats.advanced_to, false);
- add_stat_row(_("Losses"), stats.deaths);
- add_stat_row(_("Kills"), stats.killed);
- listbox& damage_list = find_widget<listbox>(&window, "stats_list_damage", false);
- const auto add_damage_row = [&](
- const std::string& type,
- const long long& damage,
- const long long& expected,
- const long long& turn_damage,
- const long long& turn_expected)
- {
- item["label"] = type;
- data.emplace("damage_type", item);
- const int shift = statistics::stats::decimal_shift;
- const long long dsa = shift * damage - expected;
- const long long dst = shift * turn_damage - turn_expected;
- std::ostringstream str;
- str << damage << " / "
- << (expected * 10 + shift / 2) / shift * 0.1
- << " " // TODO: should probably make this two columns
- << ((dsa < 0) ^ (expected < 0) ? "" : "+")
- << (expected == 0 ? 0 : 100 * dsa / expected) << '%';
- item["label"] = str.str();
- data.emplace("damage_overall", item);
- str.clear();
- if(show_this_turn) {
- str << turn_damage << " / "
- << (turn_expected * 10 + shift / 2) / shift * 0.1
- << " " // TODO: should probably make this two columns
- << ((dst < 0) ^ (turn_expected < 0) ? "" : "+")
- << (turn_expected == 0 ? 0 : 100 * dst / turn_expected) << '%';
- item["label"] = str.str();
- data.emplace("damage_this_turm", item);
- }
- damage_list.add_row(data);
- data.clear();
- item.clear();
- };
- add_damage_row(_("Inflicted"),
- stats.damage_inflicted,
- stats.expected_damage_inflicted,
- stats.turn_damage_inflicted,
- stats.turn_expected_damage_inflicted);
- add_damage_row(_("Taken"),
- stats.damage_taken,
- stats.expected_damage_taken,
- stats.turn_damage_taken,
- stats.turn_expected_damage_taken);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement