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