- make StatusScreen inherit directly from ScreenJob

This commit is contained in:
Christoph Oelckers 2022-04-26 18:06:26 +02:00
parent 3ca8c528e0
commit ce59b47e93
2 changed files with 37 additions and 47 deletions

View file

@ -4,23 +4,22 @@ class IntermissionController native ui
{
// This is mostly a black box to the native intermission code.
// May be scriptified later, but right now we do not need it.
/*
static native IntermissionController Create(String music, int musicorder, String flat, String text, int textInLump, int finalePic, int lookupText, bool ending, Name endsequence);
static native IntermissionController CreateNamed(Name nm);
*/
native bool Responder(InputEvent ev);
native bool Responder(InputEvent ev);
native bool Ticker();
native void Drawer();
native bool NextPage();
}
// Wrappers to play the old intermissions and status screens within a screen job.
// Wrapper to play the native intermissions within a screen job.
class IntermissionScreenJob : ScreenJob
{
IntermissionController controller;
ScreenJob Init(IntermissionController ctrl)
ScreenJob Init(IntermissionController ctrl, bool allowwipe)
{
Super.Init();
if (allowwipe && wipetype != 0) flags = wipetype << ScreenJob.transition_shift;
controller = ctrl;
return self;
}
@ -37,29 +36,6 @@ class IntermissionScreenJob : ScreenJob
}
class StatusScreenJob : ScreenJob
{
StatusScreen controller;
ScreenJob Init(StatusScreen scr, bool allowwipe)
{
if (allowwipe && wipetype != 0) flags |= wipetype << ScreenJob.transition_shift;
controller = scr;
return self;
}
override void OnTick() { controller.Ticker(); if (controller.CurState == StatusScreen.LeavingIntermission) jobstate = finished; }
override void Draw(double smoothratio) { controller.Drawer(); }
override bool OnEvent(InputEvent evt) { return controller.Responder(evt); }
override void OnDestroy()
{
controller.Destroy();
Super.OnDestroy();
}
}
class DoomCutscenes ui
{
//---------------------------------------------------------------------------
@ -72,11 +48,11 @@ class DoomCutscenes ui
{
if (status)
{
runner.Append(new("StatusScreenJob").Init(status));
runner.Append(status);
}
if (inter)
{
runner.Append(new("IntermissionScreenJob").Init(inter, status != nullptr));
runner.Append(new("IntermissionScreenJob").Init(inter, status != null));
}
}
}

View file

@ -39,7 +39,7 @@ struct PatchInfo ui version("2.5")
};
class StatusScreen abstract ui version("2.5")
class StatusScreen : ScreenJob abstract version("2.5")
{
enum EValues
{
@ -105,7 +105,7 @@ class StatusScreen abstract ui version("2.5")
float shadowalpha;
PatchInfo mapname;
PatchInfo finished;
PatchInfo finishedp;
PatchInfo entering;
PatchInfo content;
PatchInfo author;
@ -334,7 +334,7 @@ class StatusScreen abstract ui version("2.5")
if (!TexMan.OkForLocalization(finishedPatch, "$WI_FINISHED"))
{
disp += finished.mFont.GetMaxAscender("$WI_FINISHED");
disp += finishedp.mFont.GetMaxAscender("$WI_FINISHED");
}
}
else
@ -349,10 +349,10 @@ class StatusScreen abstract ui version("2.5")
// draw "Finished!"
int statsy = multiplayer? NG_STATSY : SP_STATSY * scaleFactorY;
if (y < (statsy - finished.mFont.GetHeight()*3/4) * scaleFactorY)
if (y < (statsy - finishedp.mFont.GetHeight()*3/4) * scaleFactorY)
{
// don't draw 'finished' if the level name is too tall
y = DrawPatchOrText(y, finished, finishedPatch, "$WI_FINISHED");
y = DrawPatchOrText(y, finishedp, finishedPatch, "$WI_FINISHED");
}
return y;
}
@ -787,7 +787,7 @@ class StatusScreen abstract ui version("2.5")
// ====================================================================
// checkForAccelerate
//
// Purpose: See if the player has hit either the attack or use key
// or mouse button. If so we set acceleratestage to 1 and
// all those display routines above jump right to the end.
@ -796,7 +796,7 @@ class StatusScreen abstract ui version("2.5")
//
// ====================================================================
virtual bool Responder(InputEvent evt)
override bool OnEvent(InputEvent evt)
{
if (evt.type == InputEvent.Type_KeyDown)
{
@ -806,9 +806,14 @@ class StatusScreen abstract ui version("2.5")
return false;
}
void checkForAccelerate()
void nextStage()
{
accelerateStage = 1;
}
// this one is no longer used, but still needed for old content referencing them.
deprecated("4.8") void checkForAccelerate()
{
// no longer used, but still needed for old content.
}
// ====================================================================
@ -827,11 +832,11 @@ class StatusScreen abstract ui version("2.5")
//====================================================================
//
//
// Two stage interface to allow redefining this class as a screen job
//
//====================================================================
virtual void Ticker(void)
protected virtual void Ticker()
{
// counter for general background animation
bcnt++;
@ -858,18 +863,23 @@ class StatusScreen abstract ui version("2.5")
break;
case LeavingIntermission:
// Hush, GCC.
break;
}
}
override void OnTick()
{
Ticker();
if (CurState == StatusScreen.LeavingIntermission) jobstate = finished;
}
//====================================================================
//
//
//
//====================================================================
virtual void Drawer (void)
protected virtual void Drawer()
{
switch (CurState)
{
@ -890,6 +900,11 @@ class StatusScreen abstract ui version("2.5")
}
}
override void Draw(double smoothratio)
{
Drawer();
}
//====================================================================
//
//
@ -917,7 +932,7 @@ class StatusScreen abstract ui version("2.5")
}
entering.Init(gameinfo.mStatscreenEnteringFont);
finished.Init(gameinfo.mStatscreenFinishedFont);
finishedp.Init(gameinfo.mStatscreenFinishedFont);
mapname.Init(gameinfo.mStatscreenMapNameFont);
content.Init(gameinfo.mStatscreenContentFont);
author.Init(gameinfo.mStatscreenAuthorFont);
@ -948,7 +963,6 @@ class StatusScreen abstract ui version("2.5")
scaleFactorY = CleanYfac;
}
protected virtual void initStats() {}
protected virtual void updateStats() {}
protected virtual void drawStats() {}