The Battle for Wesnoth  1.17.4+dev
command_executor.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2022
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 
20 #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 "game_end_exceptions.hpp"
30 #include "display.hpp"
31 #include "quit_confirmation.hpp"
32 #include "sdl/surface.hpp"
33 #include "show_dialog.hpp"
34 #include "../resources.hpp"
35 #include "../playmp_controller.hpp"
36 #include "sdl/input.hpp" // get_mouse_state
37 
38 #include <functional>
39 
40 #include <SDL2/SDL_image.h>
41 
42 #include <cassert>
43 #include <ios>
44 #include <set>
45 
46 static lg::log_domain log_config("config");
47 static lg::log_domain log_hotkey("hotkey");
48 #define ERR_G LOG_STREAM(err, lg::general())
49 #define WRN_G LOG_STREAM(warn, lg::general())
50 #define LOG_G LOG_STREAM(info, lg::general())
51 #define DBG_G LOG_STREAM(debug, lg::general())
52 #define ERR_CF LOG_STREAM(err, log_config)
53 #define LOG_HK LOG_STREAM(info, log_hotkey)
54 
55 namespace {
56 
57 void make_screenshot(const std::string& name, bool map_screenshot)
58 {
59  surface screenshot = display::get_singleton()->screenshot(map_screenshot);
60  if(screenshot) {
61  std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
62  filename = filesystem::get_next_filename(filename, ".jpg");
63  gui2::dialogs::screenshot_notification::display(filename, screenshot);
64  }
65 }
66 }
67 namespace hotkey {
68 
69 static void event_queue(const SDL_Event& event, command_executor* executor);
70 
71 bool command_executor::do_execute_command(const hotkey_command& cmd, int /*index*/, bool press, bool release)
72 {
73  // hotkey release handling
74  if (release) {
75  switch(cmd.id) {
76  // release a scroll key, un-apply scrolling in the given direction
77  case HOTKEY_SCROLL_UP:
78  scroll_up(false);
79  break;
80  case HOTKEY_SCROLL_DOWN:
81  scroll_down(false);
82  break;
83  case HOTKEY_SCROLL_LEFT:
84  scroll_left(false);
85  break;
87  scroll_right(false);
88  break;
89  default:
90  return false; // nothing else handles a hotkey release
91  }
92 
93  return true;
94  }
95 
96  // handling of hotkeys which activate even on hold events
97  switch(cmd.id) {
100  return true;
101  case HOTKEY_SCROLL_UP:
102  scroll_up(true);
103  return true;
104  case HOTKEY_SCROLL_DOWN:
105  scroll_down(true);
106  return true;
107  case HOTKEY_SCROLL_LEFT:
108  scroll_left(true);
109  return true;
110  case HOTKEY_SCROLL_RIGHT:
111  scroll_right(true);
112  return true;
113  default:
114  break;
115  }
116 
117  if(!press) {
118  return false; // nothing else handles hotkey hold events
119  }
120 
121  // hotkey press handling
122  switch(cmd.id) {
123  case HOTKEY_CYCLE_UNITS:
124  cycle_units();
125  break;
128  break;
129  case HOTKEY_ENDTURN:
130  end_turn();
131  break;
134  break;
136  end_unit_turn();
137  break;
138  case HOTKEY_LEADER:
139  goto_leader();
140  break;
141  case HOTKEY_UNDO:
142  undo();
143  break;
144  case HOTKEY_REDO:
145  redo();
146  break;
149  break;
152  break;
153  case HOTKEY_RENAME_UNIT:
154  rename_unit();
155  break;
156  case HOTKEY_SAVE_GAME:
157  save_game();
158  break;
159  case HOTKEY_SAVE_REPLAY:
160  save_replay();
161  break;
162  case HOTKEY_SAVE_MAP:
163  save_map();
164  break;
165  case HOTKEY_LOAD_GAME:
166  load_game();
167  break;
169  toggle_ellipses();
170  break;
171  case HOTKEY_TOGGLE_GRID:
172  toggle_grid();
173  break;
174  case HOTKEY_STATUS_TABLE:
175  status_table();
176  break;
177  case HOTKEY_RECALL:
178  recall();
179  break;
181  label_settings();
182  break;
183  case HOTKEY_RECRUIT:
184  recruit();
185  break;
186  case HOTKEY_SPEAK:
187  speak();
188  break;
189  case HOTKEY_SPEAK_ALLY:
190  whisper();
191  break;
192  case HOTKEY_SPEAK_ALL:
193  shout();
194  break;
195  case HOTKEY_CREATE_UNIT:
196  create_unit();
197  break;
198  case HOTKEY_CHANGE_SIDE:
199  change_side();
200  break;
201  case HOTKEY_KILL_UNIT:
202  kill_unit();
203  break;
204  case HOTKEY_PREFERENCES:
205  preferences();
206  break;
207  case HOTKEY_OBJECTIVES:
208  objectives();
209  break;
210  case HOTKEY_UNIT_LIST:
211  unit_list();
212  break;
213  case HOTKEY_STATISTICS:
214  show_statistics();
215  break;
216  case HOTKEY_STOP_NETWORK:
217  stop_network();
218  break;
220  start_network();
221  break;
223  label_terrain(true);
224  break;
226  label_terrain(false);
227  break;
228  case HOTKEY_CLEAR_LABELS:
229  clear_labels();
230  break;
232  show_enemy_moves(false);
233  break;
235  show_enemy_moves(true);
236  break;
237  case HOTKEY_DELAY_SHROUD:
239  break;
242  break;
244  continue_move();
245  break;
246  case HOTKEY_SEARCH:
247  search();
248  break;
249  case HOTKEY_HELP:
250  show_help();
251  break;
253  // although HOTKEY_HELP uses a virtual call to allow context-specific help, this one is already a specific topic
254  help::show_help("saveload");
255  break;
256  case HOTKEY_CHAT_LOG:
257  show_chat_log();
258  break;
259  case HOTKEY_USER_CMD:
260  user_command();
261  break;
262  case HOTKEY_CUSTOM_CMD:
263  custom_command();
264  break;
265  case HOTKEY_AI_FORMULA:
266  ai_formula();
267  break;
268  case HOTKEY_CLEAR_MSG:
269  clear_messages();
270  break;
271  case HOTKEY_LANGUAGE:
272  change_language();
273  break;
274  case HOTKEY_REPLAY_PLAY:
275  play_replay();
276  break;
277  case HOTKEY_REPLAY_RESET:
278  reset_replay();
279  break;
280  case HOTKEY_REPLAY_STOP:
281  stop_replay();
282  break;
285  break;
288  break;
291  break;
294  break;
297  break;
300  break;
303  break;
304  case HOTKEY_REPLAY_EXIT:
305  replay_exit();
306  break;
307  case HOTKEY_WB_TOGGLE:
309  break;
312  break;
315  break;
318  break;
321  break;
324  break;
327  break;
328  case HOTKEY_SELECT_HEX:
329  select_hex();
330  break;
331  case HOTKEY_DESELECT_HEX:
332  deselect_hex();
333  break;
334  case HOTKEY_MOVE_ACTION:
335  move_action();
336  break;
339  break;
340  case HOTKEY_TOUCH_HEX:
341  touch_hex();
342  break;
343  case HOTKEY_ACCELERATED:
345  break;
346  case LUA_CONSOLE:
347  lua_console();
348  break;
349  case HOTKEY_ZOOM_IN:
350  zoom_in();
351  break;
352  case HOTKEY_ZOOM_OUT:
353  zoom_out();
354  break;
355  case HOTKEY_ZOOM_DEFAULT:
356  zoom_default();
357  break;
359  map_screenshot();
360  break;
363  break;
364  case HOTKEY_QUIT_GAME:
366  break;
367  case HOTKEY_SURRENDER:
368  surrender_game();
369  break;
373  break;
377  break;
381  break;
385  break;
389  break;
390  default:
391  return false;
392  }
393  return true;
394 }
395 
397  if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
399  if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
400  pmc->surrender(display::get_singleton()->viewing_team());
401  }
402  }
403 }
404 
405 void command_executor::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
406 {
407  std::vector<config> items = items_arg;
408  if (items.empty()) return;
409 
410  get_menu_images(gui, items);
411 
412  int res = -1;
413  {
414  SDL_Rect pos {xloc, yloc, 1, 1};
415  gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
416  if(mmenu.show()) {
417  res = mmenu.selected_item();
418  }
419  } // This will kill the dialog.
420  if (res < 0 || std::size_t(res) >= items.size()) return;
421 
422  const theme::menu* submenu = gui.get_theme().get_menu_item(items[res]["id"]);
423  if (submenu) {
424  int y,x;
425  sdl::get_mouse_state(&x,&y);
426  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
427  } else {
428  const hotkey::hotkey_command& cmd = hotkey::get_hotkey_command(items[res]["id"]);
429  do_execute_command(cmd, res);
431  }
432 }
433 
434 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
435 {
436  std::vector<std::string> items = items_arg;
437  if (items.empty()) {
438  return;
439  }
440 
441  std::vector<std::string>::iterator i = items.begin();
442  while(i != items.end()) {
443  const hotkey_command &command = hotkey::get_hotkey_command(*i);
444  if (can_execute_command(command)) {
445  do_execute_command(command);
447  }
448  ++i;
449  }
450 }
451 
452 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const {
453 
454  // TODO: Find a way to do away with the fugly special markup
455  if(command[0] == '&') {
456  std::size_t n = command.find_first_of('=');
457  if(n != std::string::npos)
458  return command.substr(1, n - 1);
459  }
460 
461  const std::string base_image_name = "icons/action/" + command + "_25.png";
462  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
463 
464  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(command);
465  const hotkey::ACTION_STATE state = get_action_state(hk, index);
466 
467  const theme::menu* menu = disp.get_theme().get_menu_item(command);
468  if (menu) {
469  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
470  }
471 
472  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
473  switch (state) {
474  case ACTION_ON:
475  case ACTION_SELECTED:
476  return pressed_image_name + "~CROP(3,3,18,18)";
477  default:
478  return base_image_name + "~CROP(3,3,18,18)";
479  }
480  }
481 
482  switch (get_action_state(hk, index)) {
483  case ACTION_ON:
485  case ACTION_OFF:
487  case ACTION_SELECTED:
489  case ACTION_DESELECTED:
491  default: return get_action_image(hk, index);
492  }
493 }
494 
495 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
496 {
497  for(std::size_t i = 0; i < items.size(); ++i) {
498  config& item = items[i];
499 
500  const std::string& item_id = item["id"];
501  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item_id);
502 
503  //see if this menu item has an associated image
504  std::string img(get_menu_image(disp, item_id, i));
505  if (img.empty() == false) {
506  item["icon"] = img;
507  }
508 
509  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
510  if(menu) {
511  item["label"] = menu->title();
512  } else if(hk != hotkey::HOTKEY_NULL) {
513  std::string desc = hotkey::get_description(item_id);
514  if(hk == HOTKEY_ENDTURN) {
515  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
516  if (b) {
517  desc = b->title();
518  }
519  }
520 
521  item["label"] = desc;
522  item["details"] = hotkey::get_names(item_id);
523  } else if(item["label"].empty()) {
524  // If no matching hotkey was found and a custom label wasn't already set, treat
525  // the id as a plaintext description. This is because either type of value can
526  // be written to the id field by the WMI manager. The plaintext description is
527  // used in the case the menu item specifies the relevant entry is *not* a hotkey.
528  item["label"] = item_id;
529  }
530  }
531 }
532 
533 void mbutton_event(const SDL_Event& event, command_executor* executor)
534 {
535  event_queue(event, executor);
536 
537  /* Run mouse events immediately.
538 
539  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
540  button has received the mouse press event but before it has received the mouse release event.
541  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
542  set_button_state() ended up being called at such a time. However, if we run the event handlers
543  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
544  safely.
545 
546  See https://github.com/wesnoth/wesnoth/issues/2884 */
547 
548  run_events(executor);
549 }
550 
551 void jbutton_event(const SDL_Event& event, command_executor* executor)
552 {
553  event_queue(event, executor);
554 }
555 
556 void jhat_event(const SDL_Event& event, command_executor* executor)
557 {
558  event_queue(event, executor);
559 }
560 
561 void key_event(const SDL_Event& event, command_executor* executor)
562 {
563  if (!executor) return;
564  event_queue(event,executor);
565 }
566 
567 void keyup_event(const SDL_Event&, command_executor* executor)
568 {
569  if(!executor) return;
570  executor->handle_keyup();
571 }
572 
574 {
575  if(!executor) return;
576  bool commands_ran = executor->run_queued_commands();
577  if(commands_ran) {
578  executor->set_button_state();
579  }
580 }
581 
582 static void event_queue(const SDL_Event& event, command_executor* executor)
583 {
584  if (!executor) return;
585  executor->queue_command(event);
586  executor->set_button_state();
587 }
588 
589 void command_executor::queue_command(const SDL_Event& event, int index)
590 {
591  LOG_HK << "event 0x" << std::hex << event.type << std::dec << std::endl;
592  if(event.type == SDL_TEXTINPUT) {
593  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"\n";
594  }
595 
596  const hotkey_ptr hk = get_hotkey(event);
597  if(!hk->active() || hk->is_disabled()) {
598  return;
599  }
600 
601  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
602  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
604  bool press = keypress ||
605  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
606  bool release = event.type == SDL_KEYUP;
607  if(press) {
608  LOG_HK << "sending press event (keypress = " <<
609  std::boolalpha << keypress << std::noboolalpha << ")\n";
610  }
611  if(keypress) {
612  press_event_sent_ = true;
613  }
614 
615  command_queue_.emplace_back(command, index, press, release);
616 }
617 
619 {
620  if (!can_execute_command(*command.command, command.index)
621  || do_execute_command(*command.command, command.index, command.press, command.release)) {
622  return;
623  }
624 
625  if (!command.press) {
626  return; // none of the commands here respond to a key release
627  }
628 
629  switch (command.command->id) {
630  case HOTKEY_FULLSCREEN:
632  break;
633  case HOTKEY_SCREENSHOT:
634  make_screenshot(_("Screenshot"), false);
635  break;
636  case HOTKEY_ANIMATE_MAP:
638  break;
639  case HOTKEY_MOUSE_SCROLL:
641  break;
642  case HOTKEY_MUTE:
643  {
644  // look if both is not playing
645  static struct before_muted_s
646  {
647  bool playing_sound,playing_music;
648  before_muted_s() : playing_sound(false),playing_music(false){}
649  } before_muted;
651  {
652  // then remember settings and mute both
653  before_muted.playing_sound = preferences::sound_on();
654  before_muted.playing_music = preferences::music_on();
655  preferences::set_sound(false);
656  preferences::set_music(false);
657  }
658  else
659  {
660  // then set settings before mute
661  preferences::set_sound(before_muted.playing_sound);
662  preferences::set_music(before_muted.playing_music);
663  }
664  }
665  break;
666  default:
667  DBG_G << "command_executor: unknown command number " << command.command->id << ", ignoring.\n";
668  break;
669  }
670 }
671 
673 {
674  display& disp = get_display();
675  for (const theme::menu& menu : disp.get_theme().menus()) {
676 
677  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
678  if (!button) continue;
679  bool enabled = false;
680  for (const auto& command : menu.items()) {
681 
682  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command["id"]);
683  bool can_execute = can_execute_command(command_obj);
684  if (can_execute) {
685  enabled = true;
686  break;
687  }
688  }
689  button->enable(enabled);
690  }
691 
692  for (const theme::action& action : disp.get_theme().actions()) {
693 
694  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
695  if (!button) continue;
696  bool enabled = false;
697  int i = 0;
698  for (const std::string& command : action.items()) {
699 
700  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command);
701  std::string tooltip = action.tooltip(i);
702  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
703  button->set_overlay("icons/action/" + command);
704  if (!tooltip.empty())
705  button->set_tooltip_string(tooltip);
706 
707  bool can_execute = can_execute_command(command_obj);
708  i++;
709  if (!can_execute) continue;
710  enabled = true;
711 
712  ACTION_STATE state = get_action_state(command_obj.id, -1);
713  switch (state) {
714  case ACTION_SELECTED:
715  case ACTION_ON:
716  button->set_check(true);
717  break;
718  case ACTION_OFF:
719  case ACTION_DESELECTED:
720  button->set_check(false);
721  break;
722  case ACTION_STATELESS:
723  break;
724  default:
725  break;
726  }
727 
728  break;
729  }
730  button->enable(enabled);
731  }
732 }
733 
734 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
735 // See https://github.com/wesnoth/wesnoth/issues/1736
736 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
737 {
738  std::vector<queued_command> filtered_commands;
739 
740  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
741  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
742  std::set<command_with_keyrelease> seen_commands;
743 
744  for(const queued_command& cmd : command_queue_) {
745  command_with_keyrelease command_key(cmd.command, cmd.release);
746  if(seen_commands.find(command_key) == seen_commands.end()) {
747  seen_commands.insert(command_key);
748  filtered_commands.push_back(cmd);
749  }
750  }
751 
752  command_queue_.clear();
753 
754  return filtered_commands;
755 }
756 
758 {
759  std::vector<queued_command> commands = filter_command_queue();
760  for(const queued_command& cmd : commands) {
762  }
763 
764  return !commands.empty();
765 }
766 
768 {
769  get_display().recalculate_minimap();
770 }
771 
773 {
774  if (get_display().in_game()) {
776  } else {
778  }
779 
780 }
781 
783 {
785 }
786 
788 {
789  if(!get_display().view_locked()) {
790  get_display().set_zoom(true);
791  }
792 }
793 
795 {
796  if(!get_display().view_locked()) {
797  get_display().set_zoom(false);
798  }
799 }
800 
802 {
803  if(!get_display().view_locked()) {
804  get_display().toggle_default_zoom();
805  }
806 }
807 
809 {
810  make_screenshot(_("Map-Screenshot"), true);
811 }
812 }
#define LOG_HK
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:821
play_controller * controller
Definition: resources.cpp:22
Dialog was closed with the CANCEL button.
Definition: retval.hpp:38
bool set_sound(bool ison)
Definition: general.cpp:730
virtual void toggle_shroud_updates()
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:153
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
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:96
HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
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:490
theme & get_theme()
Definition: display.hpp:382
void surrender(int side_number)
static void quit_to_title()
const action * get_action_item(const std::string &key) const
Definition: theme.cpp:926
const std::string & title() const
Definition: theme.hpp:227
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:263
std::string selected_menu
General purpose widgets.
void enable_mouse_scroll(bool value)
Definition: general.cpp:812
Stores all information related to functions that can be bound to hotkeys.
virtual void terrain_description()
const std::vector< std::string > items
std::string get_screenshot_dir()
static CVideo & get_singleton()
Definition: video.hpp:52
void mbutton_event(const SDL_Event &event, command_executor *executor)
std::string unchecked_menu
virtual void recalculate_minimap()
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
static std::string _(const char *str)
Definition: gettext.hpp:93
bool show(const unsigned auto_close_time=0)
Shows the window.
virtual void whiteboard_execute_action()
virtual void scroll_up(bool)
bool sound_on()
Definition: general.cpp:725
Contains functions for cleanly handling SDL input.
Keyboard shortcuts for game actions.
virtual void whiteboard_delete_action()
virtual bool can_execute_command(const hotkey_command &command, int index=-1) const =0
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
virtual void whiteboard_bump_up_action()
virtual void label_terrain(bool)
#define b
void run_events(command_executor *executor)
static lg::log_domain log_config("config")
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
static void event_queue(const SDL_Event &event, command_executor *executor)
std::string deselected_menu
void get_menu_images(display &, std::vector< config > &items)
virtual void replay_show_team1()
void jbutton_event(const SDL_Event &event, command_executor *executor)
void toggle_minimap_draw_units()
Definition: general.cpp:857
bool is_linger_mode() const
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:779
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...
virtual void unit_hold_position()
virtual void scroll_right(bool)
Used by the menu_button widget.
virtual void show_menu(const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
void keyup_event(const SDL_Event &, command_executor *executor)
virtual void show_enemy_moves(bool)
std::string path
Definition: game_config.cpp:39
Shows a yes and no button.
Definition: message.hpp:80
void toggle_minimap_draw_terrain()
Definition: general.cpp:877
map_display and display: classes which take care of displaying the map and game-data on the screen...
bool animate_map()
Definition: general.cpp:822
void set_animate_map(bool value)
Definition: general.cpp:882
void jhat_event(const SDL_Event &event, command_executor *executor)
bool is_observer() const
void toggle_minimap_draw_villages()
Definition: general.cpp:867
void queue_command(const SDL_Event &event, int index=-1)
std::string get_menu_image(display &disp, const std::string &command, int index=-1) const
void execute_command_wrap(const queued_command &command)
static lg::log_domain log_hotkey("hotkey")
static void quit_to_desktop()
std::size_t i
Definition: function.cpp:967
const std::vector< config > & items() const
Definition: theme.hpp:235
virtual void scroll_left(bool)
std::vector< queued_command > command_queue_
virtual void update_shroud_now()
void toggle_minimap_terrain_coding()
Definition: general.cpp:847
void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
void toggle_fullscreen()
Definition: video.cpp:696
virtual void replay_show_everything()
bool music_on()
Definition: general.cpp:748
virtual void scroll_down(bool)
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int) const
void toggle_minimap_movement_coding()
Definition: general.cpp:837
virtual bool do_execute_command(const hotkey_command &command, int index=-1, bool press=true, bool release=false)
Declarations for File-IO.
bool is_context() const
Definition: theme.hpp:225
const menu * get_menu_item(const std::string &key) const
Definition: theme.cpp:917
std::shared_ptr< hotkey_base > hotkey_ptr
Definition: hotkey_item.hpp:32
const std::vector< action > & actions() const
Definition: theme.hpp:257
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
virtual void whiteboard_suppose_dead()
void key_event(const SDL_Event &event, command_executor *executor)
const std::string & get_description(const std::string &command)
virtual void whiteboard_bump_down_action()
bool mouse_scroll_enabled()
Definition: general.cpp:807
const std::string & title() const
Definition: theme.hpp:172
virtual void whiteboard_execute_all_actions()
virtual ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND, int) const
uint32_t get_mouse_state(int *x, int *y)
A wrapper for SDL_GetMouseState that gives coordinates in draw space.
Definition: input.cpp:29
bool set_music(bool ison)
Definition: general.cpp:753
Standard logging facilities (interface).
std::vector< queued_command > filter_command_queue()
#define DBG_G
const std::vector< menu > & menus() const
Definition: theme.hpp:255
std::string checked_menu
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
static void make_screenshot()
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
static map_location::DIRECTION n
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:831
HOTKEY_COMMAND get_id(const std::string &command)
returns get_hotkey_command(command).id
virtual void replay_skip_animation()
std::string tooltip
Shown when hovering over an entry in the filter&#39;s drop-down list.
Definition: manager.cpp:219
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:410
virtual void whiteboard_toggle()
virtual void toggle_accelerated_speed()