- 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;
float screenfade;
bool clearbefore;
bool skipall;
int actionState;
int terminateState;
int fadeticks = 0;
int last_paused_tic = -1;
public:
ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_)
: completion(std::move(completion_)), clearbefore(clearbefore_)
ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_)
: completion(std::move(completion_)), clearbefore(clearbefore_), skipall(skipall_)
{
jobs.Resize(count);
memcpy(jobs.Data(), jobs_, count * sizeof(JobDesc));
@ -167,7 +168,7 @@ public:
jobs[index].job->Destroy();
}
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();
index++;
@ -316,13 +317,13 @@ public:
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);
videoclearFade();
if (count)
{
runner = new ScreenJobRunner(jobs, count, completion, clearbefore);
runner = new ScreenJobRunner(jobs, count, completion, clearbefore, skipall);
gameaction = blockingui? ga_intro : ga_intermission;
}
else

View file

@ -135,11 +135,11 @@ struct JobDesc
{
DScreenJob* job;
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 DeleteScreenJob();
bool ScreenJobResponder(event_t* ev);

View file

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