mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- final function moves and renamed hud_scale to hud_scalefactor.
This commit is contained in:
parent
0270dcd5f6
commit
3b7ce26c86
7 changed files with 194 additions and 125 deletions
|
@ -641,7 +641,7 @@ private:
|
|||
}
|
||||
drawInventory(pPlayer, 166, 200 - tilesiz[2200].y);
|
||||
// Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already.
|
||||
PrintLevelStats(pPlayer, (hud_statscale <= 0.501f || hud_scale < 0.7) && double(xdim)/ydim > 1.6? 28 : 56);
|
||||
PrintLevelStats(pPlayer, (hud_statscale <= 0.501f || hud_scalefactor < 0.7) && double(xdim)/ydim > 1.6? 28 : 56);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ CUSTOM_CVARD(Int, hud_size, Hud_Stbar, CVAR_ARCHIVE, "Defines the HUD size and s
|
|||
else setViewport(self);
|
||||
}
|
||||
|
||||
CUSTOM_CVARD(Float, hud_scale, 1, CVAR_ARCHIVE, "changes the hud scale")
|
||||
CUSTOM_CVARD(Float, hud_scalefactor, 1, CVAR_ARCHIVE, "changes the hud scale")
|
||||
{
|
||||
if (self < 0.36f) self = 0.36f;
|
||||
else if (self > 1) self = 1;
|
||||
|
@ -151,7 +151,7 @@ CCMD(sizeup)
|
|||
}
|
||||
else
|
||||
{
|
||||
hud_scale = hud_scale + 0.04;
|
||||
hud_scalefactor = hud_scalefactor + 0.04;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ CCMD(sizedown)
|
|||
}
|
||||
else
|
||||
{
|
||||
hud_scale = hud_scale - 0.04;
|
||||
hud_scalefactor = hud_scalefactor - 0.04;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ EXTERN_CVAR(Int, snd_speech)
|
|||
EXTERN_CVAR(Int, mus_device)
|
||||
|
||||
EXTERN_CVAR(Int, hud_layout)
|
||||
EXTERN_CVAR(Float, hud_scale)
|
||||
EXTERN_CVAR(Float, hud_scalefactor)
|
||||
EXTERN_CVAR(Int, hud_size)
|
||||
EXTERN_CVAR(Float, hud_statscale)
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ CVAR(Float, crosshairscale, 1.0, CVAR_ARCHIVE);
|
|||
CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE);
|
||||
EXTERN_CVAR(Bool, vid_fps)
|
||||
|
||||
EXTERN_CVAR(Float, hud_scalefactor)
|
||||
|
||||
void ST_LoadCrosshair(int num, bool alwaysload)
|
||||
{
|
||||
char name[16];
|
||||
|
@ -257,6 +259,178 @@ void DStatusBarCore::ValidateResolution(int& hres, int& vres) const
|
|||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void DStatusBarCore::SetSize(int reltop, int hres, int vres, int hhres, int hvres)
|
||||
{
|
||||
ValidateResolution(hres, vres);
|
||||
|
||||
BaseRelTop = reltop;
|
||||
BaseSBarHorizontalResolution = hres;
|
||||
BaseSBarVerticalResolution = vres;
|
||||
BaseHUDHorizontalResolution = hhres < 0 ? hres : hhres;
|
||||
BaseHUDVerticalResolution = hvres < 0 ? vres : hvres;
|
||||
SetDrawSize(reltop, hres, vres);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// calculates a clean scale for the status bar
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
static void ST_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany)
|
||||
{
|
||||
float ratio;
|
||||
int cwidth;
|
||||
int cheight;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
|
||||
ratio = ActiveRatio(realwidth, realheight);
|
||||
if (AspectTallerThanWide(ratio))
|
||||
{
|
||||
cwidth = realwidth;
|
||||
cheight = realheight * AspectMultiplier(ratio) / 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
cwidth = realwidth * AspectMultiplier(ratio) / 48;
|
||||
cheight = realheight;
|
||||
}
|
||||
// Use whichever pair of cwidth/cheight or width/height that produces less difference
|
||||
// between CleanXfac and CleanYfac.
|
||||
cx1 = MAX(cwidth / designwidth, 1);
|
||||
cy1 = MAX(cheight / designheight, 1);
|
||||
cx2 = MAX(realwidth / designwidth, 1);
|
||||
cy2 = MAX(realheight / designheight, 1);
|
||||
if (abs(cx1 - cy1) <= abs(cx2 - cy2) || MAX(cx1, cx2) >= 4)
|
||||
{ // e.g. 640x360 looks better with this.
|
||||
*cleanx = cx1;
|
||||
*cleany = cy1;
|
||||
}
|
||||
else
|
||||
{ // e.g. 720x480 looks better with this.
|
||||
*cleanx = cx2;
|
||||
*cleany = cy2;
|
||||
}
|
||||
|
||||
if (*cleanx < *cleany)
|
||||
*cleany = *cleanx;
|
||||
else
|
||||
*cleanx = *cleany;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void DStatusBarCore::SetDrawSize(int reltop, int hres, int vres)
|
||||
{
|
||||
ValidateResolution(hres, vres);
|
||||
|
||||
RelTop = reltop;
|
||||
HorizontalResolution = hres;
|
||||
VerticalResolution = vres;
|
||||
|
||||
int x, y;
|
||||
ST_CalcCleanFacs(hres, vres, twod->GetWidth(), twod->GetHeight(), &x, &y);
|
||||
defaultScale = { (double)x, (double)y };
|
||||
|
||||
SetScale(); // recalculate positioning info.
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC SetScaled
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::SetScale()
|
||||
{
|
||||
ValidateResolution(HorizontalResolution, VerticalResolution);
|
||||
|
||||
int w = twod->GetWidth();
|
||||
int h = twod->GetHeight();
|
||||
double refw, refh;
|
||||
|
||||
int horz = HorizontalResolution;
|
||||
int vert = VerticalResolution;
|
||||
double refaspect = horz / double(vert);
|
||||
double screenaspect = w / double(h);
|
||||
|
||||
if ((horz == 320 && vert == 200) || (horz == 640 && vert == 400))
|
||||
{
|
||||
refaspect = 1.333;
|
||||
}
|
||||
|
||||
if (screenaspect < refaspect)
|
||||
{
|
||||
refw = w;
|
||||
refh = w / refaspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
refh = h;
|
||||
refw = h * refaspect;
|
||||
}
|
||||
refw *= hud_scalefactor;
|
||||
refh *= hud_scalefactor;
|
||||
|
||||
int sby = VerticalResolution - RelTop;
|
||||
// Use full pixels for destination size.
|
||||
|
||||
ST_X = xs_CRoundToInt((w - refw) / 2);
|
||||
ST_Y = xs_CRoundToInt(h - refh);
|
||||
SBarTop = Scale(sby, h, VerticalResolution);
|
||||
SBarScale.X = refw / horz;
|
||||
SBarScale.Y = refh / vert;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC GetHUDScale
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DVector2 DStatusBarCore::GetHUDScale() const
|
||||
{
|
||||
return SBarScale;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::BeginStatusBar(int resW, int resH, int relTop, bool forceScaled)
|
||||
{
|
||||
SetDrawSize(relTop < 0 ? BaseRelTop : relTop, resW < 0 ? BaseSBarHorizontalResolution : resW, resH < 0 ? BaseSBarVerticalResolution : resH);
|
||||
ForcedScale = forceScaled;
|
||||
fullscreenOffsets = false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::BeginHUD(int resW, int resH, double Alpha, bool forcescaled)
|
||||
{
|
||||
SetDrawSize(RelTop, resW < 0 ? BaseHUDHorizontalResolution : resW, resH < 0 ? BaseHUDVerticalResolution : resH);
|
||||
this->Alpha = Alpha;
|
||||
ForcedScale = forcescaled;
|
||||
CompleteBorder = false;
|
||||
fullscreenOffsets = true;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// draw stuff
|
||||
|
|
|
@ -188,8 +188,8 @@ public:
|
|||
void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0);
|
||||
void ValidateResolution(int& hres, int& vres) const;
|
||||
|
||||
void BeginStatusBar(int resW, int resH, int relTop);
|
||||
void BeginHUD(int resW, int resH, double Alpha);
|
||||
void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled = false);
|
||||
void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false);
|
||||
void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const;
|
||||
void PrintLevelStats(FLevelStats& stats);
|
||||
void PrintAutomapInfo(FLevelStats& stats, bool forcetextfont = false);
|
||||
|
@ -238,6 +238,7 @@ public:
|
|||
DVector2 drawOffset = { 0,0 }; // can be set by subclasses to offset drawing operations
|
||||
double drawClip[4] = { 0,0,0,0 }; // defines a clipping rectangle (not used yet)
|
||||
bool fullscreenOffsets = false; // current screen is displayed with fullscreen behavior.
|
||||
DVector2 defaultScale; // factor for clean fully scaled display.
|
||||
|
||||
private:
|
||||
void SetDrawSize(int reltop, int hres, int vres);
|
||||
|
|
|
@ -90,11 +90,13 @@ extern int setblocks;
|
|||
|
||||
void ST_Clear()
|
||||
{
|
||||
/*
|
||||
if (StatusBar != NULL)
|
||||
{
|
||||
delete StatusBar;
|
||||
StatusBar = NULL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -113,114 +115,6 @@ DStatusBarCore::DStatusBarCore ()
|
|||
SetSize(0);
|
||||
}
|
||||
|
||||
void ValidateResolution(int& hres, int& vres);
|
||||
|
||||
void DStatusBarCore::SetSize(int reltop, int hres, int vres, int hhres, int hvres)
|
||||
{
|
||||
ValidateResolution(hres, vres);
|
||||
|
||||
BaseRelTop = reltop;
|
||||
BaseSBarHorizontalResolution = hres;
|
||||
BaseSBarVerticalResolution = vres;
|
||||
BaseHUDHorizontalResolution = hhres < 0? hres : hhres;
|
||||
BaseHUDVerticalResolution = hvres < 0? vres : hvres;
|
||||
SetDrawSize(reltop, hres, vres);
|
||||
}
|
||||
|
||||
void DStatusBarCore::SetDrawSize(int reltop, int hres, int vres)
|
||||
{
|
||||
ValidateResolution(hres, vres);
|
||||
|
||||
RelTop = reltop;
|
||||
HorizontalResolution = hres;
|
||||
VerticalResolution = vres;
|
||||
SetScale(); // recalculate positioning info.
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC SetScaled
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::SetScale ()
|
||||
{
|
||||
ValidateResolution(HorizontalResolution, VerticalResolution);
|
||||
|
||||
double w = SCREENWIDTH;
|
||||
double h = SCREENHEIGHT;
|
||||
double refw, refh;
|
||||
|
||||
int horz = HorizontalResolution;
|
||||
int vert = VerticalResolution;
|
||||
double refaspect = horz / double(vert);
|
||||
double screenaspect = w / double(h);
|
||||
|
||||
if ((horz == 320 && vert == 200) || (horz == 640 && vert == 400))
|
||||
{
|
||||
refaspect = 1.333;
|
||||
}
|
||||
|
||||
if (screenaspect < refaspect)
|
||||
{
|
||||
refw = w;
|
||||
refh = w / refaspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
refh = h;
|
||||
refw = h * refaspect;
|
||||
}
|
||||
refw *= hud_scale;
|
||||
refh *= hud_scale;
|
||||
|
||||
int sby = VerticalResolution - RelTop;
|
||||
// Use full pixels for destination size.
|
||||
|
||||
ST_X = xs_CRoundToInt((w - refw) / 2);
|
||||
ST_Y = xs_CRoundToInt(h - refh);
|
||||
SBarTop = Scale(sby, h, VerticalResolution);
|
||||
SBarScale.X = refw / horz;
|
||||
SBarScale.Y = refh / vert;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC GetHUDScale
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DVector2 DStatusBarCore::GetHUDScale() const
|
||||
{
|
||||
return SBarScale;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::BeginStatusBar(int resW, int resH, int relTop)
|
||||
{
|
||||
SetDrawSize(relTop < 0? BaseRelTop : relTop, resW < 0? BaseSBarHorizontalResolution : resW, resH < 0? BaseSBarVerticalResolution : resH);
|
||||
fullscreenOffsets = false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DStatusBarCore::BeginHUD(int resW, int resH, double Alpha)
|
||||
{
|
||||
SetDrawSize(RelTop, resW < 0? BaseHUDHorizontalResolution : resW, resH < 0? BaseHUDVerticalResolution : resH);
|
||||
this->Alpha = Alpha;
|
||||
CompleteBorder = false;
|
||||
fullscreenOffsets = true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC Tick
|
||||
|
@ -407,8 +301,8 @@ void setViewport(int viewSize)
|
|||
int ydim = screen->GetHeight();
|
||||
if (xdim == 0 || ydim == 0) return;
|
||||
auto reserved = gi->GetReservedScreenSpace(viewSize);
|
||||
reserved.top = xs_CRoundToInt((reserved.top * hud_scale * ydim) / 200);
|
||||
reserved.statusbar = xs_CRoundToInt((reserved.statusbar * hud_scale * ydim) / 200);
|
||||
reserved.top = xs_CRoundToInt((reserved.top * hud_scalefactor * ydim) / 200);
|
||||
reserved.statusbar = xs_CRoundToInt((reserved.statusbar * hud_scalefactor * ydim) / 200);
|
||||
|
||||
int xdimcorrect = std::min(Scale(ydim, 4, 3), xdim);
|
||||
if (viewSize > Hud_Stbar)
|
||||
|
|
|
@ -1004,29 +1004,29 @@ public:
|
|||
if (hud_size == Hud_Nothing)
|
||||
{
|
||||
align = DI_SCREEN_RIGHT_BOTTOM;
|
||||
inv_x = -210 * hud_scale;
|
||||
inv_y = -28 * hud_scale;
|
||||
inv_x = -210 * hud_scalefactor;
|
||||
inv_y = -28 * hud_scalefactor;
|
||||
PrintLevelStats(2);
|
||||
}
|
||||
else if (hud_size == Hud_full)
|
||||
{
|
||||
align = DI_SCREEN_CENTER_BOTTOM;
|
||||
inv_x = -80 * hud_scale;
|
||||
inv_y = -40 * hud_scale;
|
||||
inv_x = -80 * hud_scalefactor;
|
||||
inv_y = -40 * hud_scalefactor;
|
||||
DrawHUD2();
|
||||
}
|
||||
else if (hud_size == Hud_Mini)
|
||||
{
|
||||
align = DI_SCREEN_RIGHT_BOTTOM;
|
||||
inv_x = -210 * hud_scale;
|
||||
inv_y = -28 * hud_scale;
|
||||
inv_x = -210 * hud_scalefactor;
|
||||
inv_y = -28 * hud_scalefactor;
|
||||
DrawHUD1();
|
||||
}
|
||||
else
|
||||
{
|
||||
align = 0;
|
||||
inv_x = 80 * hud_scale;
|
||||
inv_y = 130 * hud_scale;
|
||||
inv_x = 80 * hud_scalefactor;
|
||||
inv_y = 130 * hud_scalefactor;
|
||||
DrawStatusBar();
|
||||
}
|
||||
DrawInventory(inv_x, inv_y, align);
|
||||
|
|
Loading…
Reference in a new issue