The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
game_stats.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 - 2025
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
17#include "game_board.hpp"
18#include "gettext.hpp"
21#include "team.hpp"
22
23#include <string>
24#include <vector>
25
26
27namespace gui2::dialogs
28{
29
31{
32public:
33 game_stats(const display_context& board, const team& viewing_team, int& selected_side_number);
34
35 static bool execute(game_board& board, const team& viewing_team, int& selected_side_number)
36 {
37 if(std::all_of(board.teams().begin(), board.teams().end(), [](team& team) { return team.hidden(); })) {
38 show_transient_message("", _("No visible sides found."));
39 return false;
40 }
41
42 return game_stats(board, viewing_team, selected_side_number).show();
43 }
44
45private:
46 // TODO: don't like having this
48
50
51 std::vector<team_data> team_data_;
52
54
55 unit_const_ptr get_leader(const int side);
56
57 void on_tab_select();
58
59 virtual const std::string& window_id() const override;
60
61 virtual void pre_show() override;
62
63 virtual void post_show() override;
64};
65
66} // namespace dialogs
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
Game board class.
virtual const std::vector< team > & teams() const override
unit_const_ptr get_leader(const int side)
virtual void post_show() override
Actions to be taken after the window has been shown.
std::vector< team_data > team_data_
static bool execute(game_board &board, const team &viewing_team, int &selected_side_number)
const display_context & board_
virtual void pre_show() override
Actions to be taken before showing the window.
virtual const std::string & window_id() const override
The ID of the window to build.
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
This class stores all the data for a single 'side' (in game nomenclature).
Definition team.hpp:74
static std::string _(const char *str)
Definition gettext.hpp:100
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)
Shows a transient message to the user.
std::shared_ptr< const unit > unit_const_ptr
Definition ptr.hpp:27