mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- put ScreenJobRunner declaration into header.
This commit is contained in:
parent
71e5f9b70f
commit
805b91b721
2 changed files with 233 additions and 181 deletions
|
@ -117,27 +117,7 @@ void DImageScreen::Draw(double smoothratio)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class ScreenJobRunner
|
||||
{
|
||||
enum
|
||||
{
|
||||
State_Clear,
|
||||
State_Run,
|
||||
State_Fadeout
|
||||
};
|
||||
TArray<JobDesc> jobs;
|
||||
CompletionFunc completion;
|
||||
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_, bool skipall_)
|
||||
ScreenJobRunner::ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_)
|
||||
: completion(std::move(completion_)), clearbefore(clearbefore_), skipall(skipall_)
|
||||
{
|
||||
jobs.Resize(count);
|
||||
|
@ -150,12 +130,18 @@ public:
|
|||
AdvanceJob(false);
|
||||
}
|
||||
|
||||
~ScreenJobRunner()
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
ScreenJobRunner::~ScreenJobRunner()
|
||||
{
|
||||
DeleteJobs();
|
||||
}
|
||||
|
||||
void DeleteJobs()
|
||||
void ScreenJobRunner::DeleteJobs()
|
||||
{
|
||||
for (auto& job : jobs)
|
||||
{
|
||||
|
@ -165,7 +151,13 @@ public:
|
|||
jobs.Clear();
|
||||
}
|
||||
|
||||
void AdvanceJob(bool skip)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ScreenJobRunner::AdvanceJob(bool skip)
|
||||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
|
@ -187,7 +179,13 @@ public:
|
|||
inputState.ClearAllInput();
|
||||
}
|
||||
|
||||
int DisplayFrame(double smoothratio)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int ScreenJobRunner::DisplayFrame(double smoothratio)
|
||||
{
|
||||
auto& job = jobs[index];
|
||||
auto now = I_GetTimeNS();
|
||||
|
@ -205,7 +203,7 @@ public:
|
|||
return state;
|
||||
}
|
||||
|
||||
int FadeoutFrame(double smoothratio)
|
||||
int ScreenJobRunner::FadeoutFrame(double smoothratio)
|
||||
{
|
||||
auto& job = jobs[index];
|
||||
double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job.job->fadetime;
|
||||
|
@ -215,7 +213,13 @@ public:
|
|||
return (screenfade > 0.f);
|
||||
}
|
||||
|
||||
bool OnEvent(event_t* ev)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool ScreenJobRunner::OnEvent(event_t* ev)
|
||||
{
|
||||
if (paused || index >= jobs.Size()) return false;
|
||||
|
||||
|
@ -235,13 +239,13 @@ public:
|
|||
return jobs[index].job->OnEvent(ev);
|
||||
}
|
||||
|
||||
void OnFinished()
|
||||
void ScreenJobRunner::OnFinished()
|
||||
{
|
||||
if (completion) completion(false);
|
||||
completion = nullptr; // only finish once.
|
||||
}
|
||||
|
||||
void OnTick()
|
||||
void ScreenJobRunner::OnTick()
|
||||
{
|
||||
if (paused) return;
|
||||
if (index >= jobs.Size())
|
||||
|
@ -266,7 +270,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool RunFrame()
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool ScreenJobRunner::RunFrame()
|
||||
{
|
||||
if (index >= jobs.Size())
|
||||
{
|
||||
|
@ -318,7 +328,12 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
ScreenJobRunner *runner;
|
||||
|
||||
|
|
|
@ -132,15 +132,52 @@ public:
|
|||
void Draw(double smooth) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct JobDesc
|
||||
{
|
||||
DScreenJob* job;
|
||||
//void (*postAction)();
|
||||
};
|
||||
|
||||
|
||||
class ScreenJobRunner
|
||||
{
|
||||
enum
|
||||
{
|
||||
State_Clear,
|
||||
State_Run,
|
||||
State_Fadeout
|
||||
};
|
||||
TArray<JobDesc> jobs;
|
||||
CompletionFunc completion;
|
||||
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_, bool skipall_);
|
||||
~ScreenJobRunner();
|
||||
void DeleteJobs();
|
||||
void AdvanceJob(bool skip);
|
||||
int DisplayFrame(double smoothratio);
|
||||
int FadeoutFrame(double smoothratio);
|
||||
bool OnEvent(event_t* ev);
|
||||
void OnFinished();
|
||||
void OnTick();
|
||||
bool RunFrame();
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SJ_DONTCLEAR = 1,
|
||||
|
|
Loading…
Reference in a new issue