From 2f059d7b59b4891089fa5c52dd7aec570ac33e89 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 26 Feb 2007 03:00:25 +0000 Subject: [PATCH] Some minor tweeks to the hud plugin git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2470 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_screen.c | 22 ++++++-- engine/client/pr_csqc.c | 8 ++- engine/client/sbar.c | 108 ++++++++++++++++++++++++-------------- engine/client/sbar.h | 2 + engine/common/plugin.c | 21 +++++--- plugins/hud/ui_sbar.c | 9 ++-- 6 files changed, 116 insertions(+), 54 deletions(-) diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 0a4cc9c1a..5e79c28b5 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -2187,11 +2187,17 @@ void SCR_DrawTwoDimensional(int uimenu, qboolean nohud) if (scr_drawdialog) { if (!nohud) + { #ifdef PLUGINS Plug_SBar (); #else - Sbar_Draw (); + if (Sbar_ShouldDraw()) + { + Sbar_Draw (); + Sbar_DrawScoreboard (); + } #endif + } SCR_ShowPics_Draw(); Draw_FadeScreen (); SCR_DrawNotifyString (); @@ -2202,11 +2208,17 @@ void SCR_DrawTwoDimensional(int uimenu, qboolean nohud) SCR_DrawLoading (); if (!nohud) + { #ifdef PLUGINS Plug_SBar (); #else - Sbar_Draw (); + if (Sbar_ShouldDraw()) + { + Sbar_Draw (); + Sbar_DrawScoreboard (); + } #endif + } SCR_ShowPics_Draw(); } else if (cl.intermission == 1 && key_dest == key_game) @@ -2239,7 +2251,11 @@ void SCR_DrawTwoDimensional(int uimenu, qboolean nohud) #ifdef PLUGINS Plug_SBar (); #else - Sbar_Draw (); + if (Sbar_ShouldDraw()) + { + Sbar_Draw (); + Sbar_DrawScoreboard (); + } #endif SCR_ShowPics_Draw(); diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 831cfc444..64265b2cf 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -1136,11 +1136,17 @@ static void PF_R_RenderScene(progfuncs_t *prinst, struct globalvars_s *pr_global vid.recalc_refdef = 1; if (csqc_drawsbar) + { #ifdef PLUGINS Plug_SBar(); #else - Sbar_Draw(); + if (Sbar_ShouldDraw()) + { + Sbar_Draw (); + Sbar_DrawScoreboard (); + } #endif + } if (csqc_addcrosshair) Draw_Crosshair(); diff --git a/engine/client/sbar.c b/engine/client/sbar.c index 42d24dd44..cf95c2cbf 100644 --- a/engine/client/sbar.c +++ b/engine/client/sbar.c @@ -1255,6 +1255,10 @@ void Sbar_SoloScoreboard (void) units = seconds - 10*tens; sprintf (str,"Time :%3i:%i%i", minutes, tens, units); Sbar_DrawString (184, 4, str); + + // draw level name + l = strlen (cl.levelname); + Sbar_DrawString (232 - l*4, 12, cl.levelname); } void Sbar_CoopScoreboard (void) @@ -1650,6 +1654,70 @@ void Sbar_DrawNormal (int pnum) , cl.stats[pnum][STAT_AMMO] <= 10); } +qboolean Sbar_ShouldDraw (void) +{ + #ifdef TEXTEDITOR + extern qboolean editoractive; +#endif + qboolean headsup; + char st[512]; + int pnum; + + int deadcount=0; + + if (scr_con_current == vid.height) + return false; // console is full screen + +#ifdef TEXTEDITOR + if (editoractive) + return false; +#endif + +#ifdef VM_UI + if (UI_DrawStatusBar((sb_showscores?1:0) + (sb_showteamscores?2:0))>0) + return false; + if (UI_MenuState()) + return false; +#endif + + headsup = !(cl_sbar.value || (scr_viewsize.value<100&&cl.splitclients==1)); + if ((sb_updates >= vid.numpages) && !headsup) + return false; + + return true; +} + +void Sbar_DrawScoreboard (void) +{ + int pnum; + int deadcount=0; + + if (cls.protocol == CP_QUAKE2) + return; + + for (pnum = 0; pnum < cl.splitclients; pnum++) + { + if (cl.stats[pnum][STAT_HEALTH] <= 0) + deadcount++; + } + + if (deadcount == cl.splitclients && !cl.spectator) + { + if (cl.teamplay > 0 && !sb_showscores) + Sbar_TeamOverlay(); + else + Sbar_DeathmatchOverlay (0); + } + else if (sb_showscores) + Sbar_DeathmatchOverlay (0); + else if (sb_showteamscores) + Sbar_TeamOverlay(); + else + return; + + sb_updates = 0; +} + /* =============== Sbar_Draw @@ -1664,22 +1732,7 @@ void Sbar_Draw (void) char st[512]; int pnum; - int deadcount=0; - if (scr_con_current == vid.height) - return; // console is full screen - -#ifdef TEXTEDITOR - if (editoractive) - return; -#endif - -#ifdef VM_UI - if (UI_DrawStatusBar((sb_showscores?1:0) + (sb_showteamscores?2:0))>0) - return; - if (UI_MenuState()) - return; -#endif headsup = !(cl_sbar.value || (scr_viewsize.value<100&&cl.splitclients==1)); if ((sb_updates >= vid.numpages) && !headsup) @@ -1692,7 +1745,7 @@ void Sbar_Draw (void) SCR_VRectForPlayer(&sbar_rect, 0); if (*cl.q2statusbar) - Sbar_ExecuteLayoutString(cl.q2statusbar); + Sbar_ExecuteLayoutString(cl.q2statusbar); if (*cl.q2layout) { if (cl.q2frame.playerstate.stats[Q2STAT_LAYOUTS]) @@ -1798,34 +1851,11 @@ void Sbar_Draw (void) else Sbar_DrawNormal (pnum); } - - if (cl.stats[pnum][STAT_HEALTH] <= 0) - deadcount++; } - // main screen deathmatch rankings - // if we're dead show team scores in team games - if (deadcount == cl.splitclients && !cl.spectator) - { - if (cl.teamplay > 0 && - !sb_showscores) - Sbar_TeamOverlay(); - else - Sbar_DeathmatchOverlay (0); - } - else if (sb_showscores) - Sbar_DeathmatchOverlay (0); - else if (sb_showteamscores) - Sbar_TeamOverlay(); - #ifdef RGLQUAKE if (cl_sbar.value == 1 || scr_viewsize.value<100) { - if (sb_showscores || sb_showteamscores || - deadcount == cl.splitclients) - sb_updates = 0; - // clear unused areas in gl - if (cl.splitclients==1 && sbar_rect.x>0) { // left Draw_TileClear (0, sbar_rect.height - sb_lines, sbar_rect.x, sb_lines); diff --git a/engine/client/sbar.h b/engine/client/sbar.h index 0d76d684e..9ccf99a2b 100644 --- a/engine/client/sbar.h +++ b/engine/client/sbar.h @@ -33,7 +33,9 @@ void Sbar_ReInit (void); void Sbar_Changed (void); // call whenever any of the client stats represented on the sbar changes +qboolean Sbar_ShouldDraw(void); void Sbar_Draw (void); +void Sbar_DrawScoreboard (void); // called every frame by screen void Sbar_IntermissionOverlay (void); diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 30cc50651..9d9c149a1 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -927,7 +927,7 @@ int VARGS Plug_Net_SetTLSClient(void *offset, unsigned int mask, const long *arg pluginstream_t *stream; int handle = VM_LONG(arg[0]); - qboolean anon = true; + qboolean anon = false; if (handle < 0 || handle >= pluginstreamarraylen || pluginstreamarray[handle].plugin != currentplug) { Con_Printf("Plug_Net_SetTLSClient: socket does not belong to you (or is invalid)\n"); @@ -1536,8 +1536,11 @@ void Plug_SBar(void) int cp, ret; vrect_t rect; + if (!Sbar_ShouldDraw()) + return; + ret = 0; - if (!plug_sbar.value) + if (!plug_sbar.value || cl.splitclients > 1) currentplug = NULL; else { @@ -1556,12 +1559,9 @@ void Plug_SBar(void) } } } - if (!ret) + if (!(ret & 1)) { Sbar_Draw(); - currentplug = oc; - return; //our current sbar draws a scoreboard too. We don't want that bug to be quite so apparent. - //please don't implement this identical hack in your engines... } for (currentplug = plugs; currentplug; currentplug = currentplug->next) @@ -1573,7 +1573,7 @@ void Plug_SBar(void) SCR_VRectForPlayer(&rect, cp); if (Draw_ImageColours) Draw_ImageColours(1, 1, 1, 1); // ensure menu colors are reset - VM_Call(currentplug->vm, currentplug->sbarlevel[1], cp, rect.x, rect.y, rect.width, rect.height, sb_showscores+sb_showteamscores*2); + ret |= VM_Call(currentplug->vm, currentplug->sbarlevel[1], cp, rect.x, rect.y, rect.width, rect.height, sb_showscores+sb_showteamscores*2); } } } @@ -1587,11 +1587,16 @@ void Plug_SBar(void) SCR_VRectForPlayer(&rect, cp); if (Draw_ImageColours) Draw_ImageColours(1, 1, 1, 1); // ensure menu colors are reset - VM_Call(currentplug->vm, currentplug->sbarlevel[2], cp, rect.x, rect.y, rect.width, rect.height, sb_showscores+sb_showteamscores*2); + ret |= VM_Call(currentplug->vm, currentplug->sbarlevel[2], cp, rect.x, rect.y, rect.width, rect.height, sb_showscores+sb_showteamscores*2); } } } + if (!(ret & 2)) + { + Sbar_DrawScoreboard(); + } + currentplug = oc; } diff --git a/plugins/hud/ui_sbar.c b/plugins/hud/ui_sbar.c index 40cc644ea..dfc0813d1 100644 --- a/plugins/hud/ui_sbar.c +++ b/plugins/hud/ui_sbar.c @@ -1195,13 +1195,16 @@ int UI_StatusBar(int *arg) float vsx, vsy; if (hudedit) // don't redraw twice - return true; + return 1; if (arg[5]) - return false; + return 1; CL_GetStats(arg[0], stats, sizeof(stats)/sizeof(int)); + if (stats[STAT_HEALTH] <= 0) + return 1; + vsx = arg[3]/640.0f; vsy = arg[4]/480.0f; for (i = 0; i < numelements; i++) @@ -1215,7 +1218,7 @@ int UI_StatusBar(int *arg) drawelement[element[i].type].draw(); } - return true; + return 1; } int UI_StatusBarEdit(int *arg) // seperated so further improvements to editor view can be done