The Battle for Wesnoth  1.15.2+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
31 {
32 namespace dialogs
33 {
34 
35 class game_stats : public modal_dialog
36 {
37 public:
38  game_stats(const display_context& board, const int viewing_team, int& selected_side_number);
39 
40  static bool execute(game_board& board, const int viewing_team, int& selected_side_number)
41  {
42  if(std::all_of(board.teams().begin(), board.teams().end(), [](team& team) { return team.hidden(); })) {
43  show_transient_message("", _("No visible sides found."));
44  return false;
45  }
46 
47  return game_stats(board, viewing_team, selected_side_number).show();
48  }
49 
50 private:
51  // TODO: don't like having this
53 
55 
56  std::vector<team_data> team_data_;
57 
59 
60  unit_const_ptr get_leader(const int side);
61 
63 
64  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
65  virtual const std::string& window_id() const override;
66 
67  /** Inherited from modal_dialog. */
68  virtual void pre_show(window& window) override;
69 
70  /** Inherited from modal_dialog. */
71  virtual void post_show(window& window) override;
72 };
73 
74 } // namespace dialogs
75 } // namespace gui2
boost::intrusive_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:30
Game board class.
Definition: game_board.hpp:50
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:92
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.
-file sdl_utils.hpp
Generic file dialog.
Definition: field-fwd.hpp:22
const team & viewing_team_
Definition: game_stats.hpp:54
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:91
virtual void post_show(window &window) override
Inherited from modal_dialog.
Definition: game_stats.cpp:259
static bool execute(game_board &board, const int viewing_team, int &selected_side_number)
Definition: game_stats.hpp:40
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
void on_tab_select(window &window)
Definition: game_stats.cpp:247
Various uncategorised dialogs.
bool hidden() const
Definition: team.hpp:347
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: game_stats.cpp:75
game_stats(const display_context &board, const int viewing_team, int &selected_side_number)
Definition: game_stats.cpp:51
std::vector< team_data > team_data_
Definition: game_stats.hpp:56
Abstract base class for all modal dialogs.
unit_const_ptr get_leader(const int side)
Definition: game_stats.cpp:58
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
const display_context & board_
Definition: game_stats.hpp:52