summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-02-28 20:14:42 -0500
committerChuck Miller <shadowmil@gmail.com>2010-02-28 20:19:56 -0500
commita13bb4ca5b0b4e92711fba901796ee150445d6e4 (patch)
treee75d5827c8be74604a0c15529094283727c4b133 /src
parentd357426f64cb6f484214ec166615d70e789d63c4 (diff)
downloadmana-a13bb4ca5b0b4e92711fba901796ee150445d6e4.tar.gz
mana-a13bb4ca5b0b4e92711fba901796ee150445d6e4.tar.bz2
mana-a13bb4ca5b0b4e92711fba901796ee150445d6e4.tar.xz
mana-a13bb4ca5b0b4e92711fba901796ee150445d6e4.zip
Clean up handling of key collisions
-Cleaner code -Ignore keys can collide with anything -No longer have collisions between two unassigned keys Reviewed-By: Jared Adams
Diffstat (limited to 'src')
-rw-r--r--src/keyboardconfig.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 8d1f0bcd..7b462c25 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -156,15 +156,24 @@ bool KeyboardConfig::hasConflicts()
{
for (j = i, j++; j < KEY_TOTAL; j++)
{
- // Allow for item shortcut and emote keys to overlap
- // as well as emote and ignore keys, but no other keys
- if (!((((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) &&
- ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12))) ||
- ((i == KEY_TOGGLE_CHAT) && (j == KEY_OK)) ||
- ((i == KEY_EMOTE) &&
- (j == KEY_IGNORE_INPUT_1 || j == KEY_IGNORE_INPUT_2))) &&
- (mKey[i].value == mKey[j].value)
- )
+ // Allow collisions between shortcut and emote keys
+ if ((i >= KEY_SHORTCUT_1 && i <= KEY_SHORTCUT_12) && (j >= KEY_EMOTE_1 && j <= KEY_EMOTE_12))
+ continue;
+
+ // Why?
+ if (i == KEY_TOGGLE_CHAT && j == KEY_OK)
+ continue;
+
+ // Ignore keys can collide with anything.
+ if (j == KEY_IGNORE_INPUT_1 || j == KEY_IGNORE_INPUT_2)
+ continue;
+
+ // If the one of the keys is not set, then no conflict can happen.
+ if (mKey[i].value == -1 || mKey[j].value == -1)
+ continue;
+
+ // Finally test to see if a conflict DOES exist.
+ if (mKey[i].value == mKey[j].value)
{
mBindError = strprintf(_("Conflict \"%s\" and \"%s\" keys. "
"Resolve them, or gameplay may result"