The Battle for Wesnoth  1.17.23+dev
command_executor.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2023
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
17 #include "hotkey/hotkey_item.hpp"
18 
21 #include "gui/dialogs/message.hpp"
25 #include "gui/widgets/retval.hpp"
26 #include "filesystem.hpp"
27 #include "gettext.hpp"
28 #include "log.hpp"
29 #include "preferences/general.hpp"
30 #include "game_end_exceptions.hpp"
31 #include "display.hpp"
32 #include "quit_confirmation.hpp"
33 #include "sdl/surface.hpp"
34 #include "show_dialog.hpp"
35 #include "../resources.hpp"
36 #include "../playmp_controller.hpp"
37 #include "sdl/input.hpp" // get_mouse_state
38 #include "video.hpp" // toggle_fullscreen
39 
40 #include <functional>
41 
42 #include <SDL2/SDL_image.h>
43 
44 #include <cassert>
45 #include <ios>
46 #include <set>
47 
48 static lg::log_domain log_config("config");
49 static lg::log_domain log_hotkey("hotkey");
50 #define ERR_G LOG_STREAM(err, lg::general())
51 #define WRN_G LOG_STREAM(warn, lg::general())
52 #define LOG_G LOG_STREAM(info, lg::general())
53 #define DBG_G LOG_STREAM(debug, lg::general())
54 #define ERR_CF LOG_STREAM(err, log_config)
55 #define LOG_HK LOG_STREAM(info, log_hotkey)
56 
57 namespace {
58 
59 void make_screenshot(const std::string& name, bool map_screenshot)
60 {
61  surface screenshot = display::get_singleton()->screenshot(map_screenshot);
62  if(screenshot) {
63  std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
64  filename = filesystem::get_next_filename(filename, ".jpg");
65  gui2::dialogs::screenshot_notification::display(filename, screenshot);
66  }
67 }
68 }
69 namespace hotkey {
70 
71 static void event_queue(const SDL_Event& event, command_executor* executor);
72 
73 bool command_executor::do_execute_command(const hotkey::ui_command& cmd, bool press, bool release)
74 {
75  // hotkey release handling
76  if (release) {
77  switch(cmd.hotkey_command) {
78  // release a scroll key, un-apply scrolling in the given direction
79  case HOTKEY_SCROLL_UP:
80  scroll_up(false);
81  break;
82  case HOTKEY_SCROLL_DOWN:
83  scroll_down(false);
84  break;
85  case HOTKEY_SCROLL_LEFT:
86  scroll_left(false);
87  break;
89  scroll_right(false);
90  break;
91  default:
92  return false; // nothing else handles a hotkey release
93  }
94 
95  return true;
96  }
97 
98  // handling of hotkeys which activate even on hold events
99  switch(cmd.hotkey_command) {
101  repeat_recruit();
102  return true;
103  case HOTKEY_SCROLL_UP:
104  scroll_up(true);
105  return true;
106  case HOTKEY_SCROLL_DOWN:
107  scroll_down(true);
108  return true;
109  case HOTKEY_SCROLL_LEFT:
110  scroll_left(true);
111  return true;
112  case HOTKEY_SCROLL_RIGHT:
113  scroll_right(true);
114  return true;
115  default:
116  break;
117  }
118 
119  if(!press) {
120  return false; // nothing else handles hotkey hold events
121  }
122 
123  // hotkey press handling
124  switch(cmd.hotkey_command) {
125  case HOTKEY_CYCLE_UNITS:
126  cycle_units();
127  break;
130  break;
131  case HOTKEY_ENDTURN:
132  end_turn();
133  break;
136  break;
138  end_unit_turn();
139  break;
140  case HOTKEY_LEADER:
141  goto_leader();
142  break;
143  case HOTKEY_UNDO:
144  undo();
145  break;
146  case HOTKEY_REDO:
147  redo();
148  break;
151  break;
154  break;
155  case HOTKEY_RENAME_UNIT:
156  rename_unit();
157  break;
158  case HOTKEY_SAVE_GAME:
159  save_game();
160  break;
161  case HOTKEY_SAVE_REPLAY:
162  save_replay();
163  break;
164  case HOTKEY_SAVE_MAP:
165  save_map();
166  break;
167  case HOTKEY_LOAD_GAME:
168  load_game();
169  break;
171  toggle_ellipses();
172  break;
173  case HOTKEY_TOGGLE_GRID:
174  toggle_grid();
175  break;
176  case HOTKEY_STATUS_TABLE:
177  status_table();
178  break;
179  case HOTKEY_RECALL:
180  recall();
181  break;
183  label_settings();
184  break;
185  case HOTKEY_RECRUIT:
186  recruit();
187  break;
188  case HOTKEY_SPEAK:
189  speak();
190  break;
191  case HOTKEY_SPEAK_ALLY:
192  whisper();
193  break;
194  case HOTKEY_SPEAK_ALL:
195  shout();
196  break;
197  case HOTKEY_CREATE_UNIT:
198  create_unit();
199  break;
200  case HOTKEY_CHANGE_SIDE:
201  change_side();
202  break;
203  case HOTKEY_KILL_UNIT:
204  kill_unit();
205  break;
206  case HOTKEY_PREFERENCES:
207  preferences();
208  break;
209  case HOTKEY_OBJECTIVES:
210  objectives();
211  break;
212  case HOTKEY_UNIT_LIST:
213  unit_list();
214  break;
215  case HOTKEY_STATISTICS:
216  show_statistics();
217  break;
218  case HOTKEY_STOP_NETWORK:
219  stop_network();
220  break;
222  start_network();
223  break;
225  label_terrain(true);
226  break;
228  label_terrain(false);
229  break;
230  case HOTKEY_CLEAR_LABELS:
231  clear_labels();
232  break;
234  show_enemy_moves(false);
235  break;
237  show_enemy_moves(true);
238  break;
239  case HOTKEY_DELAY_SHROUD:
241  break;
244  break;
246  continue_move();
247  break;
248  case HOTKEY_SEARCH:
249  search();
250  break;
251  case HOTKEY_HELP:
252  show_help();
253  break;
255  // although HOTKEY_HELP uses a virtual call to allow context-specific help, this one is already a specific topic
256  help::show_help("saveload");
257  break;
258  case HOTKEY_CHAT_LOG:
259  show_chat_log();
260  break;
261  case HOTKEY_USER_CMD:
262  user_command();
263  break;
264  case HOTKEY_CUSTOM_CMD:
265  custom_command();
266  break;
267  case HOTKEY_AI_FORMULA:
268  ai_formula();
269  break;
270  case HOTKEY_CLEAR_MSG:
271  clear_messages();
272  break;
273  case HOTKEY_LANGUAGE:
274  change_language();
275  break;
276  case HOTKEY_REPLAY_PLAY:
277  play_replay();
278  break;
279  case HOTKEY_REPLAY_RESET:
280  reset_replay();
281  break;
282  case HOTKEY_REPLAY_STOP:
283  stop_replay();
284  break;
287  break;
290  break;
293  break;
296  break;
299  break;
302  break;
305  break;
306  case HOTKEY_REPLAY_EXIT:
307  replay_exit();
308  break;
309  case HOTKEY_WB_TOGGLE:
311  break;
314  break;
317  break;
320  break;
323  break;
326  break;
329  break;
330  case HOTKEY_SELECT_HEX:
331  select_hex();
332  break;
333  case HOTKEY_DESELECT_HEX:
334  deselect_hex();
335  break;
336  case HOTKEY_MOVE_ACTION:
337  move_action();
338  break;
341  break;
342  case HOTKEY_TOUCH_HEX:
343  touch_hex();
344  break;
345  case HOTKEY_ACCELERATED:
347  break;
348  case LUA_CONSOLE:
349  lua_console();
350  break;
351  case HOTKEY_ZOOM_IN:
352  zoom_in();
353  break;
354  case HOTKEY_ZOOM_OUT:
355  zoom_out();
356  break;
357  case HOTKEY_ZOOM_DEFAULT:
358  zoom_default();
359  break;
361  map_screenshot();
362  break;
365  break;
366  case HOTKEY_QUIT_GAME:
368  break;
369  case HOTKEY_SURRENDER:
370  surrender_game();
371  break;
375  break;
379  break;
383  break;
387  break;
391  break;
392  case HOTKEY_ACHIEVEMENTS:
393  {
395  ach.show();
396  }
397  break;
398  default:
399  return false;
400  }
401  return true;
402 }
403 
405  if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
407  if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
409  }
410  }
411 }
412 
413 void command_executor::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
414 {
415  std::vector<config> items = items_arg;
416  if (items.empty()) return;
417 
419 
420  int res = -1;
421  {
422  SDL_Rect pos {xloc, yloc, 1, 1};
423  gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
424  if(mmenu.show()) {
425  res = mmenu.selected_item();
426  }
427  } // This will kill the dialog.
428  if (res < 0 || std::size_t(res) >= items.size()) return;
429 
430  std::string id = items[res]["id"];
431  const theme::menu* submenu = gui.get_theme().get_menu_item(id);
432  if (submenu) {
433  int y,x;
434  sdl::get_mouse_state(&x,&y);
435  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
436  } else {
437  hotkey::ui_command cmd = hotkey::ui_command(id, res);
438  do_execute_command(cmd);
440  }
441 }
442 
443 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
444 {
445  std::vector<std::string> items = items_arg;
446  if (items.empty()) {
447  return;
448  }
449 
451  while(i != items.end()) {
453  if (can_execute_command(cmd)) {
454  do_execute_command(cmd);
456  }
457  ++i;
458  }
459 }
460 
461 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const
462 {
463  const std::string base_image_name = "icons/action/" + command + "_25.png";
464  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
465 
467  const hotkey::ACTION_STATE state = get_action_state(cmd);
468 
469  const theme::menu* menu = disp.get_theme().get_menu_item(command);
470  if (menu) {
471  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
472  }
473 
474  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
475  switch (state) {
476  case ACTION_ON:
477  case ACTION_SELECTED:
478  return pressed_image_name + "~CROP(3,3,18,18)";
479  default:
480  return base_image_name + "~CROP(3,3,18,18)";
481  }
482  }
483 
484  switch (get_action_state(cmd)) {
485  case ACTION_ON:
487  case ACTION_OFF:
489  case ACTION_SELECTED:
491  case ACTION_DESELECTED:
493  default: return get_action_image(cmd);
494  }
495 }
496 
497 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
498 {
499  for(std::size_t i = 0; i < items.size(); ++i) {
500  config& item = items[i];
501 
502  const std::string& item_id = item["id"];
504 
505  //see if this menu item has an associated image
506  std::string img(get_menu_image(disp, item_id, i));
507  if (img.empty() == false) {
508  item["icon"] = img;
509  }
510 
511  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
512  if(menu) {
513  item["label"] = menu->title();
514  } else if(hk != hotkey::HOTKEY_NULL) {
515  std::string desc = hotkey::get_hotkey_command(item_id).description;
516  if(hk == HOTKEY_ENDTURN) {
517  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
518  if (b) {
519  desc = b->title();
520  }
521  }
522 
523  item["label"] = desc;
524  item["details"] = hotkey::get_names(item_id);
525  }
526  }
527 }
528 
529 void mbutton_event(const SDL_Event& event, command_executor* executor)
530 {
531  event_queue(event, executor);
532 
533  /* Run mouse events immediately.
534 
535  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
536  button has received the mouse press event but before it has received the mouse release event.
537  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
538  set_button_state() ended up being called at such a time. However, if we run the event handlers
539  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
540  safely.
541 
542  See https://github.com/wesnoth/wesnoth/issues/2884 */
543 
544  run_events(executor);
545 }
546 
547 void jbutton_event(const SDL_Event& event, command_executor* executor)
548 {
549  event_queue(event, executor);
550 }
551 
552 void jhat_event(const SDL_Event& event, command_executor* executor)
553 {
554  event_queue(event, executor);
555 }
556 
557 void key_event(const SDL_Event& event, command_executor* executor)
558 {
559  if (!executor) return;
560  event_queue(event,executor);
561 }
562 
563 void keyup_event(const SDL_Event&, command_executor* executor)
564 {
565  if(!executor) return;
566  executor->handle_keyup();
567 }
568 
570 {
571  if(!executor) return;
572  bool commands_ran = executor->run_queued_commands();
573  if(commands_ran) {
574  executor->set_button_state();
575  }
576 }
577 
578 static void event_queue(const SDL_Event& event, command_executor* executor)
579 {
580  if (!executor) return;
581  executor->queue_command(event);
582  executor->set_button_state();
583 }
584 
585 void command_executor::queue_command(const SDL_Event& event, int index)
586 {
587  LOG_HK << "event 0x" << std::hex << event.type << std::dec;
588  if(event.type == SDL_TEXTINPUT) {
589  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"";
590  }
591 
592  const hotkey_ptr hk = get_hotkey(event);
593  if(!hk->active() || hk->is_disabled()) {
594  return;
595  }
596 
597  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
598  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
600  bool press = keypress ||
601  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
602  bool release = event.type == SDL_KEYUP;
603  if(press) {
604  LOG_HK << "sending press event (keypress = " <<
605  std::boolalpha << keypress << std::noboolalpha << ")";
606  }
607  if(keypress) {
608  press_event_sent_ = true;
609  }
610 
611  command_queue_.emplace_back(command, index, press, release);
612 }
613 
615 {
616  auto ui_cmd = hotkey::ui_command(*command.command, command.index);
617  if (!can_execute_command(ui_cmd)
618  || do_execute_command(ui_cmd, command.press, command.release)) {
619  return;
620  }
621 
622  if (!command.press) {
623  return; // none of the commands here respond to a key release
624  }
625 
626  switch(command.command->command) {
627  case HOTKEY_FULLSCREEN:
629  break;
630  case HOTKEY_SCREENSHOT:
631  make_screenshot(_("Screenshot"), false);
632  break;
633  case HOTKEY_ANIMATE_MAP:
635  break;
636  case HOTKEY_MOUSE_SCROLL:
638  break;
639  case HOTKEY_MUTE:
640  {
641  // look if both is not playing
642  static struct before_muted_s
643  {
644  bool playing_sound,playing_music;
645  before_muted_s() : playing_sound(false),playing_music(false){}
646  } before_muted;
648  {
649  // then remember settings and mute both
650  before_muted.playing_sound = preferences::sound_on();
651  before_muted.playing_music = preferences::music_on();
652  preferences::set_sound(false);
653  preferences::set_music(false);
654  }
655  else
656  {
657  // then set settings before mute
658  preferences::set_sound(before_muted.playing_sound);
659  preferences::set_music(before_muted.playing_music);
660  }
661  }
662  break;
663  default:
664  DBG_G << "command_executor: unknown command number " << command.command->command << ", ignoring.";
665  break;
666  }
667 }
668 
670 {
671  display& disp = get_display();
672  for (const theme::menu& menu : disp.get_theme().menus()) {
673 
674  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
675  if (!button) continue;
676  bool enabled = false;
677  for (const auto& command : menu.items()) {
678 
679  ui_command command_obj = ui_command(command["id"].str());
680  bool can_execute = can_execute_command(command_obj);
681  if (can_execute) {
682  enabled = true;
683  break;
684  }
685  }
686  button->enable(enabled);
687  }
688 
689  for (const theme::action& action : disp.get_theme().actions()) {
690 
691  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
692  if (!button) continue;
693  bool enabled = false;
694  int i = 0;
695  for (const std::string& command : action.items()) {
696 
697  ui_command command_obj = ui_command(command);
698  std::string tooltip = action.tooltip(i);
699  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
700  button->set_overlay("icons/action/" + command);
701  if (!tooltip.empty())
702  button->set_tooltip_string(tooltip);
703 
704  bool can_execute = can_execute_command(command_obj);
705  i++;
706  if (!can_execute) continue;
707  enabled = true;
708 
709  ACTION_STATE state = get_action_state(command_obj);
710  switch (state) {
711  case ACTION_SELECTED:
712  case ACTION_ON:
713  button->set_check(true);
714  break;
715  case ACTION_OFF:
716  case ACTION_DESELECTED:
717  button->set_check(false);
718  break;
719  case ACTION_STATELESS:
720  break;
721  default:
722  break;
723  }
724 
725  break;
726  }
727  button->enable(enabled);
728  }
729 }
730 
731 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
732 // See https://github.com/wesnoth/wesnoth/issues/1736
733 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
734 {
735  std::vector<queued_command> filtered_commands;
736 
737  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
738  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
739  std::set<command_with_keyrelease> seen_commands;
740 
741  for(const queued_command& cmd : command_queue_) {
742  command_with_keyrelease command_key(cmd.command, cmd.release);
743  if(seen_commands.find(command_key) == seen_commands.end()) {
744  seen_commands.insert(command_key);
745  filtered_commands.push_back(cmd);
746  }
747  }
748 
749  command_queue_.clear();
750 
751  return filtered_commands;
752 }
753 
755 {
756  std::vector<queued_command> commands = filter_command_queue();
757  for(const queued_command& cmd : commands) {
759  }
760 
761  return !commands.empty();
762 }
763 
765 {
767 }
768 
770 {
771  if (get_display().in_game()) {
773  } else {
775  }
776 
777 }
778 
780 {
782 }
783 
785 {
786  if(!get_display().view_locked()) {
787  get_display().set_zoom(true);
788  }
789 }
790 
792 {
793  if(!get_display().view_locked()) {
794  get_display().set_zoom(false);
795  }
796 }
797 
799 {
800  if(!get_display().view_locked()) {
802  }
803 }
804 
806 {
807  make_screenshot(_("Map-Screenshot"), true);
808 }
809 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:87
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:122
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.cpp:1653
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:810
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:820
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
Definition: display.cpp:1895
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:762
theme & get_theme()
Definition: display.hpp:386
void toggle_default_zoom()
Sets the zoom amount to the default.
Definition: display.cpp:1964
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:101
This shows a dialog displaying achievements.
Used by the menu_button widget.
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
@ yes_no_buttons
Shows a yes and no button.
Definition: message.hpp:81
bool show(const unsigned auto_close_time=0)
Shows the window.
virtual display & get_display()=0
virtual void scroll_right(bool)
virtual void replay_skip_animation()
virtual void scroll_up(bool)
virtual void scroll_left(bool)
virtual void whiteboard_execute_all_actions()
void get_menu_images(display &, std::vector< config > &items)
virtual bool do_execute_command(const hotkey::ui_command &command, bool press=true, bool release=false)
virtual void whiteboard_execute_action()
void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
virtual void show_enemy_moves(bool)
std::vector< queued_command > command_queue_
std::string get_menu_image(display &disp, const std::string &command, int index=-1) const
virtual ACTION_STATE get_action_state(const hotkey::ui_command &) const
virtual void toggle_shroud_updates()
virtual void whiteboard_bump_down_action()
void execute_command_wrap(const queued_command &command)
virtual void whiteboard_delete_action()
virtual void replay_show_everything()
virtual void toggle_accelerated_speed()
virtual void whiteboard_suppose_dead()
virtual void show_menu(const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
virtual void scroll_down(bool)
virtual void label_terrain(bool)
virtual void whiteboard_bump_up_action()
virtual void unit_hold_position()
virtual void terrain_description()
virtual void recalculate_minimap()
virtual std::string get_action_image(const hotkey::ui_command &) const
virtual bool can_execute_command(const hotkey::ui_command &command) const =0
std::vector< queued_command > filter_command_queue()
void queue_command(const SDL_Event &event, int index=-1)
bool is_linger_mode() const
bool is_observer() const
void surrender(int side_number)
static void quit_to_desktop()
static void quit_to_title()
const std::string & title() const
Definition: theme.hpp:228
bool is_context() const
Definition: theme.hpp:226
const std::vector< config > & items() const
Definition: theme.hpp:236
const action * get_action_item(const std::string &key) const
Definition: theme.cpp:927
const menu * get_menu_item(const std::string &key) const
Definition: theme.cpp:918
const std::vector< action > & actions() const
Definition: theme.hpp:258
const std::vector< menu > & menus() const
Definition: theme.hpp:256
#define LOG_HK
static lg::log_domain log_hotkey("hotkey")
#define DBG_G
static lg::log_domain log_config("config")
Declarations for File-IO.
std::size_t i
Definition: function.cpp:968
Contains the exception interfaces used to signal completion of a scenario, campaign or turn.
static std::string _(const char *str)
Definition: gettext.hpp:93
std::string tooltip
Shown when hovering over an entry in the filter's drop-down list.
Definition: manager.cpp:219
Contains functions for cleanly handling SDL input.
Standard logging facilities (interface).
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:321
std::string get_screenshot_dir()
std::string get_next_filename(const std::string &name, const std::string &extension)
Get the next free filename using "name + number (3 digits) + extension" maximum 1000 files then start...
Definition: filesystem.cpp:548
std::string selected_menu
std::string deselected_menu
std::string unchecked_menu
std::string checked_menu
std::string path
Definition: filesystem.cpp:86
static void make_screenshot()
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
Definition: message.cpp:151
@ CANCEL
Dialog was closed with the CANCEL button.
Definition: retval.hpp:38
General purpose widgets.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:144
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:414
Keyboard shortcuts for game actions.
void jhat_event(const SDL_Event &event, command_executor *executor)
void key_event(const SDL_Event &event, command_executor *executor)
void mbutton_event(const SDL_Event &event, command_executor *executor)
static void event_queue(const SDL_Event &event, command_executor *executor)
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
std::shared_ptr< class hotkey_base > hotkey_ptr
Definition: hotkey_item.hpp:27
const hotkey_ptr get_hotkey(const SDL_Event &event)
Iterate through the list of hotkeys and return a hotkey that matches the SDL_Event and the current ke...
void run_events(command_executor *executor)
void jbutton_event(const SDL_Event &event, command_executor *executor)
void keyup_event(const SDL_Event &, command_executor *executor)
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
@ HOTKEY_MINIMAP_DRAW_VILLAGES
@ HOTKEY_FULLSCREEN
@ HOTKEY_OBJECTIVES
@ HOTKEY_ANIMATE_MAP
@ HOTKEY_SCREENSHOT
@ HOTKEY_SPEAK_ALLY
@ HOTKEY_ACCELERATED
@ HOTKEY_MOUSE_SCROLL
@ HOTKEY_TERRAIN_DESCRIPTION
@ HOTKEY_END_UNIT_TURN
@ HOTKEY_LABEL_SETTINGS
@ HOTKEY_WB_EXECUTE_ALL_ACTIONS
@ HOTKEY_WB_SUPPOSE_DEAD
@ HOTKEY_HELP_ABOUT_SAVELOAD
@ HOTKEY_REPLAY_PLAY
@ HOTKEY_SCROLL_LEFT
@ HOTKEY_SAVE_GAME
@ HOTKEY_SPEAK_ALL
@ HOTKEY_SHOW_ENEMY_MOVES
@ HOTKEY_ACHIEVEMENTS
@ HOTKEY_DESELECT_HEX
@ HOTKEY_UNIT_DESCRIPTION
@ HOTKEY_UPDATE_SHROUD
@ HOTKEY_REPEAT_RECRUIT
@ HOTKEY_REPLAY_STOP
@ HOTKEY_KILL_UNIT
@ HOTKEY_SCROLL_RIGHT
@ HOTKEY_SAVE_REPLAY
@ HOTKEY_LABEL_TEAM_TERRAIN
@ HOTKEY_UNIT_HOLD_POSITION
@ HOTKEY_REPLAY_NEXT_TURN
@ HOTKEY_TOGGLE_GRID
@ HOTKEY_SURRENDER
@ HOTKEY_SELECT_AND_ACTION
@ HOTKEY_CLEAR_MSG
@ HOTKEY_REPLAY_SHOW_EVERYTHING
@ HOTKEY_REPLAY_SHOW_TEAM1
@ HOTKEY_MINIMAP_DRAW_TERRAIN
@ HOTKEY_LABEL_TERRAIN
@ HOTKEY_CUSTOM_CMD
@ HOTKEY_STOP_NETWORK
@ HOTKEY_MAP_SCREENSHOT
@ HOTKEY_CLEAR_LABELS
@ HOTKEY_CONTINUE_MOVE
@ HOTKEY_BEST_ENEMY_MOVES
@ HOTKEY_QUIT_TO_DESKTOP
@ HOTKEY_TOGGLE_ELLIPSES
@ HOTKEY_RENAME_UNIT
@ HOTKEY_MINIMAP_CODING_TERRAIN
@ HOTKEY_LOAD_GAME
@ HOTKEY_WB_EXECUTE_ACTION
@ HOTKEY_MINIMAP_DRAW_UNITS
@ HOTKEY_CHANGE_SIDE
@ HOTKEY_CYCLE_UNITS
@ HOTKEY_DELAY_SHROUD
@ HOTKEY_WB_BUMP_UP_ACTION
@ HOTKEY_CREATE_UNIT
@ HOTKEY_REPLAY_EXIT
@ HOTKEY_PREFERENCES
@ HOTKEY_STATUS_TABLE
@ HOTKEY_REPLAY_NEXT_SIDE
@ HOTKEY_MOVE_ACTION
@ HOTKEY_REPLAY_NEXT_MOVE
@ HOTKEY_REPLAY_RESET
@ HOTKEY_TOUCH_HEX
@ HOTKEY_START_NETWORK
@ HOTKEY_WB_TOGGLE
@ HOTKEY_STATISTICS
@ HOTKEY_UNIT_LIST
@ HOTKEY_SCROLL_DOWN
@ HOTKEY_REPLAY_SKIP_ANIMATION
@ HOTKEY_ZOOM_DEFAULT
@ HOTKEY_WB_BUMP_DOWN_ACTION
@ HOTKEY_SCROLL_UP
@ HOTKEY_SELECT_HEX
@ HOTKEY_QUIT_GAME
@ HOTKEY_AI_FORMULA
@ HOTKEY_REPLAY_SHOW_EACH
@ HOTKEY_CYCLE_BACK_UNITS
@ HOTKEY_WB_DELETE_ACTION
@ HOTKEY_MINIMAP_CODING_UNIT
const std::vector< std::string > items
bool set_sound(bool ison)
Definition: general.cpp:733
void toggle_minimap_draw_villages()
Definition: general.cpp:870
bool music_on()
Definition: general.cpp:751
bool sound_on()
Definition: general.cpp:728
void toggle_minimap_draw_units()
Definition: general.cpp:860
bool mouse_scroll_enabled()
Definition: general.cpp:810
bool set_music(bool ison)
Definition: general.cpp:756
void enable_mouse_scroll(bool value)
Definition: general.cpp:815
void toggle_minimap_terrain_coding()
Definition: general.cpp:850
void set_animate_map(bool value)
Definition: general.cpp:885
void toggle_minimap_draw_terrain()
Definition: general.cpp:880
bool animate_map()
Definition: general.cpp:825
void toggle_minimap_movement_coding()
Definition: general.cpp:840
play_controller * controller
Definition: resources.cpp:22
uint32_t get_mouse_state(int *x, int *y)
A wrapper for SDL_GetMouseState that gives coordinates in draw space.
Definition: input.cpp:27
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
void toggle_fullscreen()
Toggle fullscreen mode.
Definition: video.cpp:800
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
Stores all information related to functions that can be bound to hotkeys.
HOTKEY_COMMAND command
The command associated with this hotkey.
Used as the main paramneter for can_execute_command/do_execute_command These functions are used to ex...
hotkey::HOTKEY_COMMAND hotkey_command
The hotkey::HOTKEY_COMMAND associated with this action, HOTKEY_NULL for actions that don't allow hotk...
#define b