added hotkeys for wml menu items, step1 (changes in game_events.cpp missing)

This commit is contained in:
gfgtdf 2013-08-30 23:45:51 +02:00
parent 5b632a0b1b
commit a208620cf0
19 changed files with 604 additions and 299 deletions

View File

@ -276,12 +276,11 @@ void controller_base::slice_end()
void controller_base::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp)
{
std::vector<std::string> items = items_arg;
hotkey::HOTKEY_COMMAND command;
std::vector<std::string>::iterator i = items.begin();
while(i != items.end()) {
command = hotkey::get_id(*i);
hotkey::hotkey_command& command = hotkey::get_hotkey_command(*i);
if(!can_execute_command(command)
|| (context_menu && !in_context_menu(command))) {
|| (context_menu && !in_context_menu(command.id))) {
i = items.erase(i);
continue;
}
@ -298,7 +297,7 @@ void controller_base::execute_action(const std::vector<std::string>& items_arg,
std::vector<std::string> items;
BOOST_FOREACH(const std::string& item, items_arg) {
hotkey::HOTKEY_COMMAND command = hotkey::get_id(item);
hotkey::hotkey_command& command = hotkey::get_hotkey_command(item);
if(can_execute_command(command))
items.push_back(item);
}

View File

@ -233,10 +233,10 @@ void editor_controller::custom_tods_dialog()
context_manager_->refresh_all();
}
bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
bool editor_controller::can_execute_command(const hotkey::hotkey_command& cmd, int index) const
{
using namespace hotkey; //reduce hotkey:: clutter
switch (command) {
switch (cmd.id) {
case HOTKEY_NULL:
if (index >= 0) {
unsigned i = static_cast<unsigned>(index);
@ -511,10 +511,10 @@ hotkey::ACTION_STATE editor_controller::get_action_state(hotkey::HOTKEY_COMMAND
}
}
bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int index)
bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int index)
{
const int zoom_amount = 4;
hotkey::HOTKEY_COMMAND command = cmd.id;
SCOPE_ED;
using namespace hotkey;
switch (command) {
@ -833,7 +833,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
gui().invalidate_all();
return true;
default:
return controller_base::execute_command(command, index);
return controller_base::execute_command(cmd, index);
}
}
@ -855,11 +855,11 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
while(i != items_arg.end())
{
hotkey::HOTKEY_COMMAND command = hotkey::get_id(*i);
hotkey::hotkey_command& command = hotkey::get_hotkey_command(*i);
if ( ( can_execute_command(command)
&& (!context_menu || in_context_menu(command)) )
|| command == hotkey::HOTKEY_NULL) {
&& (!context_menu || in_context_menu(command.id)) )
|| command.id == hotkey::HOTKEY_NULL) {
items.push_back(*i);
}
++i;

View File

@ -107,13 +107,13 @@ class editor_controller : public controller_base,
void save_map() {context_manager_->save_map();};
/** command_executor override */
bool can_execute_command(hotkey::HOTKEY_COMMAND, int index = -1) const;
bool can_execute_command(const hotkey::hotkey_command& command, int index = -1) const;
/** command_executor override */
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const;
/** command_executor override */
bool execute_command(hotkey::HOTKEY_COMMAND command, int index = -1);
bool execute_command(const hotkey::hotkey_command& command, int index = -1);
/** controller_base override */
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp);

View File

@ -94,9 +94,12 @@ wml_menu_item::wml_menu_item(const std::string& id, const config* cfg) :
image = (*cfg)["image"].str();
description = (*cfg)["description"];
needs_select = (*cfg)["needs_select"].to_bool();
use_hotkey = (*cfg)["use_hotkey"].to_bool(true);
ignore_filter_on_hotkey = (*cfg)["ignore_filter_on_hotkey"].to_bool();
if (const config &c = cfg->child("show_if")) show_if = c;
if (const config &c = cfg->child("filter_location")) filter_location = c;
if (const config &c = cfg->child("command")) command = c;
if (const config &c = cfg->child("default_hotkey")) default_hotkey = c;
}
}
@ -138,12 +141,16 @@ void wmi_container::to_config(config& cfg){
new_cfg["image"]=j->second->image;
new_cfg["description"]=j->second->description;
new_cfg["needs_select"] = j->second->needs_select;
new_cfg["use_hotkey"] = j->second->use_hotkey;
new_cfg["ignore_filter_on_hotkey"] = j->second->ignore_filter_on_hotkey;
if(!j->second->show_if.empty())
new_cfg.add_child("show_if", j->second->show_if);
if(!j->second->filter_location.empty())
new_cfg.add_child("filter_location", j->second->filter_location);
if(!j->second->command.empty())
new_cfg.add_child("command", j->second->command);
if(!j->second->default_hotkey.empty())
new_cfg.add_child("default_hotkey", j->second->command);
cfg.add_child("menu_item", new_cfg);
}
}

View File

@ -61,6 +61,9 @@ struct wml_menu_item
config show_if;
config filter_location;
config command;
config default_hotkey;
bool use_hotkey;
bool ignore_filter_on_hotkey;
};
class wmi_container{

View File

@ -69,9 +69,10 @@ void help_button::show_help()
help::show_help(disp_, topic_);
}
bool help_button::can_execute_command(hotkey::HOTKEY_COMMAND cmd, int/*index*/) const
bool help_button::can_execute_command(const hotkey::hotkey_command& cmd, int/*index*/) const
{
return (topic_.empty() == false && cmd == hotkey::HOTKEY_HELP) || cmd == hotkey::HOTKEY_SCREENSHOT;
hotkey::HOTKEY_COMMAND command = cmd.id;
return (topic_.empty() == false && command == hotkey::HOTKEY_HELP) || command == hotkey::HOTKEY_SCREENSHOT;
}
void help_button::join() {

View File

@ -58,7 +58,7 @@ public:
void leave();
private:
void show_help();
bool can_execute_command(hotkey::HOTKEY_COMMAND cmd, int/*index*/ =-1) const;
bool can_execute_command(const hotkey::hotkey_command& command, int/*index*/ =-1) const;
display &disp_;
const std::string topic_;

View File

@ -38,6 +38,7 @@
#include <boost/assign/list_of.hpp>
#include <boost/foreach.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
namespace preferences {
@ -269,22 +270,26 @@ hotkey_preferences_dialog::hotkey_preferences_dialog(display& disp) :
set_measurements(preferences::width, preferences::height);
// Populate the command vectors, this needs to happen only once.
const hotkey::hotkey_command* list = hotkey::get_hotkey_commands();
for (size_t i = 0; list[i].id != hotkey::HOTKEY_NULL; ++i) {
const boost::ptr_vector<hotkey::hotkey_command>& list = hotkey::get_hotkey_commands();
//for (size_t i = 0; list[i].id != hotkey::HOTKEY_NULL; ++i) {
BOOST_FOREACH(const hotkey::hotkey_command& command, list)
{
if (command.hidden)
{
continue;
}
if (list[i].hidden) {
continue; }
switch (list[i].scope) {
switch (command.scope) {
case hotkey::SCOPE_GAME:
game_commands_.push_back(list[i].command);
game_commands_.push_back(command.command);
break;
case hotkey::SCOPE_EDITOR:
editor_commands_.push_back(list[i].command);
editor_commands_.push_back(command.command);
break;
case hotkey::SCOPE_GENERAL:
general_commands_.push_back(list[i].command);
general_commands_.push_back(command.command);
break;
case hotkey::SCOPE_COUNT:
break;
@ -351,7 +356,7 @@ void hotkey_preferences_dialog::set_hotkey_menu(bool keep_viewport) {
if (truncated_description.size() >= (truncate_at + 2) ) {
utils::ellipsis_truncate(truncated_description, truncate_at);
}
const std::string& name = hotkey::get_names(hotkey::get_id(command));
const std::string& name = hotkey::get_names(command);
menu_items.push_back(
(formatter() << truncated_description << HELP_STRING_SEPARATOR
@ -641,7 +646,7 @@ Control, Alt or Meta modifiers to avoid problems."));
break;
}
if (oldhk && !oldhk->null()) {
if (oldhk && oldhk->active()) {
if (oldhk->get_command() != id) {
utils::string_map symbols;

View File

@ -35,6 +35,7 @@
#include <map>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
static lg::log_domain log_config("config");
#define ERR_G LOG_STREAM(err, lg::general)
@ -45,6 +46,7 @@ static lg::log_domain log_config("config");
namespace {
std::vector<hotkey::hotkey_item> hotkeys_;
// the size_t are indexes for known_hotkeys, because known_hotkeys begins with input_list_, they are also indexes for input_list_.
std::map<std::string, size_t> command_map_;
hotkey::hotkey_item null_hotkey_("null");
@ -52,120 +54,127 @@ hotkey::hotkey_item null_hotkey_("null");
std::vector<bool> scope_active_(hotkey::SCOPE_COUNT, false);
config default_hotkey_cfg_;
// contains copys of hotkey_list_ and all current active wml menau hotkeys
// maybe known_hotkeys is not a fitting name anymore.
boost::ptr_vector<hotkey::hotkey_command> known_hotkeys;
}
namespace hotkey {
//what is this for??
const input_controll input_list_[] = {
{ hotkey::INPUT_SCROLL_HORIZONTAL, "scroll-horizontal", N_("Scroll Viewport Horizontally"), false, hotkey::SCOPE_GENERAL },
{ hotkey::INPUT_SCROLL_VERTICAL, "scroll-vertical", N_("Scroll Viewport Vertically"), false, hotkey::SCOPE_GENERAL }
};
const hotkey_command hotkey_list_[] = {
//msvc cannot collapse this otherwise
#pragma region hotkey_list_
// this contains all static hotkeys
{ hotkey::HOTKEY_CANCEL, "cancel", N_("Cancel"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_LEFT_MOUSE_CLICK, "leftmouseclick", N_("Left Mouse Click"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_RIGHT_MOUSE_CLICK, "rightmouseclick", N_("Right Mouse Click"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_ANIMATE_MAP, "animatemap", N_("Animate Map"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_CYCLE_UNITS, "cycle", N_("Next Unit"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CYCLE_BACK_UNITS, "cycleback", N_("Previous Unit"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UNIT_HOLD_POSITION, "holdposition", N_("Hold Position"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_END_UNIT_TURN, "endunitturn", N_("End Unit Turn"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_LEADER, "leader", N_("Leader"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UNDO, "undo", N_("Undo"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_REDO, "redo", N_("Redo"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_ZOOM_IN, "zoomin", N_("Zoom In"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_ZOOM_OUT, "zoomout", N_("Zoom Out"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_ZOOM_DEFAULT, "zoomdefault", N_("Default Zoom"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_FULLSCREEN, "fullscreen", N_("Toggle Full Screen"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_SCREENSHOT, "screenshot", N_("Screenshot"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_MAP_SCREENSHOT, "mapscreenshot", N_("Map Screenshot"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_ACCELERATED, "accelerated", N_("Accelerated"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UNIT_DESCRIPTION, "describeunit", N_("Unit Description"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_RENAME_UNIT, "renameunit", N_("Rename Unit"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_DELETE_UNIT, "editor-deleteunit", N_("Delete Unit"), false, hotkey::SCOPE_GENERAL, NULL },
hotkey_command_temp hotkey_list_[] = {
{ hotkey::HOTKEY_SAVE_GAME, "save", N_("Save Game"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SAVE_REPLAY, "savereplay", N_("Save Replay"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SAVE_MAP, "savemap", N_("Save Map"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_LOAD_GAME, "load", N_("Load Game"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_RECRUIT, "recruit", N_("Recruit"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPEAT_RECRUIT, "repeatrecruit", N_("Repeat Recruit"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_RECALL, "recall", N_("Recall"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_ENDTURN, "endturn", N_("End Turn"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_TOGGLE_ELLIPSES, "toggleellipses", N_("Toggle Ellipses"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_TOGGLE_GRID, "togglegrid", N_("Toggle Grid"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_MOUSE_SCROLL, "mousescroll", N_("Mouse Scrolling"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_STATUS_TABLE, "statustable", N_("Status Table"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_MUTE, "mute", N_("Mute"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_SPEAK, "speak", N_("Speak"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CREATE_UNIT, "createunit", N_("Create Unit (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CHANGE_SIDE, "changeside", N_("Change Side (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_KILL_UNIT, "killunit", N_("Kill Unit (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_PREFERENCES, "preferences", N_("Preferences"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_OBJECTIVES, "objectives", N_("Scenario Objectives"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UNIT_LIST, "unitlist", N_("Unit List"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_STATISTICS, "statistics", N_("Statistics"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_STOP_NETWORK, "stopnetwork", N_("Pause Network Game"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_START_NETWORK, "startnetwork", N_("Continue Network Game"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_QUIT_GAME, "quit", N_("Quit Game"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_QUIT_GAME, "quit-editor", N_("Quit Editor"), true, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_LABEL_TEAM_TERRAIN, "labelteamterrain", N_("Set Team Label"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_LABEL_TERRAIN, "labelterrain", N_("Set Label"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CLEAR_LABELS, "clearlabels", N_("Clear Labels"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SHOW_ENEMY_MOVES, "showenemymoves", N_("Show Enemy Moves"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_BEST_ENEMY_MOVES, "bestenemymoves", N_("Best Possible Enemy Moves"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_PLAY_REPLAY, "playreplay", N_("Play Replay"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_RESET_REPLAY, "resetreplay", N_("Reset Replay"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_STOP_REPLAY, "stopreplay", N_("Stop Replay"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_NEXT_TURN, "replaynextturn", N_("Next Turn"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_NEXT_SIDE, "replaynextside", N_("Next Side"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING, "replayshoweverything", N_("Full Map"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_SHOW_EACH, "replayshoweach", N_("Each Team"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_SHOW_TEAM1, "replayshowteam1", N_("Team 1"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_REPLAY_SKIP_ANIMATION, "replayskipanimation", N_("Skip Animation"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CANCEL, N_("cancel"), N_("Cancel"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_LEFT_MOUSE_CLICK, "leftmouseclick", N_("Left Mouse Click"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_RIGHT_MOUSE_CLICK, "rightmouseclick", N_("Right Mouse Click"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_ANIMATE_MAP, "animatemap", N_("Animate Map"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_CYCLE_UNITS, "cycle", N_("Next Unit"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CYCLE_BACK_UNITS, "cycleback", N_("Previous Unit"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_UNIT_HOLD_POSITION, "holdposition", N_("Hold Position"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_END_UNIT_TURN, "endunitturn", N_("End Unit Turn"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_LEADER, "leader", N_("Leader"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_UNDO, "undo", N_("Undo"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_REDO, "redo", N_("Redo"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_ZOOM_IN, "zoomin", N_("Zoom In"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_ZOOM_OUT, "zoomout", N_("Zoom Out"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_ZOOM_DEFAULT, "zoomdefault", N_("Default Zoom"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_FULLSCREEN, "fullscreen", N_("Toggle Full Screen"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_SCREENSHOT, "screenshot", N_("Screenshot"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_MAP_SCREENSHOT, "mapscreenshot", N_("Map Screenshot"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_ACCELERATED, "accelerated", N_("Accelerated"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_UNIT_DESCRIPTION, "describeunit", N_("Unit Description"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_RENAME_UNIT, "renameunit", N_("Rename Unit"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_DELETE_UNIT, "editor-deleteunit", N_("Delete Unit"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_SAVE_GAME, "save", N_("Save Game"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SAVE_REPLAY, "savereplay", N_("Save Replay"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SAVE_MAP, "savemap", N_("Save Map"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_LOAD_GAME, "load", N_("Load Game"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_RECRUIT, "recruit", N_("Recruit"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPEAT_RECRUIT, "repeatrecruit", N_("Repeat Recruit"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_RECALL, "recall", N_("Recall"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_ENDTURN, "endturn", N_("End Turn"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_TOGGLE_ELLIPSES, "toggleellipses", N_("Toggle Ellipses"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_TOGGLE_GRID, "togglegrid", N_("Toggle Grid"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_MOUSE_SCROLL, "mousescroll", N_("Mouse Scrolling"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_STATUS_TABLE, "statustable", N_("Status Table"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_MUTE, "mute", N_("Mute"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_SPEAK, "speak", N_("Speak"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CREATE_UNIT, "createunit", N_("Create Unit (Debug!)"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CHANGE_SIDE, "changeside", N_("Change Side (Debug!)"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_KILL_UNIT, "killunit", N_("Kill Unit (Debug!)"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_PREFERENCES, "preferences", N_("Preferences"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_OBJECTIVES, "objectives", N_("Scenario Objectives"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_UNIT_LIST, "unitlist", N_("Unit List"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_STATISTICS, "statistics", N_("Statistics"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_STOP_NETWORK, "stopnetwork", N_("Pause Network Game"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_START_NETWORK, "startnetwork", N_("Continue Network Game"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_QUIT_GAME, "quit", N_("Quit Game"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_QUIT_GAME, "quit-editor", N_("Quit Editor"), true, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_LABEL_TEAM_TERRAIN, "labelteamterrain", N_("Set Team Label"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_LABEL_TERRAIN, "labelterrain", N_("Set Label"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CLEAR_LABELS, "clearlabels", N_("Clear Labels"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SHOW_ENEMY_MOVES, "showenemymoves", N_("Show Enemy Moves"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_BEST_ENEMY_MOVES, "bestenemymoves", N_("Best Possible Enemy Moves"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_PLAY_REPLAY, "playreplay", N_("Play Replay"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_RESET_REPLAY, "resetreplay", N_("Reset Replay"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_STOP_REPLAY, "stopreplay", N_("Stop Replay"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_NEXT_TURN, "replaynextturn", N_("Next Turn"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_NEXT_SIDE, "replaynextside", N_("Next Side"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING, "replayshoweverything", N_("Full Map"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_SHOW_EACH, "replayshoweach", N_("Each Team"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_SHOW_TEAM1, "replayshowteam1", N_("Team 1"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_REPLAY_SKIP_ANIMATION, "replayskipanimation", N_("Skip Animation"), false, hotkey::SCOPE_GAME, "" },
// Whiteboard commands
// TRANSLATORS: whiteboard menu entry: toggle planning mode
{ hotkey::HOTKEY_WB_TOGGLE, "wbtoggle", N_("whiteboard^Planning Mode"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_TOGGLE, "wbtoggle", N_("whiteboard^Planning Mode"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: execute planned action
{ hotkey::HOTKEY_WB_EXECUTE_ACTION, "wbexecuteaction", N_("whiteboard^Execute Action"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_EXECUTE_ACTION, "wbexecuteaction", N_("whiteboard^Execute Action"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: execute all planned actions
{ hotkey::HOTKEY_WB_EXECUTE_ALL_ACTIONS, "wbexecuteallactions", N_("whiteboard^Execute All Actions"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_EXECUTE_ALL_ACTIONS, "wbexecuteallactions", N_("whiteboard^Execute All Actions"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: delete planned action
{ hotkey::HOTKEY_WB_DELETE_ACTION, "wbdeleteaction", N_("whiteboard^Delete Action"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_DELETE_ACTION, "wbdeleteaction", N_("whiteboard^Delete Action"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: move planned action up queue
{ hotkey::HOTKEY_WB_BUMP_UP_ACTION, "wbbumpupaction", N_("whiteboard^Move Action Up"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_BUMP_UP_ACTION, "wbbumpupaction", N_("whiteboard^Move Action Up"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: move planned action down queue
{ hotkey::HOTKEY_WB_BUMP_DOWN_ACTION, "wbbumpdownaction", N_("whiteboard^Move Action Down"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_BUMP_DOWN_ACTION, "wbbumpdownaction", N_("whiteboard^Move Action Down"), false, hotkey::SCOPE_GAME, "" },
// TRANSLATORS: whiteboard menu entry: plan as though the chosen unit were dead
{ hotkey::HOTKEY_WB_SUPPOSE_DEAD, "wbsupposedead", N_("whiteboard^Suppose Dead"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_WB_SUPPOSE_DEAD, "wbsupposedead", N_("whiteboard^Suppose Dead"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_EDITOR_QUIT_TO_DESKTOP, "editor-quit-to-desktop", N_("Quit to Desktop"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CLOSE_MAP, "editor-close-map", N_("Close Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SWITCH_MAP, "editor-switch-map", N_("Switch Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SWITCH_AREA, "editor-switch-area", N_("Switch Area"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_QUIT_TO_DESKTOP, "editor-quit-to-desktop", N_("Quit to Desktop"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CLOSE_MAP, "editor-close-map", N_("Close Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SWITCH_MAP, "editor-switch-map", N_("Switch Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SWITCH_AREA, "editor-switch-area", N_("Switch Area"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CUSTOM_TODS, "editor-custom-tods", N_("Custom Time of Day Creator"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PARTIAL_UNDO, "editor-partial-undo", N_("Partial Undo"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_NEW, "editor-map-new", N_("New Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_LOAD, "editor-map-load", N_("Load Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE, "editor-map-save", N_("Save Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE_AS, "editor-map-save-as", N_("Save Map As"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE_ALL, "editor-map-save-all", N_("Save All Maps"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_REVERT, "editor-map-revert", N_("Revert All Changes"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_INFO, "editor-map-info", N_("Map Information"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SIDE_NEW, "editor-side-new", N_("Add New Side"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SIDE_SWITCH, "editor-switch-side", N_("Switch Side"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PALETTE_ITEM_SWAP, "editor-terrain-palette-swap", N_("Swap Foreground/Background Palette Item"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PALETTE_GROUPS, "editor-palette-groups", N_("Change Palette Group"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PALETTE_UPSCROLL, "editor-palette-upscroll", N_("Scroll Palette Left"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PALETTE_DOWNSCROLL, "editor-palette-downscroll", N_("Scroll Palette Right"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CUSTOM_TODS, "editor-custom-tods", N_("Custom Time of Day Creator"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PARTIAL_UNDO, "editor-partial-undo", N_("Partial Undo"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_NEW, "editor-map-new", N_("New Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_LOAD, "editor-map-load", N_("Load Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE, "editor-map-save", N_("Save Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE_AS, "editor-map-save-as", N_("Save Map As"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_SAVE_ALL, "editor-map-save-all", N_("Save All Maps"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_REVERT, "editor-map-revert", N_("Revert All Changes"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_INFO, "editor-map-info", N_("Map Information"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SIDE_NEW, "editor-side-new", N_("Add New Side"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SIDE_SWITCH, "editor-switch-side", N_("Switch Side"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PALETTE_ITEM_SWAP, "editor-terrain-palette-swap", N_("Swap Foreground/Background Palette Item"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PALETTE_GROUPS, "editor-palette-groups", N_("Change Palette Group"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PALETTE_UPSCROLL, "editor-palette-upscroll", N_("Scroll Palette Left"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PALETTE_DOWNSCROLL, "editor-palette-downscroll", N_("Scroll Palette Right"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SWITCH_TIME, "editor-switch-time", N_("Switch Time of Day"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SWITCH_TIME, "editor-switch-time", N_("Switch Time of Day"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_TOOL_NEXT, "editor-tool-next", N_("Next Tool"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_TOOL_NEXT, "editor-tool-next", N_("Next Tool"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_TOOL_PAINT, "editor-tool-paint", N_("Paint Tool"), false, hotkey::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.") },
{ hotkey::HOTKEY_EDITOR_TOOL_FILL, "editor-tool-fill", N_("Fill Tool"), false, hotkey::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.") },
@ -180,86 +189,91 @@ const hotkey_command hotkey_list_[] = {
{ hotkey::HOTKEY_EDITOR_UNIT_TOGGLE_CANRECRUIT, "editor-toggle-canrecruit", N_("Canrecruit"), false, hotkey::SCOPE_EDITOR, N_("Toggle the recruit attribute of a unit.") },
{ hotkey::HOTKEY_EDITOR_UNIT_TOGGLE_RENAMEABLE, "editor-toggle-renameable", N_("Can be renamed"), false, hotkey::SCOPE_EDITOR, N_("Toggle the unit being renameable.") },
{ hotkey::HOTKEY_EDITOR_UNIT_CHANGE_ID, "editor-change-unitid", N_("Change Unit ID"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL, "editor-unit-toggle-loyal", N_("Loyal"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_UNIT_CHANGE_ID, "editor-change-unitid", N_("Change Unit ID"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL, "editor-unit-toggle-loyal", N_("Loyal"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_MINIMAP_COLOR_CODING, "minimap-color-coding", N_("Toggle Minimap color coding"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_MINIMAP_COLOR_CODING, "minimap-color-coding", N_("Toggle Minimap color coding"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_NEXT, "editor-brush-next", N_("Next Brush"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_DEFAULT, "editor-brush-default", N_("Default Brush"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_1, "editor-brush-1", N_("Single Tile"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_2, "editor-brush-2", N_("Radius One"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_3, "editor-brush-3", N_("Radius Two"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_NW_SE, "editor-brush-nw-se", N_("Brush NW-SE"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_SW_NE, "editor-brush-sw-ne", N_("Brush SW-NE"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CUT, "editor-cut", N_("Cut"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_COPY, "editor-copy", N_("Copy"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_BRUSH_NEXT, "editor-brush-next", N_("Next Brush"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_DEFAULT, "editor-brush-default", N_("Default Brush"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_1, "editor-brush-1", N_("Single Tile"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_2, "editor-brush-2", N_("Radius One"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_3, "editor-brush-3", N_("Radius Two"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_NW_SE, "editor-brush-nw-se", N_("Brush NW-SE"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_BRUSH_SW_NE, "editor-brush-sw-ne", N_("Brush SW-NE"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CUT, "editor-cut", N_("Cut"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_COPY, "editor-copy", N_("Copy"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PASTE, "editor-paste", N_("Paste"), false, hotkey::SCOPE_EDITOR, N_("Left mouse button pastes from the clipboard, right brings up a context menu.") },
{ hotkey::HOTKEY_EDITOR_EXPORT_SELECTION_COORDS, "editor-export-selection-coords", N_("Export Selected Coordinates to System Clipboard"), true, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECT_ALL, "editor-select-all", N_("Select All"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECT_INVERSE, "editor-select-inverse", N_("Select Inverse"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECT_NONE, "editor-select-none", N_("Select None"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW, "editor-clipboard-rotate-cw", N_("Rotate Clipboard Clockwise"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW, "editor-clipboard-rotate-ccw", N_("Rotate Clipboard Counter-Clockwise"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL, "editor-clipboard-flip-horizontal", N_("Flip Clipboard Horizontally"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL, "editor-clipboard-flip-vertical", N_("Flip Clipboard Vertically"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECTION_ROTATE, "editor-selection-rotate", N_("Rotate Selection"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECTION_FLIP, "editor-selection-flip", N_("Flip Selection"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECTION_FILL, "editor-selection-fill", N_("Fill Selection"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECTION_GENERATE, "editor-selection-generate", N_("Generate Tiles In Selection"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_SELECTION_RANDOMIZE, "editor-selection-randomize", N_("Randomize Tiles In Selection"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_RESIZE, "editor-map-resize", N_("Resize Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_ROTATE, "editor-map-rotate", N_("Rotate Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_GENERATE, "editor-map-generate", N_("Generate Map"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_APPLY_MASK, "editor-map-apply-mask", N_("Apply a Mask"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_MAP_CREATE_MASK_TO, "editor-map-create-mask-to", N_("Create Mask"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_REFRESH, "editor-refresh", N_("Refresh Display"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_UPDATE_TRANSITIONS, "editor-update-transitions", N_("Update Terrain Transitions"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_EXPORT_SELECTION_COORDS, "editor-export-selection-coords", N_("Export Selected Coordinates to System Clipboard"), true, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECT_ALL, "editor-select-all", N_("Select All"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECT_INVERSE, "editor-select-inverse", N_("Select Inverse"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECT_NONE, "editor-select-none", N_("Select None"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW, "editor-clipboard-rotate-cw", N_("Rotate Clipboard Clockwise"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW, "editor-clipboard-rotate-ccw", N_("Rotate Clipboard Counter-Clockwise"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL, "editor-clipboard-flip-horizontal", N_("Flip Clipboard Horizontally"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL, "editor-clipboard-flip-vertical", N_("Flip Clipboard Vertically"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECTION_ROTATE, "editor-selection-rotate", N_("Rotate Selection"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECTION_FLIP, "editor-selection-flip", N_("Flip Selection"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECTION_FILL, "editor-selection-fill", N_("Fill Selection"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECTION_GENERATE, "editor-selection-generate", N_("Generate Tiles In Selection"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_SELECTION_RANDOMIZE, "editor-selection-randomize", N_("Randomize Tiles In Selection"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_RESIZE, "editor-map-resize", N_("Resize Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_ROTATE, "editor-map-rotate", N_("Rotate Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_GENERATE, "editor-map-generate", N_("Generate Map"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_APPLY_MASK, "editor-map-apply-mask", N_("Apply a Mask"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_MAP_CREATE_MASK_TO, "editor-map-create-mask-to", N_("Create Mask"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_REFRESH, "editor-refresh", N_("Refresh Display"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_UPDATE_TRANSITIONS, "editor-update-transitions", N_("Update Terrain Transitions"), false, hotkey::SCOPE_EDITOR, "" },
// This item is for binding in the preferences
{ hotkey::HOTKEY_EDITOR_TOGGLE_TRANSITIONS, "editor-toggle-transitions", N_("Toggle Terrain Transition Update"), true, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS, "editor-auto-update-transitions", N_("Auto-update Terrain Transitions"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_TOGGLE_TRANSITIONS, "editor-toggle-transitions", N_("Toggle Terrain Transition Update"), true, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS, "editor-auto-update-transitions", N_("Auto-update Terrain Transitions"), false, hotkey::SCOPE_EDITOR, "" },
// The next three are for displaying the different states in the menu
{ hotkey::HOTKEY_EDITOR_NO_UPDATE_TRANSITIONS, "editor-no-update-transitions", N_("Auto-update Terrain Transitions: No"), true, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_PARTIAL_UPDATE_TRANSITIONS, "editor-partial-update-transitions", N_("Auto-update Terrain Transitions: Partial"), true, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_NO_UPDATE_TRANSITIONS, "editor-no-update-transitions", N_("Auto-update Terrain Transitions: No"), true, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_PARTIAL_UPDATE_TRANSITIONS, "editor-partial-update-transitions", N_("Auto-update Terrain Transitions: Partial"), true, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, "editor-refresh-image-cache", N_("Refresh Image Cache"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_DRAW_COORDINATES, "editor-draw-coordinates", N_("Draw Hex Coordinates"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_DRAW_TERRAIN_CODES, "editor-draw-terrain-codes", N_("Draw Terrain Codes"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, "editor-refresh-image-cache", N_("Refresh Image Cache"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_DRAW_COORDINATES, "editor-draw-coordinates", N_("Draw Hex Coordinates"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_DRAW_TERRAIN_CODES, "editor-draw-terrain-codes", N_("Draw Terrain Codes"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_EDITOR_AREA_DEFINE, "editor-define-area", N_("Define (Time) Area"), false, hotkey::SCOPE_EDITOR, NULL },
{ hotkey::HOTKEY_EDITOR_AREA_DEFINE, "editor-define-area", N_("Define (Time) Area"), false, hotkey::SCOPE_EDITOR, "" },
{ hotkey::HOTKEY_DELAY_SHROUD, "delayshroud", N_("Delay Shroud Updates"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UPDATE_SHROUD, "updateshroud", N_("Update Shroud Now"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CONTINUE_MOVE, "continue", N_("Continue Move"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SEARCH, "search", N_("Find Label or Unit"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SPEAK_ALLY, "speaktoally", N_("Speak to Ally"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_SPEAK_ALL, "speaktoall", N_("Speak to All"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_HELP, "help", N_("Help"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_CHAT_LOG, "chatlog", N_("View Chat Log"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_LANGUAGE, "changelanguage", N_("Change Language"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_USER_CMD, "command", N_("Enter User Command"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_CUSTOM_CMD, "customcommand", N_("Custom Command"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_AI_FORMULA, "aiformula", N_("Run Formula"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CLEAR_MSG, "clearmessages", N_("Clear Messages"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::TITLE_SCREEN__RELOAD_WML, "title_screen__reload_wml", N_("Refresh WML"), true ,hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__NEXT_TIP, "title_screen__next_tip", N_("Next Tip of the Day"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__PREVIOUS_TIP, "title_screen__previous_tip", N_("Previous Tip of the Day"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__TUTORIAL, "title_screen__tutorial", N_("Start Tutorial"), false , hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__CAMPAIGN, "title_screen__campaign", N_("Start Campaign"), false , hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__MULTIPLAYER, "title_screen__multiplayer", N_("Start Multiplayer Game"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__ADDONS, "title_screen__addons", N_("Manage Add-ons"), false , hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__EDITOR, "title_screen__editor", N_("Start Editor"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::TITLE_SCREEN__CREDITS, "title_screen__credits", N_("Show Credits"), false , hotkey::SCOPE_GENERAL, NULL },
{ hotkey::GLOBAL__HELPTIP, "global__helptip", N_("Show Helptip"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_DELAY_SHROUD, "delayshroud", N_("Delay Shroud Updates"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_UPDATE_SHROUD, "updateshroud", N_("Update Shroud Now"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CONTINUE_MOVE, "continue", N_("Continue Move"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SEARCH, "search", N_("Find Label or Unit"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SPEAK_ALLY, "speaktoally", N_("Speak to Ally"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_SPEAK_ALL, "speaktoall", N_("Speak to All"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_HELP, "help", N_("Help"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_CHAT_LOG, "chatlog", N_("View Chat Log"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_LANGUAGE, "changelanguage", N_("Change Language"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_USER_CMD, "command", N_("Enter User Command"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::HOTKEY_CUSTOM_CMD, "customcommand", N_("Custom Command"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_AI_FORMULA, "aiformula", N_("Run Formula"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::HOTKEY_CLEAR_MSG, "clearmessages", N_("Clear Messages"), false, hotkey::SCOPE_GAME, "" },
{ hotkey::TITLE_SCREEN__RELOAD_WML, "title_screen__reload_wml", N_("Refresh WML"), true ,hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__NEXT_TIP, "title_screen__next_tip", N_("Next Tip of the Day"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__PREVIOUS_TIP, "title_screen__previous_tip", N_("Previous Tip of the Day"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__TUTORIAL, "title_screen__tutorial", N_("Start Tutorial"), false , hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__CAMPAIGN, "title_screen__campaign", N_("Start Campaign"), false , hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__MULTIPLAYER, "title_screen__multiplayer", N_("Start Multiplayer Game"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__ADDONS, "title_screen__addons", N_("Manage Add-ons"), false , hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__EDITOR, "title_screen__editor", N_("Start Editor"), false, hotkey::SCOPE_GENERAL, "" },
{ hotkey::TITLE_SCREEN__CREDITS, "title_screen__credits", N_("Show Credits"), false , hotkey::SCOPE_GENERAL, "" },
{ hotkey::GLOBAL__HELPTIP, "global__helptip", N_("Show Helptip"), false, hotkey::SCOPE_GENERAL, "" },
//This list item must stay at the end since it is used as terminator for iterating.
{ hotkey::HOTKEY_NULL, "null", N_("Unrecognized Command"), true, hotkey::SCOPE_GENERAL, NULL }
{ hotkey::HOTKEY_NULL, "null", N_("Unrecognized Command"), true, hotkey::SCOPE_GENERAL, "" }
};
const hotkey_command* get_hotkey_commands() {
return hotkey_list_;
#pragma endregion
const boost::ptr_vector<hotkey_command>& get_hotkey_commands()
{
int i = 9;
return known_hotkeys;
}
void deactivate_all_scopes()
{
for (int i = 0; i < hotkey::SCOPE_COUNT; ++i) {
@ -282,18 +296,33 @@ static void jbutton_event_execute(display& disp, const SDL_JoyButtonEvent& event
static void jhat_event_execute(display& disp, const SDL_JoyHatEvent& event, command_executor* executor);
static void mbutton_event_execute(display& disp, const SDL_MouseButtonEvent& event, command_executor* executor);
const std::string CLEARED_TEXT = "__none__";
scope hotkey_item::get_scope() const {
return hotkey_list_[command_map_[get_command()]].scope;
scope hotkey_item::get_scope() const
{
return hotkey::get_hotkey_command(get_command()).scope;
}
HOTKEY_COMMAND hotkey_item::get_id() const {
return hotkey_list_[command_map_[get_command()]].id;
HOTKEY_COMMAND hotkey_item::get_id() const
{
return hotkey::get_id(get_command());
}
const std::string hotkey_item::get_description() const {
hotkey_command& hotkey_item::get_hotkey_command() const
{
return hotkey::get_hotkey_command(get_command());
}
bool hotkey_item::active() const
{
return !(command_ == "null" || get_hotkey_command().command == "null");
}
bool hotkey_item::valid() const
{
return (character_ | keycode_ | joystick_ | mouse_ | button_ | hat_ | value_) != 0;
}
const std::string hotkey_item::get_description() const
{
return hotkey::get_description(get_command());
}
@ -376,7 +405,6 @@ void hotkey_item::set_command(const std::string& command) {
command_ = command;
}
std::string hotkey_item::get_name() const
{
std::stringstream str;
@ -436,7 +464,6 @@ void hotkey_item::clear()
command_ = "null";
}
void hotkey_item::save(config& item)
{
if (get_button() >= 0) item["button"] = get_button();
@ -537,16 +564,42 @@ manager::manager()
void manager::init()
{
size_t i;
for (i = 0; hotkey_list_[i].id != hotkey::HOTKEY_NULL; ++i) {
command_map_[hotkey_list_[i].command] = i;
}
//size_t i;
//for (i = 0; hotkey_list_[i].id != hotkey::HOTKEY_NULL; ++i) {
// command_map_[hotkey_list_[i].command] = i;
//}
//TODO find a clever way to extend the loop and remove the next line.
command_map_[hotkey_list_[i].command] = i;
//command_map_[hotkey_list_[i].command] = i;
//the size value is just random set.
boost::ptr_vector<hotkey_command> known_hotkeys_temp(200);
known_hotkeys = known_hotkeys_temp;
size_t i = 0;
BOOST_FOREACH(hotkey_command_temp& cmd, hotkey_list_)
{
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")));
command_map_[cmd.command] = i;
i++;
}
}
void manager::wipe()
{
delete_all_wml_hotkeys();
/* not needed anymore
while(!known_hotkeys.empty())
{
if(known_hotkeys.begin()->id == HOTKEY_WML)
{
ERR_G << "a wml menu hotkey wasn't correct deleted";
}
//these are pointers to hotkey_list_. The destructor of known_hotkeys would try to delete them.
//hotkey_command* ptr =
known_hotkeys.release(known_hotkeys.begin()).release();
}
*/
hotkeys_.clear();
command_map_.clear();
}
@ -615,30 +668,146 @@ void save_hotkeys(config& cfg)
}
const std::string get_description(const std::string& command) {
std::string tmp(command);
if (command_map_.find(tmp) == command_map_.end()) {
tmp = "null";
}
return t_string(hotkey_list_[command_map_[tmp]].description,
PACKAGE "-lib");
//std::string tmp(command);
//if (command_map_.find(tmp) == command_map_.end()) {
// tmp = "null";
//}
return get_hotkey_command(command).description;
}
const std::string get_tooltip(const std::string& command) {
if (command_map_.find(command) == command_map_.end()) {
return std::string();
}
if (hotkey_list_[command_map_[command]].tooltip != NULL)
return t_string(hotkey_list_[command_map_[command]].tooltip,
PACKAGE "-lib");
else return std::string();
const std::string get_tooltip(const std::string& command)
{
// the null hotkey_command has the "" tooltip
return get_hotkey_command(command).tooltip;
}
HOTKEY_COMMAND get_id(const std::string& command) {
if (command_map_.find(command) == command_map_.end()) {
return HOTKEY_NULL;
bool hotkey_command::null() const
{
if(id == HOTKEY_NULL || command == "null")
{
hotkey_command& null_cmd = null_command();
if(id == null_cmd.id && command == null_cmd.command && scope == null_cmd.scope && description == null_cmd.description)
return true;
else
{
ERR_G << "the hotkey command seems to be the null command but it is not 100% sure. This shouldn't happen";
return true;
}
}
return false;
}
hotkey_command::hotkey_command()
: id(HOTKEY_NULL), command(""), description(""), hidden(true), scope(SCOPE_GENERAL), tooltip("")
{
ERR_G << "hotkey_command's default constructor called. This shouldn't happen, because all its members are const.";
}
hotkey_command::hotkey_command(hotkey::HOTKEY_COMMAND cmd, const std::string& id_, const t_string& desc, bool hid, hotkey::scope scop, const t_string& toolt)
: id(cmd), command(id_), description(desc), hidden(hid), scope(scop), tooltip(toolt)
{
}
hotkey_command& hotkey_command::null_command()
{
return get_hotkey_null();
}
hotkey_command& hotkey_command::get_command_by_command(hotkey::HOTKEY_COMMAND command)
{
BOOST_FOREACH(hotkey_command& cmd, known_hotkeys)
{
if(cmd.id == command)
return cmd;
}
ERR_G << " \"get_command_by_command\" returned get_hotkey_null() because no hotkey_command had the requested number:" << command;
return get_hotkey_null();
}
hotkey_command& get_hotkey_null()
{
//it is the last entry in that array, and the indexes in hotkey_list_ and known_hotkeys are the same.
return known_hotkeys[sizeof(hotkey_list_) / sizeof(hotkey_list_[0]) - 1];
}
bool has_hotkey_command(const std::string& id)
{
return get_hotkey_command(id).id != hotkey::HOTKEY_NULL;
}
bool has_hotkey_item(const std::string& command)
{
BOOST_FOREACH(hotkey_item& item, hotkeys_)
{
if(item.get_command() == command)
return true;
}
return false;
}
void delete_all_wml_hotkeys()
{
while(known_hotkeys.back().id == hotkey::HOTKEY_WML)
{
command_map_.erase(known_hotkeys.back().command);
//according to some page in the internet .back() returns a reference not an iterator, so i use this.
boost::ptr_vector<hotkey_command>::iterator last_element = known_hotkeys.end();
--last_element;
//boost::ptr_vector<hotkey_command> will manage the deleting of the object for me.
known_hotkeys.erase(last_element);
}
}
void add_wml_hotkey(const std::string& id, const t_string& description, const config& default_hotkey)
{
if(has_hotkey_command(id) || id == "null")
{
LOG_G << "coudn't add wml hotkey with id=" + id + " and description" + description.base_str();
return;
}
else
{
DBG_G << "added wml hotkey with id=" + id + " and description" + description.base_str();
//i think i dont need the temp anymore.
hotkey_command temp_command(hotkey::HOTKEY_WML, id, description, false, hotkey::SCOPE_GAME, t_string(""));
known_hotkeys.push_back(new hotkey_command(temp_command));
command_map_[id] = known_hotkeys.size() - 1;
if(!default_hotkey.empty() && !has_hotkey_item(id))
{
hotkey_item new_item(default_hotkey);
new_item.set_command(id);
if(new_item.valid())
{
DBG_G << "added default description for the wml hotkey with id=" + id;
add_hotkey(new_item);
}
else
{
ERR_CF << "failed to add default hotkey with id=" + id;
}
}
}
}
/// returns hotkey_commands the hotkey command with the given identifier.
hotkey_command& get_hotkey_command(const std::string& command)
{
if (command_map_.find(command) == command_map_.end())
{
return get_hotkey_null();
}
return hotkey_list_[command_map_[command]].id;
return known_hotkeys[command_map_[command]];
}
HOTKEY_COMMAND get_id(const std::string& command)
{
return get_hotkey_command(command).id;
}
std::string get_names(HOTKEY_COMMAND id) {
@ -666,14 +835,6 @@ std::string get_names(std::string id) {
}
HOTKEY_COMMAND get_hotkey_command(const std::string& command)
{
if (command_map_.find(command) != command_map_.end()) {
return HOTKEY_NULL;
}
return hotkey_list_[command_map_[command]].id;
}
hotkey_item& get_hotkey(int mouse, int joystick, int button, int hat, int value,
bool shift, bool ctrl, bool cmd, bool alt)
@ -682,7 +843,7 @@ hotkey_item& get_hotkey(int mouse, int joystick, int button, int hat, int value,
for (itor = hotkeys_.begin(); itor != hotkeys_.end(); ++itor) {
if (!(itor->is_in_active_scope())) {
if (!(itor->is_in_active_scope() && itor->active())) {
continue;
}
@ -737,7 +898,7 @@ hotkey_item& get_hotkey(int character, int keycode,
if (ctrl == itor->get_ctrl()
&& cmd == itor->get_cmd()
&& alt == itor->get_alt()) {
if (itor->is_in_active_scope()) {
if (itor->is_in_active_scope() && itor->active()) {
DBG_G << "Could match by character..." << "yes\n";
found = true;
break;
@ -753,7 +914,7 @@ hotkey_item& get_hotkey(int character, int keycode,
&& ctrl == itor->get_ctrl()
&& cmd == itor->get_cmd()
&& alt == itor->get_alt()) {
if (itor->is_in_active_scope()) {
if (itor->is_in_active_scope() && itor->active()) {
DBG_G << "Could match by keycode..." << "yes\n";
found = true;
break;
@ -868,7 +1029,6 @@ void mbutton_event(display& disp, const SDL_MouseButtonEvent& event, command_exe
mbutton_event_execute(disp, event, executor);
}
void jbutton_event(display& disp, const SDL_JoyButtonEvent& event, command_executor* executor)
{
jbutton_event_execute(disp, event, executor);
@ -898,37 +1058,36 @@ void key_event(display& disp, const SDL_KeyboardEvent& event, command_executor*
void mbutton_event_execute(display& disp, const SDL_MouseButtonEvent& event, command_executor* executor)
{
const hotkey_item* hk = &get_hotkey(event);
if (hk->null()) {
if (!hk->active()) {
return;
}
execute_command(disp, hk->get_id(), executor);
execute_command(disp, hotkey::get_hotkey_command(hk->get_command()), executor);
executor->set_button_state(disp);
}
void jbutton_event_execute(display& disp, const SDL_JoyButtonEvent& event, command_executor* executor)
{
const hotkey_item* hk = &get_hotkey(event);
if (hk->null()) {
if (!hk->active()) {
return;
}
execute_command(disp, hk->get_id(), executor);
execute_command(disp, hk->get_hotkey_command(), executor);
executor->set_button_state(disp);
}
void jhat_event_execute(display& disp, const SDL_JoyHatEvent& event, command_executor* executor)
{
const hotkey_item* hk = &get_hotkey(event);
if (hk->null()) {
if (!hk->active()) {
return;
}
execute_command(disp, hk->get_id(), executor);
execute_command(disp, hk->get_hotkey_command(), executor);
executor->set_button_state(disp);
}
void key_event_execute(display& disp, const SDL_KeyboardEvent& event, command_executor* executor)
{
const hotkey_item* hk = &get_hotkey(event);
@ -941,17 +1100,17 @@ void key_event_execute(display& disp, const SDL_KeyboardEvent& event, command_ex
}
#endif
if (hk->null()) {
if (!hk->active()) {
return;
}
execute_command(disp, hk->get_id(), executor);
execute_command(disp, hk->get_hotkey_command(), executor);
executor->set_button_state(disp);
}
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
bool command_executor::execute_command(const hotkey_command& cmd, int /*index*/)
{
switch(command) {
switch(cmd.id) {
case HOTKEY_CYCLE_UNITS:
cycle_units();
break;
@ -1156,7 +1315,7 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
return true;
}
void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* executor, int index)
void execute_command(display& disp, hotkey_command& command, command_executor* executor, int index)
{
const int zoom_amount = 4;
bool map_screenshot = false;
@ -1167,7 +1326,7 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
return;
}
}
switch (command) {
switch (command.id) {
case HOTKEY_MINIMAP_COLOR_CODING:
preferences::toggle_minimap_color_coding();
disp.redraw_minimap();
@ -1249,7 +1408,7 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
break;
}
default:
DBG_G << "command_executor: unknown command number " << command << ", ignoring.\n";
DBG_G << "command_executor: unknown command number " << command.id << ", ignoring.\n";
break;
}
}
@ -1263,19 +1422,19 @@ void command_executor::set_button_state(display& disp) {
int i = 0;
BOOST_FOREACH(const std::string& command, action.items()) {
hotkey::HOTKEY_COMMAND command_id = hotkey::get_id(command);
hotkey::hotkey_command& command_obj = hotkey::get_hotkey_command(command);
std::string tooltip = action.tooltip(i);
if (file_exists(game_config::path + "/images/icons/action/" + command + "_30.png" ))
button->set_overlay("icons/action/" + command);
if (!tooltip.empty())
button->set_tooltip_string(tooltip);
bool can_execute = can_execute_command(command_id);
bool can_execute = can_execute_command(command_obj);
i++;
if (!can_execute) continue;
enabled = true;
ACTION_STATE state = get_action_state(command_id, -1);
ACTION_STATE state = get_action_state(command_obj.id, -1);
switch (state) {
case ACTION_SELECTED:
case ACTION_ON:
@ -1318,7 +1477,7 @@ void command_executor::show_menu(const std::vector<std::string>& items_arg, int
SDL_GetMouseState(&x,&y);
this->show_menu(submenu->items(), x, y, submenu->is_context(), gui);
} else {
const hotkey::HOTKEY_COMMAND cmd = hotkey::get_id(items[res]);
hotkey::hotkey_command& cmd = hotkey::get_hotkey_command(items[res]);
hotkey::execute_command(gui,cmd,this,res);
set_button_state(gui);
}
@ -1331,10 +1490,9 @@ void command_executor::execute_action(const std::vector<std::string>& items_arg,
return;
}
hotkey::HOTKEY_COMMAND command;
std::vector<std::string>::iterator i = items.begin();
while(i != items.end()) {
command = hotkey::get_id(*i);
hotkey_command &command = hotkey::get_hotkey_command(*i);
if (can_execute_command(command)) {
hotkey::execute_command(gui, command, this);
set_button_state(gui);

View File

@ -16,6 +16,7 @@
#include "events.hpp"
#include "tstring.hpp"
#include <boost/ptr_container/ptr_vector.hpp>
class config;
class display;
@ -141,6 +142,8 @@ enum HOTKEY_COMMAND {
TITLE_SCREEN__CREDITS,
GLOBAL__HELPTIP,
HOTKEY_WML,
HOTKEY_NULL
};
@ -158,23 +161,58 @@ struct input_controll {
hotkey::scope scope;
};
/// Stores all static information related to hotkey functions.
/// Stores all information related to functions that can be bound to hotkeys.
/// this is currently a semi struct: it haves a constructor, but only const-public members.
struct hotkey_command {
public:
/// the compiler want me to make a default constructor
/// since most member are const, calling the default contructor is normaly no use.
hotkey_command();
hotkey_command(hotkey::HOTKEY_COMMAND cmd, const std::string& id, const t_string& desc, bool hidden, hotkey::scope scope, const t_string& tooltip);
/// the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identyfy the object is called "command"
/// there is some unconsitency with that names in this file.
/// This binds the command to a function. Does not need to be unique.
hotkey::HOTKEY_COMMAND id;
const hotkey::HOTKEY_COMMAND id;
/// The command is unique.
const char* command;
/// note: The description is untranslated.
const char* description;
const std::string command;
// since the wml_menu hotkey_command s can have different textdomains we need t_string now.
const t_string description;
/// If hidden then don't show the command in the hotkey preferences.
bool hidden;
const bool hidden;
/// The visibility scope of the command.
const hotkey::scope scope;
const t_string tooltip;
/// checks weather this is the null hotkey_command
bool null() const;
/// returns the command that is treated as null
static hotkey_command& null_command();
/// the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command,
/// to be able to call it with HOTKEY_COMMAND, this function was created
static hotkey_command& get_command_by_command(HOTKEY_COMMAND command);
};
/// Do not use this ouside hotkeys.cpp.
/// hotkey_command uses t_string wich might cause bugs when used at progamm startup, so use this for the hotkey_list_ (and only there).
struct hotkey_command_temp {
hotkey::HOTKEY_COMMAND id;
const char* command;
/// description, tooltip are untranslated
const char* description;
bool hidden;
hotkey::scope scope;
///
const char* tooltip;
};
const hotkey_command* get_hotkey_commands();
/// returns a container that contains all currently active hotkey_commands.
/// everything that wants a hotkey, must be in this container.
const boost::ptr_vector<hotkey_command>& get_hotkey_commands();
class hotkey_item {
public:
@ -218,8 +256,16 @@ public:
std::string get_name() const;
void clear();
bool null() const { return command_ == "null"; };
/// retruns weather there is a associated hotkey_command.
// if the none of the hotkey_commands fits this hotkey_item then get_hotkey_command will return the hotkey_command::null_command().
bool active() const;
/// ckecks weather that hotkey "makes sense" meaning weather one of character, keycode, joystick, mouse, button, hat, value is set.
/// i dont know what the axis_.. values are so i ignore them.
bool valid() const;
void save(config& cfg);
@ -245,6 +291,8 @@ public:
HOTKEY_COMMAND get_id() const;
hotkey_command& get_hotkey_command() const;
void set_jbutton(int button, int joystick, bool shift, bool ctrl, bool cmd, bool alt);
void set_jhat(int joystick, int hat, int value, bool shift, bool ctrl, bool cmd, bool alt);
void set_key(int character, int keycode, bool shift, bool ctrl, bool cmd, bool alt);
@ -274,7 +322,8 @@ protected:
int axis_mouse;
};
/// this class is initialized once at gamestart
/// put all initialisation and wipe code in the methods here.
class manager {
public:
manager();
@ -295,13 +344,36 @@ void load_hotkeys(const config& cfg, bool set_as_default = false);
void reset_default_hotkeys();
void save_hotkeys(config& cfg);
//TODO they do the same?
/// returns get_hotkey_command(command).id
HOTKEY_COMMAND get_id(const std::string& command);
HOTKEY_COMMAND get_hotkey_command(const std::string& command);
/// returns the hotkey_command with the given name
hotkey_command& get_hotkey_command(const std::string& command);
const std::string get_description(const std::string& command);
const std::string get_tooltip(const std::string& command);
/// adds a new wml hotkey to the list, but only if there is no hotkey woth that id yet on the list.
/// the object that is created here will be deleted in "delete_all_wml_hotkeys()"
void add_wml_hotkey(const std::string& id, const t_string& description, const config& default_hotkey);
/// deletes all wml hotkeys, should be called after a game has ended
void delete_all_wml_hotkeys();
/// returns the hotkey_command that is treated as null.
hotkey_command& get_hotkey_null();
///
bool has_hotkey_command(const std::string& id);
/// inicated weather there is at least one hotkey_item with the given command
bool has_hotkey_item(const std::string& command);
/// hotkey::HOTKEY_COMMAND isn't doesnt identify a hotkey_command, consider passing a string
std::string get_names(hotkey::HOTKEY_COMMAND id);
/// returns all hotkey_item s that point to this, command in the form "A,Strg+M,F4"
/// used in the preferences menu
std::string get_names(std::string id);
void add_hotkey(const hotkey_item& item);
void clear_hotkeys(const std::string& command);
@ -393,6 +465,8 @@ public:
virtual void left_mouse_click() {}
virtual void right_mouse_click() {}
// execute_command's parameter is changed to "hotkey_command& command" and this not maybe that is too inconsitent.
// Gets the action's image (if any). Displayed left of the action text in menus.
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND /*command*/, int /*index*/) const { return ""; }
// Does the action control a toggle switch? If so, return the state of the action (on or off).
@ -410,8 +484,8 @@ public:
* \param command The command whose linked buttons are adjusted */
void set_button_state(display& disp);
virtual bool can_execute_command(HOTKEY_COMMAND command, int index=-1) const = 0;
virtual bool execute_command(HOTKEY_COMMAND command, int index=-1);
virtual bool can_execute_command(const hotkey_command& command, int index=-1) const = 0;
virtual bool execute_command(const hotkey_command& command, int index=-1);
};
/* Functions to be called every time a event is intercepted.
@ -425,7 +499,7 @@ void key_event(display& disp, const SDL_KeyboardEvent& event, command_executor*
void mbutton_event(display& disp, const SDL_MouseButtonEvent& event, command_executor* executor);
//TODO
void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* executor, int index=-1);
void execute_command(display& disp, hotkey_command& command, command_executor* executor, int index=-1);
// Object which will ensure that basic keyboard events like escape
// are handled properly for the duration of its lifetime.

View File

@ -799,9 +799,27 @@ bool play_controller::enemies_visible() const
return false;
}
bool play_controller::execute_command(hotkey::HOTKEY_COMMAND command, int index)
//used in play_controller::execute_command
void play_controller::fire_wml_menu_item_event(wml_menu_item* menu_item)
{
const events::command_disabler disable_commands;
if(gamedata_.last_selected.valid() && menu_item->needs_select)
{
recorder.add_event("select", gamedata_.last_selected);
}
map_location const& menu_hex = mouse_handler_.get_last_hex();
recorder.add_event(menu_item->name, menu_hex);
if(game_events::fire(menu_item->name, menu_hex))
{
// The event has mutated the gamestate
undo_stack_->clear();
}
}
bool play_controller::execute_command(const hotkey::hotkey_command& cmd, int index)
{
hotkey::HOTKEY_COMMAND command = cmd.id;
if(index >= 0) {
unsigned i = static_cast<unsigned>(index);
if(i < savenames_.size() && !savenames_[i].empty()) {
@ -809,24 +827,49 @@ bool play_controller::execute_command(hotkey::HOTKEY_COMMAND command, int index)
throw game::load_game_exception(savenames_[i],false,false,false,"");
} else if (i < wml_commands_.size() && wml_commands_[i] != NULL) {
const events::command_disabler disable_commands;
if(gamedata_.last_selected.valid() && wml_commands_[i]->needs_select) {
recorder.add_event("select", gamedata_.last_selected);
}
map_location const& menu_hex = mouse_handler_.get_last_hex();
recorder.add_event(wml_commands_[i]->name, menu_hex);
if(game_events::fire(wml_commands_[i]->name, menu_hex)) {
// The event has mutated the gamestate
undo_stack_->clear();
}
fire_wml_menu_item_event(wml_commands_[i]);
return true;
}
}
return command_executor::execute_command(command, index);
int prefixlen = wml_menu_hotkey_prefix.length();
if(command == hotkey::HOTKEY_WML && cmd.command.compare(0, prefixlen, wml_menu_hotkey_prefix) == 0)
{
std::string name = cmd.command.substr(prefixlen);
typedef std::map<std::string, wml_menu_item*> map_type;
map_type& gs_wmi = gamedata_.get_wml_menu_items().get_menu_items();
map_type::iterator iter = gs_wmi.find(name);
if(iter != gs_wmi.end())
{
//i think this is not needed, but i havent tested without yet.
if(name == iter->second->event_id)
{
//copied from expand_wml_commands
const map_location& hex = mouse_handler_.get_last_hex();
gamedata_.get_variable("x1") = hex.x + 1;
gamedata_.get_variable("y1") = hex.y + 1;
scoped_xy_unit highlighted_unit("unit", hex.x, hex.y, units_);
config& show_if = iter->second->show_if;
config filter_location = iter->second->filter_location;
if (iter->second->ignore_filter_on_hotkey || ((show_if.empty()
|| game_events::conditional_passed(vconfig(show_if)))
&& (filter_location.empty()
|| terrain_filter(vconfig(filter_location), units_)(hex))))
{
if((!iter->second->needs_select
|| gamedata_.last_selected.valid()))
{
fire_wml_menu_item_event(iter->second);
}
}
}
}
}
return command_executor::execute_command(cmd, index);
}
bool play_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
bool play_controller::can_execute_command(const hotkey::hotkey_command& cmd, int index) const
{
if(index >= 0) {
unsigned i = static_cast<unsigned>(index);
@ -835,7 +878,7 @@ bool play_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int in
return true;
}
}
switch(command) {
switch(cmd.id) {
// Commands we can always do:
case hotkey::HOTKEY_LEADER:
@ -1165,7 +1208,7 @@ void play_controller::expand_autosaves(std::vector<std::string>& items)
savenames_.push_back("");
}
}
///replaces "wml" in @items with all active wml menu items for the current field
void play_controller::expand_wml_commands(std::vector<std::string>& items)
{
wml_commands_.clear();
@ -1212,14 +1255,14 @@ void play_controller::expand_wml_commands(std::vector<std::string>& items)
void play_controller::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp)
{
std::vector<std::string> items = items_arg;
hotkey::HOTKEY_COMMAND command;
hotkey::hotkey_command* cmd;
std::vector<std::string>::iterator i = items.begin();
while(i != items.end()) {
if (*i == "AUTOSAVES") {
// Autosave visibility is similar to LOAD_GAME hotkey
command = hotkey::HOTKEY_LOAD_GAME;
cmd = &hotkey::hotkey_command::get_command_by_command(hotkey::HOTKEY_LOAD_GAME);
} else {
command = hotkey::get_id(*i);
cmd = &hotkey::get_hotkey_command(*i);
}
// Remove WML commands if they would not be allowed here
if(*i == "wml") {
@ -1230,8 +1273,8 @@ void play_controller::show_menu(const std::vector<std::string>& items_arg, int x
continue;
}
// Remove commands that can't be executed or don't belong in this type of menu
} else if(!can_execute_command(command)
|| (context_menu && !in_context_menu(command))) {
} else if(!can_execute_command(*cmd)
|| (context_menu && !in_context_menu(cmd->id))) {
i = items.erase(i);
continue;
}
@ -1419,6 +1462,10 @@ void play_controller::process_oos(const std::string& msg) const
save.save_game_interactive(resources::screen->video(), message.str(), gui::YES_NO); // can throw end_level_exception
}
//this should be at the end of the file but it caused merging probmes there.
const std::string play_controller::wml_menu_hotkey_prefix = "wml_menu:";
void play_controller::update_gui_to_player(const int team_index, const bool observe)
{
gui_->set_team(team_index, observe);

View File

@ -154,6 +154,7 @@ public:
events::menu_handler& get_menu_handler() { return menu_handler_; }
std::map< std::string, std::vector<unit_animation> > animation_cache;
static const std::string wml_menu_hotkey_prefix;
protected:
void slice_before_scroll();
@ -166,8 +167,8 @@ protected:
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int index) const;
virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const;
/** Check if a command can be executed. */
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual bool execute_command(hotkey::HOTKEY_COMMAND command, int index=-1);
virtual bool can_execute_command(const hotkey::hotkey_command& command, int index=-1) const;
virtual bool execute_command(const hotkey::hotkey_command& command, int index=-1);
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp);
/**
@ -259,6 +260,7 @@ private:
// Expand AUTOSAVES in the menu items, setting the real savenames.
void expand_autosaves(std::vector<std::string>& items);
std::vector<std::string> savenames_;
void fire_wml_menu_item_event(wml_menu_item* menu_item);
void expand_wml_commands(std::vector<std::string>& items);
std::vector<wml_menu_item *> wml_commands_;
@ -268,6 +270,7 @@ private:
end_level_data end_level_data_;
std::vector<std::string> victory_music_;
std::vector<std::string> defeat_music_;
};

View File

@ -522,8 +522,9 @@ void playmp_controller::handle_generic_event(const std::string& name){
}
}
bool playmp_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
bool playmp_controller::can_execute_command(const hotkey::hotkey_command& cmd, int index) const
{
hotkey::HOTKEY_COMMAND command = cmd.id;
bool res = true;
switch (command){
case hotkey::HOTKEY_SPEAK:
@ -542,7 +543,7 @@ bool playmp_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
}
break;
default:
return playsingle_controller::can_execute_command(command, index);
return playsingle_controller::can_execute_command(cmd, index);
}
return res;
}

View File

@ -50,7 +50,7 @@ protected:
virtual void shout();
virtual void start_network();
virtual void stop_network();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual bool can_execute_command(const hotkey::hotkey_command& command, int index=-1) const;
virtual void play_side(const unsigned int side_number, bool save);
virtual void before_human_turn(bool save);

View File

@ -920,10 +920,15 @@ void playsingle_controller::check_time_over(){
}
}
bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
bool playsingle_controller::can_execute_command(const hotkey::hotkey_command& cmd, int index) const
{
hotkey::HOTKEY_COMMAND command = cmd.id;
bool res = true;
switch (command){
case hotkey::HOTKEY_WML:
//code mixed from play_controller::show_menu and code here
return (gui_->viewing_team() == gui_->playing_team()) && !events::commands_disabled && teams_[gui_->viewing_team()].is_human() && !linger_ && !browse_;
case hotkey::HOTKEY_UNIT_HOLD_POSITION:
case hotkey::HOTKEY_END_UNIT_TURN:
return !browse_ && !linger_ && !events::commands_disabled;
@ -988,7 +993,7 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
return false;
}
default: return play_controller::can_execute_command(command, index);
default: return play_controller::can_execute_command(cmd, index);
}
return res;
}

View File

@ -34,7 +34,7 @@ public:
virtual void recruit();
virtual void repeat_recruit();
virtual void recall();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual bool can_execute_command(const hotkey::hotkey_command& command, int index=-1) const;
virtual void toggle_shroud_updates();
virtual void update_shroud_now();
virtual void end_turn();

View File

@ -504,9 +504,10 @@ void replay_controller::handle_generic_event(const std::string& name){
}
}
bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
bool replay_controller::can_execute_command(const hotkey::hotkey_command& cmd, int index) const
{
bool result = play_controller::can_execute_command(command,index);
hotkey::HOTKEY_COMMAND command = cmd.id;
bool result = play_controller::can_execute_command(cmd,index);
switch(command) {

View File

@ -31,7 +31,7 @@ public:
const int ticks, const int num_turns, const config& game_config, CVideo& video);
virtual ~replay_controller();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual bool can_execute_command(const hotkey::hotkey_command& command, int index=-1) const;
//event handlers
virtual void preferences();

View File

@ -340,9 +340,10 @@ private:
}
}
bool can_execute_command(hotkey::HOTKEY_COMMAND cmd, int /*index*/) const
bool can_execute_command(const hotkey::hotkey_command& cmd, int /*index*/) const
{
return (topic_.empty() == false && cmd == hotkey::HOTKEY_HELP) || cmd == hotkey::HOTKEY_SCREENSHOT;
hotkey::HOTKEY_COMMAND command = cmd.id;
return (topic_.empty() == false && command == hotkey::HOTKEY_HELP) || command == hotkey::HOTKEY_SCREENSHOT;
}
display& disp_;