From e317109cd74ab846a4001439d8e99e4d85cc92e9 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 9 Jan 2006 02:16:09 +0000 Subject: [PATCH] Latest version. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1830 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- quakec/fallout2/csqc/invent.qc | 72 ++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/quakec/fallout2/csqc/invent.qc b/quakec/fallout2/csqc/invent.qc index c0741c9d..bdc354b6 100644 --- a/quakec/fallout2/csqc/invent.qc +++ b/quakec/fallout2/csqc/invent.qc @@ -20,6 +20,10 @@ vector toppos = '0 32 0'; float k_mouse1; float mouseisdown; +#define IMGSIZEF 64 +#define IMGSIZEV ('1 1 0'*IMGSIZEF) +#define CURSORSIZE 8 + void(vector pos, float slotno) SlotImage = { local float it; @@ -33,7 +37,14 @@ void(vector pos, float slotno) SlotImage = it = getstati(31+slotno); itname = GetItemImage(ToIID(it)); - drawpic(pos, strcat("gui/", itname), '96 96 0', '1 1 1', 1); + drawpic(pos, strcat("gui/", itname), IMGSIZEV, '1 1 1', 1); + + it = ToStatus(it); + if (it <= 1) + return; + itname = ftos(it); + it = strlen(itname); + drawstring(pos + IMGSIZEV - '0 8 0' - '8 0 0'*it, itname, '8 8 8', '1 1 1', 1); }; void() Invent_Draw = @@ -49,11 +60,11 @@ void() Invent_Draw = local float slotofs; - slotofs = sliderpos*96*8 + 96*3; + slotofs = sliderpos*IMGSIZEF*8 + IMGSIZEF*3; - for (i = 3; i < 16; i++) + for (i = 3; i < MAXSLOTS; i++) { - SlotImage(((i*96-slotofs) * '0 1 0'), i+1); + SlotImage(((i*IMGSIZEF-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); @@ -61,19 +72,40 @@ void() Invent_Draw = 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); + drawstring('112 248 0'+('1 0 0'*IMGSIZEF), " HAND 2 ", '8 8 8', '1 1 1', 1); + SlotImage('112 256 0'+('1 0 0'*IMGSIZEF), 2); + drawstring('112 248 0'+('2 0 0'*IMGSIZEF), " ARMOUR ", '8 8 8', '1 1 1', 1); + SlotImage('112 256 0'+('2 0 0'*IMGSIZEF), 3); + + i = getstati(62); + if (i == 1) + itname = "team: rangers"; + else if (i == 2) + itname = "team: raiders"; + else + itname = "team: none"; + drawstring('112 264 0'+('0 1 0'*IMGSIZEF), itname, '8 8 8', '1 1 1', 1); + i = getstati(63); + if (i == 1) + itname = "class: medic"; + else if (i == 2) + itname = "class: assasin"; + else if (i == 3) + itname = "class: soldier"; + else if (i == 4) + itname = "class: scientist"; + else + itname = "class: none"; + drawstring('112 272 0'+('0 1 0'*IMGSIZEF), itname, '8 8 8', '1 1 1', 1); - drawpic('96 0 0', "gui/scrollup.jpg", '16 16 0', '1 1 1', 1); + drawpic(('1 0 0'*IMGSIZEF), "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('1 0 0'*IMGSIZEF+'0 16 0'+i*'0 1 0', "gui/scrollbar.jpg", '16 16 0', '1 1 1', 1); + drawpic(('1 0 0'*IMGSIZEF)+(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); + drawpic(('1 0 0'*IMGSIZEF)+'0 16 0'+sliderpos*(height-48)*'0 1 0', "gui/scrollbox.jpg", '16 16 0', '1 1 1', 1); if (showcontextmenu) @@ -86,16 +118,16 @@ void() Invent_Draw = } else { - if (mousepos_x >= 96) + if (mousepos_x >= IMGSIZEF) { 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; + if (mousepos_x >= 112 && mousepos_x <= 112+3*IMGSIZEF) + if (mousepos_y >= 256 && mousepos_y <= 256+IMGSIZEF) + slotnum = floor((mousepos_x - 112)/IMGSIZEF) + 1; } else { - slotnum = floor((mousepos_y + slotofs)/96) + 1; + slotnum = floor((mousepos_y + slotofs)/IMGSIZEF) + 1; } // slotnum = floor((mousepos_y - toppos_y)/8) + 1; } @@ -111,7 +143,7 @@ void() Invent_Draw = // 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); + drawpic(mousepos, "gui/cursor.jpg", '1 1 0'*CURSORSIZE, '1 1 1', 1); }; void() CalcScrollPos = @@ -136,7 +168,7 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent = return false; else if (param1 == k_mouse1) { - if (mousepos_x >= 96 && mousepos_x <= 96+16) + if (mousepos_x >= IMGSIZEF && mousepos_x <= IMGSIZEF+16) { mouseisdown = true; CalcScrollPos(); @@ -168,7 +200,7 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent = } else { - if (mousepos_x >= 96 && mousepos_x <= 96+16) + if (mouseisdown) { //within the scrollbar mouseisdown = false; }