The Battle for Wesnoth  1.19.7+dev
Classes | Typedefs | Enumerations | Functions | Variables
hotkey Namespace Reference

Keyboard shortcuts for game actions. More...

Classes

struct  ui_command
 Used as the main paramneter for can_execute_command/do_execute_command These functions are used to execute hotkeys but also to execute menu items, (Most menu items point to the same action as a hotkey but not all) More...
 
class  command_executor
 
class  command_executor_default
 
struct  hotkey_command_temp
 
struct  hotkey_command
 Stores all information related to functions that can be bound to hotkeys. More...
 
class  scope_changer
 
class  wml_hotkey_record
 RAII helper class to control the lifetime of a WML hotkey_command. More...
 
class  hotkey_base
 This is the base class for hotkey event matching. More...
 
class  hotkey_keyboard
 This class is responsible for handling keys, not modifiers. More...
 
class  hotkey_void
 This class is used to return non-valid results in order to save other people from null checks. More...
 
class  hotkey_mouse
 This class is responsible for handling mouse button presses. More...
 
class  manager
 this class is initialized once at game start put all initialization and wipe code in the methods here. More...
 

Typedefs

typedef std::bitset< SCOPE_COUNThk_scopes
 
typedef std::shared_ptr< class hotkey_basehotkey_ptr
 
typedef std::shared_ptr< class hotkey_mousehotkey_mouse_ptr
 
typedef std::shared_ptr< class hotkey_keyboardhotkey_keyboard_ptr
 
typedef std::vector< hotkey::hotkey_ptrhotkey_list
 

Enumerations

enum  ACTION_STATE {
  ACTION_STATELESS , ACTION_ON , ACTION_OFF , ACTION_SELECTED ,
  ACTION_DESELECTED
}
 
enum  scope { SCOPE_MAIN_MENU , SCOPE_GAME , SCOPE_EDITOR , SCOPE_COUNT }
 Available hotkey scopes. More...
 
enum  HOTKEY_COMMAND {
  HOTKEY_CYCLE_UNITS , HOTKEY_CYCLE_BACK_UNITS , HOTKEY_UNIT_HOLD_POSITION , HOTKEY_END_UNIT_TURN ,
  HOTKEY_LEADER , HOTKEY_UNDO , HOTKEY_REDO , HOTKEY_ZOOM_IN ,
  HOTKEY_ZOOM_OUT , HOTKEY_ZOOM_DEFAULT , HOTKEY_FULLSCREEN , HOTKEY_SCREENSHOT ,
  HOTKEY_MAP_SCREENSHOT , HOTKEY_ACCELERATED , HOTKEY_TERRAIN_DESCRIPTION , HOTKEY_UNIT_DESCRIPTION ,
  HOTKEY_RENAME_UNIT , HOTKEY_DELETE_UNIT , HOTKEY_SAVE_GAME , HOTKEY_SAVE_REPLAY ,
  HOTKEY_SAVE_MAP , HOTKEY_LOAD_GAME , HOTKEY_LOAD_AUTOSAVES , HOTKEY_RECRUIT ,
  HOTKEY_REPEAT_RECRUIT , HOTKEY_RECALL , HOTKEY_ENDTURN , HOTKEY_TOGGLE_ELLIPSES ,
  HOTKEY_TOGGLE_GRID , HOTKEY_STATUS_TABLE , HOTKEY_MUTE , HOTKEY_MOUSE_SCROLL ,
  HOTKEY_SPEAK , HOTKEY_CREATE_UNIT , HOTKEY_CHANGE_SIDE , HOTKEY_KILL_UNIT ,
  HOTKEY_PREFERENCES , HOTKEY_TELEPORT_UNIT , HOTKEY_OBJECTIVES , HOTKEY_UNIT_LIST ,
  HOTKEY_STATISTICS , HOTKEY_STOP_NETWORK , HOTKEY_START_NETWORK , HOTKEY_SURRENDER ,
  HOTKEY_QUIT_GAME , HOTKEY_QUIT_TO_DESKTOP , HOTKEY_LABEL_TEAM_TERRAIN , HOTKEY_LABEL_TERRAIN ,
  HOTKEY_CLEAR_LABELS , HOTKEY_SHOW_ENEMY_MOVES , HOTKEY_BEST_ENEMY_MOVES , HOTKEY_DELAY_SHROUD ,
  HOTKEY_UPDATE_SHROUD , HOTKEY_CONTINUE_MOVE , HOTKEY_SEARCH , HOTKEY_SPEAK_ALLY ,
  HOTKEY_SPEAK_ALL , HOTKEY_HELP , HOTKEY_HELP_ABOUT_SAVELOAD , HOTKEY_CHAT_LOG ,
  HOTKEY_LANGUAGE , HOTKEY_ANIMATE_MAP , HOTKEY_REPLAY_PLAY , HOTKEY_REPLAY_RESET ,
  HOTKEY_REPLAY_STOP , HOTKEY_REPLAY_NEXT_TURN , HOTKEY_REPLAY_NEXT_SIDE , HOTKEY_REPLAY_NEXT_MOVE ,
  HOTKEY_REPLAY_SHOW_EVERYTHING , HOTKEY_REPLAY_SHOW_EACH , HOTKEY_REPLAY_SHOW_TEAM1 , HOTKEY_REPLAY_SKIP_ANIMATION ,
  HOTKEY_REPLAY_EXIT , HOTKEY_SELECT_HEX , HOTKEY_DESELECT_HEX , HOTKEY_MOVE_ACTION ,
  HOTKEY_SELECT_AND_ACTION , HOTKEY_TOUCH_HEX , HOTKEY_SCROLL_UP , HOTKEY_SCROLL_DOWN ,
  HOTKEY_SCROLL_LEFT , HOTKEY_SCROLL_RIGHT , HOTKEY_CANCEL , HOTKEY_OKAY ,
  HOTKEY_WB_TOGGLE , HOTKEY_WB_EXECUTE_ACTION , HOTKEY_WB_EXECUTE_ALL_ACTIONS , HOTKEY_WB_DELETE_ACTION ,
  HOTKEY_WB_BUMP_UP_ACTION , HOTKEY_WB_BUMP_DOWN_ACTION , HOTKEY_WB_SUPPOSE_DEAD , HOTKEY_USER_CMD ,
  HOTKEY_CUSTOM_CMD , HOTKEY_AI_FORMULA , HOTKEY_CLEAR_MSG , HOTKEY_LABEL_SETTINGS ,
  HOTKEY_ACHIEVEMENTS , HOTKEY_MINIMAP_CODING_TERRAIN , HOTKEY_MINIMAP_CODING_UNIT , HOTKEY_MINIMAP_DRAW_UNITS ,
  HOTKEY_MINIMAP_DRAW_VILLAGES , HOTKEY_MINIMAP_DRAW_TERRAIN , HOTKEY_MP_START_GAME , TITLE_SCREEN__RELOAD_WML ,
  TITLE_SCREEN__NEXT_TIP , TITLE_SCREEN__PREVIOUS_TIP , TITLE_SCREEN__CAMPAIGN , TITLE_SCREEN__MULTIPLAYER ,
  TITLE_SCREEN__ADDONS , TITLE_SCREEN__CORES , TITLE_SCREEN__EDITOR , TITLE_SCREEN__CREDITS ,
  TITLE_SCREEN__TEST , GLOBAL__HELPTIP , LUA_CONSOLE , HOTKEY_WML ,
  HOTKEY_EDITOR_CUSTOM_TODS , HOTKEY_EDITOR_PARTIAL_UNDO , HOTKEY_EDITOR_EDIT_UNIT , HOTKEY_EDITOR_PALETTE_ITEM_SWAP ,
  HOTKEY_EDITOR_PALETTE_ITEMS_CLEAR , HOTKEY_EDITOR_PALETTE_GROUPS , HOTKEY_EDITOR_PALETTE_UPSCROLL , HOTKEY_EDITOR_PALETTE_DOWNSCROLL ,
  HOTKEY_EDITOR_REMOVE_LOCATION , HOTKEY_EDITOR_PLAYLIST , HOTKEY_EDITOR_SCHEDULE , HOTKEY_EDITOR_LOCAL_TIME ,
  HOTKEY_EDITOR_UNIT_FACING , HOTKEY_EDITOR_HELP_TEXT_SHOWN , HOTKEY_EDITOR_UNIT_TOGGLE_CANRECRUIT , HOTKEY_EDITOR_UNIT_TOGGLE_RENAMEABLE ,
  HOTKEY_EDITOR_UNIT_CHANGE_ID , HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL , HOTKEY_EDITOR_BRUSH_NEXT , HOTKEY_EDITOR_BRUSH_DEFAULT ,
  HOTKEY_EDITOR_BRUSH_1 , HOTKEY_EDITOR_BRUSH_2 , HOTKEY_EDITOR_BRUSH_3 , HOTKEY_EDITOR_BRUSH_SW_NE ,
  HOTKEY_EDITOR_BRUSH_NW_SE , HOTKEY_EDITOR_TOOL_NEXT , HOTKEY_EDITOR_TOOL_PAINT , HOTKEY_EDITOR_TOOL_FILL ,
  HOTKEY_EDITOR_TOOL_SELECT , HOTKEY_EDITOR_TOOL_STARTING_POSITION , HOTKEY_EDITOR_TOOL_LABEL , HOTKEY_EDITOR_TOOL_UNIT ,
  HOTKEY_EDITOR_TOOL_VILLAGE , HOTKEY_EDITOR_TOOL_ITEM , HOTKEY_EDITOR_SELECT_ALL , HOTKEY_EDITOR_SELECT_INVERSE ,
  HOTKEY_EDITOR_SELECT_NONE , HOTKEY_EDITOR_CLIPBOARD_PASTE , HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW , HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW ,
  HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL , HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL , HOTKEY_EDITOR_SELECTION_CUT , HOTKEY_EDITOR_SELECTION_COPY ,
  HOTKEY_EDITOR_SELECTION_ROTATE , HOTKEY_EDITOR_SELECTION_FLIP , HOTKEY_EDITOR_SELECTION_FILL , HOTKEY_EDITOR_SELECTION_EXPORT ,
  HOTKEY_EDITOR_SELECTION_RANDOMIZE , HOTKEY_EDITOR_MAP_NEW , HOTKEY_EDITOR_MAP_LOAD , HOTKEY_EDITOR_MAP_SAVE ,
  HOTKEY_EDITOR_MAP_SAVE_AS , HOTKEY_EDITOR_MAP_SAVE_ALL , HOTKEY_EDITOR_MAP_REVERT , HOTKEY_EDITOR_MAP_INFO ,
  HOTKEY_EDITOR_MAP_CLOSE , HOTKEY_EDITOR_MAP_SWITCH , HOTKEY_EDITOR_MAP_RESIZE , HOTKEY_EDITOR_MAP_GENERATE ,
  HOTKEY_EDITOR_MAP_APPLY_MASK , HOTKEY_EDITOR_MAP_CREATE_MASK_TO , HOTKEY_EDITOR_UPDATE_TRANSITIONS , HOTKEY_EDITOR_TOGGLE_TRANSITIONS ,
  HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS , HOTKEY_EDITOR_PARTIAL_UPDATE_TRANSITIONS , HOTKEY_EDITOR_NO_UPDATE_TRANSITIONS , HOTKEY_EDITOR_REFRESH ,
  HOTKEY_EDITOR_REFRESH_IMAGE_CACHE , HOTKEY_EDITOR_DRAW_COORDINATES , HOTKEY_EDITOR_DRAW_TERRAIN_CODES , HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS ,
  HOTKEY_EDITOR_SIDE_NEW , HOTKEY_EDITOR_SIDE_EDIT , HOTKEY_EDITOR_SIDE_REMOVE , HOTKEY_EDITOR_AREA_REMOVE ,
  HOTKEY_EDITOR_AREA_ADD , HOTKEY_EDITOR_AREA_SAVE , HOTKEY_EDITOR_AREA_RENAME , HOTKEY_EDITOR_PBL ,
  HOTKEY_EDITOR_CHANGE_ADDON_ID , HOTKEY_EDITOR_SELECT_ADDON , HOTKEY_EDITOR_OPEN_ADDON , HOTKEY_EDITOR_SCENARIO_EDIT ,
  HOTKEY_EDITOR_SCENARIO_NEW , HOTKEY_EDITOR_SCENARIO_SAVE_AS , HOTKEY_NULL
}
 
enum  HOTKEY_CATEGORY {
  HKCAT_GENERAL , HKCAT_SAVING , HKCAT_MAP , HKCAT_UNITS ,
  HKCAT_CHAT , HKCAT_REPLAY , HKCAT_WHITEBOARD , HKCAT_SCENARIO ,
  HKCAT_PALETTE , HKCAT_TOOLS , HKCAT_CLIPBOARD , HKCAT_DEBUG ,
  HKCAT_CUSTOM , HKCAT_PLACEHOLDER
}
 

Functions

static void event_queue (const SDL_Event &event, command_executor *executor)
 
void mbutton_event (const SDL_Event &event, command_executor *executor)
 
void jbutton_event (const SDL_Event &event, command_executor *executor)
 
void jhat_event (const SDL_Event &event, command_executor *executor)
 
void key_event (const SDL_Event &event, command_executor *executor)
 
void keyup_event (const SDL_Event &, command_executor *executor)
 
void run_events (command_executor *executor)
 
bool is_scope_active (scope s)
 
bool is_scope_active (hk_scopes s)
 
const hotkey_commandget_hotkey_command (const std::string &command)
 returns the hotkey_command with the given name More...
 
const std::map< std::string_view, hotkey::hotkey_command > & get_hotkey_commands ()
 returns a container that contains all currently active hotkey_commands. More...
 
bool has_hotkey_command (const std::string &id)
 
void init_hotkey_commands ()
 
t_string get_translatable_category_name (HOTKEY_CATEGORY category)
 Gets the display name for a given hotkey category. More...
 
hotkey_ptr create_hotkey (const std::string &id, const SDL_Event &event)
 Create a new hotkey item for a command from an SDL_Event. More...
 
hotkey_ptr load_from_config (const config &cfg)
 Create and instantiate a hotkey from a config element. More...
 
bool has_hotkey_item (const std::string &command)
 
void del_hotkey (const hotkey_ptr &item)
 Remove a hotkey from the list of hotkeys. More...
 
void add_hotkey (hotkey_ptr item)
 Add a hotkey to the list of hotkeys. More...
 
void clear_hotkeys (const std::string &command)
 Unset the command bindings for all hotkeys matching the command. More...
 
void clear_hotkeys ()
 Unset the bindings for all hotkeys. More...
 
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 keyboard modifier state. More...
 
void load_default_hotkeys (const game_config_view &cfg)
 Registers all hotkeys present in this config. More...
 
void load_custom_hotkeys (const game_config_view &cfg)
 Registers all hotkeys present in this config, overwriting any matching default hotkeys. More...
 
void reset_default_hotkeys ()
 Reset all hotkeys to the defaults. More...
 
const hotkey_listget_hotkeys ()
 Returns the list of hotkeys. More...
 
void save_hotkeys (config &cfg)
 Save the non-default hotkeys to the config. More...
 
std::string get_names (const std::string &id)
 Returns a comma-separated string of hotkey names. More...
 
bool is_hotkeyable_event (const SDL_Event &event)
 

Variables

constexpr uint32_t scope_game = 1 << SCOPE_GAME
 
constexpr uint32_t scope_editor = 1 << SCOPE_EDITOR
 
constexpr uint32_t scope_main = 1 << SCOPE_MAIN_MENU
 

Detailed Description

Keyboard shortcuts for game actions.

Hotkey commands can be loaded from configuration objects. When a keyboard event corresponding to a hotkey occurs, a command_executor object can execute the hotkeys actions. For this to work, key_event() must be called whenever a keyboard event happens.

Typedef Documentation

◆ hk_scopes

typedef std::bitset<SCOPE_COUNT> hotkey::hk_scopes

Definition at line 234 of file hotkey_command.hpp.

◆ hotkey_keyboard_ptr

typedef std::shared_ptr<class hotkey_keyboard> hotkey::hotkey_keyboard_ptr

Definition at line 29 of file hotkey_item.hpp.

◆ hotkey_list

Definition at line 31 of file hotkey_item.hpp.

◆ hotkey_mouse_ptr

typedef std::shared_ptr<class hotkey_mouse> hotkey::hotkey_mouse_ptr

Definition at line 28 of file hotkey_item.hpp.

◆ hotkey_ptr

typedef std::shared_ptr<class hotkey_base> hotkey::hotkey_ptr

Definition at line 27 of file hotkey_item.hpp.

Enumeration Type Documentation

◆ ACTION_STATE

Enumerator
ACTION_STATELESS 
ACTION_ON 
ACTION_OFF 
ACTION_SELECTED 
ACTION_DESELECTED 

Definition at line 26 of file command_executor.hpp.

◆ HOTKEY_CATEGORY

Enumerator
HKCAT_GENERAL 
HKCAT_SAVING 
HKCAT_MAP 
HKCAT_UNITS 
HKCAT_CHAT 
HKCAT_REPLAY 
HKCAT_WHITEBOARD 
HKCAT_SCENARIO 
HKCAT_PALETTE 
HKCAT_TOOLS 
HKCAT_CLIPBOARD 
HKCAT_DEBUG 
HKCAT_CUSTOM 
HKCAT_PLACEHOLDER 

Definition at line 214 of file hotkey_command.hpp.

◆ HOTKEY_COMMAND

Enumerator
HOTKEY_CYCLE_UNITS 
HOTKEY_CYCLE_BACK_UNITS 
HOTKEY_UNIT_HOLD_POSITION 
HOTKEY_END_UNIT_TURN 
HOTKEY_LEADER 
HOTKEY_UNDO 
HOTKEY_REDO 
HOTKEY_ZOOM_IN 
HOTKEY_ZOOM_OUT 
HOTKEY_ZOOM_DEFAULT 
HOTKEY_FULLSCREEN 
HOTKEY_SCREENSHOT 
HOTKEY_MAP_SCREENSHOT 
HOTKEY_ACCELERATED 
HOTKEY_TERRAIN_DESCRIPTION 
HOTKEY_UNIT_DESCRIPTION 
HOTKEY_RENAME_UNIT 
HOTKEY_DELETE_UNIT 
HOTKEY_SAVE_GAME 
HOTKEY_SAVE_REPLAY 
HOTKEY_SAVE_MAP 
HOTKEY_LOAD_GAME 
HOTKEY_LOAD_AUTOSAVES 
HOTKEY_RECRUIT 
HOTKEY_REPEAT_RECRUIT 
HOTKEY_RECALL 
HOTKEY_ENDTURN 
HOTKEY_TOGGLE_ELLIPSES 
HOTKEY_TOGGLE_GRID 
HOTKEY_STATUS_TABLE 
HOTKEY_MUTE 
HOTKEY_MOUSE_SCROLL 
HOTKEY_SPEAK 
HOTKEY_CREATE_UNIT 
HOTKEY_CHANGE_SIDE 
HOTKEY_KILL_UNIT 
HOTKEY_PREFERENCES 
HOTKEY_TELEPORT_UNIT 
HOTKEY_OBJECTIVES 
HOTKEY_UNIT_LIST 
HOTKEY_STATISTICS 
HOTKEY_STOP_NETWORK 
HOTKEY_START_NETWORK 
HOTKEY_SURRENDER 
HOTKEY_QUIT_GAME 
HOTKEY_QUIT_TO_DESKTOP 
HOTKEY_LABEL_TEAM_TERRAIN 
HOTKEY_LABEL_TERRAIN 
HOTKEY_CLEAR_LABELS 
HOTKEY_SHOW_ENEMY_MOVES 
HOTKEY_BEST_ENEMY_MOVES 
HOTKEY_DELAY_SHROUD 
HOTKEY_UPDATE_SHROUD 
HOTKEY_CONTINUE_MOVE 
HOTKEY_SEARCH 
HOTKEY_SPEAK_ALLY 
HOTKEY_SPEAK_ALL 
HOTKEY_HELP 
HOTKEY_HELP_ABOUT_SAVELOAD 
HOTKEY_CHAT_LOG 
HOTKEY_LANGUAGE 
HOTKEY_ANIMATE_MAP 
HOTKEY_REPLAY_PLAY 
HOTKEY_REPLAY_RESET 
HOTKEY_REPLAY_STOP 
HOTKEY_REPLAY_NEXT_TURN 
HOTKEY_REPLAY_NEXT_SIDE 
HOTKEY_REPLAY_NEXT_MOVE 
HOTKEY_REPLAY_SHOW_EVERYTHING 
HOTKEY_REPLAY_SHOW_EACH 
HOTKEY_REPLAY_SHOW_TEAM1 
HOTKEY_REPLAY_SKIP_ANIMATION 
HOTKEY_REPLAY_EXIT 
HOTKEY_SELECT_HEX 
HOTKEY_DESELECT_HEX 
HOTKEY_MOVE_ACTION 
HOTKEY_SELECT_AND_ACTION 
HOTKEY_TOUCH_HEX 
HOTKEY_SCROLL_UP 
HOTKEY_SCROLL_DOWN 
HOTKEY_SCROLL_LEFT 
HOTKEY_SCROLL_RIGHT 
HOTKEY_CANCEL 
HOTKEY_OKAY 
HOTKEY_WB_TOGGLE 
HOTKEY_WB_EXECUTE_ACTION 
HOTKEY_WB_EXECUTE_ALL_ACTIONS 
HOTKEY_WB_DELETE_ACTION 
HOTKEY_WB_BUMP_UP_ACTION 
HOTKEY_WB_BUMP_DOWN_ACTION 
HOTKEY_WB_SUPPOSE_DEAD 
HOTKEY_USER_CMD 
HOTKEY_CUSTOM_CMD 
HOTKEY_AI_FORMULA 
HOTKEY_CLEAR_MSG 
HOTKEY_LABEL_SETTINGS 
HOTKEY_ACHIEVEMENTS 
HOTKEY_MINIMAP_CODING_TERRAIN 
HOTKEY_MINIMAP_CODING_UNIT 
HOTKEY_MINIMAP_DRAW_UNITS 
HOTKEY_MINIMAP_DRAW_VILLAGES 
HOTKEY_MINIMAP_DRAW_TERRAIN 
HOTKEY_MP_START_GAME 
TITLE_SCREEN__RELOAD_WML 
TITLE_SCREEN__NEXT_TIP 
TITLE_SCREEN__PREVIOUS_TIP 
TITLE_SCREEN__CAMPAIGN 
TITLE_SCREEN__MULTIPLAYER 
TITLE_SCREEN__ADDONS 
TITLE_SCREEN__CORES 
TITLE_SCREEN__EDITOR 
TITLE_SCREEN__CREDITS 
TITLE_SCREEN__TEST 
GLOBAL__HELPTIP 
LUA_CONSOLE 
HOTKEY_WML 
HOTKEY_EDITOR_CUSTOM_TODS 
HOTKEY_EDITOR_PARTIAL_UNDO 
HOTKEY_EDITOR_EDIT_UNIT 
HOTKEY_EDITOR_PALETTE_ITEM_SWAP 
HOTKEY_EDITOR_PALETTE_ITEMS_CLEAR 
HOTKEY_EDITOR_PALETTE_GROUPS 
HOTKEY_EDITOR_PALETTE_UPSCROLL 
HOTKEY_EDITOR_PALETTE_DOWNSCROLL 
HOTKEY_EDITOR_REMOVE_LOCATION 
HOTKEY_EDITOR_PLAYLIST 
HOTKEY_EDITOR_SCHEDULE 
HOTKEY_EDITOR_LOCAL_TIME 
HOTKEY_EDITOR_UNIT_FACING 
HOTKEY_EDITOR_HELP_TEXT_SHOWN 
HOTKEY_EDITOR_UNIT_TOGGLE_CANRECRUIT 
HOTKEY_EDITOR_UNIT_TOGGLE_RENAMEABLE 
HOTKEY_EDITOR_UNIT_CHANGE_ID 
HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL 
HOTKEY_EDITOR_BRUSH_NEXT 
HOTKEY_EDITOR_BRUSH_DEFAULT 
HOTKEY_EDITOR_BRUSH_1 
HOTKEY_EDITOR_BRUSH_2 
HOTKEY_EDITOR_BRUSH_3 
HOTKEY_EDITOR_BRUSH_SW_NE 
HOTKEY_EDITOR_BRUSH_NW_SE 
HOTKEY_EDITOR_TOOL_NEXT 
HOTKEY_EDITOR_TOOL_PAINT 
HOTKEY_EDITOR_TOOL_FILL 
HOTKEY_EDITOR_TOOL_SELECT 
HOTKEY_EDITOR_TOOL_STARTING_POSITION 
HOTKEY_EDITOR_TOOL_LABEL 
HOTKEY_EDITOR_TOOL_UNIT 
HOTKEY_EDITOR_TOOL_VILLAGE 
HOTKEY_EDITOR_TOOL_ITEM 
HOTKEY_EDITOR_SELECT_ALL 
HOTKEY_EDITOR_SELECT_INVERSE 
HOTKEY_EDITOR_SELECT_NONE 
HOTKEY_EDITOR_CLIPBOARD_PASTE 
HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW 
HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW 
HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL 
HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL 
HOTKEY_EDITOR_SELECTION_CUT 
HOTKEY_EDITOR_SELECTION_COPY 
HOTKEY_EDITOR_SELECTION_ROTATE 
HOTKEY_EDITOR_SELECTION_FLIP 
HOTKEY_EDITOR_SELECTION_FILL 
HOTKEY_EDITOR_SELECTION_EXPORT 
HOTKEY_EDITOR_SELECTION_RANDOMIZE 
HOTKEY_EDITOR_MAP_NEW 
HOTKEY_EDITOR_MAP_LOAD 
HOTKEY_EDITOR_MAP_SAVE 
HOTKEY_EDITOR_MAP_SAVE_AS 
HOTKEY_EDITOR_MAP_SAVE_ALL 
HOTKEY_EDITOR_MAP_REVERT 
HOTKEY_EDITOR_MAP_INFO 
HOTKEY_EDITOR_MAP_CLOSE 
HOTKEY_EDITOR_MAP_SWITCH 
HOTKEY_EDITOR_MAP_RESIZE 
HOTKEY_EDITOR_MAP_GENERATE 
HOTKEY_EDITOR_MAP_APPLY_MASK 
HOTKEY_EDITOR_MAP_CREATE_MASK_TO 
HOTKEY_EDITOR_UPDATE_TRANSITIONS 
HOTKEY_EDITOR_TOGGLE_TRANSITIONS 
HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS 
HOTKEY_EDITOR_PARTIAL_UPDATE_TRANSITIONS 
HOTKEY_EDITOR_NO_UPDATE_TRANSITIONS 
HOTKEY_EDITOR_REFRESH 
HOTKEY_EDITOR_REFRESH_IMAGE_CACHE 
HOTKEY_EDITOR_DRAW_COORDINATES 
HOTKEY_EDITOR_DRAW_TERRAIN_CODES 
HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS 
HOTKEY_EDITOR_SIDE_NEW 
HOTKEY_EDITOR_SIDE_EDIT 
HOTKEY_EDITOR_SIDE_REMOVE 
HOTKEY_EDITOR_AREA_REMOVE 
HOTKEY_EDITOR_AREA_ADD 
HOTKEY_EDITOR_AREA_SAVE 
HOTKEY_EDITOR_AREA_RENAME 
HOTKEY_EDITOR_PBL 
HOTKEY_EDITOR_CHANGE_ADDON_ID 
HOTKEY_EDITOR_SELECT_ADDON 
HOTKEY_EDITOR_OPEN_ADDON 
HOTKEY_EDITOR_SCENARIO_EDIT 
HOTKEY_EDITOR_SCENARIO_NEW 
HOTKEY_EDITOR_SCENARIO_SAVE_AS 
HOTKEY_NULL 

Definition at line 48 of file hotkey_command.hpp.

◆ scope

Available hotkey scopes.

The scope is used to allow command from non-overlapping areas of the game share the same key

Enumerator
SCOPE_MAIN_MENU 
SCOPE_GAME 
SCOPE_EDITOR 
SCOPE_COUNT 

Definition at line 34 of file hotkey_command.hpp.

Function Documentation

◆ add_hotkey()

void hotkey::add_hotkey ( hotkey_ptr  item)

Add a hotkey to the list of hotkeys.

Parameters
itemThe item to add.

Definition at line 335 of file hotkey_item.cpp.

Referenced by gui2::dialogs::preferences_dialog::add_hotkey_callback(), load_custom_hotkeys(), and hotkey::wml_hotkey_record::wml_hotkey_record().

◆ clear_hotkeys() [1/2]

void hotkey::clear_hotkeys ( )

Unset the bindings for all hotkeys.

Definition at line 362 of file hotkey_item.cpp.

◆ clear_hotkeys() [2/2]

void hotkey::clear_hotkeys ( const std::string &  command)

Unset the command bindings for all hotkeys matching the command.

Parameters
commandThe binding to be unset

Definition at line 349 of file hotkey_item.cpp.

Referenced by gui2::dialogs::preferences_dialog::remove_hotkey_callback(), and hotkey::manager::~manager().

◆ create_hotkey()

hotkey_ptr hotkey::create_hotkey ( const std::string &  id,
const SDL_Event &  event 
)

Create a new hotkey item for a command from an SDL_Event.

Parameters
idThe command to bind to.
eventThe SDL_Event to base the creation on.

Definition at line 123 of file hotkey_item.cpp.

References ERR_G, get_hotkey_command(), sdl::get_mods(), CKey::is_uncomposable(), and hotkey::hotkey_command::toggle.

Referenced by gui2::dialogs::hotkey_bind::sdl_event_callback().

◆ del_hotkey()

void hotkey::del_hotkey ( const hotkey_ptr item)

Remove a hotkey from the list of hotkeys.

Todo:
unusued?

Definition at line 328 of file hotkey_item.cpp.

References utils::erase().

◆ event_queue()

static void hotkey::event_queue ( const SDL_Event &  event,
command_executor executor 
)
static

◆ get_hotkey()

const hotkey_ptr hotkey::get_hotkey ( const SDL_Event &  event)

Iterate through the list of hotkeys and return a hotkey that matches the SDL_Event and the current keyboard modifier state.

Parameters
eventThe SDL_Event to use as a template.
Returns
The newly created hotkey item.

Definition at line 367 of file hotkey_item.cpp.

Referenced by gui2::event::sdl_event_handler::button_down(), gui2::event::sdl_event_handler::hat_motion(), gui2::event::sdl_event_handler::key_down(), wb::manager::print_help_once(), and hotkey::command_executor::queue_command().

◆ get_hotkey_command()

NOT_DANGLING const hotkey_command & hotkey::get_hotkey_command ( const std::string &  command)

◆ get_hotkey_commands()

const std::map< std::string_view, hotkey::hotkey_command > & hotkey::get_hotkey_commands ( )

returns a container that contains all currently active hotkey_commands.

everything that wants a hotkey, must be in this container

Definition at line 376 of file hotkey_command.cpp.

Referenced by gui2::dialogs::preferences_dialog::setup_hotkey_list().

◆ get_hotkeys()

const hotkey_list & hotkey::get_hotkeys ( )

Returns the list of hotkeys.

Definition at line 411 of file hotkey_item.cpp.

Referenced by gui2::dialogs::preferences_dialog::add_hotkey_callback().

◆ get_names()

std::string hotkey::get_names ( const std::string &  id)

◆ get_translatable_category_name()

t_string hotkey::get_translatable_category_name ( HOTKEY_CATEGORY  category)

Gets the display name for a given hotkey category.

Definition at line 502 of file hotkey_command.cpp.

Referenced by gui2::dialogs::preferences_dialog::setup_hotkey_list().

◆ has_hotkey_command()

bool hotkey::has_hotkey_command ( const std::string &  id)

◆ has_hotkey_item()

bool hotkey::has_hotkey_item ( const std::string &  command)

Definition at line 308 of file hotkey_item.cpp.

Referenced by hotkey::wml_hotkey_record::wml_hotkey_record().

◆ init_hotkey_commands()

void hotkey::init_hotkey_commands ( )

Definition at line 492 of file hotkey_command.cpp.

Referenced by hotkey::manager::manager().

◆ is_hotkeyable_event()

bool hotkey::is_hotkeyable_event ( const SDL_Event &  event)

Definition at line 451 of file hotkey_item.cpp.

References sdl::get_mods().

Referenced by gui2::dialogs::hotkey_bind::sdl_event_callback().

◆ is_scope_active() [1/2]

bool hotkey::is_scope_active ( hk_scopes  s)

Definition at line 360 of file hotkey_command.cpp.

References s.

◆ is_scope_active() [2/2]

bool hotkey::is_scope_active ( scope  s)

Definition at line 354 of file hotkey_command.cpp.

References s, and SCOPE_COUNT.

Referenced by help::description_type(), and hotkey::hotkey_base::matches().

◆ jbutton_event()

void hotkey::jbutton_event ( const SDL_Event &  event,
command_executor executor 
)

Definition at line 545 of file command_executor.cpp.

References event_queue().

Referenced by controller_base::handle_event().

◆ jhat_event()

void hotkey::jhat_event ( const SDL_Event &  event,
command_executor executor 
)

Definition at line 550 of file command_executor.cpp.

References event_queue().

Referenced by controller_base::handle_event().

◆ key_event()

void hotkey::key_event ( const SDL_Event &  event,
command_executor executor 
)

Definition at line 555 of file command_executor.cpp.

References event_queue().

Referenced by controller_base::handle_event().

◆ keyup_event()

void hotkey::keyup_event ( const SDL_Event &  ,
command_executor executor 
)

◆ load_custom_hotkeys()

void hotkey::load_custom_hotkeys ( const game_config_view cfg)

Registers all hotkeys present in this config, overwriting any matching default hotkeys.

Parameters
cfgThe config to load from.

Definition at line 390 of file hotkey_item.cpp.

References add_hotkey(), game_config_view::child_range(), and load_from_config().

Referenced by prefs::load_hotkeys().

◆ load_default_hotkeys()

void hotkey::load_default_hotkeys ( const game_config_view cfg)

Registers all hotkeys present in this config.

Parameters
cfgThe config to load from. This is saved and is used again when reset_default_hotkeys is called.

Definition at line 377 of file hotkey_item.cpp.

References game_config_view::child_range(), and load_from_config().

Referenced by test_utils::game_config_manager::game_config_manager(), game_config_manager::init_game_config(), and reset_default_hotkeys().

◆ load_from_config()

hotkey_ptr hotkey::load_from_config ( const config cfg)

Create and instantiate a hotkey from a config element.

Parameters
cfgThe config element to read for data.
Returns
The new instance of the hotkey item.

Definition at line 174 of file hotkey_item.cpp.

References config_attribute_value::empty(), ERR_G, and config_attribute_value::to_int().

Referenced by load_custom_hotkeys(), load_default_hotkeys(), and hotkey::wml_hotkey_record::wml_hotkey_record().

◆ mbutton_event()

void hotkey::mbutton_event ( const SDL_Event &  event,
command_executor executor 
)

Definition at line 527 of file command_executor.cpp.

References event_queue(), and run_events().

Referenced by controller_base::handle_event().

◆ reset_default_hotkeys()

void hotkey::reset_default_hotkeys ( )

Reset all hotkeys to the defaults.

Definition at line 400 of file hotkey_item.cpp.

References ERR_G, and load_default_hotkeys().

Referenced by prefs::clear_hotkeys().

◆ run_events()

void hotkey::run_events ( command_executor executor)

◆ save_hotkeys()

void hotkey::save_hotkeys ( config cfg)

Save the non-default hotkeys to the config.

Parameters
cfgThe config to save to.

Definition at line 416 of file hotkey_item.cpp.

References config::add_child(), and config::clear_children().

Referenced by prefs::save_hotkeys().

Variable Documentation

◆ scope_editor

constexpr uint32_t hotkey::scope_editor = 1 << SCOPE_EDITOR
constexpr

Definition at line 45 of file hotkey_command.hpp.

Referenced by editor::start().

◆ scope_game

constexpr uint32_t hotkey::scope_game = 1 << SCOPE_GAME
constexpr

◆ scope_main

constexpr uint32_t hotkey::scope_main = 1 << SCOPE_MAIN_MENU
constexpr

Definition at line 46 of file hotkey_command.hpp.

Referenced by game_config_manager::init_game_config().