You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
4.6 KiB
226 lines
4.6 KiB
/*** |
|
* |
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. |
|
* |
|
* This product contains software technology licensed from Id |
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
|
* All Rights Reserved. |
|
* |
|
* Use, distribution, and modification of this source code and/or resulting |
|
* object code is restricted to non-commercial enhancements to products from |
|
* Valve LLC. All other use, distribution, or modification is prohibited |
|
* without written permission from Valve LLC. |
|
* |
|
****/ |
|
|
|
#include "hud.h" |
|
#include "cl_util.h" |
|
#include "parsemsg.h" |
|
|
|
#include "const.h" |
|
#include "entity_state.h" |
|
#include "cl_entity.h" |
|
#include "entity_types.h" |
|
#include "usercmd.h" |
|
#include "pm_defs.h" |
|
#include "pm_materials.h" |
|
#include "ref_params.h" |
|
#include <string.h> |
|
//#include "vgui_viewport.h" |
|
//#include "vgui_ScorePanel.h" |
|
|
|
#define RED_FLAG_STOLE 1 |
|
#define BLUE_FLAG_STOLE 2 |
|
#define RED_FLAG_LOST 3 |
|
#define BLUE_FLAG_LOST 4 |
|
#define RED_FLAG_ATBASE 5 |
|
#define BLUE_FLAG_ATBASE 6 |
|
|
|
#define ITEM_RUNE1_FLAG 1 |
|
#define ITEM_RUNE2_FLAG 2 |
|
#define ITEM_RUNE3_FLAG 3 |
|
#define ITEM_RUNE4_FLAG 4 |
|
|
|
DECLARE_MESSAGE(m_FlagStat, FlagStat) |
|
DECLARE_MESSAGE(m_FlagStat, RuneStat) |
|
DECLARE_MESSAGE(m_FlagStat, FlagCarrier) |
|
|
|
int CHudFlagStatus::Init(void) |
|
{ |
|
HOOK_MESSAGE( FlagStat ); |
|
HOOK_MESSAGE( RuneStat ); |
|
HOOK_MESSAGE( FlagCarrier ); |
|
|
|
m_iFlags |= HUD_ACTIVE; |
|
|
|
gHUD.AddHudElem(this); |
|
|
|
Reset(); |
|
|
|
return 1; |
|
}; |
|
|
|
int CHudFlagStatus::VidInit() |
|
{ |
|
m_hBlueAtBase = gHUD.GetSprite( gHUD.GetSpriteIndex( "blue_atbase" ) ); |
|
m_hBlueLost = gHUD.GetSprite( gHUD.GetSpriteIndex( "blue_lost" ) ); |
|
m_hBlueStolen = gHUD.GetSprite( gHUD.GetSpriteIndex( "blue_stolen" ) ); |
|
|
|
m_hRedAtBase = gHUD.GetSprite( gHUD.GetSpriteIndex( "red_atbase" ) ); |
|
m_hRedLost = gHUD.GetSprite( gHUD.GetSpriteIndex( "red_lost" ) ); |
|
m_hRedStolen = gHUD.GetSprite( gHUD.GetSpriteIndex( "red_stolen" ) ); |
|
|
|
m_hRune1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "rune1" ) ); |
|
m_hRune2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "rune2" ) ); |
|
m_hRune3 = gHUD.GetSprite( gHUD.GetSpriteIndex( "rune3" ) ); |
|
m_hRune4 = gHUD.GetSprite( gHUD.GetSpriteIndex( "rune4" ) ); |
|
|
|
// Load sprites here |
|
m_hBlueFlag = gHUD.GetSprite( gHUD.GetSpriteIndex( "b_flag_c" ) ); |
|
m_hRedFlag = gHUD.GetSprite( gHUD.GetSpriteIndex( "r_flag_c" ) ); |
|
|
|
return 1; |
|
} |
|
|
|
void CHudFlagStatus::Reset() |
|
{ |
|
return; |
|
} |
|
|
|
int CHudFlagStatus::Draw( float flTime ) |
|
{ |
|
HSPRITE hSprite = 0; |
|
int iDigits = DHN_DRAWZERO; |
|
|
|
if( !iDrawStatus ) |
|
return 1; |
|
|
|
int x, y; |
|
int r, g, b; |
|
|
|
r = g = b = 255; |
|
|
|
x = 20; |
|
y = ( ScreenHeight - gHUD.m_iFontHeight ) - ( gHUD.m_iFontHeight / 2 ) - 40; |
|
|
|
switch( iBlueFlagStatus ) |
|
{ |
|
case BLUE_FLAG_STOLE: |
|
hSprite = m_hBlueStolen; |
|
break; |
|
case BLUE_FLAG_LOST: |
|
hSprite = m_hBlueLost; |
|
break; |
|
case BLUE_FLAG_ATBASE: |
|
hSprite = m_hBlueAtBase; |
|
break; |
|
default: |
|
return 1; |
|
} |
|
|
|
SPR_Set( hSprite, r, g, b ); |
|
SPR_DrawHoles( 1, x, y, NULL ); |
|
|
|
x = 50; |
|
|
|
if( iBlueTeamScore < 10 ) |
|
{ |
|
x += 3; |
|
} |
|
else if( iBlueTeamScore >= 10 && iBlueTeamScore < 100 ) |
|
iDigits |= DHN_2DIGITS; |
|
|
|
gHUD.DrawHudNumber( x, y + 4, iDigits, iBlueTeamScore, 255, 255, 255 ); |
|
|
|
x = 20; |
|
y -= 35; |
|
|
|
switch( iRedFlagStatus ) |
|
{ |
|
case RED_FLAG_STOLE: |
|
hSprite = m_hRedStolen; |
|
break; |
|
case RED_FLAG_LOST: |
|
hSprite = m_hRedLost; |
|
break; |
|
case RED_FLAG_ATBASE: |
|
hSprite = m_hRedAtBase; |
|
break; |
|
default: |
|
return 1; |
|
} |
|
|
|
SPR_Set( hSprite, r, g, b ); |
|
SPR_DrawHoles( 1, x, y, NULL ); |
|
|
|
x = 50; |
|
iDigits = DHN_DRAWZERO; |
|
|
|
if( iRedTeamScore < 10 ) |
|
{ |
|
x += 3; |
|
} |
|
else if( iRedTeamScore >= 10 && iRedTeamScore < 100 ) |
|
iDigits |= DHN_2DIGITS; |
|
|
|
gHUD.DrawHudNumber( x, y + 4, iDigits, iRedTeamScore, 255, 255, 255 ); |
|
|
|
x = 20; |
|
y -= 35; |
|
|
|
switch( m_iRuneStat ) |
|
{ |
|
case ITEM_RUNE1_FLAG: |
|
hSprite = m_hRune1; |
|
break; |
|
case ITEM_RUNE2_FLAG: |
|
hSprite = m_hRune2; |
|
break; |
|
case ITEM_RUNE3_FLAG: |
|
hSprite = m_hRune3; |
|
break; |
|
case ITEM_RUNE4_FLAG: |
|
hSprite = m_hRune4; |
|
break; |
|
default: |
|
return 1; |
|
} |
|
SPR_Set( hSprite, r, g, b ); |
|
SPR_DrawHoles( 1, x, y, NULL ); |
|
|
|
return 1; |
|
} |
|
|
|
int CHudFlagStatus::MsgFunc_FlagStat(const char *pszName, int iSize, void *pbuf) |
|
{ |
|
BEGIN_READ( pbuf, iSize ); |
|
|
|
iDrawStatus = READ_BYTE(); |
|
iRedFlagStatus = READ_BYTE(); |
|
iBlueFlagStatus = READ_BYTE(); |
|
|
|
iRedTeamScore = READ_BYTE(); |
|
iBlueTeamScore = READ_BYTE(); |
|
|
|
return 1; |
|
} |
|
|
|
int CHudFlagStatus::MsgFunc_RuneStat(const char *pszName, int iSize, void *pbuf) |
|
{ |
|
BEGIN_READ( pbuf, iSize ); |
|
|
|
m_iRuneStat = READ_BYTE(); |
|
|
|
return 1; |
|
} |
|
|
|
int CHudFlagStatus::MsgFunc_FlagCarrier(const char *pszName, int iSize, void *pbuf) |
|
{ |
|
BEGIN_READ( pbuf, iSize ); |
|
|
|
int index = READ_BYTE(); |
|
|
|
g_PlayerExtraInfo[index].iHasFlag = READ_BYTE(); |
|
|
|
return 1; |
|
}
|
|
|