mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +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:
parent
1743e1a996
commit
ccd22f2015
5 changed files with 35 additions and 72 deletions
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
||||
if (game && game->avatar)
|
||||
{
|
||||
wasInputEnabled = game->avatar->isInputEnabled();
|
||||
bool wasInputEnabled = game && game->avatar && game->avatar->isInputEnabled();
|
||||
|
||||
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)
|
||||
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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue