2020-06-20 07:46:41 +00:00
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
2020-06-27 09:48:55 +00:00
|
|
|
#include "dobject.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2021-04-15 22:50:13 +00:00
|
|
|
#include "d_eventbase.h"
|
2021-04-21 22:25:55 +00:00
|
|
|
#include "s_soundinternal.h"
|
2021-04-26 20:56:37 +00:00
|
|
|
#include "gamestate.h"
|
2020-06-20 07:46:41 +00:00
|
|
|
|
2020-06-28 08:14:42 +00:00
|
|
|
using CompletionFunc = std::function<void(bool)>;
|
2020-07-01 10:55:32 +00:00
|
|
|
struct JobDesc;
|
2020-07-19 09:57:00 +00:00
|
|
|
class ScreenJobRunner;
|
2020-06-27 09:48:55 +00:00
|
|
|
|
2021-04-26 21:10:38 +00:00
|
|
|
void Job_Init();
|
|
|
|
|
|
|
|
|
2021-04-25 18:02:40 +00:00
|
|
|
#if 0
|
2020-06-27 09:48:55 +00:00
|
|
|
class DScreenJob : public DObject
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(DScreenJob, DObject)
|
2021-04-22 16:52:39 +00:00
|
|
|
public:
|
2021-04-21 22:25:55 +00:00
|
|
|
const int flags;
|
2020-07-01 10:55:32 +00:00
|
|
|
const float fadetime; // in milliseconds
|
2020-07-03 07:59:24 +00:00
|
|
|
int fadestate = fadein;
|
2020-07-01 10:55:32 +00:00
|
|
|
|
2020-07-19 09:57:00 +00:00
|
|
|
friend class ScreenJobRunner;
|
2021-04-22 16:52:39 +00:00
|
|
|
//protected:
|
2021-04-15 22:50:13 +00:00
|
|
|
int ticks = 0;
|
|
|
|
int state = running;
|
2021-04-15 22:11:02 +00:00
|
|
|
bool pausable = true;
|
2020-07-01 10:55:32 +00:00
|
|
|
|
2020-06-27 09:48:55 +00:00
|
|
|
public:
|
2021-04-15 22:50:13 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
running = 1, // normal operation
|
|
|
|
skipped = 2, // finished by user skipping
|
|
|
|
finished = 3, // finished by completing its sequence
|
|
|
|
stopping = 4, // running ending animations / fadeout, etc. Will not accept more input.
|
|
|
|
stopped = 5, // we're done here.
|
|
|
|
};
|
2020-07-01 10:55:32 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-07-03 07:59:24 +00:00
|
|
|
visible = 0,
|
2020-07-01 10:55:32 +00:00
|
|
|
fadein = 1,
|
|
|
|
fadeout = 2,
|
2021-04-21 22:25:55 +00:00
|
|
|
stopmusic = 4,
|
|
|
|
stopsound = 8,
|
2020-07-01 10:55:32 +00:00
|
|
|
};
|
|
|
|
|
2021-04-21 22:25:55 +00:00
|
|
|
DScreenJob(int fade = 0, float fadet = 250.f) : flags(fade), fadetime(fadet) {}
|
2020-08-21 20:30:51 +00:00
|
|
|
|
|
|
|
virtual bool ProcessInput()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-01 10:55:32 +00:00
|
|
|
|
2021-04-16 21:29:53 +00:00
|
|
|
virtual void Start() {}
|
2021-04-15 22:50:13 +00:00
|
|
|
virtual bool OnEvent(event_t* evt) { return false; }
|
2021-04-15 22:11:02 +00:00
|
|
|
virtual void OnTick() { /*state = finished;*/ }
|
2021-04-15 22:50:13 +00:00
|
|
|
virtual void Draw(double smoothratio) {}
|
|
|
|
|
2021-04-16 19:27:54 +00:00
|
|
|
int DrawFrame(double smoothratio)
|
2021-04-15 22:50:13 +00:00
|
|
|
{
|
2021-04-16 18:08:20 +00:00
|
|
|
if (state != running) smoothratio = 1; // this is necessary because the ticker won't be incremented anymore to avoid having a negative time span.
|
2021-04-15 22:50:13 +00:00
|
|
|
Draw(smoothratio);
|
|
|
|
if (state == skipped) return -1;
|
|
|
|
if (state == finished) return 0;
|
2021-04-16 18:48:40 +00:00
|
|
|
return 1;
|
2021-04-15 22:50:13 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 07:59:24 +00:00
|
|
|
int GetFadeState() const { return fadestate; }
|
|
|
|
|
2021-04-21 22:25:55 +00:00
|
|
|
virtual void OnDestroy() override;
|
2020-06-27 09:48:55 +00:00
|
|
|
};
|
|
|
|
|
2020-06-28 20:17:27 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-04-15 22:02:09 +00:00
|
|
|
class DSkippableScreenJob : public DScreenJob
|
|
|
|
{
|
2021-04-22 16:52:39 +00:00
|
|
|
DECLARE_CLASS(DSkippableScreenJob, DScreenJob)
|
|
|
|
public:
|
2021-04-15 22:02:09 +00:00
|
|
|
DSkippableScreenJob(int fade = 0, float fadet = 250.f) : DScreenJob(fade, fadet)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool OnEvent(event_t* evt) override;
|
2021-04-16 16:43:59 +00:00
|
|
|
virtual void Skipped() {}
|
2021-04-15 22:02:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-07-29 21:18:08 +00:00
|
|
|
class DBlackScreen : public DScreenJob
|
|
|
|
{
|
2021-04-22 16:52:39 +00:00
|
|
|
DECLARE_CLASS(DBlackScreen, DScreenJob)
|
|
|
|
public:
|
2020-07-29 21:18:08 +00:00
|
|
|
int wait;
|
2021-04-15 22:11:02 +00:00
|
|
|
bool cleared = false;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
|
|
|
public:
|
2021-04-21 22:25:55 +00:00
|
|
|
DBlackScreen(int w, int flags = 0) : DScreenJob(flags & ~(fadein|fadeout)), wait(w) {}
|
2021-04-15 22:11:02 +00:00
|
|
|
void OnTick() override;
|
|
|
|
void Draw(double smooth) override;
|
2020-07-29 21:18:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-04-15 22:11:02 +00:00
|
|
|
class DImageScreen : public DSkippableScreenJob
|
2020-06-28 20:17:27 +00:00
|
|
|
{
|
|
|
|
DECLARE_CLASS(DImageScreen, DScreenJob)
|
|
|
|
|
2021-04-22 16:52:39 +00:00
|
|
|
public:
|
2020-06-28 20:17:27 +00:00
|
|
|
int tilenum = -1;
|
2020-10-13 21:29:12 +00:00
|
|
|
int trans;
|
2020-07-29 21:18:08 +00:00
|
|
|
int waittime; // in ms.
|
2021-04-15 22:11:02 +00:00
|
|
|
bool cleared = false;
|
2021-04-22 16:52:39 +00:00
|
|
|
FTextureID texid;
|
2020-06-28 20:17:27 +00:00
|
|
|
FGameTexture* tex = nullptr;
|
|
|
|
|
|
|
|
public:
|
2021-04-15 22:11:02 +00:00
|
|
|
DImageScreen(FGameTexture* tile, int fade = DScreenJob::fadein | DScreenJob::fadeout, int wait = 3000, int translation = 0) : DSkippableScreenJob(fade), waittime(wait)
|
2020-06-28 20:17:27 +00:00
|
|
|
{
|
|
|
|
tex = tile;
|
2020-10-13 21:29:12 +00:00
|
|
|
trans = translation;
|
2020-06-28 20:17:27 +00:00
|
|
|
}
|
|
|
|
|
2021-04-15 22:11:02 +00:00
|
|
|
DImageScreen(int tile, int fade = DScreenJob::fadein | DScreenJob::fadeout, int wait = 3000, int translation = 0) : DSkippableScreenJob(fade), waittime(wait)
|
2020-06-28 20:17:27 +00:00
|
|
|
{
|
|
|
|
tilenum = tile;
|
2020-10-13 21:29:12 +00:00
|
|
|
trans = translation;
|
2020-06-28 20:17:27 +00:00
|
|
|
}
|
|
|
|
|
2021-04-15 22:11:02 +00:00
|
|
|
void OnTick() override;
|
|
|
|
void Draw(double smooth) override;
|
2020-06-28 20:17:27 +00:00
|
|
|
};
|
2021-04-25 18:02:40 +00:00
|
|
|
#endif
|
2020-06-28 20:17:27 +00:00
|
|
|
|
2021-04-25 18:02:40 +00:00
|
|
|
#if 0
|
2021-04-21 22:35:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-06-28 20:17:27 +00:00
|
|
|
|
2021-04-21 22:35:48 +00:00
|
|
|
class ScreenJobRunner
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
State_Clear,
|
|
|
|
State_Run,
|
|
|
|
State_Fadeout
|
|
|
|
};
|
2021-04-21 22:51:14 +00:00
|
|
|
TArray<DScreenJob*> jobs;
|
2021-04-21 22:35:48 +00:00
|
|
|
CompletionFunc completion;
|
|
|
|
int index = -1;
|
|
|
|
float screenfade;
|
|
|
|
bool clearbefore;
|
|
|
|
bool skipall;
|
|
|
|
int actionState;
|
|
|
|
int terminateState;
|
|
|
|
int fadeticks = 0;
|
|
|
|
int last_paused_tic = -1;
|
|
|
|
|
|
|
|
public:
|
2021-04-21 22:51:14 +00:00
|
|
|
ScreenJobRunner(TArray<DScreenJob*>& jobs, CompletionFunc completion_, bool clearbefore_, bool skipall_);
|
2021-04-21 22:35:48 +00:00
|
|
|
~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();
|
|
|
|
};
|
2021-04-25 18:02:40 +00:00
|
|
|
#endif
|
2021-04-21 22:35:48 +00:00
|
|
|
|
|
|
|
|
2021-04-21 22:18:53 +00:00
|
|
|
enum
|
|
|
|
{
|
2021-04-26 19:13:11 +00:00
|
|
|
SJ_BLOCKUI = 1,
|
2021-04-21 22:18:53 +00:00
|
|
|
};
|
|
|
|
|
2021-04-26 19:13:11 +00:00
|
|
|
#if 0
|
2020-06-27 09:48:55 +00:00
|
|
|
|
2021-04-21 22:51:14 +00:00
|
|
|
void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flags = 0);
|
2021-04-25 18:02:40 +00:00
|
|
|
#endif
|
2021-04-15 22:50:13 +00:00
|
|
|
void EndScreenJob();
|
2020-07-19 10:48:31 +00:00
|
|
|
void DeleteScreenJob();
|
2021-04-15 22:50:13 +00:00
|
|
|
bool ScreenJobResponder(event_t* ev);
|
2021-04-26 19:13:11 +00:00
|
|
|
bool ScreenJobTick();
|
|
|
|
void ScreenJobDraw();
|
2021-04-26 20:56:37 +00:00
|
|
|
|
2021-04-26 22:01:25 +00:00
|
|
|
struct CutsceneDef;
|
|
|
|
bool StartCutscene(CutsceneDef& cs, int flags, CompletionFunc completion);
|
|
|
|
bool StartCutscene(const char* s, int flags, CompletionFunc completion);
|
2021-04-26 20:56:37 +00:00
|
|
|
void PlayLogos(gameaction_t complete_ga, gameaction_t def_ga, bool stopmusic);
|