15 #define GETTEXT_DOMAIN "wesnoth-lib"
25 #define ERR_G LOG_STREAM(err, lg::general())
26 #define LOG_G LOG_STREAM(info, lg::general())
27 #define DBG_G LOG_STREAM(debug, lg::general())
28 #define ERR_CF LOG_STREAM(err, log_config)
160 {
hotkey::HOTKEY_EDITOR_TOOL_PAINT,
"editor-tool-paint",
N_(
"Paint Tool"),
false, scope_editor,
N_(
"Use left/right mouse button to draw fore-/background terrain. Hold Shift to paint base layer only. Ctrl+click to sample terrain under cursor.") },
161 {
hotkey::HOTKEY_EDITOR_TOOL_FILL,
"editor-tool-fill",
N_(
"Fill Tool"),
false, scope_editor,
N_(
"Use left/right mouse button to draw fore-/background terrain. Hold Shift to paint base layer only. Ctrl+click to sample terrain under cursor.") },
162 {
hotkey::HOTKEY_EDITOR_TOOL_SELECT,
"editor-tool-select",
N_(
"Selection Tool"),
false, scope_editor,
N_(
"Left mouse button selects or deselects with Ctrl, right brings up a context menu. Hold Shift for magic-wand selection of tiles with same terrain.") },
163 {
hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION,
"editor-tool-starting-position",
N_(
"Starting Positions Tool"),
false, scope_editor,
N_(
"Left mouse button displays player selection, right clears. Number keys scroll to the starting position, alt+number sets respective starting position under cursor, delete clears.") },
165 {
hotkey::HOTKEY_EDITOR_TOOL_UNIT,
"editor-tool-unit",
N_(
"Unit Tool"),
false, scope_editor,
N_(
"Left mouse button sets a new unit or moves a unit via drag and drop, right brings up a context menu. Needs a defined side.") },
166 {
hotkey::HOTKEY_EDITOR_TOOL_ITEM,
"editor-tool-item",
N_(
"Item Tool"),
false, scope_editor,
N_(
"Left mouse button sets a new item or moves it via drag and drop, right clears. Not implemented yet.") },
167 {
hotkey::HOTKEY_EDITOR_TOOL_SOUNDSOURCE,
"editor-tool-soundsource",
N_(
"Sound Source Tool"),
false, scope_editor,
N_(
"Left mouse button sets or drags a sound source, right clears. Not implemented yet.") },
168 {
hotkey::HOTKEY_EDITOR_TOOL_VILLAGE,
"editor-tool-village",
N_(
"Village Tool"),
false, scope_editor,
N_(
"Left mouse button sets the village ownership to the current side, right clears. Needs a defined side.") },
265 {
hotkey::LUA_CONSOLE,
"global__lua__console",
N_(
"Show Lua Console"),
false, scope_game | scope_editor | scope_main,
""},
273 boost::ptr_vector<hotkey::hotkey_command> known_hotkeys;
276 std::map<std::string, size_t> command_map_;
285 : prev_scope_active_(scope_active_)
297 scope_active_[
i] =
false;
303 scope_active_[
s] =
set;
320 if (command_map_.find(command) == command_map_.end())
325 return known_hotkeys[command_map_[command]];
330 return known_hotkeys;
340 LOG_G <<
"remove_wml_hotkey: command with id=" +
id +
" doesn't exist\n";
345 LOG_G <<
"remove_wml_hotkey: command with id=" +
id +
" cannot be removed because it is no wml menu hotkey\n";
350 LOG_G <<
"removing wml hotkey with id=" +
id +
"\n";
353 if(
itor->command ==
id)
355 known_hotkeys.erase(
itor);
360 command_map_.clear();
363 command_map_[known_hotkeys[
index].command] =
index;
378 LOG_G <<
"Couldn't add wml hotkey with null id and description = '" << description <<
"'.\n";
385 LOG_G <<
"Hotkey with id '" <<
id <<
"' already exists. Deleting the old hotkey_command.\n";
388 DBG_G <<
"Added wml hotkey with id = '" <<
id <<
"' and description = '" << description <<
"'.\n";
391 command_map_[
id] = known_hotkeys.
size() - 1;
396 new_item->set_command(
id);
397 if(new_item->valid())
399 DBG_G <<
"added default description for the wml hotkey with id=" +
id;
404 ERR_CF <<
"failed to add default hotkey with id=" +
id;
416 ERR_G <<
"hotkey_command's default constructor called. This shouldn't happen, because all its members are const.";
420 :
id(cmd), command(id_), description(desc), hidden(hid),
scope(scop), tooltip(toolt)
438 ERR_G <<
"the hotkey command seems to be the null command but it is not 100% sure. This shouldn't happen";
450 if(cmd.id == command)
453 ERR_G <<
" \"get_command_by_command\" returned get_hotkey_null() because no hotkey_command had the requested number:" <<
command;
461 return known_hotkeys[
sizeof(hotkey_list_) /
sizeof(hotkey_list_[0]) - 1];
468 command_map_.erase(known_hotkeys.back().command);
473 known_hotkeys.erase(last_element);
490 boost::ptr_vector<hotkey_command> known_hotkeys_temp(200);
491 known_hotkeys = known_hotkeys_temp;
496 known_hotkeys.push_back(
new hotkey_command(cmd.id, cmd.command,
t_string(cmd.description,
"wesnoth-lib"), cmd.hidden, cmd.scope,
t_string(cmd.tooltip,
"wesnoth-lib")));
497 command_map_[cmd.command] =
i;
503 command_map_.clear();
bool null() const
checks weather this is the null hotkey_command
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
static lg::log_domain log_config("config")
hotkey_ptr load_from_config(const config &cfg)
Create and instantiate a hotkey from a config element.
scope
Available hotkey scopes.
void set_scope_active(scope s, bool set)
void add_wml_hotkey(const std::string &id, const t_string &description, const config &default_hotkey)
adds a new wml hotkey to the list, but only if there is no hotkey with that id yet on the list...
static const hotkey_command & null_command()
returns the command that is treated as null
bool is_scope_active(hk_scopes s)
Stores all information related to functions that can be bound to hotkeys.
bool has_hotkey_item(const std::string &command)
Definitions for the interface to Wesnoth Markup Language (WML).
void clear_hotkey_commands()
void set_active_scopes(hk_scopes s)
Keyboard shortcuts for game actions.
const std::string & get_tooltip(const std::string &command)
const t_string description
std::bitset< SCOPE_COUNT > hk_scopes
void init_hotkey_commands()
const boost::ptr_vector< hotkey_command > & get_hotkey_commands()
returns a container that contains all currently active hotkey_commands.
void add_hotkey(const hotkey_ptr item)
Add a hotkey to the list of hotkeys.
const hotkey::hk_scopes scope
The visibility scope of the command.
void deactivate_all_scopes()
Do not use this outside hotkeys.cpp.
std::map< std::string, tfilter >::iterator itor
const std::string command
The command is unique.
hotkey_command()
the compiler want me to make a default constructor since most member are const, calling the default c...
const std::string & get_description(const std::string &command)
const hotkey_command & get_hotkey_null()
returns the hotkey_command that is treated as null.
hk_scopes prev_scope_active_
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
bool has_hotkey_command(const std::string &id)
Standard logging facilities (interface).
A config object defines a single node in a WML file, with access to child nodes.
std::string::size_type size() const
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
void delete_all_wml_hotkeys()
deletes all wml hotkeys, should be called after a game has ended
bool remove_wml_hotkey(const std::string &id)
removes a wml hotkey with the given id, returns true if the deletion was successful ...
GLsizei const GLcharARB ** string
HOTKEY_COMMAND get_id(const std::string &command)
returns get_hotkey_command(command).id
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...