- added a 'Start' method to DScreenJob.

Since the menu pauses the ticker this is needed to perform initial setup before the first frame.
This commit is contained in:
Christoph Oelckers 2021-04-16 23:29:53 +02:00
parent 49e07a47c6
commit 2b9a527aba
7 changed files with 77 additions and 56 deletions

View file

@ -176,6 +176,7 @@ public:
if (index < jobs.Size()) if (index < jobs.Size())
{ {
jobs[index].job->fadestate = !paused && jobs[index].job->fadestyle & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible; jobs[index].job->fadestate = !paused && jobs[index].job->fadestyle & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible;
jobs[index].job->Start();
} }
inputState.ClearAllInput(); inputState.ClearAllInput();
} }

View file

@ -44,6 +44,7 @@ public:
return false; return false;
} }
virtual void Start() {}
virtual bool OnEvent(event_t* evt) { return false; } virtual bool OnEvent(event_t* evt) { return false; }
virtual void OnTick() { /*state = finished;*/ } virtual void OnTick() { /*state = finished;*/ }
virtual void Draw(double smoothratio) {} virtual void Draw(double smoothratio) {}

View file

@ -729,9 +729,9 @@ public:
playerswhenstarted = pws; playerswhenstarted = pws;
} }
void OnTick() override void Start() override
{ {
if (ticks == 1) S_PlayBonusMusic(); S_PlayBonusMusic();
} }
void Draw(double smoothratio) override void Draw(double smoothratio) override
@ -879,9 +879,13 @@ public:
return false; return false;
} }
void Start() override
{
S_PlayBonusMusic();
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1) S_PlayBonusMusic();
if ((displaystate & printStatsAll) != printStatsAll) if ((displaystate & printStatsAll) != printStatsAll)
{ {
if (ticks == 15 * 3) if (ticks == 15 * 3)

View file

@ -265,11 +265,12 @@ public:
playerswhenstarted = pws; playerswhenstarted = pws;
} }
void OnTick() override void Start() override
{ {
if (ticks == 1) S_PlayBonusMusic(); S_PlayBonusMusic();
} }
void Draw(double) override void Draw(double) override
{ {
char tempbuf[32]; char tempbuf[32];
@ -419,9 +420,13 @@ public:
return false; return false;
} }
void Start() override
{
S_PlayBonusMusic();
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1) S_PlayBonusMusic();
if ((displaystate & printStatsAll) != printStatsAll) if ((displaystate & printStatsAll) != printStatsAll)
{ {
if (ticks == 15 * 3) if (ticks == 15 * 3)
@ -565,9 +570,13 @@ public:
S_StopSound(35); S_StopSound(35);
} }
void Start() override
{
S_PlaySound(35, CHAN_AUTO, CHANF_UI);
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1) S_PlaySound(35, CHAN_AUTO, CHANF_UI);
if (!S_CheckSoundPlaying(-1, 35) && ticks > 15 * GameTicRate) state = finished; // make sure it stays, even if sound is off. if (!S_CheckSoundPlaying(-1, 35) && ticks > 15 * GameTicRate) state = finished; // make sure it stays, even if sound is off.
} }
void Draw(double) override void Draw(double) override

View file

@ -389,9 +389,13 @@ public:
StopLocalSound(); StopLocalSound();
} }
void Start() override
{
PlayLocalSound(StaticSound[kSoundJonLaugh2], 7000, false, CHANF_UI);
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1) PlayLocalSound(StaticSound[kSoundJonLaugh2], 7000, false, CHANF_UI);
DImageScreen::OnTick(); DImageScreen::OnTick();
if (state == finished) StopLocalSound(); if (state == finished) StopLocalSound();
@ -426,14 +430,15 @@ public:
duration = skullDurations[0]; duration = skullDurations[0];
} }
void Start() override
{
PlayLocalSound(StaticSound[59], 0, true, CHANF_UI);
playCDtrack(19, true);
}
void OnTick() override void OnTick() override
{ {
int ticker = ticks * 120 / GameTicRate; int ticker = ticks * 120 / GameTicRate;
if (ticks == 1)
{
PlayLocalSound(StaticSound[59], 0, true, CHANF_UI);
playCDtrack(19, true);
}
if (ticks > 1 && state == 0 && !soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_AUTO, -1)) if (ticks > 1 && state == 0 && !soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_AUTO, -1))
{ {
if (time(0) & 0xF) // cheap-ass random... if (time(0) & 0xF) // cheap-ass random...
@ -985,24 +990,24 @@ public:
check = checklevel; check = checklevel;
} }
void OnTick() override void Start() override
{ {
if (ticks == 1) if (check > 0 && check != selectedlevelnew)
{ {
if (check > 0 && check != selectedlevelnew) state = finished;
{ return; // immediately abort if the player selected a different level on the map
state = finished;
return; // immediately abort if the player selected a different level on the map
}
check = -1;
StopAllSounds();
if (edx != -1)
{
playCDtrack(edx + 2, false);
}
} }
check = -1;
StopAllSounds();
if (edx != -1)
{
playCDtrack(edx + 2, false);
}
}
void OnTick() override
{
if (!cont) if (!cont)
{ {
state = finished; state = finished;
@ -1018,7 +1023,7 @@ public:
void Draw(double smoothratio) override void Draw(double smoothratio) override
{ {
twod->ClearScreen(); twod->ClearScreen();
if (check < 0) return; if (check == 0) return;
DrawTexture(twod, tileGetTexture(cinematile), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, TRANSLATION(Translation_BasePalettes, currentCinemaPalette), TAG_DONE); DrawTexture(twod, tileGetTexture(cinematile), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, TRANSLATION(Translation_BasePalettes, currentCinemaPalette), TAG_DONE);
text.DisplayText(); text.DisplayText();
@ -1162,14 +1167,14 @@ private:
return true; return true;
} }
void Start() override
{
PlayLocalSound(StaticSound[kSound75], 0, false, CHANF_UI);
phase = 1;
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1)
{
PlayLocalSound(StaticSound[kSound75], 0, false, CHANF_UI);
phase = 1;
}
switch (phase) switch (phase)
{ {
case 1: case 1:
@ -1264,20 +1269,20 @@ public:
return true; return true;
} }
void Start() override
{
if (credits.Size() == 0)
{
state = finished;
return;
}
playCDtrack(19, false);
pagetime = 0;
page = -1;
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1)
{
if (credits.Size() == 0)
{
state = finished;
return;
}
playCDtrack(19, false);
pagetime = 0;
page = -1;
}
if (ticks >= pagetime || skiprequest) if (ticks >= pagetime || skiprequest)
{ {
page++; page++;

View file

@ -271,7 +271,6 @@ public:
DScreenJob* PlayMovie(const char* fileName) DScreenJob* PlayMovie(const char* fileName)
{ {
// clear keys // clear keys
inputState.ClearAllInput();
auto fp = fileSystem.OpenFileReader(fileName); auto fp = fileSystem.OpenFileReader(fileName);
if (!fp.isOpen()) if (!fp.isOpen())

View file

@ -185,13 +185,14 @@ class DSWCreditsScreen : public DSkippableScreenJob
StopSound(); StopSound();
} }
void Start() override
{
// Lo Wang feel like singing!
PlaySound(DIGI_JG95012, v3df_none, CHAN_VOICE, CHANF_UI);
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1)
{
// Lo Wang feel like singing!
PlaySound(DIGI_JG95012, v3df_none, CHAN_VOICE, CHANF_UI);
}
if (state == 0) if (state == 0)
{ {
if (!soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) if (!soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE))
@ -400,12 +401,13 @@ private:
return true; return true;
} }
void Start() override
{
PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]);
}
void OnTick() override void OnTick() override
{ {
if (ticks == 1)
{
PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]);
}
while (ticks > nextclock) while (ticks > nextclock)
{ {
nextclock++; nextclock++;