- simplified screen job setup where all elements can be skipped in one go.

This commit is contained in:
Christoph Oelckers 2021-04-22 00:11:36 +02:00
parent 9bebd7fabf
commit af3eac8456
3 changed files with 11 additions and 10 deletions

View file

@ -125,14 +125,15 @@ class ScreenJobRunner
int index = -1; int index = -1;
float screenfade; float screenfade;
bool clearbefore; bool clearbefore;
bool skipall;
int actionState; int actionState;
int terminateState; int terminateState;
int fadeticks = 0; int fadeticks = 0;
int last_paused_tic = -1; int last_paused_tic = -1;
public: public:
ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_) ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_)
: completion(std::move(completion_)), clearbefore(clearbefore_) : completion(std::move(completion_)), clearbefore(clearbefore_), skipall(skipall_)
{ {
jobs.Resize(count); jobs.Resize(count);
memcpy(jobs.Data(), jobs_, count * sizeof(JobDesc)); memcpy(jobs.Data(), jobs_, count * sizeof(JobDesc));
@ -167,7 +168,7 @@ public:
jobs[index].job->Destroy(); jobs[index].job->Destroy();
} }
index++; index++;
while (index < jobs.Size() && (jobs[index].job == nullptr || (skip && jobs[index].ignoreifskipped))) while (index < jobs.Size() && (jobs[index].job == nullptr || (skip && skipall)))
{ {
if (jobs[index].job != nullptr) jobs[index].job->Destroy(); if (jobs[index].job != nullptr) jobs[index].job->Destroy();
index++; index++;
@ -316,13 +317,13 @@ public:
ScreenJobRunner *runner; ScreenJobRunner *runner;
void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, bool clearbefore, bool blockingui) void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, bool clearbefore, bool blockingui, bool skipall)
{ {
assert(completion != nullptr); assert(completion != nullptr);
videoclearFade(); videoclearFade();
if (count) if (count)
{ {
runner = new ScreenJobRunner(jobs, count, completion, clearbefore); runner = new ScreenJobRunner(jobs, count, completion, clearbefore, skipall);
gameaction = blockingui? ga_intro : ga_intermission; gameaction = blockingui? ga_intro : ga_intermission;
} }
else else

View file

@ -135,11 +135,11 @@ struct JobDesc
{ {
DScreenJob* job; DScreenJob* job;
void (*postAction)(); void (*postAction)();
bool ignoreifskipped; //bool ignoreifskipped;
}; };
void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true, bool blockingui = false); void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true, bool blockingui = false, bool skipall = false);
void EndScreenJob(); void EndScreenJob();
void DeleteScreenJob(); void DeleteScreenJob();
bool ScreenJobResponder(event_t* ev); bool ScreenJobResponder(event_t* ev);

View file

@ -1129,9 +1129,9 @@ void e4intro(const CompletionFunc& completion)
S_PlaySpecialMusic(MUS_BRIEFING); S_PlaySpecialMusic(MUS_BRIEFING);
jobs[job++] = { PlayVideo("vol41a.anm", vol41a, framespeed_10), nullptr }; jobs[job++] = { PlayVideo("vol41a.anm", vol41a, framespeed_10), nullptr };
jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14), nullptr, true }; jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14), nullptr };
jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10), nullptr, true }; jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10), nullptr };
RunScreenJob(jobs, job, completion); RunScreenJob(jobs, job, completion, true, false, true);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------