Move drawing utilites into separate class (anti-g(od)HUD)
This commit is contained in:
parent
f5d9f82d6d
commit
e5cb94038f
325
cl_dll/draw_util.cpp
Normal file
325
cl_dll/draw_util.cpp
Normal file
@ -0,0 +1,325 @@
|
||||
#include "draw_util.h"
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "triangleapi.h"
|
||||
#include <string.h>
|
||||
|
||||
extern cvar_t *hud_textmode;
|
||||
float DrawUtils :: color[3];
|
||||
|
||||
int DrawUtils :: DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b, bool drawing )
|
||||
{
|
||||
int first_xpos = xpos;
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
int next = xpos + gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; // variable-width fonts look cool
|
||||
if ( next > iMaxX )
|
||||
return xpos;
|
||||
|
||||
if( *szIt == '\\' && *(szIt+1) != '\n' && *(szIt+1) != 0)
|
||||
{
|
||||
// an escape character
|
||||
|
||||
switch( *(++szIt) )
|
||||
{
|
||||
case 'y':
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
continue;
|
||||
case 'w':
|
||||
r = g = b = 255;
|
||||
continue;
|
||||
case 'd':
|
||||
continue;
|
||||
case 'R':
|
||||
//if( drawing ) return xpos;
|
||||
//return DrawHudStringReverse( iMaxX, ypos, first_xpos, szIt, r, g, b, true ); // set 'drawing' to true, to stop when '\R' is catched
|
||||
xpos = iMaxX - gHUD.m_scrinfo.charWidths[ 'M' ] * 10;
|
||||
++szIt;
|
||||
}
|
||||
}
|
||||
|
||||
xpos += TextMessageDrawChar( xpos, ypos, *szIt, r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int DrawUtils :: HudStringLen( char *szIt )
|
||||
{
|
||||
int l = 0;
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; // variable-width fonts look cool
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
|
||||
{
|
||||
char szString[32];
|
||||
snprintf( szString, 32, "%d", iNumber );
|
||||
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
|
||||
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b, bool drawing )
|
||||
{
|
||||
int first_xpos = xpos;
|
||||
|
||||
|
||||
// iterate throug the string in reverse
|
||||
for ( signed int i = strlen(szString); i >= 0; i-- )
|
||||
{
|
||||
int next = xpos - gHUD.m_scrinfo.charWidths[ (unsigned char)szString[i] ]; // variable-width fonts look cool
|
||||
if ( next < iMinX )
|
||||
return xpos;
|
||||
xpos = next;
|
||||
|
||||
if( i > 1 && szString[i - 1] == '\\' )
|
||||
{
|
||||
// an escape character
|
||||
|
||||
switch( szString[i] )
|
||||
{
|
||||
case 'y':
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
break;
|
||||
case 'w':
|
||||
r = g = b = 255;
|
||||
break;
|
||||
case 'R':
|
||||
//if( drawing ) return xpos;
|
||||
//else return DrawHudString( iMinX, ypos, first_xpos, &szString[i - 1], r, g, b, true ); // set 'drawing' to true, to stop when '\R' is catched
|
||||
//xpos = iMinX + gHUD.m_scrinfo.charWidths['M'] * i ;
|
||||
case 'd':
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
TextMessageDrawChar( xpos, ypos, szString[i], r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
int k;
|
||||
|
||||
if (iNumber > 0)
|
||||
{
|
||||
// SPR_Draw 100's
|
||||
if (iNumber >= 100)
|
||||
{
|
||||
k = iNumber/100;
|
||||
SPR_Set(gHUD.GetSprite(gHUD.m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(gHUD.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(gHUD.GetSprite(gHUD.m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(gHUD.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(gHUD.GetSprite(gHUD.m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(gHUD.m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & DHN_DRAWZERO)
|
||||
{
|
||||
SPR_Set(gHUD.GetSprite(gHUD.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, &gHUD.GetSpriteRect(gHUD.m_HUD_number_0));
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int DrawUtils :: GetNumWidth( int iNumber, int iFlags )
|
||||
{
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
return 3;
|
||||
|
||||
if (iFlags & (DHN_2DIGITS))
|
||||
return 2;
|
||||
|
||||
if (iNumber <= 0)
|
||||
{
|
||||
if (iFlags & (DHN_DRAWZERO))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iNumber < 10)
|
||||
return 1;
|
||||
|
||||
if (iNumber < 100)
|
||||
return 2;
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
void DrawUtils :: DrawRectangle(int x, int y, int wide, int tall , int r, int g, int b, int a, bool drawStroke)
|
||||
{
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
||||
gEngfuncs.pTriAPI->Color4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
gEngfuncs.pTriAPI->Vertex3f(x * gHUD.m_flScale, (y+tall) * gHUD.m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f(x * gHUD.m_flScale, y * gHUD.m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f((x + wide) * gHUD.m_flScale, y * gHUD.m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f((x + wide) * gHUD.m_flScale, (y+tall) * gHUD.m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->End();
|
||||
|
||||
if(drawStroke)
|
||||
{
|
||||
// TODO: remove this hardcoded hardcore
|
||||
FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 );
|
||||
}
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawHudNumber2( int x, int y, bool DrawZero, int iDigits, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
|
||||
x += ( iDigits - 1 ) * iWidth;
|
||||
|
||||
int ResX = x + iWidth;
|
||||
do
|
||||
{
|
||||
int k = iNumber % 10;
|
||||
iNumber /= 10;
|
||||
SPR_Set( gHUD.GetSprite( gHUD.m_HUD_number_0 + k ), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( gHUD.m_HUD_number_0 + k ) );
|
||||
x -= iWidth;
|
||||
iDigits--;
|
||||
}
|
||||
while( iNumber > 0 || ( iDigits > 0 && DrawZero ) );
|
||||
|
||||
return ResX;
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawHudNumber2( int x, int y, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
|
||||
|
||||
int iDigits = 0;
|
||||
int temp = iNumber;
|
||||
do
|
||||
{
|
||||
iDigits++;
|
||||
temp /= 10;
|
||||
}
|
||||
while( temp > 0 );
|
||||
|
||||
x += ( iDigits - 1 ) * iWidth;
|
||||
|
||||
int ResX = x + iWidth;
|
||||
do
|
||||
{
|
||||
int k = iNumber % 10;
|
||||
iNumber /= 10;
|
||||
SPR_Set( gHUD.GetSprite( gHUD.m_HUD_number_0 + k ), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( gHUD.m_HUD_number_0 + k ) );
|
||||
x -= iWidth;
|
||||
}
|
||||
while( iNumber > 0 );
|
||||
|
||||
return ResX;
|
||||
}
|
||||
|
||||
int DrawUtils :: DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
{
|
||||
int ret = DrawHudString( x, y, 9999, (char*)string, color[0] * 255, color[1] * 255, color[2] * 255);
|
||||
color[0] = color[1] = color[2] = 1.0f;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
|
||||
}
|
||||
|
||||
void DrawUtils :: SetConsoleTextColor(float r, float g, float b)
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
color[0] = r, color[1] = g, color[2] = b;
|
||||
else
|
||||
gEngfuncs.pfnDrawSetTextColor( r, g, b );
|
||||
}
|
||||
|
||||
void DrawUtils :: SetConsoleTextColor(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
color[0] = r / 255.0f, color[1] = g / 255.0f, color[2] = b / 255.0f ;
|
||||
else
|
||||
gEngfuncs.pfnDrawSetTextColor( r / 255.0f, g / 255.0f, b / 255.0f );
|
||||
}
|
||||
|
||||
void DrawUtils :: ConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
*height = 13, *width = HudStringLen((char*)string);
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
|
||||
}
|
||||
|
||||
int DrawUtils :: ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width, _height;
|
||||
if( hud_textmode->value )
|
||||
{
|
||||
return HudStringLen((char*)string);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
}
|
||||
|
||||
int DrawUtils :: TextMessageDrawChar(int x, int y, int number, int r, int g, int b)
|
||||
{
|
||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
||||
}
|
@ -95,7 +95,7 @@ int CHudMOTD :: Draw( float fTime )
|
||||
int ymax = ypos + height;
|
||||
if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30;
|
||||
char *next_line;
|
||||
gHUD.DrawDarkRectangle(xpos-5, ypos_r - 5, xmax - xpos+10, height + 10);
|
||||
DrawUtils::DrawRectangle(xpos-5, ypos_r - 5, xmax - xpos+10, height + 10);
|
||||
while ( *ch )
|
||||
{
|
||||
int line_length = 0; // count the length of the current line
|
||||
@ -109,7 +109,7 @@ int CHudMOTD :: Draw( float fTime )
|
||||
|
||||
// find where to start drawing the line
|
||||
if( (ypos > ROW_RANGE_MIN) && (ypos + LINE_HEIGHT <= ypos_r + height) )
|
||||
gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 );
|
||||
DrawUtils::DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 );
|
||||
|
||||
ypos += LINE_HEIGHT;
|
||||
|
||||
|
@ -1112,9 +1112,9 @@ int CHudAmmo::Draw(float flTime)
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
ScaleColors(r, g, b, a );
|
||||
DrawUtils::DrawUtils::ScaleColors(r, g, b, a );
|
||||
|
||||
// Does this weapon have a clip?
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
|
||||
@ -1129,7 +1129,7 @@ int CHudAmmo::Draw(float flTime)
|
||||
// room for the number and the '|' and the current ammo
|
||||
|
||||
x = ScreenWidth - (8 * AmmoWidth) - iIconWidth;
|
||||
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b);
|
||||
x = DrawUtils::DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b);
|
||||
|
||||
wrect_t rc;
|
||||
rc.top = 0;
|
||||
@ -1141,7 +1141,7 @@ int CHudAmmo::Draw(float flTime)
|
||||
|
||||
x += AmmoWidth/2;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
// draw the | bar
|
||||
FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a);
|
||||
@ -1149,8 +1149,8 @@ int CHudAmmo::Draw(float flTime)
|
||||
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);
|
||||
DrawUtils::ScaleColors(r, g, b, a );
|
||||
x = DrawUtils::DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
|
||||
|
||||
|
||||
}
|
||||
@ -1158,7 +1158,7 @@ int CHudAmmo::Draw(float flTime)
|
||||
{
|
||||
// SPR_Draw a bullets only line
|
||||
x = ScreenWidth - 4 * AmmoWidth - iIconWidth;
|
||||
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
|
||||
x = DrawUtils::DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
|
||||
}
|
||||
|
||||
// Draw the ammo Icon
|
||||
@ -1177,7 +1177,7 @@ int CHudAmmo::Draw(float flTime)
|
||||
{
|
||||
y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight/4;
|
||||
x = ScreenWidth - 4 * AmmoWidth - iIconWidth;
|
||||
x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, gWR.CountAmmo(pw->iAmmo2Type), r, g, b);
|
||||
x = DrawUtils::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);
|
||||
@ -1433,13 +1433,13 @@ int DrawBar(int x, int y, int width, int height, float f)
|
||||
// Always show at least one pixel if we have ammo.
|
||||
if (w <= 0)
|
||||
w = 1;
|
||||
UnpackRGB(r, g, b, RGB_GREENISH);
|
||||
DrawUtils::UnpackRGB(r, g, b, RGB_GREENISH);
|
||||
FillRGBA(x, y, w, height, r, g, b, 255);
|
||||
x += w;
|
||||
width -= w;
|
||||
}
|
||||
|
||||
UnpackRGB(r, g, b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r, g, b, RGB_YELLOWISH);
|
||||
|
||||
FillRGBA(x, y, width, height, r, g, b, 128);
|
||||
|
||||
@ -1515,14 +1515,14 @@ int CHudAmmo::DrawWList(float flTime)
|
||||
{
|
||||
int iWidth;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if ( iActiveSlot == i )
|
||||
a = 255;
|
||||
else
|
||||
a = 192;
|
||||
|
||||
ScaleColors(r, g, b, 255);
|
||||
DrawUtils::ScaleColors(r, g, b, 255);
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b );
|
||||
|
||||
// make active slot wide enough to accomodate gun pictures
|
||||
@ -1571,13 +1571,13 @@ int CHudAmmo::DrawWList(float flTime)
|
||||
// if active, then we must have ammo.
|
||||
if ( gWR.HasAmmo(p) )
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH );
|
||||
ScaleColors(r, g, b, 192);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH );
|
||||
DrawUtils::ScaleColors(r, g, b, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
ScaleColors(r, g, b, 128);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
|
||||
DrawUtils::ScaleColors(r, g, b, 128);
|
||||
}
|
||||
|
||||
|
||||
@ -1610,7 +1610,7 @@ int CHudAmmo::DrawWList(float flTime)
|
||||
{
|
||||
// Draw Row of weapons.
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
for ( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ )
|
||||
{
|
||||
@ -1621,12 +1621,12 @@ int CHudAmmo::DrawWList(float flTime)
|
||||
|
||||
if ( gWR.HasAmmo(p) )
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
a = 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
|
||||
a = 96;
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,11 @@ int CHudAmmoSecondary :: Draw(float flTime)
|
||||
|
||||
// draw secondary ammo icons above normal ammo readout
|
||||
int a, x, y, r, g, b, AmmoWidth;
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
a = (int) max( MIN_ALPHA, m_fFade );
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
DrawUtils::ScaleColors( r, g, b, a );
|
||||
|
||||
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
|
||||
@ -96,8 +96,8 @@ int CHudAmmoSecondary :: Draw(float flTime)
|
||||
x -= (AmmoWidth / 2);
|
||||
|
||||
// draw the number, right-aligned
|
||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
x -= (DrawUtils::GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
DrawUtils::DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
|
||||
if ( i != 0 )
|
||||
{
|
||||
|
@ -125,9 +125,9 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
// Draw the pic
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
@ -139,7 +139,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
}
|
||||
|
||||
// Draw the number
|
||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
||||
{
|
||||
@ -149,13 +149,13 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if ( !gWR.HasAmmo( weap ) )
|
||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
||||
@ -171,9 +171,9 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
|
||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
||||
|
@ -90,7 +90,7 @@ int CHudBattery::Draw( float flTime )
|
||||
// battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
||||
rc.top += m_iHeight * ((float)( 100 - ( min( 100, m_iBat ))) * 0.01f );
|
||||
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if( m_fFade )
|
||||
@ -115,7 +115,7 @@ int CHudBattery::Draw( float flTime )
|
||||
a = MIN_ALPHA;
|
||||
}
|
||||
|
||||
ScaleColors( r, g, b, a );
|
||||
DrawUtils::ScaleColors( r, g, b, a );
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = ScreenWidth / 5;
|
||||
@ -131,7 +131,7 @@ int CHudBattery::Draw( float flTime )
|
||||
}
|
||||
|
||||
x += (m_hEmpty[m_enArmorType].rect.right - m_hEmpty[m_enArmorType].rect.left);
|
||||
x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS|DHN_DRAWZERO, m_iBat, r, g, b );
|
||||
x = DrawUtils::DrawHudNumber( x, y, DHN_3DIGITS|DHN_DRAWZERO, m_iBat, r, g, b );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -98,19 +98,18 @@ int CHudDeathNotice :: Draw( float flTime )
|
||||
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!!
|
||||
|
||||
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
|
||||
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
x = ScreenWidth - DrawUtils::ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
if( rgDeathNoticeList[i].iHeadShotId )
|
||||
x -= gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left;
|
||||
|
||||
if ( !rgDeathNoticeList[i].bSuicide )
|
||||
{
|
||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
x -= (5 + DrawUtils::ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
|
||||
// Draw killers name
|
||||
if ( rgDeathNoticeList[i].KillerColor )
|
||||
//gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
@ -136,9 +135,8 @@ int CHudDeathNotice :: Draw( float flTime )
|
||||
if (!rgDeathNoticeList[i].bNonPlayerKill)
|
||||
{
|
||||
if ( rgDeathNoticeList[i].VictimColor )
|
||||
//gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ int CHudFlashlight::Draw(float flTime)
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if (m_flBat < 0.20)
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
DrawUtils::ScaleColors(r, g, b, a);
|
||||
|
||||
y = (m_hSprite1.rect.bottom - m_hSprite1.rect.top)/2;
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
|
@ -181,7 +181,7 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b )
|
||||
#else
|
||||
if (m_iHealth > 25)
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -227,7 +227,7 @@ int CHudHealth::Draw(float flTime)
|
||||
a = 255;
|
||||
|
||||
GetPainColor( r, g, b );
|
||||
ScaleColors(r, g, b, a );
|
||||
DrawUtils::ScaleColors(r, g, b, a );
|
||||
|
||||
// Only draw health if we have the suit.
|
||||
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
|
||||
@ -243,7 +243,7 @@ int CHudHealth::Draw(float flTime)
|
||||
|
||||
x = CrossWidth + HealthWidth / 2;
|
||||
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
|
||||
x = DrawUtils::DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
|
||||
|
||||
x += HealthWidth/2;
|
||||
|
||||
@ -333,7 +333,7 @@ int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackFront, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
DrawUtils::ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
|
||||
@ -347,7 +347,7 @@ int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRight, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
DrawUtils::ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
|
||||
@ -361,7 +361,7 @@ int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRear, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
DrawUtils::ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
|
||||
@ -375,7 +375,7 @@ int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackLeft, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
DrawUtils::ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
|
||||
@ -397,11 +397,11 @@ int CHudHealth::DrawDamage(float flTime)
|
||||
if (!m_bitsDamage)
|
||||
return 1;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
a = (int)( fabs(sin(flTime*2)) * 256.0);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
DrawUtils::ScaleColors(r, g, b, a);
|
||||
int i;
|
||||
// Draw all the items
|
||||
for (i = 0; i < NUM_DMG_TYPES; i++)
|
||||
|
@ -173,278 +173,3 @@ int CHud :: Redraw( float flTime, int intermission )
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a )
|
||||
{
|
||||
float x = (float)a / 255;
|
||||
r = (int)(r * x);
|
||||
g = (int)(g * x);
|
||||
b = (int)(b * x);
|
||||
}
|
||||
|
||||
int CHud :: DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b, bool drawing )
|
||||
{
|
||||
int first_xpos = xpos;
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
int next = xpos + gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; // variable-width fonts look cool
|
||||
if ( next > iMaxX )
|
||||
return xpos;
|
||||
|
||||
if( *szIt == '\\' && *(szIt+1) != '\n' && *(szIt+1) != 0)
|
||||
{
|
||||
// an escape character
|
||||
|
||||
switch( *(++szIt) )
|
||||
{
|
||||
case 'y':
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
continue;
|
||||
case 'w':
|
||||
r = g = b = 255;
|
||||
continue;
|
||||
case 'd':
|
||||
continue;
|
||||
case 'R':
|
||||
//if( drawing ) return xpos;
|
||||
//return DrawHudStringReverse( iMaxX, ypos, first_xpos, szIt, r, g, b, true ); // set 'drawing' to true, to stop when '\R' is catched
|
||||
xpos = iMaxX - gHUD.m_scrinfo.charWidths[ 'M' ] * 10;
|
||||
++szIt;
|
||||
}
|
||||
}
|
||||
|
||||
xpos += TextMessageDrawChar( xpos, ypos, *szIt, r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudStringLen( char *szIt )
|
||||
{
|
||||
int l = 0;
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; // variable-width fonts look cool
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
|
||||
{
|
||||
char szString[32];
|
||||
snprintf( szString, 32, "%d", iNumber );
|
||||
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
|
||||
|
||||
}
|
||||
|
||||
// draws a string from right to left (right-aligned)
|
||||
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b, bool drawing )
|
||||
{
|
||||
int first_xpos = xpos;
|
||||
|
||||
|
||||
// iterate throug the string in reverse
|
||||
for ( signed int i = strlen(szString); i >= 0; i-- )
|
||||
{
|
||||
int next = xpos - gHUD.m_scrinfo.charWidths[ (unsigned char)szString[i] ]; // variable-width fonts look cool
|
||||
if ( next < iMinX )
|
||||
return xpos;
|
||||
xpos = next;
|
||||
|
||||
if( i > 1 && szString[i - 1] == '\\' )
|
||||
{
|
||||
// an escape character
|
||||
|
||||
switch( szString[i] )
|
||||
{
|
||||
case 'y':
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
break;
|
||||
case 'w':
|
||||
r = g = b = 255;
|
||||
break;
|
||||
case 'R':
|
||||
//if( drawing ) return xpos;
|
||||
//else return DrawHudString( iMinX, ypos, first_xpos, &szString[i - 1], r, g, b, true ); // set 'drawing' to true, to stop when '\R' is catched
|
||||
//xpos = iMinX + gHUD.m_scrinfo.charWidths['M'] * i ;
|
||||
case 'd':
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
TextMessageDrawChar( xpos, ypos, szString[i], r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int CHud::GetNumWidth( int iNumber, int iFlags )
|
||||
{
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
return 3;
|
||||
|
||||
if (iFlags & (DHN_2DIGITS))
|
||||
return 2;
|
||||
|
||||
if (iNumber <= 0)
|
||||
{
|
||||
if (iFlags & (DHN_DRAWZERO))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iNumber < 10)
|
||||
return 1;
|
||||
|
||||
if (iNumber < 100)
|
||||
return 2;
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
void CHud::DrawDarkRectangle(int x, int y, int wide, int tall , int r, int g, int b, int a, bool drawStroke)
|
||||
{
|
||||
FillRGBA( x, y, wide, tall, r, g, b, a );
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
||||
gEngfuncs.pTriAPI->Color4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
gEngfuncs.pTriAPI->Vertex3f(x * m_flScale, (y+tall)*m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f(x * m_flScale, y*m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f((x + wide)*m_flScale, y*m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->Vertex3f((x + wide)*m_flScale, (y+tall)*m_flScale, 0);
|
||||
gEngfuncs.pTriAPI->End();
|
||||
|
||||
if(drawStroke)
|
||||
{
|
||||
// TODO: remove this hardcoded hardcore
|
||||
FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 );
|
||||
}
|
||||
}
|
||||
|
||||
// TANKIST START
|
||||
int CHud :: DrawHudNumber2( int x, int y, bool DrawZero, int iDigits, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = GetSpriteRect( m_HUD_number_0 ).right - GetSpriteRect( m_HUD_number_0 ).left;
|
||||
x += ( iDigits - 1 ) * iWidth;
|
||||
|
||||
int ResX = x + iWidth;
|
||||
do
|
||||
{
|
||||
int k = iNumber % 10;
|
||||
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;
|
||||
iDigits--;
|
||||
}
|
||||
while( iNumber > 0 || ( iDigits > 0 && DrawZero ) );
|
||||
|
||||
return ResX;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudNumber2( int x, int y, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = GetSpriteRect( m_HUD_number_0 ).right - GetSpriteRect( m_HUD_number_0 ).left;
|
||||
|
||||
int iDigits = 0;
|
||||
int temp = iNumber;
|
||||
do
|
||||
{
|
||||
iDigits++;
|
||||
temp /= 10;
|
||||
}
|
||||
while( temp > 0 );
|
||||
|
||||
x += ( iDigits - 1 ) * iWidth;
|
||||
|
||||
int ResX = x + iWidth;
|
||||
do
|
||||
{
|
||||
int k = iNumber % 10;
|
||||
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;
|
||||
}
|
||||
while( iNumber > 0 );
|
||||
|
||||
return ResX;
|
||||
}
|
||||
// TANKIST END
|
||||
|
@ -477,9 +477,8 @@ int CHudSpectator::Draw(float flTime)
|
||||
|
||||
lx = strlen(string)*3; // 3 is avg. character length :)
|
||||
|
||||
//gEngfuncs.pfnDrawSetTextColor( color[0], color[1], color[2] );
|
||||
DrawSetTextColor( color[0], color[1], color[2] );
|
||||
DrawConsoleString( m_vPlayerPos[i][0]-lx,m_vPlayerPos[i][1], string);
|
||||
DrawUtils::SetConsoleTextColor( color[0], color[1], color[2] );
|
||||
DrawUtils::DrawConsoleString( m_vPlayerPos[i][0]-lx,m_vPlayerPos[i][1], string);
|
||||
|
||||
}
|
||||
|
||||
@ -556,7 +555,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
|
||||
|
||||
msg->effect = READ_BYTE(); // effect
|
||||
|
||||
UnpackRGB( (int&)msg->r1, (int&)msg->g1, (int&)msg->b1, READ_LONG() ); // color
|
||||
DrawUtils::UnpackRGB( (int&)msg->r1, (int&)msg->g1, (int&)msg->b1, READ_LONG() ); // color
|
||||
msg->r2 = msg->r1;
|
||||
msg->g2 = msg->g1;
|
||||
msg->b2 = msg->b1;
|
||||
@ -1229,7 +1228,7 @@ void CHudSpectator::DrawOverviewEntities()
|
||||
|
||||
z = m_OverviewData.layersHeights[0] * zScale;
|
||||
// get yellow/brown HUD color
|
||||
UnpackRGB(ir,ig,ib, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(ir,ig,ib, RGB_YELLOWISH);
|
||||
r = (float)ir/255.0f;
|
||||
g = (float)ig/255.0f;
|
||||
b = (float)ib/255.0f;
|
||||
|
@ -116,7 +116,7 @@ int CHudMenu :: Draw( float flTime )
|
||||
i = 0;
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
|
||||
{
|
||||
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
DrawUtils::DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
y += 24;
|
||||
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
|
||||
|
@ -199,7 +199,7 @@ void CHudMessage::MessageScanNextChar( void )
|
||||
if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 )
|
||||
{
|
||||
if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth )
|
||||
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
|
||||
DrawUtils::TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
|
||||
MessageScanNextChar();
|
||||
|
||||
if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth )
|
||||
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b );
|
||||
DrawUtils::TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b );
|
||||
m_parms.x = next;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ int CHudMoney::Draw(float flTime)
|
||||
if( m_iBlinkAmt )
|
||||
{
|
||||
m_fBlinkTime += gHUD.m_flTimeDelta;
|
||||
UnpackRGB( r, g, b, m_fBlinkTime > 0.5f? RGB_REDISH : RGB_YELLOWISH );
|
||||
DrawUtils::UnpackRGB( r, g, b, m_fBlinkTime > 0.5f? RGB_REDISH : RGB_YELLOWISH );
|
||||
|
||||
if( m_fBlinkTime > 1.0f )
|
||||
{
|
||||
@ -70,17 +70,17 @@ int CHudMoney::Draw(float flTime)
|
||||
b = (RGB_REDISH & 0xFF) - interpolate * (RGB_REDISH & 0xFF);
|
||||
}
|
||||
}
|
||||
else UnpackRGB(r, g, b, RGB_YELLOWISH );
|
||||
else DrawUtils::UnpackRGB(r, g, b, RGB_YELLOWISH );
|
||||
}
|
||||
|
||||
alphaBalance = 128 - interpolate * (128 - MIN_ALPHA);
|
||||
|
||||
ScaleColors( r, g, b, alphaBalance );
|
||||
DrawUtils::ScaleColors( r, g, b, alphaBalance );
|
||||
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_dollar), r, g, b);
|
||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_dollar));
|
||||
|
||||
gHUD.DrawHudNumber2( x + iDollarWidth, y, false, 5, m_iMoneyCount, r, g, b );
|
||||
DrawUtils::DrawHudNumber2( x + iDollarWidth, y, false, 5, m_iMoneyCount, r, g, b );
|
||||
FillRGBA(x + iDollarWidth / 4, y + gHUD.m_iFontHeight / 4, 2, 2, r, g, b, alphaBalance );
|
||||
return 1;
|
||||
}
|
||||
|
@ -111,12 +111,12 @@ int CHudRadar::Draw(float flTime)
|
||||
|
||||
if( g_PlayerExtraInfo[i].has_c4 )
|
||||
{
|
||||
UnpackRGB( r, g, b, RGB_REDISH );
|
||||
DrawUtils::UnpackRGB( r, g, b, RGB_REDISH );
|
||||
}
|
||||
else
|
||||
{
|
||||
// white
|
||||
UnpackRGB( r, g, b, 0x00FFFFFF );
|
||||
DrawUtils::UnpackRGB( r, g, b, 0x00FFFFFF );
|
||||
}
|
||||
Vector2D pos = WorldToRadar(gHUD.m_vecOrigin, g_PlayerExtraInfo[i].origin, gHUD.m_vecAngles);
|
||||
float zdiff = gHUD.m_vecOrigin.z - g_PlayerExtraInfo[i].origin.z;
|
||||
@ -206,7 +206,7 @@ int CHudRadar::Draw(float flTime)
|
||||
|
||||
void CHudRadar::DrawPlayerLocation()
|
||||
{
|
||||
DrawConsoleString( 30, 30, g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].location );
|
||||
DrawUtils::DrawConsoleString( 30, 30, g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].location );
|
||||
}
|
||||
|
||||
void CHudRadar::DrawRadarDot(int x, int y, int size, int r, int g, int b, int a)
|
||||
|
@ -136,17 +136,16 @@ int CHudSayText :: Draw( float flTime )
|
||||
// draw the first x characters in the player color
|
||||
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
|
||||
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
|
||||
//gEngfuncs.pfnDrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawConsoleString( LINE_START, y, buf );
|
||||
DrawUtils::SetConsoleTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawUtils::DrawConsoleString( LINE_START, y, buf );
|
||||
|
||||
// color is reset after each string draw
|
||||
DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
|
||||
DrawUtils::DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal draw
|
||||
DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
|
||||
DrawUtils::DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +283,7 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
|
||||
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
||||
{
|
||||
int line_width = 0;
|
||||
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
|
||||
DrawUtils::ConsoleStringSize(g_szLineBuffer[line], &line_width, &line_height );
|
||||
|
||||
if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
|
||||
{ // string is too long to fit on line
|
||||
@ -316,7 +315,7 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
||||
last_break = x;
|
||||
|
||||
buf[0] = *x; // get the length of the current character
|
||||
GetConsoleStringSize( buf, &tmp_len, &line_height );
|
||||
DrawUtils::ConsoleStringSize( buf, &tmp_len, &line_height );
|
||||
length += tmp_len;
|
||||
|
||||
if ( length > MAX_LINE_WIDTH )
|
||||
|
@ -163,15 +163,15 @@ int CHudScoreboard :: DrawScoreboard( float fTime )
|
||||
|
||||
// print the heading line
|
||||
|
||||
gHUD.DrawDarkRectangle(xstart, ystart, xend - xstart, yend - ystart,
|
||||
DrawUtils::DrawRectangle(xstart, ystart, xend - xstart, yend - ystart,
|
||||
m_colors.r, m_colors.g, m_colors.b, m_colors.a, m_bDrawStroke);
|
||||
|
||||
int ypos = ystart + (list_slot * ROW_GAP) + 5;
|
||||
|
||||
gHUD.DrawHudString( NAME_POS_START(), ypos, NAME_POS_END(), (char*)(gHUD.m_Teamplay ? "TEAMS" : "PLAYERS"), 255, 140, 0 );
|
||||
gHUD.DrawHudStringReverse( KILLS_POS_END(), ypos, 0, "KILLS", 255, 140, 0 );
|
||||
gHUD.DrawHudString( DEATHS_POS_START(), ypos, DEATHS_POS_END(), "DEATHS", 255, 140, 0 );
|
||||
gHUD.DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), "PING", 255, 140, 0 );
|
||||
DrawUtils::DrawHudString( NAME_POS_START(), ypos, NAME_POS_END(), (char*)(gHUD.m_Teamplay ? "TEAMS" : "PLAYERS"), 255, 140, 0 );
|
||||
DrawUtils::DrawHudStringReverse( KILLS_POS_END(), ypos, 0, "KILLS", 255, 140, 0 );
|
||||
DrawUtils::DrawHudString( DEATHS_POS_START(), ypos, DEATHS_POS_END(), "DEATHS", 255, 140, 0 );
|
||||
DrawUtils::DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), "PING", 255, 140, 0 );
|
||||
|
||||
list_slot += 2;
|
||||
ypos = ystart + (list_slot * ROW_GAP);
|
||||
@ -283,13 +283,13 @@ int CHudScoreboard :: DrawTeams( float list_slot )
|
||||
{
|
||||
GetTeamColor( r, g, b, TEAM_TERRORIST );
|
||||
snprintf(teamName, sizeof(teamName), "Terrorists - %i players", team_info->players);
|
||||
gHUD.DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b );
|
||||
}
|
||||
else if( !strcmp(team_info->name, "CT"))
|
||||
{
|
||||
GetTeamColor( r, g, b, TEAM_CT );
|
||||
snprintf(teamName, sizeof(teamName), "Counter-Terrorists - %i players", team_info->players);
|
||||
gHUD.DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b );
|
||||
}
|
||||
else if( !strcmp(team_info->name, "SPECTATOR" ) )
|
||||
{
|
||||
@ -301,9 +301,8 @@ int CHudScoreboard :: DrawTeams( float list_slot )
|
||||
GetTeamColor( r, g, b, TEAM_UNASSIGNED );
|
||||
strncpy( teamName, team_info->name, sizeof(teamName) );
|
||||
}
|
||||
//gHUD.DrawHudNumberString( DEATHS_POS_START(), ypos, DEATHS_POS_END(), team_info->deaths, r, g, b );
|
||||
gHUD.DrawHudString( NAME_POS_START(), ypos, NAME_POS_END(), teamName, r, g, b );
|
||||
gHUD.DrawHudNumberString( PING_POS_END(), ypos, PING_POS_START(), team_info->sumping / team_info->players, r, g, b );
|
||||
DrawUtils::DrawHudString( NAME_POS_START(), ypos, NAME_POS_END(), teamName, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( PING_POS_END(), ypos, PING_POS_START(), team_info->sumping / team_info->players, r, g, b );
|
||||
|
||||
team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again
|
||||
|
||||
@ -378,26 +377,26 @@ int CHudScoreboard :: DrawPlayers( float list_slot, int nameoffset, char *team )
|
||||
}
|
||||
|
||||
|
||||
gHUD.DrawHudString( NAME_POS_START() + nameoffset, ypos, NAME_POS_END(), pl_info->name, r, g, b );
|
||||
DrawUtils::DrawHudString( NAME_POS_START() + nameoffset, ypos, NAME_POS_END(), pl_info->name, r, g, b );
|
||||
|
||||
// draw bomb( if player have the bomb )
|
||||
if( g_PlayerExtraInfo[best_player].dead )
|
||||
gHUD.DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Dead", r, g, b );
|
||||
DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Dead", r, g, b );
|
||||
else if( g_PlayerExtraInfo[best_player].has_c4 )
|
||||
gHUD.DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Bomb", r, g, b );
|
||||
DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Bomb", r, g, b );
|
||||
else if( g_PlayerExtraInfo[best_player].vip )
|
||||
gHUD.DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "VIP", r, g, b );
|
||||
DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "VIP", r, g, b );
|
||||
|
||||
// draw kills (right to left)
|
||||
gHUD.DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), g_PlayerExtraInfo[best_player].frags, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), g_PlayerExtraInfo[best_player].frags, r, g, b );
|
||||
|
||||
// draw deaths
|
||||
gHUD.DrawHudNumberString( DEATHS_POS_END(), ypos, DEATHS_POS_START(), g_PlayerExtraInfo[best_player].deaths, r, g, b );
|
||||
DrawUtils::DrawHudNumberString( DEATHS_POS_END(), ypos, DEATHS_POS_START(), g_PlayerExtraInfo[best_player].deaths, r, g, b );
|
||||
|
||||
// draw ping & packetloss
|
||||
static char buf[64];
|
||||
sprintf( buf, "%d", g_PlayerInfoList[best_player].ping );
|
||||
gHUD.DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), buf, r, g, b );
|
||||
DrawUtils::DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), buf, r, g, b );
|
||||
|
||||
pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again
|
||||
list_slot++;
|
||||
|
@ -217,7 +217,7 @@ int CHudStatusBar :: Draw( float fTime )
|
||||
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
||||
{
|
||||
int TextHeight, TextWidth;
|
||||
GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
|
||||
DrawUtils::ConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
|
||||
|
||||
int x = 4;
|
||||
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
|
||||
@ -230,9 +230,8 @@ int CHudStatusBar :: Draw( float fTime )
|
||||
}
|
||||
|
||||
if ( m_pflNameColors[i] )
|
||||
//gEngfuncs.pfnDrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
DrawUtils::DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -41,7 +41,7 @@ int CHudTimer::Draw( float fTime )
|
||||
|
||||
if( minutes * 60 + seconds > 20 )
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH );
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -52,10 +52,10 @@ int CHudTimer::Draw( float fTime )
|
||||
m_flPanicTime = 0;
|
||||
m_bPanicColorChange = !m_bPanicColorChange;
|
||||
}
|
||||
UnpackRGB( r, g, b, m_bPanicColorChange ? RGB_YELLOWISH : RGB_REDISH );
|
||||
DrawUtils::UnpackRGB( r, g, b, m_bPanicColorChange ? RGB_YELLOWISH : RGB_REDISH );
|
||||
}
|
||||
|
||||
ScaleColors( r, g, b, MIN_ALPHA );
|
||||
DrawUtils::ScaleColors( r, g, b, MIN_ALPHA );
|
||||
|
||||
|
||||
int iWatchWidth = gHUD.GetSpriteRect(m_HUD_timer).right - gHUD.GetSpriteRect(m_HUD_timer).left;
|
||||
@ -66,12 +66,12 @@ int CHudTimer::Draw( float fTime )
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_timer), r, g, b);
|
||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_timer));
|
||||
|
||||
x = gHUD.DrawHudNumber2( x + iWatchWidth / 4, y, false, 2, minutes, r, g, b );
|
||||
x = DrawUtils::DrawHudNumber2( x + iWatchWidth / 4, y, false, 2, minutes, r, g, b );
|
||||
// draw :
|
||||
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
|
||||
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight - gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
|
||||
|
||||
gHUD.DrawHudNumber2( x + iWatchWidth / 2, y, true, 2, seconds, r, g, b );
|
||||
DrawUtils::DrawHudNumber2( x + iWatchWidth / 2, y, true, 2, seconds, r, g, b );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -130,10 +130,10 @@ int CHudProgressBar::Draw( float flTime )
|
||||
if( m_szLocalizedHeader && m_szLocalizedHeader[0] )
|
||||
{
|
||||
int r, g, b;
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
gHUD.DrawHudString( ScreenWidth / 4, ScreenHeight / 2, ScreenWidth, (char*)m_szLocalizedHeader, r, g, b );
|
||||
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
DrawUtils::DrawHudString( ScreenWidth / 4, ScreenHeight / 2, ScreenWidth, (char*)m_szLocalizedHeader, r, g, b );
|
||||
|
||||
gHUD.DrawDarkRectangle( ScreenWidth/ 4, ScreenHeight / 2 + gHUD.m_scrinfo.iCharHeight, ScreenWidth/2, ScreenHeight/30 );
|
||||
DrawUtils::DrawRectangle( ScreenWidth/ 4, ScreenHeight / 2 + gHUD.m_scrinfo.iCharHeight, ScreenWidth/2, ScreenHeight/30 );
|
||||
FillRGBA( ScreenWidth/4+2, ScreenHeight/2 + gHUD.m_scrinfo.iCharHeight + 2, m_fPercent * (ScreenWidth/2-4), ScreenHeight/30-4, 255, 140, 0, 255 );
|
||||
return 1;
|
||||
}
|
||||
@ -150,7 +150,7 @@ int CHudProgressBar::Draw( float flTime )
|
||||
return 1;
|
||||
}
|
||||
|
||||
gHUD.DrawDarkRectangle( ScreenWidth/4, ScreenHeight*2/3, ScreenWidth/2, 10 );
|
||||
DrawUtils::DrawRectangle( ScreenWidth/4, ScreenHeight*2/3, ScreenWidth/2, 10 );
|
||||
FillRGBA( ScreenWidth/4+2, ScreenHeight*2/3+2, m_fPercent * (ScreenWidth/2-4), 6, 255, 140, 0, 255 );
|
||||
|
||||
return 1;
|
||||
|
@ -54,7 +54,7 @@ int CHudTrain::Draw(float fTime)
|
||||
{
|
||||
int r, g, b, x, y;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
// This should show up to the right and part way up the armor number
|
||||
|
@ -96,51 +96,6 @@ inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f)
|
||||
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
|
||||
|
||||
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
|
||||
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
||||
{
|
||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
||||
}
|
||||
|
||||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
{
|
||||
int ret = gHUD.DrawHudString( x, y, 9999, (char*)string, (int) 255*color[0], (int) 255*color[1], (int) 255*color[2]);
|
||||
color[0] = color[1] = color[2] = 1.0f;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
|
||||
}
|
||||
inline int DrawSetTextColor(float r, float g, float b)
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
color[0]=r, color[1] = g, color[2] = b;
|
||||
else
|
||||
gEngfuncs.pfnDrawSetTextColor( r, g, b );
|
||||
|
||||
return 0;
|
||||
}
|
||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
if( hud_textmode->value )
|
||||
*height = 13, *width = gHUD.DrawHudStringLen((char*)string);
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
|
||||
}
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width, _height;
|
||||
if( hud_textmode->value )
|
||||
return gHUD.DrawHudStringLen((char*)string);
|
||||
else
|
||||
{
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
}
|
||||
|
||||
inline void ConsolePrint( const char *string )
|
||||
{
|
||||
@ -162,9 +117,6 @@ inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex(
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a );
|
||||
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
||||
@ -183,13 +135,6 @@ extern vec3_t vec3_origin;
|
||||
// disable 'truncation from 'const double' to 'float' warning message
|
||||
#pragma warning( disable: 4305 )
|
||||
|
||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
||||
{\
|
||||
r = (ulRGB & 0xFF0000) >>16;\
|
||||
g = (ulRGB & 0xFF00) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
}
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName);
|
||||
float *GetClientColor( int clientIndex );
|
||||
void GetTeamColor( int &r, int &g, int &b, int teamIndex );
|
||||
|
93
cl_dll/include/draw_util.h
Normal file
93
cl_dll/include/draw_util.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef DRAW_UTIL_H
|
||||
#define DRAW_UTIL_H
|
||||
// Drawing primitives
|
||||
|
||||
class DrawUtils
|
||||
{
|
||||
public:
|
||||
static void DrawRectangle( int x, int y, int wide, int tall,
|
||||
int r = 0, int g = 0, int b = 0, int a = 153,
|
||||
bool drawStroke = true );
|
||||
|
||||
static int DrawHudNumber(int x, int y, int iFlags, int iNumber,
|
||||
int r, int g, int b );
|
||||
|
||||
static int DrawHudNumber2( int x, int y, bool DrawZero, int iDigits, int iNumber,
|
||||
int r, int g, int b);
|
||||
|
||||
static int DrawHudNumber2( int x, int y, int iNumber,
|
||||
int r, int g, int b);
|
||||
|
||||
static int DrawHudString(int x, int y, int iMaxX, char *szString,
|
||||
int r, int g, int b, bool drawing = false );
|
||||
|
||||
static int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString,
|
||||
int r, int g, int b, bool drawing = false );
|
||||
|
||||
static int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber,
|
||||
int r, int g, int b );
|
||||
|
||||
static int HudStringLen( char *szIt );
|
||||
|
||||
static int GetNumWidth(int iNumber, int iFlags);
|
||||
|
||||
static int DrawConsoleString(int x, int y, const char *string);
|
||||
|
||||
static void SetConsoleTextColor( float r, float g, float b );
|
||||
|
||||
static void SetConsoleTextColor( unsigned char r, unsigned char g, unsigned char b );
|
||||
|
||||
static int ConsoleStringLen( const char *szIt );
|
||||
|
||||
static void ConsoleStringSize( const char *szIt, int *width, int *height );
|
||||
|
||||
static int TextMessageDrawChar( int x, int y, int number, int r, int g, int b );
|
||||
|
||||
static inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)
|
||||
{
|
||||
r = (ulRGB & 0xFF0000) >>16;
|
||||
g = (ulRGB & 0xFF00) >> 8;
|
||||
b = ulRGB & 0xFF;
|
||||
}
|
||||
|
||||
static inline void ScaleColors( int &r, int &g, int &b, int a )
|
||||
{
|
||||
float x = (float)a / 255;
|
||||
r = (int)(r * x);
|
||||
g = (int)(g * x);
|
||||
b = (int)(b * x);
|
||||
}
|
||||
private:
|
||||
// console string color
|
||||
static float color[3];
|
||||
};
|
||||
|
||||
#endif // DRAW_UTIL_H
|
@ -30,6 +30,7 @@
|
||||
#include "ammo.h"
|
||||
|
||||
#include "csprite.h"
|
||||
#include "draw_util.h"
|
||||
|
||||
#define DHN_DRAWZERO 1
|
||||
#define DHN_2DIGITS 2
|
||||
@ -807,17 +808,7 @@ public:
|
||||
int UpdateClientData( client_data_t *cdata, float time );
|
||||
void AddHudElem(CHudBase *p);
|
||||
|
||||
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
|
||||
int DrawHudNumber2( int x, int y, bool DrawZero, int iDigits, int iNumber, int r, int g, int b);
|
||||
int DrawHudNumber2( int x, int y, int iNumber, int r, int g, int b);
|
||||
int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b, bool drawing = false );
|
||||
int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b, bool drawing = false );
|
||||
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
|
||||
int DrawHudStringLen( char *szIt );
|
||||
void DrawDarkRectangle( int x, int y, int wide, int tall, int r = 0, int g = 0, int b = 0, int a = 153, bool drawStroke = true );
|
||||
|
||||
float GetSensitivity();
|
||||
int GetNumWidth(int iNumber, int iFlags);
|
||||
HSPRITE GetSprite( int index );
|
||||
wrect_t& GetSpriteRect( int index );
|
||||
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
|
||||
|
Loading…
Reference in New Issue
Block a user