The Battle for Wesnoth  1.17.12+dev
mp_join_game.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2022
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 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "chat_log.hpp"
20 #include "font/text_formatting.hpp"
21 #include "formatter.hpp"
22 #include "formula/string_utils.hpp"
23 #include "game_config.hpp"
24 #include "game_config_manager.hpp"
27 #include "gettext.hpp"
29 #include "gui/core/timer.hpp"
34 #include "gui/widgets/button.hpp"
35 #include "gui/widgets/chatbox.hpp"
36 #include "gui/widgets/image.hpp"
37 #include "gui/widgets/label.hpp"
38 #include "gui/widgets/listbox.hpp"
42 #include "log.hpp"
43 #include "mp_ui_alerts.hpp"
45 #include "saved_game.hpp"
46 #include "side_controller.hpp"
47 #include "statistics.hpp"
48 #include "units/types.hpp"
49 #include "utils/guard_value.hpp"
50 #include "wesnothd_connection.hpp"
51 
52 static lg::log_domain log_mp_connect_engine("mp/connect/engine");
53 #define DBG_MP LOG_STREAM(debug, log_mp_connect_engine)
54 #define LOG_MP LOG_STREAM(info, log_mp_connect_engine)
55 #define WRN_MP LOG_STREAM(warn, log_mp_connect_engine)
56 #define ERR_MP LOG_STREAM(err, log_mp_connect_engine)
57 
58 namespace gui2::dialogs
59 {
60 
61 REGISTER_DIALOG(mp_join_game)
62 
63 mp_join_game::mp_join_game(saved_game& state, wesnothd_connection& connection, const bool first_scenario, const bool observe_game)
64  : modal_dialog(window_id())
65  , level_()
66  , state_(state)
67  , network_connection_(connection)
68  , update_timer_(0)
69  , first_scenario_(first_scenario)
70  , observe_game_(observe_game)
71  , stop_updates_(false)
72  , player_list_(nullptr)
73  , flg_dialog_(nullptr)
74 {
75  set_show_even_without_video(true);
76 }
77 
79 {
80  if(update_timer_ != 0) {
82  update_timer_ = 0;
83  }
84 }
85 
86 /*
87  * Fetch the selected game's config from the server and prompts an initial faction selection.
88  */
90 {
91  // Ask for the next scenario data, if applicable
92  if(!first_scenario_) {
93  mp::send_to_server(config("load_next_scenario"));
94  }
95 
96  bool has_scenario_and_controllers = false;
97  while(!has_scenario_and_controllers) {
98  config revc;
99 
102 
104  });
105 
106  if(const config& err = revc.child("error")) {
107  throw wesnothd_error(err["message"]);
108  } else if(revc.child("leave_game")) {
109  return false;
110  } else if(config& next_scenario = revc.child("next_scenario")) {
112  } else if(revc.has_attribute("version")) {
113  level_.swap(revc);
114 
115  has_scenario_and_controllers = true;
116  } else if(config& controllers = revc.child("controllers")) {
117  int index = 0;
118  for(const config& controller : controllers.child_range("controller")) {
119  if(config& side = get_scenario().child("side", index)) {
120  side["is_local"] = controller["is_local"];
121  }
122  ++index;
123  }
124 
125  has_scenario_and_controllers = true;
126  }
127  }
128 
129  if(level_["started"].to_bool()) {
131  return true;
132  }
133 
134  if(first_scenario_) {
135  state_.clear();
137 
138  // Make sure that we have the same config as host, if possible.
139  std::string scenario_id = state_.get_scenario_id();
140  // since add-ons are now only enabled when used, the scenario ID may still not be known
141  // so check in the MP info sent from the server for the scenario ID if that's the case
142  if(scenario_id == "") {
143  for(const auto& addon : level_.child("multiplayer").child_range("addon")) {
144  for(const auto& content : addon.child_range("content")) {
145  if(content["type"] == "scenario") {
146  scenario_id = content["id"].str();
147  }
148  }
149  }
150  }
152  }
153 
155 
156  // If we're just an observer, we don't need to find an appropriate side and set faction selection
157  if(observe_game_) {
158  return true;
159  }
160 
161  // Search for an appropriate vacant slot. If a description is set (i.e. we're loading from a saved game),
162  // then prefer to get the side with the same description as our login. Otherwise just choose the first
163  // available side.
164  const config* side_choice = nullptr;
165 
166  int side_num_choice = 1, side_num_counter = 1;
167  for(const config& side : get_scenario().child_range("side")) {
168  // TODO: it can happen that the scenario specifies that the controller
169  // of a side should also gain control of another side.
170  if(side["controller"] == side_controller::reserved && side["current_player"] == preferences::login()) {
171  side_choice = &side;
172  side_num_choice = side_num_counter;
173  break;
174  }
175 
176  if(side["controller"] == side_controller::human && side["player_id"].empty()) {
177  if(!side_choice) { // Found the first empty side
178  side_choice = &side;
179  side_num_choice = side_num_counter;
180  }
181 
182  if(side["current_player"] == preferences::login()) {
183  side_choice = &side;
184  side_num_choice = side_num_counter;
185  break; // Found the preferred one
186  }
187  }
188 
189  if(side["player_id"] == preferences::login()) {
190  // We already own a side in this game
191  return true;
192  }
193 
194  ++side_num_counter;
195  }
196 
197  if(!side_choice) {
198  observe_game_ = true;
199  return true;
200  }
201 
202  // If the client is allowed to choose their team, do that here instead of having it set by the server
203  if((*side_choice)["allow_changes"].to_bool(true)) {
204  if(!show_flg_select(side_num_choice, true)) {
205  return false;
206  }
207  }
208 
209  return true;
210 }
211 
212 static std::string generate_user_description(const config& side)
213 {
214  // Allow the host to override, since only the host knows the ai_algorithm.
215  if(const config::attribute_value* desc = side.get("user_description")) {
216  return desc->str();
217  }
218 
219  const std::string controller_type = side["controller"].str();
220  const std::string reservation = side["current_player"].str();
221  const std::string owner = side["player_id"].str();
222 
223  if(controller_type == side_controller::ai) {
224  return _("Computer Player");
225  } else if(controller_type == side_controller::none) {
226  return _("Empty slot");
227  } else if(controller_type == side_controller::reserved) {
228  return VGETTEXT("Reserved for $playername", {{"playername", reservation}});
229  } else if(owner.empty()) {
230  return _("Vacant slot");
231  } else if(controller_type == side_controller::human) {
232  return owner;
233  } else {
234  return _("empty");
235  }
236 }
237 
239 {
240  window.set_enter_disabled(true);
241  window.set_escape_disabled(true);
242 
243  //
244  // Set title
245  //
246  label& title = find_widget<label>(&window, "title", false);
247  // FIXME: very hacky way to get the game name...
248  title.set_label((formatter() << level_.child("multiplayer")["scenario"] << " " << font::unicode_em_dash << " " << get_scenario()["name"].t_str()).str());
249 
250  //
251  // Set up sides list
252  //
254 
255  //
256  // Initialize chatbox and game rooms
257  //
258  chatbox& chat = find_widget<chatbox>(&window, "chat", false);
259 
260  chat.room_window_open(N_("this game"), true, false);
261  chat.active_window_changed();
262  chat.load_log(default_chat_log, false);
263 
264  //
265  // Set up player list
266  //
267  player_list_.reset(new player_list_helper(&window));
268 
269  //
270  // Set up the network handling
271  //
273 
274  //
275  // Set up the Lua plugin context
276  //
277  plugins_context_.reset(new plugins_context("Multiplayer Join"));
278 
279  plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
280  plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
281  plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
282 }
283 
284 bool mp_join_game::show_flg_select(int side_num, bool first_time)
285 {
286  if(const config& side_choice = get_scenario().child("side", side_num - 1)) {
287  if(!side_choice["allow_changes"].to_bool(true)) {
288  return true;
289  }
290 
291  const config& era = level_.child("era");
292  if(!era) {
293  ERR_MP << "no era information";
294  return false;
295  }
296 
297  config::const_child_itors possible_sides = era.child_range("multiplayer_side");
298  if(possible_sides.empty()) {
299  WRN_MP << "no [multiplayer_side] found in era '" << era["id"] << "'.";
300  return false;
301  }
302 
303  const std::string color = side_choice["color"].str();
304 
305  std::vector<const config*> era_factions;
306  //make this safe against changes to level_ that might make possible_sides invalid pointers.
307  config era_copy;
308  for(const config& side : possible_sides) {
309  config& side_new = era_copy.add_child("multiplayer_side", side);
310  era_factions.push_back(&side_new);
311  }
312 
313  const bool is_mp = state_.classification().is_normal_mp_game();
314  const bool lock_settings = get_scenario()["force_lock_settings"].to_bool(!is_mp);
315  const bool use_map_settings = level_.child("multiplayer")["mp_use_map_settings"].to_bool();
316  const saved_game_mode::type saved_game = saved_game_mode::get_enum(level_.child("multiplayer")["savegame"].str()).value_or(saved_game_mode::type::no);
317 
318  ng::flg_manager flg(era_factions, side_choice, lock_settings, use_map_settings, saved_game == saved_game_mode::type::midgame);
319 
320  {
321  gui2::dialogs::faction_select flg_dialog(flg, color, side_num);
322  utils::guard_value guard(flg_dialog_, &flg_dialog);
323 
324  if(!flg_dialog.show() && !first_time) {
325  return true;
326  }
327  }
328 
329  config faction;
330  config& change = faction.add_child("change_faction");
331  change["change_faction"] = true;
332  change["name"] = preferences::login();
333  change["faction"] = flg.current_faction()["id"];
334  change["leader"] = flg.current_leader();
335  change["gender"] = flg.current_gender();
336  // TODO: the host cannot yet handle this and always uses the first side owned by that player.
337  change["side_num"] = side_num;
338 
339  mp::send_to_server(faction);
340  }
341 
342  return true;
343 }
344 
346 {
347  if(stop_updates_) {
348  return;
349  }
350 
351  tree_view& tree = find_widget<tree_view>(get_window(), "side_list", false);
352 
353  tree.clear();
354  team_tree_map_.clear();
355  const widget_data empty_map;
356 
357  int side_num = 0;
358  for(const auto& side : get_scenario().child_range("side")) {
359  ++side_num;
360  if(!side["allow_player"].to_bool(true)) {
361  continue;
362  }
363 
364  // Check to see whether we've added a toplevel tree node for this team. If not, add one
365  if(team_tree_map_.find(side["team_name"].str()) == team_tree_map_.end()) {
368 
369  item["label"] = t_string::from_serialized(side["user_team_name"]);
370  data.emplace("tree_view_node_label", item);
371 
372  tree_view_node& team_node = tree.add_node("team_header", data);
373  team_node.add_sibling("side_spacer", empty_map);
374 
375  team_tree_map_[side["team_name"].str()] = &team_node;
376  }
377 
380 
381  const std::string color = !side["color"].empty() ? side["color"] : side["side"].str();
382 
383  item["label"] = (formatter() << "<span color='" << font::get_pango_color_from_id(color) << "'>" << side["side"] << "</span>").str();
384  data.emplace("side_number", item);
385 
386  std::string leader_image = ng::random_enemy_picture;
387  std::string leader_type = side["type"];
388  std::string leader_gender = side["gender"];
389  std::string leader_name;
390 
391  // If there is a unit which can recruit, use it as a leader.
392  // Necessary to display leader information when loading saves.
393  for(const config& side_unit : side.child_range("unit")) {
394  if(side_unit["canrecruit"].to_bool()) {
395  leader_type = side_unit["type"].str();
396  leader_gender = side_unit["gender"].str();
397  break;
398  }
399  }
400 
401  if(const unit_type* ut = unit_types.find(leader_type)) {
402  const unit_type& type = ut->get_gender_unit_type(leader_gender);
403 
404  leader_image = formatter() << type.image() << "~RC(" << type.flag_rgb() << ">" << color << ")";
405  leader_name = type.type_name();
406  }
407 
408  item["label"] = leader_image;
409  data.emplace("leader_image", item);
410 
411  std::string description = generate_user_description(side);
412  if(!leader_name.empty()) {
413  description += formatter() << " (<i>" << leader_name << "</i>)";
414  }
415 
416  item["label"] = description;
417  data.emplace("leader_type", item);
418 
419  item["label"] = (formatter() << "<span color='#a69275'>" << side["faction_name"] << "</span>").str();
420  data.emplace("leader_faction", item);
421 
422  std::string gender_icon = "icons/icon-random.png";
423  if(leader_gender != "null") {
424  gender_icon = formatter() << "icons/icon-" << leader_gender << ".png";
425  item["tooltip"] = leader_gender;
426  }
427 
428  item["label"] = gender_icon;
429  data.emplace("leader_gender", item);
430 
431  item.clear();
432 
433  // Don't show gold for saved games
434  // TODO: gold icon
435  if(side["allow_changes"].to_bool()) {
436  item["label"] = side["gold"].str() + " " + _("Gold");
437  data.emplace("side_gold", item);
438  }
439 
440  const int income_amt = side["income"];
441  if(income_amt != 0) {
442  const std::string income_string = formatter() << (income_amt > 0 ? "+" : "") << income_amt << " " << _("Income");
443 
444  item["label"] = income_string;
445  data.emplace("side_income", item);
446  }
447 
448  tree_view_node& node = team_tree_map_[side["team_name"].str()]->add_child("side_panel", data);
449 
450  grid& row_grid = node.get_grid();
451 
452  auto* select_leader_button = find_widget<button>(&row_grid, "select_leader", false, false);
453  if(select_leader_button) {
454  if(side["player_id"] == preferences::login() && side["allow_changes"].to_bool(true)) {
455  //
456  // Small wrapper function in order to set the handled and halt parameters and prevent
457  // crashes in case the dialog closes and the original button to which the callback was
458  // bound had already been destroyed. The other use of show_flg_select doesn't need these
459  // parameters, so it's easier not to declare them as function arguments.
460  //
461  const auto handler = [this, side_num](bool& handled, bool& halt) {
462  show_flg_select(side_num);
463  // note: this function is called from a std::function object stored in the widget
464  // and show_flg_select which internally calls
465  // show_dialog -> pump -> ... -> network_handler -> ... -> generate_side_list
466  // might destroy that std::function object while it is executed, this means that
467  // using the captured variables 'this' and 'side_num' after this will result in
468  // unexpected behaviour or crashes.
469  handled = halt = true;
470  };
471 
472  connect_signal_mouse_left_click(*select_leader_button, std::bind(handler, std::placeholders::_3, std::placeholders::_4));
473  } else {
474  select_leader_button->set_visible(widget::visibility::hidden);
475  }
476  }
477 
478  if(income_amt == 0) {
479  find_widget<image>(&row_grid, "income_icon", false).set_visible(widget::visibility::invisible);
480  find_widget<label>(&row_grid, "side_income", false).set_visible(widget::visibility::invisible);
481  }
482  }
483 }
484 
486 {
487  if(flg_dialog_) {
488  if(window* w = flg_dialog_->get_window()) {
489  w->set_retval(retval::CANCEL);
490  }
491  }
492 }
493 
495 {
496  // If the game has already started, close the dialog immediately.
497  if(level_["started"].to_bool()) {
499  return;
500  }
501 
502  config data;
503  if(!network_connection_.receive_data(data)) {
504  return;
505  }
506 
507  // Update chat
508  find_widget<chatbox>(get_window(), "chat", false).process_network_data(data);
509 
510  if(!data["message"].empty()) {
511  gui2::show_transient_message(_("Response") , data["message"]);
512  }
513 
514  if(data["failed"].to_bool()) {
516 
518  } else if(data.child("start_game")) {
520 
521  level_["started"] = true;
523  } else if(data.child("leave_game")) {
525 
527  }
528 
529  if(data.child("stop_updates")) {
530  stop_updates_ = true;
531  } else if(const config& c = data.child("scenario_diff")) {
532  // TODO: We should catch config::error and then leave the game.
534 
536  } else if(const config& change = data.child("change_controller")) {
537  if(config& side_to_change = get_scenario().find_child("side", "side", change["side"])) {
538  side_to_change.merge_with(change);
539  }
540 
541  if(flg_dialog_ && flg_dialog_->get_side_num() == change["side"].to_int()) {
543  }
544  } else if(data.has_child("scenario") || data.has_child("snapshot") || data.child("next_scenario")) {
545  level_ = first_scenario_ ? data : data.child("next_scenario");
546 
548  }
549 
550  if(data.has_child("turn")) {
551  ERR_MP << "received replay data\n" << data << "\n in mp join";
552  }
553 
554  // Update player list
555  if(data.has_child("user")) {
556  player_list_->update_list(data.child_range("user"));
557  }
558 }
559 
561 {
562  if(config& scenario = level_.child("scenario")) {
563  return scenario;
564  } else if(config& snapshot = level_.child("snapshot")) {
565  return snapshot;
566  }
567 
568  return level_;
569 }
570 
572 {
573  if(update_timer_ != 0) {
575  update_timer_ = 0;
576  }
577 
578  if(window.get_retval() == retval::OK) {
579  if(const config& stats = level_.child("statistics")) {
581  statistics::read_stats(stats);
582  }
583 
585 
587  } else if(observe_game_) {
588  mp::send_to_server(config("observer_quit", config { "name", preferences::login() }));
589  } else {
590  mp::send_to_server(config("leave_game"));
591  }
592 }
593 
594 } // namespace dialogs
window(const builder_window::window_resolution &definition)
< Needs to be initialized in show.
Definition: window.cpp:263
void active_window_changed()
Definition: chatbox.cpp:108
An error occurred during when trying to communicate with the wesnothd server.
Dialog was closed with the CANCEL button.
Definition: retval.hpp:38
void game_has_begun()
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:402
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
Definition: types.cpp:1246
std::string era()
Definition: game.cpp:682
const std::string & current_gender() const
Definition: flg_manager.hpp:71
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:179
config & find_child(config_key_type key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
Definition: config.cpp:885
Variant for storing WML attributes.
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
Definition: tree_view.cpp:57
static game_config_view wrap(const config &cfg)
bool has_attribute(config_key_type key) const
Definition: config.cpp:211
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
Definition: config.cpp:394
const std::string & flag_rgb() const
Definition: types.cpp:720
child_itors child_range(config_key_type key)
Definition: config.cpp:344
static void progress(loading_stage stage=loading_stage::none)
Report what is being loaded to the loading screen.
void load_game_config_for_game(const game_classification &classification, const std::string &scenario_id)
std::string_view data
Definition: picture.cpp:206
const attribute_value * get(config_key_type key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
Definition: config.cpp:780
void fresh_stats()
Definition: statistics.cpp:783
unit_type_data unit_types
Definition: types.cpp:1465
void clear()
Definition: saved_game.cpp:785
faction_select * flg_dialog_
static lg::log_domain log_mp_connect_engine("mp/connect/engine")
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition: window.hpp:299
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
A label displays a text, the text can be wrapped but no scrollbars are provided.
Definition: label.hpp:57
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
void level_to_gamestate(const config &level, saved_game &state)
static std::string _(const char *str)
Definition: gettext.hpp:93
FLG stands for faction, leader and gender.
Definition: flg_manager.hpp:29
bool show(const unsigned auto_close_time=0)
Shows the window.
wesnothd_connection & network_connection_
A single unit type that the player may recruit.
Definition: types.hpp:45
std::string get_scenario_id() const
Definition: saved_game.cpp:649
virtual void set_label(const t_string &label)
Base container class.
Definition: grid.hpp:31
static game_config_manager * get()
void swap(config &cfg)
Definition: config.cpp:1447
std::string get_pango_color_from_id(const std::string &id)
Returns a hex color string from a color range.
std::map< std::string, t_string > widget_item
Definition: widget.hpp:32
std::ostringstream wrapper.
Definition: formatter.hpp:39
const t_string & type_name() const
The name of the unit in the current language setting.
Definition: types.hpp:141
std::unique_ptr< plugins_context > plugins_context_
void set_visible(const visibility visible)
Definition: widget.cpp:456
unsigned lobby_network_timer
Definition: game_config.cpp:87
const std::string & current_leader() const
Definition: flg_manager.hpp:69
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
A class that represents a TCP/IP connection to the wesnothd server.
bool show_flg_select(int side_num, bool first_time=false)
virtual void send_chat_message(const std::string &message, bool allies_only) override
Inherited form chat_handler.
Definition: chatbox.cpp:247
void load_log(std::map< std::string, chatroom_log > &log, bool show_lobby)
Definition: chatbox.cpp:93
void read_stats(const config &cfg)
Definition: statistics.cpp:773
A tree view is a control that holds several items of the same or different types. ...
Definition: tree_view.hpp:60
void close_faction_select_dialog_if_open()
Will close the Faction Select dialog if it&#39;s open.
void apply_diff(const config &diff, bool track=false)
A function to apply a diff config onto this config object.
Definition: config.cpp:1125
static void add_color_info(const game_config_view &v, bool build_defaults)
window * get_window()
Returns a pointer to the dialog&#39;s window.
int get_retval()
Definition: window.hpp:365
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:205
std::string login()
std::unique_ptr< player_list_helper > player_list_
const config & current_faction() const
Definition: flg_manager.hpp:67
logger & err()
Definition: log.cpp:170
Data-based RAII scope guard.
Definition: guard_value.hpp:24
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
Definition: enum_base.hpp:57
The user set the widget invisible, that means:
bool use_map_settings()
Definition: game.cpp:482
Contains the gui2 timer routines.
std::size_t add_timer(const uint32_t interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
Definition: timer.cpp:127
static t_string from_serialized(const std::string &string)
Definition: tstring.hpp:154
int w
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:358
#define N_(String)
Definition: gettext.hpp:101
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72
#define VGETTEXT(msgid,...)
Handy wrappers around interpolate_variables_into_string and gettext.
config & add_child(config_key_type key)
Definition: config.cpp:514
const std::string random_enemy_picture("units/random-dice.png")
const std::string & image() const
Definition: types.hpp:179
static void display(std::function< void()> f)
tree_view_node & add_sibling(const std::string &id, const widget_data &data)
Adds a sibbling for a node at the end of the list.
std::map< std::string, tree_view_node * > team_tree_map_
The user sets the widget hidden, that means:
game_classification & classification()
Definition: saved_game.hpp:55
const std::string unicode_em_dash
Definition: constants.cpp:44
std::map< std::string, chatroom_log > default_chat_log
Definition: chat_log.cpp:18
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Abstract base class for all modal dialogs.
Standard logging facilities (interface).
#define ERR_MP
bool wait_and_receive_data(config &data)
Unlike receive_data, waits until data is available instead of returning immediately.
std::map< std::string, widget_item > widget_data
Definition: widget.hpp:35
void send_to_server(const config &data)
Attempts to send given data to server if a connection is open.
#define WRN_MP
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
static std::string generate_user_description(const config &side)
Dialog was closed with the OK button.
Definition: retval.hpp:35
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
mock_char c
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:66
std::string str() const
Definition: formatter.hpp:61
lobby_chat_window * room_window_open(const std::string &room, const bool open_new, const bool allow_close=true)
Check if a room window for "room" is open, if open_new is true then it will be created if not found...
Definition: chatbox.cpp:379
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:414
bool remove_timer(const std::size_t id)
Removes a timer.
Definition: timer.cpp:168
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:286