16 #ifndef HOTKEY_ITEM_HPP_INCLUDED
17 #define HOTKEY_ITEM_HPP_INCLUDED
19 #include <SDL_events.h>
21 #include <boost/shared_ptr.hpp>
155 virtual bool valid()
const = 0;
262 return scancode_ != SDL_SCANCODE_UNKNOWN;
void save(config &cfg) const
Save the hotkey into the configuration object.
hotkey_mouse()
Initialise new instance of this class that has no button associated with is.
bool is_default_
is_default_ is true if the hot-key is part of the default hot-key list defined in data/core/hotkeys...
std::vector< hotkey::hotkey_ptr >::iterator hotkey_list_iter
hotkey_ptr load_from_config(const config &cfg)
Create and instantiate a hotkey from a config element.
boost::shared_ptr< hotkey_keyboard > hotkey_keyboard_ptr
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
void set_scancode(SDL_Scancode scancode)
Set the scancode associated with this class.
bool matches(const SDL_Event &event) const
Used to evaluate whether:
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.
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
void del_hotkey(hotkey_ptr item)
Remove a hotkey from the list of hotkeys.
void clear_hotkeys(const std::string &command)
Unset the command bindings for all hotkeys matching the command.
hotkey_ptr show_binding_dialog(CVideo &video, const std::string &id)
bool has_hotkey_item(const std::string &command)
virtual bool valid() const
Evaluates whether the hotkey bindings are valid.
virtual bool matches_helper(const SDL_Event &event) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
virtual void save_helper(config &cfg) const
virtual bool matches_helper(const SDL_Event &event) const =0
This is invoked by hotkey_base::matches as a helper for the concrete classes.
Keyboard shortcuts for game actions.
virtual void save_helper(config &) const
const hotkey_list & get_hotkeys()
Returns the list of hotkeys.
void unset_default()
Used to indicate that a hotkey is overriden and should be treated as a user-set hotkey.
hotkey_keyboard()
Initialise new instance of this class that has no key associated with is.
virtual bool valid() const
Returns true if the hotkey has a valid mouse button associated with it.
virtual void save_helper(config &cfg) const =0
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 set_button(int button)
hotkey_ptr create_hotkey(const std::string &id, SDL_Event &event)
Create a new hotkey item for a command from an SDL_Event.
void add_hotkey(const hotkey_ptr item)
Add a hotkey to the list of hotkeys.
This class is used to return non-valid results in order to save other people from null checks...
virtual bool matches_helper(const SDL_Event &) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
std::vector< hotkey::hotkey_ptr > hotkey_list
virtual bool hidden() const
This controls whether the item should appear in the hotkey preferences.
virtual const std::string get_name_helper() const =0
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
virtual bool matches_helper(const SDL_Event &event) const
This is invoked by hotkey_base::matches as a helper for the concrete classes.
boost::shared_ptr< hotkey_mouse > hotkey_mouse_ptr
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
std::string get_names(std::string id)
Returns a comma-separated string of hotkey names.
bool is_default() const
This indicates whether a hotkey is from the default config or if it's from the user preferences...
boost::shared_ptr< hotkey_base > hotkey_ptr
void reset_default_hotkeys()
Reset all hotkeys to the defaults.
virtual const std::string get_name_helper() const
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
virtual bool valid() const =0
Evaluates whether the hotkey bindings are valid.
This class is responsible for handling mouse button presses.
void set_command(const std::string &command)
void set_mods(unsigned int mods)
Set keyboard modifiers.
const std::string & get_command() const
Returns the string name of the HOTKEY_COMMAND.
This is the base class for hotkey event matching.
virtual bool bindings_equal_helper(hotkey_ptr other) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
std::string command_
The command that should be executed, or "null".
hotkey_base()
Initialises a new empty hotkey that will be disabled.
void load_hotkeys(const config &cfg, bool set_as_default)
Iterates through all hotkeys present in the config struct and creates and adds them to the hotkey lis...
This class is responsible for handling keys, not modifiers.
virtual bool bindings_equal_helper(hotkey_ptr other) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
virtual bool bindings_equal(hotkey_ptr other)
Checks whether the hotkey bindings and scope are equal.
const std::string get_description() const
Returns the translated description.
void clear()
Unbind this hotkey by linking it to the null-command.
A config object defines a single node in a WML file, with access to child nodes.
virtual void save_helper(config &cfg) const
virtual bool bindings_equal_helper(hotkey_ptr) const
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
GLsizei const GLcharARB ** string
bool null() const
Returns whether this hotkey points to the null-command.
virtual bool valid() const
Checks whether this hotkey has been set to a sensible value.
const std::string get_name() const
Return "name" of hotkey.