The Battle for Wesnoth  1.19.0-dev
mp_join_game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
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 
19 
20 class saved_game;
22 
23 namespace gui2
24 {
25 class tree_view_node;
26 class player_list_helper;
27 
28 namespace dialogs
29 {
30 class faction_select;
31 
32 class mp_join_game : public modal_dialog, private plugin_executor
33 {
34 public:
35  mp_join_game(saved_game& state, wesnothd_connection& connection,
36  const bool first_scenario = true, const bool observe_game = false);
37 
38  ~mp_join_game();
39 
40  bool fetch_game_config();
41  bool started() const { return level_["started"].to_bool(); }
42 private:
43  virtual const std::string& window_id() const override;
44 
45  virtual void pre_show(window& window) override;
46 
47  virtual void post_show(window& window) override;
48 
49  /** @returns false if an error ocurred. */
50  bool show_flg_select(int side_num, bool first_time = false);
51 
52  void generate_side_list();
53 
54  /**
55  * Will close the Faction Select dialog if it's open.
56  *
57  * This is used in @ref network_handler to dismiss the dialog if certain actions
58  * occur, such as the game starting.
59  *
60  * @todo maybe move this to a general-purpose close() function in @ref modal_dialog
61  * and @ref modeless_dialog? It could be useful.
62  */
64 
65  void network_handler();
66 
68 
70 
72 
74 
75  std::size_t update_timer_;
76 
77  const bool first_scenario_;
78 
81 
82  std::map<std::string, tree_view_node*> team_tree_map_;
83 
84  std::unique_ptr<player_list_helper> player_list_;
85 
87 };
88 
89 } // namespace dialogs
90 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Abstract base class for all modal dialogs.
mp_join_game(saved_game &state, wesnothd_connection &connection, const bool first_scenario=true, const bool observe_game=false)
std::unique_ptr< player_list_helper > player_list_
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
virtual const std::string & window_id() const override
The ID of the window to build.
faction_select * flg_dialog_
std::map< std::string, tree_view_node * > team_tree_map_
bool show_flg_select(int side_num, bool first_time=false)
void close_faction_select_dialog_if_open()
Will close the Faction Select dialog if it's open.
wesnothd_connection & network_connection_
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
A class that represents a TCP/IP connection to the wesnothd server.
Various uncategorised dialogs.
Generic file dialog.