The Battle for Wesnoth  1.17.0-dev
command_executor.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
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 
37 #include <functional>
38 
39 #include <SDL2/SDL_image.h>
40 
41 #include <cassert>
42 #include <ios>
43 #include <set>
44 
45 static lg::log_domain log_config("config");
46 static lg::log_domain log_hotkey("hotkey");
47 #define ERR_G LOG_STREAM(err, lg::general())
48 #define WRN_G LOG_STREAM(warn, lg::general())
49 #define LOG_G LOG_STREAM(info, lg::general())
50 #define DBG_G LOG_STREAM(debug, lg::general())
51 #define ERR_CF LOG_STREAM(err, log_config)
52 #define LOG_HK LOG_STREAM(info, log_hotkey)
53 
54 namespace {
55 
56 void make_screenshot(const std::string& name, bool map_screenshot)
57 {
58  surface screenshot = display::get_singleton()->screenshot(map_screenshot);
59  if(screenshot) {
60  std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
61  filename = filesystem::get_next_filename(filename, ".jpg");
62  gui2::dialogs::screenshot_notification::display(filename, screenshot);
63  }
64 }
65 }
66 namespace hotkey {
67 
68 static void event_queue(const SDL_Event& event, command_executor* executor);
69 
70 bool command_executor::do_execute_command(const hotkey_command& cmd, int /*index*/, bool press, bool release)
71 {
72  // hotkey release handling
73  if (release) {
74  switch(cmd.id) {
75  // release a scroll key, un-apply scrolling in the given direction
76  case HOTKEY_SCROLL_UP:
77  scroll_up(false);
78  break;
79  case HOTKEY_SCROLL_DOWN:
80  scroll_down(false);
81  break;
82  case HOTKEY_SCROLL_LEFT:
83  scroll_left(false);
84  break;
86  scroll_right(false);
87  break;
88  default:
89  return false; // nothing else handles a hotkey release
90  }
91 
92  return true;
93  }
94 
95  // handling of hotkeys which activate even on hold events
96  switch(cmd.id) {
99  return true;
100  case HOTKEY_SCROLL_UP:
101  scroll_up(true);
102  return true;
103  case HOTKEY_SCROLL_DOWN:
104  scroll_down(true);
105  return true;
106  case HOTKEY_SCROLL_LEFT:
107  scroll_left(true);
108  return true;
109  case HOTKEY_SCROLL_RIGHT:
110  scroll_right(true);
111  return true;
112  default:
113  break;
114  }
115 
116  if(!press) {
117  return false; // nothing else handles hotkey hold events
118  }
119 
120  // hotkey press handling
121  switch(cmd.id) {
122  case HOTKEY_CYCLE_UNITS:
123  cycle_units();
124  break;
127  break;
128  case HOTKEY_ENDTURN:
129  end_turn();
130  break;
133  break;
135  end_unit_turn();
136  break;
137  case HOTKEY_LEADER:
138  goto_leader();
139  break;
140  case HOTKEY_UNDO:
141  undo();
142  break;
143  case HOTKEY_REDO:
144  redo();
145  break;
148  break;
151  break;
152  case HOTKEY_RENAME_UNIT:
153  rename_unit();
154  break;
155  case HOTKEY_SAVE_GAME:
156  save_game();
157  break;
158  case HOTKEY_SAVE_REPLAY:
159  save_replay();
160  break;
161  case HOTKEY_SAVE_MAP:
162  save_map();
163  break;
164  case HOTKEY_LOAD_GAME:
165  load_game();
166  break;
168  toggle_ellipses();
169  break;
170  case HOTKEY_TOGGLE_GRID:
171  toggle_grid();
172  break;
173  case HOTKEY_STATUS_TABLE:
174  status_table();
175  break;
176  case HOTKEY_RECALL:
177  recall();
178  break;
180  label_settings();
181  break;
182  case HOTKEY_RECRUIT:
183  recruit();
184  break;
185  case HOTKEY_SPEAK:
186  speak();
187  break;
188  case HOTKEY_SPEAK_ALLY:
189  whisper();
190  break;
191  case HOTKEY_SPEAK_ALL:
192  shout();
193  break;
194  case HOTKEY_CREATE_UNIT:
195  create_unit();
196  break;
197  case HOTKEY_CHANGE_SIDE:
198  change_side();
199  break;
200  case HOTKEY_KILL_UNIT:
201  kill_unit();
202  break;
203  case HOTKEY_PREFERENCES:
204  preferences();
205  break;
206  case HOTKEY_OBJECTIVES:
207  objectives();
208  break;
209  case HOTKEY_UNIT_LIST:
210  unit_list();
211  break;
212  case HOTKEY_STATISTICS:
213  show_statistics();
214  break;
215  case HOTKEY_STOP_NETWORK:
216  stop_network();
217  break;
219  start_network();
220  break;
222  label_terrain(true);
223  break;
225  label_terrain(false);
226  break;
227  case HOTKEY_CLEAR_LABELS:
228  clear_labels();
229  break;
231  show_enemy_moves(false);
232  break;
234  show_enemy_moves(true);
235  break;
236  case HOTKEY_DELAY_SHROUD:
238  break;
241  break;
243  continue_move();
244  break;
245  case HOTKEY_SEARCH:
246  search();
247  break;
248  case HOTKEY_HELP:
249  show_help();
250  break;
252  // although HOTKEY_HELP uses a virtual call to allow context-specific help, this one is already a specific topic
253  help::show_help("saveload");
254  break;
255  case HOTKEY_CHAT_LOG:
256  show_chat_log();
257  break;
258  case HOTKEY_USER_CMD:
259  user_command();
260  break;
261  case HOTKEY_CUSTOM_CMD:
262  custom_command();
263  break;
264  case HOTKEY_AI_FORMULA:
265  ai_formula();
266  break;
267  case HOTKEY_CLEAR_MSG:
268  clear_messages();
269  break;
270  case HOTKEY_LANGUAGE:
271  change_language();
272  break;
273  case HOTKEY_REPLAY_PLAY:
274  play_replay();
275  break;
276  case HOTKEY_REPLAY_RESET:
277  reset_replay();
278  break;
279  case HOTKEY_REPLAY_STOP:
280  stop_replay();
281  break;
284  break;
287  break;
290  break;
293  break;
296  break;
299  break;
302  break;
303  case HOTKEY_REPLAY_EXIT:
304  replay_exit();
305  break;
306  case HOTKEY_WB_TOGGLE:
308  break;
311  break;
314  break;
317  break;
320  break;
323  break;
326  break;
327  case HOTKEY_SELECT_HEX:
328  select_hex();
329  break;
330  case HOTKEY_DESELECT_HEX:
331  deselect_hex();
332  break;
333  case HOTKEY_MOVE_ACTION:
334  move_action();
335  break;
338  break;
339  case HOTKEY_TOUCH_HEX:
340  touch_hex();
341  break;
342  case HOTKEY_ACCELERATED:
344  break;
345  case LUA_CONSOLE:
346  lua_console();
347  break;
348  case HOTKEY_ZOOM_IN:
349  zoom_in();
350  break;
351  case HOTKEY_ZOOM_OUT:
352  zoom_out();
353  break;
354  case HOTKEY_ZOOM_DEFAULT:
355  zoom_default();
356  break;
358  map_screenshot();
359  break;
362  break;
363  case HOTKEY_QUIT_GAME:
365  break;
366  case HOTKEY_SURRENDER:
367  surrender_game();
368  break;
372  break;
376  break;
380  break;
384  break;
388  break;
389  default:
390  return false;
391  }
392  return true;
393 }
394 
396  if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
398  if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
399  pmc->surrender(display::get_singleton()->viewing_team());
400  }
401  }
402 }
403 
404 void command_executor::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
405 {
406  std::vector<config> items = items_arg;
407  if (items.empty()) return;
408 
409  get_menu_images(gui, items);
410 
411  int res = -1;
412  {
413  SDL_Rect pos {xloc, yloc, 1, 1};
414  gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
415  if(mmenu.show()) {
416  res = mmenu.selected_item();
417  }
418  } // This will kill the dialog.
419  if (res < 0 || std::size_t(res) >= items.size()) return;
420 
421  const theme::menu* submenu = gui.get_theme().get_menu_item(items[res]["id"]);
422  if (submenu) {
423  int y,x;
424  SDL_GetMouseState(&x,&y);
425  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
426  } else {
427  const hotkey::hotkey_command& cmd = hotkey::get_hotkey_command(items[res]["id"]);
428  do_execute_command(cmd, res);
430  }
431 }
432 
433 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
434 {
435  std::vector<std::string> items = items_arg;
436  if (items.empty()) {
437  return;
438  }
439 
440  std::vector<std::string>::iterator i = items.begin();
441  while(i != items.end()) {
442  const hotkey_command &command = hotkey::get_hotkey_command(*i);
443  if (can_execute_command(command)) {
444  do_execute_command(command);
446  }
447  ++i;
448  }
449 }
450 
451 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const {
452 
453  // TODO: Find a way to do away with the fugly special markup
454  if(command[0] == '&') {
455  std::size_t n = command.find_first_of('=');
456  if(n != std::string::npos)
457  return command.substr(1, n - 1);
458  }
459 
460  const std::string base_image_name = "icons/action/" + command + "_25.png";
461  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
462 
463  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(command);
464  const hotkey::ACTION_STATE state = get_action_state(hk, index);
465 
466  const theme::menu* menu = disp.get_theme().get_menu_item(command);
467  if (menu) {
468  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
469  }
470 
471  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
472  switch (state) {
473  case ACTION_ON:
474  case ACTION_SELECTED:
475  return pressed_image_name + "~CROP(3,3,18,18)";
476  default:
477  return base_image_name + "~CROP(3,3,18,18)";
478  }
479  }
480 
481  switch (get_action_state(hk, index)) {
482  case ACTION_ON:
484  case ACTION_OFF:
486  case ACTION_SELECTED:
488  case ACTION_DESELECTED:
490  default: return get_action_image(hk, index);
491  }
492 }
493 
494 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
495 {
496  for(std::size_t i = 0; i < items.size(); ++i) {
497  config& item = items[i];
498 
499  const std::string& item_id = item["id"];
500  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item_id);
501 
502  //see if this menu item has an associated image
503  std::string img(get_menu_image(disp, item_id, i));
504  if (img.empty() == false) {
505  item["icon"] = img;
506  }
507 
508  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
509  if(menu) {
510  item["label"] = menu->title();
511  } else if(hk != hotkey::HOTKEY_NULL) {
512  std::string desc = hotkey::get_description(item_id);
513  if(hk == HOTKEY_ENDTURN) {
514  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
515  if (b) {
516  desc = b->title();
517  }
518  }
519 
520  item["label"] = desc;
521  item["details"] = hotkey::get_names(item_id);
522  } else if(item["label"].empty()) {
523  // If no matching hotkey was found and a custom label wasn't already set, treat
524  // the id as a plaintext description. This is because either type of value can
525  // be written to the id field by the WMI manager. The plaintext description is
526  // used in the case the menu item specifies the relevant entry is *not* a hotkey.
527  item["label"] = item_id;
528  }
529  }
530 }
531 
532 void mbutton_event(const SDL_Event& event, command_executor* executor)
533 {
534  event_queue(event, executor);
535 
536  /* Run mouse events immediately.
537 
538  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
539  button has received the mouse press event but before it has received the mouse release event.
540  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
541  set_button_state() ended up being called at such a time. However, if we run the event handlers
542  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
543  safely.
544 
545  See https://github.com/wesnoth/wesnoth/issues/2884 */
546 
547  run_events(executor);
548 }
549 
550 void jbutton_event(const SDL_Event& event, command_executor* executor)
551 {
552  event_queue(event, executor);
553 }
554 
555 void jhat_event(const SDL_Event& event, command_executor* executor)
556 {
557  event_queue(event, executor);
558 }
559 
560 void key_event(const SDL_Event& event, command_executor* executor)
561 {
562  if (!executor) return;
563  event_queue(event,executor);
564 }
565 
566 void keyup_event(const SDL_Event&, command_executor* executor)
567 {
568  if(!executor) return;
569  executor->handle_keyup();
570 }
571 
573 {
574  if(!executor) return;
575  bool commands_ran = executor->run_queued_commands();
576  if(commands_ran) {
577  executor->set_button_state();
578  }
579 }
580 
581 static void event_queue(const SDL_Event& event, command_executor* executor)
582 {
583  if (!executor) return;
584  executor->queue_command(event);
585  executor->set_button_state();
586 }
587 
588 void command_executor::queue_command(const SDL_Event& event, int index)
589 {
590  LOG_HK << "event 0x" << std::hex << event.type << std::dec << std::endl;
591  if(event.type == SDL_TEXTINPUT) {
592  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"\n";
593  }
594 
595  const hotkey_ptr hk = get_hotkey(event);
596  if(!hk->active() || hk->is_disabled()) {
597  return;
598  }
599 
600  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
601  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
603  bool press = keypress ||
604  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
605  bool release = event.type == SDL_KEYUP;
606  if(press) {
607  LOG_HK << "sending press event (keypress = " <<
608  std::boolalpha << keypress << std::noboolalpha << ")\n";
609  }
610  if(keypress) {
611  press_event_sent_ = true;
612  }
613 
614  command_queue_.emplace_back(command, index, press, release);
615 }
616 
618 {
619  if (!can_execute_command(*command.command, command.index)
620  || do_execute_command(*command.command, command.index, command.press, command.release)) {
621  return;
622  }
623 
624  if (!command.press) {
625  return; // none of the commands here respond to a key release
626  }
627 
628  switch (command.command->id) {
629  case HOTKEY_FULLSCREEN:
631  break;
632  case HOTKEY_SCREENSHOT:
633  make_screenshot(_("Screenshot"), false);
634  break;
635  case HOTKEY_ANIMATE_MAP:
637  break;
638  case HOTKEY_MOUSE_SCROLL:
640  break;
641  case HOTKEY_MUTE:
642  {
643  // look if both is not playing
644  static struct before_muted_s
645  {
646  bool playing_sound,playing_music;
647  before_muted_s() : playing_sound(false),playing_music(false){}
648  } before_muted;
650  {
651  // then remember settings and mute both
652  before_muted.playing_sound = preferences::sound_on();
653  before_muted.playing_music = preferences::music_on();
654  preferences::set_sound(false);
655  preferences::set_music(false);
656  }
657  else
658  {
659  // then set settings before mute
660  preferences::set_sound(before_muted.playing_sound);
661  preferences::set_music(before_muted.playing_music);
662  }
663  }
664  break;
665  default:
666  DBG_G << "command_executor: unknown command number " << command.command->id << ", ignoring.\n";
667  break;
668  }
669 }
670 
672 {
673  display& disp = get_display();
674  for (const theme::menu& menu : disp.get_theme().menus()) {
675 
676  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
677  if (!button) continue;
678  bool enabled = false;
679  for (const auto& command : menu.items()) {
680 
681  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command["id"]);
682  bool can_execute = can_execute_command(command_obj);
683  if (can_execute) {
684  enabled = true;
685  break;
686  }
687  }
688  button->enable(enabled);
689  }
690 
691  for (const theme::action& action : disp.get_theme().actions()) {
692 
693  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
694  if (!button) continue;
695  bool enabled = false;
696  int i = 0;
697  for (const std::string& command : action.items()) {
698 
699  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command);
700  std::string tooltip = action.tooltip(i);
701  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
702  button->set_overlay("icons/action/" + command);
703  if (!tooltip.empty())
704  button->set_tooltip_string(tooltip);
705 
706  bool can_execute = can_execute_command(command_obj);
707  i++;
708  if (!can_execute) continue;
709  enabled = true;
710 
711  ACTION_STATE state = get_action_state(command_obj.id, -1);
712  switch (state) {
713  case ACTION_SELECTED:
714  case ACTION_ON:
715  button->set_check(true);
716  break;
717  case ACTION_OFF:
718  case ACTION_DESELECTED:
719  button->set_check(false);
720  break;
721  case ACTION_STATELESS:
722  break;
723  default:
724  break;
725  }
726 
727  break;
728  }
729  button->enable(enabled);
730  }
731 }
732 
733 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
734 // See https://github.com/wesnoth/wesnoth/issues/1736
735 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
736 {
737  std::vector<queued_command> filtered_commands;
738 
739  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
740  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
741  std::set<command_with_keyrelease> seen_commands;
742 
743  for(const queued_command& cmd : command_queue_) {
744  command_with_keyrelease command_key(cmd.command, cmd.release);
745  if(seen_commands.find(command_key) == seen_commands.end()) {
746  seen_commands.insert(command_key);
747  filtered_commands.push_back(cmd);
748  }
749  }
750 
751  command_queue_.clear();
752 
753  return filtered_commands;
754 }
755 
757 {
758  std::vector<queued_command> commands = filter_command_queue();
759  for(const queued_command& cmd : commands) {
761  }
762 
763  return !commands.empty();
764 }
765 
767 {
768  get_display().recalculate_minimap();
769 }
770 
772 {
773  if (get_display().in_game()) {
775  } else {
777  }
778 
779 }
780 
782 {
784 }
785 
787 {
788  if(!get_display().view_locked()) {
789  get_display().set_zoom(true);
790  }
791 }
792 
794 {
795  if(!get_display().view_locked()) {
796  get_display().set_zoom(false);
797  }
798 }
799 
801 {
802  if(!get_display().view_locked()) {
803  get_display().toggle_default_zoom();
804  }
805 }
806 
808 {
809  make_screenshot(_("Map-Screenshot"), true);
810 }
811 }
#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:832
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:693
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:92
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:384
void surrender(int side_number)
static void quit_to_title()
const action * get_action_item(const std::string &key) const
Definition: theme.cpp:958
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:775
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:49
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...
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:688
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:820
bool is_linger_mode() const
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:790
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:840
map_display and display: classes which take care of displaying the map and game-data on the screen...
bool animate_map()
Definition: general.cpp:785
void set_animate_map(bool value)
Definition: general.cpp:845
void jhat_event(const SDL_Event &event, command_executor *executor)
bool is_observer() const
void toggle_minimap_draw_villages()
Definition: general.cpp:830
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:810
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:567
virtual void replay_show_everything()
bool music_on()
Definition: general.cpp:711
virtual void scroll_down(bool)
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int) const
void toggle_minimap_movement_coding()
Definition: general.cpp:800
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:949
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:770
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
bool set_music(bool ison)
Definition: general.cpp:716
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:61
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:842
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()