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.
This commit is contained in:
@@ -595,6 +595,13 @@ extern void restoreeditundo(ucharbuf &q);
|
||||
extern int backupeditundo(vector<uchar> &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,
|
||||
|
||||
@@ -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->type<NUMGUNS)
|
||||
drawequipicon(1020, 1650, c, r, (!p->weaponsel->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<NUMGUNS)
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
@@ -844,13 +844,13 @@ void weapon::renderstats()
|
||||
{
|
||||
char gunstats[64];
|
||||
if(oldfashionedgunstats) sprintf(gunstats, "%i/%i", mag, ammo); else sprintf(gunstats, "%i", mag);
|
||||
draw_text(gunstats, 590, 823);
|
||||
draw_text(gunstats, HUDPOS_WEAPON + HUDPOS_NUMBERSPACING, 823);
|
||||
if(!oldfashionedgunstats)
|
||||
{
|
||||
int offset = text_width(gunstats);
|
||||
glScalef(0.5f, 0.5f, 1.0f);
|
||||
sprintf(gunstats, "%i", ammo);
|
||||
draw_text(gunstats, (590 + offset)*2, 826*2);
|
||||
draw_text(gunstats, (HUDPOS_WEAPON + HUDPOS_NUMBERSPACING + offset)*2, 826*2);
|
||||
glLoadIdentity();
|
||||
}
|
||||
}
|
||||
@@ -1187,7 +1187,7 @@ void grenades::renderstats()
|
||||
{
|
||||
char gunstats[64];
|
||||
sprintf(gunstats, "%i", mag);
|
||||
draw_text(gunstats, 830, 823);
|
||||
draw_text(gunstats, oldfashionedgunstats ? HUDPOS_GRENADE + HUDPOS_NUMBERSPACING + 25 : HUDPOS_GRENADE + HUDPOS_NUMBERSPACING, 823);
|
||||
}
|
||||
|
||||
bool grenades::selectable() { return weapon::selectable() && state != GST_INHAND && mag; }
|
||||
|
||||
Reference in New Issue
Block a user