The Battle for Wesnoth  1.19.3+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 "hotkey/hotkey_item.hpp"
40 #include "mp_ui_alerts.hpp"
41 #include "units/types.hpp"
42 #include "wesnothd_connection.hpp"
43 
44 namespace gui2::dialogs
45 {
46 
47 REGISTER_DIALOG(mp_staging)
48 
49 mp_staging::mp_staging(ng::connect_engine& connect_engine, wesnothd_connection* connection)
50  : modal_dialog(window_id())
51  , connect_engine_(connect_engine)
52  , ai_algorithms_(ai::configuration::get_available_ais())
53  , network_connection_(connection)
54  , update_timer_(0)
55  , state_changed_(false)
56  , team_tree_map_()
57  , side_tree_map_()
58  , player_list_(nullptr)
59 {
60  set_show_even_without_video(true);
61 
62  assert(!ai_algorithms_.empty());
63 }
64 
66 {
67  if(update_timer_ != 0) {
69  update_timer_ = 0;
70  }
71 }
72 
74 {
77 
78  // Ctrl+G triggers 'I'm Ready' (ok) button's functionality
80  std::stringstream tooltip;
81  tooltip
82  << vgettext_impl("wesnoth", "Hotkey(s): ", {{}})
84  find_widget<button>(get_window(), "ok", false).set_tooltip(tooltip.str());
85 
86  //
87  // Set title and status widget states
88  //
89  label& title = find_widget<label>(&window, "title", false);
90  title.set_label((formatter() << connect_engine_.params().name << " " << font::unicode_em_dash << " " << connect_engine_.scenario()["name"].t_str()).str());
91 
93 
94  //
95  // Set up sides list
96  //
97  for(const auto& side : connect_engine_.side_engines()) {
98  if(side->allow_player() || game_config::debug) {
99  add_side_node(side);;
100  }
101  }
102 
103  //
104  // Initialize chatbox and game rooms
105  //
106  chatbox& chat = find_widget<chatbox>(&window, "chat", false);
107 
108  chat.room_window_open(N_("this game"), true, false);
109  chat.active_window_changed();
110  chat.load_log(default_chat_log, false);
111 
112  //
113  // Set up player list
114  //
116 
117  //
118  // Set up the network handling
119  //
121 
122  //
123  // Set up the Lua plugin context
124  //
125  plugins_context_.reset(new plugins_context("Multiplayer Staging"));
126 
127  plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
128  plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
129  plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
130 }
131 
133 {
134  int position = 0;
135  for(const auto& side_engine : connect_engine_.side_engines()) {
136  if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
137  ++position;
138  }
139  }
140 
141  return position;
142 }
143 
144 template<typename... T>
146 {
147  static const widget_data empty_map;
148 
149  // If there is no team node in the map, this will return nullptr
150  tree_view_node* team_node = team_tree_map_[side->team_name()];
151 
152  // Add a team node if none exists
153  if(team_node == nullptr) {
154  tree_view& tree = find_widget<tree_view>(get_window(), "side_list", false);
155 
156  widget_data tree_data;
157  widget_item tree_item;
158 
159  tree_item["label"] = side->user_team_name();
160  tree_data.emplace("tree_view_node_label", tree_item);
161 
162  team_node = &tree.add_node("team_header", tree_data);
163  team_node->add_sibling("side_spacer", empty_map);
164 
165  team_tree_map_[side->team_name()] = team_node;
166  }
167 
168  assert(team_node && "No team node found!");
169  return team_node->add_child(std::forward<T>(params)...);
170 }
171 
173 {
176 
177  item["label"] = std::to_string(side->index() + 1);
178  data.emplace("side_number", item);
179 
180  // TODO: don't hardcode magenta?
181  item["label"] = "units/unknown-unit.png~RC(magenta>" + side->color_id() + ")";
182  data.emplace("leader_image", item);
183 
184  item["label"] = "icons/icon-random.png";
185  data.emplace("leader_gender", item);
186 
187  tree_view_node& node = add_side_to_team_node(side, "side_panel", data, get_side_node_position(side));
188 
189  side_tree_map_[side] = &node;
190 
191  grid& row_grid = node.get_grid();
192 
193  update_leader_display(side, row_grid);
194 
195  // Status variables
196  const bool fls = connect_engine_.force_lock_settings();
197  const bool ums = connect_engine_.params().use_map_settings;
198 
199  const bool lock_gold = side->cfg()["gold_lock"].to_bool(fls);
200  const bool lock_income = side->cfg()["income_lock"].to_bool(fls);
201  const bool lock_team = side->cfg()["team_lock"].to_bool(fls);
202  const bool lock_color = side->cfg()["color_lock"].to_bool(fls);
203 
204  const bool saved_game = connect_engine_.params().saved_game == saved_game_mode::type::midgame;
205 
206  //
207  // AI Algorithm
208  //
209  int selection = 0;
210 
211  // We use an index-based loop in order to get the index of the selected option
212  std::vector<config> ai_options;
213  // If this is loading a saved game, we add an option at the beginning of the menu.
214  // This results in a mismatch between the indices of ai_options and ai_algorithms_
215  // that we need to account for later.
216  if(saved_game) {
217  ai_options.emplace_back("label", "Keep saved AI");
218  }
219  for(unsigned i = 0; i < ai_algorithms_.size(); ++i) {
220  ai_options.emplace_back("label", ai_algorithms_[i]->text);
221 
222  if(ai_algorithms_[i]->id == side->ai_algorithm()) {
223  selection = i;
224  }
225  }
226 
227  menu_button& ai_selection = find_widget<menu_button>(&row_grid, "ai_controller", false);
228 
229  ai_selection.set_values(ai_options, selection);
230 
231  connect_signal_notify_modified(ai_selection,
232  std::bind(&mp_staging::on_ai_select, this, side, std::ref(ai_selection), saved_game));
233 
234  on_ai_select(side, ai_selection, saved_game);
235  //
236  // Controller
237  //
238  std::vector<config> controller_names;
239  for(const auto& controller : side->controller_options()) {
240  controller_names.emplace_back("label", controller.second);
241  }
242 
243  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
244 
245  controller_selection.set_values(controller_names, side->current_controller_index());
246  controller_selection.set_active(controller_names.size() > 1);
247 
248  connect_signal_notify_modified(controller_selection,
249  std::bind(&mp_staging::on_controller_select, this, side, std::ref(row_grid)));
250 
251  on_controller_select(side, row_grid);
252 
253  //
254  // Leader controls
255  //
256  button& leader_select = find_widget<button>(&row_grid, "select_leader", false);
257 
258  //todo: shouldn't this also be disabled when the flg settings are locked.
259  leader_select.set_active(!saved_game);
260 
261  connect_signal_mouse_left_click(leader_select,
262  std::bind(&mp_staging::select_leader_callback, this, side, std::ref(row_grid)));
263 
264  //
265  // Team
266  //
267  std::vector<config> team_names;
268  unsigned initial_team_selection = 0;
269 
270  for(unsigned i = 0; i < connect_engine_.team_data().size(); ++i) {
272 
273  if(!tdata.is_player_team && !game_config::debug) {
274  continue;
275  }
276 
277  config entry;
278  entry["label"] = t_string::from_serialized(tdata.user_team_name);
279 
280  // Since we're not necessarily displaying every every team, we need to store the
281  // index a displayed team has in the connect_engine's team_data vector. This is
282  // then utilized in the click callback.
283  entry["team_index"] = i;
284 
285  team_names.push_back(std::move(entry));
286 
287  // Since, again, every team might not be displayed, and side_engine::team() returns
288  // an index into the team_data vector, get an initial selection index for the menu
289  // adjusted for the displayed named.
290  if(side->team() == i) {
291  initial_team_selection = team_names.size() - 1;
292  }
293  }
294 
295  menu_button& team_selection = find_widget<menu_button>(&row_grid, "side_team", false);
296 
297  team_selection.set_values(team_names, initial_team_selection);
298  //todo: shouldn't this also be disabled when team settings are locked.
299  team_selection.set_active(!saved_game);
300 
301  connect_signal_notify_modified(team_selection,
302  std::bind(&mp_staging::on_team_select, this, side, std::ref(team_selection)));
303 
304  //
305  // Colors
306  //
307  std::vector<config> color_options;
308  for(const auto& color : side->color_options()) {
309  color_options.emplace_back(
310  "label", font::get_color_string_pango(color),
311  "icon", (formatter() << "misc/status.png~RC(magenta>" << color << ")").str()
312  );
313  }
314 
315  menu_button& color_selection = find_widget<menu_button>(&row_grid, "side_color", false);
316 
317  color_selection.set_values(color_options, side->color());
318  color_selection.set_active(!saved_game);
319  color_selection.set_use_markup(true);
320 
321  connect_signal_notify_modified(color_selection,
322  std::bind(&mp_staging::on_color_select, this, side, std::ref(row_grid)));
323 
324  //
325  // Gold and Income
326  //
327  const auto slider_setup_helper = [](slider& slider, const int value) {
328  // For the gold and income sliders, the usual min and max values are set in
329  // the dialog WML. However, if a side specifies a value out of that range,
330  // we adjust the bounds to accommodate it.
332  std::min(value, slider.get_minimum_value()),
333  std::max(value, slider.get_maximum_value())
334  );
335 
336  slider.set_value(value);
337  };
338 
339  slider& slider_gold = find_widget<slider>(&row_grid, "side_gold_slider", false);
340  slider_setup_helper(slider_gold, side->gold());
341 
342  connect_signal_notify_modified(slider_gold, std::bind(
343  &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>, this, side, std::ref(slider_gold)));
344 
345  slider& slider_income = find_widget<slider>(&row_grid, "side_income_slider", false);
346  slider_setup_helper(slider_income, side->income());
347 
348  connect_signal_notify_modified(slider_income, std::bind(
349  &mp_staging::on_side_slider_change<&ng::side_engine::set_income>, this, side, std::ref(slider_income)));
350 
351  // TODO: maybe display the saved values
352  if(saved_game) {
355  }
356 
357  //
358  // Gold, income, team, and color are only suggestions unless explicitly locked
359  //
360  if(!saved_game && ums) {
361  team_selection.set_active(!lock_team);
362  color_selection.set_active(!lock_color);
363 
364  slider_gold.set_active(!lock_gold);
365  slider_income.set_active(!lock_income);
366  }
367 }
368 
370 {
371  menu_button& ai_selection = find_widget<menu_button>(&row_grid, "ai_controller", false);
372  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
373 
374  if(side->controller_changed(controller_selection.get_value())) {
376 
378  }
379 }
380 
382 {
383  // If this is a saved game, we need to reduce the index by one, to account for
384  // the "Keep saved AI" option having been added to the computer player menu
385  int i = ai_menu.get_value();
386  if(saved_game) {
387  i--;
388  }
389 
390  if(i < 0) {
391  side->set_ai_algorithm("use_saved");
392  } else {
393  side->set_ai_algorithm(ai_algorithms_[i]->id);
394  }
395 
397 }
398 
400 {
401  side->set_color(find_widget<menu_button>(&row_grid, "side_color", false).get_value());
402 
403  update_leader_display(side, row_grid);
404 
406 }
407 
409 {
410  // Since we're not necessarily displaying every every team in the menu, we can't just
411  // use the selected index to set a side's team. Instead, we grab the index we stored
412  // in add_side_node from the selected config, which should correspond to the
413  // appropriate entry in the connect_engine's team name vector.
414  const unsigned team_index = team_menu.get_value_config()["team_index"].to_unsigned();
415 
416  if(team_index == side->team()) {
417  return;
418  }
419 
420  // Note the old team so we can remove the node if empty after the side move.
421  // Do this *before* setting the new team!
422  const std::string old_team = side->team_name();
423  side->set_team(team_index);
424 
425  auto& tree = find_widget<tree_view>(get_window(), "side_list", false);
426 
427  // First, remove the node from the tree
428  auto node = tree.remove_node(side_tree_map_[side]);
429 
430  // Then add a new node as a child to the appropriate team's node
431  add_side_to_team_node(side, std::move(node.first), get_side_node_position(side));
432 
433  tree_view_node* old_team_node = team_tree_map_[old_team];
434 
435  // Last, remove the old team node if it's now empty
436  if(old_team_node->empty()) {
437  // Decor node will be immediately after team node. Remove this first!
438  tree.remove_node(old_team_node->get_node_below());
439  tree.remove_node(old_team_node);
440 
441  team_tree_map_[old_team] = nullptr;
442  }
443 
445 }
446 
448 {
449  if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
450  update_leader_display(side, row_grid);
451 
453  }
454 }
455 
456 template<void(ng::side_engine::*fptr)(int)>
458 {
459  std::invoke(fptr, side, slider.get_value());
460 
462 }
463 
465 {
466  // BIG FAT TODO: get rid of this shitty "null" string value in the FLG manager
467  std::string current_leader = side->flg().current_leader() != "null" ? side->flg().current_leader() : font::unicode_em_dash;
468  const std::string current_gender = side->flg().current_gender() != "null" ? side->flg().current_gender() : font::unicode_em_dash;
469 
470  // Sprite
471  std::string new_image;
472 
473  if(side->flg().is_random_faction() || current_leader == "random") {
474  new_image = ng::random_enemy_picture;
475  }
476 
477  if(const unit_type* ut = unit_types.find(current_leader)) {
478  const unit_type& type = ut->get_gender_unit_type(current_gender);
479 
480  new_image = formatter() << type.image() << "~RC(magenta>" << side->color_id() << ")";
481 
482  // We don't need the unit type id anymore, and can now replace this variable with the type name
483  current_leader = type.type_name();
484  }
485 
486  find_widget<drawing>(&row_grid, "leader_image", false).set_label(new_image);
487 
488  // Faction and leader
489  if(!side->cfg()["name"].empty()) {
490  current_leader = formatter() << side->cfg()["name"] << " (<i>" << current_leader << "</i>)";
491  }
492 
493  find_widget<label>(&row_grid, "leader_type", false).set_label(current_leader == "random" ? _("Random") : current_leader);
494  find_widget<label>(&row_grid, "leader_faction", false).set_label(side->flg().current_faction()["name"]);
495 
496  // Gender
497  if(current_gender != font::unicode_em_dash) {
498  const std::string gender_icon = formatter() << "icons/icon-" << current_gender << ".png";
499 
500  image& icon = find_widget<image>(&row_grid, "leader_gender", false);
501  icon.set_label(gender_icon);
502  }
503 }
504 
506 {
507  find_widget<label>(get_window(), "status_label", false).set_label(
509  ? _("Waiting for players to join...")
510  : _("Waiting for players to choose factions...")
511  );
512 
513  find_widget<button>(get_window(), "ok", false).set_active(connect_engine_.can_start_game());
514 }
515 
517 {
518  // First, send off any changes if they've been accumulated
519  if(state_changed_) {
521  }
522 
523  // Next, check for any incoming changes
524  config data;
526  return;
527  }
528 
529  // Update chat
530  find_widget<chatbox>(get_window(), "chat", false).process_network_data(data);
531 
532  // TODO: why is this needed...
533  const bool was_able_to_start = connect_engine_.can_start_game();
534 
535  bool quit_signal_received;
536  std::tie(quit_signal_received, std::ignore) = connect_engine_.process_network_data(data);
537 
538  if(quit_signal_received) {
540  }
541 
542  // Update side leader displays
543  // This is basically only needed when a new player joins and selects their faction
544  for(auto& tree_entry : side_tree_map_) {
545  ng::side_engine_ptr side = tree_entry.first;
546 
547  grid& row_grid = tree_entry.second->get_grid();
548 
549  update_leader_display(side, row_grid);
550 
551  std::vector<config> controller_names;
552  for(const auto& controller : side->controller_options()) {
553  controller_names.emplace_back("label", controller.second);
554  }
555 
556  menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
557 
558  controller_selection.set_values(controller_names, side->current_controller_index());
559  controller_selection.set_active(controller_names.size() > 1);
560  }
561 
562  // Update player list
563  if(data.has_child("user")) {
564  player_list_->update_list(data.child_range("user"));
565  }
566 
567  // Update status label and buttons
569 
570  if(!was_able_to_start && connect_engine_.can_start_game()) {
572  }
573 
574  state_changed_ = false;
575 }
576 
578 {
579  if(update_timer_ != 0) {
581  update_timer_ = 0;
582  }
583 
584  if(window.get_retval() == retval::OK) {
586  } else {
588  }
589 }
590 
591 } // 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:64
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:375
virtual void send_chat_message(const std::string &message, bool allies_only) override
Inherited form chat_handler.
Definition: chatbox.cpp:243
void load_log(std::map< std::string, chatroom_log > &log, bool show_lobby)
Definition: chatbox.cpp:90
void active_window_changed()
Definition: chatbox.cpp:105
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:464
void on_color_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:399
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: mp_staging.cpp:73
wesnothd_connection * network_connection_
Definition: mp_staging.hpp:96
int get_side_node_position(ng::side_engine_ptr side) const
Find an appropriate position to insert a side node.
Definition: mp_staging.cpp:132
ng::connect_engine & connect_engine_
Definition: mp_staging.hpp:92
void on_controller_select(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:369
void select_leader_callback(ng::side_engine_ptr side, grid &row_grid)
Definition: mp_staging.cpp:447
void on_ai_select(ng::side_engine_ptr side, menu_button &ai_menu, const bool saved_game)
Definition: mp_staging.cpp:381
void on_team_select(ng::side_engine_ptr side, menu_button &team_menu)
Definition: mp_staging.cpp:408
std::map< ng::side_engine_ptr, tree_view_node * > side_tree_map_
Definition: mp_staging.hpp:103
void on_side_slider_change(ng::side_engine_ptr side, slider &slider)
Definition: mp_staging.cpp:457
std::unique_ptr< player_list_helper > player_list_
Definition: mp_staging.hpp:105
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: mp_staging.cpp:577
std::vector< ai::description * > ai_algorithms_
Definition: mp_staging.hpp:94
std::map< std::string, tree_view_node * > team_tree_map_
Definition: mp_staging.hpp:102
tree_view_node & add_side_to_team_node(ng::side_engine_ptr side, T &&... params)
Definition: mp_staging.cpp:145
void add_side_node(ng::side_engine_ptr side)
Definition: mp_staging.cpp:172
std::unique_ptr< plugins_context > plugins_context_
At the moment two kinds of tips are known:
Definition: tooltip.cpp:42
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
Definition: dispatcher.cpp:147
Base container class.
Definition: grid.hpp:32
const ::config & get_value_config() const
Returns the entire config object for the selected row.
Definition: menu_button.hpp:70
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:55
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.
virtual int get_minimum_value() const override
Inherited from integer_selector.
Definition: slider.hpp:58
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:64
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:52
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.
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:469
@ 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:61
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:325
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:397
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:338
int get_retval()
Definition: window.hpp:404
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:1267
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:965
#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:92
unsigned lobby_network_timer
Definition: game_config.cpp:68
REGISTER_DIALOG(editor_edit_unit)
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:411
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
@ HOTKEY_MP_START_GAME
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:178
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...
saved_game_mode::type saved_game
unit_type_data unit_types
Definition: types.cpp:1486