From 1d81f2e2b64ba1cbbf01b2378e221561c44dbe12 Mon Sep 17 00:00:00 2001 From: svdijk Date: Tue, 6 May 2014 19:45:11 +0200 Subject: [PATCH] screen: auto-scale the HUD when gl_hudscale < 0. --- src/client/cl_inventory.c | 5 +---- src/client/cl_screen.c | 38 ++++++++++++++++++++++++++++++++----- src/client/header/screen.h | 2 ++ src/client/refresh/r_main.c | 4 ---- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/client/cl_inventory.c b/src/client/cl_inventory.c index 170d102c..6cfd0762 100644 --- a/src/client/cl_inventory.c +++ b/src/client/cl_inventory.c @@ -59,9 +59,6 @@ SetStringHighBit(char *s) #define DISPLAY_ITEMS 17 -// from r_main.c -extern cvar_t *gl_hudscale; - void CL_DrawInventory(void) { @@ -80,7 +77,7 @@ CL_DrawInventory(void) num = 0; selected_num = 0; - float scale = gl_hudscale->value; + float scale = SCR_GetHUDScale(); for (i = 0; i < MAX_ITEMS; i++) { diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c index f2816cf9..9c707820 100644 --- a/src/client/cl_screen.c +++ b/src/client/cl_screen.c @@ -50,6 +50,8 @@ cvar_t *scr_graphscale; cvar_t *scr_graphshift; cvar_t *scr_drawall; +cvar_t *gl_hudscale; /* named for consistency with R1Q2 */ + typedef struct { int x1, y1, x2, y2; @@ -423,9 +425,9 @@ SCR_Init(void) { scr_viewsize = Cvar_Get("viewsize", "100", CVAR_ARCHIVE); scr_conspeed = Cvar_Get("scr_conspeed", "3", 0); + scr_centertime = Cvar_Get("scr_centertime", "2.5", 0); scr_showturtle = Cvar_Get("scr_showturtle", "0", 0); scr_showpause = Cvar_Get("scr_showpause", "1", 0); - scr_centertime = Cvar_Get("scr_centertime", "2.5", 0); scr_netgraph = Cvar_Get("netgraph", "0", 0); scr_timegraph = Cvar_Get("timegraph", "0", 0); scr_debuggraph = Cvar_Get("debuggraph", "0", 0); @@ -433,6 +435,7 @@ SCR_Init(void) scr_graphscale = Cvar_Get("graphscale", "1", 0); scr_graphshift = Cvar_Get("graphshift", "0", 0); scr_drawall = Cvar_Get("scr_drawall", "0", 0); + gl_hudscale = Cvar_Get("gl_hudscale", "1", CVAR_ARCHIVE); /* register our commands */ Cmd_AddCommand("timerefresh", SCR_TimeRefresh_f); @@ -1012,9 +1015,6 @@ SCR_TouchPics(void) } } -// from r_main.c -extern cvar_t *gl_hudscale; - void SCR_ExecuteLayoutString(char *s) { @@ -1025,7 +1025,7 @@ SCR_ExecuteLayoutString(char *s) int index; clientinfo_t *ci; - float scale = gl_hudscale->value; + float scale = SCR_GetHUDScale(); if ((cls.state != ca_active) || !cl.refresh_prepped) { @@ -1585,3 +1585,31 @@ SCR_DrawCrosshair(void) crosshair_pic); } +float +SCR_GetHUDScale(void) +{ + float scale; + + if (gl_hudscale->value < 0) + { + int i = viddef.width / 640; + + while (i > viddef.height / 240) + { + i--; + } + if (i < 1) + { + i = 1; + } + + scale = i; + } + else + { + scale = gl_hudscale->value; + } + + return scale; +} + diff --git a/src/client/header/screen.h b/src/client/header/screen.h index 7caaac81..e91726c3 100644 --- a/src/client/header/screen.h +++ b/src/client/header/screen.h @@ -65,4 +65,6 @@ void SCR_RunCinematic(void); void SCR_StopCinematic(void); void SCR_FinishCinematic(void); +float SCR_GetHUDScale(void); + #endif diff --git a/src/client/refresh/r_main.c b/src/client/refresh/r_main.c index ba16c926..6b147497 100644 --- a/src/client/refresh/r_main.c +++ b/src/client/refresh/r_main.c @@ -141,8 +141,6 @@ cvar_t *gl_anisotropic_avail; cvar_t *gl_lockpvs; cvar_t *gl_msaa_samples; -cvar_t *gl_hudscale; - cvar_t *vid_fullscreen; cvar_t *vid_gamma; @@ -1020,8 +1018,6 @@ R_Register(void) gl_customheight = Cvar_Get("gl_customheight", "768", CVAR_ARCHIVE); gl_msaa_samples = Cvar_Get ( "gl_msaa_samples", "0", CVAR_ARCHIVE ); - gl_hudscale = Cvar_Get ("gl_hudscale", "1", CVAR_ARCHIVE); - #ifdef RETEXTURE gl_retexturing = Cvar_Get("gl_retexturing", "1", CVAR_ARCHIVE); #endif