From 5e6e01e66378261a075bbc9730c9287874b8c3bd Mon Sep 17 00:00:00 2001 From: xolatile Date: Wed, 30 Jul 2025 12:56:45 +0200 Subject: HUD, GUI, maps, textures, scripts... --- src/fpsgame/fps.cpp | 493 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 309 insertions(+), 184 deletions(-) (limited to 'src/fpsgame/fps.cpp') diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index fceb94a..37777cb 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -872,13 +872,6 @@ namespace game pophudmatrix(); } - VARP(speedometer, 0, 1, 1); - FVARP(speedometerx, 0.0, 0.5, 1.0); - FVARP(speedometery, 0.0, 0.6, 1.0); - FVARP(speedometerscale, 0.1, 0.5, 2.0); - VARP(speedometercolor, 0, 1, 1); - FVARP(speedometeralpha, 0.0, 0.5, 1.0); - //~void drawspeedometer(fpsent *d, int w, int h) { //~int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + 1.0f); //~speedforreal = (speedforreal == 1) ? 0 : speedforreal; @@ -909,43 +902,155 @@ namespace game //~pophudmatrix(); //~} + void hudquad(float x, float y, float w, float h, float r = 1, float g = 1, float b = 1, float tx = 0, float ty = 0, float tw = 1, float th = 1) + { + gle::defvertex(2); + gle::deftexcoord0(); + gle::colorf(r, g, b); + gle::begin(GL_TRIANGLE_STRIP); + //~gle::begin(GL_QUADS); + gle::attribf(x, y); gle::attribf(tx, ty); + gle::attribf(x+w, y); gle::attribf(tx + tw, ty); + gle::attribf(x, y+h); gle::attribf(tx, ty + th); + gle::attribf(x+w, y+h); gle::attribf(tx + tw, ty + th); + gle::end(); + } + VARP(healthcolors, 0, 1, 1); - void drawhudicons(fpsent *d) + VARP(hudhealth, 0, 1, 1); + FVARP(hudhealthx, 0, 0, 1); + FVARP(hudhealthy, 0, 1, 1); + FVARP(hudhealthscale, 0.1, 1.0, 1.0); + + void drawhudhealth(fpsent *d, int w, int h) { pushhudmatrix(); - hudmatrix.scale(2, 2, 1); + hudmatrix.scale(hudhealthscale, hudhealthscale, 1); flushhudmatrix(); - defformatstring(health, "%d", d->state==CS_DEAD ? 0 : d->health); - bvec healthcolor = bvec::hexcolor(healthcolors && !m_insta ? (d->state==CS_DEAD ? 0x808080 : (d->health<=25 ? 0xFF0000 : (d->health<=50 ? 0xFF8000 : (d->health<=100 ? 0xFFFFFF : 0x40C0FF)))) : 0xFFFFFF); - draw_text(health, (HICON_X + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, healthcolor.r, healthcolor.g, healthcolor.b); - if(d->state!=CS_DEAD) - { - if(d->armour) draw_textf("%d", (HICON_X + HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->armour); - draw_textf("%d", (HICON_X + 2*HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->ammo[d->gunselect]); + + bvec healthcolor = bvec::hexcolor(healthcolors && !m_insta ? + (d->state==CS_DEAD ? 0x808080 : + (d->health<=25 ? 0xc02020 : + (d->health<=50 ? 0xc08020 : + (d->health<=75 ? 0xc0c040 : + (d->health<=100 ? 0xFFFFFF : 0x4080c0))))) : 0xFFFFFF); + const float proportion = (w/4.0f)/600.0f; + const float healthbarw = 600*proportion; + const float healthbarh = 113*proportion; + vec2 offset = vec2(hudhealthx, hudhealthy).mul(vec2(w-healthbarw, h-healthbarh).div(hudhealthscale)); + settexture("packages/hud/health_bar_base.png"); + float hp = (float)d->health/d->maxhealth; + hudquad(offset.x, offset.y, hp*healthbarw, healthbarh, healthcolor.r, healthcolor.g, healthcolor.b, 0, 0, hp, 1); + settexture("packages/hud/health_bar_over.png"); + hudquad(offset.x, offset.y, healthbarw, healthbarh); + if (d->quadmillis) { + settexture("packages/hud/health_bar_quad.png"); + hudquad(offset.x, offset.y, healthbarw, healthbarh); } + defformatstring(health, "%d", d->state==CS_DEAD ? 0 : d->health); + float tw=0, th=0; text_boundsf(health, tw, th); + draw_text(health, offset.x+(125*proportion-tw)/2, offset.y+(healthbarh-th)/2, healthcolor.r, healthcolor.g, healthcolor.b); + pophudmatrix(); + } - if(d->state != CS_DEAD && d->maxhealth > 100) - { - float scale = 0.66f; - pushhudmatrix(); - hudmatrix.scale(scale, scale, 1); - flushhudmatrix(); + VARP(hudmaxhealth, 0, 1, 1); + FVARP(hudmaxhealthx, 0, 0.207, 1); + FVARP(hudmaxhealthy, 0, 0.97, 1); + FVARP(hudmaxhealthscale, 0.1, 1.0, 1.0); - float width, height; - text_boundsf(health, width, height); - draw_textf("/%d", (HICON_X + HICON_SIZE + HICON_SPACE + width*2)/scale, (HICON_TEXTY + height)/scale, d->maxhealth); + void drawhudmaxhealth(fpsent *d, int w, int h) + { + pushhudmatrix(); + hudmatrix.scale(hudmaxhealthscale, hudmaxhealthscale, 1); + flushhudmatrix(); - pophudmatrix(); + const float proportion = (w/15.0f)/160.0f; + const float healthboostw = 160*proportion; + const float healthboosth = 78*proportion; + float hb = (float)d->maxhealth/100.0f-1.0f; + vec2 offset = vec2(hudmaxhealthx, hudmaxhealthy).mul(vec2(w-healthboostw, h-healthboosth).div(hudhealthscale)); + settexture("packages/hud/health_boost_base.png"); + hudquad(offset.x, offset.y, hb*healthboostw, healthboosth, 0.3f, 0.6f, 0.9f, 0, 0, hb, 1); + settexture("packages/hud/health_boost_over.png"); + hudquad(offset.x, offset.y, healthboostw, healthboosth); + if (d->quadmillis) { + settexture("packages/hud/health_boost_quad.png"); + hudquad(offset.x, offset.y, healthboostw, healthboosth); } - drawicon(HICON_HEALTH, HICON_X, HICON_Y); - if(d->state!=CS_DEAD) - { - if(d->armour) drawicon(HICON_BLUE_ARMOUR+d->armourtype, HICON_X + HICON_STEP, HICON_Y); + pophudmatrix(); + } + + VARP(armourcolors, 0, 1, 1); + + VARP(hudarmour, 0, 1, 1); + FVARP(hudarmourx, 0, 1, 1); + FVARP(hudarmoury, 0, 1, 1); + FVARP(hudarmourscale, 0.1, 1.0, 1.0); + + void drawhudarmour(fpsent *d, int w, int h) + { + pushhudmatrix(); + hudmatrix.scale(hudarmourscale, hudarmourscale, 1); + flushhudmatrix(); + + bvec armourcolor = bvec::hexcolor(d->armourtype == A_BLUE ? 0x83ade5 : (d->armourtype == A_GREEN ? 0x77f29e : (d->armourtype == A_YELLOW ? 0xf5f19b : 0xffffff))); + const float proportion = (w/4.0f)/600.0f; + const float armourbarw = 600*proportion; + const float armourbarh = 113*proportion; + vec2 offset = vec2(hudarmourx, hudarmoury).mul(vec2(w-armourbarw, h-armourbarh).div(hudarmourscale)); + settexture("packages/hud/armour_bar_base.png"); + float ap = (float)d->armour/d->maxarmour; + hudquad(offset.x, offset.y, ap*armourbarw, armourbarh, armourcolor.r, armourcolor.g, armourcolor.b, 0, 0, ap, 1); + settexture("packages/hud/armour_bar_over.png"); + hudquad(offset.x, offset.y, armourbarw, armourbarh); + if (d->quadmillis) { + settexture("packages/hud/armour_bar_quad.png"); + hudquad(offset.x, offset.y, armourbarw, armourbarh); + } + defformatstring(armour, "%d", d->state==CS_DEAD ? 0 : d->armour); + float tw=0, th=0; text_boundsf(armour, tw, th); + draw_text(armour, offset.x+(2*(600-63)*proportion-tw)/2, offset.y+(armourbarh-th)/2, armourcolor.r, armourcolor.g, armourcolor.b); + + pophudmatrix(); + } + + void drawhudicons(fpsent *d, int w, int h) + { + //~defformatstring(health, "%d", d->state==CS_DEAD ? 0 : d->health); + //~bvec healthcolor = bvec::hexcolor(healthcolors && !m_insta ? (d->state==CS_DEAD ? 0x808080 : (d->health<=25 ? 0xFF0000 : (d->health<=50 ? 0xFF8000 : (d->health<=100 ? 0xFFFFFF : 0x40C0FF)))) : 0xFFFFFF); + //~draw_text(health, (HICON_X + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, healthcolor.r, healthcolor.g, healthcolor.b); + //~if(d->state!=CS_DEAD) + //~{ + //~if(d->armour) draw_textf("%d", (HICON_X + HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->armour); + //~draw_textf("%d", (HICON_X + 2*HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->ammo[d->gunselect]); + //~} + + //~if(d->state != CS_DEAD && d->maxhealth > 100) + //~{ + //~float scale = 0.66f; + //~pushhudmatrix(); + //~hudmatrix.scale(scale, scale, 1); + //~flushhudmatrix(); + + //~float width, height; + //~text_boundsf(health, width, height); + //~draw_textf("/%d", (HICON_X + HICON_SIZE + HICON_SPACE + width*2)/scale, (HICON_TEXTY + height)/scale, d->maxhealth); + + //~pophudmatrix(); + //~} + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + if(hudhealth) drawhudhealth(d, w, h); + if(hudmaxhealth) drawhudmaxhealth(d, w, h); + if(hudarmour) drawhudarmour(d, w, h); + + if(d->state!=CS_DEAD) { drawicon(HICON_FIST+d->gunselect, HICON_X + 2*HICON_STEP, HICON_Y); - if(d->quadmillis) drawicon(HICON_QUAD, HICON_X + 3*HICON_STEP, HICON_Y); if(ammohud) drawammohud(d); } } @@ -1068,32 +1173,75 @@ namespace game pophudmatrix(); } - void newhud(int w, int h) //new SauerEnhanced HUD + VARP(speedometer, 0, 1, 1); + FVARP(speedometerx, 0.0, 0.5, 1.0); + FVARP(speedometery, 0.0, 0.6, 1.0); + FVARP(speedometerscale, 0.1, 0.5, 1.0); + VARP(speedometercolor, 0, 1, 1); + FVARP(speedometeralpha, 0.0, 0.5, 1.0); + + void drawspeedometer(fpsent *d, int w, int h) { - if(player1->state==CS_DEAD || player1->state==CS_SPECTATOR) return; + int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + 1.0f); + speedforreal = (speedforreal == 1) ? 0 : speedforreal; + vec colour = vec(255, 255, 255); + float realw = 0; + float realh = 0; + if (speedometercolor) { + if (speedforreal==0) colour = vec(60, 60, 60); + else if (speedforreal>0 && speedforreal<=60) colour = vec(240, 30, 30); + else if (speedforreal>60 && speedforreal<=120) colour = vec(180, 90, 60); + else if (speedforreal>120 && speedforreal<=180) colour = vec(180, 180, 30); + else if (speedforreal>180 && speedforreal<=240) colour = vec(90, 180, 60); + else colour = vec(30, 240, 30); + } + + defformatstring(speedstring, "%d", speedforreal); + text_boundsf(speedstring, realw, realh); + vec2 offset = vec2(speedometerx, speedometery).mul(vec2(w, h).div(speedometerscale)); + offset.x -= realw/2.0f; + offset.y -= realh/2.0f; + + pushhudmatrix(); + hudmatrix.scale(speedometerscale, speedometerscale, 1); + flushhudmatrix(); + + const int speedow = 220; + const int speedoh = 101; + settexture("packages/hud/speedometer.png"); + hudquad(offset.x+realw/2.0f-speedow/2, offset.y+realh/2.0f-speedoh/2, speedow, speedoh); + + draw_text(speedstring, int(offset.x), int(offset.y), colour.x, colour.y, colour.z, (int)(speedometeralpha*255.0f)); + + pophudmatrix(); + } + + //~void newhud(int w, int h) //new SauerEnhanced HUD + //~{ + //~if(player1->state==CS_DEAD || player1->state==CS_SPECTATOR) return; //~glPushMatrix(); //~glScalef(1/1.2f, 1/1.2f, 1); - pushhudmatrix(); + //~pushhudmatrix(); //~hudmatrix.scale(w/1800.0f, h/1650.0f, 1); - hudmatrix.scale(1.0f/1.2f, 1.0f/1.2f, 1); - flushhudmatrix(); - if(!m_insta) draw_textf("%d", 80, h*1.2f-128, player1->state==CS_DEAD ? 0 : player1->health); - defformatstring(ammo, "%d", player1->ammo[player1->gunselect]); - int wb, hb; - text_bounds(ammo, wb, hb); - draw_textf("%d", w*1.2f-wb-80, h*1.2f-128, player1->ammo[player1->gunselect]); + //~hudmatrix.scale(1.0f/1.2f, 1.0f/1.2f, 1); + //~flushhudmatrix(); + //~if(!m_insta) draw_textf("%d", 80, h*1.2f-128, player1->state==CS_DEAD ? 0 : player1->health); + //~defformatstring(ammo, "%d", player1->ammo[player1->gunselect]); + //~int wb, hb; + //~text_bounds(ammo, wb, hb); + //~draw_textf("%d", w*1.2f-wb-80, h*1.2f-128, player1->ammo[player1->gunselect]); //~hudmatrix.ortho(0, w, h, 0, -1, 1); //~resethudmatrix(); //~hudshader->set(); - gle::colorf(1, 1, 1); + //~gle::colorf(1, 1, 1); - gle::defvertex(2); - gle::deftexcoord0(); + //~gle::defvertex(2); + //~gle::deftexcoord0(); - if(player1->quadmillis) - { + //~if(player1->quadmillis) + //~{ //~gle::begin(GL_QUADS); //~loopj(numdecals) //~{ @@ -1104,132 +1252,138 @@ namespace game //~gle::attribf(hx-hsz, hy+hsz); gle::attribf(side, 1); //~} //~gle::end(); - settexture("packages/hud/hud_quaddamage_left.png"); //QuadDamage left glow - gle::begin(GL_QUADS); - gle::attribf(0, h*1.2f-207); gle::attribf(0.0f, 0.0f); - gle::attribf(539, h*1.2f-207); gle::attribf(1.0f, 0.0f); - gle::attribf(539, h*1.2f); gle::attribf(1.0f, 1.0f); - gle::attribf(0, h*1.2f); gle::attribf(0.0f, 1.0f); - gle::end(); - - settexture("packages/hud/hud_quaddamage_right.png"); //QuadDamage right glow - gle::begin(GL_QUADS); - gle::attribf(w*1.2f-135, h*1.2f-207); gle::attribf(0.0f, 0.0f); - gle::attribf(w*1.2f, h*1.2f-207); gle::attribf(1.0f, 0.0f); - gle::attribf(w*1.2f, h*1.2f); gle::attribf(1.0f, 1.0f); - gle::attribf(w*1.2f-135, h*1.2f); gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~settexture("packages/hud/hud_quaddamage_left.png"); //QuadDamage left glow + //~gle::begin(GL_QUADS); + //~gle::attribf(0, h*1.2f-207); gle::attribf(0.0f, 0.0f); + //~gle::attribf(539, h*1.2f-207); gle::attribf(1.0f, 0.0f); + //~gle::attribf(539, h*1.2f); gle::attribf(1.0f, 1.0f); + //~gle::attribf(0, h*1.2f); gle::attribf(0.0f, 1.0f); + //~gle::end(); - if(player1->maxhealth > 100) - { - settexture("packages/hud/hud_megahealth.png"); //HealthBoost indicator - gle::begin(GL_QUADS); - gle::attribf(0, h*1.2f-207); gle::attribf(0.0f, 0.0f); - gle::attribf(539, h*1.2f-207); gle::attribf(1.0f, 0.0f); - gle::attribf(539, h*1.2f); gle::attribf(1.0f, 1.0f); - gle::attribf(0, h*1.2f); gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~settexture("packages/hud/hud_quaddamage_right.png"); //QuadDamage right glow + //~gle::begin(GL_QUADS); + //~gle::attribf(w*1.2f-135, h*1.2f-207); gle::attribf(0.0f, 0.0f); + //~gle::attribf(w*1.2f, h*1.2f-207); gle::attribf(1.0f, 0.0f); + //~gle::attribf(w*1.2f, h*1.2f); gle::attribf(1.0f, 1.0f); + //~gle::attribf(w*1.2f-135, h*1.2f); gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} - int health = (player1->health*100)/player1->maxhealth, - armour = (player1->armour*100)/200, - hh = (health*101)/100, - ah = (armour*167)/100; + //~if(player1->maxhealth > 100) + //~{ + //~settexture("packages/hud/hud_megahealth.png"); //HealthBoost indicator + //~gle::begin(GL_QUADS); + //~gle::attribf(0, h*1.2f-207); gle::attribf(0.0f, 0.0f); + //~gle::attribf(539, h*1.2f-207); gle::attribf(1.0f, 0.0f); + //~gle::attribf(539, h*1.2f); gle::attribf(1.0f, 1.0f); + //~gle::attribf(0, h*1.2f); gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} - float hs = (health*1.0f)/100, - as = (armour*1.0f)/100; + //~gle::begin(GL_QUADS); + //~gle::attribf(w/2-speedow/2, h/2-speedoh/2); gle::attribf(0.0f, 1.0f); + //~gle::attribf(w/2, h/2-speedoh/2); gle::attribf(1.0f, 1.0f); + //~gle::attribf(w/2, h/2); gle::attribf(1.0f, 1.0f); + //~gle::attribf(w/2-speedow/2, h/2); gle::attribf(0.0f, 1.0f); + //~gle::end(); - if(player1->health > 0 && !m_insta) - { - settexture("packages/hud/hud_health.png"); //Health bar - gle::begin(GL_QUADS); - gle::attribf(47, h*1.2f-hh-56); gle::attribf(0.0f, 1.0f-hs); - gle::attribf(97, h*1.2f-hh-56); gle::attribf(1.0f, 1.0f-hs); - gle::attribf(97, h*1.2f-57); gle::attribf(1.0f, 1.0f); - gle::attribf(47, h*1.2f-57); gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~int health = (player1->health*100)/player1->maxhealth, + //~armour = (player1->armour*100)/200, + //~hh = (health*101)/100; - if(player1->armour > 0) - { - settexture("packages/hud/hud_armour.png"); //Armour bar - gle::begin(GL_QUADS); - gle::attribf(130, h*1.2f-62);gle::attribf(0.0f, 0.0f); - gle::attribf(130+ah, h*1.2f-62);gle::attribf(as, 0.0f); - gle::attribf(130+ah, h*1.2f-44);gle::attribf(as, 1.0f); - gle::attribf(130, h*1.2f-44);gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~float hs = (health*1.0f)/100; - if(!m_insta) - { - settexture("packages/hud/hud_left.png"); //left HUD - gle::begin(GL_QUADS); - gle::attribf(0, h*1.2f-207);gle::attribf(0.0f, 0.0f); - gle::attribf(539, h*1.2f-207);gle::attribf(1.0f, 0.0f); - gle::attribf(539, h*1.2f );gle::attribf(1.0f, 1.0f); - gle::attribf(0, h*1.2f );gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~if(player1->health > 0 && !m_insta) + //~{ + //~settexture("packages/hud/hud_health.png"); //Health bar + //~hudquad(4000, 600, 97, 56); + //~gle::begin(GL_QUADS); + //~gle::attribf(47, h*1.2f-hh-56); gle::attribf(0.0f, 1.0f-hs); + //~gle::attribf(97, h*1.2f-hh-56); gle::attribf(1.0f, 1.0f-hs); + //~gle::attribf(97, h*1.2f-57); gle::attribf(1.0f, 1.0f); + //~gle::attribf(47, h*1.2f-57); gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} - settexture("packages/hud/hud_right.png"); //right HUD - gle::begin(GL_QUADS); - gle::attribf(w*1.2f-135, h*1.2f-207);gle::attribf(0.0f, 0.0f); - gle::attribf(w*1.2f, h*1.2f-207);gle::attribf(1.0f, 0.0f); - gle::attribf(w*1.2f, h*1.2f );gle::attribf(1.0f, 1.0f); - gle::attribf(w*1.2f-135, h*1.2f );gle::attribf(0.0f, 1.0f); - gle::end(); + //~if(player1->armour > 0) + //~{ + //~settexture("packages/hud/hud_armour.png"); //Armour bar + //~gle::begin(GL_QUADS); + //~gle::attribf(130, h*1.2f-62);gle::attribf(0.0f, 0.0f); + //~gle::attribf(130+ah, h*1.2f-62);gle::attribf(as, 0.0f); + //~gle::attribf(130+ah, h*1.2f-44);gle::attribf(as, 1.0f); + //~gle::attribf(130, h*1.2f-44);gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} - int maxammo = 0; + //~if(!m_insta) + //~{ + //~settexture("packages/hud/hud_left.png"); //left HUD + //~gle::begin(GL_QUADS); + //~gle::attribf(0, h*1.2f-207);gle::attribf(0.0f, 0.0f); + //~gle::attribf(539, h*1.2f-207);gle::attribf(1.0f, 0.0f); + //~gle::attribf(539, h*1.2f );gle::attribf(1.0f, 1.0f); + //~gle::attribf(0, h*1.2f );gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} - switch(player1->gunselect) - { - case GUN_FIST: - maxammo = 1; - break; + //~settexture("packages/hud/hud_right.png"); //right HUD + //~gle::begin(GL_QUADS); + //~gle::attribf(w*1.2f-135, h*1.2f-207);gle::attribf(0.0f, 0.0f); + //~gle::attribf(w*1.2f, h*1.2f-207);gle::attribf(1.0f, 0.0f); + //~gle::attribf(w*1.2f, h*1.2f );gle::attribf(1.0f, 1.0f); + //~gle::attribf(w*1.2f-135, h*1.2f );gle::attribf(0.0f, 1.0f); + //~gle::end(); - case GUN_RL: - case GUN_RIFLE: - maxammo = m_insta ? 100 : 15; - break; + //~int maxammo = 0; - case GUN_SG: - case GUN_GL: - maxammo = 30; - break; + //~switch(player1->gunselect) + //~{ + //~case GUN_FIST: + //~maxammo = 1; + //~break; - case GUN_CG: - maxammo = 60; - break; + //~case GUN_RL: + //~case GUN_RIFLE: + //~maxammo = m_insta ? 100 : 15; + //~break; - case GUN_PISTOL: - maxammo = 120; - break; - } + //~case GUN_SG: + //~case GUN_GL: + //~maxammo = 30; + //~break; - int curammo = (player1->ammo[player1->gunselect]*100)/maxammo, - amh = (curammo*101)/100; + //~case GUN_CG: + //~maxammo = 60; + //~break; - float ams = (curammo*1.0f)/100; + //~case GUN_PISTOL: + //~maxammo = 120; + //~break; + //~} - if(player1->ammo[player1->gunselect] > 0) - { - settexture("packages/hud/hud_health.png"); //Ammo bar - gle::begin(GL_QUADS); - gle::attribf(w*1.2f-47, h*1.2f-amh-56);gle::attribf(0.0f, 1.0f-ams); - gle::attribf(w*1.2f-97, h*1.2f-amh-56);gle::attribf(1.0f, 1.0f-ams); - gle::attribf(w*1.2f-97, h*1.2f-57 );gle::attribf(1.0f, 1.0f); - gle::attribf(w*1.2f-47, h*1.2f-57 );gle::attribf(0.0f, 1.0f); - gle::end(); - } + //~int curammo = (player1->ammo[player1->gunselect]*100)/maxammo, + //~amh = (curammo*101)/100; + + //~float ams = (curammo*1.0f)/100; + + //~if(player1->ammo[player1->gunselect] > 0) + //~{ + //~settexture("packages/hud/hud_health.png"); //Ammo bar + //~gle::begin(GL_QUADS); + //~gle::attribf(w*1.2f-47, h*1.2f-amh-56);gle::attribf(0.0f, 1.0f-ams); + //~gle::attribf(w*1.2f-97, h*1.2f-amh-56);gle::attribf(1.0f, 1.0f-ams); + //~gle::attribf(w*1.2f-97, h*1.2f-57 );gle::attribf(1.0f, 1.0f); + //~gle::attribf(w*1.2f-47, h*1.2f-57 );gle::attribf(0.0f, 1.0f); + //~gle::end(); + //~} //~glPopMatrix(); - pophudmatrix(); - } + //~pophudmatrix(); + //~} void gameplayhud(int w, int h) { - newhud(w, h); + //~newhud(w, h); pushhudmatrix(); hudmatrix.scale(h/1800.0f, h/1800.0f, 1); @@ -1255,15 +1409,17 @@ namespace game fpsent *d = hudplayer(); if(d->state!=CS_EDITING) { - if(d->state!=CS_SPECTATOR) drawhudicons(d); if(cmode) cmode->drawhud(d, w, h); } pophudmatrix(); + if(d->state!=CS_EDITING && d->state!=CS_SPECTATOR) drawhudicons(d, w, h); + if(d->state!=CS_EDITING && d->state!=CS_SPECTATOR && d->state!=CS_DEAD) { if(ammobar) drawammobar(w, h, d); + if(speedometer) drawspeedometer(d, w, h); } @@ -1271,39 +1427,8 @@ namespace game { if(gameclock) drawgameclock(w, h); if(hudscore) drawhudscore(w, h); - //~if(speedometer) drawspeedometer(d, w, h); - } - - /// Speedometer. - - int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + 1.0f); - speedforreal = (speedforreal == 1) ? 0 : speedforreal; - vec colour = vec(255, 255, 255); - float realw = 0; - float realh = 0; - if (speedometercolor) { - if (speedforreal==0) colour = vec(60, 60, 60); - else if (speedforreal>0 && speedforreal<=60) colour = vec(240, 30, 30); - else if (speedforreal>60 && speedforreal<=120) colour = vec(180, 90, 60); - else if (speedforreal>120 && speedforreal<=180) colour = vec(180, 180, 30); - else if (speedforreal>180 && speedforreal<=240) colour = vec(90, 180, 60); - else colour = vec(30, 240, 30); } - defformatstring(speedstring, "%d", speedforreal); - text_boundsf(speedstring, realw, realh); - vec2 offset = vec2(speedometerx, speedometery).mul(vec2(w, h).div(speedometerscale)); - offset.x -= realw/2.0f; - offset.y -= realh/2.0f; - - pushhudmatrix(); - hudmatrix.scale(speedometerscale, speedometerscale, 1); - flushhudmatrix(); - - draw_text(speedstring, int(offset.x), int(offset.y), colour.x, colour.y, colour.z, (int)(speedometeralpha*255.0f)); - - pophudmatrix(); - /// Frag message. if((hudfragmillis+fragmessageduration > lastmillis) && (lastmillis>fragmessageduration)) -- cgit v1.2.3