The Battle for Wesnoth  1.15.12+dev
mp_join_game.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 
18 
19 class config;
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
faction_select * flg_dialog_
wesnothd_connection & network_connection_
Generic file dialog.
Definition: field-fwd.hpp:22
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:59
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64
mp_join_game(saved_game &state, wesnothd_connection &connection, const bool first_scenario=true, const bool observe_game=false)