diff --git a/Aquaria/BitBlotLogo.cpp b/Aquaria/BitBlotLogo.cpp index 62a51ac..28475d9 100644 --- a/Aquaria/BitBlotLogo.cpp +++ b/Aquaria/BitBlotLogo.cpp @@ -30,9 +30,7 @@ BitBlotLogo::BitBlotLogo() : StateObject() bool BitBlotLogo::watchQuit(float time) { - core->run(time); - return false; - + return dsq->run(time, false, true); } void BitBlotLogo::doShortBitBlot() @@ -55,23 +53,15 @@ void BitBlotLogo::doShortBitBlot() logo->scale = Vector(0.6f,0.6f); addRenderObject(logo, LR_HUD); - core->run(1.5); + if(watchQuit(1.5f)) + return; dsq->overlay2->alpha.interpolateTo(1, 0.5f); - core->run(0.5); -} - -void BitBlotLogo::skipLogo() -{ - quitFlag = 2; - doShortBitBlot(); - getOut(); + watchQuit(0.5f); } void BitBlotLogo::getOut() { - - #ifdef AQUARIA_DEMO dsq->title(); #else @@ -83,10 +73,14 @@ void BitBlotLogo::getOut() } void BitBlotLogo::applyState() +{ + showSequence(); + getOut(); +} + +void BitBlotLogo::showSequence() { StateObject::applyState(); - quitFlag = 0; - logo = 0; dsq->toggleCursor(0); dsq->toggleBlackBars(1); @@ -94,15 +88,7 @@ void BitBlotLogo::applyState() if (dsq->user.demo.shortLogos) { - skipLogo(); - return; - } - - logo = 1; - - if (core->getKeyState(KEY_ESCAPE)) - { - skipLogo(); + doShortBitBlot(); return; } @@ -287,12 +273,6 @@ void BitBlotLogo::applyState() dsq->overlay2->alpha.interpolateTo(1, 2); if (watchQuit(2.0)) return; - - - getOut(); - - - } void BitBlotLogo::removeState() diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 2d1bc77..b2c45f8 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -3540,55 +3540,41 @@ bool DSQ::isQuitFlag() return watchQuitFlag; } -void DSQ::run(float runTime /* = -1 */, bool skipRecurseCheck) +bool DSQ::run(float runTime /* = -1 */, bool skipRecurseCheck, bool canQuit) { if(isDeveloperKeys() && isNested() && !skipRecurseCheck) errorLog("Warning: Nesting recursive main()"); + watchQuitFlag = false; + watchForQuit = canQuit; + 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; watchForQuit = false; - bool wasInputEnabled = false; + bool wasInputEnabled = game && game->avatar && game->avatar->isInputEnabled(); - if (game && game->avatar) - { - wasInputEnabled = game->avatar->isInputEnabled(); - - if (wasInputEnabled) - { - game->avatar->disableInput(); - } - } + if (wasInputEnabled) + game->avatar->disableInput(); quitNestedMain(); - if (canQuit) - { - watchForQuit = true; - } - if (t != 0.0f) run(t); else errorLog("Called Watch with time == 0"); - if (canQuit && watchQuitFlag) - { - // did it! - } - - watchForQuit = false; - - if (game && game->avatar) - { - if (wasInputEnabled) - game->avatar->enableInput(); - } + if (wasInputEnabled && game && game->avatar) + game->avatar->enableInput(); } 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->isActing(ACTION_ESC, -1)) + if (game->isActing(ACTION_ESC, -1) || getKeyState(KEY_ESCAPE)) { watchQuitFlag = true; quitNestedMain(); diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 033eda1..584ffb7 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -299,8 +299,9 @@ public: void rumble(float leftMotor, float rightMotor, float time, int source, InputDevice device); 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 - void watch(float t, int canQuit = 0); + // returns true if quit early + 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; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index eb20ebc..1db3aea 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -4329,11 +4329,10 @@ luaFunc(entity_watchForPath) luaFunc(watchForVoice) { - int quit = lua_tointeger(L, 1); while (dsq->sound->isPlayingVoice()) { - dsq->watch(FRAME_TIME, quit); - if (quit && dsq->isQuitFlag()) + dsq->watch(FRAME_TIME); + if (dsq->isQuitFlag()) { dsq->sound->stopVoice(); break; @@ -7218,8 +7217,7 @@ luaFunc(entity_getPushDamage) luaFunc(watch) { float t = lua_tonumber(L, 1); - int quit = lua_tointeger(L, 2); - dsq->watch(t, quit); + dsq->watch(t); luaReturnNil(); } diff --git a/Aquaria/States.h b/Aquaria/States.h index f07e5f3..030a863 100644 --- a/Aquaria/States.h +++ b/Aquaria/States.h @@ -61,12 +61,10 @@ public: void doShortBitBlot(); void getOut(); - void skipLogo(); bool watchQuit(float time); -protected: - int quitFlag; - int logo; +private: + void showSequence(); }; class Hair;