The Battle for Wesnoth  1.15.9+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  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
36  virtual const std::string& window_id() const override;
37 
38  /** Inherited from modal_dialog. */
39  virtual void pre_show(window& window) override;
40 
41  /**
42  * Picks out the stats structure that was selected for displaying.
43  */
44  inline const statistics::stats& current_stats();
45 
46  void add_stat_row(const std::string& type, const statistics::stats::str_int_map& value, const bool has_cost = true);
47 
48  /** Add a row to the Damage table */
49  void add_damage_row(
50  const std::string& type,
51  const long long& damage,
52  const long long& expected,
53  const long long& turn_damage,
54  const long long& turn_expected,
55  const bool show_this_turn);
56 
57  /**
58  * Add a row to the Hits table
59  * @param type
60  * @param more_is_better True for "Inflicted" and false for "Taken". Affects coloring.
61  * @param by_cth
62  * @param turn_by_cth
63  * @param show_this_turn
64  */
65  void add_hits_row(
66  const std::string& type,
67  const bool more_is_better,
68  const statistics::stats::hitrate_map& by_cth,
69  const statistics::stats::hitrate_map& turn_by_cth,
70  const bool show_this_turn);
71 
72  void update_lists();
73 
75  void on_scenario_select();
76 
78 
81 
82  std::size_t selection_index_;
83 
84  std::vector<const statistics::stats::str_int_map*> main_stat_table_;
85 };
86 
87 } // namespace dialogs
88 } // 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
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
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
Inherited from modal_dialog.
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