From efe118cb22313a22add505919ea6ef75ebde23b6 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Wed, 10 May 2006 02:28:31 +0000 Subject: [PATCH] don't crash with no object selected, don't draw twice while editing, misc cleanups git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2266 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- plugins/hud/ui_sbar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/hud/ui_sbar.c b/plugins/hud/ui_sbar.c index 79dbcbb02..9f4fb4612 100644 --- a/plugins/hud/ui_sbar.c +++ b/plugins/hud/ui_sbar.c @@ -1194,6 +1194,9 @@ int UI_StatusBar(int *arg) float vsx, vsy; + if (hudedit) // don't redraw twice + return true; + if (arg[5]) return false; @@ -1432,6 +1435,8 @@ void Hud_Load(char *fname) element[i].type = type; element[i].subtype = subtype; } + + currentitem = -1; } // FindItemUnderMouse: given mouse coordinates, finds element number under mouse @@ -1609,7 +1614,7 @@ void UI_KeyPress(int key, int mx, int my) if (context) { - if (key != K_MOUSE1) + if (key != K_MOUSE1 || currentitem < 0) { context = false; return; @@ -1627,7 +1632,7 @@ void UI_KeyPress(int key, int mx, int my) if (context == 3) { context = false; - if ((unsigned)(i-2) > drawelement[typetoinsert].maxsubtype) + if ((unsigned)(i-2) > (unsigned)drawelement[typetoinsert].maxsubtype) return; currentitem = numelements; numelements++; @@ -1941,10 +1946,11 @@ int Plug_MenuEvent(int *args) altargs[4] = vid.height; if (hudedit) UI_StatusBarEdit(altargs); - else - UI_StatusBar(altargs); //draw it using the same function (we're lazy) +// else +// UI_StatusBar(altargs); //draw it using the same function (we're lazy) - UI_DrawHandles(altargs, currentitem); + if (currentitem >= 0) + UI_DrawHandles(altargs, currentitem); sbarscalex = vid.width/640.0f; sbarscaley = vid.height/480.0f;