summaryrefslogtreecommitdiff
path: root/src/gui/setup_input.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-19 23:48:29 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-19 23:48:29 +0300
commit0b7e752bd177c90a05ca752fa31810f9e34c432c (patch)
treedb1809a48faf051af11c94058e8f126c9e9ef1ab /src/gui/setup_input.cpp
parent23f87c10db7e6b149e9e1f351e1a82516c545df7 (diff)
downloadplus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.gz
plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.bz2
plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.xz
plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.zip
Dehardcode keys in gui widgets.
Add new tab with keys settings in input settings tab.
Diffstat (limited to 'src/gui/setup_input.cpp')
-rw-r--r--src/gui/setup_input.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gui/setup_input.cpp b/src/gui/setup_input.cpp
index 3c512ecc9..3bbdfcee4 100644
--- a/src/gui/setup_input.cpp
+++ b/src/gui/setup_input.cpp
@@ -46,6 +46,8 @@
#include "debug.h"
+const int setupGroups = 9;
+
/**
* The list model for key function list.
*
@@ -100,9 +102,9 @@ Setup_Input::Setup_Input():
setName(_("Input"));
selectedData = 0;
- mActionDataSize = new int [8];
+ mActionDataSize = new int [9];
- for (int f = 0; f < 8; f ++)
+ for (int f = 0; f < setupGroups; f ++)
{
int cnt = 0;
while (!setupActionData[f][cnt].name.empty())
@@ -179,14 +181,13 @@ void Setup_Input::apply()
if (inputManager.hasConflicts(key1, key2))
{
- int s1 = keyToSetupData(key1);
- int s2 = keyToSetupData(key2);
+ std::string str1 = keyToString(key1);
+ std::string str2 = keyToString(key2);
new OkDialog(_("Key Conflict(s) Detected."),
strprintf(_("Conflict \"%s\" and \"%s\" keys. "
"Resolve them, or gameplay may result in strange behaviour."),
- setupActionData[selectedData][s1].name.c_str(),
- setupActionData[selectedData][s2].name.c_str()), DIALOG_ERROR);
+ str1.c_str(), str2.c_str()), DIALOG_ERROR);
}
keyboard.setEnabled(true);
inputManager.store();
@@ -331,6 +332,20 @@ int Setup_Input::keyToSetupData(int index)
return -1;
}
+std::string Setup_Input::keyToString(int index)
+{
+ for (int f = 0; f < setupGroups; f ++)
+ {
+ for (int i = 0; i < mActionDataSize[f]; i++)
+ {
+ const SetupActionData &key = setupActionData[f][i];
+ if (key.actionId == index)
+ return key.name;
+ }
+ }
+ return _("unknown");
+}
+
void Setup_Input::refreshKeys()
{
for (int i = 0; i < mActionDataSize[selectedData]; i++)