summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp74
-rw-r--r--src/keyboardconfig.cpp16
-rw-r--r--src/keyboardconfig.h14
3 files changed, 77 insertions, 27 deletions
diff --git a/src/game.cpp b/src/game.cpp
index a108b9e0..1b84833c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -541,32 +541,54 @@ void Game::handleInput()
// Smilie
if (keyboard.isKeyActive(keyboard.KEY_SMILIE))
- {
- // Emotions
- Uint8 emotion;
- switch (event.key.keysym.sym)
- {
- case SDLK_1: emotion = 1; break;
- case SDLK_2: emotion = 2; break;
- case SDLK_3: emotion = 3; break;
- case SDLK_4: emotion = 4; break;
- case SDLK_5: emotion = 5; break;
- case SDLK_6: emotion = 6; break;
- case SDLK_7: emotion = 7; break;
- case SDLK_8: emotion = 8; break;
- case SDLK_9: emotion = 9; break;
- case SDLK_0: emotion = 10; break;
- case SDLK_MINUS: emotion = 11; break;
- case SDLK_EQUALS: emotion = 12; break;
- default: emotion = 0; break;
- }
-
- if (emotion)
- {
- player_node->emote(emotion);
- used = true;
- }
- }
+ {
+ // Emotions
+ Uint8 emotion;
+ /**
+ *
+ * Might be simpler to perform as follow
+ * emotion=0;
+ * const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
+ * if ((tKey <=KeyboardConfig::KEY_SMILEY_12)
+ * &&(tKey >=KeyboardConfig::KEY_SMILEY_1)
+ * )
+ * {
+ * emotion= 1+tKey-KeyboardConfig::KEY_SMILEY_1;
+ * }
+ *
+ * But this add constraints over KEY_SMILEY_* allocation
+ * (ordering, consecutive positive values)
+ * Old story... compiler optimisation
+ * or code complexity for update, which one is better ?
+ * I won't rely on enum allocation, let's keep the switch,
+ * it does not add such undocumented constraints on that enum.
+ *
+ * Speed consideration ? not even sure!
+ */
+ const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
+ switch (tKey)
+ {
+ case KeyboardConfig::KEY_SMILEY_1: emotion = 1; break;
+ case KeyboardConfig::KEY_SMILEY_2: emotion = 2; break;
+ case KeyboardConfig::KEY_SMILEY_3: emotion = 3; break;
+ case KeyboardConfig::KEY_SMILEY_4: emotion = 4; break;
+ case KeyboardConfig::KEY_SMILEY_5: emotion = 5; break;
+ case KeyboardConfig::KEY_SMILEY_6: emotion = 6; break;
+ case KeyboardConfig::KEY_SMILEY_7: emotion = 7; break;
+ case KeyboardConfig::KEY_SMILEY_8: emotion = 8; break;
+ case KeyboardConfig::KEY_SMILEY_9: emotion = 9; break;
+ case KeyboardConfig::KEY_SMILEY_10: emotion = 10; break;
+ case KeyboardConfig::KEY_SMILEY_11: emotion = 11; break;
+ case KeyboardConfig::KEY_SMILEY_12: emotion = 12; break;
+ default: emotion = 0; break;
+ }
+
+ if (emotion)
+ {
+ player_node->emote(emotion);
+ used = true;
+ }
+ }
switch (event.key.keysym.sym)
{
case SDLK_PAGEUP:
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index ea40ff38..d23410bd 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -68,7 +68,21 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyWindowChat", SDLK_F7, "Chat Window"},
{"keyWindowShortcut", SDLK_F8, "Item Shortcut Window"},
{"keyWindowSetup", SDLK_F9, "Setup Window"},
- {"keyWindowDebug", SDLK_F10, "Debug Window"}
+ {"keyWindowDebug", SDLK_F10, "Debug Window"},
+ {"keyWindowSmileyList", SDLK_F11, "Smiley List Window"},
+ {"keyWindowSmileyBar", SDLK_F12, "Smiley Shortcut Window"},
+ {"keySmileyShortcut1", SDLK_KP1, "Smiley Shortcut 1"},
+ {"keySmileyShortcut2", SDLK_KP2, "Smiley Shortcut 2"},
+ {"keySmileyShortcut3", SDLK_KP3, "Smiley Shortcut 3"},
+ {"keySmileyShortcut4", SDLK_KP4, "Smiley Shortcut 4"},
+ {"keySmileyShortcut5", SDLK_KP5, "Smiley Shortcut 5"},
+ {"keySmileyShortcut6", SDLK_KP6, "Smiley Shortcut 6"},
+ {"keySmileyShortcut7", SDLK_KP7, "Smiley Shortcut 7"},
+ {"keySmileyShortcut8", SDLK_KP8, "Smiley Shortcut 8"},
+ {"keySmileyShortcut9", SDLK_KP9, "Smiley Shortcut 9"},
+ {"keySmileyShortcut10", SDLK_KP0, "Smiley Shortcut 10"},
+ {"keySmileyShortcut11", SDLK_KP_DIVIDE, "Smiley Shortcut 11"},
+ {"keySmileyShortcut12", SDLK_KP_MULTIPLY, "Smiley Shortcut 12"}
};
void KeyboardConfig::init()
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index b51f12f4..08c1dba7 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -177,6 +177,20 @@ class KeyboardConfig
KEY_WINDOW_SHORTCUT,
KEY_WINDOW_SETUP,
KEY_WINDOW_DEBUG,
+ KEY_WINDOW_ALLSMILEY,
+ KEY_WINDOW_SMILEY_SHORTCUT,
+ KEY_SMILEY_1,
+ KEY_SMILEY_2,
+ KEY_SMILEY_3,
+ KEY_SMILEY_4,
+ KEY_SMILEY_5,
+ KEY_SMILEY_6,
+ KEY_SMILEY_7,
+ KEY_SMILEY_8,
+ KEY_SMILEY_9,
+ KEY_SMILEY_10,
+ KEY_SMILEY_11,
+ KEY_SMILEY_12,
KEY_TOTAL
};