health and ammo HUD scaling

- Scale HUD with a modified version of @Toodles2You 's triapi HUD scaling
- Add commands for position, scale, and minimum alpha of heath and ammo
- Fixes sprite blurring
- Fixed nearby pixels bleeding in to the drawn sprites
- Fixed the health cross art being cut off at the edges
This commit is contained in:
pierow 2024-04-29 17:58:32 -04:00
parent f39297efcb
commit c5153c4ab1
14 changed files with 918 additions and 153 deletions

View file

@ -589,6 +589,10 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection )
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int giBucketHeight, giBucketWidth, giABHeight, giABWidth; // Ammo Bar width and height
cvar_t* hud_ammo_x;
cvar_t* hud_ammo_y;
cvar_t* hud_ammo_scale;
cvar_t* hud_ammo_alphamin;
AVHHSPRITE ghsprBuckets; // Sprite for top row of weapons menu
@ -651,6 +655,11 @@ int CHudAmmo::Init(void)
CVAR_CREATE( "hud_drawhistory_time", HISTORY_DRAW_TIME, 0 );
CVAR_CREATE( "hud_fastswitch", "0", FCVAR_ARCHIVE ); // controls whether or not weapons can be selected in one keypress
hud_ammo_x = CVAR_CREATE("hud_ammo_x", "0", FCVAR_ARCHIVE);
hud_ammo_y = CVAR_CREATE("hud_ammo_y", "0", FCVAR_ARCHIVE);
hud_ammo_scale = CVAR_CREATE("hud_ammo_scale", "1", FCVAR_ARCHIVE);
hud_ammo_alphamin = CVAR_CREATE("hud_ammo_alphamin", "128", FCVAR_ARCHIVE);
m_iFlags |= HUD_ACTIVE; //!!!
gWR.Init();
@ -1161,6 +1170,125 @@ void CHudAmmo::SetCurrentClip(int inClip)
}
}
//// Old HUD drawing
//int CHudAmmo::Draw(float flTime)
//{
// int a, x, y, r, g, b;
// int AmmoWidth;
//
// if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
// return 1;
//
// if (/*!gHUD.GetIsAlive() ||*/ (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
// return 1;
//
// // Draw Weapon Menu
// DrawWList(flTime);
//
// // Draw ammo pickup history
// gHR.DrawAmmoHistory( flTime );
//
// if (!(m_iFlags & HUD_ACTIVE))
// return 0;
//
// if (!m_pWeapon)
// return 0;
//
// WEAPON *pw = m_pWeapon; // shorthand
//
// // SPR_Draw Ammo
// if ((pw->iAmmoType < 0) && (pw->iAmmo2Type < 0))
// return 0;
//
//
// int iFlags = DHN_DRAWZERO; // draw 0 values
//
// AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
//
// a = (int) max( MIN_ALPHA, m_fFade );
//
// if (m_fFade > 0)
// m_fFade -= (gHUD.m_flTimeDelta * 20);
//
// gHUD.GetPrimaryHudColor(r, g, b);
//
// ScaleColors(r, g, b, a );
//
// int theViewport[4];
// gHUD.GetViewport(theViewport);
//
// // Does this weapon have a clip?
// y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
//
// // Does weapon have any ammo at all?
// if (m_pWeapon->iAmmoType > 0)
// {
// int iIconWidth = m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left;
//
// if (pw->iClip >= 0)
// {
// // room for the number and the '|' and the current ammo
//
// x = theViewport[0] + theViewport[2] - (8 * AmmoWidth) - iIconWidth;
// x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b);
//
// wrect_t rc;
// rc.top = 0;
// rc.left = 0;
// rc.right = AmmoWidth;
// rc.bottom = 100;
//
// int iBarWidth = AmmoWidth/10;
//
// x += AmmoWidth/2;
//
// gHUD.GetPrimaryHudColor(r, g, b);
//
// // draw the | bar
// FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a);
//
// x += iBarWidth + AmmoWidth/2;;
//
// // GL Seems to need this
// ScaleColors(r, g, b, a );
// x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
//
//
// }
// else
// {
// // SPR_Draw a bullets only line
// x = theViewport[0] + theViewport[2] - 4 * AmmoWidth - iIconWidth;
// x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
// }
//
// // Draw the ammo Icon
// int iOffset = (m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top)/8;
// SPR_Set(m_pWeapon->hAmmo, r, g, b);
// SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo);
// }
//
// // Does weapon have seconday ammo?
// if (pw->iAmmo2Type > 0)
// {
// int iIconWidth = m_pWeapon->rcAmmo2.right - m_pWeapon->rcAmmo2.left;
//
// // Do we have secondary ammo?
// if ((pw->iAmmo2Type != 0) && (gWR.CountAmmo(pw->iAmmo2Type) > 0))
// {
// y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight/4;
// x = theViewport[0] + theViewport[2] - 4 * AmmoWidth - iIconWidth;
// x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, gWR.CountAmmo(pw->iAmmo2Type), r, g, b);
//
// // Draw the ammo Icon
// SPR_Set(m_pWeapon->hAmmo2, r, g, b);
// int iOffset = (m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top)/8;
// SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo2);
// }
// }
// return 1;
//}
//-------------------------------------------------------------------------
// Drawing code
//-------------------------------------------------------------------------
@ -1197,9 +1325,21 @@ int CHudAmmo::Draw(float flTime)
int iFlags = DHN_DRAWZERO; // draw 0 values
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
float ammoScale = 1.0f;
if (hud_ammo_scale)
{
ammoScale = min(max(0.01f, hud_ammo_scale->value), 5.0f);
}
a = (int) max( MIN_ALPHA, m_fFade );
AmmoWidth = (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left) * ammoScale;
int minAlpha;
if (hud_ammo_alphamin)
minAlpha = max(0, min(hud_ammo_alphamin->value, 255));
else
minAlpha = MIN_ALPHA;
a = (int)max(minAlpha, m_fFade);
if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20);
@ -1208,58 +1348,60 @@ int CHudAmmo::Draw(float flTime)
ScaleColors(r, g, b, a );
int theViewport[4];
gHUD.GetViewport(theViewport);
// Does this weapon have a clip?
y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
int initialY = gHUD.GetHeight();
if (hud_ammo_y && hud_ammo_y->value != 0.0f)
{
initialY *= min(max(0.0f, hud_ammo_y->value), 1.0f);
}
y = initialY - gHUD.m_iFontHeight / 2;
// Does weapon have any ammo at all?
if (m_pWeapon->iAmmoType > 0)
{
int iIconWidth = m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left;
int iIconWidth = (m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left) * ammoScale;
if (pw->iClip >= 0)
{
// room for the number and the '|' and the current ammo
x = theViewport[0] + theViewport[2] - (8 * AmmoWidth) - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b);
int initialX = gHUD.GetWidth();
if (hud_ammo_x && hud_ammo_x->value != 0.0f)
{
initialX *= min(max(0.0f, hud_ammo_x->value), 1.0f);
}
wrect_t rc;
rc.top = 0;
rc.left = 0;
rc.right = AmmoWidth;
rc.bottom = 100;
x = initialX - (8 * AmmoWidth) - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b, 255, ammoScale, CHud::a_southwest);
int iBarWidth = AmmoWidth/10;
int iBarHeight = gHUD.m_iFontHeight * -1;
x += AmmoWidth/2;
gHUD.GetPrimaryHudColor(r, g, b);
// draw the | bar
FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a);
gHUD.DrawHudFill(x, y, iBarWidth, iBarHeight, r, g, b, a, ammoScale);
x += iBarWidth + AmmoWidth/2;;
x += iBarWidth + AmmoWidth/2;
// GL Seems to need this
ScaleColors(r, g, b, a );
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b, 255, ammoScale, CHud::a_southwest);
}
else
{
// SPR_Draw a bullets only line
x = theViewport[0] + theViewport[2] - 4 * AmmoWidth - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
x = gHUD.GetWidth() - 4 * AmmoWidth - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b, 255, ammoScale, CHud::a_southwest);
}
// Draw the ammo Icon
int iOffset = (m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top)/8;
SPR_Set(m_pWeapon->hAmmo, r, g, b);
SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo);
gHUD.DrawHudSprite(m_pWeapon->hAmmo, 0, &m_pWeapon->rcAmmo, x, y, r, g, b, 255, ammoScale, CHud::a_southwest);
}
// Does weapon have seconday ammo?
@ -1271,13 +1413,11 @@ int CHudAmmo::Draw(float flTime)
if ((pw->iAmmo2Type != 0) && (gWR.CountAmmo(pw->iAmmo2Type) > 0))
{
y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight/4;
x = theViewport[0] + theViewport[2] - 4 * AmmoWidth - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, gWR.CountAmmo(pw->iAmmo2Type), r, g, b);
x = gHUD.GetWidth() - 4 * AmmoWidth - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, gWR.CountAmmo(pw->iAmmo2Type), r, g, b, 255, ammoScale, CHud::a_southwest);
// Draw the ammo Icon
SPR_Set(m_pWeapon->hAmmo2, r, g, b);
int iOffset = (m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top)/8;
SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo2);
gHUD.DrawHudSprite(m_pWeapon->hAmmo2, 0, &m_pWeapon->rcAmmo2, x, y, r, b, g, 255, ammoScale, CHud::a_southwest);
}
}
return 1;

View file

@ -70,8 +70,9 @@ int CHudAmmoSecondary :: Draw(float flTime)
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
//SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
//SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
gHUD.DrawHudSpriteIndex(m_HUD_ammoicon, x, y, r , g, b);
}
else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
@ -96,7 +97,8 @@ int CHudAmmoSecondary :: Draw(float flTime)
{
// draw the divider bar
x -= (AmmoWidth / 2);
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
//FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
gHUD.DrawHudFill(x, y, (AmmoWidth / 10), gHUD.m_iFontHeight, r, g ,b , MIN_ALPHA);
}
}

View file

@ -95,7 +95,7 @@ int CHudBattery::Draw(float flTime)
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return 1;
// Has health changed? Flash the health #
if (m_fFade)
{
@ -105,23 +105,23 @@ int CHudBattery::Draw(float flTime)
m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
a = 128;
//a = 128;
m_fFade = 0;
}
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
a = gHUD.m_Health.m_iMinAlpha + (m_fFade/FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
a = gHUD.m_Health.m_iMinAlpha;
ScaleColors(r, g, b, a );
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
//int iOffset = (m_prc1->bottom - m_prc1->top)/6;
int theInset = 0;
//int theInset = 0;
//if(gHUD.GetIsAlien())
//{
// theInset = ScreenWidth()*kResourceEnergyBarWidth;
@ -130,8 +130,11 @@ int CHudBattery::Draw(float flTime)
int theViewport[4];
gHUD.GetViewport(theViewport);
y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = theViewport[0] + theInset + kArmorLeftInset*ScreenWidth();
//y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
//x = theViewport[0] + theInset + kArmorLeftInset*ScreenWidth();
//y = m_iAnchorY - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
y = m_iAnchorY - gHUD.m_iFontHeight / 2;
x = m_iAnchorX;
// make sure we have the right sprite handles
if ( !m_hSprite1 )
@ -139,18 +142,101 @@ int CHudBattery::Draw(float flTime)
if ( !m_hSprite2 )
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
SPR_Set(m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
//SPR_Set(m_hSprite1, r, g, b );
//SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
gHUD.DrawHudSprite(m_hSprite1, 0, m_prc1, x, y, r, g, b, a, gHUD.m_Health.m_fHealthScale, CHud::a_southwest);
if (rc.bottom > rc.top)
{
SPR_Set(m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
//SPR_Set(m_hSprite2, r, g, b );
//SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
gHUD.DrawHudSprite(m_hSprite2, 0, &rc, x, y, r, g, b, a, gHUD.m_Health.m_fHealthScale, CHud::a_southwest);
}
x += (m_prc1->right - m_prc1->left);
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
x += (m_prc1->right - m_prc1->left) * gHUD.m_Health.m_fHealthScale;
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b, 255, gHUD.m_Health.m_fHealthScale, CHud::a_southwest);
return 1;
}
//// Old HUD drawing.
//int CHudBattery::Draw(float flTime)
//{
//
// if (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH)
// return 1;
//
// int r, g, b, x, y, a;
// wrect_t rc;
//
// rc = *m_prc2;
//
// int theMaxArmor = gHUD.GetHUDMaxArmor();
// float theScalar = 1.0f / theMaxArmor;
//
// rc.top += m_iHeight * ((float)(theMaxArmor - (min(theMaxArmor, m_iBat))) * theScalar); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
//
// gHUD.GetPrimaryHudColor(r, g, b);
//
// if (!(gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT))))
// return 1;
//
// // Has health changed? Flash the health #
// if (m_fFade)
// {
// if (m_fFade > FADE_TIME)
// m_fFade = FADE_TIME;
//
// m_fFade -= (gHUD.m_flTimeDelta * 20);
// if (m_fFade <= 0)
// {
// a = 128;
// m_fFade = 0;
// }
//
// // Fade the health number back to dim
//
// a = MIN_ALPHA + (m_fFade / FADE_TIME) * 128;
//
// }
// else
// a = MIN_ALPHA;
//
// ScaleColors(r, g, b, a);
//
// int iOffset = (m_prc1->bottom - m_prc1->top) / 6;
//
// int theInset = 0;
// //if(gHUD.GetIsAlien())
// //{
// // theInset = ScreenWidth()*kResourceEnergyBarWidth;
// //}
//
// int theViewport[4];
// gHUD.GetViewport(theViewport);
//
// y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
// x = theViewport[0] + theInset + kArmorLeftInset * ScreenWidth();
//
// // make sure we have the right sprite handles
// if (!m_hSprite1)
// m_hSprite1 = gHUD.GetSprite(gHUD.GetSpriteIndex("suit_empty"));
// if (!m_hSprite2)
// m_hSprite2 = gHUD.GetSprite(gHUD.GetSpriteIndex("suit_full"));
//
// SPR_Set(m_hSprite1, r, g, b);
// SPR_DrawAdditive(0, x, y - iOffset, m_prc1);
//
// if (rc.bottom > rc.top)
// {
// SPR_Set(m_hSprite2, r, g, b);
// SPR_DrawAdditive(0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
// }
//
// x += (m_prc1->right - m_prc1->left);
// x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
//
// return 1;
//
//}

View file

@ -19,6 +19,14 @@ private:
float m_flMouseSensitivity;
bool wstoggle;
float m_flScaleX;
float m_flScaleY;
unsigned int m_iConWidth;
unsigned int m_iConHeight;
float m_flOffsetX;
float m_flOffsetY;
byte m_bIsWidescreen;
public:
AVHHSPRITE m_hsprCursor;
@ -35,17 +43,88 @@ public:
cvar_t *m_pCvarStealMouse;
cvar_t *m_pCvarDraw;
bool m_bWindowed;
cvar_t* m_pCvarWidescreen;
int m_iFontHeight;
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
//int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
int DrawHudStringCentered(int x, int y, int iMaxX, const char *szString, int r, int g, int b );
int DrawHudString(int x, int y, int iMaxX, const char *szString, int r, int g, int b );
int GetHudStringHeight();
int GetHudStringWidth(const char* szIt);
int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b );
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
//int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
int GetNumWidth(int iNumber, int iFlags);
// New stuff
typedef enum {
COLOR_DEFAULT = 0,
COLOR_PRIMARY,
COLOR_SECONDARY,
COLOR_WARNING,
COLOR_COUNT
} hudcolor_e;
typedef enum {
a_northwest = 0,
a_north,
a_northeast,
a_west,
a_center,
a_east,
a_southwest,
a_south,
a_southeast,
} hudalign_e;
void DrawHudSprite(AVHHSPRITE pic, int frame, wrect_t* rect, int x, int y, int r, int g, int b, int a = 255, float scale = 1.0f, hudalign_e alignment = a_northwest);
//void DrawHudSprite(AVHHSPRITE pic, int frame, wrect_t* rect, int x, int y, hudcolor_e color, int a = 255, hudalign_e alignment = a_northwest);
//void DrawHudSpriteIndex(int index, int x, int y, hudcolor_e color, int a = 255, hudalign_e alignment = a_northwest);
void DrawHudSpriteIndex(int index, int x, int y, int r, int g, int b, int a = 255, float scale = 1.0f, hudalign_e alignment = a_northwest);
void DrawHudFill(int x, int y, int w, int h, int r, int g, int b, int a, float scale = 1.0f);
//void DrawHudFill(int x, int y, int w, int h, hudcolor_e color, int a);
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b, int a = 255, float scale = 1.0f, hudalign_e alignment = a_northwest);
//int DrawHudNumber(int x, int y, int iFlags, int iNumber, hudcolor_e color, int a = 255, hudalign_e alignment = a_northwest);
//int DrawHudStringReverse(int xpos, int ypos, int iMinX, const char* szString, int r, int g, int b);
int DrawHudNumberString(int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b);
int GetHudNumberWidth(int number, int width, int flags, float scale = 1.0f);
int DrawHudNumberReverse(int x, int y, int number, int flags, int r, int g, int b, int a = 255, float scale = 1.0f, hudalign_e alignment = a_northwest);
//int DrawHudNumberReverse(int x, int y, int number, int flags, hudcolor_e color, int a = 255, hudalign_e alignment = a_northwest);
//int DrawHudString(const char* string, int x, int y);
//void GetHudStringSize(const char* string, int& width, int& height);
//int HudStringLen(const char* string);
//void GetChatInputPosition(int& x, int& y);
inline unsigned int GetWidth() const
{
return m_iConWidth;
}
inline unsigned int GetHeight() const
{
return m_iConHeight;
}
inline float GetScaleX() const
{
return m_flScaleX;
}
inline float GetScaleY() const
{
return m_flScaleY;
}
//inline void GetColor(int& r, int& g, int& b, hudcolor_e color) const
//{
// r = m_cColors[color].r;
// g = m_cColors[color].g;
// b = m_cColors[color].b;
//}
private:
// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
// freed in ~CHud()

View file

@ -23,7 +23,8 @@
#define DHN_DRAWZERO 1
#define DHN_2DIGITS 2
#define DHN_3DIGITS 4
#define MIN_ALPHA 100
//#define MIN_ALPHA 100
#define MIN_ALPHA 128
#define HUDELEM_ACTIVE 1
@ -342,7 +343,10 @@ public:
int VidInit( void );
int Draw(float flTime);
int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf );
int m_iAnchorX; // our x position, set by the health hud
int m_iAnchorY; // our y position, set by the health hud
private:
AVHHSPRITE m_hSprite1;
AVHHSPRITE m_hSprite2;

View file

@ -28,6 +28,7 @@
#include "mod/AvHHudConstants.h"
#include "mod/AvHPlayerUpgrade.h"
#include "mod/AvHNetworkMessages.h"
#include "chudmisc.h"
DECLARE_MESSAGE(m_Health, Health )
DECLARE_MESSAGE(m_Health, Damage )
@ -66,9 +67,14 @@ int CHudHealth::Init(void)
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
giDmgHeight = 0;
giDmgWidth = 0;
m_fHealthScale = 1.0f;
memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES);
hud_health_x = CVAR_CREATE("hud_health_x", "0", FCVAR_ARCHIVE);
hud_health_y = CVAR_CREATE("hud_health_y", "0", FCVAR_ARCHIVE);
hud_health_scale = CVAR_CREATE("hud_health_scale", "1", FCVAR_ARCHIVE);
hud_health_alphamin = CVAR_CREATE("hud_health_alphamin", "128", FCVAR_ARCHIVE);
gHUD.AddHudElem(this);
return 1;
@ -160,6 +166,91 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b )
}
}
//// Old HUD drawing.
//int CHudHealth::Draw(float flTime)
//{
// int r, g, b;
// int a = 0, x, y;
// int HealthWidth;
//
// if ( /*!gHUD.GetIsAlive() ||*/ (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) /*|| gEngfuncs.IsSpectateOnly()*/)
// return 1;
//
// if (!m_hSprite)
// m_hSprite = LoadSprite(PAIN_NAME);
//
// // Has health changed? Flash the health #
// if (m_fFade)
// {
// m_fFade -= (gHUD.m_flTimeDelta * 20);
// if (m_fFade <= 0)
// {
// a = MIN_ALPHA;
// m_fFade = 0;
// }
//
// // Fade the health number back to dim
//
// a = MIN_ALPHA + (m_fFade / FADE_TIME) * 128;
//
// }
// else
// a = MIN_ALPHA;
//
// // Potentially se upgrades and health of spectator target
// int theUpgrades = gHUD.GetHUDUpgrades();
//
// // If health is getting low, make it bright red
// int theMaxHealth = gHUD.GetHUDMaxHealth();
// if (m_iHealth <= theMaxHealth / 10)
// {
// a = 255;
// }
//
// GetPainColor(r, g, b);
// ScaleColors(r, g, b, a);
//
// int theViewport[4];
// gHUD.GetViewport(theViewport);
//
// // Only draw health if we have the suit.
// if (gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT)))
// {
// HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
// int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
//
// y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
//
// x = theViewport[0] + CrossWidth / 2;
//
// int theInset = 0;
// //if(gHUD.GetIsAlien() && !gHUD.GetIsCombatMode())
// //{
// // theInset = ScreenWidth()*kResourceEnergyBarWidth;
// //}
// x += theInset;// + kHealthLeftInset*ScreenWidth;
//
// SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
// SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
//
// x += CrossWidth + HealthWidth / 2;
//
// x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
//
// x += HealthWidth / 2;
//
// gHUD.GetPrimaryHudColor(r, g, b);
//
// int iHeight = gHUD.m_iFontHeight;
// int iWidth = HealthWidth / 10;
// FillRGBA(x, y, iWidth, iHeight, r, g, b, a);
// }
//
// DrawDamage(flTime);
// return DrawPain(flTime);
//}
int CHudHealth::Draw(float flTime)
{
int r, g, b;
@ -172,23 +263,24 @@ int CHudHealth::Draw(float flTime)
if ( !m_hSprite )
m_hSprite = LoadSprite(PAIN_NAME);
if (hud_health_alphamin)
m_iMinAlpha = max(0, min(hud_health_alphamin->value, 255));
else
m_iMinAlpha = MIN_ALPHA;
// Has health changed? Flash the health #
if (m_fFade)
{
m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
a = MIN_ALPHA;
m_fFade = 0;
}
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
a = m_iMinAlpha + (m_fFade/FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
a = m_iMinAlpha;
// Potentially se upgrades and health of spectator target
int theUpgrades = gHUD.GetHUDUpgrades();
@ -203,40 +295,53 @@ int CHudHealth::Draw(float flTime)
GetPainColor( r, g, b );
ScaleColors(r, g, b, a );
int theViewport[4];
gHUD.GetViewport(theViewport);
// Only draw health if we have the suit.
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
{
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
if (hud_health_scale)
{
m_fHealthScale = min(max(0.01f, hud_health_scale->value), 5.0f);
}
y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = theViewport[0] + CrossWidth /2;
HealthWidth = (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left) * m_fHealthScale;
int CrossWidth = (gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left) * m_fHealthScale;
int theInset = 0;
//if(gHUD.GetIsAlien() && !gHUD.GetIsCombatMode())
//{
// theInset = ScreenWidth()*kResourceEnergyBarWidth;
//}
x += theInset;// + kHealthLeftInset*ScreenWidth;
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
if (hud_health_x && hud_health_x->value != 0.0f)
{
x = min(max(0.0f, hud_health_x->value), 1.0f) * gHUD.GetWidth();
}
else
{
x = CrossWidth / 2;
}
int initialY = gHUD.GetHeight();
if (hud_health_y && hud_health_y->value != 0.0f)
{
initialY *= min(max(0.0f, hud_health_y->value), 1.0f);
}
y = initialY - gHUD.m_iFontHeight / 2;
gHUD.DrawHudSpriteIndex(m_HUD_cross, x, y, r, g, b, 255, m_fHealthScale, CHud::a_southwest);
x += CrossWidth + HealthWidth / 2;
//Reserve space for 3 digits by default, but allow it to expand
x += gHUD.GetHudNumberWidth(m_iHealth, 3, DHN_DRAWZERO, m_fHealthScale);
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
gHUD.DrawHudNumberReverse(x, y, m_iHealth, DHN_DRAWZERO, r, g, b, 255, m_fHealthScale, CHud::a_southwest);
x += HealthWidth/2;
x += HealthWidth /2;
gHUD.GetPrimaryHudColor(r, g, b);
int iHeight = gHUD.m_iFontHeight;
int iWidth = HealthWidth/10;
FillRGBA(x, y, iWidth, iHeight, r, g, b, a);
int iHeight = gHUD.m_iFontHeight * -1;
int iWidth = max(1, HealthWidth /10);
gHUD.DrawHudFill(x, y, iWidth, iHeight, r ,g , b, a, m_fHealthScale);
gHUD.m_Battery.m_iAnchorX = x + + iWidth + HealthWidth / 2;
gHUD.m_Battery.m_iAnchorY = initialY;
}
DrawDamage(flTime);

View file

@ -101,6 +101,8 @@ public:
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
void GetPainColor( int &r, int &g, int &b );
float m_fFade;
float m_fHealthScale;
int m_iMinAlpha;
private:
AVHHSPRITE m_hSprite;
@ -112,6 +114,11 @@ private:
int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits);
cvar_t* hud_health_x;
cvar_t* hud_health_y;
cvar_t* hud_health_scale;
cvar_t* hud_health_alphamin;
};
#endif

View file

@ -230,6 +230,7 @@ void CHud :: Init( void )
CVAR_CREATE("hud_nameinfo", "1", FCVAR_ARCHIVE);
CVAR_CREATE("hud_drawwaypoints", "2", FCVAR_ARCHIVE);
CVAR_CREATE("hud_waypointblinking", "0", FCVAR_ARCHIVE);
m_pCvarWidescreen = gEngfuncs.pfnGetCvarPointer("gl_widescreen_yfov");
m_pSpriteList = NULL;
@ -367,6 +368,17 @@ void CHud :: VidInit( void )
else
m_iRes = 640;
// HUD scaling
//m_iConHeight = m_iRes * 0.75F;
m_iConHeight = 600; // Replicate 800x600 scale since NS seems to have been designed for that.
m_flScaleY = ScreenHeight() / (float)m_iConHeight;
m_flScaleX = m_flScaleY;
m_flOffsetY = 0.0F;
m_bIsWidescreen = m_pCvarWidescreen->value == 0.0F;
// Only load this once
if ( !m_pSpriteList || gHUD.GetReInitHUD())
{

View file

@ -21,9 +21,13 @@
#include "mod/AvHFont.h"
#include "vgui_TeamFortressViewport.h"
#include "common/com_model.h"
//#include "r_studioint.h"
#define MAX_LOGO_FRAMES 56
//extern engine_studio_api_t IEngineStudio;
int grgLogoFrame[MAX_LOGO_FRAMES] =
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
@ -106,6 +110,22 @@ int CHud :: Redraw( float flTime, int intermission )
if ( m_flTimeDelta < 0 )
m_flTimeDelta = 0;
bool bWantWidescreen = m_pCvarWidescreen->value != 0.0F;
if (bWantWidescreen != m_bIsWidescreen)
{
if (bWantWidescreen)
{
m_iConWidth = m_iConHeight * (ScreenWidth() / (float)ScreenHeight());
}
else
{
m_iConWidth = m_iRes;
}
m_flOffsetX = (ScreenWidth() - m_iConWidth * m_flScaleX) / 2.0F;
m_bIsWidescreen = bWantWidescreen;
}
// Bring up the scoreboard during intermission
if (gViewPort)
{
@ -318,22 +338,253 @@ int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString,
}
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
//// Old metod before scaling.
//int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
//{
// int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
// int k;
//
// if (iNumber > 0)
// {
// // SPR_Draw 100's
// if (iNumber >= 100)
// {
// k = iNumber/100;
// SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
// SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
// x += iWidth;
// }
// else if (iFlags & (DHN_3DIGITS))
// {
// //SPR_DrawAdditive( 0, x, y, &rc );
// x += iWidth;
// }
//
// // SPR_Draw 10's
// if (iNumber >= 10)
// {
// k = (iNumber % 100)/10;
// SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
// SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
// x += iWidth;
// }
// else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
// {
// //SPR_DrawAdditive( 0, x, y, &rc );
// x += iWidth;
// }
//
// // SPR_Draw ones
// k = iNumber % 10;
// SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
// SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
// x += iWidth;
// }
// else if (iFlags & DHN_DRAWZERO)
// {
// SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
//
// // SPR_Draw 100's
// if (iFlags & (DHN_3DIGITS))
// {
// //SPR_DrawAdditive( 0, x, y, &rc );
// x += iWidth;
// }
//
// if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
// {
// //SPR_DrawAdditive( 0, x, y, &rc );
// x += iWidth;
// }
//
// // SPR_Draw ones
//
// SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
// x += iWidth;
// }
//
// return x;
//}
// Toodles' sprite scaling with additional scaling option added.
void CHud::DrawHudSprite(AVHHSPRITE pic, int frame, wrect_t * rect, int x, int y, int r, int g, int b, int a, float scale, hudalign_e alignment)
{
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
auto sprw = gEngfuncs.pfnSPR_Width(pic, frame);
auto sprh = gEngfuncs.pfnSPR_Height(pic, frame);
if (!rect)
{
static wrect_t rc;
rc.left = 0;
rc.right = sprw;
rc.top = 0;
rc.bottom = sprh;
rect = &rc;
}
float xf = x;
float yf = y;
auto width = (rect->right - rect->left) * scale;
auto height = (rect->bottom - rect->top) * scale;
switch (alignment)
{
case a_north:
case a_center:
case a_south:
xf -= width / 2.0F - 0.5F;
break;
case a_northeast:
case a_east:
case a_southeast:
xf -= width;
break;
}
switch (alignment)
{
case a_west:
case a_center:
case a_east:
yf -= height / 2.0F - 0.5F;
break;
case a_southwest:
case a_south:
case a_southeast:
yf -= height;
break;
}
//// No software mode in NS.
//if (!IEngineStudio.IsHardware())
//{
// x += m_flOffsetX;
// y += m_flOffsetY;
// ScaleColors(r, g, b, a);
// gEngfuncs.pfnSPR_Set(pic, r, g, b);
// // Toodles FIXME: Hack for the crosshair.
// if (alignment == a_center)
// {
// gEngfuncs.pfnSPR_DrawHoles(frame, x, y, rect);
// }
// else
// {
// gEngfuncs.pfnSPR_DrawAdditive(frame, x, y, rect);
// }
// return;
//}
auto pSprite = const_cast<model_t*>(gEngfuncs.GetSpritePointer(pic));
auto x1 = roundf(m_flOffsetX + xf * m_flScaleX);
auto y1 = roundf(m_flOffsetY + yf * m_flScaleY);
auto x2 = roundf(m_flOffsetX + (xf + width) * m_flScaleX);
auto y2 = roundf(m_flOffsetY + (yf + height) * m_flScaleY);
auto left = rect->left / (float)sprw;
auto right = rect->right / (float)sprw;
auto top = rect->top / (float)sprh;
auto bottom = rect->bottom / (float)sprh;
gEngfuncs.pTriAPI->SpriteTexture(pSprite, frame);
auto rendermode = kRenderTransAdd;
// Toodles FIXME: Hack for the crosshair.
if (alignment == a_center)
{
rendermode = kRenderTransAlpha;
}
gEngfuncs.pTriAPI->Color4fRendermode(r / 255.0F, g / 255.0F, b / 255.0F, a / 255.0F, rendermode);
gEngfuncs.pTriAPI->RenderMode(rendermode);
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
gEngfuncs.pTriAPI->TexCoord2f(left, top);
gEngfuncs.pTriAPI->Vertex3f(x1, y1, 0);
gEngfuncs.pTriAPI->TexCoord2f(right, top);
gEngfuncs.pTriAPI->Vertex3f(x2, y1, 0);
gEngfuncs.pTriAPI->TexCoord2f(right, bottom);
gEngfuncs.pTriAPI->Vertex3f(x2, y2, 0);
gEngfuncs.pTriAPI->TexCoord2f(left, bottom);
gEngfuncs.pTriAPI->Vertex3f(x1, y2, 0);
gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
}
//void CHud::DrawHudSprite(AVHHSPRITE pic, int frame, wrect_t* rect, int x, int y, hudcolor_e color, int a, hudalign_e alignment)
//{
// int r, g, b;
// GetColor(r, g, b, color);
// DrawHudSprite(pic, frame, rect, x, y, r, g, b, a, alignment);
//}
void CHud::DrawHudSpriteIndex(int index, int x, int y, int r, int g, int b, int a, float scale, hudalign_e alignment)
{
DrawHudSprite(GetSprite(index), 0, &GetSpriteRect(index), x, y, r, g, b, a, scale, alignment);
}
//void CHud::DrawHudSpriteIndex(int index, int x, int y, hudcolor_e color, int a, hudalign_e alignment)
//{
// int r, g, b;
// GetColor(r, g, b, color);
// DrawHudSprite(GetSprite(index), 0, &GetSpriteRect(index), x, y, r, g, b, a, alignment);
//}
void CHud::DrawHudFill(int x, int y, int w, int h, int r, int g, int b, int a, float scale)
{
x = roundf(m_flOffsetX + x * m_flScaleX);
y = roundf(m_flOffsetY + y * m_flScaleY);
w = roundf(w * m_flScaleX * scale);
h = roundf(h * m_flScaleY * scale);
gEngfuncs.pfnFillRGBA(x, y, w, h, r, g, b, a);
}
//void CHud::DrawHudFill(int x, int y, int w, int h, hudcolor_e color, int a)
//{
// int r, g, b;
// GetColor(r, g, b, color);
// DrawHudFill(x, y, w, h, r, g, b, a);
//}
//int CHud::DrawHudString(int xpos, int ypos, int iMaxX, const char* szIt, int r, int g, int b)
//{
// auto x1 = roundf(m_flOffsetX + xpos * m_flScaleX);
// auto y1 = roundf(m_flOffsetY + ypos * m_flScaleY);
// return (gEngfuncs.pfnDrawString(x1, y1, szIt, r, g, b) - m_flOffsetX) / m_flScaleX;
//}
//// draws a string from right to left (right-aligned)
//int CHud::DrawHudStringReverse(int xpos, int ypos, int iMinX, const char* szString, int r, int g, int b)
//{
// auto x1 = roundf(m_flOffsetX + xpos * m_flScaleX);
// auto y1 = roundf(m_flOffsetY + ypos * m_flScaleY);
// return (gEngfuncs.pfnDrawStringReverse(x1, y1, szString, r, g, b) - m_flOffsetX) / m_flScaleX;
//}
int CHud::DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b, int a, float scale, hudalign_e alignment)
{
int iWidth = (GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left) * scale;
int k;
if (iNumber > 0)
{
// SPR_Draw 100's
if (iNumber >= 100)
{
k = iNumber/100;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
k = iNumber / 100;
DrawHudSpriteIndex(m_HUD_number_0 + k, x, y, r, g, b, a, scale, alignment);
x += iWidth;
}
else if (iFlags & (DHN_3DIGITS))
else if ((iFlags & DHN_3DIGITS) != 0)
{
//SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth;
@ -342,12 +593,11 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
// SPR_Draw 10's
if (iNumber >= 10)
{
k = (iNumber % 100)/10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
k = (iNumber % 100) / 10;
DrawHudSpriteIndex(m_HUD_number_0 + k, x, y, r, g, b, a, scale, alignment);
x += iWidth;
}
else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
else if ((iFlags & (DHN_3DIGITS | DHN_2DIGITS)) != 0)
{
//SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth;
@ -355,36 +605,39 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
// SPR_Draw ones
k = iNumber % 10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
DrawHudSpriteIndex(m_HUD_number_0 + k, x, y, r, g, b, a, scale, alignment);
x += iWidth;
}
else if (iFlags & DHN_DRAWZERO)
}
else if ((iFlags & DHN_DRAWZERO) != 0)
{
SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
// SPR_Draw 100's
if (iFlags & (DHN_3DIGITS))
if ((iFlags & DHN_3DIGITS) != 0)
{
//SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth;
}
if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
if ((iFlags & (DHN_3DIGITS | DHN_2DIGITS)) != 0)
{
//SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth;
}
// SPR_Draw ones
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
DrawHudSpriteIndex(m_HUD_number_0, x, y, r, g, b, a, scale, alignment);
x += iWidth;
}
return x;
}
//int CHud::DrawHudNumber(int x, int y, int iFlags, int iNumber, hudcolor_e color, int a, hudalign_e alignment)
//{
// int r, g, b;
// GetColor(r, g, b, color);
// return DrawHudNumber(x, y, iFlags, iNumber, r, g, b, a, alignment);
//}
int CHud::GetNumWidth( int iNumber, int iFlags )
{
@ -412,4 +665,81 @@ int CHud::GetNumWidth( int iNumber, int iFlags )
}
int CHud::GetHudNumberWidth(int number, int width, int flags, float scale)
{
const int digitWidth = (GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left) * scale;
int totalDigits = 0;
if (number > 0)
{
totalDigits = static_cast<int>(log10(number)) + 1;
}
else if ((flags & DHN_DRAWZERO) != 0)
{
totalDigits = 1;
}
totalDigits = max(totalDigits, width);
return totalDigits * digitWidth;
}
int CHud::DrawHudNumberReverse(int x, int y, int number, int flags, int r, int g, int b, int a, float scale, hudalign_e alignment)
{
if (number > 0 || (flags & DHN_DRAWZERO) != 0)
{
const int digitWidth = (GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left) * scale;
int remainder = number;
do
{
const int digit = remainder % 10;
const int digitSpriteIndex = m_HUD_number_0 + digit;
//This has to happen *before* drawing because we're drawing in reverse
x -= digitWidth;
DrawHudSpriteIndex(digitSpriteIndex, x, y, r, g, b, a, scale, alignment);
remainder /= 10;
} while (remainder > 0);
}
return x;
}
//int CHud::DrawHudNumberReverse(int x, int y, int number, int flags, hudcolor_e color, int a, hudalign_e alignment)
//{
// int r, g, b;
// GetColor(r, g, b, color);
// return DrawHudNumberReverse(x, y, number, flags, r, g, b, a, alignment);
//}
//int CHud::DrawHudString(const char* string, int x, int y)
//{
// auto x1 = roundf (m_flOffsetX + x * m_flScaleX);
// auto y1 = roundf (m_flOffsetY + y * m_flScaleY);
// return (gEngfuncs.pfnDrawConsoleString(x1, y1, (char*)string) - m_flOffsetX) / m_flScaleX;
//}
//
//void CHud::GetHudStringSize(const char* string, int& width, int& height)
//{
// gEngfuncs.pfnDrawConsoleStringLen(string, &width, &height);
// width /= m_flScaleX;
// height /= m_flScaleY;
//}
//
//int CHud::HudStringLen(const char* string)
//{
// int width, height;
// GetHudStringSize(string, width, height);
// return width;
//}
//
//void CHud::GetChatInputPosition(int& x, int& y)
//{
// x = roundf (m_flOffsetX + m_SayText.m_iBaseX * m_flScaleX);
// y = roundf (m_flOffsetY + (m_SayText.m_iBaseY + m_SayText.m_iLineHeight) * m_flScaleY);
//}

View file

@ -36,7 +36,7 @@ const float kPlayerStatusStatusSpacing = .02f;
// health armor inset (it is inset by the alien energy indicator for aliens)
const float kHealthLeftInset = .05f;
const float kArmorLeftInset = .1f;
const float kArmorLeftInset = .2f;
// blip size
const float kWorldBlipScale = 100;

Binary file not shown.

Binary file not shown.

View file

@ -75,12 +75,12 @@ suit_empty 320 320hud2 16 88 16 16
//===========================================
selection 640 640hud3 0 180 170 45
bucket1 640 640hud7 168 72 20 20
bucket2 640 640hud7 188 72 20 20
bucket3 640 640hud7 208 72 20 20
bucket4 640 640hud7 168 92 20 20
bucket5 640 640hud7 188 92 20 20
bucket0 640 640hud7 208 92 20 20
bucket1 640 640hud7 177 72 20 20
bucket2 640 640hud7 198 72 20 20
bucket3 640 640hud7 219 72 20 20
bucket4 640 640hud7 177 93 20 20
bucket5 640 640hud7 198 93 20 20
bucket0 640 640hud7 219 93 20 20
dmg_poison 640 640hud8 128 0 64 64
dmg_bio 640 640hud8 128 0 64 64
dmg_chem 640 640hud8 0 0 64 64
@ -90,22 +90,22 @@ dmg_cold 640 640hud9 64 0 64 64
dmg_heat 640 640hud9 128 0 64 64
dmg_rad 640 640hud9 192 0 64 64
dmg_shock 640 640hud8 192 0 64 64
number_0 640 640hud7 0 0 24 25
number_1 640 640hud7 24 0 24 25
number_2 640 640hud7 48 0 24 25
number_3 640 640hud7 72 0 24 25
number_4 640 640hud7 96 0 24 25
number_5 640 640hud7 120 0 24 25
number_6 640 640hud7 144 0 24 25
number_7 640 640hud7 168 0 24 25
number_8 640 640hud7 192 0 24 25
number_9 640 640hud7 216 0 24 25
divider 640 640hud7 240 0 2 40
cross 640 640hud7 48 25 24 24
d_skull 640 640hud7 72 25 12 12
flash_full 640 640hud7 160 25 32 32
flash_empty 640 640hud7 112 25 32 32
flash_beam 640 640hud7 144 25 16 32
number_0 640 640hud7 1 1 24 25
number_1 640 640hud7 25 1 24 25
number_2 640 640hud7 49 1 24 25
number_3 640 640hud7 73 1 24 25
number_4 640 640hud7 97 1 24 25
number_5 640 640hud7 121 1 24 25
number_6 640 640hud7 145 1 24 25
number_7 640 640hud7 169 1 24 25
number_8 640 640hud7 193 1 24 25
number_9 640 640hud7 217 1 24 25
divider 640 640hud7 251 1 2 40
cross 640 640hud7 56 27 26 26
d_skull 640 640hud7 83 27 12 12
flash_full 640 640hud7 171 27 32 32
flash_empty 640 640hud7 123 27 32 32
flash_beam 640 640hud7 155 27 16 32
title_half 640 640hud4 0 226 256 30
title_life 640 640hud5 0 226 220 30
d_knife 640 640aw3-s 100 232 64 24
@ -125,7 +125,7 @@ d_sporegunprojectile 640 640aw3-s 192 0 64 24
d_healingspray 640 640aw3-s 192 72 64 24
d_parasite 640 640aw3-s 192 48 64 24
d_siegeturret 640 640aw3 143 224 48 32
d_spitgunspit 640 640aw3 192 102 64 24
d_spitgunspit 640 640aw3 192 102 64 24
d_claws 640 640aw3 176 48 80 32
d_bitegun 640 640aw3 192 0 64 24
d_bite2gun 640 640aw3 192 24 64 24
@ -144,6 +144,6 @@ d_tracktrain 640 640hud1 192 240 32 16
d_team_advturretfactory 640 320w-s 80 240 32 16
d_team_turretfactory 640 320w-s 80 240 32 16
d_resourcetower 640 320w-s 80 240 32 16
suit_full 640 640hud7 0 25 24 24
suit_empty 640 640hud7 24 25 24 24
suit_full 640 640hud7 1 27 24 24
suit_empty 640 640hud7 26 27 24 24

View file

@ -27,7 +27,7 @@ number_8 320 320hud2 96 0 12 16
number_9 320 320hud2 108 0 12 16
divider 320 320hud2 120 0 1 20
cross 320 320hud2 0 72 16 16
d_skull 320 640hud7 72 25 12 12
d_skull 320 640nlhud7 72 25 12 12
flash_full 320 320hud2 16 72 18 16
flash_empty 320 320hud2 34 72 18 16
flash_beam 320 320hud2 52 72 6 16
@ -75,12 +75,12 @@ suit_empty 320 320hud2 16 88 16 16
//===========================================
selection 640 640hud3 0 180 170 45
bucket1 640 640nlhud7 168 72 20 20
bucket2 640 640nlhud7 188 72 20 20
bucket3 640 640nlhud7 208 72 20 20
bucket4 640 640nlhud7 168 92 20 20
bucket5 640 640nlhud7 188 92 20 20
bucket0 640 640nlhud7 208 92 20 20
bucket1 640 640nlhud7 177 72 20 20
bucket2 640 640nlhud7 198 72 20 20
bucket3 640 640nlhud7 219 72 20 20
bucket4 640 640nlhud7 177 93 20 20
bucket5 640 640nlhud7 198 93 20 20
bucket0 640 640nlhud7 219 93 20 20
dmg_poison 640 640hud8 128 0 64 64
dmg_bio 640 640hud8 128 0 64 64
dmg_chem 640 640hud8 0 0 64 64
@ -90,27 +90,27 @@ dmg_cold 640 640hud9 64 0 64 64
dmg_heat 640 640hud9 128 0 64 64
dmg_rad 640 640hud9 192 0 64 64
dmg_shock 640 640hud8 192 0 64 64
number_0 640 640nlhud7 0 0 24 25
number_1 640 640nlhud7 24 0 24 25
number_2 640 640nlhud7 48 0 24 25
number_3 640 640nlhud7 72 0 24 25
number_4 640 640nlhud7 96 0 24 25
number_5 640 640nlhud7 120 0 24 25
number_6 640 640nlhud7 144 0 24 25
number_7 640 640nlhud7 168 0 24 25
number_8 640 640nlhud7 192 0 24 25
number_9 640 640nlhud7 216 0 24 25
divider 640 640nlhud7 240 0 2 40
cross 640 640nlhud7 48 25 24 24
d_skull 640 640nlhud7 72 25 12 12
flash_full 640 640nlhud7 160 25 32 32
flash_empty 640 640nlhud7 112 25 32 32
flash_beam 640 640nlhud7 144 25 16 32
number_0 640 640nlhud7 1 1 24 25
number_1 640 640nlhud7 25 1 24 25
number_2 640 640nlhud7 49 1 24 25
number_3 640 640nlhud7 73 1 24 25
number_4 640 640nlhud7 97 1 24 25
number_5 640 640nlhud7 121 1 24 25
number_6 640 640nlhud7 145 1 24 25
number_7 640 640nlhud7 169 1 24 25
number_8 640 640nlhud7 193 1 24 25
number_9 640 640nlhud7 217 1 24 25
divider 640 640nlhud7 251 1 2 40
cross 640 640nlhud7 56 27 26 26
d_skull 640 640nlhud7 83 27 12 12
flash_full 640 640nlhud7 171 27 32 32
flash_empty 640 640nlhud7 123 27 32 32
flash_beam 640 640nlhud7 155 27 16 32
title_half 640 640hud4 0 226 256 30
title_life 640 640hud5 0 226 220 30
d_knife 640 640aw3-s 100 232 64 24
d_handgrenade 640 640aw1 192 231 64 24
d_grenade 640 640aw3-s 192 192 64 24
d_handgrenade 640 640aw1 192 231 64 24
d_grenade 640 640aw3-s 192 192 64 24
d_grenadegun 640 640aw3-s 192 192 64 24
d_machinegun 640 640aw3-s 192 96 64 24
d_pistol 640 640aw3-s 192 168 64 24
@ -125,7 +125,7 @@ d_sporegunprojectile 640 640aw3-s 192 0 64 24
d_healingspray 640 640aw3-s 192 72 64 24
d_parasite 640 640aw3-s 192 48 64 24
d_siegeturret 640 640aw3 143 224 48 32
d_spitgunspit 640 640aw3 192 102 64 24
d_spitgunspit 640 640aw3 192 102 64 24
d_claws 640 640aw3 176 48 80 32
d_bitegun 640 640aw3 192 0 64 24
d_bite2gun 640 640aw3 192 24 64 24
@ -144,6 +144,6 @@ d_tracktrain 640 640hud1 192 240 32 16
d_team_advturretfactory 640 320w-s 80 240 32 16
d_team_turretfactory 640 320w-s 80 240 32 16
d_resourcetower 640 320w-s 80 240 32 16
suit_full 640 640nlhud7 0 25 24 24
suit_empty 640 640nlhud7 24 25 24 24
suit_full 640 640nlhud7 1 27 24 24
suit_empty 640 640nlhud7 26 27 24 24