- added wipe transitions to screen job

Mainly to have the crossfade, the other styles are mostly bonus.
This also adds proper scoping to the cutscene code, which needs to run in UI scope.
This commit is contained in:
Christoph Oelckers 2022-04-25 17:26:17 +02:00
parent 21b4862460
commit 0dc670da8e
13 changed files with 86 additions and 35 deletions

View file

@ -279,7 +279,7 @@ Wiper_Melt::Wiper_Melt()
bool Wiper_Melt::Run(int ticks)
{
bool done;
bool done = false;
DrawTexture(twod, endScreen, 0, 0, DTA_FlipY, screen->RenderTextureIsFlipped(), DTA_Masked, false, TAG_DONE);
// Copy the old screen in vertical strips on top of the new one.
@ -366,14 +366,13 @@ Wiper_Burn::~Wiper_Burn()
bool Wiper_Burn::Run(int ticks)
{
bool done;
bool done = false;
BurnTime += ticks;
ticks *= 2;
// Make the fire burn
done = false;
while (!done && ticks--)
{
Density = wipe_CalcBurn(BurnArray, WIDTH, HEIGHT, Density);

View file

@ -334,6 +334,21 @@ bool StartCutscene(const char* s, int flags, const CompletionFunc& completion)
return StartCutscene(def, flags, completion);
}
//=============================================================================
//
// initiates a screen wipe. Needs to call the game code for it.
//
//=============================================================================
DEFINE_ACTION_FUNCTION(DScreenJobRunner, setTransition)
{
PARAM_PROLOGUE;
PARAM_INT(type);
if (type && sysCallbacks.SetTransition) sysCallbacks.SetTransition(type);
return 0;
}
//=============================================================================
//
//

View file

@ -34,6 +34,7 @@ struct SystemCallbacks
void (*FontCharCreated)(FGameTexture* base, FGameTexture* untranslated);
void (*ToggleFullConsole)();
void (*StartCutscene)(bool blockui);
void (*SetTransition)(int type);
};
extern SystemCallbacks sysCallbacks;

View file

@ -79,6 +79,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "hw_palmanager.h"
#include "razefont.h"
#include "coreactor.h"
#include "wipe.h"
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -182,6 +183,7 @@ bool pausedWithKey;
bool gamesetinput = false;
int PlayClock;
extern int nextwipe;
CUSTOM_CVAR(Int, cl_gender, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
@ -542,6 +544,11 @@ static void System_StartCutscene(bool blockui)
gameaction = blockui ? ga_intro : ga_intermission;
}
static void System_SetTransition(int type)
{
nextwipe = type;
}
void I_StartupJoysticks();
void I_ShutdownInput();
int RunGame();
@ -579,6 +586,7 @@ int GameMain()
FontCharCreated,
System_ToggleFullConsole,
System_StartCutscene,
System_SetTransition,
};
try

View file

@ -88,6 +88,7 @@
#include "savegamehelp.h"
#include "v_draw.h"
#include "gamehud.h"
#include "wipe.h"
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -104,6 +105,7 @@ bool r_NoInterpolate;
int entertic;
int oldentertics;
int gametic;
int nextwipe = wipe_None;
FString savename;
FString BackupSaveGame;
@ -375,6 +377,21 @@ static void GameTicker()
}
void DrawOverlays()
{
NetUpdate(); // send out any new accumulation
if (gamestate != GS_INTRO) // do not draw overlays on the intros
{
// Draw overlay elements
CT_Drawer();
C_DrawConsole();
M_Drawer();
FStat::PrintStat(twod);
}
DrawRateStuff();
}
//==========================================================================
//
// Display
@ -388,6 +405,12 @@ void Display()
{
return;
}
FTexture* wipestart = nullptr;
if (nextwipe != wipe_None)
{
wipestart = screen->WipeStartScreen();
}
screen->FrameTime = I_msTimeFS();
tileUpdateAnimations();
@ -408,7 +431,6 @@ void Display()
case GS_INTRO:
case GS_CUTSCENE:
// screen jobs are not bound by the game ticker so they need to be ticked in the display loop.
ScreenJobDraw();
break;
@ -420,6 +442,7 @@ void Display()
screen->SetSceneRenderTarget(gl_ssao != 0);
updateModelInterpolation();
gi->Render();
if (vid_renderer == 0) videoShowFrame();
DrawFullscreenBlends();
drawMapTitle();
break;
@ -430,21 +453,15 @@ void Display()
twod->ClearScreen();
break;
}
NetUpdate(); // send out any new accumulation
if (gamestate != GS_INTRO) // do not draw overlays on the intros
if (nextwipe == wipe_None)
DrawOverlays();
else
{
// Draw overlay elements
CT_Drawer();
C_DrawConsole();
M_Drawer();
FStat::PrintStat(twod);
PerformWipe(wipestart, screen->WipeEndScreen(), nextwipe, true, DrawOverlays);
nextwipe = wipe_None;
}
DrawRateStuff();
if (vid_renderer == 0) videoShowFrame(1);
else screen->Update();
screen->Update();
}
//==========================================================================

View file

@ -417,7 +417,7 @@ int32_t r_scenebrightness = 0;
void videoShowFrame(int32_t w)
void videoShowFrame()
{
int oldssao = gl_ssao;
@ -428,7 +428,6 @@ void videoShowFrame(int32_t w)
screen->PostProcessScene(false, 0, Brightness, []() {
Draw2D(&twodpsp, *screen->RenderState()); // draws the weapon sprites
});
screen->Update();
screen->mVertexData->Reset();
screen->mViewpoints->Clear();

View file

@ -310,4 +310,4 @@ void renderSetVisibility(float v);
void renderSetViewpoint(float x, float y, float z);
void renderBeginScene();
void renderFinishScene();
void videoShowFrame(int32_t);
void videoShowFrame();

View file

@ -29,7 +29,7 @@ struct UiEvent native ui version("2.4")
Type_FwdButtonUp, // ???
Type_LastMouseEvent
}
// for KeyDown, KeyRepeat, KeyUp
enum ESpecialGUIKeys
{
@ -67,7 +67,7 @@ struct UiEvent native ui version("2.4")
Key_Back = 30, // browser back key
Key_CEscape = 31 // color escape
}
//
native readonly EGUIEvent Type;
//
@ -93,7 +93,7 @@ struct InputEvent native play version("2.4")
Type_GUI, // unused, kept for completeness
Type_DeviceChange
}
// ew.
enum EDoomInputKeys
{
@ -237,7 +237,7 @@ struct InputEvent native play version("2.4")
Num_Keys = 0x1C4
}
//
native readonly EGenericEvent Type;
//

View file

@ -1,5 +1,5 @@
class ScreenJob : Object
class ScreenJob : Object UI
{
int flags;
float fadetime; // in milliseconds
@ -25,6 +25,11 @@ class ScreenJob : Object
fadeout = 2,
stopmusic = 4,
stopsound = 8,
transition_shift = 4,
transition_mask = 48,
transition_melt = 16,
transition_burn = 32,
transition_crossfade = 48,
};
void Init(int fflags = 0, float fadet = 250.f)
@ -60,6 +65,7 @@ class ScreenJob : Object
if (flags & stopmusic) System.StopMusic();
if (flags & stopsound) System.StopAllSounds();
}
}
//---------------------------------------------------------------------------
@ -244,12 +250,12 @@ class MoviePlayerJob : SkippableScreenJob
empty.Push(int(soundname));
return CreateWithSoundInfo(filename, empty, flags, frametime);
}
virtual void DrawFrame()
{
let tex = player.GetTexture();
let size = TexMan.GetScaledSize(tex);
if (!(flag & MoviePlayer.FIXEDVIEWPORT) || (size.x <= 320 && size.y <= 200) || size.x >= 640 || size.y >= 480)
{
Screen.DrawTexture(tex, false, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false);
@ -298,7 +304,7 @@ class MoviePlayerJob : SkippableScreenJob
//
//---------------------------------------------------------------------------
class ScreenJobRunner : Object
class ScreenJobRunner : Object UI
{
enum ERunState
{
@ -317,6 +323,8 @@ class ScreenJobRunner : Object
int terminateState;
int fadeticks;
int last_paused_tic;
native static void setTransition(int type);
void Init(bool clearbefore_, bool skipall_)
{
@ -378,6 +386,10 @@ class ScreenJobRunner : Object
{
jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible;
jobs[index].Start();
if (jobs[index].flags & ScreenJob.transition_mask)
{
setTransition((jobs[index].flags & ScreenJob.transition_mask) >> ScreenJob.Transition_Shift);
}
}
}

View file

@ -41,7 +41,7 @@ class BloodIntroImage : ImageScreen
}
}
struct BloodScreen
struct BloodScreen ui
{
enum EConstants
{
@ -289,7 +289,7 @@ class BloodLoadScreen : ScreenJob
//
//---------------------------------------------------------------------------
class BloodCutscenes
class BloodCutscenes ui
{
static void BuildIntro(ScreenJobRunner runner)
{

View file

@ -26,7 +26,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
class DukeCutscenes // Note: must be class, not struct, otherwise we cannot easily look up the methods from C++.
class DukeCutscenes ui // Note: must be class, not struct, otherwise we cannot easily look up the methods from C++.
{
//---------------------------------------------------------------------------
//
@ -261,7 +261,7 @@ class DukeCutscenes // Note: must be class, not struct, otherwise we cannot easi
}
class RRCutscenes
class RRCutscenes ui
{
//---------------------------------------------------------------------------

View file

@ -784,7 +784,7 @@ class ExCredits : ScreenJob
}
}
class ExhumedCutscenes
class ExhumedCutscenes ui
{
//---------------------------------------------------------------------------
//

View file

@ -361,7 +361,7 @@ class SWLoadScreen : ScreenJob
}
class SWCutscenes
class SWCutscenes ui
{
//---------------------------------------------------------------------------
//