mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- changed screen job list to work without per-job completion callbacks.
They made things more complex than necessary and do not translate well to scripting.
This commit is contained in:
parent
fb5e2fe0c0
commit
71e5f9b70f
6 changed files with 107 additions and 50 deletions
|
@ -56,6 +56,11 @@
|
|||
IMPLEMENT_CLASS(DScreenJob, true, false)
|
||||
IMPLEMENT_CLASS(DImageScreen, true, false)
|
||||
|
||||
void DScreenJob::OnDestroy()
|
||||
{
|
||||
if (flags & stopmusic) Mus_Stop();
|
||||
if (flags & stopsound) FX_StopAllSounds();
|
||||
}
|
||||
|
||||
bool DSkippableScreenJob::OnEvent(event_t* evt)
|
||||
{
|
||||
|
@ -164,7 +169,7 @@ public:
|
|||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
if (jobs[index].postAction) jobs[index].postAction();
|
||||
//if (jobs[index].postAction) jobs[index].postAction();
|
||||
jobs[index].job->Destroy();
|
||||
}
|
||||
index++;
|
||||
|
@ -176,7 +181,7 @@ public:
|
|||
actionState = clearbefore ? State_Clear : State_Run;
|
||||
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->flags & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible;
|
||||
jobs[index].job->Start();
|
||||
}
|
||||
inputState.ClearAllInput();
|
||||
|
@ -289,7 +294,7 @@ public:
|
|||
if (terminateState < 1)
|
||||
{
|
||||
// Must lock before displaying.
|
||||
if (jobs[index].job->fadestyle & DScreenJob::fadeout)
|
||||
if (jobs[index].job->flags & DScreenJob::fadeout)
|
||||
{
|
||||
jobs[index].job->fadestate = DScreenJob::fadeout;
|
||||
jobs[index].job->state = DScreenJob::stopping;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "dobject.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "d_eventbase.h"
|
||||
#include "s_soundinternal.h"
|
||||
|
||||
using CompletionFunc = std::function<void(bool)>;
|
||||
struct JobDesc;
|
||||
|
@ -11,7 +12,7 @@ class ScreenJobRunner;
|
|||
class DScreenJob : public DObject
|
||||
{
|
||||
DECLARE_CLASS(DScreenJob, DObject)
|
||||
const int fadestyle;
|
||||
const int flags;
|
||||
const float fadetime; // in milliseconds
|
||||
int fadestate = fadein;
|
||||
|
||||
|
@ -35,9 +36,11 @@ public:
|
|||
visible = 0,
|
||||
fadein = 1,
|
||||
fadeout = 2,
|
||||
stopmusic = 4,
|
||||
stopsound = 8,
|
||||
};
|
||||
|
||||
DScreenJob(int fade = 0, float fadet = 250.f) : fadestyle(fade), fadetime(fadet) {}
|
||||
DScreenJob(int fade = 0, float fadet = 250.f) : flags(fade), fadetime(fadet) {}
|
||||
|
||||
virtual bool ProcessInput()
|
||||
{
|
||||
|
@ -60,6 +63,7 @@ public:
|
|||
|
||||
int GetFadeState() const { return fadestate; }
|
||||
|
||||
virtual void OnDestroy() override;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -90,7 +94,7 @@ class DBlackScreen : public DScreenJob
|
|||
bool cleared = false;
|
||||
|
||||
public:
|
||||
DBlackScreen(int w) : wait(w) {}
|
||||
DBlackScreen(int w, int flags = 0) : DScreenJob(flags & ~(fadein|fadeout)), wait(w) {}
|
||||
void OnTick() override;
|
||||
void Draw(double smooth) override;
|
||||
};
|
||||
|
@ -134,8 +138,7 @@ public:
|
|||
struct JobDesc
|
||||
{
|
||||
DScreenJob* job;
|
||||
void (*postAction)();
|
||||
//bool ignoreifskipped;
|
||||
//void (*postAction)();
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -36,6 +36,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
class DBloodIntroImage : public DImageScreen
|
||||
{
|
||||
bool mus;
|
||||
|
||||
public:
|
||||
DBloodIntroImage(int tilenum, int flags = 0, bool withmusic = false) : DImageScreen(tilenum, flags), mus(withmusic)
|
||||
{}
|
||||
|
||||
void Start() override
|
||||
{
|
||||
sndStartSample("THUNDER2", 128, -1);
|
||||
if (mus) sndPlaySpecialMusicOrNothing(MUS_INTRO);
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -70,8 +84,7 @@ void playlogos()
|
|||
}
|
||||
else
|
||||
{
|
||||
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); } };
|
||||
jobs[job++] = { Create<DImageScreen>(2050) };
|
||||
jobs[job++] = { Create<DBloodIntroImage>(2050) };
|
||||
}
|
||||
if (fileSystem.FindFile("gti.smk") != -1)
|
||||
{
|
||||
|
@ -79,12 +92,11 @@ void playlogos()
|
|||
}
|
||||
else
|
||||
{
|
||||
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); } };
|
||||
jobs[job++] = { Create<DImageScreen>(2052) };
|
||||
jobs[job++] = { Create<DBloodIntroImage>(2052) };
|
||||
}
|
||||
}
|
||||
jobs[job++] = { Create<DBlackScreen>(1), []() { sndPlaySpecialMusicOrNothing(MUS_INTRO); sndStartSample("THUNDER2", 128, -1); }};
|
||||
jobs[job++] = { Create<DImageScreen>(2518, DScreenJob::fadein) };
|
||||
jobs[job++] = { Create<DBlackScreen>(1) };
|
||||
jobs[job++] = { Create<DBloodIntroImage>(2518, DScreenJob::fadein, true) };
|
||||
|
||||
RunScreenJob(jobs, job, [](bool) {
|
||||
Mus_Stop();
|
||||
|
|
|
@ -170,6 +170,11 @@ class DDRealmsScreen : public DSkippableScreenJob
|
|||
public:
|
||||
DDRealmsScreen() : DSkippableScreenJob(fadein | fadeout) {}
|
||||
|
||||
void Start() override
|
||||
{
|
||||
S_PlaySpecialMusic(MUS_INTRO);
|
||||
}
|
||||
|
||||
void OnTick() override
|
||||
{
|
||||
if (ticks >= 7 * GameTicRate) state = finished;
|
||||
|
@ -200,6 +205,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void Start() override
|
||||
{
|
||||
if (isNam() || userConfig.nologo) S_PlaySpecialMusic(MUS_INTRO);
|
||||
}
|
||||
|
||||
void OnTick() override
|
||||
{
|
||||
int clock = ticks * 120 / GameTicRate;
|
||||
|
@ -276,6 +286,11 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy() override
|
||||
{
|
||||
S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -301,12 +316,10 @@ void Logo_d(const CompletionFunc &completion)
|
|||
int job = 0;
|
||||
if (!userConfig.nologo)
|
||||
{
|
||||
if (!isShareware()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
|
||||
else jobs[job++] = { Create<DBlackScreen>(1), []() { S_PlaySpecialMusic(MUS_INTRO); } };
|
||||
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
|
||||
if (!isShareware()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes) };
|
||||
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), };
|
||||
}
|
||||
else S_PlaySpecialMusic(MUS_INTRO);
|
||||
jobs[job++] = { Create<DTitleScreen>(), []() { S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI); } };
|
||||
jobs[job++] = { Create<DTitleScreen>() };
|
||||
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
|
||||
}
|
||||
|
||||
|
@ -422,6 +435,18 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class DE2EndScreen : public DImageScreen
|
||||
{
|
||||
public:
|
||||
DE2EndScreen() : DImageScreen(E2ENDSCREEN, DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff, 0)
|
||||
{}
|
||||
|
||||
void Start() override
|
||||
{
|
||||
S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -513,6 +538,11 @@ public:
|
|||
}
|
||||
if (state != running) FX_StopAllSounds();
|
||||
}
|
||||
|
||||
void OnDestroy() override
|
||||
{
|
||||
if (!isPlutoPak()) S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -535,6 +565,11 @@ public:
|
|||
BigText(160, 70 + 16 + 16 + 16, GStrings("Look for a Duke Nukem 3D"));
|
||||
BigText(160, 70 + 16 + 16 + 16 + 16, GStrings("sequel soon."));
|
||||
}
|
||||
|
||||
void Start() override
|
||||
{
|
||||
S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -548,7 +583,7 @@ class DEpisode5End : public DImageScreen
|
|||
int sound = 0;
|
||||
|
||||
public:
|
||||
DEpisode5End() : DImageScreen(FIREFLYGROWEFFECT, fadein|fadeout)
|
||||
DEpisode5End() : DImageScreen(FIREFLYGROWEFFECT, fadein|fadeout|stopsound)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -644,45 +679,45 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job)
|
|||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
jobs[job++] = { Create<DEpisode1End1>(), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout, 0x7fffffff), []() { Mus_Stop(); } };
|
||||
jobs[job++] = { Create<DEpisode1End1>() };
|
||||
jobs[job++] = { Create<DImageScreen>(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout|DScreenJob::stopmusic, 0x7fffffff) };
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Mus_Stop();
|
||||
jobs[job++] = { PlayVideo("cineov2.anm", cineov2sound, framespeed_18), []() { S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } };
|
||||
jobs[job++] = { Create<DImageScreen>(E2ENDSCREEN, DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff), []() { FX_StopAllSounds(); } };
|
||||
jobs[job++] = { PlayVideo("cineov2.anm", cineov2sound, framespeed_18) };
|
||||
jobs[job++] = { Create<DE2EndScreen>() };
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Mus_Stop();
|
||||
if (g_gameType & GAMEFLAG_DUKEDC)
|
||||
{
|
||||
jobs[job++] = { PlayVideo("radlogo.anm", dukedcsound, framespeed_10), nullptr };
|
||||
jobs[job++] = { PlayVideo("radlogo.anm", dukedcsound, framespeed_10) };
|
||||
}
|
||||
else
|
||||
{
|
||||
jobs[job++] = { PlayVideo("cineov3.anm", cineov3sound, framespeed_10), nullptr };
|
||||
jobs[job++] = { Create<DBlackScreen>(200), []() { FX_StopAllSounds(); } };
|
||||
jobs[job++] = { Create<DEpisode3End>(), []() { if (!isPlutoPak()) S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI); } };
|
||||
jobs[job++] = { PlayVideo("cineov3.anm", cineov3sound, framespeed_10) };
|
||||
jobs[job++] = { Create<DBlackScreen>(200, DScreenJob::stopsound) };
|
||||
jobs[job++] = { Create<DEpisode3End>() };
|
||||
if (!isPlutoPak()) jobs[job++] = { Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup),
|
||||
DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff), []() { FX_StopAllSounds(); } };
|
||||
DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff) };
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Mus_Stop();
|
||||
jobs[job++] = { PlayVideo("vol4e1.anm", vol4e1, framespeed_10), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol4e2.anm", vol4e2, framespeed_10), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol4e3.anm", vol4e3, framespeed_10), []() { S_PlaySound(ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI); } };
|
||||
jobs[job++] = { Create<DEpisode4Text>(), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol4e1.anm", vol4e1, framespeed_10) };
|
||||
jobs[job++] = { PlayVideo("vol4e2.anm", vol4e2, framespeed_10) };
|
||||
jobs[job++] = { PlayVideo("vol4e3.anm", vol4e3, framespeed_10) };
|
||||
jobs[job++] = { Create<DEpisode4Text>() };
|
||||
jobs[job++] = { Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup),
|
||||
DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff), []() { FX_StopAllSounds(); } };
|
||||
DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff) };
|
||||
break;
|
||||
|
||||
case 4:
|
||||
Mus_Stop();
|
||||
jobs[job++] = { Create<DEpisode5End>(), []() { FX_StopAllSounds(); } };
|
||||
jobs[job++] = { Create<DEpisode5End>() };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -698,8 +733,8 @@ void showtwoscreens(const CompletionFunc& completion)
|
|||
JobDesc jobs[2];
|
||||
int job = 0;
|
||||
|
||||
jobs[job++] = { Create<DImageScreen>(3291), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(3290), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(3291) };
|
||||
jobs[job++] = { Create<DImageScreen>(3290) };
|
||||
RunScreenJob(jobs, job, completion);
|
||||
}
|
||||
|
||||
|
@ -709,7 +744,7 @@ void doorders(const CompletionFunc& completion)
|
|||
int job = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
jobs[job++] = { Create<DImageScreen>(ORDERING + i), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(ORDERING + i) };
|
||||
RunScreenJob(jobs, job, completion);
|
||||
}
|
||||
|
||||
|
@ -1128,9 +1163,9 @@ void e4intro(const CompletionFunc& completion)
|
|||
static const int framespeed_14[] = { 14, 14, 14 };
|
||||
|
||||
S_PlaySpecialMusic(MUS_BRIEFING);
|
||||
jobs[job++] = { PlayVideo("vol41a.anm", vol41a, framespeed_10), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10), nullptr };
|
||||
jobs[job++] = { PlayVideo("vol41a.anm", vol41a, framespeed_10) };
|
||||
jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14) };
|
||||
jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10) };
|
||||
RunScreenJob(jobs, job, completion, SJ_SKIPALL);
|
||||
}
|
||||
|
||||
|
|
|
@ -196,13 +196,13 @@ void Logo_r(const CompletionFunc& completion)
|
|||
}
|
||||
else if (!isRRRA())
|
||||
{
|
||||
jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed), nullptr };
|
||||
jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed), nullptr };
|
||||
jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed), nullptr };
|
||||
jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed) };
|
||||
jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed) };
|
||||
jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed) };
|
||||
}
|
||||
else
|
||||
{
|
||||
jobs[job++] = { PlayVideo("redint.mve"), nullptr };
|
||||
jobs[job++] = { PlayVideo("redint.mve") };
|
||||
}
|
||||
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
|
||||
}
|
||||
|
@ -235,13 +235,13 @@ static void bonussequence_r(int num, JobDesc* jobs, int& job)
|
|||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(TENSCREEN), nullptr };
|
||||
jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed) };
|
||||
jobs[job++] = { Create<DImageScreen>(TENSCREEN) };
|
||||
break;
|
||||
|
||||
case 1:
|
||||
jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed), nullptr };
|
||||
jobs[job++] = { Create<DImageScreen>(TENSCREEN), nullptr };
|
||||
jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed) };
|
||||
jobs[job++] = { Create<DImageScreen>(TENSCREEN) };
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -356,6 +356,7 @@ public:
|
|||
seconds = (second_tics % 60);
|
||||
}
|
||||
private:
|
||||
|
||||
static void gNextState(STATE** State)
|
||||
{
|
||||
// Transition to the next state
|
||||
|
@ -403,6 +404,7 @@ private:
|
|||
|
||||
void Start() override
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]);
|
||||
}
|
||||
|
||||
|
@ -610,7 +612,7 @@ void StatScreen(int FinishAnim, CompletionFunc completion)
|
|||
if (FinishAnim)
|
||||
{
|
||||
StopSound();
|
||||
jobs[job++] = { GetFinishAnim(FinishAnim), []() { soundEngine->StopAllChannels(); } };
|
||||
jobs[job++] = { GetFinishAnim(FinishAnim) };
|
||||
jobs[job++] = { Create<DSWLevelSummaryScreen>() };
|
||||
if (FinishAnim == ANIM_ZILLA)
|
||||
jobs[job++] = { Create<DSWCreditsScreen>() };
|
||||
|
|
Loading…
Reference in a new issue