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