raze-gles/source/core/screenjob.h

93 lines
1.7 KiB
C
Raw Normal View History

#pragma once
#include <functional>
2020-06-27 09:48:55 +00:00
#include "dobject.h"
2020-06-28 08:14:42 +00:00
using CompletionFunc = std::function<void(bool)>;
struct JobDesc;
class ScreenJobRunner;
2020-06-27 09:48:55 +00:00
class DScreenJob : public DObject
{
DECLARE_CLASS(DScreenJob, DObject)
int64_t now;
const int fadestyle;
const float fadetime; // in milliseconds
2020-07-03 07:59:24 +00:00
int fadestate = fadein;
friend class ScreenJobRunner;
2020-06-27 09:48:55 +00:00
public:
enum
{
2020-07-03 07:59:24 +00:00
visible = 0,
fadein = 1,
fadeout = 2,
};
DScreenJob(int fade = 0, float fadet = 250.f) : fadestyle(fade), fadetime(fadet) {}
void SetClock(int64_t nsnow)
{
now = nsnow;
}
int64_t GetClock() const
{
return now;
}
2020-07-01 20:27:38 +00:00
virtual int Frame(uint64_t clock, bool skiprequest) { return 0; }
2020-07-03 07:59:24 +00:00
int GetFadeState() const { return fadestate; }
2020-06-27 09:48:55 +00:00
};
2020-06-28 20:17:27 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
class DImageScreen : public DScreenJob
{
DECLARE_CLASS(DImageScreen, DScreenJob)
int tilenum = -1;
FGameTexture* tex = nullptr;
public:
DImageScreen(FGameTexture* tile, int fade = DScreenJob::fadein | DScreenJob::fadeout) : DScreenJob(fade)
2020-06-28 20:17:27 +00:00
{
tex = tile;
}
DImageScreen(int tile, int fade = DScreenJob::fadein | DScreenJob::fadeout) : DScreenJob(fade)
2020-06-28 20:17:27 +00:00
{
tilenum = tile;
}
int Frame(uint64_t clock, bool skiprequest) override;
};
struct JobDesc
{
DScreenJob* job;
void (*postAction)();
bool ignoreifskipped;
};
2020-06-27 09:48:55 +00:00
void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true, bool blockingui = false);
void DeleteScreenJob();
void RunScreenJobFrame();
2020-06-27 09:48:55 +00:00
struct AnimSound
{
int framenum;
int soundnum;
};
DScreenJob *PlayVideo(const char *filename, const AnimSound *ans = nullptr, const int *frameticks = nullptr);