The Battle for Wesnoth  1.17.0-dev
game_stats.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 
16 #include "game_board.hpp"
17 #include "gettext.hpp"
20 #include "team.hpp"
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 class display;
27 class team;
28 struct team_data;
29 
30 namespace gui2::dialogs
31 {
32 
33 class game_stats : public modal_dialog
34 {
35 public:
36  game_stats(const display_context& board, const int viewing_team, int& selected_side_number);
37 
38  static bool execute(game_board& board, const int viewing_team, int& selected_side_number)
39  {
40  if(std::all_of(board.teams().begin(), board.teams().end(), [](team& team) { return team.hidden(); })) {
41  show_transient_message("", _("No visible sides found."));
42  return false;
43  }
44 
45  return game_stats(board, viewing_team, selected_side_number).show();
46  }
47 
48 private:
49  // TODO: don't like having this
51 
53 
54  std::vector<team_data> team_data_;
55 
57 
58  unit_const_ptr get_leader(const int side);
59 
60  void on_tab_select();
61 
62  virtual const std::string& window_id() const override;
63 
64  virtual void pre_show(window& window) override;
65 
66  virtual void post_show(window& window) override;
67 };
68 
69 } // namespace dialogs
Game board class.
Definition: game_board.hpp:50
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:84
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
static std::string _(const char *str)
Definition: gettext.hpp:92
const team & viewing_team_
Definition: game_stats.hpp:52
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:26
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:71
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: game_stats.cpp:257
static bool execute(game_board &board, const int viewing_team, int &selected_side_number)
Definition: game_stats.hpp:38
virtual const std::string & window_id() const override
The id of the window to build.
bool hidden() const
Definition: team.hpp:359
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: game_stats.cpp:73
game_stats(const display_context &board, const int viewing_team, int &selected_side_number)
Definition: game_stats.cpp:49
std::vector< team_data > team_data_
Definition: game_stats.hpp:54
Abstract base class for all modal dialogs.
unit_const_ptr get_leader(const int side)
Definition: game_stats.cpp:56
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64
const display_context & board_
Definition: game_stats.hpp:50