- 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())
{
jobs[index].job->fadestate = !paused && jobs[index].job->fadestyle & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible;
jobs[index].job->Start();
}
inputState.ClearAllInput();
}

View file

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

View file

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

View file

@ -265,11 +265,12 @@ public:
playerswhenstarted = pws;
}
void OnTick() override
void Start() override
{
if (ticks == 1) S_PlayBonusMusic();
S_PlayBonusMusic();
}
void Draw(double) override
{
char tempbuf[32];
@ -419,9 +420,13 @@ public:
return false;
}
void Start() override
{
S_PlayBonusMusic();
}
void OnTick() override
{
if (ticks == 1) S_PlayBonusMusic();
if ((displaystate & printStatsAll) != printStatsAll)
{
if (ticks == 15 * 3)
@ -565,9 +570,13 @@ public:
S_StopSound(35);
}
void Start() override
{
S_PlaySound(35, CHAN_AUTO, CHANF_UI);
}
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.
}
void Draw(double) override

View file

@ -389,9 +389,13 @@ public:
StopLocalSound();
}
void Start() override
{
PlayLocalSound(StaticSound[kSoundJonLaugh2], 7000, false, CHANF_UI);
}
void OnTick() override
{
if (ticks == 1) PlayLocalSound(StaticSound[kSoundJonLaugh2], 7000, false, CHANF_UI);
DImageScreen::OnTick();
if (state == finished) StopLocalSound();
@ -426,14 +430,15 @@ public:
duration = skullDurations[0];
}
void Start() override
{
PlayLocalSound(StaticSound[59], 0, true, CHANF_UI);
playCDtrack(19, true);
}
void OnTick() override
{
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 (time(0) & 0xF) // cheap-ass random...
@ -985,24 +990,24 @@ public:
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
}
check = -1;
StopAllSounds();
if (edx != -1)
{
playCDtrack(edx + 2, false);
}
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);
}
}
void OnTick() override
{
if (!cont)
{
state = finished;
@ -1018,7 +1023,7 @@ public:
void Draw(double smoothratio) override
{
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);
text.DisplayText();
@ -1162,14 +1167,14 @@ private:
return true;
}
void Start() override
{
PlayLocalSound(StaticSound[kSound75], 0, false, CHANF_UI);
phase = 1;
}
void OnTick() override
{
if (ticks == 1)
{
PlayLocalSound(StaticSound[kSound75], 0, false, CHANF_UI);
phase = 1;
}
switch (phase)
{
case 1:
@ -1264,20 +1269,20 @@ public:
return true;
}
void Start() override
{
if (credits.Size() == 0)
{
state = finished;
return;
}
playCDtrack(19, false);
pagetime = 0;
page = -1;
}
void OnTick() override
{
if (ticks == 1)
{
if (credits.Size() == 0)
{
state = finished;
return;
}
playCDtrack(19, false);
pagetime = 0;
page = -1;
}
if (ticks >= pagetime || skiprequest)
{
page++;

View file

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

View file

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