diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index e775f65..39d1f09 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -484,7 +484,13 @@ AquariaKeyConfig *AquariaKeyConfig::waitingForInput = 0; AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetType inputSetType, int inputIdx) -: AquariaGuiElement(), RenderObject(), actionInputName(actionInputName), inputSetType(inputSetType), inputIdx(inputIdx) +: AquariaGuiElement(), RenderObject() +, actionInputName(actionInputName) +, inputSetType(inputSetType) +, inputIdx(inputIdx) +, actionSetIndex(0) +, acceptEsc(false) +, rejectJoyAxis(false) { bg = new Quad(); if (inputSetType == INPUTSET_OTHER) @@ -504,10 +510,7 @@ AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetT addChild(keyConfigFont, PM_POINTER); - keyDown = false; - acceptEsc = false; - actionSetIndex = 0; toggleEnterKey(false); } @@ -862,6 +865,15 @@ void AquariaKeyConfig::onUpdate(float dt) waitingForInput = 0; AquariaGuiElement::canDirMoveGlobal = true; + if(rejectJoyAxis && ( + (ac >= JOY_AXIS_0_POS && ac < JOY_AXIS_END_POS) + || (ac >= JOY_AXIS_0_NEG && ac < JOY_AXIS_END_NEG) + )) + { + dsq->sound->playSfx("denied"); + abort = true; + } + if(!abort) { if(clear || *k == ac) // clear key if pressed again @@ -929,6 +941,11 @@ void AquariaKeyConfig::setAcceptEsc(bool a) acceptEsc = a; } +void AquariaKeyConfig::setRejectJoyAxis(bool b) +{ + rejectJoyAxis = b; +} + AquariaMenuItem::AquariaMenuItem() : Quad(), ActionMapper(), AquariaGuiElement() { quad = glow = 0; diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index a444d30..52be587 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -176,6 +176,7 @@ public: void setAcceptEsc(bool a); void setActionSetIndex(int idx); + void setRejectJoyAxis(bool b); protected: void toggleEnterKey(int on); @@ -192,6 +193,7 @@ protected: Quad *bg; int actionSetIndex; bool acceptEsc; + bool rejectJoyAxis; }; class AquariaComboBox; diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp index 58db153..021353f 100644 --- a/Aquaria/InGameMenu.cpp +++ b/Aquaria/InGameMenu.cpp @@ -1513,7 +1513,7 @@ void InGameMenu::hide(bool effects, bool cancel) } -void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc) +void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc, bool rejectJoyAxis) { TTFText *lb = new TTFText(&dsq->fontArialSmallest); lb->setText(label); @@ -1545,6 +1545,7 @@ void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, j1->position = Vector(x,y); group->addChild(j1, PM_POINTER); keyConfigs.push_back(j1); + j1->setRejectJoyAxis(rejectJoyAxis); x += KEYCONFIG_COL_DISTANCE; m->setDirMove(DIR_RIGHT, k1); @@ -2097,10 +2098,10 @@ void InGameMenu::create() addKeyConfigLine(kk, SB(2107), "PrimaryAction", offx, y+=yi); addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, y+=yi); - addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi); - addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi); - addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi); - addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi); + addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi, false, true); + addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi, false, true); + addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi, false, true); + addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi, false, true); addKeyConfigLine(kk, SB(2113), "Roll", offx, y+=yi); addKeyConfigLine(kk, SB(2114), "Revert", offx, y+=yi); addKeyConfigLine(kk, SB(2115), "WorldMap", offx, y+=yi); diff --git a/Aquaria/InGameMenu.h b/Aquaria/InGameMenu.h index 06e61b1..02271c2 100644 --- a/Aquaria/InGameMenu.h +++ b/Aquaria/InGameMenu.h @@ -194,7 +194,7 @@ private: void onKeyConfig(); - void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc = false); + void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc = false, bool rejectJoyAxis = false); AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int offx, int y);