2020-06-20 09:46:41 +02:00
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
2020-06-27 11:48:55 +02:00
|
|
|
#include "dobject.h"
|
2020-07-29 23:18:08 +02:00
|
|
|
#include "v_2ddrawer.h"
|
2020-06-20 09:46:41 +02:00
|
|
|
|
2020-06-28 10:14:42 +02:00
|
|
|
using CompletionFunc = std::function<void(bool)>;
|
2020-07-01 12:55:32 +02:00
|
|
|
struct JobDesc;
|
2020-07-19 11:57:00 +02:00
|
|
|
class ScreenJobRunner;
|
2020-06-27 11:48:55 +02:00
|
|
|
|
|
|
|
class DScreenJob : public DObject
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(DScreenJob, DObject)
|
2020-07-01 12:55:32 +02:00
|
|
|
int64_t now;
|
|
|
|
const int fadestyle;
|
|
|
|
const float fadetime; // in milliseconds
|
2020-07-03 09:59:24 +02:00
|
|
|
int fadestate = fadein;
|
2020-07-01 12:55:32 +02:00
|
|
|
|
2020-07-19 11:57:00 +02:00
|
|
|
friend class ScreenJobRunner;
|
2020-07-01 12:55:32 +02:00
|
|
|
|
2020-06-27 11:48:55 +02:00
|
|
|
public:
|
2020-07-01 12:55:32 +02:00
|
|
|
enum
|
|
|
|
{
|
2020-07-03 09:59:24 +02:00
|
|
|
visible = 0,
|
2020-07-01 12:55:32 +02:00
|
|
|
fadein = 1,
|
|
|
|
fadeout = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
DScreenJob(int fade = 0, float fadet = 250.f) : fadestyle(fade), fadetime(fadet) {}
|
2020-08-21 22:30:51 +02:00
|
|
|
|
|
|
|
virtual bool ProcessInput()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-01 12:55:32 +02:00
|
|
|
|
|
|
|
void SetClock(int64_t nsnow)
|
|
|
|
{
|
|
|
|
now = nsnow;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t GetClock() const
|
|
|
|
{
|
|
|
|
return now;
|
|
|
|
}
|
|
|
|
|
2020-07-01 22:27:38 +02:00
|
|
|
virtual int Frame(uint64_t clock, bool skiprequest) { return 0; }
|
2020-07-03 09:59:24 +02:00
|
|
|
int GetFadeState() const { return fadestate; }
|
|
|
|
|
2020-06-27 11:48:55 +02:00
|
|
|
};
|
|
|
|
|
2020-06-28 22:17:27 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-07-29 23:18:08 +02:00
|
|
|
class DBlackScreen : public DScreenJob
|
|
|
|
{
|
|
|
|
int wait;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DBlackScreen(int w) : wait(w) {}
|
|
|
|
int Frame(uint64_t clock, bool skiprequest) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-06-28 22:17:27 +02:00
|
|
|
class DImageScreen : public DScreenJob
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(DImageScreen, DScreenJob)
|
|
|
|
|
|
|
|
int tilenum = -1;
|
2020-10-13 23:29:12 +02:00
|
|
|
int trans;
|
2020-07-29 23:18:08 +02:00
|
|
|
int waittime; // in ms.
|
2020-06-28 22:17:27 +02:00
|
|
|
FGameTexture* tex = nullptr;
|
|
|
|
|
|
|
|
public:
|
2020-10-13 23:29:12 +02:00
|
|
|
DImageScreen(FGameTexture* tile, int fade = DScreenJob::fadein | DScreenJob::fadeout, int wait = 3000, int translation = 0) : DScreenJob(fade), waittime(wait)
|
2020-06-28 22:17:27 +02:00
|
|
|
{
|
|
|
|
tex = tile;
|
2020-10-13 23:29:12 +02:00
|
|
|
trans = translation;
|
2020-06-28 22:17:27 +02:00
|
|
|
}
|
|
|
|
|
2020-10-13 23:29:12 +02:00
|
|
|
DImageScreen(int tile, int fade = DScreenJob::fadein | DScreenJob::fadeout, int wait = 3000, int translation = 0) : DScreenJob(fade), waittime(wait)
|
2020-06-28 22:17:27 +02:00
|
|
|
{
|
|
|
|
tilenum = tile;
|
2020-10-13 23:29:12 +02:00
|
|
|
trans = translation;
|
2020-06-28 22:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int Frame(uint64_t clock, bool skiprequest) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-28 21:38:25 +02:00
|
|
|
struct JobDesc
|
|
|
|
{
|
|
|
|
DScreenJob* job;
|
|
|
|
void (*postAction)();
|
|
|
|
bool ignoreifskipped;
|
|
|
|
};
|
|
|
|
|
2020-06-27 11:48:55 +02:00
|
|
|
|
2020-07-22 00:42:50 +02:00
|
|
|
void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true, bool blockingui = false);
|
2020-07-19 12:48:31 +02:00
|
|
|
void DeleteScreenJob();
|
|
|
|
void RunScreenJobFrame();
|
2020-06-27 11:48:55 +02:00
|
|
|
|
|
|
|
struct AnimSound
|
|
|
|
{
|
|
|
|
int framenum;
|
|
|
|
int soundnum;
|
|
|
|
};
|
|
|
|
|
2020-08-18 00:04:48 +02:00
|
|
|
DScreenJob *PlayVideo(const char *filename, const AnimSound *ans = nullptr, const int *frameticks = nullptr, bool nosoundstop = false);
|