The Battle for Wesnoth  1.19.0-dev
mp_staging.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
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 "ai/configuration.hpp"
20 #include "chat_log.hpp"
21 #include "formula/string_utils.hpp"
22 #include "font/text_formatting.hpp"
23 #include "formatter.hpp"
24 #include "game_config.hpp"
25 #include "gettext.hpp"
29 #include "gui/widgets/button.hpp"
30 #include "gui/widgets/chatbox.hpp"
31 #include "gui/widgets/drawing.hpp"
32 #include "gui/widgets/image.hpp"
33 #include "gui/widgets/label.hpp"
35 #include "gui/widgets/slider.hpp"
38 #include "mp_ui_alerts.hpp"
39 #include "units/types.hpp"
40 #include "wesnothd_connection.hpp"
41 
42 namespace gui2::dialogs
43 {
44 
45 REGISTER_DIALOG(mp_staging)
46 
47 mp_staging::mp_staging(ng::connect_engine& connect_engine, wesnothd_connection* connection)
48  : modal_dialog(window_id())
49  , connect_engine_(connect_engine)
50  , ai_algorithms_(ai::configuration::get_available_ais())
51  , network_connection_(connection)
52  , update_timer_(0)
53  , state_changed_(false)
54  , team_tree_map_()
55  , side_tree_map_()
56  , player_list_(nullptr)
57 {
58  set_show_even_without_video(true);
59 
60  assert(!ai_algorithms_.empty());
61 }
62 
64 {
65  if(update_timer_ != 0) {
67  update_timer_ = 0;
68  }
69 }
70 
72 {
75 
76  // Ctrl+G triggers 'I'm Ready' (ok) button's functionality
77  connect_signal<event::SDL_KEY_DOWN>(std::bind(
78  &mp_staging::signal_handler_sdl_key_down, this, std::placeholders::_2, std::placeholders::_3, std::placeholders::_5, std::placeholders::_6));
79  std::stringstream tooltip;
80  tooltip << vgettext_impl("wesnoth", "Hotkey(s): ", {{}});
81  #ifdef __APPLE__
82  tooltip << "cmd+g";
83  #else
84  tooltip << "ctrl+g";
85  #endif
86  find_widget<button>(get_window(), "ok", false).set_tooltip(tooltip.str());
87 
88  //
89  // Set title and status widget states
90  //
91  label& title = find_widget<label>(&window, "title", false);
92  title.set_label((formatter() << connect_engine_.params().name << " " << font::unicode_em_dash << " " << connect_engine_.scenario()["name"].t_str()).str());
93 
95 
96  //
97  // Set up sides list
98  //
99  for(const auto& side : connect_engine_.side_engines()) {
100  if(side->allow_player() || game_config::debug) {
101  add_side_node(side);;
102  }
103  }
104 
105  //
106  // Initialize chatbox and game rooms
107  //
108  chatbox& chat = find_widget<chatbox>(&window, "chat", false);
109 
110  chat.room_window_open(N_("this game"), true, false);
111  chat.active_window_changed();
112  chat.load_log(default_chat_log, false);
113 
114  //
115  // Set up player list
116  //
118 
119  //
120  // Set up the network handling
121  //
123 
124  //
125  // Set up the Lua plugin context
126  //
127  plugins_context_.reset(new plugins_context("Multiplayer Staging"));
128 
129  plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
130  plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
131  plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
132 }
133 
135 {
136  int position = 0;
137  for(const auto& side_engine : connect_engine_.side_engines()) {
138  if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
139  ++position;
140  }
141  }
142 
143  return position;
144 }
145 
146 template<typename... T>
148 {
149  static const widget_data empty_map;
150 
151  // If there is no team node in the map, this will return nullptr
152  tree_view_node* team_node = team_tree_map_[side->team_name()];
153 
154  // Add a team node if none exists
155  if(team_node == nullptr) {
156  tree_view& tree = find_widget<tree_view>(get_window(), "side_list", false);
157 
158  widget_data tree_data;
159  widget_item tree_item;
160 
161  tree_item["label"] = side->user_team_name();
162  tree_data.emplace("tree_view_node_label", tree_item);
163 
164  team_node = &tree.add_node("team_header", tree_data);
165  team_node->add_sibling("side_spacer", empty_map);
166 
167  team_tree_map_[side->team_name()] = team_node;
168  }
169 
170  assert(team_node && "No team node found!");
171  return team_node->add_child(std::forward<T>(params)...);
172 }
173 
175 {
178 
179  item["label"] = std::to_string(side->index() + 1);
180  data.emplace("side_number", item);
181 
182  // TODO: don't hardcode magenta?
183  item["label"] = "units/unknown-unit.png~RC(magenta>" + side->color_id() + ")";
184  data.emplace("leader_image", item);
185 
186  item["label"] = "icons/icon-random.png";
187  data.emplace("leader_gender", item);
188 
189  tree_view_node& node = add_side_to_team_node(side, "side_panel", data, get_side_node_position(side));
190 
191  side_tree_map_[side] = &node;
192 
193  grid& row_grid = node.get_grid();
194 
195  update_leader_display(side, row_grid);
196 
197  // Status variables
198  const bool fls = connect_engine_.force_lock_settings();
199  const bool ums = connect_engine_.params().use_map_settings;
200 
201  const bool lock_gold = side->cfg()["gold_lock"].to_bool(fls);
202  const bool lock_income = side->cfg()["income_lock"].to_bool(fls);
203  const bool lock_team = side->cfg()["team_lock"].to_bool(fls);
204  const bool lock_color = side->cfg()["color_lock"].to_bool(fls);
205 
206  const bool saved_game = connect_engine_.params().saved_game == saved_game_mode::type::midgame;
207 
208  //
209  // AI Algorithm
210  //
211  int selection = 0;
212 
213  // We use an index-based loop in order to get the index of the selected option
214  std::vector<config> ai_options;
215  // If this is loading a saved game, we add an option at the beginning of the menu.
216  // This results in a mismatch between the indices of ai_options and ai_algorithms_
217  // that we need to account for later.
218  if(saved_game) {
219  ai_options.emplace_back("label", "Keep saved AI");
220  }
221  for(unsigned i = 0; i < ai_algorithms_.size(); ++i) {
222  ai_options.emplace_back("label", ai_algorithms_[i]->text);
223 
224  if(ai_algorithms_[i]->id == side->ai_algorithm()) {
225  selection = i;
226  }
227  }
228 
229  menu_button& ai_selection = find_widget<menu_button>(&row_grid, "ai_controller", false);
230 
231  ai_selection.set_values(ai_options, selection);
232 
233  connect_signal_notify_modified(ai_selection,
234  std::bind(&mp_staging::on_ai_select, this, side, std::ref(ai_selection), saved_game));
235 
236  on_ai_select(side, ai_selection, saved_game);
237  //
238  // Controller
239  //
240  std::vector<config> controller_names;
241  for(const auto& controller : side->controller_options()) {
242  controller_names.emplace_back("label", controller.second);
243  }
244 
245  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
246 
247  controller_selection.set_values(controller_names, side->current_controller_index());
248  controller_selection.set_active(controller_names.size() > 1);
249 
250  connect_signal_notify_modified(controller_selection,
251  std::bind(&mp_staging::on_controller_select, this, side, std::ref(row_grid)));
252 
253  on_controller_select(side, row_grid);
254 
255  //
256  // Leader controls
257  //
258  button& leader_select = find_widget<button>(&row_grid, "select_leader", false);
259 
260  //todo: shouldn't this also be disabled when the flg settings are locked.
261  leader_select.set_active(!saved_game);
262 
263  connect_signal_mouse_left_click(leader_select,
264  std::bind(&mp_staging::select_leader_callback, this, side, std::ref(row_grid)));
265 
266  //
267  // Team
268  //
269  std::vector<config> team_names;
270  unsigned initial_team_selection = 0;
271 
272  for(unsigned i = 0; i < connect_engine_.team_data().size(); ++i) {
274 
275  if(!tdata.is_player_team && !game_config::debug) {
276  continue;
277  }
278 
279  config entry;
280  entry["label"] = t_string::from_serialized(tdata.user_team_name);
281 
282  // Since we're not necessarily displaying every every team, we need to store the
283  // index a displayed team has in the connect_engine's team_data vector. This is
284  // then utilized in the click callback.
285  entry["team_index"] = i;
286 
287  team_names.push_back(std::move(entry));
288 
289  // Since, again, every team might not be displayed, and side_engine::team() returns
290  // an index into the team_data vector, get an initial selection index for the menu
291  // adjusted for the displayed named.
292  if(side->team() == i) {
293  initial_team_selection = team_names.size() - 1;
294  }
295  }
296 
297  menu_button& team_selection = find_widget<menu_button>(&row_grid, "side_team", false);
298 
299  team_selection.set_values(team_names, initial_team_selection);
300  //todo: shouldn't this also be disabled when team settings are locked.
301  team_selection.set_active(!saved_game);
302 
303  connect_signal_notify_modified(team_selection,
304  std::bind(&mp_staging::on_team_select, this, side, std::ref(team_selection)));
305 
306  //
307  // Colors
308  //
309  std::vector<config> color_options;
310  for(const auto& color : side->color_options()) {
311  color_options.emplace_back(
312  "label", font::get_color_string_pango(color),
313  "icon", (formatter() << "misc/status.png~RC(magenta>" << color << ")").str()
314  );
315  }
316 
317  menu_button& color_selection = find_widget<menu_button>(&row_grid, "side_color", false);
318 
319  color_selection.set_values(color_options, side->color());
320  color_selection.set_active(!saved_game);
321  color_selection.set_use_markup(true);
322 
323  connect_signal_notify_modified(color_selection,
324  std::bind(&mp_staging::on_color_select, this, side, std::ref(row_grid)));
325 
326  //
327  // Gold and Income
328  //
329  const auto slider_setup_helper = [](slider& slider, const int value) {
330  // For the gold and income sliders, the usual min and max values are set in
331  // the dialog WML. However, if a side specifies a value out of that range,
332  // we adjust the bounds to accommodate it.
334  std::min(value, slider.get_minimum_value()),
335  std::max(value, slider.get_maximum_value())
336  );
337 
338  slider.set_value(value);
339  };
340 
341  slider& slider_gold = find_widget<slider>(&row_grid, "side_gold_slider", false);
342  slider_setup_helper(slider_gold, side->gold());
343 
344  connect_signal_notify_modified(slider_gold, std::bind(
345  &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>, this, side, std::ref(slider_gold)));
346 
347  slider& slider_income = find_widget<slider>(&row_grid, "side_income_slider", false);
348  slider_setup_helper(slider_income, side->income());
349 
350  connect_signal_notify_modified(slider_income, std::bind(
351  &mp_staging::on_side_slider_change<&ng::side_engine::set_income>, this, side, std::ref(slider_income)));
352 
353  // TODO: maybe display the saved values
354  if(saved_game) {
357  }
358 
359  //
360  // Gold, income, team, and color are only suggestions unless explicitly locked
361  //
362  if(!saved_game && ums) {
363  team_selection.set_active(!lock_team);
364  color_selection.set_active(!lock_color);
365 
366  slider_gold.set_active(!lock_gold);
367  slider_income.set_active(!lock_income);
368  }
369 }
370 
372 {
373  menu_button& ai_selection = find_widget<menu_button>(&row_grid, "ai_controller", false);
374  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
375 
376  if(side->controller_changed(controller_selection.get_value())) {
378 
380  }
381 }
382 
384 {
385  // If this is a saved game, we need to reduce the index by one, to account for
386  // the "Keep saved AI" option having been added to the computer player menu
387  int i = ai_menu.get_value();
388  if(saved_game) {
389  i--;
390  }
391 
392  if(i < 0) {
393  side->set_ai_algorithm("use_saved");
394  } else {
395  side->set_ai_algorithm(ai_algorithms_[i]->id);
396  }
397 
399 }
400 
402 {
403  side->set_color(find_widget<menu_button>(&row_grid, "side_color", false).get_value());
404 
405  update_leader_display(side, row_grid);
406 
408 }
409 
411 {
412  // Since we're not necessarily displaying every every team in the menu, we can't just
413  // use the selected index to set a side's team. Instead, we grab the index we stored
414  // in add_side_node from the selected config, which should correspond to the
415  // appropriate entry in the connect_engine's team name vector.
416  const unsigned team_index = team_menu.get_value_config()["team_index"].to_unsigned();
417 
418  if(team_index == side->team()) {
419  return;
420  }
421 
422  // Note the old team so we can remove the node if empty after the side move.
423  // Do this *before* setting the new team!
424  const std::string old_team = side->team_name();
425  side->set_team(team_index);
426 
427  auto& tree = find_widget<tree_view>(get_window(), "side_list", false);
428 
429  // First, remove the node from the tree
430  auto node = tree.remove_node(side_tree_map_[side]);
431 
432  // Then add a new node as a child to the appropriate team's node
433  add_side_to_team_node(side, std::move(node.first), get_side_node_position(side));
434 
435  tree_view_node* old_team_node = team_tree_map_[old_team];
436 
437  // Last, remove the old team node if it's now empty
438  if(old_team_node->empty()) {
439  // Decor node will be immediately after team node. Remove this first!
440  tree.remove_node(old_team_node->get_node_below());
441  tree.remove_node(old_team_node);
442 
443  team_tree_map_[old_team] = nullptr;
444  }
445 
447 }
448 
450 {
451  if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
452  update_leader_display(side, row_grid);
453 
455  }
456 }
457 
458 template<void(ng::side_engine::*fptr)(int)>
460 {
461  std::invoke(fptr, side, slider.get_value());
462 
464 }
465 
467 {
468  const std::string current_faction = side->flg().current_faction()["name"];
469 
470  // BIG FAT TODO: get rid of this shitty "null" string value in the FLG manager
471  std::string current_leader = side->flg().current_leader() != "null" ? side->flg().current_leader() : font::unicode_em_dash;
472  const std::string current_gender = side->flg().current_gender() != "null" ? side->flg().current_gender() : font::unicode_em_dash;
473 
474  // Sprite
475  std::string new_image;
476 
477  if(side->flg().is_random_faction() || current_leader == "random") {
478  new_image = ng::random_enemy_picture;
479  }
480 
481  if(const unit_type* ut = unit_types.find(current_leader)) {
482  const unit_type& type = ut->get_gender_unit_type(current_gender);
483 
484  new_image = formatter() << type.image() << "~RC(magenta>" << side->color_id() << ")";
485 
486  // We don't need the unit type id anymore, and can now replace this variable with the type name
487  current_leader = type.type_name();
488  }
489 
490  find_widget<drawing>(&row_grid, "leader_image", false).set_label(new_image);
491 
492  // Faction and leader
493  if(!side->cfg()["name"].empty()) {
494  current_leader = formatter() << side->cfg()["name"] << " (<i>" << current_leader << "</i>)";
495  }
496 
497  find_widget<label>(&row_grid, "leader_type", false).set_label(current_leader == "random" ? _("Random") : current_leader);
498  find_widget<label>(&row_grid, "leader_faction", false).set_label("<span color='#a69275'>" + current_faction + "</span>");
499 
500  // Gender
501  if(current_gender != font::unicode_em_dash) {
502  const std::string gender_icon = formatter() << "icons/icon-" << current_gender << ".png";
503 
504  image& icon = find_widget<image>(&row_grid, "leader_gender", false);
505  icon.set_label(gender_icon);
506  }
507 }
508 
510 {
511  find_widget<label>(get_window(), "status_label", false).set_label(
513  ? _("Waiting for players to join...")
514  : _("Waiting for players to choose factions...")
515  );
516 
517  find_widget<button>(get_window(), "ok", false).set_active(connect_engine_.can_start_game());
518 }
519 
521 {
522  // First, send off any changes if they've been accumulated
523  if(state_changed_) {
525  }
526 
527  // Next, check for any incoming changes
528  config data;
530  return;
531  }
532 
533  // Update chat
534  find_widget<chatbox>(get_window(), "chat", false).process_network_data(data);
535 
536  // TODO: why is this needed...
537  const bool was_able_to_start = connect_engine_.can_start_game();
538 
539  bool quit_signal_received;
540  std::tie(quit_signal_received, std::ignore) = connect_engine_.process_network_data(data);
541 
542  if(quit_signal_received) {
544  }
545 
546  // Update side leader displays
547  // This is basically only needed when a new player joins and selects their faction
548  for(auto& tree_entry : side_tree_map_) {
549  ng::side_engine_ptr side = tree_entry.first;
550 
551  grid& row_grid = tree_entry.second->get_grid();
552 
553  update_leader_display(side, row_grid);
554 
555  std::vector<config> controller_names;
556  for(const auto& controller : side->controller_options()) {
557  controller_names.emplace_back("label", controller.second);
558  }
559 
560  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
561 
562  controller_selection.set_values(controller_names, side->current_controller_index());
563  controller_selection.set_active(controller_names.size() > 1);
564  }
565 
566  // Update player list
567  if(data.has_child("user")) {
568  player_list_->update_list(data.child_range("user"));
569  }
570 
571  // Update status label and buttons
573 
574  if(!was_able_to_start && connect_engine_.can_start_game()) {
576  }
577 
578  state_changed_ = false;
579 }
580 
582  bool& handled,
583  const SDL_Keycode key,
584  SDL_Keymod modifier)
585 {
586  handled = true;
587 
588  #ifdef __APPLE__
589  // Idiomatic modifier key in macOS computers.
590  const SDL_Keycode modifier_key = KMOD_GUI;
591  #else
592  // Idiomatic modifier key in Microsoft desktop environments. Common in
593  // GNU/Linux as well, to some extent.
594  const SDL_Keycode modifier_key = KMOD_CTRL;
595  #endif
596 
597  if ((key == SDLK_g) && (modifier & modifier_key)) {
599  return;
600  }
601 }
602 
604 {
605  if(update_timer_ != 0) {
607  update_timer_ = 0;
608  }
609 
610  if(window.get_retval() == retval::OK) {
612  } else {
614  }
615 }
616 
617 } // namespace dialogs
std::map< std::string, chatroom_log > default_chat_log
Definition: chat_log.cpp:18
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
std::ostringstream wrapper.
Definition: formatter.hpp:40
Simple push button.
Definition: button.hpp:36
virtual void set_active(const bool active) override
See styled_widget::set_active.
Definition: button.cpp:63
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:378
virtual void send_chat_message(const std::string &message, bool allies_only) override
Inherited form chat_handler.
Definition: chatbox.cpp:246
void load_log(std::map< std::string, chatroom_log > &log, bool show_lobby)
Definition: chatbox.cpp:92
void active_window_changed()
Definition: chatbox.cpp:107
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
void update_leader_display(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:466
void signal_handler_sdl_key_down(const event::ui_event, bool &handled, const SDL_Keycode key, SDL_Keymod modifier)
for Ctrl+G handling
Definition: mp_staging.cpp:581
void on_color_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:401
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: mp_staging.cpp:71
wesnothd_connection * network_connection_
Definition: mp_staging.hpp:97
int get_side_node_position(ng::side_engine_ptr side) const
Find an appropriate position to insert a side node.
Definition: mp_staging.cpp:134
ng::connect_engine & connect_engine_
Definition: mp_staging.hpp:93
void on_controller_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:371
void select_leader_callback(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:449
void on_ai_select(ng::side_engine_ptr side, menu_button &ai_menu, const bool saved_game)
Definition: mp_staging.cpp:383
void on_team_select(ng::side_engine_ptr side, menu_button &team_menu)
Definition: mp_staging.cpp:410
std::map< ng::side_engine_ptr, tree_view_node * > side_tree_map_
Definition: mp_staging.hpp:104
void on_side_slider_change(ng::side_engine_ptr side, slider &slider)
Definition: mp_staging.cpp:459
std::unique_ptr< player_list_helper > player_list_
Definition: mp_staging.hpp:106
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: mp_staging.cpp:603
std::vector< ai::description * > ai_algorithms_
Definition: mp_staging.hpp:95
std::map< std::string, tree_view_node * > team_tree_map_
Definition: mp_staging.hpp:103
tree_view_node & add_side_to_team_node(ng::side_engine_ptr side, T &&... params)
Definition: mp_staging.cpp:147
void add_side_node(ng::side_engine_ptr side)
Definition: mp_staging.cpp:174
std::unique_ptr< plugins_context > plugins_context_
Class to show the tips.
Definition: tooltip.cpp:56
Base container class.
Definition: grid.hpp:32
A label displays text that can be wrapped but no scrollbars are provided.
Definition: label.hpp:56
A menu_button is a styled_widget to choose an element from a list of elements.
Definition: menu_button.hpp:59
const ::config & get_value_config() const
Returns the entire config object for the selected row.
Definition: menu_button.hpp:96
void set_values(const std::vector<::config > &values, unsigned selected=0)
virtual unsigned get_value() const override
Inherited from selectable_item.
Definition: menu_button.hpp:81
virtual void set_active(const bool active) override
See styled_widget::set_active.
Definition: menu_button.cpp:74
virtual void set_active(const bool active) override
See styled_widget::set_active.
A slider is a control that can select a value by moving a grip on a groove.
Definition: slider.hpp:59
virtual int get_minimum_value() const override
Inherited from integer_selector.
Definition: slider.hpp:84
virtual void set_value(int value) override
Inherited from integer_selector.
Definition: slider.cpp:81
virtual int get_maximum_value() const override
Inherited from integer_selector.
Definition: slider.hpp:90
void set_value_range(int min_value, int max_value)
Definition: slider.cpp:250
virtual int get_value() const override
Inherited from integer_selector.
Definition: slider.hpp:78
void set_tooltip(const t_string &tooltip)
const t_string & tooltip() const
virtual void set_label(const t_string &text)
virtual void set_use_markup(bool use_markup)
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.
bool empty() const
Does the node have children?
tree_view_node * get_node_below()
tree_view_node & add_child(const std::string &id, const widget_data &data, const int index=-1)
Constructs a new child node.
A tree view is a control that holds several items of the same or different types.
Definition: tree_view.hpp:60
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
Definition: tree_view.cpp:56
void set_visible(const visibility visible)
Definition: widget.cpp:470
@ visible
The user sets the widget visible, that means:
@ invisible
The user set the widget invisible, that means:
@ hidden
The user sets the widget hidden, that means:
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:327
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:399
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition: window.hpp:340
int get_retval()
Definition: window.hpp:406
const std::vector< team_data_pod > & team_data() const
std::vector< side_engine_ptr > & side_engines()
std::pair< bool, bool > process_network_data(const config &data)
bool sides_available() const
bool force_lock_settings() const
const mp_game_settings & params() const
bool can_start_game() const
static t_string from_serialized(const std::string &string)
Definition: tstring.hpp:153
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:1266
A single unit type that the player may recruit.
Definition: types.hpp:43
A class that represents a TCP/IP connection to the wesnothd server.
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
Managing the AIs configuration - headers.
std::string vgettext_impl(const char *domain, const char *msgid, const utils::string_map &symbols)
Implementation functions for the VGETTEXT and VNGETTEXT macros.
std::size_t i
Definition: function.cpp:968
#define N_(String)
Definition: gettext.hpp:101
static std::string _(const char *str)
Definition: gettext.hpp:93
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:59
const std::string unicode_em_dash
Definition: constants.cpp:44
std::string get_color_string_pango(const std::string &id)
Returns the name of a color range, colored with its own color.
const bool & debug
Definition: game_config.cpp:91
unsigned lobby_network_timer
Definition: game_config.cpp:67
REGISTER_DIALOG(tod_new_schedule)
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
Definition: dispatcher.cpp:203
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:177
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
std::map< std::string, widget_item > widget_data
Definition: widget.hpp:34
std::map< std::string, t_string > widget_item
Definition: widget.hpp:31
bool remove_timer(const std::size_t id)
Removes a timer.
Definition: timer.cpp:168
@ OK
Dialog was closed with the OK button.
Definition: retval.hpp:35
@ CANCEL
Dialog was closed with the CANCEL button.
Definition: retval.hpp:38
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:412
Functions to load and save images from/to disk.
void ready_for_start()
@ CNTR_COMPUTER
std::shared_ptr< side_engine > side_engine_ptr
const std::string random_enemy_picture("units/random-dice.png")
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
std::string_view data
Definition: picture.cpp:194
saved_game_mode::type saved_game
unit_type_data unit_types
Definition: types.cpp:1485