diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index e9be621..01fd1b7 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -271,6 +271,9 @@ void CHud :: Init( void ) m_Scoreboard.Init(); m_Menu.Init(); m_MOTD.Init(); + m_Radio.Init(); + m_Timer.Init(); + m_Money.Init(); //ServersInit(); @@ -423,6 +426,8 @@ void CHud :: VidInit( void ) m_StatusIcons.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); + m_Timer.VidInit(); + m_Money.VidInit(); } int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 8599f3b..1035354 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -383,6 +383,7 @@ public: void Reset( void ); int Draw( float flTime ); int MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ); void SelectMenuItem( int menu_item ); @@ -390,6 +391,7 @@ public: int m_bitsValidSlots; float m_flShutoffTime; int m_fWaitingForMore; + }; // @@ -571,6 +573,64 @@ private: }; + +// +//----------------------------------------------------- +// +class CHudMoney : public CHudBase +{ +public: + int Init( void ); + int VidInit( void ); + int Draw( float flTime ); + int MsgFunc_Money( const char *pszName, int iSize, void *pbuf ); + +private: + int m_iMoneyCount; + HSPRITE m_hSprite; +}; +// +//----------------------------------------------------- +// +class CHudRadio: public CHudBase +{ +public: + int Init( void ); + int VidInit( void ); + int Draw( float flTime ); + // play a sentence from a radio + // [byte] unknown (always 1) + // [string] sentence name + // [short] unknown. (always 100, it's a volume?) + int MsgFunc_SendAudio( const char *pszName, int iSize, void *pbuf ); +private: + int m_bFirst; + char m_sentence[64]; + int m_sThird; + bool m_enableRadio; +}; + +// +//----------------------------------------------------- +// +class CHudTimer: public CHudBase +{ +public: + int Init( void ); + int VidInit( void ); + int Draw(float fTime); + // set up the timer. + // [short] + int MsgFunc_RoundTime(const char *pszName, int iSize, void *pbuf); + int MsgFunc_KillTimer(const char *pszName, int iSize, void *pbuf); + // show the timer + // [empty] + int MsgFunc_ShowTimer(const char *pszName, int iSize, void *pbuf); + int m_HUD_timer; + bool ShowTimer; + int Time; + float StartTime; +}; // //----------------------------------------------------- // @@ -602,12 +662,15 @@ public: int m_iFOV; int m_Teamplay; int m_iRes; + int RealSize; float m_flScale; cvar_t *m_pCvarStealMouse; cvar_t *m_pCvarDraw; int m_iFontHeight; 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 ); 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 ); @@ -653,6 +716,9 @@ public: CHudStatusIcons m_StatusIcons; CHudScoreboard m_Scoreboard; CHudMOTD m_MOTD; + CHudMoney m_Money; + CHudTimer m_Timer; + CHudRadio m_Radio; void Init( void ); void VidInit( void ); diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index a74e164..ec1004a 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -363,3 +363,53 @@ void CHud::DrawDarkRectangle( int x, int y, int wide, int tall ) 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 diff --git a/cl_dll/money.cpp b/cl_dll/money.cpp new file mode 100644 index 0000000..eb5e0ee --- /dev/null +++ b/cl_dll/money.cpp @@ -0,0 +1,51 @@ +#include "stdio.h" +#include "stdlib.h" +#include "math.h" + +#include "hud.h" +#include "cl_util.h" +#include "parsemsg.h" +#include +DECLARE_MESSAGE( m_Money, Money ) + +int CHudMoney::Init( ) +{ + HOOK_MESSAGE( Money ); + gHUD.AddHudElem(this); + m_iFlags = HUD_ACTIVE; + return 1; +} + +int CHudMoney::Draw(float flTime) +{ + if(( gHUD.m_iHideHUDDisplay & ( HIDEHUD_HEALTH ) )) + return 1; + int r, g, b; + UnpackRGB(r,g,b, RGB_YELLOWISH); + + int iDollarWidth = gHUD.GetSpriteRect(m_hSprite).right - gHUD.GetSpriteRect(m_hSprite).left; + + int x = ScreenWidth - iDollarWidth * 7; + int y = ScreenHeight - 3 * gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; + + SPR_Set(gHUD.GetSprite(m_hSprite), r, g, b); + SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_hSprite)); + + gHUD.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, 128 ); + return 1; +} + +int CHudMoney::VidInit() +{ + m_hSprite = gHUD.GetSpriteIndex( "dollar" ); + + return 1; +} + +int CHudMoney::MsgFunc_Money(const char *pszName, int iSize, void *pbuf) +{ + BEGIN_READ( pbuf, iSize ); + m_iMoneyCount = READ_LONG(); + return 1; +} diff --git a/cl_dll/radio.cpp b/cl_dll/radio.cpp new file mode 100644 index 0000000..d1d4aa3 --- /dev/null +++ b/cl_dll/radio.cpp @@ -0,0 +1,55 @@ + +#include "hud.h" +#include "parsemsg.h" +#include "cl_util.h" +#include + +DECLARE_MESSAGE( m_Radio, SendAudio ) + +int CHudRadio::Init( ) +{ + HOOK_MESSAGE( SendAudio ); + gHUD.AddHudElem(this); + m_iFlags = HUD_ACTIVE; + m_enableRadio = false; + return 1; +} + +int CHudRadio::Draw(float flTime) +{ + if( !m_enableRadio ) return 1; + + if( m_sentence[0] == '%' ) + PlaySound( &m_sentence[1], 100.0 ); + else + PlaySound( m_sentence, 100.0 ); + + m_enableRadio = false; + + return 1; +} + +int CHudRadio::VidInit() +{ + return 1; +} + +int CHudRadio::MsgFunc_SendAudio(const char *pszName, int iSize, void *pbuf) +{ + BEGIN_READ( pbuf, iSize ); + + m_bFirst = READ_BYTE( ); + strcpy( m_sentence, READ_STRING( )); + m_sThird = READ_SHORT( ); + m_enableRadio = true; + + return 1; +} + +void Broadcast( const char *sentence ) +{ + if( sentence[0] == '%' ) + PlaySound( (char*)&sentence[1], 100.0 ); + else + PlaySound( (char*)sentence, 100.0 ); +} diff --git a/cl_dll/timer.cpp b/cl_dll/timer.cpp new file mode 100644 index 0000000..1b70a4d --- /dev/null +++ b/cl_dll/timer.cpp @@ -0,0 +1,82 @@ +#include "stdio.h" +#include "stdlib.h" +#include "math.h" + +#include "hud.h" +#include "cl_util.h" +#include "parsemsg.h" +#include + +DECLARE_MESSAGE( m_Timer, RoundTime ) +DECLARE_MESSAGE( m_Timer, KillTimer ) +DECLARE_MESSAGE( m_Timer, ShowTimer ) + +int CHudTimer::Init() +{ + HOOK_MESSAGE( RoundTime ); + HOOK_MESSAGE( KillTimer ); + HOOK_MESSAGE( ShowTimer ); + ShowTimer = false; + m_iFlags = HUD_ACTIVE; + gHUD.AddHudElem(this); + return 1; +} + +int CHudTimer::VidInit() +{ + ShowTimer = false; + m_HUD_timer = gHUD.GetSpriteIndex( "stopwatch" ); + return 1; +} + +int CHudTimer::Draw( float fTime ) +{ + if ( ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) || ( !ShowTimer ) ) + return 1; + int r, g, b; + UnpackRGB(r,g,b, RGB_YELLOWISH); + + int iWatchWidth = gHUD.GetSpriteRect(m_HUD_timer).right - gHUD.GetSpriteRect(m_HUD_timer).left; + + int x = ScreenWidth/2; + int y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; + + SPR_Set(gHUD.GetSprite(m_HUD_timer), r, g, b); + SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_timer)); + + int minutes = (int)( Time + StartTime - gHUD.m_flTime ) / 60; + int seconds = (int)( Time + StartTime - gHUD.m_flTime ) - (minutes * 60); + + if( minutes < 0 ) + minutes = 0; + if( seconds < 0 ) + seconds = 0; + + x = gHUD.DrawHudNumber2( x + iWatchWidth * 2, y, true, 2, minutes, r, g, b ); + FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 220); + FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight - gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 220); + gHUD.DrawHudNumber2( x + iWatchWidth / 2, y, true, 2, seconds, r, g, b ); + return 1; +} + +int CHudTimer::MsgFunc_RoundTime(const char *pszName, int iSize, void *pbuf) +{ + BEGIN_READ( pbuf, iSize ); + Time = READ_SHORT(); + StartTime = gHUD.m_flTime; + ShowTimer = true; + return 1; +} + +int CHudTimer::MsgFunc_ShowTimer(const char *pszName, int iSize, void *pbuf) +{ + ShowTimer = true; + return 1; +} + +int CHudTimer::MsgFunc_KillTimer(const char *pszName, int iSize, void *pbuf) +{ + ShowTimer = false; + return 1; +} +