The Battle for Wesnoth  1.17.12+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 
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_command& cmd, int /*index*/, bool press, bool release)
74 {
75  // hotkey release handling
76  if (release) {
77  switch(cmd.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.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.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()) {
408  pmc->surrender(display::get_singleton()->viewing_team());
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 
418  get_menu_images(gui, items);
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  const theme::menu* submenu = gui.get_theme().get_menu_item(items[res]["id"]);
431  if (submenu) {
432  int y,x;
433  sdl::get_mouse_state(&x,&y);
434  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
435  } else {
436  const hotkey::hotkey_command& cmd = hotkey::get_hotkey_command(items[res]["id"]);
437  do_execute_command(cmd, res);
439  }
440 }
441 
442 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
443 {
444  std::vector<std::string> items = items_arg;
445  if (items.empty()) {
446  return;
447  }
448 
449  std::vector<std::string>::iterator i = items.begin();
450  while(i != items.end()) {
451  const hotkey_command &command = hotkey::get_hotkey_command(*i);
452  if (can_execute_command(command)) {
453  do_execute_command(command);
455  }
456  ++i;
457  }
458 }
459 
460 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const {
461 
462  // TODO: Find a way to do away with the fugly special markup
463  if(command[0] == '&') {
464  std::size_t n = command.find_first_of('=');
465  if(n != std::string::npos)
466  return command.substr(1, n - 1);
467  }
468 
469  const std::string base_image_name = "icons/action/" + command + "_25.png";
470  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
471 
473  const hotkey::ACTION_STATE state = get_action_state(hk, index);
474 
475  const theme::menu* menu = disp.get_theme().get_menu_item(command);
476  if (menu) {
477  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
478  }
479 
480  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
481  switch (state) {
482  case ACTION_ON:
483  case ACTION_SELECTED:
484  return pressed_image_name + "~CROP(3,3,18,18)";
485  default:
486  return base_image_name + "~CROP(3,3,18,18)";
487  }
488  }
489 
490  switch (get_action_state(hk, index)) {
491  case ACTION_ON:
493  case ACTION_OFF:
495  case ACTION_SELECTED:
497  case ACTION_DESELECTED:
499  default: return get_action_image(hk, index);
500  }
501 }
502 
503 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
504 {
505  for(std::size_t i = 0; i < items.size(); ++i) {
506  config& item = items[i];
507 
508  const std::string& item_id = item["id"];
510 
511  //see if this menu item has an associated image
512  std::string img(get_menu_image(disp, item_id, i));
513  if (img.empty() == false) {
514  item["icon"] = img;
515  }
516 
517  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
518  if(menu) {
519  item["label"] = menu->title();
520  } else if(hk != hotkey::HOTKEY_NULL) {
521  std::string desc = hotkey::get_hotkey_command(item_id).description;
522  if(hk == HOTKEY_ENDTURN) {
523  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
524  if (b) {
525  desc = b->title();
526  }
527  }
528 
529  item["label"] = desc;
530  item["details"] = hotkey::get_names(item_id);
531  } else if(item["label"].empty()) {
532  // If no matching hotkey was found and a custom label wasn't already set, treat
533  // the id as a plaintext description. This is because either type of value can
534  // be written to the id field by the WMI manager. The plaintext description is
535  // used in the case the menu item specifies the relevant entry is *not* a hotkey.
536  item["label"] = item_id;
537  }
538  }
539 }
540 
541 void mbutton_event(const SDL_Event& event, command_executor* executor)
542 {
543  event_queue(event, executor);
544 
545  /* Run mouse events immediately.
546 
547  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
548  button has received the mouse press event but before it has received the mouse release event.
549  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
550  set_button_state() ended up being called at such a time. However, if we run the event handlers
551  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
552  safely.
553 
554  See https://github.com/wesnoth/wesnoth/issues/2884 */
555 
556  run_events(executor);
557 }
558 
559 void jbutton_event(const SDL_Event& event, command_executor* executor)
560 {
561  event_queue(event, executor);
562 }
563 
564 void jhat_event(const SDL_Event& event, command_executor* executor)
565 {
566  event_queue(event, executor);
567 }
568 
569 void key_event(const SDL_Event& event, command_executor* executor)
570 {
571  if (!executor) return;
572  event_queue(event,executor);
573 }
574 
575 void keyup_event(const SDL_Event&, command_executor* executor)
576 {
577  if(!executor) return;
578  executor->handle_keyup();
579 }
580 
582 {
583  if(!executor) return;
584  bool commands_ran = executor->run_queued_commands();
585  if(commands_ran) {
586  executor->set_button_state();
587  }
588 }
589 
590 static void event_queue(const SDL_Event& event, command_executor* executor)
591 {
592  if (!executor) return;
593  executor->queue_command(event);
594  executor->set_button_state();
595 }
596 
597 void command_executor::queue_command(const SDL_Event& event, int index)
598 {
599  LOG_HK << "event 0x" << std::hex << event.type << std::dec;
600  if(event.type == SDL_TEXTINPUT) {
601  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"";
602  }
603 
604  const hotkey_ptr hk = get_hotkey(event);
605  if(!hk->active() || hk->is_disabled()) {
606  return;
607  }
608 
609  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
610  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
612  bool press = keypress ||
613  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
614  bool release = event.type == SDL_KEYUP;
615  if(press) {
616  LOG_HK << "sending press event (keypress = " <<
617  std::boolalpha << keypress << std::noboolalpha << ")";
618  }
619  if(keypress) {
620  press_event_sent_ = true;
621  }
622 
623  command_queue_.emplace_back(command, index, press, release);
624 }
625 
627 {
628  if (!can_execute_command(*command.command, command.index)
629  || do_execute_command(*command.command, command.index, command.press, command.release)) {
630  return;
631  }
632 
633  if (!command.press) {
634  return; // none of the commands here respond to a key release
635  }
636 
637  switch(command.command->command) {
638  case HOTKEY_FULLSCREEN:
640  break;
641  case HOTKEY_SCREENSHOT:
642  make_screenshot(_("Screenshot"), false);
643  break;
644  case HOTKEY_ANIMATE_MAP:
646  break;
647  case HOTKEY_MOUSE_SCROLL:
649  break;
650  case HOTKEY_MUTE:
651  {
652  // look if both is not playing
653  static struct before_muted_s
654  {
655  bool playing_sound,playing_music;
656  before_muted_s() : playing_sound(false),playing_music(false){}
657  } before_muted;
659  {
660  // then remember settings and mute both
661  before_muted.playing_sound = preferences::sound_on();
662  before_muted.playing_music = preferences::music_on();
663  preferences::set_sound(false);
664  preferences::set_music(false);
665  }
666  else
667  {
668  // then set settings before mute
669  preferences::set_sound(before_muted.playing_sound);
670  preferences::set_music(before_muted.playing_music);
671  }
672  }
673  break;
674  default:
675  DBG_G << "command_executor: unknown command number " << command.command->command << ", ignoring.";
676  break;
677  }
678 }
679 
681 {
682  display& disp = get_display();
683  for (const theme::menu& menu : disp.get_theme().menus()) {
684 
685  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
686  if (!button) continue;
687  bool enabled = false;
688  for (const auto& command : menu.items()) {
689 
690  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command["id"]);
691  bool can_execute = can_execute_command(command_obj);
692  if (can_execute) {
693  enabled = true;
694  break;
695  }
696  }
697  button->enable(enabled);
698  }
699 
700  for (const theme::action& action : disp.get_theme().actions()) {
701 
702  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
703  if (!button) continue;
704  bool enabled = false;
705  int i = 0;
706  for (const std::string& command : action.items()) {
707 
708  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command);
709  std::string tooltip = action.tooltip(i);
710  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
711  button->set_overlay("icons/action/" + command);
712  if (!tooltip.empty())
713  button->set_tooltip_string(tooltip);
714 
715  bool can_execute = can_execute_command(command_obj);
716  i++;
717  if (!can_execute) continue;
718  enabled = true;
719 
720  ACTION_STATE state = get_action_state(command_obj.command, -1);
721  switch (state) {
722  case ACTION_SELECTED:
723  case ACTION_ON:
724  button->set_check(true);
725  break;
726  case ACTION_OFF:
727  case ACTION_DESELECTED:
728  button->set_check(false);
729  break;
730  case ACTION_STATELESS:
731  break;
732  default:
733  break;
734  }
735 
736  break;
737  }
738  button->enable(enabled);
739  }
740 }
741 
742 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
743 // See https://github.com/wesnoth/wesnoth/issues/1736
744 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
745 {
746  std::vector<queued_command> filtered_commands;
747 
748  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
749  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
750  std::set<command_with_keyrelease> seen_commands;
751 
752  for(const queued_command& cmd : command_queue_) {
753  command_with_keyrelease command_key(cmd.command, cmd.release);
754  if(seen_commands.find(command_key) == seen_commands.end()) {
755  seen_commands.insert(command_key);
756  filtered_commands.push_back(cmd);
757  }
758  }
759 
760  command_queue_.clear();
761 
762  return filtered_commands;
763 }
764 
766 {
767  std::vector<queued_command> commands = filter_command_queue();
768  for(const queued_command& cmd : commands) {
770  }
771 
772  return !commands.empty();
773 }
774 
776 {
777  get_display().recalculate_minimap();
778 }
779 
781 {
782  if (get_display().in_game()) {
784  } else {
786  }
787 
788 }
789 
791 {
793 }
794 
796 {
797  if(!get_display().view_locked()) {
798  get_display().set_zoom(true);
799  }
800 }
801 
803 {
804  if(!get_display().view_locked()) {
805  get_display().set_zoom(false);
806  }
807 }
808 
810 {
811  if(!get_display().view_locked()) {
812  get_display().toggle_default_zoom();
813  }
814 }
815 
817 {
818  make_screenshot(_("Map-Screenshot"), true);
819 }
820 }
#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:825
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:733
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:151
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:98
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:375
void surrender(int side_number)
static void quit_to_title()
const action * get_action_item(const std::string &key) const
Definition: theme.cpp:927
const std::string & title() const
Definition: theme.hpp:228
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:264
std::string selected_menu
General purpose widgets.
void enable_mouse_scroll(bool value)
Definition: general.cpp:815
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()
void mbutton_event(const SDL_Event &event, command_executor *executor)
std::string unchecked_menu
HOTKEY_COMMAND command
The command associated with this hotkey.
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:728
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.
This shows a dialog displaying achievements.
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:860
bool is_linger_mode() const
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:781
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()
std::shared_ptr< class hotkey_base > hotkey_ptr
Definition: hotkey_item.hpp:27
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:81
void toggle_minimap_draw_terrain()
Definition: general.cpp:880
map_display and display: classes which take care of displaying the map and game-data on the screen...
bool animate_map()
Definition: general.cpp:825
void set_animate_map(bool value)
Definition: general.cpp:885
void jhat_event(const SDL_Event &event, command_executor *executor)
bool is_observer() const
void toggle_minimap_draw_villages()
Definition: general.cpp:870
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:968
const std::vector< config > & items() const
Definition: theme.hpp:236
virtual void scroll_left(bool)
std::vector< queued_command > command_queue_
virtual void update_shroud_now()
void toggle_minimap_terrain_coding()
Definition: general.cpp:850
void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
virtual void replay_show_everything()
bool music_on()
Definition: general.cpp:751
virtual void scroll_down(bool)
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int) const
void toggle_minimap_movement_coding()
Definition: general.cpp:840
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:226
const menu * get_menu_item(const std::string &key) const
Definition: theme.cpp:918
const std::vector< action > & actions() const
Definition: theme.hpp:258
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)
virtual void whiteboard_bump_down_action()
void toggle_fullscreen()
Toggle fullscreen mode.
Definition: video.cpp:784
bool mouse_scroll_enabled()
Definition: general.cpp:810
const std::string & title() const
Definition: theme.hpp:173
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:27
bool set_music(bool ison)
Definition: general.cpp:756
Standard logging facilities (interface).
std::vector< queued_command > filter_command_queue()
#define DBG_G
const std::vector< menu > & menus() const
Definition: theme.hpp:256
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:835
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:414
virtual void whiteboard_toggle()
virtual void toggle_accelerated_speed()