summaryrefslogtreecommitdiff
path: root/src/keyboardconfig.cpp
diff options
context:
space:
mode:
authorForge <jgrimbert@free.fr>2009-01-02 21:31:39 +0100
committerForge <jgrimbert@free.fr>2009-01-02 21:31:39 +0100
commit402ac13b30d9bcd3c0f67184c9886a2d46516d2f (patch)
treed4ce0b544585ae8f9aed3936987e73d5e92c70bb /src/keyboardconfig.cpp
parentda857b4386d53bed713871f31f1b4e6b0851373f (diff)
downloadmana-client-402ac13b30d9bcd3c0f67184c9886a2d46516d2f.tar.gz
mana-client-402ac13b30d9bcd3c0f67184c9886a2d46516d2f.tar.bz2
mana-client-402ac13b30d9bcd3c0f67184c9886a2d46516d2f.tar.xz
mana-client-402ac13b30d9bcd3c0f67184c9886a2d46516d2f.zip
Step 1.5 of smiley update: allow usage of same key for smiley and
different purpose (as smiley are requiring a special key press, that's not a problem to assign the same key to differents purpose) The function of game.cpp get reindented in the process, but the actual change is minor. The keyboardconfig get a new function, returning directly the emoticon offset from the key pressed. (later, that function will return the index of the smiley shortcut/array that has been selected... later) Signed-off-by: Forge <jgrimbert@free.fr>
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r--src/keyboardconfig.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index d23410bd..930d8944 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -128,11 +128,24 @@ void KeyboardConfig::makeDefault()
bool KeyboardConfig::hasConflicts()
{
int i, j;
+/**
+ * No need to parse the square matrix: only check one triangle
+ * that's enough to detect conflicts
+ */
for (i = 0; i < KEY_TOTAL; i++)
{
- for (j = 0; j < KEY_TOTAL; j++)
+ for (j = i,j++; j < KEY_TOTAL; j++)
{
- if (i != j && mKey[i].value == mKey[j].value)
+/**
+ * KEY_SMILEY_* are separated from other keys, duplicate in different
+ * area is allowed, but not in same area (of course)
+ * (i.e.: not two identical key for smiley, not two identical for other;
+ * but same key for a smiley and a not-smiley is ok)
+ *
+ */
+ if (!((i<KEY_SMILEY_1)&&(j>=KEY_SMILEY_1))
+ && mKey[i].value == mKey[j].value
+ )
{
return true;
}
@@ -158,6 +171,18 @@ int KeyboardConfig::getKeyIndex(int keyValue) const
return KEY_NO_VALUE;
}
+int KeyboardConfig::getKeySmilieOffset(int keyValue) const
+{
+ for (int i = KEY_SMILEY_1; i <= KEY_SMILEY_12; i++)
+ {
+ if(keyValue == mKey[i].value)
+ {
+ return 1+i-KEY_SMILEY_1;
+ }
+ }
+ return KEY_NO_VALUE;
+}
+
bool KeyboardConfig::isKeyActive(int index)
{
return mActiveKeys[ mKey[index].value];