1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 09:44:02 +00:00

hard-wire Escape key to always trigger ACTION_ESC.

Additional config for more keys/button to trigger the same action
is still possible.
This commit is contained in:
fgenesis 2019-03-18 01:07:14 +01:00
parent 520c71fdb7
commit 0abe0f821c
7 changed files with 17 additions and 18 deletions

View file

@ -491,7 +491,6 @@ AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetT
, inputSetType(inputSetType) , inputSetType(inputSetType)
, inputIdx(inputIdx) , inputIdx(inputIdx)
, actionSetIndex(0) , actionSetIndex(0)
, acceptEsc(false)
, rejectJoyAxis(false) , rejectJoyAxis(false)
{ {
bg = new Quad(); bg = new Quad();
@ -760,7 +759,7 @@ void AquariaKeyConfig::onUpdate(float dt)
{ {
if(*k == i) // clear key if pressed again if(*k == i) // clear key if pressed again
*k = 0; *k = 0;
else if(acceptEsc || i != KEY_ESCAPE) else if(i != KEY_ESCAPE)
{ {
if (i == KEY_DELETE || i == KEY_BACKSPACE) if (i == KEY_DELETE || i == KEY_BACKSPACE)
*k = 0; *k = 0;
@ -963,11 +962,6 @@ void AquariaKeyConfig::setActionSetIndex(size_t idx)
actionSetIndex = idx; actionSetIndex = idx;
} }
void AquariaKeyConfig::setAcceptEsc(bool a)
{
acceptEsc = a;
}
void AquariaKeyConfig::setRejectJoyAxis(bool b) void AquariaKeyConfig::setRejectJoyAxis(bool b)
{ {
rejectJoyAxis = b; rejectJoyAxis = b;

View file

@ -174,7 +174,6 @@ public:
static AquariaKeyConfig *waitingForInput; static AquariaKeyConfig *waitingForInput;
void setAcceptEsc(bool a);
void setActionSetIndex(size_t idx); void setActionSetIndex(size_t idx);
void setRejectJoyAxis(bool b); void setRejectJoyAxis(bool b);
@ -192,7 +191,6 @@ protected:
TTFText *keyConfigFont; TTFText *keyConfigFont;
Quad *bg, *bg2; Quad *bg, *bg2;
size_t actionSetIndex; size_t actionSetIndex;
bool acceptEsc;
bool rejectJoyAxis; bool rejectJoyAxis;
}; };

View file

@ -3696,6 +3696,7 @@ void DSQ::bindInput()
almb.clear(); almb.clear();
armb.clear(); armb.clear();
addAction(ACTION_ESC, KEY_ESCAPE, -1);
addAction(MakeFunctionEvent(DSQ, onSwitchScreenMode), KEY_RETURN, 1); addAction(MakeFunctionEvent(DSQ, onSwitchScreenMode), KEY_RETURN, 1);
if (isDeveloperKeys()) if (isDeveloperKeys())

View file

@ -3226,6 +3226,8 @@ void Game::bindInput()
ActionMapper::clearActions(); ActionMapper::clearActions();
//ActionMapper::clearCreatedEvents(); //ActionMapper::clearCreatedEvents();
addAction(ACTION_ESC, KEY_ESCAPE, -1);
#ifdef AQUARIA_BUILD_SCENEEDITOR #ifdef AQUARIA_BUILD_SCENEEDITOR
if (dsq->canOpenEditor()) if (dsq->canOpenEditor())

View file

@ -925,6 +925,8 @@ InGameMenu::~InGameMenu()
void InGameMenu::bindInput() void InGameMenu::bindInput()
{ {
addAction(ACTION_ESC, KEY_ESCAPE, -1);
for(size_t i = 0; i < dsq->user.control.actionSets.size(); ++i) for(size_t i = 0; i < dsq->user.control.actionSets.size(); ++i)
{ {
const ActionSet& as = dsq->user.control.actionSets[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); TTFText *lb = new TTFText(&dsq->fontArialSmallest);
lb->setText(label); lb->setText(label);
@ -1540,14 +1542,12 @@ void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label,
k1->position = Vector(x,y); k1->position = Vector(x,y);
group->addChild(k1, PM_POINTER); group->addChild(k1, PM_POINTER);
keyConfigs.push_back(k1); keyConfigs.push_back(k1);
k1->setAcceptEsc(acceptEsc);
x += KEYCONFIG_COL_DISTANCE; x += KEYCONFIG_COL_DISTANCE;
AquariaKeyConfig *k2 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 1); AquariaKeyConfig *k2 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 1);
k2->position = Vector(x,y); k2->position = Vector(x,y);
group->addChild(k2, PM_POINTER); group->addChild(k2, PM_POINTER);
keyConfigs.push_back(k2); keyConfigs.push_back(k2);
k2->setAcceptEsc(acceptEsc);
x += KEYCONFIG_COL_DISTANCE; x += KEYCONFIG_COL_DISTANCE;
AquariaKeyConfig *j1 = new AquariaKeyConfig(actionInputName, INPUTSET_JOY, 0); 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(2107), "PrimaryAction", offx, y+=yi);
addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, y+=yi); addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, y+=yi);
addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi, false, true); addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi, true);
addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi, false, true); addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi, true);
addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi, false, true); addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi, true);
addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi, false, true); addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi, true);
addKeyConfigLine(kk, SB(2113), "Roll", offx, y+=yi); addKeyConfigLine(kk, SB(2113), "Roll", offx, y+=yi);
addKeyConfigLine(kk, SB(2114), "Revert", offx, y+=yi); addKeyConfigLine(kk, SB(2114), "Revert", offx, y+=yi);
addKeyConfigLine(kk, SB(2115), "WorldMap", offx, y+=yi); addKeyConfigLine(kk, SB(2115), "WorldMap", offx, y+=yi);
@ -2162,7 +2162,7 @@ void InGameMenu::create()
int y = offy; 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(2128), "ToggleHelp", offx, y+=yi);
addKeyConfigLine(kk, SB(2121), "PrevPage", offx, y+=yi); addKeyConfigLine(kk, SB(2121), "PrevPage", offx, y+=yi);
addKeyConfigLine(kk, SB(2122), "NextPage", offx, y+=yi); addKeyConfigLine(kk, SB(2122), "NextPage", offx, y+=yi);

View file

@ -194,7 +194,7 @@ private:
void onKeyConfig(); 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); AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int offx, int y);

View file

@ -197,6 +197,10 @@ int getStringToInputCode(const std::string& s)
k = getInputCodeFromKeyName(s.c_str()); k = getInputCodeFromKeyName(s.c_str());
} }
// Non-configurable keys
if(k == KEY_ESCAPE)
return 0;
if(k < ACTION_BUTTON_ENUM_SIZE) if(k < ACTION_BUTTON_ENUM_SIZE)
return k; return k;