mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-15 12:10:53 +00:00
- Duke's intro works, without fading.
This commit is contained in:
parent
1166b00af2
commit
26a7700579
7 changed files with 56 additions and 26 deletions
|
@ -948,6 +948,7 @@ int RunGame()
|
||||||
LoadScripts();
|
LoadScripts();
|
||||||
StartScreen->Progress();
|
StartScreen->Progress();
|
||||||
SetDefaultStrings();
|
SetDefaultStrings();
|
||||||
|
Job_Init();
|
||||||
if (Args->CheckParm("-sounddebug"))
|
if (Args->CheckParm("-sounddebug"))
|
||||||
C_DoCommand("stat sounddebug");
|
C_DoCommand("stat sounddebug");
|
||||||
|
|
||||||
|
|
|
@ -333,6 +333,7 @@ static void GameTicker()
|
||||||
case GS_INTRO:
|
case GS_INTRO:
|
||||||
if (ScreenJobTick())
|
if (ScreenJobTick())
|
||||||
{
|
{
|
||||||
|
Printf("Sending event\n");
|
||||||
// synchronize termination with the playsim.
|
// synchronize termination with the playsim.
|
||||||
Net_WriteByte(DEM_ENDSCREENJOB);
|
Net_WriteByte(DEM_ENDSCREENJOB);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,14 +86,15 @@ class AnmPlayer : public MoviePlayer
|
||||||
int nextframetime = 0;
|
int nextframetime = 0;
|
||||||
AnimTextures animtex;
|
AnimTextures animtex;
|
||||||
const TArray<int> animSnd;
|
const TArray<int> animSnd;
|
||||||
const int* frameTicks;
|
int frameTicks[3];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isvalid() { return numframes > 0; }
|
bool isvalid() { return numframes > 0; }
|
||||||
|
|
||||||
AnmPlayer(FileReader& fr, TArray<int>& ans, const int *frameticks, int flags_)
|
AnmPlayer(FileReader& fr, TArray<int>& ans, const int *frameticks, int flags_)
|
||||||
: animSnd(std::move(ans)), frameTicks(frameticks)
|
: animSnd(std::move(ans))
|
||||||
{
|
{
|
||||||
|
memcpy(frameTicks, frameticks, 3 * sizeof(int));
|
||||||
flags = flags_;
|
flags = flags_;
|
||||||
buffer = fr.ReadPadded(1);
|
buffer = fr.ReadPadded(1);
|
||||||
fr.Close();
|
fr.Close();
|
||||||
|
@ -798,7 +799,7 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Frame)
|
||||||
{
|
{
|
||||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||||
PARAM_FLOAT(clock);
|
PARAM_FLOAT(clock);
|
||||||
self->Frame(int64_t(clock));
|
ACTION_RETURN_INT(self->Frame(int64_t(clock)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ static int ticks;
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
static void Job_Init()
|
void Job_Init()
|
||||||
{
|
{
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
if (!done)
|
if (!done)
|
||||||
|
@ -215,6 +215,7 @@ bool StartCutscene(CutsceneDef& cs, int flags, CompletionFunc completion_)
|
||||||
{
|
{
|
||||||
completion = completion_;
|
completion = completion_;
|
||||||
runner = CreateRunner();
|
runner = CreateRunner();
|
||||||
|
GC::WriteBarrier(runner);
|
||||||
cs.Create(runner);
|
cs.Create(runner);
|
||||||
gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission;
|
gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission;
|
||||||
return true;
|
return true;
|
||||||
|
@ -225,12 +226,13 @@ bool StartCutscene(CutsceneDef& cs, int flags, CompletionFunc completion_)
|
||||||
|
|
||||||
void DeleteScreenJob()
|
void DeleteScreenJob()
|
||||||
{
|
{
|
||||||
runner->Destroy();
|
if (runner) runner->Destroy();
|
||||||
runner = nullptr;
|
runner = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndScreenJob()
|
void EndScreenJob()
|
||||||
{
|
{
|
||||||
|
Printf("EndScreenJob\n");
|
||||||
DeleteScreenJob();
|
DeleteScreenJob();
|
||||||
if (completion) completion(false);
|
if (completion) completion(false);
|
||||||
completion = nullptr;
|
completion = nullptr;
|
||||||
|
|
|
@ -10,6 +10,9 @@ using CompletionFunc = std::function<void(bool)>;
|
||||||
struct JobDesc;
|
struct JobDesc;
|
||||||
class ScreenJobRunner;
|
class ScreenJobRunner;
|
||||||
|
|
||||||
|
void Job_Init();
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
class DScreenJob : public DObject
|
class DScreenJob : public DObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
struct DukeCutscenes
|
class DukeCutscenes // Note: must be class, not struct, otherwise we cannot easily look up the methods from C++.
|
||||||
{
|
{
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -205,7 +205,7 @@ struct DukeCutscenes
|
||||||
|
|
||||||
static void BuildMPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats)
|
static void BuildMPSummary(ScreenJobRunner runner, MapRecord map, SummaryInfo stats)
|
||||||
{
|
{
|
||||||
runner.Append(new("DukeMultiplayerBonusScreen").Init(playerswhenstarted));
|
runner.Append(new("DukeMultiplayerBonusScreen").Init(stats.playercount));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -260,7 +260,7 @@ struct DukeCutscenes
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RRCutscenes
|
class RRCutscenes
|
||||||
{
|
{
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -301,7 +301,7 @@ struct RRCutscenes
|
||||||
|
|
||||||
static void BuildE1End(ScreenJobRunner runner)
|
static void BuildE1End(ScreenJobRunner runner)
|
||||||
{
|
{
|
||||||
if (!isRRRA())
|
if (!Raze.isRRRA())
|
||||||
{
|
{
|
||||||
Array<int> soundinfo;
|
Array<int> soundinfo;
|
||||||
soundinfo.Pushv(1, RRSnd.CHKAMMO + 1);
|
soundinfo.Pushv(1, RRSnd.CHKAMMO + 1);
|
||||||
|
@ -318,7 +318,7 @@ struct RRCutscenes
|
||||||
|
|
||||||
static void BuildE2End(ScreenJobRunner runner)
|
static void BuildE2End(ScreenJobRunner runner)
|
||||||
{
|
{
|
||||||
if (!isRRRA())
|
if (!Raze.isRRRA())
|
||||||
{
|
{
|
||||||
Array<int> soundinfo;
|
Array<int> soundinfo;
|
||||||
soundinfo.Pushv(1, RRSnd.LN_FINAL + 1);
|
soundinfo.Pushv(1, RRSnd.LN_FINAL + 1);
|
||||||
|
|
|
@ -7,15 +7,14 @@ class ScreenJob : Object
|
||||||
|
|
||||||
int ticks;
|
int ticks;
|
||||||
int jobstate;
|
int jobstate;
|
||||||
bool pausable;
|
|
||||||
|
|
||||||
enum EJobState
|
enum EJobState
|
||||||
{
|
{
|
||||||
running = 1, // normal operation
|
running = 0, // normal operation
|
||||||
skipped = 2, // finished by user skipping
|
skipped = 1, // finished by user skipping
|
||||||
finished = 3, // finished by completing its sequence
|
finished = 2, // finished by completing its sequence
|
||||||
stopping = 4, // running ending animations / fadeout, etc. Will not accept more input.
|
stopping = 3, // running ending animations / fadeout, etc. Will not accept more input.
|
||||||
stopped = 5, // we're done here.
|
stopped = 4, // we're done here.
|
||||||
};
|
};
|
||||||
enum EJobFlags
|
enum EJobFlags
|
||||||
{
|
{
|
||||||
|
@ -31,7 +30,6 @@ class ScreenJob : Object
|
||||||
flags = fadet;
|
flags = fadet;
|
||||||
fadetime = fadet;
|
fadetime = fadet;
|
||||||
jobstate = running;
|
jobstate = running;
|
||||||
pausable = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ProcessInput()
|
virtual bool ProcessInput()
|
||||||
|
@ -78,8 +76,10 @@ class SkippableScreenJob : ScreenJob
|
||||||
|
|
||||||
override bool OnEvent(InputEvent evt)
|
override bool OnEvent(InputEvent evt)
|
||||||
{
|
{
|
||||||
|
Console.Printf("OnEvent");
|
||||||
if (evt.type == InputEvent.Type_KeyDown && !Raze.specialKeyEvent(evt))
|
if (evt.type == InputEvent.Type_KeyDown && !Raze.specialKeyEvent(evt))
|
||||||
{
|
{
|
||||||
|
Console.Printf("Skip requested");
|
||||||
jobstate = skipped;
|
jobstate = skipped;
|
||||||
OnSkip();
|
OnSkip();
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ struct MoviePlayer native
|
||||||
native static MoviePlayer Create(String filename, Array<int> soundinfo, int flags, int frametime, int firstframetime, int lastframetime);
|
native static MoviePlayer Create(String filename, Array<int> soundinfo, int flags, int frametime, int firstframetime, int lastframetime);
|
||||||
native void Start();
|
native void Start();
|
||||||
native bool Frame(double clock);
|
native bool Frame(double clock);
|
||||||
native bool Destroy();
|
native void Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -246,8 +246,8 @@ class MoviePlayerJob : SkippableScreenJob
|
||||||
|
|
||||||
ScreenJob Init(MoviePlayer mp)
|
ScreenJob Init(MoviePlayer mp)
|
||||||
{
|
{
|
||||||
|
Super.Init();
|
||||||
player = mp;
|
player = mp;
|
||||||
pausable = false;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,19 +272,25 @@ class MoviePlayerJob : SkippableScreenJob
|
||||||
|
|
||||||
override void Draw(double smoothratio)
|
override void Draw(double smoothratio)
|
||||||
{
|
{
|
||||||
|
Console.Printf("MoviePlayer.Draw state = %d", jobstate);
|
||||||
|
|
||||||
if (!player)
|
if (!player)
|
||||||
{
|
{
|
||||||
|
Console.Printf("MoviePlayer.Draw: end");
|
||||||
jobstate = stopped;
|
jobstate = stopped;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!started)
|
if (!started)
|
||||||
{
|
{
|
||||||
|
Console.Printf("MoviePlayer.Draw: start");
|
||||||
started = true;
|
started = true;
|
||||||
player.Start();
|
player.Start();
|
||||||
}
|
}
|
||||||
double clock = (ticks + smoothratio) * 1000000000. / GameTicRate;
|
double clock = (ticks + smoothratio) * 1000000000. / GameTicRate;
|
||||||
|
Console.Printf("MoviePlayer.Frame %d %f", ticks, clock);
|
||||||
if (jobstate == running && !player.Frame(clock))
|
if (jobstate == running && !player.Frame(clock))
|
||||||
{
|
{
|
||||||
|
Console.Printf("MoviePlayer.finish");
|
||||||
jobstate = finished;
|
jobstate = finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,6 +358,7 @@ class ScreenJobRunner : Object
|
||||||
|
|
||||||
void Append(ScreenJob job)
|
void Append(ScreenJob job)
|
||||||
{
|
{
|
||||||
|
Console.Printf("Appending job of type " .. job.GetClassName() );
|
||||||
jobs.Push(job);
|
jobs.Push(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +372,7 @@ class ScreenJobRunner : Object
|
||||||
{
|
{
|
||||||
if (index == jobs.Size()-1)
|
if (index == jobs.Size()-1)
|
||||||
{
|
{
|
||||||
|
Console.Printf("AdvanceJob: reached end of list");
|
||||||
index++;
|
index++;
|
||||||
return; // we need to retain the last element until the runner is done.
|
return; // we need to retain the last element until the runner is done.
|
||||||
}
|
}
|
||||||
|
@ -379,6 +387,7 @@ class ScreenJobRunner : Object
|
||||||
actionState = clearbefore ? State_Clear : State_Run;
|
actionState = clearbefore ? State_Clear : State_Run;
|
||||||
if (index < jobs.Size())
|
if (index < jobs.Size())
|
||||||
{
|
{
|
||||||
|
Console.Printf("AdvanceJob: starting job at index %d, type %s", index, jobs[index].GetClassName());
|
||||||
jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible;
|
jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible;
|
||||||
jobs[index].Start();
|
jobs[index].Start();
|
||||||
}
|
}
|
||||||
|
@ -406,6 +415,7 @@ class ScreenJobRunner : Object
|
||||||
double ms = (job.ticks + smoothratio) * 1000 / GameTicRate / job.fadetime;
|
double ms = (job.ticks + smoothratio) * 1000 / GameTicRate / job.fadetime;
|
||||||
double screenfade = clamp(ms, 0., 1.);
|
double screenfade = clamp(ms, 0., 1.);
|
||||||
Screen.SetScreenFade(screenfade);
|
Screen.SetScreenFade(screenfade);
|
||||||
|
Console.Printf("DisplayFrame: fading in %s with %f", job.GetClassName(), screenfade);
|
||||||
if (screenfade == 1.) job.fadestate = ScreenJob.visible;
|
if (screenfade == 1.) job.fadestate = ScreenJob.visible;
|
||||||
}
|
}
|
||||||
int state = job.DrawFrame(smoothratio);
|
int state = job.DrawFrame(smoothratio);
|
||||||
|
@ -428,6 +438,7 @@ class ScreenJobRunner : Object
|
||||||
Screen.SetScreenFade(screenfade);
|
Screen.SetScreenFade(screenfade);
|
||||||
job.DrawFrame(1.);
|
job.DrawFrame(1.);
|
||||||
Screen.SetScreenFade(1.);
|
Screen.SetScreenFade(1.);
|
||||||
|
Console.Printf("FadeoutFrame: fading out %s with %f", job.GetClassName(), screenfade);
|
||||||
return (screenfade > 0.);
|
return (screenfade > 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,6 +452,7 @@ class ScreenJobRunner : Object
|
||||||
{
|
{
|
||||||
if (paused || index >= jobs.Size()) return false;
|
if (paused || index >= jobs.Size()) return false;
|
||||||
if (jobs[index].jobstate != ScreenJob.running) return false;
|
if (jobs[index].jobstate != ScreenJob.running) return false;
|
||||||
|
if (ev.type == InputEvent.Type_KeyDown) Console.Printf("OnEvent: dispatching key %d to job %s", ev.keyScan, jobs[index].GetClassName());
|
||||||
return jobs[index].OnEvent(ev);
|
return jobs[index].OnEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,23 +465,26 @@ class ScreenJobRunner : Object
|
||||||
virtual bool OnTick()
|
virtual bool OnTick()
|
||||||
{
|
{
|
||||||
if (paused) return false;
|
if (paused) return false;
|
||||||
if (jobs.Size() == 0) return true;
|
if (index >= jobs.Size() || jobs.Size() == 0) return true;
|
||||||
if (advance)
|
if (advance || index < 0)
|
||||||
{
|
{
|
||||||
advance = false;
|
advance = false;
|
||||||
AdvanceJob(terminateState < 0);
|
AdvanceJob(terminateState < 0);
|
||||||
if (index >= jobs.Size())
|
if (index >= jobs.Size())
|
||||||
{
|
{
|
||||||
|
Console.Printf("OnTick: done");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jobs[index].jobstate == ScreenJob.running)
|
if (jobs[index].jobstate == ScreenJob.running)
|
||||||
{
|
{
|
||||||
jobs[index].ticks++;
|
jobs[index].ticks++;
|
||||||
|
Console.Printf("OnTick: job %s, ticks = %d", jobs[index].GetClassName(), jobs[index].ticks);
|
||||||
jobs[index].OnTick();
|
jobs[index].OnTick();
|
||||||
}
|
}
|
||||||
else if (jobs[index].jobstate == ScreenJob.stopping)
|
else if (jobs[index].jobstate == ScreenJob.stopping)
|
||||||
{
|
{
|
||||||
|
Console.Printf("OnTick: fadeticks for %s", jobs[index].GetClassName());
|
||||||
fadeticks++;
|
fadeticks++;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -484,10 +499,14 @@ class ScreenJobRunner : Object
|
||||||
virtual bool RunFrame(double smoothratio)
|
virtual bool RunFrame(double smoothratio)
|
||||||
{
|
{
|
||||||
// ensure that we won't go back in time if the menu is dismissed without advancing our ticker
|
// ensure that we won't go back in time if the menu is dismissed without advancing our ticker
|
||||||
|
if (index < jobs.Size())
|
||||||
|
{
|
||||||
bool menuon = paused;
|
bool menuon = paused;
|
||||||
if (menuon) last_paused_tic = jobs[index].ticks;
|
if (menuon) last_paused_tic = jobs[index].ticks;
|
||||||
else if (last_paused_tic == jobs[index].ticks) menuon = true;
|
else if (last_paused_tic == jobs[index].ticks) menuon = true;
|
||||||
if (menuon || index >= jobs.Size()) smoothratio = 1.;
|
if (menuon) smoothratio = 1.;
|
||||||
|
}
|
||||||
|
else smoothratio = 1.;
|
||||||
|
|
||||||
if (actionState == State_Clear)
|
if (actionState == State_Clear)
|
||||||
{
|
{
|
||||||
|
@ -499,6 +518,8 @@ class ScreenJobRunner : Object
|
||||||
terminateState = DisplayFrame(smoothratio);
|
terminateState = DisplayFrame(smoothratio);
|
||||||
if (terminateState < 1 && index < jobs.Size())
|
if (terminateState < 1 && index < jobs.Size())
|
||||||
{
|
{
|
||||||
|
Console.Printf("RunFrame: job %s, state %d", jobs[index].GetClassName(), terminateState);
|
||||||
|
|
||||||
if (jobs[index].flags & ScreenJob.fadeout)
|
if (jobs[index].flags & ScreenJob.fadeout)
|
||||||
{
|
{
|
||||||
jobs[index].fadestate = ScreenJob.fadeout;
|
jobs[index].fadestate = ScreenJob.fadeout;
|
||||||
|
@ -508,6 +529,7 @@ class ScreenJobRunner : Object
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.Printf("RunState: advancing");
|
||||||
advance = true;
|
advance = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue