The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
multiplayer_connect.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 /** @file */
16 
17 #ifndef MULTIPLAYER_CONNECT_H_INCLUDED
18 #define MULTIPLAYER_CONNECT_H_INCLUDED
19 
20 #include "commandline_options.hpp"
21 #include "connect_engine.hpp"
22 #include "multiplayer_ui.hpp"
23 #include "widgets/combo_drag.hpp"
24 #include "widgets/scrollpane.hpp"
25 #include "widgets/slider.hpp"
26 class CVideo;
27 
28 namespace ai {
29  struct description;
30 }
31 
32 namespace mp {
33 
34 // Helper function to retrieve controller names.
35 std::vector<std::string> controller_options_names(
36  const std::vector<ng::controller_option>& controller_options);
37 
38 class connect : public mp::ui
39 {
40 public:
41 
42  class side {
43  public:
45  side(const side& a);
46  ~side();
47 
48  void process_event();
49 
50  // Returns true if this side changed since last call to this method.
51  bool changed();
52 
53  void update_ui();
54 
56 
58  const ng::side_engine_ptr engine() const { return engine_; }
59 
60  private:
61  // Update UI methods and their helper(s).
62  void update_faction_combo();
63  void update_controller_ui();
64 
65  // The mp::connect widget owning this mp::connect::side.
68 
69  // Flags for controlling which configuration widgets should be locked.
70  bool gold_lock_;
72  bool team_lock_;
74 
75  bool changed_;
76 
91  };
92 
93  typedef std::vector<side> side_list;
94 
95  connect(CVideo& v, twesnothd_connection* wesnothd_connection, const std::string& game_name,
97  ng::connect_engine& engine);
98  ~connect();
99 
100  // Updates the current game state, resolves random factions, and sends a
101  // "start game" message to the network.
103  void start_game_commandline(const commandline_options& cmdline_opts)
104  { engine_.start_game_commandline(cmdline_opts); }
105 
106 protected:
107  virtual void process_event();
108 
109  virtual void layout_children(const SDL_Rect& rect);
110  virtual void hide_children(bool hide = true);
111 
112  virtual void process_network_data(const config& data);
113 
114 private:
115  connect(const connect&);
116  void operator=(const connect&);
117 
118  // Updates the state of the player list, the launch button and of the start
119  // game label, to reflect the actual state.
120  void update_playerlist_state(bool silent = true);
121 
122  const mp_game_settings& params() { return engine_.params(); }
124 
125  std::vector<ai::description*> ai_algorithms_;
126 
127  side_list sides_;
129 
141 
143  bool launch, quit;
144 
146  : launch(false), quit(false)
147  {}
148  process_event_data(bool l, bool q)
149  : launch(l), quit(q)
150  {}
151  };
152 
153  void process_event_impl(const process_event_data &);
154  bool plugin_event_helper(const process_event_data &);
155 };
156 
157 } // end namespace mp
158 
159 #endif
160 
gui::label leader_gender_title_label_
ng::side_engine_ptr engine_
const GLfloat * c
Definition: glew.h:12741
int pos
Definition: formula.cpp:800
ng::side_engine_ptr engine()
void process_event_impl(const process_event_data &)
Definition: video.hpp:58
Scrollpane.
Definition: scrollpane.hpp:30
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
gui::label type_title_label_
bool plugin_event_helper(const process_event_data &)
connect(CVideo &v, twesnothd_connection *wesnothd_connection, const std::string &game_name, const config &game_config, chat &c, config &gamelist, ng::connect_engine &engine)
std::vector< side > side_list
gui::combo_drag_ptr combo_controller_
GLdouble l
Definition: glew.h:6966
void add_widgets_to_scrollpane(gui::scrollpane &pane, int pos)
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1382
This module controls the multiplayer lobby.
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
gui::scrollpane scroll_pane_
A class that represents a TCP/IP connection to the wesnothd server.
const mp_game_settings & params() const
virtual void hide(bool value=true)
Definition: widget.cpp:162
virtual void process_event()
const GLdouble * v
Definition: glew.h:1359
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:7319
ng::connect_engine & engine_
void start_game_commandline(const commandline_options &cmdline_opts)
gui::label label_original_controller_
void start_game_commandline(const commandline_options &cmdline_opts)
gui::label waiting_label_
bool force_lock_settings() const
gui::label gold_title_label_
bool force_lock_settings() const
gui::drop_group_manager_ptr combo_control_group_
Game configuration data as global variables.
Definition: build_info.cpp:38
config & gamelist()
Returns the current gamelist.
virtual void process_network_data(const config &data)
Processes any pending network data.
std::vector< std::string > controller_options_names(const std::vector< ng::controller_option > &controller_options)
std::vector< ai::description * > ai_algorithms_
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
gui::label team_color_title_label_
gui::label income_title_label_
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
const ng::side_engine_ptr engine() const
this class memorizes a chat session.
void update_playerlist_state(bool silent=true)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
gui::label faction_name_title_label_
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void operator=(const connect &)
a base class for the different multiplayer base dialogs: game list, create game, wait game...
side(connect &parent, ng::side_engine_ptr engine)
const mp_game_settings & params()