- properly hook up the alt HUD with the status bar.

This commit is contained in:
Christoph Oelckers 2018-12-02 14:24:26 +01:00
parent d11b33e8fd
commit db814dc333
4 changed files with 29 additions and 53 deletions

View file

@ -773,7 +773,7 @@ void D_Display ()
if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10)
{
StatusBar->DrawBottomStuff (HUD_AltHud);
if (DrawFSHUD || automapactive) DrawHUD();
if (DrawFSHUD || automapactive) StatusBar->DrawAltHUD();
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
{
StatusBar->DrawCrosshair();

View file

@ -31,11 +31,6 @@
**
*/
// NOTE: Some stuff in here might seem a little redundant but I wanted this
// to be as true as possible to my original intent which means that it
// only uses that code from ZDoom's status bar that is the same as any
// copy would be.
#include "doomtype.h"
#include "doomdef.h"
#include "v_video.h"
@ -57,17 +52,6 @@
#include <time.h>
#define HUMETA_AltIcon 0x10f000
EXTERN_CVAR(Bool,am_follow)
EXTERN_CVAR (Int, con_scaletext)
EXTERN_CVAR (Bool, idmypos)
EXTERN_CVAR (Int, screenblocks)
EXTERN_CVAR(Bool, hud_aspectscale)
EXTERN_CVAR (Bool, am_showtime)
EXTERN_CVAR (Bool, am_showtotaltime)
CVAR(Int,hud_althudscale, 0, CVAR_ARCHIVE) // Scale the hud to 640x400?
CVAR(Bool,hud_althud, false, CVAR_ARCHIVE) // Enable/Disable the alternate HUD
@ -108,55 +92,27 @@ CVAR (Int, hudcolor_stats, CR_GREEN, CVAR_ARCHIVE) // For the stats values the
CVAR(Bool, map_point_coordinates, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // show player or map coordinates?
static FFont * HudFont; // The font for the health and armor display
static FFont * IndexFont; // The font for the inventory indices
// Icons
static FTexture * healthpic; // Health icon
static FTexture * berserkpic; // Berserk icon (Doom only)
static FTexture * fragpic; // Frags icon
static FTexture * invgems[2]; // Inventory arrows
static FTextureID tnt1a0; // We need this to check for empty sprites.
static int hudwidth, hudheight; // current width/height for HUD display
static int statspace;
//---------------------------------------------------------------------------
//
// draw the overlay
// draw the HUD
//
//---------------------------------------------------------------------------
EXTERN_CVAR(Bool, hud_aspectscale)
void DrawHUD()
void DBaseStatusBar::DrawAltHUD()
{
player_t * CPlayer = StatusBar->CPlayer;
players[consoleplayer].inventorytics = 0;
int scale = GetUIScale(hud_althudscale);
hudwidth = SCREENWIDTH / scale;
hudheight = hud_aspectscale ? int(SCREENHEIGHT / (scale*1.2)) : SCREENHEIGHT / scale;
// Until the script export is complete we need to do some manual setup here
auto cls = PClass::FindClass("AltHud");
if (!cls) return;
DObject *althud = cls->CreateNew(); // scripted parts. This is here to make a gradual transition
{
IFVM(AltHud, Init)
{
VMValue params[] = { althud };
VMCall(func, params, countof(params), nullptr, 0);
}
}
int hudwidth = SCREENWIDTH / scale;
int hudheight = hud_aspectscale ? int(SCREENHEIGHT / (scale*1.2)) : SCREENHEIGHT / scale;
IFVM(AltHud, Draw)
{
VMValue params[] = { althud, CPlayer, hudwidth, hudheight };
VMValue params[] = { AltHud, CPlayer, hudwidth, hudheight };
VMCall(func, params, countof(params), nullptr, 0);
}
if (althud) althud->Destroy();
althud = nullptr;
}

View file

@ -432,6 +432,7 @@ public:
virtual void SetMugShotState (const char *state_name, bool wait_till_done=false, bool reset=false);
void DrawLog();
uint32_t GetTranslation() const;
void DrawAltHUD();
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY);
void DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY);
@ -454,6 +455,9 @@ public:
void RefreshBackground () const;
private:
DObject *AltHud = nullptr;
public:
AInventory *ValidateInvFirst (int numVisible) const;

View file

@ -70,6 +70,7 @@ IMPLEMENT_POINTERS_START(DBaseStatusBar)
IMPLEMENT_POINTER(Messages[0])
IMPLEMENT_POINTER(Messages[1])
IMPLEMENT_POINTER(Messages[2])
IMPLEMENT_POINTER(AltHud)
IMPLEMENT_POINTERS_END
EXTERN_CVAR (Bool, am_showmonsters)
@ -358,6 +359,22 @@ DBaseStatusBar::DBaseStatusBar ()
CPlayer = NULL;
ShowLog = false;
defaultScale = { (double)CleanXfac, (double)CleanYfac };
// Create the AltHud object. Todo: Make class type configurable.
FName classname = "AltHud";
auto cls = PClass::FindClass(classname);
if (cls)
{
AltHud = cls->CreateNew();
VMFunction * func = nullptr;
PClass::FindFunction(&func, classname, "Init");
if (func != nullptr)
{
VMValue params[] = { AltHud };
VMCall(func, params, countof(params), nullptr, 0);
}
}
}
static void ValidateResolution(int &hres, int &vres)
@ -421,6 +438,7 @@ void DBaseStatusBar::OnDestroy ()
}
Messages[i] = NULL;
}
if (AltHud) AltHud->Destroy();
Super::OnDestroy();
}
@ -987,8 +1005,6 @@ void DBaseStatusBar::CallDraw(EHudState state, double ticFrac)
BeginStatusBar(BaseSBarHorizontalResolution, BaseSBarVerticalResolution, BaseRelTop, false);
}
void DBaseStatusBar::DrawLog ()
{
int hudwidth, hudheight;