1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-03 18:14:01 +00:00

Can now quit the intro sequence on Esc (finally!)

Apparently this was planned, but never worked.
Also removed watch() canQuit parameter because during watch(),
input is disabled.
Moved the quitting logic to DSQ::run() and added the canQuit param there.
Game still didn't get the ACTION_ESC for some reason so an extra check for
a raw Esc keypress seems like a good solution.

Game scripts calling watch() and watchForVoice() never used the canQuit
parameter (presumably because it was broken?) so i've felt it's an ok
thing to take it out completely.
This commit is contained in:
fgenesis 2023-06-01 02:31:50 +02:00
parent 1743e1a996
commit ccd22f2015
5 changed files with 35 additions and 72 deletions

View file

@ -30,9 +30,7 @@ BitBlotLogo::BitBlotLogo() : StateObject()
bool BitBlotLogo::watchQuit(float time) bool BitBlotLogo::watchQuit(float time)
{ {
core->run(time); return dsq->run(time, false, true);
return false;
} }
void BitBlotLogo::doShortBitBlot() void BitBlotLogo::doShortBitBlot()
@ -55,23 +53,15 @@ void BitBlotLogo::doShortBitBlot()
logo->scale = Vector(0.6f,0.6f); logo->scale = Vector(0.6f,0.6f);
addRenderObject(logo, LR_HUD); addRenderObject(logo, LR_HUD);
core->run(1.5); if(watchQuit(1.5f))
return;
dsq->overlay2->alpha.interpolateTo(1, 0.5f); dsq->overlay2->alpha.interpolateTo(1, 0.5f);
core->run(0.5); watchQuit(0.5f);
}
void BitBlotLogo::skipLogo()
{
quitFlag = 2;
doShortBitBlot();
getOut();
} }
void BitBlotLogo::getOut() void BitBlotLogo::getOut()
{ {
#ifdef AQUARIA_DEMO #ifdef AQUARIA_DEMO
dsq->title(); dsq->title();
#else #else
@ -83,10 +73,14 @@ void BitBlotLogo::getOut()
} }
void BitBlotLogo::applyState() void BitBlotLogo::applyState()
{
showSequence();
getOut();
}
void BitBlotLogo::showSequence()
{ {
StateObject::applyState(); StateObject::applyState();
quitFlag = 0;
logo = 0;
dsq->toggleCursor(0); dsq->toggleCursor(0);
dsq->toggleBlackBars(1); dsq->toggleBlackBars(1);
@ -94,15 +88,7 @@ void BitBlotLogo::applyState()
if (dsq->user.demo.shortLogos) if (dsq->user.demo.shortLogos)
{ {
skipLogo(); doShortBitBlot();
return;
}
logo = 1;
if (core->getKeyState(KEY_ESCAPE))
{
skipLogo();
return; return;
} }
@ -287,12 +273,6 @@ void BitBlotLogo::applyState()
dsq->overlay2->alpha.interpolateTo(1, 2); dsq->overlay2->alpha.interpolateTo(1, 2);
if (watchQuit(2.0)) return; if (watchQuit(2.0)) return;
getOut();
} }
void BitBlotLogo::removeState() void BitBlotLogo::removeState()

View file

@ -3540,55 +3540,41 @@ bool DSQ::isQuitFlag()
return watchQuitFlag; return watchQuitFlag;
} }
void DSQ::run(float runTime /* = -1 */, bool skipRecurseCheck) bool DSQ::run(float runTime /* = -1 */, bool skipRecurseCheck, bool canQuit)
{ {
if(isDeveloperKeys() && isNested() && !skipRecurseCheck) if(isDeveloperKeys() && isNested() && !skipRecurseCheck)
errorLog("Warning: Nesting recursive main()"); errorLog("Warning: Nesting recursive main()");
watchQuitFlag = false;
watchForQuit = canQuit;
Core::run(runTime); Core::run(runTime);
bool ret = canQuit && watchQuitFlag;
watchForQuit = false;
return ret;
} }
void DSQ::watch(float t, int canQuit) void DSQ::watch(float t)
{ {
watchQuitFlag = false; watchQuitFlag = false;
watchForQuit = false; watchForQuit = false;
bool wasInputEnabled = false; bool wasInputEnabled = game && game->avatar && game->avatar->isInputEnabled();
if (game && game->avatar)
{
wasInputEnabled = game->avatar->isInputEnabled();
if (wasInputEnabled) if (wasInputEnabled)
{
game->avatar->disableInput(); game->avatar->disableInput();
}
}
quitNestedMain(); quitNestedMain();
if (canQuit)
{
watchForQuit = true;
}
if (t != 0.0f) if (t != 0.0f)
run(t); run(t);
else else
errorLog("Called Watch with time == 0"); errorLog("Called Watch with time == 0");
if (canQuit && watchQuitFlag) if (wasInputEnabled && game && game->avatar)
{
// did it!
}
watchForQuit = false;
if (game && game->avatar)
{
if (wasInputEnabled)
game->avatar->enableInput(); game->avatar->enableInput();
}
} }
void DSQ::action(int id, int state, int source, InputDevice device) void DSQ::action(int id, int state, int source, InputDevice device)
@ -3752,7 +3738,7 @@ void DSQ::onUpdate(float dt)
if (game && watchForQuit && isNested()) if (game && watchForQuit && isNested())
{ {
if (game->isActing(ACTION_ESC, -1)) if (game->isActing(ACTION_ESC, -1) || getKeyState(KEY_ESCAPE))
{ {
watchQuitFlag = true; watchQuitFlag = true;
quitNestedMain(); quitNestedMain();

View file

@ -299,8 +299,9 @@ public:
void rumble(float leftMotor, float rightMotor, float time, int source, InputDevice device); void rumble(float leftMotor, float rightMotor, float time, int source, InputDevice device);
void vision(std::string folder, int num, bool ignoreMusic = false); void vision(std::string folder, int num, bool ignoreMusic = false);
void run(float runTime = -1, bool skipRecurseCheck = false); // same as Core::run() but with recursion check // returns true if quit early
void watch(float t, int canQuit = 0); bool run(float runTime = -1, bool skipRecurseCheck = false, bool canQuit = false); // same as Core::run() but with recursion check
void watch(float t);
UserSettings user, user_backup, user_bcontrol; UserSettings user, user_backup, user_bcontrol;

View file

@ -4329,11 +4329,10 @@ luaFunc(entity_watchForPath)
luaFunc(watchForVoice) luaFunc(watchForVoice)
{ {
int quit = lua_tointeger(L, 1);
while (dsq->sound->isPlayingVoice()) while (dsq->sound->isPlayingVoice())
{ {
dsq->watch(FRAME_TIME, quit); dsq->watch(FRAME_TIME);
if (quit && dsq->isQuitFlag()) if (dsq->isQuitFlag())
{ {
dsq->sound->stopVoice(); dsq->sound->stopVoice();
break; break;
@ -7218,8 +7217,7 @@ luaFunc(entity_getPushDamage)
luaFunc(watch) luaFunc(watch)
{ {
float t = lua_tonumber(L, 1); float t = lua_tonumber(L, 1);
int quit = lua_tointeger(L, 2); dsq->watch(t);
dsq->watch(t, quit);
luaReturnNil(); luaReturnNil();
} }

View file

@ -61,12 +61,10 @@ public:
void doShortBitBlot(); void doShortBitBlot();
void getOut(); void getOut();
void skipLogo();
bool watchQuit(float time); bool watchQuit(float time);
protected: private:
int quitFlag; void showSequence();
int logo;
}; };
class Hair; class Hair;