The Battle for Wesnoth  1.17.17+dev
mp_staging.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2023
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 
20 
21 class config;
23 
24 namespace ai
25 {
26  struct description;
27 }
28 
29 namespace gui2
30 {
31 class menu_button;
32 class slider;
33 class tree_view_node;
34 class player_list_helper;
35 
36 namespace dialogs
37 {
38 
39 class mp_staging : public modal_dialog, private plugin_executor
40 {
41 public:
42  mp_staging(ng::connect_engine& connect_engine, wesnothd_connection* connection = nullptr);
43 
44  ~mp_staging();
45 
47 
48 private:
49  virtual const std::string& window_id() const override;
50 
51  virtual void pre_show(window& window) override;
52 
53  virtual void post_show(window& window) override;
54 
55  template<typename... T>
57 
59 
60  /**
61  * Find an appropriate position to insert a side node.
62  *
63  * This ensures the side nodes are always arranged by descending index order
64  * in each team group.
65  */
67 
68  void on_controller_select(ng::side_engine_ptr side, grid& row_grid);
69  void on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu, const bool saved_game);
70  void on_color_select(ng::side_engine_ptr side, grid& row_grid);
71  void on_team_select(ng::side_engine_ptr side, menu_button& team_menu);
72 
73  template<void(ng::side_engine::*fptr)(int)>
75 
76  void select_leader_callback(ng::side_engine_ptr side, grid& row_grid);
77 
78  void update_leader_display(ng::side_engine_ptr side, grid& row_grid);
80 
81  void network_handler();
82 
84  {
85  state_changed_ = true;
86  }
87 
89 
90  std::vector<ai::description*> ai_algorithms_;
91 
93 
94  std::size_t update_timer_;
95 
97 
98  std::map<std::string, tree_view_node*> team_tree_map_;
99  std::map<ng::side_engine_ptr, tree_view_node*> side_tree_map_;
100 
101  std::unique_ptr<player_list_helper> player_list_;
102 };
103 
104 } // namespace dialogs
105 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
Abstract base class for all modal dialogs.
virtual const std::string & window_id() const override
The ID of the window to build.
void update_leader_display(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:457
void on_color_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:392
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: mp_staging.cpp:74
wesnothd_connection * network_connection_
Definition: mp_staging.hpp:92
int get_side_node_position(ng::side_engine_ptr side) const
Find an appropriate position to insert a side node.
Definition: mp_staging.cpp:125
mp_staging(ng::connect_engine &connect_engine, wesnothd_connection *connection=nullptr)
Definition: mp_staging.cpp:50
ng::connect_engine & connect_engine_
Definition: mp_staging.hpp:88
void on_controller_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:362
void select_leader_callback(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:440
void on_ai_select(ng::side_engine_ptr side, menu_button &ai_menu, const bool saved_game)
Definition: mp_staging.cpp:374
void on_team_select(ng::side_engine_ptr side, menu_button &team_menu)
Definition: mp_staging.cpp:401
std::map< ng::side_engine_ptr, tree_view_node * > side_tree_map_
Definition: mp_staging.hpp:99
void on_side_slider_change(ng::side_engine_ptr side, slider &slider)
Definition: mp_staging.cpp:450
std::unique_ptr< player_list_helper > player_list_
Definition: mp_staging.hpp:101
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: mp_staging.cpp:572
std::vector< ai::description * > ai_algorithms_
Definition: mp_staging.hpp:90
std::map< std::string, tree_view_node * > team_tree_map_
Definition: mp_staging.hpp:98
tree_view_node & add_side_to_team_node(ng::side_engine_ptr side, T &&... params)
Definition: mp_staging.cpp:138
void add_side_node(ng::side_engine_ptr side)
Definition: mp_staging.cpp:165
Base container class.
Definition: grid.hpp:32
A menu_button is a styled_widget to choose an element from a list of elements.
Definition: menu_button.hpp:62
A slider is a control that can select a value by moving a grip on a groove.
Definition: slider.hpp:60
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:67
A class that represents a TCP/IP connection to the wesnothd server.
#define DEFINE_SIMPLE_EXECUTE_WRAPPER(dialog)
Adds a bare-bonesstatic execute function to a dialog class that immediately invokes and return the re...
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:61
Various uncategorised dialogs.
Generic file dialog.
std::shared_ptr< side_engine > side_engine_ptr