Hit stats: Show number of hits/misses inflicted overall in statistics dialog.
This commit is contained in:
parent
38641d667a
commit
ed22925dd1
3 changed files with 76 additions and 7 deletions
|
@ -108,9 +108,9 @@
|
|||
[/listbox]
|
||||
#enddef
|
||||
|
||||
#define _GUI_DAMAGE_STATS_LIST
|
||||
#define _GUI_DAMAGE_STATS_LIST top_left_label overall_id colid_type colid_overall colid_this_turn
|
||||
[listbox]
|
||||
id = "stats_list_damage"
|
||||
id = {overall_id}
|
||||
definition = "default"
|
||||
|
||||
horizontal_scrollbar_mode = "never"
|
||||
|
@ -126,7 +126,7 @@
|
|||
|
||||
[label]
|
||||
definition = "default_small"
|
||||
label = _ "Damage"
|
||||
label = {top_left_label}
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
[/column]
|
||||
|
@ -181,7 +181,7 @@
|
|||
horizontal_grow = true
|
||||
|
||||
[label]
|
||||
id = "damage_type"
|
||||
id = {colid_type}
|
||||
definition = "default"
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
|
@ -194,7 +194,7 @@
|
|||
horizontal_grow = true
|
||||
|
||||
[label]
|
||||
id = "damage_overall"
|
||||
id = {colid_overall}
|
||||
definition = "default_small"
|
||||
linked_group = "detail"
|
||||
[/label]
|
||||
|
@ -207,7 +207,7 @@
|
|||
horizontal_grow = true
|
||||
|
||||
[label]
|
||||
id = "damage_this_turn"
|
||||
id = {colid_this_turn}
|
||||
definition = "default_small"
|
||||
linked_group = "cost"
|
||||
[/label]
|
||||
|
@ -481,7 +481,21 @@
|
|||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
|
||||
{_GUI_DAMAGE_STATS_LIST}
|
||||
{_GUI_DAMAGE_STATS_LIST (_ "Damage") stats_list_damage damage_type damage_overall damage_this_turn}
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
|
||||
{_GUI_DAMAGE_STATS_LIST (_ "Hits") stats_list_hits hits_type hits_overall hits_this_turn}
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
|
|
@ -161,6 +161,45 @@ void statistics_dialog::add_damage_row(
|
|||
damage_list.add_row(data);
|
||||
}
|
||||
|
||||
void statistics_dialog::add_hits_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& by_cth,
|
||||
const bool show_this_turn)
|
||||
{
|
||||
listbox& hits_list = find_widget<listbox>(&window, "stats_list_hits", false);
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
string_map item;
|
||||
|
||||
std::ostringstream str;
|
||||
|
||||
item["label"] = type;
|
||||
data.emplace("hits_type", item);
|
||||
|
||||
int overall_hits = 0;
|
||||
double expected_hits = 0;
|
||||
|
||||
for(const auto& i : by_cth) {
|
||||
int cth = i.first;
|
||||
overall_hits += i.second.hits;
|
||||
expected_hits += (cth * 0.01) * i.second.strikes;
|
||||
}
|
||||
|
||||
str.str("");
|
||||
str << overall_hits << " / " << expected_hits;
|
||||
|
||||
item["label"] = str.str();
|
||||
data.emplace("hits_overall", item);
|
||||
|
||||
if(show_this_turn) {
|
||||
item["label"] = "";
|
||||
data.emplace("hits_this_turn", item);
|
||||
}
|
||||
|
||||
hits_list.add_row(data);
|
||||
}
|
||||
|
||||
void statistics_dialog::update_lists(window& window)
|
||||
{
|
||||
//
|
||||
|
@ -197,6 +236,9 @@ void statistics_dialog::update_lists(window& window)
|
|||
|
||||
damage_list.clear();
|
||||
|
||||
listbox& hits_list = find_widget<listbox>(&window, "stats_list_hits", false);
|
||||
hits_list.clear();
|
||||
|
||||
add_damage_row(window, _("Inflicted"),
|
||||
stats.damage_inflicted,
|
||||
stats.expected_damage_inflicted,
|
||||
|
@ -204,6 +246,10 @@ void statistics_dialog::update_lists(window& window)
|
|||
stats.turn_expected_damage_inflicted,
|
||||
show_this_turn
|
||||
);
|
||||
add_hits_row(window, _("Inflicted"),
|
||||
stats.by_cth,
|
||||
show_this_turn
|
||||
);
|
||||
|
||||
add_damage_row(window, _("Taken"),
|
||||
stats.damage_taken,
|
||||
|
@ -212,6 +258,7 @@ void statistics_dialog::update_lists(window& window)
|
|||
stats.turn_expected_damage_taken,
|
||||
show_this_turn
|
||||
);
|
||||
// TODO add by_cth_taken/by_cth_inflicted
|
||||
}
|
||||
|
||||
void statistics_dialog::on_scenario_select(window& window)
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
|
||||
void add_stat_row(window& window, const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost = true);
|
||||
|
||||
/// Add a row to the Damage table
|
||||
void add_damage_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
|
@ -54,6 +55,13 @@ private:
|
|||
const long long& turn_expected,
|
||||
const bool show_this_turn);
|
||||
|
||||
/// Add a row to the Hits table
|
||||
void add_hits_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& by_cth,
|
||||
const bool show_this_turn);
|
||||
|
||||
void update_lists(window& window);
|
||||
|
||||
void on_primary_list_select(window& window);
|
||||
|
|
Loading…
Add table
Reference in a new issue