Merge pull request #919 from WagicProject/key_bind_changes

key binding related
This commit is contained in:
Rolzad73
2017-02-02 11:18:46 -05:00
committed by GitHub
4 changed files with 57 additions and 34 deletions

View File

@@ -998,6 +998,8 @@ protected:
set<LocalKeySym> confirmedKeys;
set<JButton> confirmedButtons;
string confirmationString;
private:
void populateKeyBindingList();
};
/**@} This comment used by Doxyyen. */

View File

@@ -82,8 +82,8 @@ void GameStateOptions::Start()
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConst::kNewProfileID, this));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks")));
optionsTabs->Add(optionsList);

View File

@@ -12,7 +12,7 @@ using std::map;
static map<const LocalKeySym, KeyRep> fattable;
static map<const JButton, KeyRep> slimtable;
#if defined(LINUX) || defined (IOS) || defined (ANDROID) || defined (SDL_CONFIG) || defined (QT_CONFIG)
#if defined(LINUX) || defined (IOS) || defined (ANDROID) || defined (SDL_CONFIG) || defined (QT_CONFIG)
const KeyRep& translateKey(LocalKeySym key)
{
{
@@ -135,33 +135,34 @@ const KeyRep& translateKey(LocalKeySym key)
#endif
const KeyRep& translateKey(JButton key) {
/*
{
map<const JButton, KeyRep>::iterator res;
if ((res = slimtable.find(key)) != slimtable.end())
return res->second;
}
slimtable[JGE_BTN_NONE] = make_pair(_("None"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_QUIT] = make_pair(_("Quit"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_MENU] = make_pair(_("Menu"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_CTRL] = make_pair(_("Control"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_POWER] = make_pair(_("Power"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_SOUND] = make_pair(_("Sound"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_RIGHT] = make_pair(_("Right"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_LEFT] = make_pair(_("Left"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_UP] = make_pair(_("Up"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_DOWN] = make_pair(_("Down"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_OK] = make_pair(_("Ok"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_CANCEL] = make_pair(_("Cancel"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_PRI] = make_pair(_("Primary"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_SEC] = make_pair(_("Secondary"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_PREV] = make_pair(_("Next phase/Previous item"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_NEXT] = make_pair(_("Open hand/Next item"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_NONE] = make_pair(_("Delete this binding"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_QUIT] = make_pair(_("Quit"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_MENU] = make_pair(_("Menu"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_CTRL] = make_pair(_("Control"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_POWER] = make_pair(_("Power"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_SOUND] = make_pair(_("Sound"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_RIGHT] = make_pair(_("Right"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_LEFT] = make_pair(_("Left"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_UP] = make_pair(_("Up"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_DOWN] = make_pair(_("Down"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_OK] = make_pair(_("Ok"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_CANCEL] = make_pair(_("Cancel"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_PRI] = make_pair(_("Primary"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_SEC] = make_pair(_("Secondary"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_PREV] = make_pair(_("Next phase/Previous item"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_NEXT] = make_pair(_("Open hand/Next item"), static_cast<JQuad*>(NULL));
slimtable[JGE_BTN_FULLSCREEN] = make_pair(_("Fullscreen"), static_cast<JQuad*>(NULL));
return slimtable[key];
*/
/*
map<const JButton, KeyRep>::iterator res;
if ((res = slimtable.find(key)) == slimtable.end())
{
@@ -205,7 +206,8 @@ const KeyRep& translateKey(JButton key) {
case JGE_BTN_OK : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL).get(); break;
case JGE_BTN_SEC : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL).get(); break;
case JGE_BTN_PRI : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL).get(); break;
default: /* Unknown key : no icon */ ;
default: ; // Unknown key : no icon
}
return k;
*/
}

View File

@@ -2276,22 +2276,17 @@ WGuiKeyBinder::WGuiKeyBinder(string name, GameStateOptions* parent) :
WGuiList(name), parent(parent), confirmMenu(NULL), modal(false), confirmed(CONFIRM_NEED), confirmingKey(LOCAL_KEY_NONE),
confirmingButton(JGE_BTN_NONE), confirmationString("")
{
JGE* j = JGE::GetInstance();
JGE::keybindings_it start = j->KeyBindings_begin(), end = j->KeyBindings_end();
Add(NEW OptionKey(parent, LOCAL_KEY_NONE, JGE_BTN_NONE));
for (JGE::keybindings_it it = start; it != end; ++it)
Add(NEW OptionKey(parent, it->first, it->second));
populateKeyBindingList();
}
void WGuiKeyBinder::Update(float dt)
{
OptionKey* o = dynamic_cast<OptionKey*> (items[0]);
OptionKey* o = dynamic_cast<OptionKey*> (items[1]);
if (!o) return;
if (LOCAL_KEY_NONE != o->from)
{
items.insert(items.begin(), NEW OptionKey(parent, LOCAL_KEY_NONE, JGE_BTN_NONE));
if (0 == currentItem) ++currentItem;
items.insert(items.begin() + 1, NEW OptionKey(parent, LOCAL_KEY_NONE, JGE_BTN_NONE));
if (1 == currentItem) ++currentItem;
}
for (vector<WGuiBase*>::iterator it = items.begin(); it != items.end(); ++it)
(*it)->Update(dt);
@@ -2416,7 +2411,11 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm()
void WGuiKeyBinder::ButtonPressed(int controllerId, int controlId)
{
if (2 == controlId)
if (1 == controlId)
{
confirmed = CONFIRM_CANCEL;
}
else if (2 == controlId) {
switch (controllerId)
{
case 0:
@@ -2426,8 +2425,16 @@ void WGuiKeyBinder::ButtonPressed(int controllerId, int controlId)
confirmedButtons.insert(confirmingButton);
break;
}
else
confirmed = CONFIRM_CANCEL;
}
else if (3 == controlId) {
switch (controllerId)
{
case -102:
JGE::GetInstance()->ResetBindings();
populateKeyBindingList();
break;
}
}
SAFE_DELETE(confirmMenu);
confirmMenu = NULL;
}
@@ -2460,3 +2467,15 @@ bool WGuiKeyBinder::yieldFocus()
{
return true;
}
void WGuiKeyBinder::populateKeyBindingList()
{
items.clear();
Add(NEW WGuiButton(NEW WGuiItem("Load Defaults..."), -102, 3, this));
Add(NEW OptionKey(parent, LOCAL_KEY_NONE, JGE_BTN_NONE));
JGE* j = JGE::GetInstance();
JGE::keybindings_it start = j->KeyBindings_begin(), end = j->KeyBindings_end();
for (JGE::keybindings_it it = start; it != end; ++it)
Add(NEW OptionKey(parent, it->first, it->second));
}