From 0abe0f821c7b08a1d8a8365a53b282e84ab77ac5 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Mon, 18 Mar 2019 01:07:14 +0100 Subject: [PATCH] hard-wire Escape key to always trigger ACTION_ESC. Additional config for more keys/button to trigger the same action is still possible. --- Aquaria/AquariaMenuItem.cpp | 8 +------- Aquaria/AquariaMenuItem.h | 2 -- Aquaria/DSQ.cpp | 1 + Aquaria/Game.cpp | 2 ++ Aquaria/InGameMenu.cpp | 16 ++++++++-------- Aquaria/InGameMenu.h | 2 +- BBGE/ActionInput.cpp | 4 ++++ 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index dde23c1..0ad89d7 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -491,7 +491,6 @@ AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetT , inputSetType(inputSetType) , inputIdx(inputIdx) , actionSetIndex(0) -, acceptEsc(false) , rejectJoyAxis(false) { bg = new Quad(); @@ -760,7 +759,7 @@ void AquariaKeyConfig::onUpdate(float dt) { if(*k == i) // clear key if pressed again *k = 0; - else if(acceptEsc || i != KEY_ESCAPE) + else if(i != KEY_ESCAPE) { if (i == KEY_DELETE || i == KEY_BACKSPACE) *k = 0; @@ -963,11 +962,6 @@ void AquariaKeyConfig::setActionSetIndex(size_t idx) actionSetIndex = idx; } -void AquariaKeyConfig::setAcceptEsc(bool a) -{ - acceptEsc = a; -} - void AquariaKeyConfig::setRejectJoyAxis(bool b) { rejectJoyAxis = b; diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index 0268a5c..db5483b 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -174,7 +174,6 @@ public: static AquariaKeyConfig *waitingForInput; - void setAcceptEsc(bool a); void setActionSetIndex(size_t idx); void setRejectJoyAxis(bool b); @@ -192,7 +191,6 @@ protected: TTFText *keyConfigFont; Quad *bg, *bg2; size_t actionSetIndex; - bool acceptEsc; bool rejectJoyAxis; }; diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 27b4910..ace7e23 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -3696,6 +3696,7 @@ void DSQ::bindInput() almb.clear(); armb.clear(); + addAction(ACTION_ESC, KEY_ESCAPE, -1); addAction(MakeFunctionEvent(DSQ, onSwitchScreenMode), KEY_RETURN, 1); if (isDeveloperKeys()) diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 0f36092..f4d1559 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -3226,6 +3226,8 @@ void Game::bindInput() ActionMapper::clearActions(); //ActionMapper::clearCreatedEvents(); + addAction(ACTION_ESC, KEY_ESCAPE, -1); + #ifdef AQUARIA_BUILD_SCENEEDITOR if (dsq->canOpenEditor()) diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp index 81f2735..a10e956 100644 --- a/Aquaria/InGameMenu.cpp +++ b/Aquaria/InGameMenu.cpp @@ -925,6 +925,8 @@ InGameMenu::~InGameMenu() void InGameMenu::bindInput() { + addAction(ACTION_ESC, KEY_ESCAPE, -1); + for(size_t i = 0; i < dsq->user.control.actionSets.size(); ++i) { const ActionSet& as = dsq->user.control.actionSets[i]; @@ -1522,7 +1524,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, bool rejectJoyAxis) +void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool rejectJoyAxis) { TTFText *lb = new TTFText(&dsq->fontArialSmallest); lb->setText(label); @@ -1540,14 +1542,12 @@ void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, k1->position = Vector(x,y); group->addChild(k1, PM_POINTER); keyConfigs.push_back(k1); - k1->setAcceptEsc(acceptEsc); x += KEYCONFIG_COL_DISTANCE; AquariaKeyConfig *k2 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 1); k2->position = Vector(x,y); group->addChild(k2, PM_POINTER); keyConfigs.push_back(k2); - k2->setAcceptEsc(acceptEsc); x += KEYCONFIG_COL_DISTANCE; AquariaKeyConfig *j1 = new AquariaKeyConfig(actionInputName, INPUTSET_JOY, 0); @@ -2127,10 +2127,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, 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(2109), "SwimUp", offx, y+=yi, true); + addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi, true); + addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi, true); + addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi, 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); @@ -2162,7 +2162,7 @@ void InGameMenu::create() int y = offy; - addKeyConfigLine(kk, SB(2116), "Escape", offx, y+=yi, true); + addKeyConfigLine(kk, SB(2116), "Escape", offx, y+=yi); addKeyConfigLine(kk, SB(2128), "ToggleHelp", offx, y+=yi); addKeyConfigLine(kk, SB(2121), "PrevPage", offx, y+=yi); addKeyConfigLine(kk, SB(2122), "NextPage", offx, y+=yi); diff --git a/Aquaria/InGameMenu.h b/Aquaria/InGameMenu.h index fbe2962..d6f1200 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, bool rejectJoyAxis = false); + void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool rejectJoyAxis = false); AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int offx, int y); diff --git a/BBGE/ActionInput.cpp b/BBGE/ActionInput.cpp index be1ebf7..36377b5 100644 --- a/BBGE/ActionInput.cpp +++ b/BBGE/ActionInput.cpp @@ -197,6 +197,10 @@ int getStringToInputCode(const std::string& s) k = getInputCodeFromKeyName(s.c_str()); } + // Non-configurable keys + if(k == KEY_ESCAPE) + return 0; + if(k < ACTION_BUTTON_ENUM_SIZE) return k;