cl_dll/death.cpp
35363738394041
virtual void CHudDeathNotice::ApplySchemeSettings( vgui::IScheme *scheme );
void FireGameEvent( KeyValues * event);
private:
CHudTexture *m_iconD_skull; // sprite index of skull icon
35363738394041424344454647
virtual void CHudDeathNotice::ApplySchemeSettings( vgui::IScheme *scheme );
//--- Modified by L0ki ----------------
// Was originally:
// void FireGameEvent( KeyValues * event);
// which is what IGameEventListener uses. CHudElement derives
// from IGameEventListener2, so i had to change to the following
void FireGameEvent( IGameEvent *event);
//-------------------------------------
private:
CHudTexture *m_iconD_skull; // sprite index of skull icon
585960616263
CHudDeathNotice::CHudDeathNotice( const char *pElementName ) :
CHudElement( pElementName ), BaseClass( NULL, "HudDeathNotice" )
{
vgui::Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );
646566676869707172737475767778798081828384
CHudDeathNotice::CHudDeathNotice( const char *pElementName ) :
CHudElement( pElementName ), BaseClass( NULL, "HudDeathNotice" )
{
if(gameeventmanager->AddListener( this, "player_death", false ))
DevMsg("[CHudDeathNotice::CHudDeathNotice] Successfully added listener!\n");
else
DevMsg("[CHudDeathNotice::CHudDeathNotice] failed to add listener!\n");
if( gameeventmanager->AddListener( this, "dispenser_killed", false ) )
DevMsg( "[CHudDeathNotice::CHudDeathNotice] Successfully added dispenser_killed listener!\n" );
else
DevMsg( "[CHudDeathNotice::CHudDeathNotice] Failed to add sentrygun_killed listener!\n" );
if( gameeventmanager->AddListener( this, "sentrygun_killed", false ) )
DevMsg( "[CHudDeathNotice::CHudDeathNotice] Successfully added sentrygun_killed listener!\n" );
else
DevMsg( "[CHudDeathNotice::CHudDeathNotice] Failed to add sentrygun_killed listener!\n" );
vgui::Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );
68697071727374
{
BaseClass::ApplySchemeSettings( scheme );
m_hTextFont = scheme->GetFont( "HudNumbersSmall" );
m_clrText = scheme->GetColor( "FgColor", GetFgColor() );
SetPaintBackgroundEnabled( false );
89909192939495
{
BaseClass::ApplySchemeSettings( scheme );
m_hTextFont = scheme->GetFont( "Default" );
m_clrText = scheme->GetColor( "FgColor", GetFgColor() );
SetPaintBackgroundEnabled( false );
767778798081
//-----------------------------------------------------
struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH];
char szVictim[MAX_PLAYER_NAME_LENGTH];
CHudTexture *iconDeath; // the index number of the associated sprite
979899100101102103104
//-----------------------------------------------------
struct DeathNoticeItem {
int iKillerTeam;
int iVictimTeam;
char szKiller[MAX_PLAYER_NAME_LENGTH];
char szVictim[MAX_PLAYER_NAME_LENGTH];
CHudTexture *iconDeath; // the index number of the associated sprite
88899091929394
static int DEATHNOTICE_DISPLAY_TIME = 6;
// Robin HACKHACK: HL2 doesn't use deathmsgs, so I just forced these down below our minimap.
#define DEATHNOTICE_TOP YRES( 140 ) // Was: 20
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
111112113114115116117
static int DEATHNOTICE_DISPLAY_TIME = 6;
// Robin HACKHACK: HL2 doesn't use deathmsgs, so I just forced these down below our minimap.
#define DEATHNOTICE_TOP YRES( 0 )//YRES( 140 ) // Was: 20
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
171172173174175176
// Draw killer's name
surface()->DrawSetTextPos( x, y );
surface()->DrawUnicodeString( killer );
surface()->DrawGetTextPos( x, y );
x += 5;
194195196197198199200201202203204
// Draw killer's name
surface()->DrawSetTextPos( x, y );
if(g_PR)
{
Color col = g_PR->GetTeamColor(rgDeathNoticeList[i].iKillerTeam);
surface()->DrawSetTextColor( col );
}
surface()->DrawUnicodeString( killer );
surface()->DrawGetTextPos( x, y );
x += 5;
191192193194195196
// Draw victims name
surface()->DrawSetTextPos( x, y );
surface()->DrawUnicodeString( victim );
}
}
219220221222223224225226227228229
// Draw victims name
surface()->DrawSetTextPos( x, y );
if(g_PR)
{
Color col = g_PR->GetTeamColor(rgDeathNoticeList[i].iVictimTeam);
surface()->DrawSetTextColor( col );
}
surface()->DrawUnicodeString( victim );
}
}
198199200201202203204205206207208209210211
//-----------------------------------------------------------------------------
// Purpose: This message handler may be better off elsewhere
//-----------------------------------------------------------------------------
void CHudDeathNotice::FireGameEvent( KeyValues * event)
{
// Got message during connection
if ( !g_PR )
return;
int killer = engine->GetPlayerForUserID( event->GetInt("killer") );
int victim = engine->GetPlayerForUserID( event->GetInt("victim") );
char killedwith[32];
Q_snprintf( killedwith, sizeof( killedwith ), "d_%s", event->GetString("weapon") );
231232233234235236237238239240241242243244
//-----------------------------------------------------------------------------
// Purpose: This message handler may be better off elsewhere
//-----------------------------------------------------------------------------
void CHudDeathNotice::FireGameEvent( IGameEvent *event)
{
// Got message during connection
if ( !g_PR )
return;
int killer = engine->GetPlayerForUserID( event->GetInt("attacker") );
int victim = engine->GetPlayerForUserID( event->GetInt("userid") );
char killedwith[32];
Q_snprintf( killedwith, sizeof( killedwith ), "d_%s", event->GetString("weapon") );
223224225226227228229
}
// Get the names of the players
const char *killer_name = g_PR->GetPlayerName( killer );
const char *victim_name = g_PR->GetPlayerName( victim );
if ( !killer_name )
killer_name = "";
256257258259260261262
}
// Get the names of the players
const char *killer_name = ( killer == 0 ) ? "worldspawn" : g_PR->GetPlayerName( killer );
const char *victim_name = g_PR->GetPlayerName( victim );
if ( !killer_name )
killer_name = "";
230231232233234235
if ( !victim_name )
victim_name = "";
Q_strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
Q_strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
263264265266267268269270271272273274275276277278279280281282283284285286
if ( !victim_name )
victim_name = "";
// Temporary until we decide how we're displaying dispenser/sg deaths
char pszVictimMod[ 256 ];
if( !Q_strcmp( event->GetName(), "dispenser_killed" ) )
{
Q_strcpy( pszVictimMod, victim_name );
Q_strcat( pszVictimMod, "'s Dispenser" );
victim_name = const_cast< char * >( pszVictimMod );
}
else if( !Q_strcmp( event->GetName(), "sentrygun_killed" ) )
{
Q_strcpy( pszVictimMod, victim_name );
Q_strcat( pszVictimMod, "'s SentryGun" );
victim_name = const_cast< char * >( pszVictimMod );
}
rgDeathNoticeList[i].iKillerTeam = g_PR->GetTeam(killer);
rgDeathNoticeList[i].iVictimTeam = g_PR->GetTeam(victim);
Q_strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
Q_strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );