mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- moved the entire screen job management to the script side.
This isn't hooked up yet and lots of code is commented out, the games won't start with this commit.
This commit is contained in:
parent
d853b63a1a
commit
4ff2010bd1
18 changed files with 665 additions and 158 deletions
|
@ -331,6 +331,14 @@ DEFINE_ACTION_FUNCTION(_Screen, ClearScreen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, SetScreenFade)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_FLOAT(x);
|
||||
twod->SetScreenFade(x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void F2DDrawer::GetClipRect(int *x, int *y, int *w, int *h)
|
||||
{
|
||||
|
|
|
@ -1449,6 +1449,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, StopAllSounds, FX_StopAllSounds)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, StopMusic, Mus_Stop)
|
||||
{
|
||||
Mus_Stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SoundEnabled, SoundEnabled)
|
||||
{
|
||||
ACTION_RETURN_INT(SoundEnabled());
|
||||
|
@ -1459,6 +1465,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, MusicEnabled, MusicEnabled)
|
|||
ACTION_RETURN_INT(MusicEnabled());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, GetTimeFrac, I_GetTimeFrac)
|
||||
{
|
||||
ACTION_RETURN_INT(I_GetTimeFrac());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Raze, PlayerName)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
@ -1474,6 +1485,7 @@ DEFINE_GLOBAL(gamestate)
|
|||
DEFINE_GLOBAL(demoplayback)
|
||||
DEFINE_GLOBAL(consoleplayer)
|
||||
DEFINE_GLOBAL(currentLevel)
|
||||
DEFINE_GLOBAL(paused)
|
||||
|
||||
DEFINE_FIELD_X(MapRecord, MapRecord, parTime)
|
||||
DEFINE_FIELD_X(MapRecord, MapRecord, designerTime)
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <vpx/vpx_decoder.h>
|
||||
#include <vpx/vp8dx.h>
|
||||
#include "raze_music.h"
|
||||
#include "vm.h"
|
||||
|
||||
|
||||
class MoviePlayer
|
||||
|
@ -649,6 +650,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -697,8 +699,9 @@ public:
|
|||
player = nullptr;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -751,7 +754,7 @@ MoviePlayer* OpenMovie(const char* filename, const AnimSound* ans, const int* fr
|
|||
else if (!memcmp(id, "SMK2", 4))
|
||||
{
|
||||
fr.Close();
|
||||
auto anm = new SmkPlayer(filename, ans, true); // Fixme: Handle Blood's video scaling behavior more intelligently.
|
||||
auto anm = new SmkPlayer(filename, ans, isBlood()); // Fixme: Handle Blood's video scaling behavior more intelligently.
|
||||
if (!anm->isvalid())
|
||||
{
|
||||
error.Format("%s: invalid SMK file.\n", filename);
|
||||
|
@ -811,4 +814,34 @@ DScreenJob* PlayVideo(const char* filename, const AnimSound* ans, const int* fra
|
|||
return Create<DMoviePlayer>(movie);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, OpenMovie)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Start)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
self->Start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Frame)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
PARAM_FLOAT(clock);
|
||||
self->Frame(int64_t(clock));
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Destroy)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
self->Stop();
|
||||
delete self;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "vm.h"
|
||||
|
||||
|
||||
#if 0
|
||||
IMPLEMENT_CLASS(DScreenJob, true, false)
|
||||
IMPLEMENT_CLASS(DSkippableScreenJob, true, false)
|
||||
IMPLEMENT_CLASS(DBlackScreen, true, false)
|
||||
|
@ -318,17 +319,6 @@ bool ScreenJobRunner::OnEvent(event_t* ev)
|
|||
{
|
||||
if (paused || index >= jobs.Size()) return false;
|
||||
|
||||
if (ev->type == EV_KeyDown)
|
||||
{
|
||||
// We never reach the key binding checks in G_Responder, so for the console we have to check for ourselves here.
|
||||
auto binding = Bindings.GetBinding(ev->data1);
|
||||
if (binding.CompareNoCase("toggleconsole") == 0)
|
||||
{
|
||||
C_ToggleConsole();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (jobs[index]->state != DScreenJob::running) return false;
|
||||
|
||||
return jobs[index]->OnEvent(ev);
|
||||
|
@ -432,6 +422,10 @@ bool ScreenJobRunner::RunFrame()
|
|||
|
||||
ScreenJobRunner *runner;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flags)
|
||||
{
|
||||
assert(completion != nullptr);
|
||||
|
@ -446,38 +440,52 @@ void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flag
|
|||
completion(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DeleteScreenJob()
|
||||
{
|
||||
/*
|
||||
if (runner)
|
||||
{
|
||||
delete runner;
|
||||
runner = nullptr;
|
||||
}
|
||||
twod->SetScreenFade(1);
|
||||
twod->SetScreenFade(1);*/
|
||||
}
|
||||
|
||||
void EndScreenJob()
|
||||
{
|
||||
if (runner) runner->OnFinished();
|
||||
//if (runner) runner->OnFinished();
|
||||
DeleteScreenJob();
|
||||
}
|
||||
|
||||
|
||||
bool ScreenJobResponder(event_t* ev)
|
||||
{
|
||||
if (runner) return runner->OnEvent(ev);
|
||||
if (ev->type == EV_KeyDown)
|
||||
{
|
||||
// We never reach the key binding checks in G_Responder, so for the console we have to check for ourselves here.
|
||||
auto binding = Bindings.GetBinding(ev->data1);
|
||||
if (binding.CompareNoCase("toggleconsole") == 0)
|
||||
{
|
||||
C_ToggleConsole();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//if (runner) return runner->OnEvent(ev);
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScreenJobTick()
|
||||
{
|
||||
if (runner) runner->OnTick();
|
||||
//if (runner) runner->OnTick();
|
||||
}
|
||||
|
||||
bool ScreenJobDraw()
|
||||
{
|
||||
// we cannot recover from this because we have no completion callback to call.
|
||||
/*
|
||||
if (!runner)
|
||||
{
|
||||
// We can get here before a gameaction has been processed. In that case just draw a black screen and wait.
|
||||
|
@ -486,6 +494,7 @@ bool ScreenJobDraw()
|
|||
return false;
|
||||
}
|
||||
auto res = runner->RunFrame();
|
||||
*/ int res = 0;
|
||||
if (!res)
|
||||
{
|
||||
assert((gamestate != GS_INTERMISSION && gamestate != GS_INTRO) || gameaction != ga_nothing);
|
||||
|
@ -493,4 +502,3 @@ bool ScreenJobDraw()
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using CompletionFunc = std::function<void(bool)>;
|
|||
struct JobDesc;
|
||||
class ScreenJobRunner;
|
||||
|
||||
#if 0
|
||||
class DScreenJob : public DObject
|
||||
{
|
||||
DECLARE_CLASS(DScreenJob, DObject)
|
||||
|
@ -137,7 +138,9 @@ public:
|
|||
void OnTick() override;
|
||||
void Draw(double smooth) override;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -175,9 +178,10 @@ public:
|
|||
void OnTick();
|
||||
bool RunFrame();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
enum
|
||||
{
|
||||
SJ_DONTCLEAR = 1,
|
||||
|
@ -187,6 +191,7 @@ enum
|
|||
|
||||
|
||||
void RunScreenJob(TArray<DScreenJob*>& jobs, CompletionFunc completion, int flags = 0);
|
||||
#endif
|
||||
void EndScreenJob();
|
||||
void DeleteScreenJob();
|
||||
bool ScreenJobResponder(event_t* ev);
|
||||
|
@ -199,4 +204,6 @@ struct AnimSound
|
|||
int soundnum;
|
||||
};
|
||||
|
||||
#if 0
|
||||
DScreenJob *PlayVideo(const char *filename, const AnimSound *ans = nullptr, const int *frameticks = nullptr, bool nosoundstop = false);
|
||||
#endif
|
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
#if 0
|
||||
class DBloodIntroImage : public DImageScreen
|
||||
{
|
||||
bool mus;
|
||||
|
@ -50,6 +51,7 @@ public:
|
|||
if (mus) sndPlaySpecialMusicOrNothing(MUS_INTRO);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -59,6 +61,7 @@ public:
|
|||
|
||||
void playlogos()
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
static AnimSound logosound[] =
|
||||
{
|
||||
|
@ -101,10 +104,12 @@ void playlogos()
|
|||
Mus_Stop();
|
||||
gameaction = ga_mainmenu;
|
||||
}, SJ_BLOCKUI);
|
||||
#endif
|
||||
}
|
||||
|
||||
void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
static AnimSound smksound[] =
|
||||
{
|
||||
|
@ -128,6 +133,7 @@ void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func)
|
|||
smksound[0].soundnum = id;
|
||||
jobs.Push(PlayVideo(smkk, smksound, nullptr));
|
||||
RunScreenJob(jobs, func);
|
||||
#endif
|
||||
}
|
||||
|
||||
void levelPlayIntroScene(int nEpisode, CompletionFunc completion)
|
||||
|
|
|
@ -91,6 +91,7 @@ static void DrawCaption(const char* text)
|
|||
}
|
||||
|
||||
|
||||
#if 0 // public DScreenJob
|
||||
class DBloodSummaryScreen : public DSkippableScreenJob
|
||||
{
|
||||
void DrawKills(void)
|
||||
|
@ -170,9 +171,11 @@ class DBloodSummaryScreen : public DSkippableScreenJob
|
|||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void GameInterface::LevelCompleted(MapRecord *map, int skill)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> job(1, true);
|
||||
job[0] = Create<DBloodSummaryScreen>();
|
||||
sndStartSample(268, 128, -1, false, CHANF_UI);
|
||||
|
@ -182,7 +185,9 @@ void GameInterface::LevelCompleted(MapRecord *map, int skill)
|
|||
soundEngine->StopAllChannels();
|
||||
gameaction = ga_nextlevel;
|
||||
});
|
||||
|
||||
#else
|
||||
gameaction = ga_nextlevel;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,6 +278,7 @@ void SerializeGameStats(FSerializer& arc)
|
|||
CSecretMgr gSecretMgr;
|
||||
CKillMgr gKillMgr;
|
||||
|
||||
#if 0
|
||||
class DBloodLoadScreen : public DScreenJob
|
||||
{
|
||||
const char* pzLoadingScreenText1;
|
||||
|
@ -306,6 +312,6 @@ void loadscreen(const char *caption, MapRecord* rec, CompletionFunc func)
|
|||
job[0] = Create<DBloodLoadScreen>(caption, rec);
|
||||
RunScreenJob(job, func);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -131,7 +131,7 @@ void InitFonts_d()
|
|||
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//==========================================================================
|
||||
//
|
||||
// wrappers around DrawText to allow easier reuse of the old code.
|
||||
|
@ -293,6 +293,7 @@ public:
|
|||
S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -302,6 +303,7 @@ public:
|
|||
|
||||
void Logo_d(const CompletionFunc &completion)
|
||||
{
|
||||
#if 0
|
||||
Mus_Stop();
|
||||
FX_StopAllSounds(); // JBF 20031228
|
||||
|
||||
|
@ -322,8 +324,10 @@ void Logo_d(const CompletionFunc &completion)
|
|||
}
|
||||
jobs.Push(Create<DTitleScreen>());
|
||||
RunScreenJob(jobs, completion, SJ_BLOCKUI);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -715,6 +719,7 @@ static void bonussequence_d(int num, TArray<DScreenJob*>& jobs)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -724,22 +729,27 @@ static void bonussequence_d(int num, TArray<DScreenJob*>& jobs)
|
|||
|
||||
void showtwoscreens(const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
jobs.Push(Create<DImageScreen>(3291));
|
||||
jobs.Push(Create<DImageScreen>(3290));
|
||||
RunScreenJob(jobs, completion);
|
||||
#endif
|
||||
}
|
||||
|
||||
void doorders(const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
jobs.Push(Create<DImageScreen>(ORDERING + i));
|
||||
RunScreenJob(jobs, completion);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -1080,6 +1090,7 @@ public:
|
|||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1089,6 +1100,7 @@ public:
|
|||
|
||||
void dobonus_d(int bonusonly, const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
FX_StopAllSounds();
|
||||
|
@ -1113,6 +1125,7 @@ void dobonus_d(int bonusonly, const CompletionFunc& completion)
|
|||
RunScreenJob(jobs, completion);
|
||||
}
|
||||
else if (completion) completion(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -1123,6 +1136,7 @@ void dobonus_d(int bonusonly, const CompletionFunc& completion)
|
|||
|
||||
void e4intro(const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
static const AnimSound vol42a[] =
|
||||
|
@ -1157,8 +1171,10 @@ void e4intro(const CompletionFunc& completion)
|
|||
jobs.Push(PlayVideo("vol42a.anm", vol42a, framespeed_14));
|
||||
jobs.Push(PlayVideo("vol43a.anm", vol43a, framespeed_10));
|
||||
RunScreenJob(jobs, completion, SJ_SKIPALL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -1189,10 +1205,11 @@ void loadscreen_d(MapRecord *rec, CompletionFunc func)
|
|||
jobs[0] = Create<DDukeLoadScreen>(rec);
|
||||
RunScreenJob(jobs, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PrintPaused_d()
|
||||
{
|
||||
BigText(160, 100, GStrings("Game Paused"));
|
||||
//BigText(160, 100, GStrings("Game Paused"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ void InitFonts_r()
|
|||
|
||||
}
|
||||
|
||||
#if 0
|
||||
//==========================================================================
|
||||
//
|
||||
// wrappers around DrawText to allow easier reuse of the old code.
|
||||
|
@ -153,6 +154,7 @@ static void MiniText(double x, double y, const char* t, int shade, int align = -
|
|||
x -= SmallFont2->StringWidth(t) * (align == 0 ? 0.5 : 1);
|
||||
DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, FSMode_Fit640x400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -162,6 +164,7 @@ static void MiniText(double x, double y, const char* t, int shade, int align = -
|
|||
|
||||
void Logo_r(const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
Mus_Stop();
|
||||
FX_StopAllSounds(); // JBF 20031228
|
||||
|
||||
|
@ -203,8 +206,10 @@ void Logo_r(const CompletionFunc& completion)
|
|||
jobs.Push(PlayVideo("redint.mve"));
|
||||
}
|
||||
RunScreenJob(jobs, completion, SJ_BLOCKUI);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -246,7 +251,9 @@ static void bonussequence_r(int num, TArray<DScreenJob*>& jobs)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -583,6 +590,7 @@ public:
|
|||
DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -592,6 +600,7 @@ public:
|
|||
|
||||
void dobonus_r(int bonusonly, const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
FX_StopAllSounds();
|
||||
|
@ -627,9 +636,11 @@ void dobonus_r(int bonusonly, const CompletionFunc& completion)
|
|||
if (jobs.Size())
|
||||
RunScreenJob(jobs, completion);
|
||||
else if (completion) completion(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -660,10 +671,11 @@ void loadscreen_r(MapRecord* rec, CompletionFunc func)
|
|||
jobs[0] = Create<DRRLoadScreen>(rec);
|
||||
RunScreenJob(jobs, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PrintPaused_r()
|
||||
{
|
||||
BigText(160, 100, GStrings("Game Paused"), 0);
|
||||
//BigText(160, 100, GStrings("Game Paused"), 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -372,6 +372,7 @@ void menu_DoPlasma()
|
|||
DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150);
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -509,6 +510,7 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -516,10 +518,11 @@ public:
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DScreenJob *PlayMovie(const char* fileName);
|
||||
//DScreenJob *PlayMovie(const char* fileName);
|
||||
|
||||
void DoTitle(CompletionFunc completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
jobs.Push(Create<DImageScreen>(tileGetTexture(PublisherLogo()), DScreenJob::fadein | DScreenJob::fadeout));
|
||||
|
@ -528,9 +531,10 @@ void DoTitle(CompletionFunc completion)
|
|||
jobs.Push(Create<DMainTitle>());
|
||||
|
||||
RunScreenJob(jobs, completion, SJ_BLOCKUI);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// pre-level map display
|
||||
|
@ -814,7 +818,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<DScreenJob*> &jobs)
|
||||
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<DScreenJob*> &jobs)
|
||||
{
|
||||
if (nLevel > kMap20 || nLevelNew > kMap20) // max single player levels
|
||||
{
|
||||
|
@ -831,6 +835,8 @@ public:
|
|||
jobs.Push(Create<DMapScreen>(nLevel-1, nLevelNew-1, nLevelBest-1));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// text overlay
|
||||
|
@ -961,6 +967,7 @@ void uploadCinemaPalettes()
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// cinema
|
||||
|
@ -1336,6 +1343,7 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1345,6 +1353,7 @@ public:
|
|||
|
||||
void DoGameOverScene(bool finallevel)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs(1, true);
|
||||
|
||||
if (finallevel)
|
||||
|
@ -1358,8 +1367,10 @@ void DoGameOverScene(bool finallevel)
|
|||
jobs[0] = Create<DImageScreen>(tileGetTexture(kTile3591), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff, TRANSLATION(Translation_BasePalettes, 16));
|
||||
}
|
||||
RunScreenJob(jobs, [](bool) { gameaction = ga_mainmenu; });
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void DoAfterCinemaScene(int nLevel, TArray<DScreenJob*>& jobs)
|
||||
{
|
||||
|
@ -1378,4 +1389,92 @@ void DoBeforeCinemaScene(int nLevel, TArray<DScreenJob*>& jobs)
|
|||
else if (nLevel == 11) jobs.Push(Create<DCinema>(CINEMA_BEFORE_LEVEL_11, 11));
|
||||
}
|
||||
|
||||
void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<DScreenJob*>& jobs)
|
||||
{
|
||||
if (nLevelNew == 5 && !(nCinemaSeen & 1)) {
|
||||
nCinemaSeen |= 1;
|
||||
DoBeforeCinemaScene(5, jobs);
|
||||
}
|
||||
|
||||
menu_DrawTheMap(nLevel, nLevelNew, nLevelBest, jobs);
|
||||
|
||||
if (nLevelNew == 11 && !(nCinemaSeen & 2)) {
|
||||
DoBeforeCinemaScene(11, jobs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Intermission(MapRecord* from_map, MapRecord* to_map)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
if (from_map) StopAllSounds();
|
||||
bCamera = false;
|
||||
automapMode = am_off;
|
||||
|
||||
if (to_map)
|
||||
{
|
||||
if (to_map->levelNumber != 0)
|
||||
nBestLevel = to_map->levelNumber - 1;
|
||||
|
||||
STAT_Update(false);
|
||||
if (to_map->levelNumber == kMap20)
|
||||
nPlayerLives[0] = 0;
|
||||
|
||||
if (to_map->levelNumber == 0) // skip all intermission stuff when going to the training map.
|
||||
{
|
||||
gameaction = ga_nextlevel;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DoAfterCinemaScene(to_map->levelNumber - 1, jobs);
|
||||
}
|
||||
if (to_map->levelNumber > -1 && to_map->levelNumber < kMap20)
|
||||
{
|
||||
// start a new game at the given level
|
||||
if (!nNetPlayerCount && to_map->levelNumber > 0)
|
||||
{
|
||||
showmap(from_map ? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs);
|
||||
}
|
||||
else
|
||||
jobs.Push(Create<DBlackScreen>(1)); // we need something in here even in the multiplayer case.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DoAfterCinemaScene(20, jobs);
|
||||
STAT_Update(true);
|
||||
}
|
||||
|
||||
|
||||
if (jobs.Size() > 0)
|
||||
{
|
||||
RunScreenJob(jobs, [=](bool)
|
||||
{
|
||||
if (!to_map) gameaction = ga_startup; // this was the end of the game
|
||||
else
|
||||
{
|
||||
if (to_map->levelNumber != selectedlevelnew)
|
||||
{
|
||||
// User can switch destination on the scrolling map.
|
||||
g_nextmap = FindMapByLevelNum(selectedlevelnew);
|
||||
STAT_Cancel();
|
||||
}
|
||||
gameaction = ga_nextlevel;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
END_PS_NS
|
||||
|
|
|
@ -54,8 +54,6 @@ void SetHiRes();
|
|||
void BlackOut();
|
||||
|
||||
void DoGameOverScene(bool finallevel);
|
||||
void DoAfterCinemaScene(int nLevel, TArray<DScreenJob*> &jobs);
|
||||
void DoBeforeCinemaScene(int nLevel, TArray<DScreenJob*>& jobs);
|
||||
|
||||
int Query(short n, short l, ...);
|
||||
|
||||
|
@ -88,7 +86,6 @@ void InitNewGame();
|
|||
|
||||
int showmap(short nLevel, short nLevelNew, short nLevelBest);
|
||||
void menu_DoPlasma();
|
||||
void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray<DScreenJob*>& jobs);
|
||||
void DoEnergyTile();
|
||||
void InitEnergyTile();
|
||||
|
||||
|
|
|
@ -62,19 +62,6 @@ void DrawClock();
|
|||
double calc_smoothratio();
|
||||
void DoTitle(CompletionFunc completion);
|
||||
|
||||
static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<DScreenJob*> &jobs)
|
||||
{
|
||||
if (nLevelNew == 5 && !(nCinemaSeen & 1)) {
|
||||
nCinemaSeen |= 1;
|
||||
DoBeforeCinemaScene(5, jobs);
|
||||
}
|
||||
|
||||
menu_DrawTheMap(nLevel, nLevelNew, nLevelBest, jobs);
|
||||
|
||||
if (nLevelNew == 11 && !(nCinemaSeen & 2)) {
|
||||
DoBeforeCinemaScene(11, jobs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameInterface::Render()
|
||||
|
@ -127,77 +114,6 @@ void GameInterface::DrawBackground()
|
|||
DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150, 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void Intermission(MapRecord *from_map, MapRecord *to_map)
|
||||
{
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
if (from_map) StopAllSounds();
|
||||
bCamera = false;
|
||||
automapMode = am_off;
|
||||
|
||||
if (to_map)
|
||||
{
|
||||
if (to_map->levelNumber != 0)
|
||||
nBestLevel = to_map->levelNumber - 1;
|
||||
|
||||
STAT_Update(false);
|
||||
if (to_map->levelNumber == kMap20)
|
||||
nPlayerLives[0] = 0;
|
||||
|
||||
if (to_map->levelNumber == 0) // skip all intermission stuff when going to the training map.
|
||||
{
|
||||
gameaction = ga_nextlevel;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DoAfterCinemaScene(to_map->levelNumber - 1, jobs);
|
||||
}
|
||||
if (to_map->levelNumber > -1 && to_map->levelNumber < kMap20)
|
||||
{
|
||||
// start a new game at the given level
|
||||
if (!nNetPlayerCount && to_map->levelNumber > 0)
|
||||
{
|
||||
showmap(from_map ? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs);
|
||||
}
|
||||
else
|
||||
jobs.Push(Create<DBlackScreen>(1)); // we need something in here even in the multiplayer case.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DoAfterCinemaScene(20, jobs);
|
||||
STAT_Update(true);
|
||||
}
|
||||
|
||||
|
||||
if (jobs.Size() > 0)
|
||||
{
|
||||
RunScreenJob(jobs, [=](bool)
|
||||
{
|
||||
if (!to_map) gameaction = ga_startup; // this was the end of the game
|
||||
else
|
||||
{
|
||||
if (to_map->levelNumber != selectedlevelnew)
|
||||
{
|
||||
// User can switch destination on the scrolling map.
|
||||
g_nextmap = FindMapByLevelNum(selectedlevelnew);
|
||||
STAT_Cancel();
|
||||
}
|
||||
gameaction = ga_nextlevel;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GameInterface::NextLevel(MapRecord *map, int skill)
|
||||
{
|
||||
InitLevel(map->levelNumber);
|
||||
|
@ -212,6 +128,8 @@ void GameInterface::NextLevel(MapRecord *map, int skill)
|
|||
|
||||
}
|
||||
|
||||
void Intermission(MapRecord* from_map, MapRecord* to_map);
|
||||
|
||||
void GameInterface::NewGame(MapRecord *map, int skill, bool frommenu)
|
||||
{
|
||||
// start a new game on the given level
|
||||
|
|
|
@ -194,6 +194,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -288,5 +289,6 @@ DScreenJob* PlayMovie(const char* fileName)
|
|||
fp.Seek(0, FileReader::SeekSet);
|
||||
return Create<DLmfPlayer>(fp);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_PS_NS
|
||||
|
|
|
@ -39,6 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
BEGIN_SW_NS
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -64,6 +65,7 @@ public:
|
|||
DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -74,6 +76,7 @@ public:
|
|||
|
||||
void Logo(const CompletionFunc& completion)
|
||||
{
|
||||
#if 0
|
||||
StopSound();
|
||||
PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]);
|
||||
|
||||
|
@ -94,8 +97,11 @@ void Logo(const CompletionFunc& completion)
|
|||
RunScreenJob(jobs, completion, SJ_BLOCKUI);
|
||||
}
|
||||
else completion(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -225,7 +231,7 @@ class DSWCreditsScreen : public DSkippableScreenJob
|
|||
DrawTexture(twod, tileGetTexture(curpic, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Summary screen
|
||||
|
@ -340,6 +346,7 @@ static STATE * s_BonusAnim[] =
|
|||
s_BonusGrab
|
||||
};
|
||||
|
||||
#if 0
|
||||
class DSWLevelSummaryScreen : public DScreenJob
|
||||
{
|
||||
int minutes, seconds, second_tics;
|
||||
|
@ -462,6 +469,7 @@ private:
|
|||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -483,7 +491,7 @@ enum
|
|||
STAT_TABLE_XOFF = SM_SIZ(6)
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
class DSWMultiSummaryScreen : public DSkippableScreenJob
|
||||
{
|
||||
short death_total[MAX_SW_PLAYERS_REG]{};
|
||||
|
@ -596,6 +604,7 @@ class DSWMultiSummaryScreen : public DSkippableScreenJob
|
|||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -605,6 +614,7 @@ class DSWMultiSummaryScreen : public DSkippableScreenJob
|
|||
|
||||
void StatScreen(int FinishAnim, CompletionFunc completion)
|
||||
{
|
||||
#if 0
|
||||
TArray<DScreenJob*> jobs;
|
||||
|
||||
if (FinishAnim)
|
||||
|
@ -624,6 +634,7 @@ void StatScreen(int FinishAnim, CompletionFunc completion)
|
|||
jobs.Push(Create<DSWMultiSummaryScreen>());
|
||||
}
|
||||
RunScreenJob(jobs, completion);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -634,6 +645,7 @@ void StatScreen(int FinishAnim, CompletionFunc completion)
|
|||
|
||||
void SybexScreen(CompletionFunc completion)
|
||||
{
|
||||
#if 0
|
||||
if (!SW_SHAREWARE || CommEnabled) completion(false);
|
||||
else
|
||||
{
|
||||
|
@ -641,8 +653,10 @@ void SybexScreen(CompletionFunc completion)
|
|||
jobs[0] = Create<DImageScreen>(tileGetTexture(5261), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff);
|
||||
RunScreenJob(jobs, completion, SJ_BLOCKUI);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -673,5 +687,6 @@ void loadscreen(MapRecord* rec, CompletionFunc func)
|
|||
jobs[0] = Create<DSWLoadScreen>(rec);
|
||||
RunScreenJob(jobs, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -406,6 +406,7 @@ struct Screen native
|
|||
native static double, double, double, double GetFullscreenRect(double vwidth, double vheight, int fsmode);
|
||||
native static Vector2 SetOffset(double x, double y);
|
||||
native static void ClearScreen(color col = 0);
|
||||
native static void SetScreenFade(double factor);
|
||||
}
|
||||
|
||||
struct Font native
|
||||
|
|
|
@ -261,7 +261,7 @@ class E2EndScreen : ImageScreen
|
|||
{
|
||||
void Init()
|
||||
{
|
||||
Super.Init("E2ENDSCREEN", fadein | fadeout | stopsound, 0x7fffffff, 0);
|
||||
Super.InitNamed("E2ENDSCREEN", fadein | fadeout | stopsound, 0x7fffffff, 0);
|
||||
}
|
||||
|
||||
override void Start()
|
||||
|
@ -283,8 +283,7 @@ class Episode3End : ImageScreen
|
|||
|
||||
void Init()
|
||||
{
|
||||
Super.Init("", fadein|fadeout, 0x7fffffff);
|
||||
texid = TexMan.CheckForTexture("radlogo.anm", TexMan.Type_Any, TexMan.TryAny | TexMan.ForceLookup); // must override with 'forcelookup'.
|
||||
Super.InitNamed("radlogo.anm", fadein|fadeout, 0x7fffffff);
|
||||
soundstate = 0;
|
||||
finishtime = 0;
|
||||
}
|
||||
|
@ -402,7 +401,7 @@ class Episode5End : ImageScreen
|
|||
{
|
||||
void Init()
|
||||
{
|
||||
Super.Init("FIREFLYGROWEFFECT", fadein|fadeout|stopsound);
|
||||
Super.InitNamed("FIREFLYGROWEFFECT", fadein|fadeout|stopsound);
|
||||
}
|
||||
|
||||
override void OnTick()
|
||||
|
|
|
@ -29,15 +29,16 @@ enum EGameType
|
|||
|
||||
struct UserConfigStruct native
|
||||
{
|
||||
native bool nomonsters;
|
||||
native bool nosound;
|
||||
native bool nologo;
|
||||
native readonly bool nomonsters;
|
||||
native readonly bool nosound;
|
||||
native readonly bool nologo;
|
||||
}
|
||||
|
||||
extend struct _
|
||||
{
|
||||
native @UserConfigStruct userConfig;
|
||||
native MapRecord currentLevel;
|
||||
native readonly MapRecord currentLevel;
|
||||
native readonly int paused;
|
||||
}
|
||||
|
||||
struct MapRecord native
|
||||
|
@ -91,8 +92,10 @@ struct Raze
|
|||
native static Color shadeToLight(int shade);
|
||||
native static void StopAllSounds();
|
||||
native static bool SoundEnabled();
|
||||
native static void StopMusic();
|
||||
native static bool MusicEnabled();
|
||||
native static String PlayerName(int i);
|
||||
native static double GetTimeFrac();
|
||||
|
||||
static bool specialKeyEvent(InputEvent ev)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
class ScreenJob native
|
||||
class ScreenJob : Object
|
||||
{
|
||||
native int flags;
|
||||
native float fadetime; // in milliseconds
|
||||
native int fadestate;
|
||||
int flags;
|
||||
float fadetime; // in milliseconds
|
||||
int fadestate;
|
||||
|
||||
native int ticks;
|
||||
native int jobstate;
|
||||
native bool pausable;
|
||||
int ticks;
|
||||
int jobstate;
|
||||
bool pausable;
|
||||
|
||||
enum EJobState
|
||||
{
|
||||
|
@ -26,17 +26,41 @@ class ScreenJob native
|
|||
stopsound = 8,
|
||||
};
|
||||
|
||||
native void Init(int flags = 0, float fadet = 250.f);
|
||||
native virtual bool ProcessInput();
|
||||
native virtual void Start();
|
||||
native virtual bool OnEvent(InputEvent evt);
|
||||
native virtual void OnTick();
|
||||
native virtual void Draw(double smoothratio);
|
||||
void Init(int flags = 0, float fadet = 250.f)
|
||||
{
|
||||
flags = fadet;
|
||||
fadetime = fadet;
|
||||
jobstate = running;
|
||||
pausable = true;
|
||||
}
|
||||
|
||||
virtual bool ProcessInput()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void Start() {}
|
||||
virtual bool OnEvent(InputEvent evt) { return false; }
|
||||
virtual void OnTick() {}
|
||||
virtual void Draw(double smoothratio) {}
|
||||
virtual void OnSkip() {}
|
||||
|
||||
//native int DrawFrame(double smoothratio);
|
||||
//native int GetFadeState();
|
||||
//native override void OnDestroy();
|
||||
int DrawFrame(double smoothratio)
|
||||
{
|
||||
if (jobstate != running) smoothratio = 1; // this is necessary because the ticker won't be incremented anymore to avoid having a negative time span.
|
||||
Draw(smoothratio);
|
||||
if (jobstate == skipped) return -1;
|
||||
if (jobstate == finished) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFadeState() { return fadestate; }
|
||||
override void OnDestroy()
|
||||
{
|
||||
if (flags & stopmusic) Raze.StopMusic();
|
||||
if (flags & stopsound) Raze.StopAllSounds();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -45,10 +69,22 @@ class ScreenJob native
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class SkippableScreenJob : ScreenJob native
|
||||
class SkippableScreenJob : ScreenJob
|
||||
{
|
||||
native void Init(int flags = 0, float fadet = 250.f);
|
||||
//native override bool OnEvent(InputEvent evt);
|
||||
void Init(int flags = 0, float fadet = 250.f)
|
||||
{
|
||||
Super.Init(flags, fadet);
|
||||
}
|
||||
|
||||
override bool OnEvent(InputEvent evt)
|
||||
{
|
||||
if (evt.type == InputEvent.Type_KeyDown && !Raze.specialKeyEvent(evt))
|
||||
{
|
||||
jobstate = skipped;
|
||||
OnSkip();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -57,14 +93,32 @@ class SkippableScreenJob : ScreenJob native
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class BlackScreen : ScreenJob native
|
||||
class BlackScreen : ScreenJob
|
||||
{
|
||||
native int wait;
|
||||
native bool cleared;
|
||||
int wait;
|
||||
bool cleared;
|
||||
|
||||
native void Init(int w, int flags = 0);
|
||||
//override void OnTick();
|
||||
//override void Draw(double smooth);
|
||||
void Init(int w, int flags = 0)
|
||||
{
|
||||
Super.Init(flags & ~(fadein|fadeout));
|
||||
wait = w;
|
||||
cleared = false;
|
||||
}
|
||||
|
||||
override void OnTick()
|
||||
{
|
||||
if (cleared)
|
||||
{
|
||||
int span = ticks * 1000 / GameTicRate;
|
||||
if (span > wait) jobstate = finished;
|
||||
}
|
||||
}
|
||||
|
||||
override void Draw(double smooth)
|
||||
{
|
||||
cleared = true;
|
||||
Screen.ClearScreen();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -73,17 +127,46 @@ class BlackScreen : ScreenJob native
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class ImageScreen : SkippableScreenJob native
|
||||
class ImageScreen : SkippableScreenJob
|
||||
{
|
||||
native int tilenum;
|
||||
native int trans;
|
||||
native int waittime; // in ms.
|
||||
native bool cleared;
|
||||
native TextureID texid;
|
||||
int tilenum;
|
||||
int trans;
|
||||
int waittime; // in ms.
|
||||
bool cleared;
|
||||
TextureID texid;
|
||||
|
||||
native void Init(String tex, int fade = fadein | fadeout, int wait = 3000, int translation = 0);
|
||||
//override void OnTick();
|
||||
//override void Draw(double smooth);
|
||||
void Init(TextureID tile, int fade = fadein | fadeout, int wait = 3000, int translation = 0)
|
||||
{
|
||||
Super.Init(fade);
|
||||
waittime = wait;
|
||||
texid = tile;
|
||||
trans = translation;
|
||||
cleared = false;
|
||||
}
|
||||
|
||||
void InitNamed(String tex, int fade = fadein | fadeout, int wait = 3000, int translation = 0)
|
||||
{
|
||||
Super.Init(fade);
|
||||
waittime = wait;
|
||||
texid = TexMan.CheckForTexture(tex, TexMan.Type_Any, TexMan.TryAny | TexMan.ForceLookup);
|
||||
trans = translation;
|
||||
cleared = false;
|
||||
}
|
||||
override void OnTick()
|
||||
{
|
||||
if (cleared)
|
||||
{
|
||||
int span = ticks * 1000 / GameTicRate;
|
||||
if (span > waittime) jobstate = finished;
|
||||
}
|
||||
}
|
||||
|
||||
override void Draw(double smooth)
|
||||
{
|
||||
Screen.ClearScreen();
|
||||
if (texid.IsValid()) Screen.DrawTexture(texid, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_TranslationIndex, trans);
|
||||
cleared = true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -119,3 +202,284 @@ class SummaryScreenBase : ScreenJob
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// internal polymorphic movie player object
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct AnmControl // ANM has no internal timing and sound info. Ugh...
|
||||
{
|
||||
Array<int> sounds;
|
||||
int frameticks[3]; // first and last frame have their own durations.
|
||||
}
|
||||
|
||||
struct MoviePlayer native
|
||||
{
|
||||
native static MoviePlayer OpenMovie(String filename, AnmControl ans, bool nosoundcutoff, out String error);
|
||||
native void Start();
|
||||
native bool Frame(double clock);
|
||||
native bool Destroy();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class MoviePlayerJob : SkippableScreenJob
|
||||
{
|
||||
MoviePlayer player;
|
||||
bool started;
|
||||
|
||||
void Init(MoviePlayer mp)
|
||||
{
|
||||
player = mp;
|
||||
pausable = false;
|
||||
}
|
||||
|
||||
override void Draw(double smoothratio)
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
jobstate = stopped;
|
||||
return;
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started = true;
|
||||
player.Start();
|
||||
}
|
||||
double clock = (ticks + smoothratio) * 1000000000. / GameTicRate;
|
||||
if (jobstate == running && !player.Frame(clock))
|
||||
{
|
||||
jobstate = finished;
|
||||
}
|
||||
}
|
||||
|
||||
override void OnDestroy()
|
||||
{
|
||||
if (player)
|
||||
{
|
||||
player.Destroy();
|
||||
}
|
||||
player = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class ScreenJobRunner : Object
|
||||
{
|
||||
enum ERunState
|
||||
{
|
||||
State_Clear,
|
||||
State_Run,
|
||||
State_Fadeout,
|
||||
}
|
||||
Array<ScreenJob> jobs;
|
||||
//CompletionFunc completion;
|
||||
int index;
|
||||
float screenfade;
|
||||
bool clearbefore;
|
||||
bool skipall;
|
||||
bool advance;
|
||||
int actionState;
|
||||
int terminateState;
|
||||
int fadeticks;
|
||||
int last_paused_tic;
|
||||
|
||||
void Init(bool clearbefore_ = true, bool skipall_ = false)
|
||||
{
|
||||
clearbefore = clearbefore_;
|
||||
skipall = skipall_;
|
||||
index = -1;
|
||||
fadeticks = 0;
|
||||
last_paused_tic = -1;
|
||||
}
|
||||
|
||||
override void OnDestroy()
|
||||
{
|
||||
DeleteJobs();
|
||||
}
|
||||
|
||||
void DeleteJobs()
|
||||
{
|
||||
// Free all allocated resources now.
|
||||
for (int i = 0; i < jobs.Size(); i++)
|
||||
{
|
||||
if (jobs[i]) jobs[i].Destroy();
|
||||
}
|
||||
jobs.Clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void AdvanceJob(bool skip)
|
||||
{
|
||||
if (index == jobs.Size()-1)
|
||||
{
|
||||
index++;
|
||||
return; // we need to retain the last element until the runner is done.
|
||||
}
|
||||
|
||||
if (index >= 0) jobs[index].Destroy();
|
||||
index++;
|
||||
while (index < jobs.Size() && (jobs[index] == null || (skip && skipall)))
|
||||
{
|
||||
if (jobs[index] != null) jobs[index].Destroy();
|
||||
index++;
|
||||
}
|
||||
actionState = clearbefore ? State_Clear : State_Run;
|
||||
if (index < jobs.Size())
|
||||
{
|
||||
jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible;
|
||||
jobs[index].Start();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
virtual int DisplayFrame(double smoothratio)
|
||||
{
|
||||
int x = index >= jobs.Size()? jobs.Size()-1 : index;
|
||||
let job = jobs[x];
|
||||
bool processed = job.ProcessInput();
|
||||
|
||||
if (job.fadestate == ScreenJob.fadein)
|
||||
{
|
||||
double ms = (job.ticks + smoothratio) * 1000 / GameTicRate / job.fadetime;
|
||||
double screenfade = clamp(ms, 0., 1.);
|
||||
Screen.SetScreenFade(screenfade);
|
||||
if (screenfade == 1.) job.fadestate = ScreenJob.visible;
|
||||
}
|
||||
int state = job.DrawFrame(smoothratio);
|
||||
Screen.SetScreenFade(1.);
|
||||
return state;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
virtual int FadeoutFrame(double smoothratio)
|
||||
{
|
||||
int x = index >= jobs.Size()? jobs.Size()-1 : index;
|
||||
let job = jobs[x];
|
||||
double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job.fadetime;
|
||||
float screenfade = 1. - clamp(ms, 0., 1.);
|
||||
Screen.SetScreenFade(screenfade);
|
||||
job.DrawFrame(1.);
|
||||
Screen.SetScreenFade(1.);
|
||||
return (screenfade > 0.);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
virtual bool OnEvent(InputEvent ev)
|
||||
{
|
||||
if (paused || index >= jobs.Size()) return false;
|
||||
if (jobs[index].jobstate != ScreenJob.running) return false;
|
||||
return jobs[index].OnEvent(ev);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
virtual bool OnTick()
|
||||
{
|
||||
if (paused) return false;
|
||||
if (advance)
|
||||
{
|
||||
advance = false;
|
||||
AdvanceJob(terminateState < 0);
|
||||
if (index >= jobs.Size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (jobs[index].jobstate == ScreenJob.running)
|
||||
{
|
||||
jobs[index].ticks++;
|
||||
jobs[index].OnTick();
|
||||
}
|
||||
else if (jobs[index].jobstate == ScreenJob.stopping)
|
||||
{
|
||||
fadeticks++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
virtual bool RunFrame(double smoothratio)
|
||||
{
|
||||
// ensure that we won't go back in time if the menu is dismissed without advancing our ticker
|
||||
bool menuon = paused;
|
||||
if (menuon) last_paused_tic = jobs[index].ticks;
|
||||
else if (last_paused_tic == jobs[index].ticks) menuon = true;
|
||||
if (menuon || index >= jobs.Size()) smoothratio = 1.;
|
||||
|
||||
if (actionState == State_Clear)
|
||||
{
|
||||
actionState = State_Run;
|
||||
Screen.ClearScreen();
|
||||
}
|
||||
else if (actionState == State_Run)
|
||||
{
|
||||
terminateState = DisplayFrame(smoothratio);
|
||||
if (terminateState < 1 && index < jobs.Size())
|
||||
{
|
||||
if (jobs[index].flags & ScreenJob.fadeout)
|
||||
{
|
||||
jobs[index].fadestate = ScreenJob.fadeout;
|
||||
jobs[index].jobstate = ScreenJob.stopping;
|
||||
actionState = State_Fadeout;
|
||||
fadeticks = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
advance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (actionState == State_Fadeout)
|
||||
{
|
||||
int ended = FadeoutFrame(smoothratio);
|
||||
if (ended < 1 && index < jobs.Size())
|
||||
{
|
||||
jobs[index].jobstate = ScreenJob.stopped;
|
||||
advance = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue