- minor CVAR cleanup and refactoring of one more

This commit is contained in:
Christoph Oelckers 2019-10-23 00:30:51 +02:00
parent 713250cc64
commit 8f06f0748d
8 changed files with 30 additions and 28 deletions

View file

@ -100,7 +100,6 @@ bool gInfiniteAmmo;
bool gFullMap;
int32_t gUpscaleFactor;
int32_t gPowerupDuration;
int32_t gCenterHoriz;
int32_t gDeliriumBlur;
//////////
@ -332,7 +331,6 @@ void CONFIG_SetDefaults(void)
//ud.textscale = 200;
//ud.weaponscale = 100;
//cl_weaponswitch = 3; // new+empty
gCenterHoriz = 0;
gDeliriumBlur = 1;
gViewSize = 2;
gTurnSpeed = 92;

View file

@ -80,7 +80,6 @@ extern bool gFullMap;
extern hashtable_t h_gamefuncs;
extern int32_t gUpscaleFactor;
extern int32_t gPowerupDuration;
extern int32_t gCenterHoriz;
extern int32_t gDeliriumBlur;
///////

View file

@ -415,7 +415,7 @@ CGameMenuItemTitle itemOptionsDisplayTitle("DISPLAY SETUP", 1, 160, 20, 2038);
CGameMenuItemChain itemOptionsDisplayColor("COLOR CORRECTION", 3, 66, 60, 180, 0, &menuOptionsDisplayColor, -1, NULL, 0);
CGameMenuItemChain itemOptionsDisplayMode("VIDEO MODE", 3, 66, 70, 180, 0, &menuOptionsDisplayMode, -1, SetupVideoModeMenu, 0);
CGameMenuItemZBool itemOptionsDisplayBoolCrosshair("CROSSHAIR:", 3, 66, 80, 180, cl_crosshair, SetCrosshair, NULL, NULL);
CGameMenuItemZBool itemOptionsDisplayBoolCenterHoriz("CENTER HORIZON LINE:", 3, 66, 90, 180, gCenterHoriz, SetCenterHoriz, NULL, NULL);
CGameMenuItemZBool itemOptionsDisplayBoolCenterHoriz("CENTER HORIZON LINE:", 3, 66, 90, 180, r_horizcenter, SetCenterHoriz, NULL, NULL);
CGameMenuItemZBool itemOptionsDisplayBoolLevelStats("LEVEL STATS:", 3, 66, 100, 180, hud_stats, SetLevelStats, NULL, NULL);
CGameMenuItemZBool itemOptionsDisplayBoolPowerupDuration("POWERUP DURATION:", 3, 66, 110, 180, gPowerupDuration, SetPowerupDuration, NULL, NULL);
CGameMenuItemZBool itemOptionsDisplayBoolShowMapTitle("MAP TITLE:", 3, 66, 120, 180, hud_showmapname, SetShowMapTitle, NULL, NULL);
@ -1145,7 +1145,7 @@ void SetupOptionsMenu(void)
#endif
menuOptionsDisplay.Add(&itemBloodQAV, false);
itemOptionsDisplayBoolCrosshair.at20 = cl_crosshair;
itemOptionsDisplayBoolCenterHoriz.at20 = gCenterHoriz;
itemOptionsDisplayBoolCenterHoriz.at20 = r_horizcenter;
itemOptionsDisplayBoolLevelStats.at20 = hud_stats;
itemOptionsDisplayBoolPowerupDuration.at20 = gPowerupDuration;
itemOptionsDisplayBoolShowMapTitle.at20 = hud_showmapname;
@ -1376,7 +1376,7 @@ void SetCrosshair(CGameMenuItemZBool *pItem)
void SetCenterHoriz(CGameMenuItemZBool *pItem)
{
gCenterHoriz = pItem->at20;
r_horizcenter = pItem->at20;
}
void ResetKeys(CGameMenuItemChain *)

View file

@ -3043,7 +3043,7 @@ void viewDrawScreen(void)
{
int nPalette = 0;
static ClockTicks lastUpdate;
int defaultHoriz = gCenterHoriz ? 100 : 90;
int defaultHoriz = r_horizcenter ? 100 : 90;
#ifdef USE_OPENGL
polymostcenterhoriz = defaultHoriz;

View file

@ -64,6 +64,11 @@ enum
//CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar)
//CVAR_CHEAT = 32768,// can be set only when sv_cheats is enabled
//CVAR_UNSAFECONTEXT = 65536,// cvar value came from unsafe context
CVAR_FRONTEND_BLOOD = 0x10000000, // To mark frontend specific CVARs, so that the other ones can disable them.
CVAR_FRONTEND_EDUKE = 0x20000000,
CVAR_FRONTEND_DUKELIKE = 0x30000000,
CVAR_FRONTEND_REDNUKEM = 0x40000000,
CVAR_FRONTEND_SHADOWWARRIOR = 0x80000000,
};
union UCVarValue

View file

@ -47,9 +47,9 @@ CVARD(Bool, cl_showcoords, false, 0, "show your position in the game world") //
CVARD(Bool, cl_weaponsway, true, CVAR_ARCHIVE, "enable/disable player weapon swaying") // Not implemented for Blood
// Todo: Consolidate these to be consistent across games?
CVARD(Bool, cl_viewbob, true, CVAR_ARCHIVE, "enable/disable player head bobbing") // Not implemented for Blood
CVARD(Bool, cl_viewhbob, true, CVAR_ARCHIVE, "enable/disable view horizontal bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewvbob, true, CVAR_ARCHIVE, "enable/disable view vertical bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewbob, true, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "enable/disable player head bobbing") // Not implemented for Blood
CVARD(Bool, cl_viewhbob, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable view horizontal bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewvbob, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable view vertical bobbing") // Only implemented in Blood
CVARD(Bool, cl_interpolate, true, CVAR_ARCHIVE, "enable/disable view interpolation") // only implemented in Blood
CVARD(Bool, cl_slopetilting, false, CVAR_ARCHIVE, "enable/disable slope tilting") // only implemented in Blood
@ -108,7 +108,7 @@ CVARD(Bool, snd_doppler, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable
CVARD(Bool, mus_enabled, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disables music")
CVARD(Bool, mus_restartonload, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "restart the music when loading a saved game with the same map or not") // only implemented for Blood - todo: generalize
CVARD(Bool, mus_redbook, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disables redbook audio (Blood only!)") // only Blood has assets for this.
CVARD(Bool, mus_redbook, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_FRONTEND_BLOOD, "enables/disables redbook audio (Blood only!)") // only Blood has assets for this.
CUSTOM_CVARD(Bool, snd_reversestereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "reverses the stereo channels")
{
@ -153,8 +153,10 @@ CUSTOM_CVARD(Int, mus_volume, 255, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls mus
// HUD
// NBlood had this differently with an inverted scale of 0-7 with 0 having no HUD, For consistency all frontends now use the same scale, with 0 being the smallest and 11 being the largest.
CUSTOM_CVARD(Int, r_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD layout")
// This was particularly messy. EDuke and Rednukem had no consistent setting for this but a complex combination fo 4 CVARs and lots of mod flags controlling the HUD layout
// NBlood had this differently with an inverted scale of 0-7 with 0 having no HUD.
// For consistency all frontends now use the same scale, with 0 being the smallest and 11 being the largest, which get converted to the internal swrrings by the set_hud_layout callback.
CUSTOM_CVARD(Int, hud_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD size and style")
{
if (self < 0) self = 0;
else if (self > 11) self = 11;
@ -163,37 +165,37 @@ CUSTOM_CVARD(Int, r_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD la
if (gi->validate_hud(self))
gi->set_hud_layout(self);
else
OSD_Printf("Hud size %d not available\n");
OSD_Printf("Hud size %d not available\n", *self);
}
}
CUSTOM_CVARD(Int, hud_scale, 100, CVAR_ARCHIVE | CVAR_NOINITCALL, "changes the hud scale")//, (void*)&ud.statusbarscale, CVAR_INT | CVAR_FUNCPTR, 36, 100 },
CUSTOM_CVARD(Int, hud_scale, 100, CVAR_ARCHIVE | CVAR_NOINITCALL, "changes the hud scale")
{
if (self < 36) self = 36;
else if (self > 100) self = 100;
else gi->set_hud_scale(r_size);
else gi->set_hud_scale(hud_size);
}
// This is to allow flattening the overly complicated HUD configuration to one single value and keep the complexity safely inside the HUD code.
bool G_ChangeHudLayout(int direction)
{
if (direction < 0 && r_size > 0)
if (direction < 0 && hud_size > 0)
{
int layout = r_size - 1;
int layout = hud_size - 1;
while (!gi->validate_hud(layout) && layout >= 0) layout--;
if (layout >= 0)
{
r_size = layout;
hud_size = layout;
return true;
}
}
else if (r_size < 11)
else if (hud_size < 11)
{
int layout = r_size + 1;
int layout = hud_size + 1;
while (!gi->validate_hud(layout) && layout <= 11) layout++;
if (layout <= 11)
{
r_size = layout;
hud_size = layout;
return true;
}
}
@ -215,6 +217,8 @@ CUSTOM_CVARD(Int, r_fov, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "change the field o
else if (self < 140) self = 140;
}
CVARD(Bool, r_horizcenter, false, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable centered horizon line") // only present in Blood, maybe add to others?
#if 0
@ -334,7 +338,6 @@ int32_t registerosdcommands(void)
char buffer[256];
static osdcvardata_t cvars_game[] =
{
{ "horizcenter", "enable/disable centered horizon line", (void *)&gCenterHoriz, CVAR_BOOL, 0, 1 },
{ "in_joystick","enables input from the joystick if it is present",(void *)&gSetup.usejoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_mouse","enables input from the mouse if it is present",(void *)&gSetup.usemouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },

View file

@ -56,6 +56,8 @@ EXTERN_CVAR(Bool, hud_stats)
EXTERN_CVAR(Bool, hud_showmapname)
EXTERN_CVAR(Int, r_fov)
EXTERN_CVAR(r_horizcenter)
extern int hud_statusbarrange; // will be set by the game's configuration setup.
bool G_ChangeHudLayout(int direction);
bool G_CheckAutorun(bool button);

View file

@ -1233,11 +1233,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
videoSetGameMode(fullscreen, xres, yres, bpp, ud.detail);
}
}
else if (!Bstrcasecmp(parm->name, "r_size"))
{
ud.statusbarmode = (ud.screen_size < 8);
G_UpdateScreenArea();
}
else if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset"))
{
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);