Inventory is now graphical.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1806 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
8e747066aa
commit
a952dcfc56
1 changed files with 105 additions and 17 deletions
|
@ -8,13 +8,33 @@ vector mousepos;
|
|||
|
||||
float showcontextmenu;
|
||||
vector contextpos;
|
||||
float slotnum;
|
||||
|
||||
float downslotnum;
|
||||
float slotnum; //the current slot under the mousecursor
|
||||
|
||||
float sliderpos;
|
||||
|
||||
float downslotnum; //the slot number when the mousecursor when down
|
||||
|
||||
vector toppos = '0 32 0';
|
||||
|
||||
float k_mouse1;
|
||||
float mouseisdown;
|
||||
|
||||
void(vector pos, float slotno) SlotImage =
|
||||
{
|
||||
local float it;
|
||||
local string itname;
|
||||
|
||||
if (slotno == downslotnum && slotnum)
|
||||
slotno = slotnum;
|
||||
else if (slotno == slotnum && downslotnum)
|
||||
slotno = downslotnum;
|
||||
|
||||
it = getstati(31+slotno);
|
||||
|
||||
itname = GetItemImage(ToIID(it));
|
||||
drawpic(pos, strcat("gui/", itname), '96 96 0', '1 1 1', 1);
|
||||
};
|
||||
|
||||
void() Invent_Draw =
|
||||
{
|
||||
|
@ -22,20 +42,40 @@ void() Invent_Draw =
|
|||
local float it;
|
||||
local string itname;
|
||||
local float op;
|
||||
|
||||
local float height;
|
||||
height = cvar("vid_conheight");
|
||||
//how much space have we got for the slider?
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
|
||||
local float slotofs;
|
||||
slotofs = sliderpos*96*13 - 96*3;
|
||||
|
||||
for (i = 3; i < 16; i++)
|
||||
{
|
||||
if (i+1 == downslotnum && slotnum)
|
||||
op = slotnum-1;
|
||||
else if (i+1 == slotnum && downslotnum)
|
||||
op = downslotnum-1;
|
||||
else
|
||||
op = i;
|
||||
it = getstati(32+op);
|
||||
itname = GetItemName(ToIID(it));
|
||||
drawstring(toppos + (i * '0 8 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1);
|
||||
SlotImage(((i*96-slotofs) * '0 1 0'), i+1);
|
||||
|
||||
// itname = GetItemName(ToIID(it));
|
||||
// drawstring(toppos + ((i*8-slotofs) * '0 1 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1);
|
||||
}
|
||||
|
||||
drawstring('112 248 0', " HAND 1 ", '8 8 8', '1 1 1', 1);
|
||||
SlotImage('112 256 0', 1);
|
||||
drawstring('112 248 0'+'96 0 0', " HAND 2 ", '8 8 8', '1 1 1', 1);
|
||||
SlotImage('112 256 0'+'96 0 0', 2);
|
||||
drawstring('112 248 0'+'192 0 0', " ARMOUR ", '8 8 8', '1 1 1', 1);
|
||||
SlotImage('112 256 0'+'192 0 0', 3);
|
||||
|
||||
|
||||
|
||||
drawpic('96 0 0', "gui/scrollup.jpg", '16 16 0', '1 1 1', 1);
|
||||
for (i = 0; i < height; i+=16)
|
||||
drawpic('96 16 0'+i*'0 1 0', "gui/scrollbar.jpg", '16 16 0', '1 1 1', 1);
|
||||
drawpic('96 0 0'+(height-16)*'0 1 0', "gui/scrolldown.jpg", '16 16 0', '1 1 1', 1);
|
||||
|
||||
drawpic('96 16 0'+sliderpos*(height-48)*'0 1 0', "gui/scrollbox.jpg", '16 16 0', '1 1 1', 1);
|
||||
|
||||
|
||||
if (showcontextmenu)
|
||||
{
|
||||
op = floor((mousepos_y - contextpos_y)/8);
|
||||
|
@ -45,14 +85,43 @@ void() Invent_Draw =
|
|||
drawstring(contextpos + (2 * '0 8 0'), "Drop", '8 8 0', '1 1 0' + (op!=2)*'0 0 1', 1);
|
||||
}
|
||||
else
|
||||
slotnum = floor((mousepos_y - toppos_y)/8) + 1;
|
||||
{
|
||||
if (mousepos_x >= 96)
|
||||
{
|
||||
slotnum = 0;
|
||||
if (mousepos_x >= 112 && mousepos_x <= 112+3*96)
|
||||
if (mousepos_y >= 256 && mousepos_y <= 256+96)
|
||||
slotnum = floor((mousepos_x - 112)/96) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
slotnum = floor((mousepos_y + slotofs)/96) + 1;
|
||||
}
|
||||
// slotnum = floor((mousepos_y - toppos_y)/8) + 1;
|
||||
}
|
||||
|
||||
drawstring('128 0 0', ftos(slotnum), '8 8 0', '1 1 1', 1);
|
||||
|
||||
it = getstati(31+slotnum);
|
||||
itname = GetItemName(ToIID(it));
|
||||
drawstring('128 32 0', itname, '8 8 0', '1 1 1', 1);
|
||||
itname = GetItemDesc(ToIID(it));
|
||||
drawstring('128 48 0', itname, '8 8 0', '1 1 1', 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);
|
||||
// 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);
|
||||
};
|
||||
|
||||
void() CalcScrollPos =
|
||||
{
|
||||
sliderpos = (mousepos_y-24)/(cvar("vid_conheight")-48);
|
||||
if (sliderpos < 0)
|
||||
sliderpos = 0;
|
||||
if (sliderpos > 1)
|
||||
sliderpos = 1;
|
||||
};
|
||||
|
||||
float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
||||
{
|
||||
|
@ -67,7 +136,13 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|||
return false;
|
||||
else if (param1 == k_mouse1)
|
||||
{
|
||||
downslotnum = slotnum;
|
||||
if (mousepos_x >= 96 && mousepos_x <= 96+16)
|
||||
{
|
||||
mouseisdown = true;
|
||||
CalcScrollPos();
|
||||
}
|
||||
else
|
||||
downslotnum = slotnum;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
@ -77,6 +152,12 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|||
{
|
||||
if (param1 == k_mouse1)
|
||||
{
|
||||
if (mousepos_x >= 96 && mousepos_x <= 96+16)
|
||||
{ //within the scrollbar
|
||||
mouseisdown = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (showcontextmenu)
|
||||
{
|
||||
op = floor((mousepos_y - contextpos_y)/8);
|
||||
|
@ -104,7 +185,10 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_inventory = false; //they clicked outside, fools!
|
||||
showcontextmenu = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -113,6 +197,7 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|||
localcmd(strcat("cmd invswap ", ftos(downslotnum), " ", ftos(slotnum), "\nimpulse 1\n"));
|
||||
}
|
||||
}
|
||||
mouseisdown = false;
|
||||
downslotnum = 0;
|
||||
}
|
||||
else
|
||||
|
@ -129,6 +214,9 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
|
|||
if (mousepos_y < 0)
|
||||
mousepos_y = 0;
|
||||
|
||||
if (mouseisdown)
|
||||
CalcScrollPos();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue