The Battle for Wesnoth  1.15.1+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(window& window, 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  window& window,
51  const std::string& type,
52  const long long& damage,
53  const long long& expected,
54  const long long& turn_damage,
55  const long long& turn_expected,
56  const bool show_this_turn);
57 
58  /// Add a row to the Hits table
59  ///
60  /// @param more_is_better True for "Inflicted" and false for "Taken". Affects coloring.
61  void add_hits_row(
62  window& window,
63  const std::string& type,
64  const bool more_is_better,
65  const statistics::stats::hitrate_map& by_cth,
66  const statistics::stats::hitrate_map& turn_by_cth,
67  const bool show_this_turn);
68 
69  void update_lists(window& window);
70 
71  void on_primary_list_select(window& window);
72  void on_scenario_select(window& window);
73 
75 
78 
79  std::size_t selection_index_;
80 
81  std::vector<const statistics::stats::str_int_map*> main_stat_table_;
82 };
83 
84 } // namespace dialogs
85 } // namespace gui2
void add_damage_row(window &window, 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 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:71
void add_hits_row(window &window, 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.
statistics_dialog(const team &current_team)
std::vector< std::pair< const std::string *, const stats * > > levels
Stats (and name) for each scenario. The pointers are never nullptr.
Definition: statistics.hpp:137
Generic file dialog.
Definition: field-fwd.hpp:22
void add_stat_row(window &window, const std::string &type, const statistics::stats::str_int_map &value, const bool has_cost=true)
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.
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_
void on_primary_list_select(window &window)
std::map< std::string, int > str_int_map
Definition: statistics.hpp:37
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:63