The Battle for Wesnoth  1.15.12+dev
statistics_dialog.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
17 #include "statistics.hpp"
18 
19 class team;
20 
21 namespace gui2
22 {
23 
24 namespace dialogs
25 {
26 
28 {
29 public:
30  statistics_dialog(const team& current_team);
31 
33 
34 private:
35  virtual const std::string& window_id() const override;
36 
37  virtual void pre_show(window& window) override;
38 
39  /**
40  * Picks out the stats structure that was selected for displaying.
41  */
42  inline const statistics::stats& current_stats();
43 
44  void add_stat_row(const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost = true);
45 
46  /** Add a row to the Damage table */
47  void add_damage_row(
48  const std::string& type,
49  const long long& damage,
50  const long long& expected,
51  const long long& turn_damage,
52  const long long& turn_expected,
53  const bool show_this_turn);
54 
55  /**
56  * Add a row to the Hits table
57  * @param type
58  * @param more_is_better True for "Inflicted" and false for "Taken". Affects coloring.
59  * @param by_cth
60  * @param turn_by_cth
61  * @param show_this_turn
62  */
63  void add_hits_row(
64  const std::string& type,
65  const bool more_is_better,
66  const statistics::stats::hitrate_map& by_cth,
67  const statistics::stats::hitrate_map& turn_by_cth,
68  const bool show_this_turn);
69 
70  void update_lists();
71 
73  void on_scenario_select();
74 
76 
79 
80  std::size_t selection_index_;
81 
82  std::vector<const statistics::stats::str_int_map*> main_stat_table_;
83 };
84 
85 } // namespace dialogs
86 } // namespace gui2
void add_hits_row(const std::string &type, const bool more_is_better, const statistics::stats::hitrate_map &by_cth, const statistics::stats::hitrate_map &turn_by_cth, const bool show_this_turn)
Add a row to the Hits table.
const statistics::stats campaign_
const statistics::levels scenarios_
std::map< int, hitrate_t > hitrate_map
A type that maps chance-to-hit percentage to number of hits and strikes at that CTH.
Definition: statistics.hpp:69
statistics_dialog(const team &current_team)
std::vector< std::pair< const std::string *, const stats * > > levels
Stats (and name) for each scenario.
Definition: statistics.hpp:135
Generic file dialog.
Definition: field-fwd.hpp:22
virtual const std::string & window_id() const override
The id of the window to build.
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void add_stat_row(const std::string &type, const statistics::stats::str_int_map &value, const bool has_cost=true)
void 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, const bool show_this_turn)
Add a row to the Damage table.
const statistics::stats & current_stats()
Picks out the stats structure that was selected for displaying.
Various uncategorised dialogs.
std::vector< const statistics::stats::str_int_map * > main_stat_table_
std::map< std::string, int > str_int_map
Definition: statistics.hpp:35
Abstract base class for all modal dialogs.
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64