2006-01-02 02:52:56 +00:00
|
|
|
void bprint(float plev, string st, string s2){}
|
|
|
|
float PRINT_MEDIUM = 1;
|
|
|
|
#include "/../inventory.qc"
|
|
|
|
|
2006-01-02 22:04:05 +00:00
|
|
|
float show_inventory;
|
|
|
|
|
|
|
|
vector mousepos;
|
|
|
|
|
|
|
|
float showcontextmenu;
|
|
|
|
vector contextpos;
|
|
|
|
float slotnum;
|
|
|
|
|
2006-01-04 20:45:08 +00:00
|
|
|
float downslotnum;
|
|
|
|
|
2006-01-02 22:04:05 +00:00
|
|
|
vector toppos = '0 32 0';
|
|
|
|
|
|
|
|
float k_mouse1;
|
2006-01-02 02:52:56 +00:00
|
|
|
|
|
|
|
void() Invent_Draw =
|
|
|
|
{
|
|
|
|
local float i;
|
|
|
|
local float it;
|
|
|
|
local string itname;
|
2006-01-02 22:04:05 +00:00
|
|
|
local float op;
|
2006-01-02 02:52:56 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
if (i+1 == downslotnum && slotnum)
|
|
|
|
op = slotnum-1;
|
|
|
|
else if (i+1 == slotnum && downslotnum)
|
|
|
|
op = downslotnum-1;
|
|
|
|
else
|
|
|
|
op = i;
|
|
|
|
it = getstati(32+op);
|
2006-01-02 02:52:56 +00:00
|
|
|
itname = GetItemName(ToIID(it));
|
2006-01-02 22:04:05 +00:00
|
|
|
drawstring(toppos + (i * '0 8 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (showcontextmenu)
|
|
|
|
{
|
|
|
|
op = floor((mousepos_y - contextpos_y)/8);
|
|
|
|
drawfill(contextpos - '8 8 0', '88 24 0'+'16 16 0', '0 0 0', 0.7);
|
|
|
|
drawstring(contextpos + (0 * '0 8 0'), "Use/Reload", '8 8 0', '1 1 0' + (op!=0)*'0 0 1', 1);
|
|
|
|
drawstring(contextpos + (1 * '0 8 0'), "Put In Hand", '8 8 0', '1 1 0' + (op!=1)*'0 0 1', 1);
|
|
|
|
drawstring(contextpos + (2 * '0 8 0'), "Drop", '8 8 0', '1 1 0' + (op!=2)*'0 0 1', 1);
|
2006-01-02 02:52:56 +00:00
|
|
|
}
|
2006-01-02 22:04:05 +00:00
|
|
|
else
|
|
|
|
slotnum = floor((mousepos_y - toppos_y)/8) + 1;
|
|
|
|
|
|
|
|
|
|
|
|
drawfill(mousepos, '8 8 0', '0 0 0', 0.7);
|
|
|
|
drawstring(mousepos, "^", '8 8 0', '1 1 1', 1);
|
|
|
|
// drawpic(mousepos, "gui/cursor.jpg", '32 32 0', '1 1 1', 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|
|
|
{
|
|
|
|
local float op;
|
2006-01-04 20:45:08 +00:00
|
|
|
if (eventtype == 0) //key down
|
2006-01-02 22:04:05 +00:00
|
|
|
{
|
|
|
|
if (param1 == 'i')
|
2006-01-04 20:45:08 +00:00
|
|
|
{
|
2006-01-02 22:04:05 +00:00
|
|
|
show_inventory = !show_inventory;
|
2006-01-04 20:45:08 +00:00
|
|
|
}
|
2006-01-02 22:04:05 +00:00
|
|
|
else if (!show_inventory)
|
|
|
|
return false;
|
|
|
|
else if (param1 == k_mouse1)
|
2006-01-04 20:45:08 +00:00
|
|
|
{
|
|
|
|
downslotnum = slotnum;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (eventtype == 1 && show_inventory) //key up
|
|
|
|
{
|
|
|
|
if (param1 == k_mouse1)
|
2006-01-02 22:04:05 +00:00
|
|
|
{
|
|
|
|
if (showcontextmenu)
|
|
|
|
{
|
|
|
|
op = floor((mousepos_y - contextpos_y)/8);
|
|
|
|
|
|
|
|
if (op == 0)
|
|
|
|
localcmd(strcat("cmd invuse ", ftos(slotnum), "\n"));
|
|
|
|
else if (op == 1)
|
|
|
|
localcmd(strcat("cmd invswap 1 ", ftos(slotnum), "\nimpulse 1\n"));
|
|
|
|
else if (op == 2)
|
|
|
|
localcmd(strcat("cmd invdrop ", ftos(slotnum), "\n"));
|
|
|
|
|
|
|
|
|
|
|
|
showcontextmenu = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
if (downslotnum == slotnum) //mouse didn't move away
|
2006-01-02 22:04:05 +00:00
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
if (slotnum >= 1 && slotnum <= MAXSLOTS)
|
2006-01-02 22:04:05 +00:00
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
if (getstati(32+slotnum-1) != 0) //if there's actually an item there
|
|
|
|
{
|
|
|
|
showcontextmenu = true; //show the context menu
|
|
|
|
contextpos = mousepos;
|
|
|
|
}
|
2006-01-02 22:04:05 +00:00
|
|
|
}
|
2006-01-04 20:45:08 +00:00
|
|
|
else
|
|
|
|
show_inventory = false; //they clicked outside, fools!
|
2006-01-02 22:04:05 +00:00
|
|
|
}
|
|
|
|
else
|
2006-01-04 20:45:08 +00:00
|
|
|
{
|
|
|
|
//they dragged
|
|
|
|
showcontextmenu = false;
|
|
|
|
localcmd(strcat("cmd invswap ", ftos(downslotnum), " ", ftos(slotnum), "\nimpulse 1\n"));
|
|
|
|
}
|
2006-01-02 22:04:05 +00:00
|
|
|
}
|
2006-01-04 20:45:08 +00:00
|
|
|
downslotnum = 0;
|
2006-01-02 22:04:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (eventtype == 2 && show_inventory) //mouse
|
|
|
|
{
|
|
|
|
mousepos_x += param1;
|
|
|
|
mousepos_y += param2;
|
|
|
|
|
|
|
|
if (mousepos_x < 0)
|
|
|
|
mousepos_x = 0;
|
|
|
|
if (mousepos_y < 0)
|
|
|
|
mousepos_y = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
void() FigureOutButtons =
|
|
|
|
{
|
|
|
|
k_mouse1 = stringtokeynum("K_MOUSE1");
|
2006-01-02 02:52:56 +00:00
|
|
|
};
|