18 #include <SDL2/SDL_events.h>
169 bool matches(
const SDL_Event& event)
const;
249 void set_text(
const std::string& text);
418 std::string
get_names(
const std::string&
id);
A config object defines a single node in a WML file, with access to child nodes.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
This is the base class for hotkey event matching.
void set_command(const std::string &command)
void clear()
Unbind this hotkey by linking it to the null-command.
virtual void save_helper(config &cfg) const =0
const std::string & get_command() const
Returns the string name of the HOTKEY_COMMAND.
void unset_default()
Used to indicate that a hotkey is overridden and should be treated as a user-set hotkey.
hotkey_base()
Initialises a new empty hotkey that will be disabled.
bool is_default() const
This indicates whether a hotkey is from the default config or if it's from the user preferences.
virtual bool hidden() const
This controls whether the item should appear in the hotkey preferences.
void save(config &cfg) const
Save the hotkey into the configuration object.
bool is_default_
is_default_ is true if the hot-key is part of the default hot-key list defined in data/core/hotkeys....
const std::string get_description() const
Returns the translated description.
void set_mods(unsigned int mods)
Set keyboard modifiers.
virtual bool valid() const =0
Evaluates whether the hotkey bindings are valid.
virtual bool bindings_equal_helper(hotkey_ptr other) const =0
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
bool matches(const SDL_Event &event) const
Used to evaluate whether:
virtual bool bindings_equal(hotkey_ptr other)
Checks whether the hotkey bindings and scope are equal.
std::string command_
The command that should be executed, or "null".
virtual const std::string get_name_helper() const =0
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
const std::string get_name() const
Return "name" of hotkey.
virtual bool matches_helper(const SDL_Event &event) const =0
This is invoked by hotkey_base::matches as a helper for the concrete classes.
This class is responsible for handling keys, not modifiers.
void set_text(const std::string &text)
virtual bool valid() const
Checks whether this hotkey has been set to a sensible value.
virtual void save_helper(config &cfg) const
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
hotkey_keyboard()
Initialise new instance of this class that has no key associated with is.
virtual bool bindings_equal_helper(hotkey_ptr other) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
void set_keycode(SDL_Keycode keycode)
Set the keycode associated with this class.
virtual bool matches_helper(const SDL_Event &event) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
This class is responsible for handling mouse button presses.
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
virtual void save_helper(config &cfg) const
void set_button(int button)
virtual bool valid() const
Returns true if the hotkey has a valid mouse button associated with it.
virtual bool matches_helper(const SDL_Event &event) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
virtual bool bindings_equal_helper(hotkey_ptr other) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
hotkey_mouse()
Initialise new instance of this class that has no button associated with is.
This class is used to return non-valid results in order to save other people from null checks.
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
virtual void save_helper(config &) const
virtual bool valid() const
Evaluates whether the hotkey bindings are valid.
virtual bool bindings_equal_helper(hotkey_ptr) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
virtual bool matches_helper(const SDL_Event &) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
std::pair< std::string, unsigned > item
Keyboard shortcuts for game actions.
const hotkey_list & get_hotkeys()
Returns the list of hotkeys.
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
std::shared_ptr< class hotkey_keyboard > hotkey_keyboard_ptr
std::shared_ptr< class hotkey_base > hotkey_ptr
bool has_hotkey_item(const std::string &command)
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...
void clear_hotkeys(const std::string &command)
Unset the command bindings for all hotkeys matching the command.
void reset_default_hotkeys()
Reset all hotkeys to the defaults.
hotkey_ptr load_from_config(const config &cfg)
Create and instantiate a hotkey from a config element.
hotkey_ptr create_hotkey(const std::string &id, const SDL_Event &event)
Create a new hotkey item for a command from an SDL_Event.
std::shared_ptr< class hotkey_mouse > hotkey_mouse_ptr
void del_hotkey(hotkey_ptr item)
Remove a hotkey from the list of hotkeys.
std::vector< hotkey::hotkey_ptr > hotkey_list
void load_custom_hotkeys(const game_config_view &cfg)
Registers all hotkeys present in this config, overwriting any matching default hotkeys.
void load_default_hotkeys(const game_config_view &cfg)
Registers all hotkeys present in this config.
void add_hotkey(hotkey_ptr item)
Add a hotkey to the list of hotkeys.
bool is_hotkeyable_event(const SDL_Event &event)