summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-26 17:46:50 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-26 17:46:50 +0300
commita1cd5307497bfc754f157a3e22bfa98fc126137a (patch)
tree2516d80f0a08fe0004dcdd49efec8d31b0d76214 /src
parent4208c8cd889112aa1adffaa2b6492f61734d1105 (diff)
downloadmv-a1cd5307497bfc754f157a3e22bfa98fc126137a.tar.gz
mv-a1cd5307497bfc754f157a3e22bfa98fc126137a.tar.bz2
mv-a1cd5307497bfc754f157a3e22bfa98fc126137a.tar.xz
mv-a1cd5307497bfc754f157a3e22bfa98fc126137a.zip
Split keyboard keys to groups.
Diffstat (limited to 'src')
-rw-r--r--src/gui/setup_keyboard.cpp33
-rw-r--r--src/keyboardconfig.cpp32
-rw-r--r--src/keyboardconfig.h16
3 files changed, 62 insertions, 19 deletions
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 5125541cf..922d9797b 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -153,8 +153,17 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
if (!mKeySetting)
{
- mAssignKeyButton->setEnabled(true);
- mUnassignKeyButton->setEnabled(true);
+ int i(mKeyList->getSelected());
+ if (keyboard.isSeparator(i))
+ {
+ mAssignKeyButton->setEnabled(false);
+ mUnassignKeyButton->setEnabled(false);
+ }
+ else
+ {
+ mAssignKeyButton->setEnabled(true);
+ mUnassignKeyButton->setEnabled(true);
+ }
}
}
else if (event.getId() == "assign")
@@ -183,11 +192,21 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
void Setup_Keyboard::refreshAssignedKey(int index)
{
- std::string caption;
- char *temp = SDL_GetKeyName(
- static_cast<SDLKey>(keyboard.getKeyValue(index)));
- caption = keyboard.getKeyCaption(index) + ": " + toString(temp);
- mKeyListModel->setElementAt(index, caption);
+ if (keyboard.isSeparator(index))
+ {
+ const std::string str = " \342\200\225\342\200\225\342\200\225"
+ "\342\200\225\342\200\225 ";
+ mKeyListModel->setElementAt(index, str
+ + keyboard.getKeyCaption(index) + str);
+ }
+ else
+ {
+ std::string caption;
+ char *temp = SDL_GetKeyName(
+ static_cast<SDLKey>(keyboard.getKeyValue(index)));
+ caption = keyboard.getKeyCaption(index) + ": " + toString(temp);
+ mKeyListModel->setElementAt(index, caption);
+ }
}
void Setup_Keyboard::newKeyCallback(int index)
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index ea9f9b90b..f9831c18f 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -40,6 +40,7 @@ struct KeyData
// keyData must be in same order as enum keyAction.
static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
+ {"", 0, N_("Basic Keys"), 0},
{"keyMoveUp", SDLK_UP, N_("Move Up"), KeyboardConfig::GRP_DEFAULT},
{"keyMoveDown", SDLK_DOWN, N_("Move Down"), KeyboardConfig::GRP_DEFAULT},
{"keyMoveLeft", SDLK_LEFT, N_("Move Left"), KeyboardConfig::GRP_DEFAULT},
@@ -58,7 +59,6 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_DEFAULT},
{"keyMoveToPoint", SDLK_RSHIFT, N_("Move to navigation point"),
KeyboardConfig::GRP_DEFAULT},
- {"keySmilie", SDLK_LALT, N_("Smilie"), KeyboardConfig::GRP_DEFAULT},
{"keyTalk", SDLK_t, N_("Talk"), KeyboardConfig::GRP_DEFAULT},
{"keyTarget", SDLK_LSHIFT, N_("Stop Attack"), KeyboardConfig::GRP_DEFAULT},
{"keyTargetClosest", SDLK_a, N_("Target Closest"),
@@ -77,6 +77,10 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_DEFAULT},
{"keyPathfind", SDLK_f, N_("Change Map View Mode"),
KeyboardConfig::GRP_DEFAULT},
+ {"keyOK", SDLK_SPACE, N_("Select OK"),
+ KeyboardConfig::GRP_DEFAULT | KeyboardConfig::GRP_GUI},
+ {"keyQuit", SDLK_ESCAPE, N_("Quit"), KeyboardConfig::GRP_DEFAULT},
+ {"", 0, N_("Shortcuts Keys"), 0},
{"keyShortcutsKey", SDLK_MENU, N_("Item Shortcuts Key"),
KeyboardConfig::GRP_DEFAULT},
{"keyShortcut1", SDLK_1, strprintf(N_("Item Shortcut %d"), 1),
@@ -119,6 +123,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
strprintf(N_("Item Shortcut %d"), 19), KeyboardConfig::GRP_DEFAULT},
{"keyShortcut20", KeyboardConfig::KEY_NO_VALUE,
strprintf(N_("Item Shortcut %d"), 20), KeyboardConfig::GRP_DEFAULT},
+ {"", 0, N_("Windows Keys"), 0},
{"keyWindowHelp", SDLK_F1, N_("Help Window"), KeyboardConfig::GRP_DEFAULT
| KeyboardConfig::GRP_GUI},
{"keyWindowStatus", SDLK_F2, N_("Status Window"),
@@ -165,6 +170,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
| KeyboardConfig::GRP_GUI},
{"keySocialNextTab", KeyboardConfig::KEY_NO_VALUE, N_("Next Social Tab"),
KeyboardConfig::GRP_DEFAULT | KeyboardConfig::GRP_GUI},
+ {"", 0, N_("Emotes Keys"), 0},
+ {"keySmilie", SDLK_LALT, N_("Smilie"), KeyboardConfig::GRP_DEFAULT},
{"keyEmoteShortcut1", SDLK_1, strprintf(N_("Emote Shortcut %d"), 1),
KeyboardConfig::GRP_EMOTION},
{"keyEmoteShortcut2", SDLK_2, strprintf(N_("Emote Shortcut %d"), 2),
@@ -258,12 +265,14 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_EMOTION},
{"keyEmoteShortcut44", SDLK_b, strprintf(N_("Emote Shortcut %d"), 44),
KeyboardConfig::GRP_EMOTION},
+ {"", 0, N_("Outfits Keys"), 0},
{"keyWearOutfit", SDLK_RCTRL, N_("Wear Outfit"),
KeyboardConfig::GRP_DEFAULT},
{"keyCopyOutfit", SDLK_RALT, N_("Copy Outfit"),
KeyboardConfig::GRP_DEFAULT},
{"keyCopyEquipedOutfit", SDLK_RIGHTBRACKET, N_("Copy equipped to Outfit"),
KeyboardConfig::GRP_DEFAULT},
+ {"", 0, N_("Chat Keys"), 0},
{"keyChat", SDLK_RETURN, N_("Toggle Chat"), KeyboardConfig::GRP_DEFAULT
| KeyboardConfig::GRP_CHAT},
{"keyChatScrollUp", SDLK_PAGEUP, N_("Scroll Chat Up"),
@@ -285,9 +294,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_CHAT},
{"keyDeActivateChat", SDLK_ESCAPE, N_("Deactivate Chat Input"),
KeyboardConfig::GRP_CHAT},
- {"keyOK", SDLK_SPACE, N_("Select OK"),
- KeyboardConfig::GRP_DEFAULT | KeyboardConfig::GRP_GUI},
- {"keyQuit", SDLK_ESCAPE, N_("Quit"), KeyboardConfig::GRP_DEFAULT},
+ {"", 0, N_("Other Keys"), 0},
{"keyIgnoreInput1", SDLK_LSUPER, N_("Ignore input 1"),
KeyboardConfig::GRP_DEFAULT},
{"keyIgnoreInput2", SDLK_RSUPER, N_("Ignore input 2"),
@@ -370,15 +377,21 @@ void KeyboardConfig::retrieve()
{
for (int i = 0; i < KEY_TOTAL; i++)
{
- mKey[i].value = static_cast<int>(config.getValue(
- mKey[i].configField, mKey[i].defaultValue));
+ if (*mKey[i].configField)
+ {
+ mKey[i].value = static_cast<int>(config.getValue(
+ mKey[i].configField, mKey[i].defaultValue));
+ }
}
}
void KeyboardConfig::store()
{
for (int i = 0; i < KEY_TOTAL; i++)
- config.setValue(mKey[i].configField, mKey[i].value);
+ {
+ if (*mKey[i].configField)
+ config.setValue(mKey[i].configField, mKey[i].value);
+ }
}
void KeyboardConfig::makeDefault()
@@ -396,7 +409,7 @@ bool KeyboardConfig::hasConflicts()
*/
for (i = 0; i < KEY_TOTAL; i++)
{
- if (mKey[i].value == KEY_NO_VALUE)
+ if (mKey[i].value == KEY_NO_VALUE || !*mKey[i].configField)
continue;
for (j = i, j++; j < KEY_TOTAL; j++)
@@ -405,7 +418,8 @@ bool KeyboardConfig::hasConflicts()
// as well as emote and ignore keys, but no other keys
if (mKey[j].value != KEY_NO_VALUE &&
mKey[i].value == mKey[j].value &&
- ((mKey[i].grp & mKey[j].grp) != 0)
+ ((mKey[i].grp & mKey[j].grp) != 0 &&
+ *mKey[i].configField)
)
{
mBindError = strprintf(_("Conflict \"%s\" and \"%s\" keys. "
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index 43bb1c17f..bfec0fc87 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -78,6 +78,9 @@ class KeyboardConfig
int getKeyValue(int index) const
{ return mKey[index].value; }
+ bool isSeparator(int index) const
+ { return !*mKey[index].configField; }
+
/**
* Get the index of the new key to be assigned.
*/
@@ -157,6 +160,7 @@ class KeyboardConfig
enum KeyAction
{
KEY_NO_VALUE = -1,
+ KEY_SEPARATOR1,
KEY_MOVE_UP,
KEY_MOVE_DOWN,
KEY_MOVE_LEFT,
@@ -168,7 +172,6 @@ class KeyboardConfig
KEY_MOVE_TO_HOME,
KEY_SET_HOME,
KEY_MOVE_TO_POINT,
- KEY_EMOTE,
KEY_TALK,
KEY_TARGET,
KEY_TARGET_CLOSEST,
@@ -181,6 +184,9 @@ class KeyboardConfig
KEY_SCREENSHOT,
KEY_TRADE,
KEY_PATHFIND,
+ KEY_OK,
+ KEY_QUIT,
+ KEY_SEPARATOR2,
KEY_SHORTCUTS_KEY,
KEY_SHORTCUT_1,
KEY_SHORTCUT_2,
@@ -202,6 +208,7 @@ class KeyboardConfig
KEY_SHORTCUT_18,
KEY_SHORTCUT_19,
KEY_SHORTCUT_20,
+ KEY_SEPARATOR3,
KEY_WINDOW_HELP,
KEY_WINDOW_STATUS,
KEY_WINDOW_INVENTORY,
@@ -224,6 +231,8 @@ class KeyboardConfig
KEY_WINDOW_DIDYOUKNOW,
KEY_PREV_SOCIAL_TAB,
KEY_NEXT_SOCIAL_TAB,
+ KEY_SEPARATOR4,
+ KEY_EMOTE,
KEY_EMOTE_1,
KEY_EMOTE_2,
KEY_EMOTE_3,
@@ -268,9 +277,11 @@ class KeyboardConfig
KEY_EMOTE_42,
KEY_EMOTE_43,
KEY_EMOTE_44,
+ KEY_SEPARATOR5,
KEY_WEAR_OUTFIT,
KEY_COPY_OUTFIT,
KEY_COPY_EQUIPED_OUTFIT,
+ KEY_SEPARATOR6,
KEY_TOGGLE_CHAT,
KEY_SCROLL_CHAT_UP,
KEY_SCROLL_CHAT_DOWN,
@@ -281,8 +292,7 @@ class KeyboardConfig
KEY_CHAT_NEXT_HISTORY,
KEY_AUTOCOMPLETE_CHAT,
KEY_DEACTIVATE_CHAT,
- KEY_OK,
- KEY_QUIT,
+ KEY_SEPARATOR7,
KEY_IGNORE_INPUT_1,
KEY_IGNORE_INPUT_2,
KEY_DIRECT_UP,