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