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