From 63bbd353fcf4e09dc4352447a7e6f8d2f5a5b884 Mon Sep 17 00:00:00 2001 From: aurhat Date: Sat, 7 Mar 2015 12:17:44 +0100 Subject: [PATCH] Align equipment icons and stats on HUD Among other things it fixes https://github.com/assaultcube/AC/issues/65 . It betters also display for oldfashionedgunstats=1. --- source/src/protos.h | 7 +++++++ source/src/renderhud.cpp | 14 ++++++++------ source/src/weapon.cpp | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/src/protos.h b/source/src/protos.h index ee4f13ec..299cbba5 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -595,6 +595,13 @@ extern void restoreeditundo(ucharbuf &q); extern int backupeditundo(vector &buf, int undolimit, int redolimit); // renderhud +#define HUDPOS_ICONSPACING 235 +#define HUDPOS_HEALTH 10 +#define HUDPOS_ARMOUR (HUDPOS_HEALTH + HUDPOS_ICONSPACING) +#define HUDPOS_WEAPON (HUDPOS_ARMOUR + HUDPOS_ICONSPACING) +#define HUDPOS_GRENADE (HUDPOS_WEAPON + HUDPOS_ICONSPACING) +#define HUDPOS_NUMBERSPACING 70 + enum { HUDMSG_INFO = 0, diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 4ba982b7..7cc8203e 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -368,6 +368,8 @@ void drawdmgindicator() glEnable(GL_TEXTURE_2D); } +extern int oldfashionedgunstats; + void drawequipicons(playerent *p) { glDisable(GL_BLEND); @@ -375,9 +377,9 @@ void drawequipicons(playerent *p) glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/100.0f)+1.0f)/2.0f); // health & armor - if(p->armour) drawequipicon(560, 1650, (p->armour-1)/25, 2, false); - drawequipicon(20, 1650, 2, 3, (p->state!=CS_DEAD && p->health<=20 && !m_osok)); - if(p->mag[GUN_GRENADE]) drawequipicon(1520, 1650, 3, 1, false); + if(p->armour) drawequipicon(HUDPOS_ARMOUR*2, 1650, (p->armour-1)/25, 2, false); + drawequipicon(HUDPOS_HEALTH*2, 1650, 2, 3, (p->state!=CS_DEAD && p->health<=20 && !m_osok)); + if(p->mag[GUN_GRENADE]) drawequipicon(oldfashionedgunstats ? (HUDPOS_GRENADE + 25)*2 : HUDPOS_GRENADE*2, 1650, 3, 1, false); // weapons int c = p->weaponsel->type != GUN_GRENADE ? p->weaponsel->type : p->prevweaponsel->type, r = 0; @@ -385,7 +387,7 @@ void drawequipicons(playerent *p) if(c>3) { c -= 4; r = 1; } if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); + drawequipicon(HUDPOS_WEAPON*2, 1650, c, r, (!p->weaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); glEnable(GL_BLEND); } @@ -1080,8 +1082,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(!hidehudequipment) { pushfont("huddigits"); - draw_textf("%d", 90, 823, p->health); - if(p->armour) draw_textf("%d", 360, 823, p->armour); + draw_textf("%d", HUDPOS_HEALTH + HUDPOS_NUMBERSPACING, 823, p->health); + if(p->armour) draw_textf("%d", HUDPOS_ARMOUR + HUDPOS_NUMBERSPACING, 823, p->armour); if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->type