- got rid of JobDesc.

This commit is contained in:
Christoph Oelckers 2021-04-22 00:51:14 +02:00
parent 805b91b721
commit 4a7430c8e4
10 changed files with 165 additions and 174 deletions

View file

@ -117,15 +117,14 @@ void DImageScreen::Draw(double smoothratio)
//
//---------------------------------------------------------------------------
ScreenJobRunner::ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_)
ScreenJobRunner::ScreenJobRunner(TArray<DScreenJob*>& jobs_, CompletionFunc completion_, bool clearbefore_, bool skipall_)
: completion(std::move(completion_)), clearbefore(clearbefore_), skipall(skipall_)
{
jobs.Resize(count);
memcpy(jobs.Data(), jobs_, count * sizeof(JobDesc));
jobs = std::move(jobs_);
// Release all jobs from the garbage collector - the code as it is cannot deal with them getting collected. This should be removed later once the GC is working.
for (int i = 0; i < count; i++)
for (unsigned i = 0; i < jobs.Size(); i++)
{
jobs[i].job->Release();
jobs[i]->Release();
}
AdvanceJob(false);
}
@ -145,8 +144,8 @@ void ScreenJobRunner::DeleteJobs()
{
for (auto& job : jobs)
{
job.job->ObjectFlags |= OF_YesReallyDelete;
delete job.job;
job->ObjectFlags |= OF_YesReallyDelete;
delete job;
}
jobs.Clear();
}
@ -162,19 +161,19 @@ void ScreenJobRunner::AdvanceJob(bool skip)
if (index >= 0)
{
//if (jobs[index].postAction) jobs[index].postAction();
jobs[index].job->Destroy();
jobs[index]->Destroy();
}
index++;
while (index < jobs.Size() && (jobs[index].job == nullptr || (skip && skipall)))
while (index < jobs.Size() && (jobs[index] == nullptr || (skip && skipall)))
{
if (jobs[index].job != nullptr) jobs[index].job->Destroy();
if (jobs[index] != nullptr) jobs[index]->Destroy();
index++;
}
actionState = clearbefore ? State_Clear : State_Run;
if (index < jobs.Size())
{
jobs[index].job->fadestate = !paused && jobs[index].job->flags & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible;
jobs[index].job->Start();
jobs[index]->fadestate = !paused && jobs[index]->flags & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible;
jobs[index]->Start();
}
inputState.ClearAllInput();
}
@ -189,16 +188,16 @@ int ScreenJobRunner::DisplayFrame(double smoothratio)
{
auto& job = jobs[index];
auto now = I_GetTimeNS();
bool processed = job.job->ProcessInput();
bool processed = job->ProcessInput();
if (job.job->fadestate == DScreenJob::fadein)
if (job->fadestate == DScreenJob::fadein)
{
double ms = (job.job->ticks + smoothratio) * 1000 / GameTicRate / job.job->fadetime;
double ms = (job->ticks + smoothratio) * 1000 / GameTicRate / job->fadetime;
float screenfade = (float)clamp(ms, 0., 1.);
twod->SetScreenFade(screenfade);
if (screenfade == 1.f) job.job->fadestate = DScreenJob::visible;
if (screenfade == 1.f) job->fadestate = DScreenJob::visible;
}
int state = job.job->DrawFrame(smoothratio);
int state = job->DrawFrame(smoothratio);
twod->SetScreenFade(1.f);
return state;
}
@ -206,10 +205,10 @@ int ScreenJobRunner::DisplayFrame(double smoothratio)
int ScreenJobRunner::FadeoutFrame(double smoothratio)
{
auto& job = jobs[index];
double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job.job->fadetime;
double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job->fadetime;
float screenfade = 1.f - (float)clamp(ms, 0., 1.);
twod->SetScreenFade(screenfade);
job.job->DrawFrame(1.);
job->DrawFrame(1.);
return (screenfade > 0.f);
}
@ -234,9 +233,9 @@ bool ScreenJobRunner::OnEvent(event_t* ev)
}
}
if (jobs[index].job->state != DScreenJob::running) return false;
if (jobs[index]->state != DScreenJob::running) return false;
return jobs[index].job->OnEvent(ev);
return jobs[index]->OnEvent(ev);
}
void ScreenJobRunner::OnFinished()
@ -258,12 +257,12 @@ void ScreenJobRunner::OnTick()
}
else
{
if (jobs[index].job->state == DScreenJob::running)
if (jobs[index]->state == DScreenJob::running)
{
jobs[index].job->ticks++;
jobs[index].job->OnTick();
jobs[index]->ticks++;
jobs[index]->OnTick();
}
else if (jobs[index].job->state == DScreenJob::stopping)
else if (jobs[index]->state == DScreenJob::stopping)
{
fadeticks++;
}
@ -289,8 +288,8 @@ bool ScreenJobRunner::RunFrame()
// ensure that we won't go back in time if the menu is dismissed without advancing our ticker
bool menuon = paused;
if (menuon) last_paused_tic = jobs[index].job->ticks;
else if (last_paused_tic == jobs[index].job->ticks) menuon = true;
if (menuon) last_paused_tic = jobs[index]->ticks;
else if (last_paused_tic == jobs[index]->ticks) menuon = true;
double smoothratio = menuon ? 1. : I_GetTimeFrac();
if (actionState == State_Clear)
@ -304,10 +303,10 @@ bool ScreenJobRunner::RunFrame()
if (terminateState < 1)
{
// Must lock before displaying.
if (jobs[index].job->flags & DScreenJob::fadeout)
if (jobs[index]->flags & DScreenJob::fadeout)
{
jobs[index].job->fadestate = DScreenJob::fadeout;
jobs[index].job->state = DScreenJob::stopping;
jobs[index]->fadestate = DScreenJob::fadeout;
jobs[index]->state = DScreenJob::stopping;
actionState = State_Fadeout;
fadeticks = 0;
}
@ -322,7 +321,7 @@ bool ScreenJobRunner::RunFrame()
int ended = FadeoutFrame(smoothratio);
if (ended < 1)
{
jobs[index].job->state = DScreenJob::stopped;
jobs[index]->state = DScreenJob::stopped;
AdvanceJob(terminateState < 0);
}
}
@ -337,13 +336,13 @@ bool ScreenJobRunner::RunFrame()
ScreenJobRunner *runner;
void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, int flags)
void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flags)
{
assert(completion != nullptr);
videoclearFade();
if (count)
if (jobs.Size())
{
runner = new ScreenJobRunner(jobs, count, completion, !(flags & SJ_DONTCLEAR), !!(flags & SJ_SKIPALL));
runner = new ScreenJobRunner(jobs, completion, !(flags & SJ_DONTCLEAR), !!(flags & SJ_SKIPALL));
gameaction = (flags & SJ_BLOCKUI)? ga_intro : ga_intermission;
}
else

View file

@ -138,12 +138,6 @@ public:
//
//---------------------------------------------------------------------------
struct JobDesc
{
DScreenJob* job;
};
class ScreenJobRunner
{
enum
@ -152,7 +146,7 @@ class ScreenJobRunner
State_Run,
State_Fadeout
};
TArray<JobDesc> jobs;
TArray<DScreenJob*> jobs;
CompletionFunc completion;
int index = -1;
float screenfade;
@ -164,7 +158,7 @@ class ScreenJobRunner
int last_paused_tic = -1;
public:
ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_);
ScreenJobRunner(TArray<DScreenJob*>& jobs, CompletionFunc completion_, bool clearbefore_, bool skipall_);
~ScreenJobRunner();
void DeleteJobs();
void AdvanceJob(bool skip);
@ -186,7 +180,7 @@ enum
};
void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, int flags = 0);
void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flags = 0);
void EndScreenJob();
void DeleteScreenJob();
bool ScreenJobResponder(event_t* ev);

View file

@ -59,8 +59,7 @@ public:
void playlogos()
{
JobDesc jobs[6];
int job = 0;
TArray<DScreenJob*> jobs;
static AnimSound logosound[] =
{
{ 1, -1 },
@ -80,25 +79,25 @@ void playlogos()
{
if (fileSystem.FindFile("logo.smk") != -1)
{
jobs[job++] = { PlayVideo("logo.smk", &logosound[0], 0) };
jobs.Push(PlayVideo("logo.smk", &logosound[0], 0));
}
else
{
jobs[job++] = { Create<DBloodIntroImage>(2050) };
jobs.Push(Create<DBloodIntroImage>(2050));
}
if (fileSystem.FindFile("gti.smk") != -1)
{
jobs[job++] = { PlayVideo("gti.smk", &logosound[2], 0) };
jobs.Push(PlayVideo("gti.smk", &logosound[2], 0));
}
else
{
jobs[job++] = { Create<DBloodIntroImage>(2052) };
jobs.Push(Create<DBloodIntroImage>(2052));
}
}
jobs[job++] = { Create<DBlackScreen>(1) };
jobs[job++] = { Create<DBloodIntroImage>(2518, DScreenJob::fadein, true) };
jobs.Push(Create<DBlackScreen>(1));
jobs.Push(Create<DBloodIntroImage>(2518, DScreenJob::fadein, true));
RunScreenJob(jobs, job, [](bool) {
RunScreenJob(jobs, [](bool) {
Mus_Stop();
gameaction = ga_mainmenu;
}, SJ_BLOCKUI);
@ -106,7 +105,7 @@ void playlogos()
void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func)
{
JobDesc jobs{};
TArray<DScreenJob*> jobs;
static AnimSound smksound[] =
{
{ 1, -1 },
@ -127,8 +126,8 @@ void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func)
FString smkk = smk;
FixPathSeperator(smkk);
smksound[0].soundnum = id;
jobs.job = PlayVideo(smkk, smksound, nullptr);
RunScreenJob(&jobs, 1, func);
jobs.Push(PlayVideo(smkk, smksound, nullptr));
RunScreenJob(jobs, func);
}
void levelPlayIntroScene(int nEpisode, CompletionFunc completion)

View file

@ -173,10 +173,11 @@ class DBloodSummaryScreen : public DSkippableScreenJob
void GameInterface::LevelCompleted(MapRecord *map, int skill)
{
JobDesc job = { Create<DBloodSummaryScreen>() };
TArray<DScreenJob*> job(1, true);
job[0] = Create<DBloodSummaryScreen>();
sndStartSample(268, 128, -1, false, CHANF_UI);
Mus_Stop();
RunScreenJob(&job, 1, [=](bool)
RunScreenJob(job, [=](bool)
{
soundEngine->StopAllChannels();
gameaction = ga_nextlevel;
@ -301,8 +302,9 @@ public:
void loadscreen(const char *caption, MapRecord* rec, CompletionFunc func)
{
JobDesc job = { Create<DBloodLoadScreen>(caption, rec) };
RunScreenJob(&job, 1, func);
TArray<DScreenJob*> job(1, true);
job[0] = Create<DBloodLoadScreen>(caption, rec);
RunScreenJob(job, func);
}

View file

@ -312,15 +312,15 @@ void Logo_d(const CompletionFunc &completion)
};
static const int logoframetimes[] = { 9, 9, 9 };
JobDesc jobs[3];
TArray<DScreenJob*> jobs;
int job = 0;
if (!userConfig.nologo)
{
if (!isShareware()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes) };
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), };
if (!isShareware()) jobs.Push(PlayVideo("logo.anm", logosound, logoframetimes));
if (!isNam()) jobs.Push(Create<DDRealmsScreen>());
}
jobs[job++] = { Create<DTitleScreen>() };
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
jobs.Push(Create<DTitleScreen>());
RunScreenJob(jobs, completion, SJ_BLOCKUI);
}
//---------------------------------------------------------------------------
@ -612,7 +612,7 @@ public:
//
//---------------------------------------------------------------------------
static void bonussequence_d(int num, JobDesc *jobs, int &job)
static void bonussequence_d(int num, TArray<DScreenJob*>& jobs)
{
static const AnimSound cineov2sound[] =
{
@ -679,45 +679,45 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job)
switch (num)
{
case 0:
jobs[job++] = { Create<DEpisode1End1>() };
jobs[job++] = { Create<DImageScreen>(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout|DScreenJob::stopmusic, 0x7fffffff) };
jobs.Push(Create<DEpisode1End1>());
jobs.Push(Create<DImageScreen>(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout|DScreenJob::stopmusic, 0x7fffffff));
break;
case 1:
Mus_Stop();
jobs[job++] = { PlayVideo("cineov2.anm", cineov2sound, framespeed_18) };
jobs[job++] = { Create<DE2EndScreen>() };
jobs.Push(PlayVideo("cineov2.anm", cineov2sound, framespeed_18));
jobs.Push(Create<DE2EndScreen>());
break;
case 2:
Mus_Stop();
if (g_gameType & GAMEFLAG_DUKEDC)
{
jobs[job++] = { PlayVideo("radlogo.anm", dukedcsound, framespeed_10) };
jobs.Push(PlayVideo("radlogo.anm", dukedcsound, framespeed_10));
}
else
{
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 | DScreenJob::stopsound, 0x7fffffff) };
jobs.Push(PlayVideo("cineov3.anm", cineov3sound, framespeed_10));
jobs.Push(Create<DBlackScreen>(200, DScreenJob::stopsound));
jobs.Push(Create<DEpisode3End>());
if (!isPlutoPak()) jobs.Push(Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup),
DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff));
}
break;
case 3:
Mus_Stop();
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 | DScreenJob::stopsound, 0x7fffffff) };
jobs.Push(PlayVideo("vol4e1.anm", vol4e1, framespeed_10));
jobs.Push(PlayVideo("vol4e2.anm", vol4e2, framespeed_10));
jobs.Push(PlayVideo("vol4e3.anm", vol4e3, framespeed_10));
jobs.Push(Create<DEpisode4Text>());
jobs.Push(Create<DImageScreen>(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup),
DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff));
break;
case 4:
Mus_Stop();
jobs[job++] = { Create<DEpisode5End>() };
jobs.Push(Create<DEpisode5End>());
break;
}
}
@ -730,22 +730,20 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job)
void showtwoscreens(const CompletionFunc& completion)
{
JobDesc jobs[2];
int job = 0;
TArray<DScreenJob*> jobs;
jobs[job++] = { Create<DImageScreen>(3291) };
jobs[job++] = { Create<DImageScreen>(3290) };
RunScreenJob(jobs, job, completion);
jobs.Push(Create<DImageScreen>(3291));
jobs.Push(Create<DImageScreen>(3290));
RunScreenJob(jobs, completion);
}
void doorders(const CompletionFunc& completion)
{
JobDesc jobs[4];
int job = 0;
TArray<DScreenJob*> jobs;
for (int i = 0; i < 4; i++)
jobs[job++] = { Create<DImageScreen>(ORDERING + i) };
RunScreenJob(jobs, job, completion);
jobs.Push(Create<DImageScreen>(ORDERING + i));
RunScreenJob(jobs, completion);
}
//---------------------------------------------------------------------------
@ -1097,29 +1095,28 @@ public:
void dobonus_d(int bonusonly, const CompletionFunc& completion)
{
JobDesc jobs[20];
int job = 0;
TArray<DScreenJob*> jobs;
FX_StopAllSounds();
if (bonusonly < 0 && numplayers < 2 && ud.from_bonus == 0)
{
bonussequence_d(volfromlevelnum(currentLevel->levelNumber), jobs, job);
bonussequence_d(volfromlevelnum(currentLevel->levelNumber), jobs);
}
else
Mus_Stop();
if (playerswhenstarted > 1 && ud.coop != 1)
{
jobs[job++] = { Create<DDukeMultiplayerBonusScreen>(playerswhenstarted) };
jobs.Push(Create<DDukeMultiplayerBonusScreen>(playerswhenstarted));
}
else if (bonusonly <= 0 && ud.multimode <= 1)
{
jobs[job++] = { Create<DDukeLevelSummaryScreen>() };
jobs.Push(Create<DDukeLevelSummaryScreen>());
}
if (job)
if (jobs.Size())
{
RunScreenJob(jobs, job, completion);
RunScreenJob(jobs, completion);
}
else if (completion) completion(false);
}
@ -1132,8 +1129,7 @@ void dobonus_d(int bonusonly, const CompletionFunc& completion)
void e4intro(const CompletionFunc& completion)
{
JobDesc jobs[5];
int job = 0;
TArray<DScreenJob*> jobs;
static const AnimSound vol42a[] =
{
@ -1163,10 +1159,10 @@ 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) };
jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14) };
jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10) };
RunScreenJob(jobs, job, completion, SJ_SKIPALL);
jobs.Push(PlayVideo("vol41a.anm", vol41a, framespeed_10));
jobs.Push(PlayVideo("vol42a.anm", vol42a, framespeed_14));
jobs.Push(PlayVideo("vol43a.anm", vol43a, framespeed_10));
RunScreenJob(jobs, completion, SJ_SKIPALL);
}
//---------------------------------------------------------------------------
@ -1194,8 +1190,10 @@ public:
void loadscreen_d(MapRecord *rec, CompletionFunc func)
{
JobDesc job = { Create<DDukeLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
TArray<DScreenJob*> jobs(1, true);
jobs[0] = Create<DDukeLoadScreen>(rec);
RunScreenJob(jobs, func);
}
void PrintPaused_d()

View file

@ -186,8 +186,7 @@ void Logo_r(const CompletionFunc& completion)
static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims
JobDesc jobs[3];
int job = 0;
TArray<DScreenJob*> jobs;
if (userConfig.nologo)
{
@ -196,15 +195,15 @@ void Logo_r(const CompletionFunc& completion)
}
else if (!isRRRA())
{
jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed) };
jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed) };
jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed) };
jobs.Push(PlayVideo("rr_intro.anm", introsound, framespeed));
jobs.Push(PlayVideo("redneck.anm", rednecksound, framespeed));
jobs.Push(PlayVideo("xatlogo.anm", xatrixsound, framespeed));
}
else
{
jobs[job++] = { PlayVideo("redint.mve") };
jobs.Push(PlayVideo("redint.mve"));
}
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
RunScreenJob(jobs, completion, SJ_BLOCKUI);
}
//---------------------------------------------------------------------------
@ -213,7 +212,7 @@ void Logo_r(const CompletionFunc& completion)
//
//---------------------------------------------------------------------------
static void bonussequence_r(int num, JobDesc* jobs, int& job)
static void bonussequence_r(int num, TArray<DScreenJob*>& jobs)
{
static const AnimSound turdmov[] =
{
@ -235,13 +234,13 @@ static void bonussequence_r(int num, JobDesc* jobs, int& job)
switch (num)
{
case 0:
jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed) };
jobs[job++] = { Create<DImageScreen>(TENSCREEN) };
jobs.Push(PlayVideo("turdmov.anm", turdmov, framespeed));
jobs.Push(Create<DImageScreen>(TENSCREEN));
break;
case 1:
jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed) };
jobs[job++] = { Create<DImageScreen>(TENSCREEN) };
jobs.Push(PlayVideo("rr_outro.anm", rr_outro, framespeed));
jobs.Push(Create<DImageScreen>(TENSCREEN));
break;
default:
@ -594,8 +593,7 @@ public:
void dobonus_r(int bonusonly, const CompletionFunc& completion)
{
JobDesc jobs[20];
int job = 0;
TArray<DScreenJob*> jobs;
FX_StopAllSounds();
Mus_Stop();
@ -603,32 +601,32 @@ void dobonus_r(int bonusonly, const CompletionFunc& completion)
if (bonusonly < 0 && !isRRRA() && numplayers < 2 && ud.from_bonus == 0)
{
int vol = volfromlevelnum(currentLevel->levelNumber);
bonussequence_r(vol, jobs, job);
bonussequence_r(vol, jobs);
}
if (playerswhenstarted > 1 && ud.coop != 1)
{
jobs[job++] = { Create<DRRMultiplayerBonusScreen>(playerswhenstarted) };
jobs.Push(Create<DRRMultiplayerBonusScreen>(playerswhenstarted));
}
else if (bonusonly <= 0 && ud.multimode <= 1)
{
if (isRRRA() && !(currentLevel->flags & MI_USERMAP) && currentLevel->levelNumber < 106) // fixme: The logic here is awful. Shift more control to the map records.
{
jobs[job++] = { Create<DRRLevelSummaryScreen>(true) };
jobs.Push(Create<DRRLevelSummaryScreen>(true));
int levnum = clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13);
char fn[20];
mysnprintf(fn, 20, "lvl%d.anm", levnum + 1);
static const int framespeed[] = { 20, 20, 7200 }; // wait for one minute on the final frame so that the video doesn't stop before the user notices.
jobs[job++] = { PlayVideo(fn, nullptr, framespeed) };
jobs.Push(PlayVideo(fn, nullptr, framespeed));
if (bonusonly < 0 && currentLevel->levelNumber > 100)
{
jobs[job++] = { Create<DRRRAEndOfGame>() };
jobs.Push(Create<DRRRAEndOfGame>());
}
}
else jobs[job++] = { Create<DRRLevelSummaryScreen>(false) };
else jobs.Push(Create<DRRLevelSummaryScreen>(false));
}
if (job)
RunScreenJob(jobs, job, completion);
if (jobs.Size())
RunScreenJob(jobs, completion);
else if (completion) completion(false);
}
@ -658,8 +656,10 @@ public:
void loadscreen_r(MapRecord* rec, CompletionFunc func)
{
JobDesc job = { Create<DRRLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
TArray<DScreenJob*> jobs(1, true);
jobs[0] = Create<DRRLoadScreen>(rec);
RunScreenJob(jobs, func);
}
void PrintPaused_r()

View file

@ -520,15 +520,14 @@ DScreenJob *PlayMovie(const char* fileName);
void DoTitle(CompletionFunc completion)
{
JobDesc jobs[5];
int job = 0;
TArray<DScreenJob*> jobs;
jobs[job++] = { Create<DImageScreen>(tileGetTexture(PublisherLogo()), DScreenJob::fadein | DScreenJob::fadeout) };
jobs[job++] = { Create<DLobotomyScreen>(tileGetTexture(seq_GetSeqPicnum(kSeqScreens, 0, 0)), DScreenJob::fadein | DScreenJob::fadeout) };
jobs[job++] = { PlayMovie("book.mov") };
jobs[job++] = { Create<DMainTitle>() };
jobs.Push(Create<DImageScreen>(tileGetTexture(PublisherLogo()), DScreenJob::fadein | DScreenJob::fadeout));
jobs.Push(Create<DLobotomyScreen>(tileGetTexture(seq_GetSeqPicnum(kSeqScreens, 0, 0)), DScreenJob::fadein | DScreenJob::fadeout));
jobs.Push(PlayMovie("book.mov"));
jobs.Push(Create<DMainTitle>());
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
RunScreenJob(jobs, completion, SJ_BLOCKUI);
}
@ -815,7 +814,7 @@ public:
}
};
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<JobDesc> &jobs)
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<DScreenJob*> &jobs)
{
if (nLevel > kMap20 || nLevelNew > kMap20) // max single player levels
{
@ -829,7 +828,7 @@ public:
if (nLevelNew < 1) nLevelNew = nLevel;
// 0-offset the level numbers
jobs.Push( { Create<DMapScreen>(nLevel-1, nLevelNew-1, nLevelBest-1) });
jobs.Push(Create<DMapScreen>(nLevel-1, nLevelNew-1, nLevelBest-1));
}
//---------------------------------------------------------------------------
@ -1346,37 +1345,37 @@ public:
void DoGameOverScene(bool finallevel)
{
JobDesc job;
TArray<DScreenJob*> jobs(1, true);
if (finallevel)
{
job = { Create<DCinema>(CINEMA_LOSE_SCENE) };
jobs[0] = Create<DCinema>(CINEMA_LOSE_SCENE);
}
else
{
StopCD();
PlayGameOverSound();
job = { Create<DImageScreen>(tileGetTexture(kTile3591), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff, TRANSLATION(Translation_BasePalettes, 16)) };
jobs[0] = Create<DImageScreen>(tileGetTexture(kTile3591), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff, TRANSLATION(Translation_BasePalettes, 16));
}
RunScreenJob(&job, 1, [](bool) { gameaction = ga_mainmenu; });
RunScreenJob(jobs, [](bool) { gameaction = ga_mainmenu; });
}
void DoAfterCinemaScene(int nLevel, TArray<JobDesc>& jobs)
void DoAfterCinemaScene(int nLevel, TArray<DScreenJob*>& jobs)
{
int scene = -1;
if (nLevel == 10) scene = CINEMA_AFTER_LEVEL_10;
if (nLevel == 15) scene = CINEMA_AFTER_LEVEL_15;
if (nLevel == 20) scene = CINEMA_AFTER_LEVEL_20;
if (scene > 0) jobs.Push({ Create<DCinema>(scene) });
if (nLevel == 19) { jobs.Push({ Create<DLastLevelCinema>() }); selectedlevelnew = 20; }
if (nLevel == 20) jobs.Push({ Create<DExCredits>() });
if (scene > 0) jobs.Push(Create<DCinema>(scene));
if (nLevel == 19) { jobs.Push(Create<DLastLevelCinema>()); selectedlevelnew = 20; }
if (nLevel == 20) jobs.Push(Create<DExCredits>());
}
void DoBeforeCinemaScene(int nLevel, TArray<JobDesc>& jobs)
void DoBeforeCinemaScene(int nLevel, TArray<DScreenJob*>& jobs)
{
if (nLevel == 5) jobs.Push({ Create<DCinema>(CINEMA_BEFORE_LEVEL_5) });
else if (nLevel == 11) jobs.Push({ Create<DCinema>(CINEMA_BEFORE_LEVEL_11, 11) });
if (nLevel == 5) jobs.Push(Create<DCinema>(CINEMA_BEFORE_LEVEL_5));
else if (nLevel == 11) jobs.Push(Create<DCinema>(CINEMA_BEFORE_LEVEL_11, 11));
}
END_PS_NS

View file

@ -54,8 +54,8 @@ void SetHiRes();
void BlackOut();
void DoGameOverScene(bool finallevel);
void DoAfterCinemaScene(int nLevel, TArray<JobDesc> &jobs);
void DoBeforeCinemaScene(int nLevel, TArray<JobDesc>& jobs);
void DoAfterCinemaScene(int nLevel, TArray<DScreenJob*> &jobs);
void DoBeforeCinemaScene(int nLevel, TArray<DScreenJob*>& jobs);
int Query(short n, short l, ...);
@ -88,7 +88,7 @@ void InitNewGame();
int showmap(short nLevel, short nLevelNew, short nLevelBest);
void menu_DoPlasma();
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<JobDesc>& jobs);
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<DScreenJob*>& jobs);
void DoEnergyTile();
void InitEnergyTile();

View file

@ -62,7 +62,7 @@ void DrawClock();
double calc_smoothratio();
void DoTitle(CompletionFunc completion);
static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<JobDesc> &jobs)
static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<DScreenJob*> &jobs)
{
if (nLevelNew == 5 && !(nCinemaSeen & 1)) {
nCinemaSeen |= 1;
@ -135,7 +135,7 @@ void GameInterface::DrawBackground()
static void Intermission(MapRecord *from_map, MapRecord *to_map)
{
TArray<JobDesc> jobs;
TArray<DScreenJob*> jobs;
if (from_map) StopAllSounds();
bCamera = false;
@ -167,7 +167,7 @@ static void Intermission(MapRecord *from_map, MapRecord *to_map)
showmap(from_map ? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs);
}
else
jobs.Push({ Create<DBlackScreen>(1) }); // we need something in here even in the multiplayer case.
jobs.Push(Create<DBlackScreen>(1)); // we need something in here even in the multiplayer case.
}
}
else
@ -179,7 +179,7 @@ static void Intermission(MapRecord *from_map, MapRecord *to_map)
if (jobs.Size() > 0)
{
RunScreenJob(jobs.Data(), jobs.Size(), [=](bool)
RunScreenJob(jobs, [=](bool)
{
if (!to_map) gameaction = ga_startup; // this was the end of the game
else

View file

@ -88,11 +88,10 @@ void Logo(const CompletionFunc& completion)
if (!userConfig.nologo)
{
JobDesc jobs[3];
int job = 0;
jobs[job++] = { Create<DSWDRealmsScreen>() };
jobs[job++] = { PlayVideo("sw.anm", logosound, logoframetimes, true)};
RunScreenJob(jobs, job, completion, SJ_BLOCKUI);
TArray<DScreenJob*> jobs;
jobs.Push(Create<DSWDRealmsScreen>());
jobs.Push(PlayVideo("sw.anm", logosound, logoframetimes, true));
RunScreenJob(jobs, completion, SJ_BLOCKUI);
}
else completion(false);
}
@ -606,26 +605,25 @@ class DSWMultiSummaryScreen : public DSkippableScreenJob
void StatScreen(int FinishAnim, CompletionFunc completion)
{
JobDesc jobs[5];
int job = 0;
TArray<DScreenJob*> jobs;
if (FinishAnim)
{
StopSound();
jobs[job++] = { GetFinishAnim(FinishAnim) };
jobs[job++] = { Create<DSWLevelSummaryScreen>() };
jobs.Push(GetFinishAnim(FinishAnim));
jobs.Push(Create<DSWLevelSummaryScreen>());
if (FinishAnim == ANIM_ZILLA)
jobs[job++] = { Create<DSWCreditsScreen>() };
jobs.Push(Create<DSWCreditsScreen>());
}
else if (gNet.MultiGameType != MULTI_GAME_COMMBAT)
{
jobs[job++] = { Create<DSWLevelSummaryScreen>() };
jobs.Push(Create<DSWLevelSummaryScreen>());
}
else
{
jobs[job++] = { Create<DSWMultiSummaryScreen>() };
jobs.Push(Create<DSWMultiSummaryScreen>());
}
RunScreenJob(jobs, job, completion);
RunScreenJob(jobs, completion);
}
//---------------------------------------------------------------------------
@ -639,8 +637,9 @@ void SybexScreen(CompletionFunc completion)
if (!SW_SHAREWARE || CommEnabled) completion(false);
else
{
JobDesc job = { Create<DImageScreen>(tileGetTexture(5261), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff) };
RunScreenJob(&job, 1, completion, SJ_BLOCKUI);
TArray<DScreenJob*> jobs(1, true);
jobs[0] = Create<DImageScreen>(tileGetTexture(5261), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff);
RunScreenJob(jobs, completion, SJ_BLOCKUI);
}
}
@ -670,8 +669,9 @@ public:
void loadscreen(MapRecord* rec, CompletionFunc func)
{
JobDesc job = { Create<DSWLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
TArray<DScreenJob*> jobs(1, true);
jobs[0] = Create<DSWLoadScreen>(rec);
RunScreenJob(jobs, func);
}
END_SW_NS