- make hud_scale a floating point CVAR.

This commit is contained in:
Christoph Oelckers 2020-08-24 21:48:47 +02:00
parent 3a6ccac8ea
commit e7c58a5b29
6 changed files with 20 additions and 20 deletions

View file

@ -170,10 +170,10 @@ CUSTOM_CVARD(Int, hud_size, Hud_Stbar, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines
else setViewport(self);
}
CUSTOM_CVARD(Int, hud_scale, 100, CVAR_ARCHIVE | CVAR_NOINITCALL, "changes the hud scale")
CUSTOM_CVARD(Float, hud_scale, 1, CVAR_ARCHIVE, "changes the hud scale")
{
if (self < 36) self = 36;
else if (self > 100) self = 100;
if (self < 0.36f) self = 0.36f;
else if (self > 1) self = 1;
else setViewport(hud_size);
}
@ -190,7 +190,7 @@ CCMD(sizeup)
}
else
{
hud_scale = hud_scale + 4;
hud_scale = hud_scale + 0.04;
}
}
@ -206,7 +206,7 @@ CCMD(sizedown)
}
else
{
hud_scale = hud_scale - 4;
hud_scale = hud_scale - 0.04;
}
}

View file

@ -50,7 +50,7 @@ EXTERN_CVAR(Int, snd_speech)
EXTERN_CVAR(Int, mus_device)
EXTERN_CVAR(Int, hud_layout)
EXTERN_CVAR(Int, hud_scale)
EXTERN_CVAR(Float, hud_scale)
EXTERN_CVAR(Int, hud_size)
EXTERN_CVAR(Float, hud_statscale)

View file

@ -200,8 +200,8 @@ void DBaseStatusBar::SetScale ()
refh = h;
refw = h * refaspect;
}
refw *= (hud_scale / 100.);
refh *= (hud_scale / 100.);
refw *= hud_scale;
refh *= hud_scale;
int sby = VerticalResolution - RelTop;
// Use full pixels for destination size.
@ -757,8 +757,8 @@ void setViewport(int viewSize)
int ydim = screen->GetHeight();
if (xdim == 0 || ydim == 0) return;
auto reserved = gi->GetReservedScreenSpace(viewSize);
reserved.top = (reserved.top * hud_scale * ydim) / 20000;
reserved.statusbar = (reserved.statusbar * hud_scale * ydim) / 20000;
reserved.top = xs_CRoundToInt((reserved.top * hud_scale * ydim) / 200);
reserved.statusbar = xs_CRoundToInt((reserved.statusbar * hud_scale * ydim) / 200);
int xdimcorrect = std::min(Scale(ydim, 4, 3), xdim);
if (viewSize > Hud_Stbar)

View file

@ -194,7 +194,7 @@ void DDukeCommonStatusBar::PrintLevelStats(int bottomy)
font = isNamWW2GI() ? ConFont : SmallFont;
if (isNamWW2GI()) color = CR_ORANGE;
}
int top = am_nameontop ? 0 : ( 200 - Scale(bottomy < 0 ? RelTop : bottomy, hud_scale, 100) - (isRR()? 25 : 20));
double top = am_nameontop ? 0 : ( 200 - (bottomy < 0 ? RelTop : bottomy) * hud_scale - (isRR()? 25 : 20));
if (!(currentLevel->flags & MI_USERMAP))
DrawText(twod, font, color, 5, top + 6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]),
DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);

View file

@ -961,29 +961,29 @@ public:
if (hud_size == Hud_Nothing)
{
align = DI_SCREEN_RIGHT_BOTTOM;
inv_x = -210 * hud_scale / 100.;
inv_y = -28 * hud_scale / 100.;
inv_x = -210 * hud_scale;
inv_y = -28 * hud_scale;
PrintLevelStats(2);
}
else if (hud_size == Hud_full)
{
align = DI_SCREEN_CENTER_TOP;
inv_x = -80 * hud_scale / 100.;
inv_y = -70 * hud_scale / 100.;
inv_x = -80 * hud_scale;
inv_y = -70 * hud_scale;
DrawHUD2(); // todo: Implement a proper view for this
}
else if (hud_size == Hud_Mini)
{
align = DI_SCREEN_RIGHT_BOTTOM;
inv_x = -210 * hud_scale / 100.;
inv_y = -28 * hud_scale / 100.;
inv_x = -210 * hud_scale;
inv_y = -28 * hud_scale;
DrawHUD1();
}
else
{
align = 0;
inv_x = 80 * hud_scale / 100.;
inv_y = 130 * hud_scale / 100.;
inv_x = 80 * hud_scale;
inv_y = 130 * hud_scale;
DrawStatusBar();
}
DrawInventory(inv_x, inv_y, align);

View file

@ -1024,7 +1024,7 @@ OptionMenu "HUDOptions" //protected
Title "$OPTMNU_HUD"
Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 9.0, 1.0, -1
Slider "$DSPLYMNU_SBSCALE", "hud_scale", 36, 100, 4, 2
Slider "$DSPLYMNU_SBSCALE", "hud_scale", 36, 100, 0.04, 2
StaticText ""
Option "$DSPLYMNU_LEVELSTATS", "hud_stats", "OnOff"
Slider "$DSPLYMNU_STATSCALE", "hud_statscale", .5, 3, 0.25, 2