summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-03-08 22:37:44 +0200
committerChuck Miller <shadowmil@gmail.com>2010-03-08 16:18:03 -0500
commit1826d95339a371d6246b1453605374260e111e47 (patch)
treed547dfcb347ccfac3eaf93784f03be27c1af6640
parentae774999ad279b0b4d627c13464bc4818a14a6da (diff)
downloadmana-1826d95339a371d6246b1453605374260e111e47.tar.gz
mana-1826d95339a371d6246b1453605374260e111e47.tar.bz2
mana-1826d95339a371d6246b1453605374260e111e47.tar.xz
mana-1826d95339a371d6246b1453605374260e111e47.zip
Add unassign button in setup keyboard tab.
Signed-off-by: Chuck Miller <shadowmil@gmail.com>
-rw-r--r--src/gui/setup_keyboard.cpp19
-rw-r--r--src/gui/setup_keyboard.h1
-rw-r--r--src/keyboardconfig.cpp6
3 files changed, 25 insertions, 1 deletions
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index da473aeb..21891d33 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -87,6 +87,10 @@ Setup_Keyboard::Setup_Keyboard():
mAssignKeyButton->addActionListener(this);
mAssignKeyButton->setEnabled(false);
+ mUnAssignKeyButton = new Button(_("Unassign"), "unassign", this);
+ mUnAssignKeyButton->addActionListener(this);
+ mUnAssignKeyButton->setEnabled(false);
+
mMakeDefaultButton = new Button(_("Default"), "makeDefault", this);
mMakeDefaultButton->addActionListener(this);
@@ -96,7 +100,8 @@ Setup_Keyboard::Setup_Keyboard():
place(0, 0, scrollArea, 4, 6).setPadding(2);
place(0, 6, mMakeDefaultButton);
- place(3, 6, mAssignKeyButton);
+ place(2, 6, mAssignKeyButton);
+ place(3, 6, mUnAssignKeyButton);
setDimension(gcn::Rectangle(0, 0, 365, 280));
}
@@ -107,6 +112,7 @@ Setup_Keyboard::~Setup_Keyboard()
delete mKeyListModel;
delete mAssignKeyButton;
+ delete mUnAssignKeyButton;
delete mMakeDefaultButton;
}
@@ -138,7 +144,10 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
if (event.getSource() == mKeyList)
{
if (!mKeySetting)
+ {
mAssignKeyButton->setEnabled(true);
+ mUnAssignKeyButton->setEnabled(true);
+ }
}
else if (event.getId() == "assign")
{
@@ -149,6 +158,14 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
keyboard.setNewKeyIndex(i);
mKeyListModel->setElementAt(i, keyboard.getKeyCaption(i) + ": ?");
}
+ else if (event.getId() == "unassign")
+ {
+ int i(mKeyList->getSelected());
+ keyboard.setNewKeyIndex(i);
+ refreshAssignedKey(mKeyList->getSelected());
+ keyboard.setNewKey(keyboard.KEY_NO_VALUE);
+ mAssignKeyButton->setEnabled(true);
+ }
else if (event.getId() == "makeDefault")
{
keyboard.makeDefault();
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index 69c2d58a..28f6f9aa 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -72,6 +72,7 @@ class Setup_Keyboard : public SetupTab, public gcn::ActionListener
gcn::ListBox *mKeyList;
gcn::Button *mAssignKeyButton;
+ gcn::Button *mUnAssignKeyButton;
gcn::Button *mMakeDefaultButton;
bool mKeySetting; /**< flag to check if key being set. */
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 7b462c25..65143d69 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -154,8 +154,14 @@ bool KeyboardConfig::hasConflicts()
*/
for (i = 0; i < KEY_TOTAL; i++)
{
+ if (mKey[i].value == KEY_NO_VALUE)
+ continue;
+
for (j = i, j++; j < KEY_TOTAL; j++)
{
+ if (mKey[j].value == KEY_NO_VALUE)
+ continue;
+
// 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;