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