The Battle for Wesnoth  1.19.0-dev
command_executor.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
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"
24 #include "gui/widgets/retval.hpp"
25 #include "filesystem.hpp"
26 #include "gettext.hpp"
27 #include "log.hpp"
28 #include "preferences/general.hpp"
29 #include "display.hpp"
30 #include "quit_confirmation.hpp"
31 #include "sdl/surface.hpp"
32 #include "../resources.hpp"
33 #include "../playmp_controller.hpp"
34 #include "sdl/input.hpp" // get_mouse_state
35 #include "video.hpp" // toggle_fullscreen
36 
37 
38 
39 #include <ios>
40 #include <set>
41 
42 static lg::log_domain log_config("config");
43 static lg::log_domain log_hotkey("hotkey");
44 #define ERR_G LOG_STREAM(err, lg::general())
45 #define WRN_G LOG_STREAM(warn, lg::general())
46 #define LOG_G LOG_STREAM(info, lg::general())
47 #define DBG_G LOG_STREAM(debug, lg::general())
48 #define ERR_CF LOG_STREAM(err, log_config)
49 #define LOG_HK LOG_STREAM(info, log_hotkey)
50 
51 namespace {
52 
53 void make_screenshot(const std::string& name, bool map_screenshot)
54 {
55  surface screenshot = display::get_singleton()->screenshot(map_screenshot);
56  if(screenshot) {
57  std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
58  filename = filesystem::get_next_filename(filename, ".jpg");
59  gui2::dialogs::screenshot_notification::display(filename, screenshot);
60  }
61 }
62 }
63 namespace hotkey {
64 
65 static void event_queue(const SDL_Event& event, command_executor* executor);
66 
67 bool command_executor::do_execute_command(const hotkey::ui_command& cmd, bool press, bool release)
68 {
69  // hotkey release handling
70  if (release) {
71  switch(cmd.hotkey_command) {
72  // release a scroll key, un-apply scrolling in the given direction
73  case HOTKEY_SCROLL_UP:
74  scroll_up(false);
75  break;
76  case HOTKEY_SCROLL_DOWN:
77  scroll_down(false);
78  break;
79  case HOTKEY_SCROLL_LEFT:
80  scroll_left(false);
81  break;
83  scroll_right(false);
84  break;
85  default:
86  return false; // nothing else handles a hotkey release
87  }
88 
89  return true;
90  }
91 
92  // handling of hotkeys which activate even on hold events
93  switch(cmd.hotkey_command) {
96  return true;
97  case HOTKEY_SCROLL_UP:
98  scroll_up(true);
99  return true;
100  case HOTKEY_SCROLL_DOWN:
101  scroll_down(true);
102  return true;
103  case HOTKEY_SCROLL_LEFT:
104  scroll_left(true);
105  return true;
106  case HOTKEY_SCROLL_RIGHT:
107  scroll_right(true);
108  return true;
109  default:
110  break;
111  }
112 
113  if(!press) {
114  return false; // nothing else handles hotkey hold events
115  }
116 
117  // hotkey press handling
118  switch(cmd.hotkey_command) {
119  case HOTKEY_CYCLE_UNITS:
120  cycle_units();
121  break;
124  break;
125  case HOTKEY_ENDTURN:
126  end_turn();
127  break;
130  break;
132  end_unit_turn();
133  break;
134  case HOTKEY_LEADER:
135  goto_leader();
136  break;
137  case HOTKEY_UNDO:
138  undo();
139  break;
140  case HOTKEY_REDO:
141  redo();
142  break;
145  break;
148  break;
149  case HOTKEY_RENAME_UNIT:
150  rename_unit();
151  break;
152  case HOTKEY_SAVE_GAME:
153  save_game();
154  break;
155  case HOTKEY_SAVE_REPLAY:
156  save_replay();
157  break;
158  case HOTKEY_SAVE_MAP:
159  save_map();
160  break;
161  case HOTKEY_LOAD_GAME:
162  load_game();
163  break;
165  toggle_ellipses();
166  break;
167  case HOTKEY_TOGGLE_GRID:
168  toggle_grid();
169  break;
170  case HOTKEY_STATUS_TABLE:
171  status_table();
172  break;
173  case HOTKEY_RECALL:
174  recall();
175  break;
177  label_settings();
178  break;
179  case HOTKEY_RECRUIT:
180  recruit();
181  break;
182  case HOTKEY_SPEAK:
183  speak();
184  break;
185  case HOTKEY_SPEAK_ALLY:
186  whisper();
187  break;
188  case HOTKEY_SPEAK_ALL:
189  shout();
190  break;
191  case HOTKEY_CREATE_UNIT:
192  create_unit();
193  break;
194  case HOTKEY_CHANGE_SIDE:
195  change_side();
196  break;
197  case HOTKEY_KILL_UNIT:
198  kill_unit();
199  break;
200  case HOTKEY_PREFERENCES:
201  preferences();
202  break;
203  case HOTKEY_OBJECTIVES:
204  objectives();
205  break;
206  case HOTKEY_UNIT_LIST:
207  unit_list();
208  break;
209  case HOTKEY_STATISTICS:
210  show_statistics();
211  break;
212  case HOTKEY_STOP_NETWORK:
213  stop_network();
214  break;
216  start_network();
217  break;
219  label_terrain(true);
220  break;
222  label_terrain(false);
223  break;
224  case HOTKEY_CLEAR_LABELS:
225  clear_labels();
226  break;
228  show_enemy_moves(false);
229  break;
231  show_enemy_moves(true);
232  break;
233  case HOTKEY_DELAY_SHROUD:
235  break;
238  break;
240  continue_move();
241  break;
242  case HOTKEY_SEARCH:
243  search();
244  break;
245  case HOTKEY_HELP:
246  show_help();
247  break;
249  // although HOTKEY_HELP uses a virtual call to allow context-specific help, this one is already a specific topic
250  help::show_help("saveload");
251  break;
252  case HOTKEY_CHAT_LOG:
253  show_chat_log();
254  break;
255  case HOTKEY_USER_CMD:
256  user_command();
257  break;
258  case HOTKEY_CUSTOM_CMD:
259  custom_command();
260  break;
261  case HOTKEY_AI_FORMULA:
262  ai_formula();
263  break;
264  case HOTKEY_CLEAR_MSG:
265  clear_messages();
266  break;
267  case HOTKEY_LANGUAGE:
268  change_language();
269  break;
270  case HOTKEY_REPLAY_PLAY:
271  play_replay();
272  break;
273  case HOTKEY_REPLAY_RESET:
274  reset_replay();
275  break;
276  case HOTKEY_REPLAY_STOP:
277  stop_replay();
278  break;
281  break;
284  break;
287  break;
290  break;
293  break;
296  break;
299  break;
300  case HOTKEY_REPLAY_EXIT:
301  replay_exit();
302  break;
303  case HOTKEY_WB_TOGGLE:
305  break;
308  break;
311  break;
314  break;
317  break;
320  break;
323  break;
324  case HOTKEY_SELECT_HEX:
325  select_hex();
326  break;
327  case HOTKEY_DESELECT_HEX:
328  deselect_hex();
329  break;
330  case HOTKEY_MOVE_ACTION:
331  move_action();
332  break;
335  break;
336  case HOTKEY_TOUCH_HEX:
337  touch_hex();
338  break;
339  case HOTKEY_ACCELERATED:
341  break;
342  case LUA_CONSOLE:
343  lua_console();
344  break;
345  case HOTKEY_ZOOM_IN:
346  zoom_in();
347  break;
348  case HOTKEY_ZOOM_OUT:
349  zoom_out();
350  break;
351  case HOTKEY_ZOOM_DEFAULT:
352  zoom_default();
353  break;
355  map_screenshot();
356  break;
359  break;
360  case HOTKEY_QUIT_GAME:
362  break;
363  case HOTKEY_SURRENDER:
364  surrender_game();
365  break;
369  break;
373  break;
377  break;
381  break;
385  break;
386  case HOTKEY_ACHIEVEMENTS:
387  {
389  ach.show();
390  }
391  break;
392  default:
393  return false;
394  }
395  return true;
396 }
397 
399  if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
401  if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
403  }
404  }
405 }
406 
407 void command_executor::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
408 {
409  std::vector<config> items = items_arg;
410  if (items.empty()) return;
411 
413 
414  int res = -1;
415  {
416  SDL_Rect pos {xloc, yloc, 1, 1};
417  gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
418  if(mmenu.show()) {
419  res = mmenu.selected_item();
420  }
421  } // This will kill the dialog.
422  if (res < 0 || std::size_t(res) >= items.size()) return;
423 
424  std::string id = items[res]["id"];
425  const theme::menu* submenu = gui.get_theme().get_menu_item(id);
426  if (submenu) {
427  int y,x;
428  sdl::get_mouse_state(&x,&y);
429  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
430  } else {
431  hotkey::ui_command cmd = hotkey::ui_command(id, res);
432  do_execute_command(cmd);
434  }
435 }
436 
437 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
438 {
439  std::vector<std::string> items = items_arg;
440  if (items.empty()) {
441  return;
442  }
443 
445  while(i != items.end()) {
447  if (can_execute_command(cmd)) {
448  do_execute_command(cmd);
450  }
451  ++i;
452  }
453 }
454 
455 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const
456 {
457  const std::string base_image_name = "icons/action/" + command + "_25.png";
458  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
459 
461  const hotkey::ACTION_STATE state = get_action_state(cmd);
462 
463  const theme::menu* menu = disp.get_theme().get_menu_item(command);
464  if (menu) {
465  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
466  }
467 
468  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
469  switch (state) {
470  case ACTION_ON:
471  case ACTION_SELECTED:
472  return pressed_image_name + "~CROP(3,3,18,18)";
473  default:
474  return base_image_name + "~CROP(3,3,18,18)";
475  }
476  }
477 
478  switch (get_action_state(cmd)) {
479  case ACTION_ON:
481  case ACTION_OFF:
483  case ACTION_SELECTED:
485  case ACTION_DESELECTED:
487  default: return get_action_image(cmd);
488  }
489 }
490 
491 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
492 {
493  for(std::size_t i = 0; i < items.size(); ++i) {
494  config& item = items[i];
495 
496  const std::string& item_id = item["id"];
498 
499  //see if this menu item has an associated image
500  std::string img(get_menu_image(disp, item_id, i));
501  if (img.empty() == false) {
502  item["icon"] = img;
503  }
504 
505  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
506  if(menu) {
507  item["label"] = menu->title();
508  } else if(hk != hotkey::HOTKEY_NULL) {
509  std::string desc = hotkey::get_hotkey_command(item_id).description;
510  if(hk == HOTKEY_ENDTURN) {
511  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
512  if (b) {
513  desc = b->title();
514  }
515  }
516 
517  item["label"] = desc;
518  item["details"] = hotkey::get_names(item_id);
519  }
520  }
521 }
522 
523 void mbutton_event(const SDL_Event& event, command_executor* executor)
524 {
525  event_queue(event, executor);
526 
527  /* Run mouse events immediately.
528 
529  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
530  button has received the mouse press event but before it has received the mouse release event.
531  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
532  set_button_state() ended up being called at such a time. However, if we run the event handlers
533  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
534  safely.
535 
536  See https://github.com/wesnoth/wesnoth/issues/2884 */
537 
538  run_events(executor);
539 }
540 
541 void jbutton_event(const SDL_Event& event, command_executor* executor)
542 {
543  event_queue(event, executor);
544 }
545 
546 void jhat_event(const SDL_Event& event, command_executor* executor)
547 {
548  event_queue(event, executor);
549 }
550 
551 void key_event(const SDL_Event& event, command_executor* executor)
552 {
553  if (!executor) return;
554  event_queue(event,executor);
555 }
556 
557 void keyup_event(const SDL_Event&, command_executor* executor)
558 {
559  if(!executor) return;
560  executor->handle_keyup();
561 }
562 
564 {
565  if(!executor) return;
566  bool commands_ran = executor->run_queued_commands();
567  if(commands_ran) {
568  executor->set_button_state();
569  }
570 }
571 
572 static void event_queue(const SDL_Event& event, command_executor* executor)
573 {
574  if (!executor) return;
575  executor->queue_command(event);
576  executor->set_button_state();
577 }
578 
579 void command_executor::queue_command(const SDL_Event& event, int index)
580 {
581  LOG_HK << "event 0x" << std::hex << event.type << std::dec;
582  if(event.type == SDL_TEXTINPUT) {
583  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"";
584  }
585 
586  const hotkey_ptr hk = get_hotkey(event);
587  if(!hk->active() || hk->is_disabled()) {
588  return;
589  }
590 
591  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
592  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
594  bool press = keypress ||
595  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
596  bool release = event.type == SDL_KEYUP;
597  if(press) {
598  LOG_HK << "sending press event (keypress = " <<
599  std::boolalpha << keypress << std::noboolalpha << ")";
600  }
601  if(keypress) {
602  press_event_sent_ = true;
603  }
604 
605  command_queue_.emplace_back(command, index, press, release);
606 }
607 
609 {
610  auto ui_cmd = hotkey::ui_command(*command.command, command.index);
611  if (!can_execute_command(ui_cmd)
612  || do_execute_command(ui_cmd, command.press, command.release)) {
613  return;
614  }
615 
616  if (!command.press) {
617  return; // none of the commands here respond to a key release
618  }
619 
620  switch(command.command->command) {
621  case HOTKEY_FULLSCREEN:
623  break;
624  case HOTKEY_SCREENSHOT:
625  make_screenshot(_("Screenshot"), false);
626  break;
627  case HOTKEY_ANIMATE_MAP:
629  break;
630  case HOTKEY_MOUSE_SCROLL:
632  break;
633  case HOTKEY_MUTE:
634  {
635  // look if both is not playing
636  static struct before_muted_s
637  {
638  bool playing_sound,playing_music;
639  before_muted_s() : playing_sound(false),playing_music(false){}
640  } before_muted;
642  {
643  // then remember settings and mute both
644  before_muted.playing_sound = preferences::sound_on();
645  before_muted.playing_music = preferences::music_on();
646  preferences::set_sound(false);
647  preferences::set_music(false);
648  }
649  else
650  {
651  // then set settings before mute
652  preferences::set_sound(before_muted.playing_sound);
653  preferences::set_music(before_muted.playing_music);
654  }
655  }
656  break;
657  default:
658  DBG_G << "command_executor: unknown command number " << command.command->command << ", ignoring.";
659  break;
660  }
661 }
662 
664 {
665  display& disp = get_display();
666  for (const theme::menu& menu : disp.get_theme().menus()) {
667 
668  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
669  if (!button) continue;
670  bool enabled = false;
671  for (const auto& command : menu.items()) {
672 
673  ui_command command_obj = ui_command(command["id"].str());
674  bool can_execute = can_execute_command(command_obj);
675  if (can_execute) {
676  enabled = true;
677  break;
678  }
679  }
680  button->enable(enabled);
681  }
682 
683  for (const theme::action& action : disp.get_theme().actions()) {
684 
685  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
686  if (!button) continue;
687  bool enabled = false;
688  int i = 0;
689  for (const std::string& command : action.items()) {
690 
691  ui_command command_obj = ui_command(command);
692  std::string tooltip = action.tooltip(i);
693  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
694  button->set_overlay("icons/action/" + command);
695  if (!tooltip.empty())
696  button->set_tooltip_string(tooltip);
697 
698  bool can_execute = can_execute_command(command_obj);
699  i++;
700  if (!can_execute) continue;
701  enabled = true;
702 
703  ACTION_STATE state = get_action_state(command_obj);
704  switch (state) {
705  case ACTION_SELECTED:
706  case ACTION_ON:
707  button->set_check(true);
708  break;
709  case ACTION_OFF:
710  case ACTION_DESELECTED:
711  button->set_check(false);
712  break;
713  case ACTION_STATELESS:
714  break;
715  default:
716  break;
717  }
718 
719  break;
720  }
721  button->enable(enabled);
722  }
723 }
724 
725 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
726 // See https://github.com/wesnoth/wesnoth/issues/1736
727 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
728 {
729  std::vector<queued_command> filtered_commands;
730 
731  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
732  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
733  std::set<command_with_keyrelease> seen_commands;
734 
735  for(const queued_command& cmd : command_queue_) {
736  command_with_keyrelease command_key(cmd.command, cmd.release);
737  if(seen_commands.find(command_key) == seen_commands.end()) {
738  seen_commands.insert(command_key);
739  filtered_commands.push_back(cmd);
740  }
741  }
742 
743  command_queue_.clear();
744 
745  return filtered_commands;
746 }
747 
749 {
750  std::vector<queued_command> commands = filter_command_queue();
751  for(const queued_command& cmd : commands) {
753  }
754 
755  return !commands.empty();
756 }
757 
759 {
761 }
762 
764 {
765  if (get_display().in_game()) {
767  } else {
769  }
770 
771 }
772 
774 {
776 }
777 
779 {
780  if(!get_display().view_locked()) {
781  get_display().set_zoom(true);
782  }
783 }
784 
786 {
787  if(!get_display().view_locked()) {
788  get_display().set_zoom(false);
789  }
790 }
791 
793 {
794  if(!get_display().view_locked()) {
796  }
797 }
798 
800 {
801  make_screenshot(_("Map-Screenshot"), true);
802 }
803 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:81
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:116
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.cpp:1652
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:805
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:815
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
Definition: display.cpp:1887
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:757
theme & get_theme()
Definition: display.hpp:380
void toggle_default_zoom()
Sets the zoom amount to the default.
Definition: display.cpp:1956
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:95
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:926
const menu * get_menu_item(const std::string &key) const
Definition: theme.cpp:917
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
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:211
Contains functions for cleanly handling SDL input.
Standard logging facilities (interface).
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:318
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:545
std::string selected_menu
std::string deselected_menu
std::string unchecked_menu
std::string checked_menu
std::string path
Definition: filesystem.cpp:83
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:150
@ 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:140
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:412
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:862
bool music_on()
Definition: general.cpp:751
bool sound_on()
Definition: general.cpp:728
void toggle_minimap_draw_units()
Definition: general.cpp:852
bool mouse_scroll_enabled()
Definition: general.cpp:802
bool set_music(bool ison)
Definition: general.cpp:756
void enable_mouse_scroll(bool value)
Definition: general.cpp:807
void toggle_minimap_terrain_coding()
Definition: general.cpp:842
void set_animate_map(bool value)
Definition: general.cpp:877
void toggle_minimap_draw_terrain()
Definition: general.cpp:872
bool animate_map()
Definition: general.cpp:817
void toggle_minimap_movement_coding()
Definition: general.cpp:832
play_controller * controller
Definition: resources.cpp:21
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:70
void toggle_fullscreen()
Toggle fullscreen mode.
Definition: video.cpp:796
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