mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-16 12:54:49 +00:00
Add support for suppressing game actions from being handled, minor changes to actions
This allows to e.g. prevent ACTION_TOGGLEHELPSCREEN from being handled by the game, and instead use a node's catch action functionality to handle the event. Add related Lua functions: - setIgnoreAction() - isIgnoreAction() - sendAction()
This commit is contained in:
parent
9e66c4cd69
commit
3ad6eedd37
7 changed files with 71 additions and 13 deletions
|
@ -4508,6 +4508,9 @@ Vector Avatar::getVectorToCursor(bool trueMouse)
|
||||||
|
|
||||||
void Avatar::action(int id, int state)
|
void Avatar::action(int id, int state)
|
||||||
{
|
{
|
||||||
|
if(dsq->game->isIgnoreAction((AquariaActions)id))
|
||||||
|
return;
|
||||||
|
|
||||||
if (id == ACTION_PRIMARY) { if (state) lmbd(); else lmbu(); }
|
if (id == ACTION_PRIMARY) { if (state) lmbd(); else lmbu(); }
|
||||||
if (id == ACTION_SECONDARY) { if (state) rmbd(); else rmbu(); }
|
if (id == ACTION_SECONDARY) { if (state) rmbd(); else rmbu(); }
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,9 @@ enum AquariaActions
|
||||||
ACTION_FOODRIGHT,
|
ACTION_FOODRIGHT,
|
||||||
ACTION_FOODDROP,
|
ACTION_FOODDROP,
|
||||||
|
|
||||||
|
ACTION_TOGGLEMENU,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ACTION_SWIMUP = 100,
|
ACTION_SWIMUP = 100,
|
||||||
ACTION_SWIMDOWN,
|
ACTION_SWIMDOWN,
|
||||||
|
|
|
@ -3939,7 +3939,7 @@ void Game::createInGameMenu()
|
||||||
menu[8]->useSound("Click");
|
menu[8]->useSound("Click");
|
||||||
menu[8]->position = Vector(400+60, 350);
|
menu[8]->position = Vector(400+60, 350);
|
||||||
|
|
||||||
menu[9]->event.set(MakeFunctionEvent(Game, onToggleHelpScreen));
|
menu[9]->event.set(MakeFunctionEvent(Game, toggleHelpScreen));
|
||||||
menu[9]->useQuad("gui/icon-help");
|
menu[9]->useQuad("gui/icon-help");
|
||||||
menu[9]->useGlow("particles/glow", gs, gs);
|
menu[9]->useGlow("particles/glow", gs, gs);
|
||||||
menu[9]->useSound("Click");
|
menu[9]->useSound("Click");
|
||||||
|
@ -5846,6 +5846,9 @@ void Game::action(int id, int state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isIgnoreAction((AquariaActions)id))
|
||||||
|
return;
|
||||||
|
|
||||||
if (id == ACTION_TOGGLEHELPSCREEN && !state)
|
if (id == ACTION_TOGGLEHELPSCREEN && !state)
|
||||||
{
|
{
|
||||||
onToggleHelpScreen();
|
onToggleHelpScreen();
|
||||||
|
@ -5853,6 +5856,13 @@ void Game::action(int id, int state)
|
||||||
}
|
}
|
||||||
if (id == ACTION_ESC && !state) onPressEscape();
|
if (id == ACTION_ESC && !state) onPressEscape();
|
||||||
if (id == ACTION_PRIMARY && !state) onLeftMouseButton();
|
if (id == ACTION_PRIMARY && !state) onLeftMouseButton();
|
||||||
|
if (id == ACTION_TOGGLEMENU)
|
||||||
|
{
|
||||||
|
if(state)
|
||||||
|
showInGameMenu();
|
||||||
|
else
|
||||||
|
hideInGameMenu();
|
||||||
|
}
|
||||||
if (id == ACTION_TOGGLEWORLDMAP && !state)
|
if (id == ACTION_TOGGLEWORLDMAP && !state)
|
||||||
{
|
{
|
||||||
if (foodMenu)
|
if (foodMenu)
|
||||||
|
@ -6129,6 +6139,8 @@ void Game::applyState()
|
||||||
|
|
||||||
dsq->resetLayerPasses();
|
dsq->resetLayerPasses();
|
||||||
|
|
||||||
|
ignoredActions.clear();
|
||||||
|
|
||||||
cameraLerpDelay = 0;
|
cameraLerpDelay = 0;
|
||||||
playingSongInMenu = -1;
|
playingSongInMenu = -1;
|
||||||
sceneColor2 = Vector(1,1,1);
|
sceneColor2 = Vector(1,1,1);
|
||||||
|
@ -7825,7 +7837,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label)
|
||||||
helpCancel->position = Vector(750, 600-20);
|
helpCancel->position = Vector(750, 600-20);
|
||||||
helpCancel->followCamera = 1;
|
helpCancel->followCamera = 1;
|
||||||
//helpCancel->rotation.z = 90;
|
//helpCancel->rotation.z = 90;
|
||||||
helpCancel->event.set(MakeFunctionEvent(Game, onToggleHelpScreen));
|
helpCancel->event.set(MakeFunctionEvent(Game, toggleHelpScreen));
|
||||||
helpCancel->scale = Vector(0.9, 0.9);
|
helpCancel->scale = Vector(0.9, 0.9);
|
||||||
helpCancel->guiInputLevel = 100;
|
helpCancel->guiInputLevel = 100;
|
||||||
addRenderObject(helpCancel, LR_HELP);
|
addRenderObject(helpCancel, LR_HELP);
|
||||||
|
@ -7978,7 +7990,7 @@ void Game::onPressEscape()
|
||||||
if (optionsMenu || keyConfigMenu)
|
if (optionsMenu || keyConfigMenu)
|
||||||
onOptionsCancel();
|
onOptionsCancel();
|
||||||
else
|
else
|
||||||
hideInGameMenu();
|
action(ACTION_TOGGLEMENU, 0); // hide menu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -7987,7 +7999,7 @@ void Game::onPressEscape()
|
||||||
if (!paused)
|
if (!paused)
|
||||||
{
|
{
|
||||||
if (core->getNestedMains() == 1 && !core->isStateJumpPending())
|
if (core->getNestedMains() == 1 && !core->isStateJumpPending())
|
||||||
showInGameMenu();
|
action(ACTION_TOGGLEMENU, 1); // show menu
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -10991,4 +11003,15 @@ void Game::learnedRecipe(Recipe *r, bool effects)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::setIgnoreAction(AquariaActions ac, bool ignore)
|
||||||
|
{
|
||||||
|
if (ignore)
|
||||||
|
ignoredActions.insert(ac);
|
||||||
|
else
|
||||||
|
ignoredActions.erase(ac);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::isIgnoreAction(AquariaActions ac) const
|
||||||
|
{
|
||||||
|
return ignoredActions.find(ac) != ignoredActions.end();
|
||||||
|
}
|
||||||
|
|
|
@ -1001,14 +1001,19 @@ public:
|
||||||
|
|
||||||
void enqueuePreviewRecipe();
|
void enqueuePreviewRecipe();
|
||||||
|
|
||||||
void toggleHelpScreen(bool on, const std::string &label="");
|
void toggleHelpScreen() { action(ACTION_TOGGLEHELPSCREEN, 0); }
|
||||||
void onToggleHelpScreen();
|
|
||||||
|
|
||||||
void setWorldPaused(bool b) { worldPaused = b; }
|
void setWorldPaused(bool b) { worldPaused = b; }
|
||||||
bool isWorldPaused() const { return worldPaused; }
|
bool isWorldPaused() const { return worldPaused; }
|
||||||
|
|
||||||
|
void setIgnoreAction(AquariaActions ac, bool ignore);
|
||||||
|
bool isIgnoreAction(AquariaActions ac) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void toggleHelpScreen(bool on, const std::string &label="");
|
||||||
|
void onToggleHelpScreen();
|
||||||
|
|
||||||
void onHelpUp();
|
void onHelpUp();
|
||||||
void onHelpDown();
|
void onHelpDown();
|
||||||
bool helpWasPaused;
|
bool helpWasPaused;
|
||||||
|
@ -1181,9 +1186,6 @@ protected:
|
||||||
void toggleSceneEditor();
|
void toggleSceneEditor();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signed char grid[MAX_GRID][MAX_GRID];
|
signed char grid[MAX_GRID][MAX_GRID];
|
||||||
|
|
||||||
|
|
||||||
|
@ -1197,10 +1199,10 @@ protected:
|
||||||
|
|
||||||
std::string selectedChoice;
|
std::string selectedChoice;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void warpCameraTo(Vector position);
|
void warpCameraTo(Vector position);
|
||||||
|
|
||||||
|
std::set<int> ignoredActions;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ingredients ingredients;
|
Ingredients ingredients;
|
||||||
};
|
};
|
||||||
|
|
|
@ -357,7 +357,7 @@ void MiniMapRender::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
doubleClickDelay = 0;
|
doubleClickDelay = 0;
|
||||||
if (!core->isStateJumpPending())
|
if (!core->isStateJumpPending())
|
||||||
dsq->game->showInGameMenu();
|
dsq->game->action(ACTION_TOGGLEMENU, 1);
|
||||||
btn = true;
|
btn = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1673,6 +1673,30 @@ luaFunc(debugBreak)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(setIgnoreAction)
|
||||||
|
{
|
||||||
|
dsq->game->setIgnoreAction((AquariaActions)lua_tointeger(L, 1), getBool(L, 2));
|
||||||
|
luaReturnNil();
|
||||||
|
}
|
||||||
|
|
||||||
|
luaFunc(isIgnoreAction)
|
||||||
|
{
|
||||||
|
luaReturnBool(dsq->game->isIgnoreAction((AquariaActions)lua_tointeger(L, 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
luaFunc(sendAction)
|
||||||
|
{
|
||||||
|
AquariaActions ac = (AquariaActions)lua_tointeger(L, 1);
|
||||||
|
int state = lua_tointeger(L, 2);
|
||||||
|
int mask = lua_tointeger(L, 3);
|
||||||
|
if(!mask)
|
||||||
|
mask = -1;
|
||||||
|
if(mask & 1)
|
||||||
|
dsq->game->action(ac, state);
|
||||||
|
if((mask & 2) && dsq->game->avatar)
|
||||||
|
dsq->game->avatar->action(ac, state);
|
||||||
|
luaReturnNil();
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(randRange)
|
luaFunc(randRange)
|
||||||
{
|
{
|
||||||
|
@ -8044,6 +8068,9 @@ static const struct {
|
||||||
{"loadfile", l_loadfile_caseinsensitive},
|
{"loadfile", l_loadfile_caseinsensitive},
|
||||||
|
|
||||||
luaRegister(debugBreak),
|
luaRegister(debugBreak),
|
||||||
|
luaRegister(setIgnoreAction),
|
||||||
|
luaRegister(isIgnoreAction),
|
||||||
|
luaRegister(sendAction),
|
||||||
|
|
||||||
luaRegister(shakeCamera),
|
luaRegister(shakeCamera),
|
||||||
luaRegister(upgradeHealth),
|
luaRegister(upgradeHealth),
|
||||||
|
|
|
@ -865,7 +865,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper()
|
||||||
|
|
||||||
void WorldMapRender::onToggleHelpScreen()
|
void WorldMapRender::onToggleHelpScreen()
|
||||||
{
|
{
|
||||||
game->onToggleHelpScreen();
|
game->toggleHelpScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldMapRender::bindInput()
|
void WorldMapRender::bindInput()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue