The Battle for Wesnoth  1.15.0-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 <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.null()) {
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;
250  case HOTKEY_CHAT_LOG:
251  show_chat_log();
252  break;
253  case HOTKEY_USER_CMD:
254  user_command();
255  break;
256  case HOTKEY_CUSTOM_CMD:
257  custom_command();
258  break;
259  case HOTKEY_AI_FORMULA:
260  ai_formula();
261  break;
262  case HOTKEY_CLEAR_MSG:
263  clear_messages();
264  break;
265  case HOTKEY_LANGUAGE:
266  change_language();
267  break;
268  case HOTKEY_REPLAY_PLAY:
269  play_replay();
270  break;
271  case HOTKEY_REPLAY_RESET:
272  reset_replay();
273  break;
274  case HOTKEY_REPLAY_STOP:
275  stop_replay();
276  break;
279  break;
282  break;
285  break;
288  break;
291  break;
294  break;
297  break;
298  case HOTKEY_REPLAY_EXIT:
299  replay_exit();
300  break;
301  case HOTKEY_WB_TOGGLE:
303  break;
306  break;
309  break;
312  break;
315  break;
318  break;
321  break;
322  case HOTKEY_SELECT_HEX:
323  select_hex();
324  break;
325  case HOTKEY_DESELECT_HEX:
326  deselect_hex();
327  break;
328  case HOTKEY_MOVE_ACTION:
329  move_action();
330  break;
333  break;
334  case HOTKEY_TOUCH_HEX:
335  touch_hex();
336  break;
337  case HOTKEY_ACCELERATED:
339  break;
340  case LUA_CONSOLE:
341  lua_console();
342  break;
343  case HOTKEY_ZOOM_IN:
344  zoom_in();
345  break;
346  case HOTKEY_ZOOM_OUT:
347  zoom_out();
348  break;
349  case HOTKEY_ZOOM_DEFAULT:
350  zoom_default();
351  break;
353  map_screenshot();
354  break;
357  break;
358  case HOTKEY_QUIT_GAME:
360  break;
361  case HOTKEY_SURRENDER:
362  surrender_game();
363  break;
367  break;
371  break;
375  break;
379  break;
383  break;
384  default:
385  return false;
386  }
387  return true;
388 }
389 
391  if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
393  if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
394  pmc->surrender(display::get_singleton()->viewing_team());
395  }
396  }
397 }
398 
399 void command_executor::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
400 {
401  std::vector<config> items = items_arg;
402  if (items.empty()) return;
403 
404  get_menu_images(gui, items);
405 
406  int res = -1;
407  {
408  SDL_Rect pos {xloc, yloc, 1, 1};
409  gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
410  if(mmenu.show()) {
411  res = mmenu.selected_item();
412  }
413  } // This will kill the dialog.
414  if (res < 0 || std::size_t(res) >= items.size()) return;
415 
416  const theme::menu* submenu = gui.get_theme().get_menu_item(items[res]["id"]);
417  if (submenu) {
418  int y,x;
419  SDL_GetMouseState(&x,&y);
420  this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
421  } else {
422  const hotkey::hotkey_command& cmd = hotkey::get_hotkey_command(items[res]["id"]);
423  do_execute_command(cmd, res);
425  }
426 }
427 
428 void command_executor::execute_action(const std::vector<std::string>& items_arg, int /*xloc*/, int /*yloc*/, bool /*context_menu*/, display&)
429 {
430  std::vector<std::string> items = items_arg;
431  if (items.empty()) {
432  return;
433  }
434 
435  std::vector<std::string>::iterator i = items.begin();
436  while(i != items.end()) {
437  const hotkey_command &command = hotkey::get_hotkey_command(*i);
438  if (can_execute_command(command)) {
439  do_execute_command(command);
441  }
442  ++i;
443  }
444 }
445 
446 std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const {
447 
448  // TODO: Find a way to do away with the fugly special markup
449  if(command[0] == '&') {
450  std::size_t n = command.find_first_of('=');
451  if(n != std::string::npos)
452  return command.substr(1, n - 1);
453  }
454 
455  const std::string base_image_name = "icons/action/" + command + "_25.png";
456  const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";
457 
458  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(command);
459  const hotkey::ACTION_STATE state = get_action_state(hk, index);
460 
461  const theme::menu* menu = disp.get_theme().get_menu_item(command);
462  if (menu) {
463  return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
464  }
465 
466  if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
467  switch (state) {
468  case ACTION_ON:
469  case ACTION_SELECTED:
470  return pressed_image_name + "~CROP(3,3,18,18)";
471  default:
472  return base_image_name + "~CROP(3,3,18,18)";
473  }
474  }
475 
476  switch (get_action_state(hk, index)) {
477  case ACTION_ON:
479  case ACTION_OFF:
481  case ACTION_SELECTED:
483  case ACTION_DESELECTED:
485  default: return get_action_image(hk, index);
486  }
487 }
488 
489 void command_executor::get_menu_images(display& disp, std::vector<config>& items)
490 {
491  for(std::size_t i = 0; i < items.size(); ++i) {
492  config& item = items[i];
493 
494  const std::string& item_id = item["id"];
495  const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item_id);
496 
497  //see if this menu item has an associated image
498  std::string img(get_menu_image(disp, item_id, i));
499  if (img.empty() == false) {
500  item["icon"] = img;
501  }
502 
503  const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
504  if(menu) {
505  item["label"] = menu->title();
506  } else if(hk != hotkey::HOTKEY_NULL) {
507  std::string desc = hotkey::get_description(item_id);
508  if(hk == HOTKEY_ENDTURN) {
509  const theme::action *b = disp.get_theme().get_action_item("button-endturn");
510  if (b) {
511  desc = b->title();
512  }
513  }
514 
515  item["label"] = desc;
516  item["details"] = hotkey::get_names(item_id);
517  } else if(item["label"].empty()) {
518  // If no matching hotkey was found and a custom label wasn't already set, treat
519  // the id as a plaintext description. This is because either type of value can
520  // be written to the id field by the WMI manager. The plaintext description is
521  // used in the case the menu item specifies the relevant entry is *not* a hotkey.
522  item["label"] = item_id;
523  }
524  }
525 }
526 
527 void mbutton_event(const SDL_Event& event, command_executor* executor)
528 {
529  event_queue(event, executor);
530 
531  /* Run mouse events immediately.
532 
533  This is necessary because the sidebar doesn't allow set_button_state() to be called after a
534  button has received the mouse press event but before it has received the mouse release event.
535  When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
536  set_button_state() ended up being called at such a time. However, if we run the event handlers
537  now, the button (if any) hasn't received the press event yet and we can call set_button_state()
538  safely.
539 
540  See https://github.com/wesnoth/wesnoth/issues/2884 */
541 
542  run_events(executor);
543 }
544 
545 void jbutton_event(const SDL_Event& event, command_executor* executor)
546 {
547  event_queue(event, executor);
548 }
549 
550 void jhat_event(const SDL_Event& event, command_executor* executor)
551 {
552  event_queue(event, executor);
553 }
554 
555 void key_event(const SDL_Event& event, command_executor* executor)
556 {
557  if (!executor) return;
558  event_queue(event,executor);
559 }
560 
561 void keyup_event(const SDL_Event&, command_executor* executor)
562 {
563  if(!executor) return;
564  executor->handle_keyup();
565 }
566 
568 {
569  if(!executor) return;
570  bool commands_ran = executor->run_queued_commands();
571  if(commands_ran) {
572  executor->set_button_state();
573  }
574 }
575 
576 static void event_queue(const SDL_Event& event, command_executor* executor)
577 {
578  if (!executor) return;
579  executor->queue_command(event);
580  executor->set_button_state();
581 }
582 
583 void command_executor::queue_command(const SDL_Event& event, int index)
584 {
585  LOG_HK << "event 0x" << std::hex << event.type << std::dec << std::endl;
586  if(event.type == SDL_TEXTINPUT) {
587  LOG_HK << "SDL_TEXTINPUT \"" << event.text.text << "\"\n";
588  }
589 
590  const hotkey_ptr hk = get_hotkey(event);
591  if(!hk->active() || hk->is_disabled()) {
592  return;
593  }
594 
595  const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command());
596  bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) &&
598  bool press = keypress ||
599  (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_FINGERDOWN);
600  bool release = event.type == SDL_KEYUP;
601  if(press) {
602  LOG_HK << "sending press event (keypress = " <<
603  std::boolalpha << keypress << std::noboolalpha << ")\n";
604  }
605  if(keypress) {
606  press_event_sent_ = true;
607  }
608 
609  command_queue_.emplace_back(command, index, press, release);
610 }
611 
613 {
614  if (!can_execute_command(*command.command, command.index)
615  || do_execute_command(*command.command, command.index, command.press, command.release)) {
616  return;
617  }
618 
619  if (!command.press) {
620  return; // none of the commands here respond to a key release
621  }
622 
623  switch (command.command->id) {
624  case HOTKEY_FULLSCREEN:
626  break;
627  case HOTKEY_SCREENSHOT:
628  make_screenshot(_("Screenshot"), false);
629  break;
630  case HOTKEY_ANIMATE_MAP:
632  break;
633  case HOTKEY_MOUSE_SCROLL:
635  break;
636  case HOTKEY_MUTE:
637  {
638  // look if both is not playing
639  static struct before_muted_s
640  {
641  bool playing_sound,playing_music;
642  before_muted_s() : playing_sound(false),playing_music(false){}
643  } before_muted;
645  {
646  // then remember settings and mute both
647  before_muted.playing_sound = preferences::sound_on();
648  before_muted.playing_music = preferences::music_on();
649  preferences::set_sound(false);
650  preferences::set_music(false);
651  }
652  else
653  {
654  // then set settings before mute
655  preferences::set_sound(before_muted.playing_sound);
656  preferences::set_music(before_muted.playing_music);
657  }
658  }
659  break;
660  default:
661  DBG_G << "command_executor: unknown command number " << command.command->id << ", ignoring.\n";
662  break;
663  }
664 }
665 
667 {
668  display& disp = get_display();
669  for (const theme::menu& menu : disp.get_theme().menus()) {
670 
671  std::shared_ptr<gui::button> button = disp.find_menu_button(menu.get_id());
672  if (!button) continue;
673  bool enabled = false;
674  for (const auto& command : menu.items()) {
675 
676  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command["id"]);
677  bool can_execute = can_execute_command(command_obj);
678  if (can_execute) {
679  enabled = true;
680  break;
681  }
682  }
683  button->enable(enabled);
684  }
685 
686  for (const theme::action& action : disp.get_theme().actions()) {
687 
688  std::shared_ptr<gui::button> button = disp.find_action_button(action.get_id());
689  if (!button) continue;
690  bool enabled = false;
691  int i = 0;
692  for (const std::string& command : action.items()) {
693 
694  const hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command);
695  std::string tooltip = action.tooltip(i);
696  if (filesystem::file_exists(game_config::path + "/images/icons/action/" + command + "_25.png" ))
697  button->set_overlay("icons/action/" + command);
698  if (!tooltip.empty())
699  button->set_tooltip_string(tooltip);
700 
701  bool can_execute = can_execute_command(command_obj);
702  i++;
703  if (!can_execute) continue;
704  enabled = true;
705 
706  ACTION_STATE state = get_action_state(command_obj.id, -1);
707  switch (state) {
708  case ACTION_SELECTED:
709  case ACTION_ON:
710  button->set_check(true);
711  break;
712  case ACTION_OFF:
713  case ACTION_DESELECTED:
714  button->set_check(false);
715  break;
716  case ACTION_STATELESS:
717  break;
718  default:
719  break;
720  }
721 
722  break;
723  }
724  button->enable(enabled);
725  }
726 }
727 
728 // Removes duplicate commands caused by both SDL_KEYDOWN and SDL_TEXTINPUT triggering hotkeys.
729 // See https://github.com/wesnoth/wesnoth/issues/1736
730 std::vector<command_executor::queued_command> command_executor::filter_command_queue()
731 {
732  std::vector<queued_command> filtered_commands;
733 
734  /** A command plus "key released" flag. Otherwise, we will filter out key releases that are preceded by a keypress. */
735  using command_with_keyrelease = std::pair<const hotkey_command*, bool>;
736  std::set<command_with_keyrelease> seen_commands;
737 
738  for(const queued_command& cmd : command_queue_) {
739  command_with_keyrelease command_key(cmd.command, cmd.release);
740  if(seen_commands.find(command_key) == seen_commands.end()) {
741  seen_commands.insert(command_key);
742  filtered_commands.push_back(cmd);
743  }
744  }
745 
746  command_queue_.clear();
747 
748  return filtered_commands;
749 }
750 
752 {
753  std::vector<queued_command> commands = filter_command_queue();
754  for(const queued_command& cmd : commands) {
756  }
757 
758  return !commands.empty();
759 }
760 
762 {
763  get_display().recalculate_minimap();
764 }
765 
767 {
768  if (get_display().in_game()) {
770  } else {
772  }
773 
774 }
775 
777 {
779 }
780 
782 {
783  if(!get_display().view_locked()) {
784  get_display().set_zoom(true);
785  }
786 }
787 
789 {
790  if(!get_display().view_locked()) {
791  get_display().set_zoom(false);
792  }
793 }
794 
796 {
797  if(!get_display().view_locked()) {
798  get_display().set_default_zoom();
799  }
800 }
801 
803 {
804  make_screenshot(_("Map-Screenshot"), true);
805 }
806 }
#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:804
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
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:507
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:957
const std::string & title() const
Definition: theme.hpp:232
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:280
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.
bool null() const
Definition: surface.hpp:79
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:89
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:240
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:556
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:230
const menu * get_menu_item(const std::string &key) const
Definition: theme.cpp:948
std::shared_ptr< hotkey_base > hotkey_ptr
Definition: hotkey_item.hpp:30
const std::vector< action > & actions() const
Definition: theme.hpp:262
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:177
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:260
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:814
HOTKEY_COMMAND get_id(const std::string &command)
returns get_hotkey_command(command).id
virtual void replay_skip_animation()
virtual void whiteboard_toggle()
virtual void toggle_accelerated_speed()