From 4bd1718475b5a930dba9300ba61f07cb0481056d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 11 Feb 2003 21:24:27 +0000 Subject: [PATCH] re-arrange viewsize handling to fix the hud bug in glx --- include/QF/render.h | 3 +++ libs/video/renderer/gl/gl_screen.c | 34 ++++++++------------------- libs/video/renderer/r_cvar.c | 18 ++++++++++++++- libs/video/renderer/r_screen.c | 9 ++++---- libs/video/renderer/sw/screen.c | 34 ++++++--------------------- libs/video/renderer/sw32/screen.c | 34 ++++++--------------------- nq/source/cl_main.c | 11 --------- nq/source/sbar.c | 35 ++++++++++++++++++++++++++++ qw/source/cl_main.c | 13 ----------- qw/source/sbar.c | 37 +++++++++++++++++++++++++++++- 10 files changed, 118 insertions(+), 110 deletions(-) diff --git a/include/QF/render.h b/include/QF/render.h index 6292c4112..e1b7ac088 100644 --- a/include/QF/render.h +++ b/include/QF/render.h @@ -143,6 +143,9 @@ extern struct texture_s *r_notexture_mip; extern entity_t r_worldentity; +extern void (*r_viewsize_callback)(struct cvar_s *var); +extern int r_viewsize; + void R_Init (void); void R_Init_Cvars (void); void R_InitEfrags (void); diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index c82320ba1..9a19eaa4c 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -74,7 +74,7 @@ static void SCR_CalcRefdef (void) { float size; - int h; + int h, lines; qboolean full = false; scr_fullupdate = 0; // force a background redraw @@ -83,34 +83,25 @@ SCR_CalcRefdef (void) // force the status bar to redraw Sbar_Changed (); - // bound viewsize - Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); - // bound field of view Cvar_SetValue (scr_fov, bound (1, scr_fov->value, 170)); - if (scr_viewsize->int_val >= 120) - sb_lines = 0; // no status bar at all - else if (scr_viewsize->int_val >= 110) - sb_lines = 24; // no inventory - else - sb_lines = 24 + 16 + 8; - - if (scr_viewsize->int_val >= 100) { + if (r_viewsize >= 100) { full = true; size = 100.0; } else { - size = scr_viewsize->int_val; + size = r_viewsize; } // intermission is always full screen + lines = r_lineadj; if (r_force_fullscreen /* FIXME: better test */) { full = true; size = 100.0; - sb_lines = 0; + lines = 0; } size /= 100.0; - h = vid.height - r_lineadj; + h = vid.height - lines; r_refdef.vrect.width = vid.width * size + 0.5; if (r_refdef.vrect.width < 96) { @@ -223,11 +214,11 @@ SCR_TileClear (void) { if (r_refdef.vrect.x > 0) { // left - Draw_TileClear (0, 0, r_refdef.vrect.x, vid.height - sb_lines); + Draw_TileClear (0, 0, r_refdef.vrect.x, vid.height - r_lineadj); // right Draw_TileClear (r_refdef.vrect.x + r_refdef.vrect.width, 0, vid.width - r_refdef.vrect.x + r_refdef.vrect.width, - vid.height - sb_lines); + vid.height - r_lineadj); } if (r_refdef.vrect.y > 0) { // top @@ -238,13 +229,11 @@ SCR_TileClear (void) Draw_TileClear (r_refdef.vrect.x, r_refdef.vrect.y + r_refdef.vrect.height, r_refdef.vrect.width, - vid.height - sb_lines - + vid.height - r_lineadj - (r_refdef.vrect.height + r_refdef.vrect.y)); } } -int oldviewsize = 0; - /* SCR_UpdateScreen @@ -274,11 +263,6 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) if (!scr_initialized) return; // not initialized yet - if (oldviewsize != scr_viewsize->int_val) { - oldviewsize = scr_viewsize->int_val; - vid.recalc_refdef = true; - } - GL_BeginRendering (&glx, &gly, &glwidth, &glheight); if (r_speeds->int_val) { diff --git a/libs/video/renderer/r_cvar.c b/libs/video/renderer/r_cvar.c index dff39d2ef..0e231efba 100644 --- a/libs/video/renderer/r_cvar.c +++ b/libs/video/renderer/r_cvar.c @@ -140,6 +140,9 @@ cvar_t *scr_showram; cvar_t *scr_showturtle; cvar_t *scr_viewsize; +void (*r_viewsize_callback)(cvar_t *var); +int r_viewsize; + float cl_wateralpha; static void @@ -214,6 +217,19 @@ scr_ffov_f (cvar_t *var) Cvar_Set (scr_fviews, "6"); } +static void +viewsize_f (cvar_t *var) +{ + if (var->int_val < 32 || var->int_val > 120) { + Cvar_SetValue (var, bound (30, var->int_val, 120)); + } else { + vid.recalc_refdef = true; + r_viewsize = bound (0, var->int_val, 100); + if (r_viewsize_callback) + r_viewsize_callback (var); + } +} + void R_Init_Cvars (void) { @@ -434,6 +450,6 @@ R_Init_Cvars (void) "Show RAM icon if game is running low on memory"); scr_showturtle = Cvar_Get ("showturtle", "0", CVAR_NONE, NULL, "Show a turtle icon if your fps is below 10"); - scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE, NULL, + scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE, viewsize_f, "Set the screen size 30 minimum, 120 maximum"); } diff --git a/libs/video/renderer/r_screen.c b/libs/video/renderer/r_screen.c index 0bc28644d..79c79f934 100644 --- a/libs/video/renderer/r_screen.c +++ b/libs/video/renderer/r_screen.c @@ -104,7 +104,6 @@ int scr_copyeverything; float scr_con_current; float scr_conlines; // lines of console to display -int oldscreensize; float oldfov; int oldsbar; @@ -328,7 +327,7 @@ SCR_DrawFPS (void) } x = hudswap ? vid.width - ((strlen (st) * 8) + i) : i; - y = vid.height - sb_lines - 8; + y = vid.height - r_lineadj - 8; Draw_String (x, y, st); } @@ -364,7 +363,7 @@ SCR_DrawTime (void) // Print it at far left/right of screen x = hudswap ? (vid.width - ((strlen (st) * 8) + 8)) : 8; - y = vid.height - (sb_lines + 8); + y = vid.height - (r_lineadj + 8); Draw_String (x, y, st); } @@ -398,7 +397,7 @@ SCR_SetUpToDrawConsole (void) else scr_conlines = 0; // none visible - if (scr_con_current >= vid.height - sb_lines) + if (scr_con_current >= vid.height - r_lineadj) scr_copyeverything = 1; if (scr_conlines < scr_con_current) { scr_con_current -= scr_conspeed->value * r_frametime; @@ -410,7 +409,7 @@ SCR_SetUpToDrawConsole (void) if (scr_conlines < scr_con_current) scr_con_current = scr_conlines; } - if (scr_con_current >= vid.height - sb_lines) + if (scr_con_current >= vid.height - r_lineadj) scr_copyeverything = 1; if (clearconsole++ < vid.numpages) diff --git a/libs/video/renderer/sw/screen.c b/libs/video/renderer/sw/screen.c index beec67604..97cb3baad 100644 --- a/libs/video/renderer/sw/screen.c +++ b/libs/video/renderer/sw/screen.c @@ -68,7 +68,7 @@ SCR_CalcRefdef (void) { vrect_t vrect; float size; - int h; + int h, lines; qboolean full = false; scr_fullupdate = 0; // force a background redraw @@ -77,34 +77,25 @@ SCR_CalcRefdef (void) // force the status bar to redraw Sbar_Changed (); - // bound viewsize - Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); - // bound field of view Cvar_SetValue (scr_fov, bound (1, scr_fov->value, 170)); - if (scr_viewsize->int_val >= 120) - sb_lines = 0; // no status bar at all - else if (scr_viewsize->int_val >= 110) - sb_lines = 24; // no inventory - else - sb_lines = 24 + 16 + 8; - - if (scr_viewsize->int_val >= 100) { + if (r_viewsize >= 100) { full = true; size = 100.0; } else { - size = scr_viewsize->int_val; + size = r_viewsize; } // intermission is always full screen + lines = r_lineadj; if (r_force_fullscreen /* FIXME: better test */) { full = true; size = 100.0; - sb_lines = 0; + lines = 0; } size /= 100.0; - h = vid.height - r_lineadj; + h = vid.height - lines; r_refdef.vrect.width = vid.width * size + 0.5; if (r_refdef.vrect.width < 96) { @@ -278,7 +269,6 @@ SCR_ScreenShot_f (void) void SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) { - static int oldviewsize; vrect_t vrect; if (scr_skipupdate || block_drawing) @@ -292,21 +282,11 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) if (!scr_initialized) return; // not initialized yet - if (oldviewsize != scr_viewsize->int_val) { - oldviewsize = scr_viewsize->int_val; - vid.recalc_refdef = true; - } - if (oldfov != scr_fov->value) { // determine size of refresh window oldfov = scr_fov->value; vid.recalc_refdef = true; } - if (oldscreensize != scr_viewsize->int_val) { - oldscreensize = scr_viewsize->int_val; - vid.recalc_refdef = true; - } - if (vid.recalc_refdef) SCR_CalcRefdef (); @@ -366,7 +346,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) vrect.x = 0; vrect.y = 0; vrect.width = vid.width; - vrect.height = vid.height - sb_lines; + vrect.height = vid.height - r_lineadj; vrect.pnext = 0; VID_Update (&vrect); diff --git a/libs/video/renderer/sw32/screen.c b/libs/video/renderer/sw32/screen.c index 70844aa5f..530681092 100644 --- a/libs/video/renderer/sw32/screen.c +++ b/libs/video/renderer/sw32/screen.c @@ -69,7 +69,7 @@ SCR_CalcRefdef (void) { vrect_t vrect; float size; - int h; + int h, lines; qboolean full = false; scr_fullupdate = 0; // force a background redraw @@ -78,34 +78,25 @@ SCR_CalcRefdef (void) // force the status bar to redraw Sbar_Changed (); - // bound viewsize - Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); - // bound field of view Cvar_SetValue (scr_fov, bound (1, scr_fov->value, 170)); - if (scr_viewsize->int_val >= 120) - sb_lines = 0; // no status bar at all - else if (scr_viewsize->int_val >= 110) - sb_lines = 24; // no inventory - else - sb_lines = 24 + 16 + 8; - - if (scr_viewsize->int_val >= 100) { + if (r_viewsize >= 100) { full = true; size = 100.0; } else { - size = scr_viewsize->int_val; + size = r_viewsize; } // intermission is always full screen + lines = r_lineadj; if (r_force_fullscreen /* FIXME: better test */) { full = true; size = 100.0; - sb_lines = 0; + lines = 0; } size /= 100.0; - h = vid.height - r_lineadj; + h = vid.height - lines; r_refdef.vrect.width = vid.width * size + 0.5; if (r_refdef.vrect.width < 96) { @@ -299,7 +290,6 @@ SCR_ScreenShot_f (void) void SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) { - static int oldviewsize; vrect_t vrect; if (scr_skipupdate || block_drawing) @@ -313,21 +303,11 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) if (!scr_initialized) return; // not initialized yet - if (oldviewsize != scr_viewsize->int_val) { - oldviewsize = scr_viewsize->int_val; - vid.recalc_refdef = true; - } - if (oldfov != scr_fov->value) { // determine size of refresh window oldfov = scr_fov->value; vid.recalc_refdef = true; } - if (oldscreensize != scr_viewsize->int_val) { - oldscreensize = scr_viewsize->int_val; - vid.recalc_refdef = true; - } - if (vid.recalc_refdef) SCR_CalcRefdef (); @@ -387,7 +367,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) vrect.x = 0; vrect.y = 0; vrect.width = vid.width; - vrect.height = vid.height - sb_lines; + vrect.height = vid.height - r_lineadj; vrect.pnext = 0; VID_Update (&vrect); diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index efc72dfa0..8a5a4b5c4 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -62,8 +62,6 @@ cvar_t *cl_writecfg; cvar_t *cl_shownet; cvar_t *cl_nolerp; -cvar_t *cl_sbar; -cvar_t *cl_sbar_separator; cvar_t *cl_hudswap; cvar_t *cl_cshift_bonus; @@ -93,13 +91,6 @@ cl_entity_state_t cl_baselines[MAX_EDICTS]; entity_t cl_static_entities[MAX_STATIC_ENTITIES]; -static void -CL_Sbar_f (cvar_t *var) -{ - vid.recalc_refdef = true; - r_lineadj = var->int_val ? sb_lines : 0; -} - static void cl_hudswap_f (cvar_t *var) { @@ -145,8 +136,6 @@ CL_InitCvars (void) "show network packets. 0=off, 1=basic, 2=verbose"); cl_nolerp = Cvar_Get ("cl_nolerp", "0", CVAR_NONE, NULL, "linear motion interpolation"); - cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_f, - "status bar mode"); cl_hudswap = Cvar_Get ("cl_hudswap", "0", CVAR_ARCHIVE, cl_hudswap_f, "new HUD on left side?"); lookspring = Cvar_Get ("lookspring", "0", CVAR_ARCHIVE, NULL, "Snap view " diff --git a/nq/source/sbar.c b/nq/source/sbar.c index 4e2ae9da7..dddeb639c 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -90,6 +90,37 @@ qpic_t *hsb_items[2]; // MED 01/04/97 added hipnotic items array qboolean headsup; qboolean sbar_centered; +cvar_t *cl_sbar; + +static void +calc_sb_lines (cvar_t *var) +{ + if (var->int_val >= 120) + sb_lines = 0; + else if (var->int_val >= 110) + sb_lines = 24; + else + sb_lines = 24 + 16 + 8; +} + +static void +cl_sbar_f (cvar_t *var) +{ + vid.recalc_refdef = true; + if (scr_viewsize) + calc_sb_lines (scr_viewsize); + r_lineadj = var->int_val ? sb_lines : 0; +} + +static void +viewsize_f (cvar_t *var) +{ + calc_sb_lines (var); + if (cl_sbar) + r_lineadj = cl_sbar->int_val ? sb_lines : 0; +} + + static int Sbar_ColorForMap (int m) { @@ -1198,4 +1229,8 @@ Sbar_Init (void) rsb_ammo[1] = Draw_PicFromWad ("r_ammomulti"); rsb_ammo[2] = Draw_PicFromWad ("r_ammoplasma"); } + + r_viewsize_callback = viewsize_f; + cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, cl_sbar_f, + "status bar mode"); } diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index bdb593a90..a95159b4c 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -142,8 +142,6 @@ cvar_t *cl_timeout; cvar_t *cl_shownet; cvar_t *cl_autoexec; cvar_t *cl_quakerc; -cvar_t *cl_sbar; -cvar_t *cl_sbar_separator; cvar_t *cl_hudswap; cvar_t *cl_maxfps; cvar_t *cl_usleep; @@ -232,13 +230,6 @@ char soundlist_name[] = "soundlist %i %i"; extern cvar_t *cl_showscoresuid; -static void -CL_Sbar_f (cvar_t *var) -{ - vid.recalc_refdef = true; - r_lineadj = var->int_val ? sb_lines : 0; -} - static void CL_Quit_f (void) { @@ -1285,10 +1276,6 @@ CL_Init_Cvars (void) "write config files?"); cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_NONE, NULL, "show network packets. 0=off, 1=basic, 2=verbose"); - cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_f, - "status bar mode"); - cl_sbar_separator = Cvar_Get ("cl_sbar_separator", "0", CVAR_ARCHIVE, NULL, - "turns on status bar separator"); cl_hudswap = Cvar_Get ("cl_hudswap", "0", CVAR_ARCHIVE, cl_hudswap_f, "new HUD on left side?"); cl_maxfps = Cvar_Get ("cl_maxfps", "0", CVAR_ARCHIVE, NULL, diff --git a/qw/source/sbar.c b/qw/source/sbar.c index 83e6096d9..32ae5c065 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -91,10 +91,39 @@ static qboolean largegame = false; cvar_t *cl_showscoresuid; cvar_t *fs_fraglog; cvar_t *cl_fraglog; - +cvar_t *cl_sbar; +cvar_t *cl_sbar_separator; static void (*Sbar_Draw_DMO_func) (int l, int y, int skip); +static void +calc_sb_lines (cvar_t *var) +{ + if (var->int_val >= 120) + sb_lines = 0; + else if (var->int_val >= 110) + sb_lines = 24; + else + sb_lines = 24 + 16 + 8; +} + +static void +cl_sbar_f (cvar_t *var) +{ + vid.recalc_refdef = true; + if (scr_viewsize) + calc_sb_lines (scr_viewsize); + r_lineadj = var->int_val ? sb_lines : 0; +} + +static void +viewsize_f (cvar_t *var) +{ + calc_sb_lines (var); + if (cl_sbar) + r_lineadj = cl_sbar->int_val ? sb_lines : 0; +} + /* Sbar_ShowTeamScores @@ -248,6 +277,8 @@ Sbar_Init (void) sb_ibar = Draw_PicFromWad ("ibar"); sb_scorebar = Draw_PicFromWad ("scorebar"); + r_viewsize_callback = viewsize_f; + cl_showscoresuid = Cvar_Get ("cl_showscoresuid", "0", CVAR_NONE, Sbar_DMO_Init_f, "Set to 1 to show uid " "instead of ping. Set to 2 to show both."); @@ -256,6 +287,10 @@ Sbar_Init (void) cl_fraglog = Cvar_Get ("cl_fraglog", "0", CVAR_ARCHIVE, NULL, "Automatic fraglogging, non-zero value will switch " "it on."); + cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, cl_sbar_f, + "status bar mode"); + cl_sbar_separator = Cvar_Get ("cl_sbar_separator", "0", CVAR_ARCHIVE, NULL, + "turns on status bar separator"); } // drawing routines are reletive to the status bar location