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
This commit is contained in:
TimeServ 2006-05-10 02:28:31 +00:00
parent 974cf6b3ac
commit efe118cb22

View file

@ -1194,6 +1194,9 @@ int UI_StatusBar(int *arg)
float vsx, vsy; float vsx, vsy;
if (hudedit) // don't redraw twice
return true;
if (arg[5]) if (arg[5])
return false; return false;
@ -1432,6 +1435,8 @@ void Hud_Load(char *fname)
element[i].type = type; element[i].type = type;
element[i].subtype = subtype; element[i].subtype = subtype;
} }
currentitem = -1;
} }
// FindItemUnderMouse: given mouse coordinates, finds element number under mouse // 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 (context)
{ {
if (key != K_MOUSE1) if (key != K_MOUSE1 || currentitem < 0)
{ {
context = false; context = false;
return; return;
@ -1627,7 +1632,7 @@ void UI_KeyPress(int key, int mx, int my)
if (context == 3) if (context == 3)
{ {
context = false; context = false;
if ((unsigned)(i-2) > drawelement[typetoinsert].maxsubtype) if ((unsigned)(i-2) > (unsigned)drawelement[typetoinsert].maxsubtype)
return; return;
currentitem = numelements; currentitem = numelements;
numelements++; numelements++;
@ -1941,9 +1946,10 @@ int Plug_MenuEvent(int *args)
altargs[4] = vid.height; altargs[4] = vid.height;
if (hudedit) if (hudedit)
UI_StatusBarEdit(altargs); UI_StatusBarEdit(altargs);
else // else
UI_StatusBar(altargs); //draw it using the same function (we're lazy) // UI_StatusBar(altargs); //draw it using the same function (we're lazy)
if (currentitem >= 0)
UI_DrawHandles(altargs, currentitem); UI_DrawHandles(altargs, currentitem);
sbarscalex = vid.width/640.0f; sbarscalex = vid.width/640.0f;