mirror of
https://github.com/celisej567/source-engine.git
synced 2025-12-31 21:48:22 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62ad1ba047 |
@@ -1,245 +0,0 @@
|
||||
// C_NextBot.cpp
|
||||
// Client-side implementation of Next generation bot system
|
||||
// Author: Michael Booth, April 2005
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "C_NextBot.h"
|
||||
#include "debugoverlay_shared.h"
|
||||
#include <bitbuf.h>
|
||||
#include "viewrender.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#undef NextBot
|
||||
|
||||
ConVar NextBotShadowDist( "nb_shadow_dist", "400" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_NextBotCombatCharacter, DT_NextBot, NextBotCombatCharacter )
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_NextBotCombatCharacter::C_NextBotCombatCharacter()
|
||||
{
|
||||
// Left4Dead have surfaces too steep for IK to work properly
|
||||
m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK;
|
||||
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
m_forcedShadowType = SHADOWS_NONE;
|
||||
m_bForceShadowType = false;
|
||||
|
||||
TheClientNextBots().Register( this );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_NextBotCombatCharacter::~C_NextBotCombatCharacter()
|
||||
{
|
||||
TheClientNextBots().UnRegister( this );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::UpdateClientSideAnimation()
|
||||
{
|
||||
if (IsDormant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::UpdateClientSideAnimation();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::UpdateShadowLOD( void )
|
||||
{
|
||||
ShadowType_t oldShadowType = m_shadowType;
|
||||
|
||||
if ( m_bForceShadowType )
|
||||
{
|
||||
m_shadowType = m_forcedShadowType;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NEED_SPLITSCREEN_INTEGRATION
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh )
|
||||
{
|
||||
C_BasePlayer *pl = C_BasePlayer::GetLocalPlayer(hh);
|
||||
if ( pl )
|
||||
{
|
||||
Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer(hh)->GetAbsOrigin();
|
||||
#else
|
||||
{
|
||||
if ( C_BasePlayer::GetLocalPlayer() )
|
||||
{
|
||||
Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer()->GetAbsOrigin();
|
||||
#endif
|
||||
if ( delta.IsLengthLessThan( NextBotShadowDist.GetFloat() ) )
|
||||
{
|
||||
m_shadowType = SHADOWS_RENDER_TO_TEXTURE_DYNAMIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( oldShadowType != m_shadowType )
|
||||
{
|
||||
DestroyShadow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
ShadowType_t C_NextBotCombatCharacter::ShadowCastType( void )
|
||||
{
|
||||
if ( !IsVisible() )
|
||||
return SHADOWS_NONE;
|
||||
|
||||
if ( m_shadowTimer.IsElapsed() )
|
||||
{
|
||||
m_shadowTimer.Start( 0.15f );
|
||||
UpdateShadowLOD();
|
||||
}
|
||||
|
||||
return m_shadowType;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool C_NextBotCombatCharacter::GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const
|
||||
{
|
||||
if ( pForcedShadowType )
|
||||
{
|
||||
*pForcedShadowType = m_forcedShadowType;
|
||||
}
|
||||
return m_bForceShadowType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Singleton accessor.
|
||||
* By returning a reference, we guarantee construction of the
|
||||
* instance before its first use.
|
||||
*/
|
||||
C_NextBotManager &TheClientNextBots( void )
|
||||
{
|
||||
static C_NextBotManager manager;
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
C_NextBotManager::C_NextBotManager( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
C_NextBotManager::~C_NextBotManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotManager::Register( C_NextBotCombatCharacter *bot )
|
||||
{
|
||||
m_botList.AddToTail( bot );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotManager::UnRegister( C_NextBotCombatCharacter *bot )
|
||||
{
|
||||
m_botList.FindAndRemove( bot );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_NextBotManager::SetupInFrustumData( void )
|
||||
{
|
||||
#ifdef ENABLE_AFTER_INTEGRATION
|
||||
// Done already this frame.
|
||||
if ( IsInFrustumDataValid() )
|
||||
return true;
|
||||
|
||||
// Can we use the view data yet?
|
||||
if ( !FrustumCache()->IsValid() )
|
||||
return false;
|
||||
|
||||
// Get the number of active bots.
|
||||
int nBotCount = m_botList.Count();
|
||||
|
||||
// Reset.
|
||||
for ( int iBot = 0; iBot < nBotCount; ++iBot )
|
||||
{
|
||||
// Get the current bot.
|
||||
C_NextBotCombatCharacter *pBot = m_botList[iBot];
|
||||
if ( !pBot )
|
||||
continue;
|
||||
|
||||
pBot->InitFrustumData();
|
||||
}
|
||||
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( iSlot )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( iSlot );
|
||||
// Get the active local player.
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
continue;
|
||||
|
||||
for ( int iBot = 0; iBot < nBotCount; ++iBot )
|
||||
{
|
||||
// Get the current bot.
|
||||
C_NextBotCombatCharacter *pBot = m_botList[iBot];
|
||||
if ( !pBot )
|
||||
continue;
|
||||
|
||||
// Are we in the view frustum?
|
||||
Vector vecMin, vecMax;
|
||||
pBot->CollisionProp()->WorldSpaceAABB( &vecMin, &vecMax );
|
||||
bool bInFrustum = !FrustumCache()->m_Frustums[iSlot].CullBox( vecMin, vecMax );
|
||||
|
||||
if ( bInFrustum )
|
||||
{
|
||||
Vector vecSegment;
|
||||
VectorSubtract( pBot->GetAbsOrigin(), pPlayer->GetAbsOrigin(), vecSegment );
|
||||
float flDistance = vecSegment.LengthSqr();
|
||||
if ( flDistance < pBot->GetInFrustumDistanceSqr() )
|
||||
{
|
||||
pBot->SetInFrustumDistanceSqr( flDistance );
|
||||
}
|
||||
|
||||
pBot->SetInFrustum( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark as setup this frame.
|
||||
m_nInFrustumFrame = gpGlobals->framecount;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@@ -1,134 +0,0 @@
|
||||
// C_NextBot.h
|
||||
// Next generation bot system
|
||||
// Author: Michael Booth, April 2005
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef _C_NEXT_BOT_H_
|
||||
#define _C_NEXT_BOT_H_
|
||||
|
||||
#include "c_ai_basenpc.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The interface holding IBody information
|
||||
*/
|
||||
class IBodyClient
|
||||
{
|
||||
public:
|
||||
enum ActivityType
|
||||
{
|
||||
MOTION_CONTROLLED_XY = 0x0001, // XY position and orientation of the bot is driven by the animation.
|
||||
MOTION_CONTROLLED_Z = 0x0002, // Z position of the bot is driven by the animation.
|
||||
ACTIVITY_UNINTERRUPTIBLE= 0x0004, // activity can't be changed until animation finishes
|
||||
ACTIVITY_TRANSITORY = 0x0008, // a short animation that takes over from the underlying animation momentarily, resuming it upon completion
|
||||
ENTINDEX_PLAYBACK_RATE = 0x0010, // played back at different rates based on entindex
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The client-side implementation of the NextBot
|
||||
*/
|
||||
class C_NextBotCombatCharacter : public C_BaseCombatCharacter
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_NextBotCombatCharacter, C_BaseCombatCharacter );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_NextBotCombatCharacter();
|
||||
virtual ~C_NextBotCombatCharacter();
|
||||
|
||||
public:
|
||||
virtual void Spawn( void );
|
||||
virtual void UpdateClientSideAnimation( void );
|
||||
virtual ShadowType_t ShadowCastType( void );
|
||||
virtual bool IsNextBot() { return true; }
|
||||
void ForceShadowCastType( bool bForce, ShadowType_t forcedShadowType = SHADOWS_NONE ) { m_bForceShadowType = bForce; m_forcedShadowType = forcedShadowType; }
|
||||
bool GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const;
|
||||
|
||||
// Local In View Data.
|
||||
void InitFrustumData( void ) { m_bInFrustum = false; m_flFrustumDistanceSqr = FLT_MAX; m_nInFrustumFrame = gpGlobals->framecount; }
|
||||
bool IsInFrustumValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); }
|
||||
void SetInFrustum( bool bInFrustum ) { m_bInFrustum = bInFrustum; }
|
||||
bool IsInFrustum( void ) { return m_bInFrustum; }
|
||||
void SetInFrustumDistanceSqr( float flDistance ) { m_flFrustumDistanceSqr = flDistance; }
|
||||
float GetInFrustumDistanceSqr( void ) { return m_flFrustumDistanceSqr; }
|
||||
|
||||
private:
|
||||
ShadowType_t m_shadowType; // Are we LOD'd to simple shadows?
|
||||
CountdownTimer m_shadowTimer; // Timer to throttle checks for shadow LOD
|
||||
ShadowType_t m_forcedShadowType;
|
||||
bool m_bForceShadowType;
|
||||
void UpdateShadowLOD( void );
|
||||
|
||||
// Local In View Data.
|
||||
int m_nInFrustumFrame;
|
||||
bool m_bInFrustum;
|
||||
float m_flFrustumDistanceSqr;
|
||||
|
||||
private:
|
||||
C_NextBotCombatCharacter( const C_NextBotCombatCharacter & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The C_NextBotManager manager
|
||||
*/
|
||||
class C_NextBotManager
|
||||
{
|
||||
public:
|
||||
C_NextBotManager( void );
|
||||
~C_NextBotManager();
|
||||
|
||||
/**
|
||||
* Execute functor for each NextBot in the system.
|
||||
* If a functor returns false, stop iteration early
|
||||
* and return false.
|
||||
*/
|
||||
template < typename Functor >
|
||||
bool ForEachCombatCharacter( Functor &func )
|
||||
{
|
||||
for( int i=0; i < m_botList.Count(); ++i )
|
||||
{
|
||||
C_NextBotCombatCharacter *character = m_botList[i];
|
||||
if ( character->IsPlayer() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( character->IsDormant() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !func( character ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetActiveCount() { return m_botList.Count(); }
|
||||
|
||||
bool SetupInFrustumData( void );
|
||||
bool IsInFrustumDataValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); }
|
||||
|
||||
private:
|
||||
friend class C_NextBotCombatCharacter;
|
||||
|
||||
void Register( C_NextBotCombatCharacter *bot );
|
||||
void UnRegister( C_NextBotCombatCharacter *bot );
|
||||
|
||||
CUtlVector< C_NextBotCombatCharacter * > m_botList; ///< list of all active NextBots
|
||||
|
||||
int m_nInFrustumFrame;
|
||||
};
|
||||
|
||||
// singleton accessor
|
||||
extern C_NextBotManager &TheClientNextBots( void );
|
||||
|
||||
|
||||
#endif // _C_NEXT_BOT_H_
|
||||
@@ -1,275 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CLIENT_CSTRIKE.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro GAMENAME "cstrike"
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE;$SRCDIR\game\shared\cstrike\control,.\cstrike,.\cstrike\control,.\cstrike\VGUI,$SRCDIR\game\shared\cstrike"
|
||||
$PreprocessorDefinitions "$BASE;CSTRIKE_DLL;NEXT_BOT"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Client (CStrike)"
|
||||
{
|
||||
$Folder "Replay"
|
||||
{
|
||||
$File "cstrike\cs_replay.cpp"
|
||||
$File "cstrike\cs_replay.h"
|
||||
}
|
||||
|
||||
$Folder "Source Files"
|
||||
{
|
||||
-$File "$SRCDIR\game\shared\weapon_parse_default.cpp"
|
||||
|
||||
$File "c_team_objectiveresource.cpp"
|
||||
$File "c_team_objectiveresource.h"
|
||||
$File "c_team_train_watcher.cpp"
|
||||
$File "c_team_train_watcher.h"
|
||||
$File "hud_base_account.cpp"
|
||||
$File "hud_base_account.h"
|
||||
$File "hud_voicestatus.cpp"
|
||||
$File "hud_baseachievement_tracker.cpp"
|
||||
$File "hud_baseachievement_tracker.h"
|
||||
$File "$SRCDIR\game\client\hud_vote.h"
|
||||
$File "$SRCDIR\game\client\hud_vote.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.h"
|
||||
|
||||
$Folder "CounterStrike DLL"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_achievement_constants.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_achievementdefs.h"
|
||||
$File "$SRCDIR\game\shared\cs_achievements_and_stats_interface.cpp"
|
||||
$File "$SRCDIR\game\shared\cs_achievements_and_stats_interface.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\achievements_cs.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\achievements_cs.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\basecsgrenade_projectile.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\basecsgrenade_projectile.h"
|
||||
$File "cstrike\buy_presets\buy_preset.cpp"
|
||||
$File "cstrike\buy_presets\buy_preset_debug.cpp"
|
||||
$File "cstrike\buy_presets\buy_preset_debug.h"
|
||||
$File "cstrike\buy_presets\buy_preset_weapon_info.cpp"
|
||||
$File "cstrike\buy_presets\buy_presets.cpp"
|
||||
$File "cstrike\buy_presets\buy_presets.h"
|
||||
$File "cstrike\c_cs_hostage.cpp"
|
||||
$File "cstrike\c_cs_hostage.h"
|
||||
$File "cstrike\c_cs_player.cpp"
|
||||
$File "cstrike\c_cs_player.h"
|
||||
$File "cstrike\c_cs_playerresource.cpp"
|
||||
$File "cstrike\c_cs_playerresource.h"
|
||||
$File "cstrike\c_cs_team.cpp"
|
||||
$File "cstrike\c_cs_team.h"
|
||||
$File "cstrike\c_csrootpanel.cpp"
|
||||
$File "cstrike\c_csrootpanel.h"
|
||||
$File "cstrike\c_plantedc4.cpp"
|
||||
$File "cstrike\c_plantedc4.h"
|
||||
$File "cstrike\c_te_radioicon.cpp"
|
||||
$File "cstrike\c_te_shotgun_shot.cpp"
|
||||
$File "cstrike\clientmode_csnormal.cpp"
|
||||
$File "cstrike\clientmode_csnormal.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_ammodef.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_ammodef.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_gamerules.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_gamerules.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_gamestats_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_gamestats_shared.h"
|
||||
$File "$SRCDIR\game\shared\steamworks_gamestats.cpp"
|
||||
$File "$SRCDIR\game\shared\steamworks_gamestats.h"
|
||||
$File "cstrike\cs_in_main.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_player_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_playeranimstate.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_playeranimstate.h"
|
||||
$File "cstrike\cs_prediction.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_shareddefs.cpp"
|
||||
$File "cstrike\cs_client_gamestats.cpp"
|
||||
$File "cstrike\cs_client_gamestats.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_usermessages.cpp"
|
||||
$File "cstrike\cs_view_scene.cpp"
|
||||
$File "cstrike\cs_view_scene.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_weapon_parse.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\cs_weapon_parse.h"
|
||||
$File "cstrike\fx_cs_blood.cpp"
|
||||
$File "cstrike\fx_cs_blood.h"
|
||||
$File "cstrike\fx_cs_impacts.cpp"
|
||||
$File "cstrike\fx_cs_knifeslash.cpp"
|
||||
$File "cstrike\fx_cs_muzzleflash.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\fx_cs_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\fx_cs_shared.h"
|
||||
$File "cstrike\fx_cs_weaponfx.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\bot\shared_util.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\bot\shared_util.h"
|
||||
$File "cstrike\vgui_rootpanel_cs.cpp"
|
||||
|
||||
$Folder "HUD Elements"
|
||||
{
|
||||
$File "cstrike\cs_hud_ammo.cpp"
|
||||
$File "cstrike\cs_hud_chat.cpp"
|
||||
$File "cstrike\cs_hud_chat.h"
|
||||
$File "cstrike\cs_hud_damageindicator.cpp"
|
||||
$File "cstrike\cs_hud_freezepanel.cpp"
|
||||
$File "cstrike\cs_hud_freezepanel.h"
|
||||
$File "cstrike\cs_hud_playerhealth.cpp"
|
||||
$File "cstrike\cs_hud_playerhealth.h"
|
||||
$File "cstrike\cs_hud_health.cpp"
|
||||
$File "cstrike\cs_hud_scope.cpp"
|
||||
$File "cstrike\cs_hud_target_id.cpp"
|
||||
$File "cstrike\cs_hud_weaponselection.cpp"
|
||||
$File "cstrike\hud_account.cpp"
|
||||
$File "cstrike\hud_armor.cpp"
|
||||
$File "cstrike\hud_c4.cpp"
|
||||
$File "cstrike\hud_deathnotice.cpp"
|
||||
$File "cstrike\hud_defuser.cpp"
|
||||
$File "cstrike\hud_flashbang.cpp"
|
||||
$File "cstrike\hud_hostagerescue.cpp"
|
||||
$File "cstrike\hud_progressbar.cpp"
|
||||
$File "cstrike\hud_radar.cpp"
|
||||
$File "cstrike\hud_radar.h"
|
||||
$File "cstrike\hud_roundtimer.cpp"
|
||||
$File "cstrike\hud_scenarioicon.cpp"
|
||||
$File "cstrike\hud_shopping_cart.cpp"
|
||||
$File "cstrike\cs_hud_achievement_announce.cpp"
|
||||
$File "cstrike\cs_hud_achievement_announce.h"
|
||||
$File "cstrike\cs_hud_achievement_tracker.cpp"
|
||||
$File "cstrike\radio_status.cpp"
|
||||
$File "cstrike\radio_status.h"
|
||||
}
|
||||
|
||||
$Folder "Weapon"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_ak47.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_aug.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_awp.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_c4.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_c4.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_csbase.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_csbase.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_csbasegun.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_csbasegun.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_deagle.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_elite.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_famas.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_fiveseven.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_flashbang.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_flashbang.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_g3sg1.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_galil.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_glock.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_hegrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_hegrenade.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_knife.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_knife.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_m249.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_m3.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_m4a1.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_mac10.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_mp5navy.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_p228.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_p90.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_scout.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_sg550.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_sg552.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_smokegrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_smokegrenade.h"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_tmp.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_ump45.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_usp.cpp"
|
||||
$File "$SRCDIR\game\shared\cstrike\weapon_xm1014.cpp"
|
||||
}
|
||||
|
||||
$Folder "vgui"
|
||||
{
|
||||
$File "cstrike\VGUI\achievement_stats_summary.cpp"
|
||||
$File "cstrike\VGUI\achievement_stats_summary.h"
|
||||
$File "cstrike\VGUI\achievements_page.cpp"
|
||||
$File "cstrike\VGUI\achievements_page.h"
|
||||
$File "cstrike\VGUI\stats_summary.cpp"
|
||||
$File "cstrike\VGUI\stats_summary.h"
|
||||
$File "cstrike\VGUI\stat_card.cpp"
|
||||
$File "cstrike\VGUI\stat_card.h"
|
||||
$File "cstrike\VGUI\base_stats_page.cpp"
|
||||
$File "cstrike\VGUI\base_stats_page.h"
|
||||
$File "cstrike\VGUI\match_stats_page.cpp"
|
||||
$File "cstrike\VGUI\match_stats_page.h"
|
||||
$File "cstrike\VGUI\lifetime_stats_page.cpp"
|
||||
$File "cstrike\VGUI\lifetime_stats_page.h"
|
||||
$File "cstrike\VGUI\bordered_panel.cpp"
|
||||
$File "cstrike\VGUI\bordered_panel.h"
|
||||
$File "cstrike\VGUI\backgroundpanel.cpp"
|
||||
$File "cstrike\VGUI\backgroundpanel.h"
|
||||
$File "cstrike\VGUI\buymouseoverpanelbutton.h"
|
||||
$File "cstrike\VGUI\buypreset_imageinfo.cpp"
|
||||
$File "cstrike\VGUI\buypreset_listbox.cpp"
|
||||
$File "cstrike\VGUI\buypreset_listbox.h"
|
||||
$File "cstrike\VGUI\buypreset_panel.cpp"
|
||||
$File "cstrike\VGUI\buypreset_weaponsetlabel.h"
|
||||
$File "cstrike\VGUI\career_box.cpp"
|
||||
$File "cstrike\VGUI\career_box.h"
|
||||
$File "cstrike\VGUI\career_button.cpp"
|
||||
$File "cstrike\VGUI\career_button.h"
|
||||
$File "cstrike\VGUI\counterstrikeviewport.cpp"
|
||||
$File "cstrike\VGUI\counterstrikeviewport.h"
|
||||
$File "cstrike\VGUI\cstrikebuyequipmenu.cpp"
|
||||
$File "cstrike\VGUI\cstrikebuyequipmenu.h"
|
||||
$File "cstrike\VGUI\cstrikebuymenu.cpp"
|
||||
$File "cstrike\VGUI\cstrikebuymenu.h"
|
||||
$File "cstrike\VGUI\cstrikebuysubmenu.h"
|
||||
$File "cstrike\VGUI\cstrikeclassmenu.cpp"
|
||||
$File "cstrike\VGUI\cstrikeclassmenu.h"
|
||||
$File "cstrike\VGUI\cstrikeclientscoreboard.cpp"
|
||||
$File "cstrike\VGUI\cstrikeclientscoreboard.h"
|
||||
$File "cstrike\VGUI\cstrikespectatorgui.cpp"
|
||||
$File "cstrike\VGUI\cstrikespectatorgui.h"
|
||||
$File "cstrike\VGUI\cstriketeammenu.cpp"
|
||||
$File "cstrike\VGUI\cstriketeammenu.h"
|
||||
$File "cstrike\VGUI\cstriketextwindow.cpp"
|
||||
$File "cstrike\VGUI\cstriketextwindow.h"
|
||||
$File "cstrike\vgui_c4panel.cpp"
|
||||
$File "cstrike\vgui_viewc4panel.cpp"
|
||||
$File "cstrike\VGUI\win_panel_round.cpp"
|
||||
$File "cstrike\VGUI\win_panel_round.h"
|
||||
}
|
||||
|
||||
$Folder "NextBot"
|
||||
{
|
||||
$File "NextBot\C_NextBot.cpp"
|
||||
$File "NextBot\C_NextBot.h"
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "game_controls"
|
||||
{
|
||||
$File "game_controls\buymenu.cpp"
|
||||
$File "game_controls\buysubmenu.cpp"
|
||||
$File "game_controls\classmenu.cpp"
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
|
||||
$Folder "game_controls header files"
|
||||
{
|
||||
$File "game_controls\buymenu.h"
|
||||
$File "game_controls\buysubmenu.h"
|
||||
$File "game_controls\classmenu.h"
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "Link Libraries"
|
||||
{
|
||||
$Lib vtf
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CLIENT_DOD.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro GAMENAME "dod"
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE;dod,.\dod\VGUI,$SRCDIR\game\shared\dod"
|
||||
$PreprocessorDefinitions "$BASE;DOD_DLL;ENABLE_HTML_WINDOW"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Client (DOD)"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
-$File "$SRCDIR\game\shared\weapon_parse_default.cpp"
|
||||
-$File "history_resource.cpp"
|
||||
-$File "hud_hintdisplay.cpp"
|
||||
|
||||
$File "hud_voicestatus.cpp"
|
||||
|
||||
$File "$SRCDIR\game\shared\playerclass_info_parse.cpp"
|
||||
$File "$SRCDIR\game\shared\playerclass_info_parse.h"
|
||||
|
||||
$Folder "Day of Defeat DLL"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\dod\achievements_dod.cpp"
|
||||
$File "dod\c_dod_basegrenade.cpp"
|
||||
$File "dod\c_dod_basegrenade.h"
|
||||
$File "dod\c_dod_baserocket.cpp"
|
||||
$File "dod\c_dod_bombdispenser.cpp"
|
||||
$File "dod\c_dod_bombtarget.cpp"
|
||||
$File "dod\c_dod_objective_resource.cpp"
|
||||
$File "dod\c_dod_objective_resource.h"
|
||||
$File "dod\c_dod_player.cpp"
|
||||
$File "dod\c_dod_player.h"
|
||||
$File "dod\c_dod_playerresource.cpp"
|
||||
$File "dod\c_dod_playerresource.h"
|
||||
$File "dod\c_dod_smokegrenade.cpp"
|
||||
$File "dod\c_dod_smokegrenade.h"
|
||||
$File "dod\c_dod_team.cpp"
|
||||
$File "dod\c_dod_team.h"
|
||||
$File "dod\c_grenadetrail.cpp"
|
||||
$File "dod\c_grenadetrail.h"
|
||||
$File "dod\c_te_firebullets.cpp"
|
||||
$File "dod\clientmode_dod.cpp"
|
||||
$File "dod\clientmode_dod.h"
|
||||
$File "dod\dod_fx_explosions.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_gamerules.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_gamerules.h"
|
||||
$File "dod\dod_headiconmanager.cpp"
|
||||
$File "dod\dod_headiconmanager.h"
|
||||
$File "dod\dod_hud_ammo.cpp"
|
||||
$File "dod\dod_hud_areacapicon.cpp"
|
||||
$File "dod\dod_hud_capturepanel.cpp"
|
||||
$File "dod\dod_hud_capturepanel.h"
|
||||
$File "dod\dod_hud_chat.cpp"
|
||||
$File "dod\dod_hud_chat.h"
|
||||
$File "dod\dod_hud_crosshair.cpp"
|
||||
$File "dod\dod_hud_crosshair.h"
|
||||
$File "dod\dod_hud_damageindicator.cpp"
|
||||
$File "dod\dod_hud_deathnotice.cpp"
|
||||
$File "dod\dod_hud_freezepanel.cpp"
|
||||
$File "dod\dod_hud_freezepanel.h"
|
||||
$File "dod\dod_hud_health.cpp"
|
||||
$File "dod\dod_hud_hintdisplay.cpp"
|
||||
$File "dod\dod_hud_history_resource.cpp"
|
||||
$File "dod\dod_hud_objectiveicons.cpp"
|
||||
$File "dod\dod_hud_playerstatus_ammo.cpp"
|
||||
$File "dod\dod_hud_playerstatus_ammo.h"
|
||||
$File "dod\dod_hud_playerstatus_fireselect.cpp"
|
||||
$File "dod\dod_hud_playerstatus_fireselect.h"
|
||||
$File "dod\dod_hud_playerstatus_health.cpp"
|
||||
$File "dod\dod_hud_playerstatus_health.h"
|
||||
$File "dod\dod_hud_playerstatus_mgheat.cpp"
|
||||
$File "dod\dod_hud_playerstatus_mgheat.h"
|
||||
$File "dod\dod_hud_playerstatus_stamina.cpp"
|
||||
$File "dod\dod_hud_playerstatus_stamina.h"
|
||||
$File "dod\dod_hud_playerstatus_tnt.cpp"
|
||||
$File "dod\dod_hud_playerstatus_weapon.cpp"
|
||||
$File "dod\dod_hud_playerstatus_weapon.h"
|
||||
$File "dod\dod_hud_playerstatuspanel.cpp"
|
||||
$File "dod\dod_hud_readyrestart.cpp"
|
||||
$File "dod\dod_hud_restartround.cpp"
|
||||
$File "dod\dod_hud_scope.cpp"
|
||||
$File "dod\dod_hud_spec_crosshair.cpp"
|
||||
$File "dod\dod_hud_spec_crosshair.h"
|
||||
$File "dod\dod_hud_target_id.cpp"
|
||||
$File "dod\dod_hud_tnt_pickup.cpp"
|
||||
$File "dod\dod_hud_warmuplabel.cpp"
|
||||
$File "dod\dod_hud_weaponselection.cpp"
|
||||
$File "dod\dod_hud_winpanel.cpp"
|
||||
$File "dod\dod_hud_winpanel.h"
|
||||
$File "dod\dod_in_main.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_player_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_player_shared.h"
|
||||
$File "$SRCDIR\game\shared\dod\dod_playeranimstate.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_playeranimstate.h"
|
||||
$File "$SRCDIR\game\shared\dod\dod_playerclass_info_parse.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_playerclass_info_parse.h"
|
||||
$File "dod\dod_playerstats.cpp"
|
||||
$File "dod\dod_playerstats.h"
|
||||
$File "dod\dod_prediction.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_round_timer.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_shareddefs.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_shareddefs.h"
|
||||
$File "$SRCDIR\game\shared\dod\dod_usermessages.cpp"
|
||||
$File "dod\dod_view_scene.cpp"
|
||||
$File "dod\dod_view_scene.h"
|
||||
$File "$SRCDIR\game\shared\dod\dod_viewmodel.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_viewmodel.h"
|
||||
$File "$SRCDIR\game\shared\dod\dod_weapon_parse.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\dod_weapon_parse.h"
|
||||
$File "dod\VGUI\backgroundpanel.cpp"
|
||||
$File "dod\VGUI\backgroundpanel.h"
|
||||
$File "dod\VGUI\dodbutton.cpp"
|
||||
$File "dod\VGUI\dodbutton.h"
|
||||
$File "dod\VGUI\dodclassmenu.cpp"
|
||||
$File "dod\VGUI\dodclassmenu.h"
|
||||
$File "dod\VGUI\dodclientscoreboard.cpp"
|
||||
$File "dod\VGUI\dodclientscoreboard.h"
|
||||
$File "dod\VGUI\dodcornercutpanel.cpp"
|
||||
$File "dod\VGUI\dodcornercutpanel.h"
|
||||
$File "dod\VGUI\dodmenubackground.cpp"
|
||||
$File "dod\VGUI\dodmenubackground.h"
|
||||
$File "dod\VGUI\dodmouseoverpanelbutton.h"
|
||||
$File "dod\VGUI\dodoverview.cpp"
|
||||
$File "dod\VGUI\dodoverview.h"
|
||||
$File "dod\VGUI\dodrandombutton.h"
|
||||
$File "dod\VGUI\dodspectatorgui.cpp"
|
||||
$File "dod\VGUI\dodspectatorgui.h"
|
||||
$File "dod\VGUI\dodteammenu.cpp"
|
||||
$File "dod\VGUI\dodteammenu.h"
|
||||
$File "dod\VGUI\dodtextwindow.cpp"
|
||||
$File "dod\VGUI\dodtextwindow.h"
|
||||
$File "dod\VGUI\dodviewport.cpp"
|
||||
$File "dod\VGUI\dodviewport.h"
|
||||
$File "dod\fx_dod_blood.cpp"
|
||||
$File "dod\fx_dod_blood.h"
|
||||
$File "dod\fx_dod_ejectbrass.cpp"
|
||||
$File "dod\fx_dod_filmgrain.cpp"
|
||||
$File "dod\fx_dod_impact.cpp"
|
||||
$File "dod\fx_dod_knifeslash.cpp"
|
||||
$File "dod\fx_dod_muzzleflash.cpp"
|
||||
$File "dod\fx_dod_muzzleflash.h"
|
||||
$File "$SRCDIR\game\shared\dod\fx_dod_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\fx_dod_shared.h"
|
||||
$File "dod\fx_dod_tracers.cpp"
|
||||
$File "dod\VGUI\idodviewportmsgs.h"
|
||||
$File "dod\VGUI\vgui_rootpanel_dod.cpp"
|
||||
$File "dod\VGUI\vgui_rootpanel_dod.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_30cal.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_amerknife.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_bar.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_bazooka.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_c96.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_colt.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbase.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbase.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasebomb.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasebomb.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasegrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasegrenade.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasegun.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasegun.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasemelee.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbasemelee.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbaserpg.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbaserpg.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbipodgun.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodbipodgun.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfireselect.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfireselect.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfullauto.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfullauto.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfullauto_punch.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodfullauto_punch.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodsemiauto.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodsemiauto.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodsniper.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_dodsniper.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_explodinghandgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_explodingstickgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_garand.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_handgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_k98.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_k98_scoped.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_m1carbine.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_mg42.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_mg42.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_mp40.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_mp44.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_p38.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_pschreck.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade.h"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade_ger.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade_ger_live.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade_us.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_riflegrenade_us_live.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_smokegrenade_ger.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_smokegrenade_us.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_spade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_spring.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_stickgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\dod\weapon_thompson.cpp"
|
||||
}
|
||||
|
||||
$Folder "game_controls"
|
||||
{
|
||||
$File "game_controls\buymenu.cpp"
|
||||
$File "game_controls\buysubmenu.cpp"
|
||||
$File "game_controls\classmenu.cpp"
|
||||
}
|
||||
|
||||
$Folder "IFM"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\weapon_ifmbase.cpp"
|
||||
$File "$SRCDIR\game\shared\weapon_ifmbase.h"
|
||||
$File "$SRCDIR\game\shared\weapon_ifmbasecamera.cpp"
|
||||
$File "$SRCDIR\game\shared\weapon_ifmbasecamera.h"
|
||||
$File "$SRCDIR\game\shared\weapon_ifmsteadycam.cpp"
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
|
||||
$Folder "game_controls header files"
|
||||
{
|
||||
$File "game_controls\buymenu.h"
|
||||
$File "game_controls\buysubmenu.h"
|
||||
$File "game_controls\classmenu.h"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CLIENT_HL1.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro GAMENAME "hl1"
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE;.\hl1,.\hl2,.\hl2\elements,$SRCDIR\game\shared\hl1,$SRCDIR\game\shared\hl2"
|
||||
$PreprocessorDefinitions "$BASE;HL1_CLIENT_DLL"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Client (HL1)"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
-$File "geiger.cpp"
|
||||
-$File "history_resource.cpp"
|
||||
-$File "train.cpp"
|
||||
|
||||
$File "c_team_objectiveresource.cpp"
|
||||
$File "c_team_objectiveresource.h"
|
||||
$File "hud_chat.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.h"
|
||||
|
||||
$Folder "HL2 DLL"
|
||||
{
|
||||
$File "hl2\c_antlion_dust.cpp"
|
||||
$File "hl2\c_basehelicopter.cpp"
|
||||
$File "hl2\c_basehelicopter.h"
|
||||
$File "hl2\c_basehlcombatweapon.h"
|
||||
$File "hl2\c_corpse.cpp"
|
||||
$File "hl2\c_corpse.h"
|
||||
$File "hl2\c_hl2_playerlocaldata.h"
|
||||
$File "hl2\c_rotorwash.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h"
|
||||
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h"
|
||||
$File "hl2\fx_bugbait.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h"
|
||||
$File "hl2\hl_in_main.cpp"
|
||||
$File "hl2\hl_prediction.cpp"
|
||||
$File "hl2\vgui_rootpanel_hl2.cpp"
|
||||
}
|
||||
|
||||
$Folder "HL1 DLL"
|
||||
{
|
||||
$File "hl1\c_hl1mp_player.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_basecombatweapon_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_basecombatweapon_shared.h"
|
||||
$File "hl1\hl1_c_legacytempents.cpp"
|
||||
$File "hl1\hl1_c_player.cpp"
|
||||
$File "hl1\hl1_c_player.h"
|
||||
$File "hl1\hl1_c_rpg_rocket.cpp"
|
||||
$File "hl1\hl1_c_weapon__stubs.cpp"
|
||||
$File "hl1\hl1_clientmode.cpp"
|
||||
$File "hl1\hl1_clientmode.h"
|
||||
$File "hl1\hl1_fx_gauss.cpp"
|
||||
$File "hl1\hl1_fx_gibs.cpp"
|
||||
$File "hl1\hl1_fx_impacts.cpp"
|
||||
$File "hl1\hl1_fx_shelleject.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamemovement.h"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamerules.cpp"
|
||||
$File "hl1\hl1_hud_ammo.cpp"
|
||||
$File "hl1\hl1_hud_battery.cpp"
|
||||
$File "hl1\hl1_hud_damageindicator.cpp"
|
||||
$File "hl1\hl1_hud_damagetiles.cpp"
|
||||
$File "hl1\hl1_hud_flashlight.cpp"
|
||||
$File "hl1\hl1_hud_geiger.cpp"
|
||||
$File "hl1\hl1_hud_health.cpp"
|
||||
$File "hl1\hl1_hud_history_resource.cpp"
|
||||
$File "hl1\hl1_hud_numbers.cpp"
|
||||
$File "hl1\hl1_hud_numbers.h"
|
||||
$File "hl1\hl1_hud_train.cpp"
|
||||
$File "hl1\hl1_hud_weaponselection.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_player_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_player_shared.h"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_usermessages.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_basecombatweapon_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_357.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_crossbow.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_egon.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_gauss.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_glock.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_handgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_hornetgun.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_mp5.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_rpg.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_sachel.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_shotgun.cpp"
|
||||
$File "$SRCDIR\game\server\hl1\hl1_weapon_crowbar.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CLIENT_HL1MP.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro GAMENAME "hl1mp"
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE;.\hl1,.\hl2,.\hl2\elements,$SRCDIR\game\shared\hl1,$SRCDIR\game\shared\hl2"
|
||||
$PreprocessorDefinitions "$BASE;HL1_CLIENT_DLL;HL1MP_CLIENT_DLL"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Client (HL1MP)"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
-$File "geiger.cpp"
|
||||
-$File "history_resource.cpp"
|
||||
-$File "train.cpp"
|
||||
|
||||
$File "c_team_objectiveresource.cpp"
|
||||
$File "c_team_objectiveresource.h"
|
||||
$File "hud_chat.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.cpp"
|
||||
$File "$SRCDIR\game\shared\predicted_viewmodel.h"
|
||||
|
||||
$Folder "HL2 DLL"
|
||||
{
|
||||
$File "hl2\c_antlion_dust.cpp"
|
||||
$File "hl2\c_basehelicopter.cpp"
|
||||
$File "hl2\c_basehelicopter.h"
|
||||
$File "hl2\c_basehlcombatweapon.h"
|
||||
$File "hl2\c_corpse.cpp"
|
||||
$File "hl2\c_corpse.h"
|
||||
$File "hl2\c_hl2_playerlocaldata.h"
|
||||
$File "hl2\c_rotorwash.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h"
|
||||
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h"
|
||||
$File "hl2\fx_bugbait.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h"
|
||||
$File "hl2\hl_in_main.cpp"
|
||||
$File "hl2\hl_prediction.cpp"
|
||||
$File "hl2\vgui_rootpanel_hl2.cpp"
|
||||
}
|
||||
|
||||
$Folder "HL1 DLL"
|
||||
{
|
||||
$File "hl1\hl1_c_legacytempents.cpp"
|
||||
$File "hl1\hl1_c_player.cpp"
|
||||
$File "hl1\hl1_c_player.h"
|
||||
$File "hl1\hl1_c_rpg_rocket.cpp"
|
||||
$File "hl1\hl1_c_weapon__stubs.cpp"
|
||||
$File "hl1\hl1_clientmode.cpp"
|
||||
$File "hl1\hl1_clientmode.h"
|
||||
$File "hl1\hl1_clientscoreboard.cpp"
|
||||
$File "hl1\hl1_hud_deathnotice.cpp"
|
||||
$File "hl1\hl1_fx_gauss.cpp"
|
||||
$File "hl1\hl1_fx_gibs.cpp"
|
||||
$File "hl1\hl1_fx_impacts.cpp"
|
||||
$File "hl1\hl1_fx_shelleject.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamemovement.h"
|
||||
$File "hl1\hl1_hud_ammo.cpp"
|
||||
$File "hl1\hl1_hud_battery.cpp"
|
||||
$File "hl1\hl1_hud_damageindicator.cpp"
|
||||
$File "hl1\hl1_hud_damagetiles.cpp"
|
||||
$File "hl1\hl1_hud_flashlight.cpp"
|
||||
$File "hl1\hl1_hud_geiger.cpp"
|
||||
$File "hl1\hl1_hud_health.cpp"
|
||||
$File "hl1\hl1_hud_history_resource.cpp"
|
||||
$File "hl1\hl1_hud_numbers.cpp"
|
||||
$File "hl1\hl1_hud_numbers.h"
|
||||
$File "hl1\hl1_hud_train.cpp"
|
||||
$File "hl1\hl1_hud_weaponselection.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_basecombatweapon_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_gamerules.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_player_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_player_shared.h"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1_usermessages.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_357.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_crossbow.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_egon.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_gauss.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_glock.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_handgrenade.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_hornetgun.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_mp5.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_rpg.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_sachel.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_weapon_shotgun.cpp"
|
||||
$File "$SRCDIR\game\server\hl1\hl1_weapon_crowbar.cpp"
|
||||
}
|
||||
|
||||
$Folder "HL1MP DLL"
|
||||
{
|
||||
$File "hl1\c_hl1mp_player.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_basecombatweapon_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl1\hl1mp_gamerules.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CLIENT_PORTAL.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro GAMENAME "portal"
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories ".\hl2;.\hl2\elements;.\portal;.\portal\vgui;$SRCDIR\game\shared\hl2;$SRCDIR\game\shared\Multiplayer;$SRCDIR\gcsdk\steamextra;$SRCDIR\game\shared\portal;$BASE"
|
||||
$PreprocessorDefinitions "$BASE;PORTAL;HL2_EPISODIC;HL2_CLIENT_DLL"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Client (Portal)"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
-$File "$SRCDIR\game\shared\weapon_parse_default.cpp"
|
||||
$File "hud_chat.cpp"
|
||||
$File "c_team_objectiveresource.cpp"
|
||||
$File "c_team_objectiveresource.h"
|
||||
|
||||
$Folder "HL2 DLL"
|
||||
{
|
||||
$File "episodic\flesh_internal_material_proxy.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\basehlcombatweapon_shared.cpp"
|
||||
$File "hl2\c_antlion_dust.cpp"
|
||||
$File "hl2\c_ar2_explosion.cpp"
|
||||
$File "hl2\c_barnacle.cpp"
|
||||
$File "hl2\c_barney.cpp"
|
||||
$File "hl2\c_basehelicopter.cpp"
|
||||
$File "hl2\c_basehelicopter.h"
|
||||
$File "hl2\c_basehlcombatweapon.cpp"
|
||||
$File "hl2\c_basehlcombatweapon.h"
|
||||
$File "hl2\c_basehlplayer.cpp"
|
||||
$File "hl2\c_basehlplayer.h"
|
||||
$File "hl2\c_citadel_effects.cpp"
|
||||
$File "hl2\c_corpse.cpp"
|
||||
$File "hl2\c_corpse.h"
|
||||
$File "hl2\c_env_alyxtemp.cpp"
|
||||
$File "hl2\c_env_headcrabcanister.cpp"
|
||||
$File "hl2\c_env_starfield.cpp"
|
||||
$File "hl2\c_func_tankmortar.cpp"
|
||||
$File "hl2\c_hl2_playerlocaldata.cpp"
|
||||
$File "hl2\c_hl2_playerlocaldata.h"
|
||||
$File "hl2\c_info_teleporter_countdown.cpp"
|
||||
$File "hl2\c_npc_antlionguard.cpp"
|
||||
$File "hl2\c_npc_combinegunship.cpp"
|
||||
$File "hl2\c_npc_manhack.cpp"
|
||||
$File "hl2\c_npc_rollermine.cpp"
|
||||
$File "hl2\c_plasma_beam_node.cpp"
|
||||
$File "hl2\c_prop_combine_ball.cpp"
|
||||
$File "hl2\c_prop_combine_ball.h"
|
||||
$File "hl2\c_rotorwash.cpp"
|
||||
$File "hl2\c_script_intro.cpp"
|
||||
$File "$SRCDIR\game\shared\script_intro_shared.cpp"
|
||||
$File "hl2\c_strider.cpp"
|
||||
$File "hl2\c_te_concussiveexplosion.cpp"
|
||||
$File "hl2\c_te_flare.cpp"
|
||||
$File "hl2\c_thumper_dust.cpp"
|
||||
$File "hl2\c_vehicle_airboat.cpp"
|
||||
$File "hl2\c_vehicle_cannon.cpp"
|
||||
$File "hl2\c_vehicle_crane.cpp"
|
||||
$File "hl2\c_vehicle_crane.h"
|
||||
$File "hl2\c_vehicle_prisoner_pod.cpp"
|
||||
$File "episodic\c_vort_charge_token.cpp"
|
||||
$File "hl2\c_weapon_crossbow.cpp"
|
||||
$File "episodic\c_weapon_hopwire.cpp"
|
||||
$File "episodic\c_vehicle_jeep_episodic.cpp"
|
||||
$File "hl2\hud_radar.cpp"
|
||||
$File "hl2\c_weapon_stunstick.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h"
|
||||
$File "hl2\clientmode_hlnormal.h"
|
||||
$File "death.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h"
|
||||
$File "hl2\fx_antlion.cpp"
|
||||
$File "hl2\fx_bugbait.cpp"
|
||||
$File "hl2\fx_hl2_impacts.cpp"
|
||||
$File "hl2\fx_hl2_tracers.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\hl2_gamerules.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\hl2_gamerules.h"
|
||||
$File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h"
|
||||
$File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\hl_gamemovement.h"
|
||||
$File "hl2\hl_in_main.cpp"
|
||||
$File "hl2\hl_prediction.cpp"
|
||||
$File "hl2\hud_ammo.cpp"
|
||||
$File "hl2\hud_battery.cpp"
|
||||
$File "hl2\hud_blood.cpp"
|
||||
$File "hl2\hud_bonusprogress.cpp"
|
||||
$File "hl2\hud_credits.cpp"
|
||||
$File "hl2\hud_damageindicator.cpp"
|
||||
$File "hl2\hud_flashlight.cpp"
|
||||
$File "hl2\hud_health.cpp"
|
||||
$File "hl2\hud_poisondamageindicator.cpp"
|
||||
$File "hud_squadstatus.cpp"
|
||||
$File "hl2\hud_suitpower.cpp"
|
||||
$File "hl2\hud_suitpower.h"
|
||||
$File "hl2\hud_weaponselection.cpp"
|
||||
$File "hl2\hud_zoom.cpp"
|
||||
$File "hl2\shieldproxy.cpp"
|
||||
$File "$SRCDIR\game\shared\hl2\survival_gamerules.cpp"
|
||||
$File "hl2\vgui_rootpanel_hl2.cpp"
|
||||
}
|
||||
|
||||
$Folder "Portal"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\portal\achievements_portal.cpp"
|
||||
$File "portal\c_env_lightraill_endpoint.cpp"
|
||||
$File "portal\c_env_portal_path_track.cpp"
|
||||
$File "portal\c_func_liquidportal.cpp"
|
||||
$File "portal\c_func_liquidportal.h"
|
||||
$File "portal\c_neurotoxin_countdown.cpp"
|
||||
$File "portal\c_neurotoxin_countdown.h"
|
||||
$File "portal\c_npc_portal_turret_floor.cpp"
|
||||
$File "portal\c_npc_rocket_turret.cpp"
|
||||
$File "portal\c_portal_player.cpp"
|
||||
$File "portal\c_portal_player.h"
|
||||
$File "portal\C_PortalGhostRenderable.cpp"
|
||||
$File "portal\C_PortalGhostRenderable.h"
|
||||
$File "portal\c_prop_energy_ball.cpp"
|
||||
$File "portal\c_prop_portal.cpp"
|
||||
$File "portal\c_prop_portal.h"
|
||||
$File "portal\c_prop_portal_stats_display.cpp"
|
||||
$File "portal\c_prop_portal_stats_display.h"
|
||||
$File "portal\clientmode_portal.cpp"
|
||||
$File "portal\clientmode_portal.h"
|
||||
$File "$SRCDIR\game\shared\portal\env_lightrail_endpoint_shared.h"
|
||||
$File "$SRCDIR\game\shared\portal\env_portal_path_track_shared.h"
|
||||
$File "portal\fx_portal.cpp"
|
||||
$File "portal\hud_quickinfo.cpp"
|
||||
$File "portal\MaterialProxy_Portal_PickAlphaMask.cpp"
|
||||
$File "portal\materialproxy_portalstatic.cpp"
|
||||
$File "$SRCDIR\game\shared\Multiplayer\multiplayer_animstate.cpp"
|
||||
$File "$SRCDIR\game\shared\Multiplayer\multiplayer_animstate.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_collideable_enumerator.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_collideable_enumerator.h"
|
||||
$File "portal\portal_credits.cpp"
|
||||
$File "portal\Portal_DynamicMeshRenderingUtils.cpp"
|
||||
$File "portal\Portal_DynamicMeshRenderingUtils.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_gamemovement.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_gamerules.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_gamerules.h"
|
||||
$File "portal\portal_hud_crosshair.cpp"
|
||||
$File "portal\portal_hud_crosshair.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_player_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_player_shared.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_playeranimstate.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_playeranimstate.h"
|
||||
$File "portal\portal_render_targets.cpp"
|
||||
$File "portal\portal_render_targets.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_shareddefs.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_shareddefs.h"
|
||||
$File "$SRCDIR\game\shared\portal\portal_usermessages.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_util_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_util_shared.h"
|
||||
$File "$SRCDIR\game\shared\portal\prop_portal_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\prop_portal_shared.h"
|
||||
$File "$SRCDIR\game\shared\portal\PortalSimulation.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\PortalSimulation.h"
|
||||
$File "$SRCDIR\game\shared\portal\StaticCollisionPolyhedronCache.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\StaticCollisionPolyhedronCache.h"
|
||||
$File "portal\PortalRender.cpp"
|
||||
$File "portal\PortalRender.h"
|
||||
$File "portal\c_portal_radio.cpp"
|
||||
$File "portal\portalrenderable_flatbasic.cpp"
|
||||
$File "portal\portalrenderable_flatbasic.h"
|
||||
$File "portal\vgui_portal_stats_display_screen.cpp"
|
||||
$File "portal\vgui_neurotoxin_countdown_screen.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\portal_weapon_parse.cpp"
|
||||
|
||||
$Folder "Weapons"
|
||||
{
|
||||
$File "portal\c_weapon_physcannon.cpp"
|
||||
$File "portal\c_weapon_portalgun.cpp"
|
||||
$File "portal\c_weapon_portalgun.h"
|
||||
$File "portal\c_weapon_stubs_portal.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalbase.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalbase.h"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalbasecombatweapon.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalbasecombatweapon.h"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalgun_shared.cpp"
|
||||
$File "$SRCDIR\game\shared\portal\weapon_portalgun_shared.h"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "achievement_stats_summary.h"
|
||||
#include "achievements_page.h"
|
||||
#include "lifetime_stats_page.h"
|
||||
#include "match_stats_page.h"
|
||||
#include "stats_summary.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include <KeyValues.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
const int cDialogWidth = 900;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CAchievementAndStatsSummary::CAchievementAndStatsSummary(vgui::Panel *parent) : BaseClass(parent, "AchievementAndStatsSummary")
|
||||
{
|
||||
SetDeleteSelfOnClose(false);
|
||||
//SetBounds(0, 0, 640, 384);
|
||||
SetBounds(0, 0, 900, 780);
|
||||
SetMinimumSize( 640, 780 );
|
||||
SetSizeable( false );
|
||||
|
||||
SetTitle("#GameUI_CreateAchievementsAndStats", true);
|
||||
SetOKButtonText("#GameUI_Close");
|
||||
SetCancelButtonVisible(false);
|
||||
|
||||
m_pStatsSummary = new CStatsSummary( this, "StatsSummary" );
|
||||
m_pAchievementsPage = new CAchievementsPage(this, "AchievementsPage");
|
||||
m_pLifetimeStatsPage = new CLifetimeStatsPage(this, "StatsPage");
|
||||
m_pMatchStatsPage = new CMatchStatsPage(this, "MatchStatsPage");
|
||||
|
||||
AddPage(m_pStatsSummary, "#GameUI_Stats_Summary");
|
||||
AddPage(m_pAchievementsPage, "#GameUI_Achievements_Tab");
|
||||
AddPage(m_pMatchStatsPage, "#GameUI_MatchStats");
|
||||
AddPage(m_pLifetimeStatsPage, "#GameUI_LifetimeStats");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CAchievementAndStatsSummary::~CAchievementAndStatsSummary()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementAndStatsSummary::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
int screenWide, screenTall;
|
||||
surface()->GetScreenSize( screenWide, screenTall );
|
||||
|
||||
// [smessick] Close the achievements dialog for a low resolution screen.
|
||||
if ( screenWide < cAchievementsDialogMinWidth )
|
||||
{
|
||||
OnOK( true );
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: runs the server when the OK button is pressed
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CAchievementAndStatsSummary::OnOK(bool applyOnly)
|
||||
{
|
||||
BaseClass::OnOK(applyOnly);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Purpose: Preserve our width to the one in the .res file
|
||||
//----------------------------------------------------------
|
||||
void CAchievementAndStatsSummary::OnSizeChanged(int newWide, int newTall)
|
||||
{
|
||||
// Lock the width, but allow height scaling
|
||||
if ( newWide != cDialogWidth )
|
||||
{
|
||||
SetSize( cDialogWidth, newTall );
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnSizeChanged(newWide, newTall);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Purpose: Processes when summary dialog is activated.
|
||||
//----------------------------------------------------------
|
||||
void CAchievementAndStatsSummary::Activate()
|
||||
{
|
||||
m_pStatsSummary->MakeReadyForUse();
|
||||
m_pStatsSummary->UpdateStatsData();
|
||||
m_pAchievementsPage->UpdateAchievementDialogInfo();
|
||||
m_pLifetimeStatsPage->UpdateStatsData();
|
||||
m_pMatchStatsPage->UpdateStatsData();
|
||||
|
||||
BaseClass::Activate();
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACHIEVEMENTANDSTATSSUMMARY_H
|
||||
#define ACHIEVEMENTANDSTATSSUMMARY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyDialog.h>
|
||||
|
||||
class CAchievementsPage;
|
||||
class CLifetimeStatsPage;
|
||||
class CMatchStatsPage;
|
||||
class StatCard;
|
||||
class CStatsSummary;
|
||||
|
||||
const int cAchievementsDialogMinWidth = 1024; // don't show this screen for lower resolutions
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: dialog for displaying the achievements/stats summary
|
||||
//-----------------------------------------------------------------------------
|
||||
class CAchievementAndStatsSummary : public vgui::PropertyDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CAchievementAndStatsSummary, vgui::PropertyDialog );
|
||||
|
||||
public:
|
||||
CAchievementAndStatsSummary(vgui::Panel *parent);
|
||||
~CAchievementAndStatsSummary();
|
||||
|
||||
virtual void Activate();
|
||||
|
||||
void OnKeyCodePressed( vgui::KeyCode code )
|
||||
{
|
||||
if ( code == KEY_XBUTTON_B )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool OnOK(bool applyOnly);
|
||||
virtual void OnSizeChanged( int newWide, int newTall );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
private:
|
||||
CAchievementsPage* m_pAchievementsPage;
|
||||
CLifetimeStatsPage* m_pLifetimeStatsPage;
|
||||
CMatchStatsPage* m_pMatchStatsPage;
|
||||
CStatsSummary* m_pStatsSummary;
|
||||
};
|
||||
|
||||
|
||||
#endif // ACHIEVEMENTANDSTATSSUMMARY_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,218 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSACHIEVEMENTSPAGE_H
|
||||
#define CSACHIEVEMENTSPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "vgui_controls/PropertyPage.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "vgui_avatarimage.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
class CCSBaseAchievement;
|
||||
class IScheme;
|
||||
class CAchievementsPageGroupPanel;
|
||||
class StatCard;
|
||||
|
||||
#define ACHIEVED_ICON_PATH "hud/icon_check.vtf"
|
||||
#define LOCK_ICON_PATH "hud/icon_locked.vtf"
|
||||
|
||||
// Loads an achievement's icon into a specified image panel, or turns the panel off if no achievement icon was found.
|
||||
bool CSLoadAchievementIconForPage( vgui::ImagePanel* pIconPanel, CCSBaseAchievement *pAchievement, const char *pszExt = NULL );
|
||||
|
||||
// Loads an achievement's icon into a specified image panel, or turns the panel off if no achievement icon was found.
|
||||
bool CSLoadIconForPage( vgui::ImagePanel* pIconPanel, const char* pFilename, const char *pszExt = NULL );
|
||||
|
||||
// Updates a listed achievement item's progress bar.
|
||||
void CSUpdateProgressBarForPage( vgui::EditablePanel* pPanel, CCSBaseAchievement *pAchievement, Color clrProgressBar );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// PC version
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CAchievementsPage : public vgui::PropertyPage, public CGameEventListener
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE ( CAchievementsPage, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
CAchievementsPage( vgui::Panel *parent, const char *name );
|
||||
~CAchievementsPage();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
void UpdateTotalProgressDisplay();
|
||||
virtual void UpdateAchievementDialogInfo( void );
|
||||
|
||||
virtual void OnPageShow();
|
||||
virtual void OnThink();
|
||||
|
||||
virtual void ApplySettings( KeyValues *pResourceData );
|
||||
virtual void OnSizeChanged( int newWide, int newTall );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void CreateNewAchievementGroup( int iMinRange, int iMaxRange );
|
||||
void CreateOrUpdateComboItems( bool bCreate );
|
||||
void UpdateAchievementList(CAchievementsPageGroupPanel* groupPanel);
|
||||
void UpdateAchievementList(int minID, int maxID);
|
||||
|
||||
vgui::PanelListPanel *m_pAchievementsList;
|
||||
vgui::ImagePanel *m_pListBG;
|
||||
|
||||
vgui::PanelListPanel *m_pGroupsList;
|
||||
vgui::ImagePanel *m_pGroupListBG;
|
||||
|
||||
vgui::ImagePanel *m_pPercentageBarBackground;
|
||||
vgui::ImagePanel *m_pPercentageBar;
|
||||
|
||||
StatCard* m_pStatCard;
|
||||
|
||||
int m_iFixedWidth;
|
||||
|
||||
bool m_bStatsDirty;
|
||||
bool m_bAchievementsDirty;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int m_iMinRange;
|
||||
int m_iMaxRange;
|
||||
} achievement_group_t;
|
||||
|
||||
int m_iNumAchievementGroups;
|
||||
|
||||
achievement_group_t m_AchievementGroups[15];
|
||||
};
|
||||
|
||||
class CHiddenHUDToggleButton : public vgui::Button
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHiddenHUDToggleButton, vgui::Button );
|
||||
|
||||
public:
|
||||
|
||||
CHiddenHUDToggleButton( vgui::Panel *pParent, const char *pName, const char *pText );
|
||||
|
||||
virtual void DoClick( void );
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Individual item panel, displaying stats for one achievement
|
||||
class CAchievementsPageItemPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CAchievementsPageItemPanel, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CAchievementsPageItemPanel( vgui::PanelListPanel *parent, const char* name);
|
||||
~CAchievementsPageItemPanel();
|
||||
|
||||
void SetAchievementInfo ( CCSBaseAchievement* pAchievement );
|
||||
CCSBaseAchievement* GetAchievementInfo( void ) { return m_pSourceAchievement; }
|
||||
void UpdateAchievementInfo( vgui::IScheme *pScheme );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
void ToggleShowOnHUDButton();
|
||||
|
||||
MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
|
||||
|
||||
private:
|
||||
static void PreloadResourceFile();
|
||||
|
||||
CCSBaseAchievement* m_pSourceAchievement;
|
||||
int m_iSourceAchievementIndex;
|
||||
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
|
||||
vgui::Label *m_pAchievementNameLabel;
|
||||
vgui::Label *m_pAchievementDescLabel;
|
||||
vgui::Label *m_pPercentageText;
|
||||
vgui::Label *m_pAwardDate;
|
||||
|
||||
vgui::ImagePanel *m_pLockedIcon;
|
||||
vgui::ImagePanel *m_pAchievementIcon;
|
||||
|
||||
vgui::ImagePanel *m_pPercentageBarBackground;
|
||||
vgui::ImagePanel *m_pPercentageBar;
|
||||
|
||||
vgui::CheckButton *m_pShowOnHUDButton;
|
||||
|
||||
vgui::IScheme *m_pSchemeSettings;
|
||||
|
||||
CHiddenHUDToggleButton *m_pHiddenHUDToggleButton;
|
||||
|
||||
CPanelAnimationVar( Color, m_clrProgressBar, "ProgressBarColor", "140 140 140 255" );
|
||||
};
|
||||
|
||||
class CGroupButton : public vgui::Button
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CGroupButton, vgui::Button );
|
||||
|
||||
public:
|
||||
|
||||
CGroupButton( vgui::Panel *pParent, const char *pName, const char *pText );
|
||||
|
||||
virtual void DoClick( void );
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Individual achievement group panel, displaying info for one achievement group
|
||||
class CAchievementsPageGroupPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CAchievementsPageGroupPanel, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CAchievementsPageGroupPanel( vgui::PanelListPanel *parent, CAchievementsPage *owner, const char* name, int iListItemID );
|
||||
~CAchievementsPageGroupPanel();
|
||||
|
||||
void SetGroupInfo ( const wchar_t* name, int firstAchievementID, int lastAchievementID );
|
||||
void UpdateAchievementInfo( vgui::IScheme *pScheme );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
int GetFirstAchievementID() { return m_iFirstAchievementID; }
|
||||
int GetLastAchievementID() { return m_iLastAchievementID; }
|
||||
|
||||
vgui::PanelListPanel* GetParent() { return m_pParent; }
|
||||
CAchievementsPage* GetOwner() { return m_pOwner; }
|
||||
|
||||
void SetGroupActive(bool active) { m_bActiveButton = active; }
|
||||
bool IsGroupActive() { return m_bActiveButton; }
|
||||
|
||||
private:
|
||||
void PreloadResourceFile( void );
|
||||
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
CAchievementsPage *m_pOwner;
|
||||
|
||||
vgui::Label *m_pAchievementGroupLabel;
|
||||
vgui::Label *m_pPercentageText;
|
||||
|
||||
CGroupButton *m_pGroupButton;
|
||||
|
||||
vgui::ImagePanel *m_pGroupIcon;
|
||||
|
||||
vgui::ImagePanel *m_pPercentageBarBackground;
|
||||
vgui::ImagePanel *m_pPercentageBar;
|
||||
|
||||
vgui::IScheme *m_pSchemeSettings;
|
||||
|
||||
bool m_bActiveButton;
|
||||
|
||||
CPanelAnimationVar( Color, m_clrProgressBar, "ProgressBarColor", "140 140 140 255" );
|
||||
|
||||
int m_iFirstAchievementID;
|
||||
int m_iLastAchievementID;
|
||||
|
||||
wchar_t *m_pGroupName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CSACHIEVEMENTSPAGE_H
|
||||
@@ -1,676 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "backgroundpanel.h"
|
||||
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "vgui_controls/BuildGroup.h"
|
||||
#include "vgui_controls/BitmapImagePanel.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define DEBUG_WINDOW_RESIZING 0
|
||||
#define DEBUG_WINDOW_REPOSITIONING 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const int NumSegments = 7;
|
||||
static int coord[NumSegments+1] = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
6,
|
||||
9,
|
||||
10
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void DrawRoundedBackground( Color bgColor, int wide, int tall )
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
surface()->DrawSetColor(bgColor);
|
||||
surface()->DrawSetTextColor(bgColor);
|
||||
|
||||
int i;
|
||||
|
||||
// top-left corner --------------------------------------------------------
|
||||
int xDir = 1;
|
||||
int yDir = -1;
|
||||
int xIndex = 0;
|
||||
int yIndex = NumSegments - 1;
|
||||
int xMult = 1;
|
||||
int yMult = 1;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = y + coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// top-right corner -------------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = wide;
|
||||
y = 0;
|
||||
xMult = -1;
|
||||
yMult = 1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = y + coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// bottom-right corner ----------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = wide;
|
||||
y = tall;
|
||||
xMult = -1;
|
||||
yMult = -1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = y - coord[NumSegments];
|
||||
y2 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// bottom-left corner -----------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = 0;
|
||||
y = tall;
|
||||
xMult = 1;
|
||||
yMult = -1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = y - coord[NumSegments];
|
||||
y2 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// paint between top left and bottom left ---------------------------------
|
||||
x1 = 0;
|
||||
x2 = coord[NumSegments];
|
||||
y1 = coord[NumSegments];
|
||||
y2 = tall - coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
// paint between left and right -------------------------------------------
|
||||
x1 = coord[NumSegments];
|
||||
x2 = wide - coord[NumSegments];
|
||||
y1 = 0;
|
||||
y2 = tall;
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
// paint between top right and bottom right -------------------------------
|
||||
x1 = wide - coord[NumSegments];
|
||||
x2 = wide;
|
||||
y1 = coord[NumSegments];
|
||||
y2 = tall - coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void DrawRoundedBorder( Color borderColor, int wide, int tall )
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
surface()->DrawSetColor(borderColor);
|
||||
surface()->DrawSetTextColor(borderColor);
|
||||
|
||||
int i;
|
||||
|
||||
// top-left corner --------------------------------------------------------
|
||||
int xDir = 1;
|
||||
int yDir = -1;
|
||||
int xIndex = 0;
|
||||
int yIndex = NumSegments - 1;
|
||||
int xMult = 1;
|
||||
int yMult = 1;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// top-right corner -------------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = wide;
|
||||
y = 0;
|
||||
xMult = -1;
|
||||
yMult = 1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// bottom-right corner ----------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = wide;
|
||||
y = tall;
|
||||
xMult = -1;
|
||||
yMult = -1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// bottom-left corner -----------------------------------------------------
|
||||
xDir = 1;
|
||||
yDir = -1;
|
||||
xIndex = 0;
|
||||
yIndex = NumSegments - 1;
|
||||
x = 0;
|
||||
y = tall;
|
||||
xMult = 1;
|
||||
yMult = -1;
|
||||
for ( i=0; i<NumSegments; ++i )
|
||||
{
|
||||
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
|
||||
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
xIndex += xDir;
|
||||
yIndex += yDir;
|
||||
}
|
||||
|
||||
// top --------------------------------------------------------------------
|
||||
x1 = coord[NumSegments];
|
||||
x2 = wide - coord[NumSegments];
|
||||
y1 = 0;
|
||||
y2 = 1;
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
// bottom -----------------------------------------------------------------
|
||||
x1 = coord[NumSegments];
|
||||
x2 = wide - coord[NumSegments];
|
||||
y1 = tall - 1;
|
||||
y2 = tall;
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
// left -------------------------------------------------------------------
|
||||
x1 = 0;
|
||||
x2 = 1;
|
||||
y1 = coord[NumSegments];
|
||||
y2 = tall - coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
|
||||
// right ------------------------------------------------------------------
|
||||
x1 = wide - 1;
|
||||
x2 = wide;
|
||||
y1 = coord[NumSegments];
|
||||
y2 = tall - coord[NumSegments];
|
||||
surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CaptionLabel : public Label
|
||||
{
|
||||
public:
|
||||
CaptionLabel(Panel *parent, const char *panelName, const char *text) : Label(parent, panelName, text)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
Label::ApplySchemeSettings( pScheme );
|
||||
SetFont( pScheme->GetFont( "MenuTitle", IsProportional() ) );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: transform a normalized value into one that is scaled based the minimum
|
||||
// of the horizontal and vertical ratios
|
||||
//-----------------------------------------------------------------------------
|
||||
static int GetAlternateProportionalValueFromNormal(int normalizedValue)
|
||||
{
|
||||
int wide, tall;
|
||||
GetHudSize( wide, tall );
|
||||
int proH, proW;
|
||||
surface()->GetProportionalBase( proW, proH );
|
||||
double scaleH = (double)tall / (double)proH;
|
||||
double scaleW = (double)wide / (double)proW;
|
||||
double scale = (scaleW < scaleH) ? scaleW : scaleH;
|
||||
|
||||
return (int)( normalizedValue * scale );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: transform a standard scaled value into one that is scaled based the minimum
|
||||
// of the horizontal and vertical ratios
|
||||
//-----------------------------------------------------------------------------
|
||||
int GetAlternateProportionalValueFromScaled( HScheme hScheme, int scaledValue)
|
||||
{
|
||||
return GetAlternateProportionalValueFromNormal( scheme()->GetProportionalNormalizedValueEx( hScheme, scaledValue ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: moves and resizes a single control
|
||||
//-----------------------------------------------------------------------------
|
||||
static void RepositionControl( Panel *pPanel )
|
||||
{
|
||||
int x, y, w, h;
|
||||
pPanel->GetBounds(x, y, w, h);
|
||||
|
||||
#if DEBUG_WINDOW_RESIZING
|
||||
int x1, y1, w1, h1;
|
||||
pPanel->GetBounds(x1, y1, w1, h1);
|
||||
int x2, y2, w2, h2;
|
||||
x2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(), x1 );
|
||||
y2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(), y1 );
|
||||
w2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(), w1 );
|
||||
h2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(), h1 );
|
||||
#endif
|
||||
|
||||
x = GetAlternateProportionalValueFromScaled( pPanel->GetScheme(), x );
|
||||
y = GetAlternateProportionalValueFromScaled( pPanel->GetScheme(), y );
|
||||
w = GetAlternateProportionalValueFromScaled( pPanel->GetScheme(), w );
|
||||
h = GetAlternateProportionalValueFromScaled( pPanel->GetScheme(), h );
|
||||
|
||||
pPanel->SetBounds(x, y, w, h);
|
||||
|
||||
#if DEBUG_WINDOW_RESIZING
|
||||
DevMsg( "Resizing '%s' from (%d,%d) %dx%d to (%d,%d) %dx%d -- initially was (%d,%d) %dx%d\n",
|
||||
pPanel->GetName(), x1, y1, w1, h1, x, y, w, h, x2, y2, w2, h2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets colors etc for background image panels
|
||||
//-----------------------------------------------------------------------------
|
||||
void ApplyBackgroundSchemeSettings( EditablePanel *pWindow, vgui::IScheme *pScheme )
|
||||
{
|
||||
Color bgColor = Color( 255, 255, 255, pScheme->GetColor( "BgColor", Color( 0, 0, 0, 0 ) )[3] );
|
||||
Color fgColor = pScheme->GetColor( "FgColor", Color( 0, 0, 0, 0 ) );
|
||||
|
||||
if ( !pWindow )
|
||||
return;
|
||||
|
||||
CBitmapImagePanel *pBitmapPanel;
|
||||
|
||||
// corners --------------------------------------------
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopLeftPanel" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopRightPanel" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomLeftPanel" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomRightPanel" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
|
||||
// background -----------------------------------------
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopSolid" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "UpperMiddleSolid" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "LowerMiddleSolid" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomSolid" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( bgColor );
|
||||
}
|
||||
|
||||
// Logo -----------------------------------------------
|
||||
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "ExclamationPanel" ));
|
||||
if ( pBitmapPanel )
|
||||
{
|
||||
pBitmapPanel->setImageColor( fgColor );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Re-aligns background image panels so they are touching.
|
||||
//-----------------------------------------------------------------------------
|
||||
static void FixupBackgroundPanels( EditablePanel *pWindow, int offsetX, int offsetY )
|
||||
{
|
||||
if ( !pWindow )
|
||||
return;
|
||||
|
||||
int screenWide, screenTall;
|
||||
pWindow->GetSize( screenWide, screenTall );
|
||||
|
||||
int inset = GetAlternateProportionalValueFromNormal( 20 );
|
||||
int cornerSize = GetAlternateProportionalValueFromNormal( 10 );
|
||||
|
||||
int titleHeight = GetAlternateProportionalValueFromNormal( 42 );
|
||||
int mainHeight = GetAlternateProportionalValueFromNormal( 376 );
|
||||
|
||||
int logoSize = titleHeight;
|
||||
|
||||
int captionInset = GetAlternateProportionalValueFromNormal( 76 );
|
||||
|
||||
Panel *pPanel;
|
||||
|
||||
// corners --------------------------------------------
|
||||
pPanel = pWindow->FindChildByName( "TopLeftPanel" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset, offsetY + inset, cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "TopRightPanel" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, offsetY + inset, cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "BottomLeftPanel" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "BottomRightPanel" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
// background -----------------------------------------
|
||||
pPanel = pWindow->FindChildByName( "TopSolid" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset + cornerSize, offsetY + inset, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "UpperMiddleSolid" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset, offsetY + inset + cornerSize, screenWide - 2*offsetX - 2*inset, titleHeight );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "LowerMiddleSolid" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset + cornerSize, screenTall - offsetY - inset - cornerSize, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "BottomSolid" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize - mainHeight, screenWide - 2*offsetX - 2*inset, mainHeight );
|
||||
}
|
||||
|
||||
// transparent border ---------------------------------
|
||||
pPanel = pWindow->FindChildByName( "TopClear" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( 0, 0, screenWide, offsetY + inset );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "BottomClear" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( 0, screenTall - offsetY - inset, screenWide, offsetY + inset );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "LeftClear" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( 0, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset );
|
||||
}
|
||||
|
||||
pPanel = pWindow->FindChildByName( "RightClear" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -20 );
|
||||
pPanel->SetBounds( screenWide - offsetX - inset, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset );
|
||||
}
|
||||
|
||||
// Logo -----------------------------------------------
|
||||
int logoInset = (cornerSize + titleHeight - logoSize)/2;
|
||||
pPanel = pWindow->FindChildByName( "ExclamationPanel" );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -19 ); // higher than the background
|
||||
pPanel->SetBounds( offsetX + inset + logoInset, offsetY + inset + logoInset, logoSize, logoSize );
|
||||
}
|
||||
|
||||
// Title caption --------------------------------------
|
||||
pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" ));
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetZPos( -19 ); // higher than the background
|
||||
pPanel->SetBounds( offsetX + captionInset/*inset + 2*logoInset + logoSize*/, offsetY + inset + logoInset, screenWide, logoSize );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates background image panels
|
||||
//-----------------------------------------------------------------------------
|
||||
void CreateBackground( EditablePanel *pWindow )
|
||||
{
|
||||
// corners --------------------------------------------
|
||||
new CBitmapImagePanel( pWindow, "TopLeftPanel", "gfx/vgui/round_corner_nw" );
|
||||
new CBitmapImagePanel( pWindow, "TopRightPanel", "gfx/vgui/round_corner_ne" );
|
||||
new CBitmapImagePanel( pWindow, "BottomLeftPanel", "gfx/vgui/round_corner_sw" );
|
||||
new CBitmapImagePanel( pWindow, "BottomRightPanel", "gfx/vgui/round_corner_se" );
|
||||
|
||||
// background -----------------------------------------
|
||||
new CBitmapImagePanel( pWindow, "TopSolid", "gfx/vgui/solid_background" );
|
||||
new CBitmapImagePanel( pWindow, "UpperMiddleSolid", "gfx/vgui/solid_background" );
|
||||
new CBitmapImagePanel( pWindow, "LowerMiddleSolid", "gfx/vgui/solid_background" );
|
||||
new CBitmapImagePanel( pWindow, "BottomSolid", "gfx/vgui/solid_background" );
|
||||
|
||||
// transparent border ---------------------------------
|
||||
new CBitmapImagePanel( pWindow, "TopClear", "gfx/vgui/trans_background" );
|
||||
new CBitmapImagePanel( pWindow, "BottomClear", "gfx/vgui/trans_background" );
|
||||
new CBitmapImagePanel( pWindow, "LeftClear", "gfx/vgui/trans_background" );
|
||||
new CBitmapImagePanel( pWindow, "RightClear", "gfx/vgui/trans_background" );
|
||||
|
||||
// Logo -----------------------------------------------
|
||||
new CBitmapImagePanel( pWindow, "ExclamationPanel", "gfx/vgui/CS_logo" );
|
||||
|
||||
// Title caption --------------------------------------
|
||||
Panel *pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" ));
|
||||
if ( !pPanel )
|
||||
new CaptionLabel( pWindow, "CaptionLabel", "" );
|
||||
}
|
||||
|
||||
void ResizeWindowControls( EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY )
|
||||
{
|
||||
if (!pWindow || !pWindow->GetBuildGroup() || !pWindow->GetBuildGroup()->GetPanelList())
|
||||
return;
|
||||
|
||||
CUtlVector<PHandle> *panelList = pWindow->GetBuildGroup()->GetPanelList();
|
||||
CUtlVector<Panel *> resizedPanels;
|
||||
CUtlVector<Panel *> movedPanels;
|
||||
|
||||
// Resize to account for 1.25 aspect ratio (1280x1024) screens
|
||||
{
|
||||
for ( int i = 0; i < panelList->Size(); ++i )
|
||||
{
|
||||
PHandle handle = (*panelList)[i];
|
||||
|
||||
Panel *panel = handle.Get();
|
||||
|
||||
bool found = false;
|
||||
for ( int j = 0; j < resizedPanels.Size(); ++j )
|
||||
{
|
||||
if (panel == resizedPanels[j])
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!panel || found)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
resizedPanels.AddToTail( panel ); // don't move a panel more than once
|
||||
|
||||
if ( panel != pWindow )
|
||||
{
|
||||
RepositionControl( panel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// and now re-center them. Woohoo!
|
||||
for ( int i = 0; i < panelList->Size(); ++i )
|
||||
{
|
||||
PHandle handle = (*panelList)[i];
|
||||
|
||||
Panel *panel = handle.Get();
|
||||
|
||||
bool found = false;
|
||||
for ( int j = 0; j < movedPanels.Size(); ++j )
|
||||
{
|
||||
if (panel == movedPanels[j])
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!panel || found)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
movedPanels.AddToTail( panel ); // don't move a panel more than once
|
||||
|
||||
if ( panel != pWindow )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
panel->GetPos( x, y );
|
||||
panel->SetPos( x + offsetX, y + offsetY );
|
||||
|
||||
#if DEBUG_WINDOW_REPOSITIONING
|
||||
DevMsg( "Repositioning '%s' from (%d,%d) to (%d,%d) -- a distance of (%d,%d)\n",
|
||||
panel->GetName(), x, y, x + offsetX, y + offsetY, offsetX, offsetY );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and
|
||||
// centers them on the screen. Sub-controls are also resized and moved.
|
||||
//-----------------------------------------------------------------------------
|
||||
void LayoutBackgroundPanel( EditablePanel *pWindow )
|
||||
{
|
||||
if ( !pWindow )
|
||||
return;
|
||||
|
||||
int screenW, screenH;
|
||||
GetHudSize( screenW, screenH );
|
||||
|
||||
int wide, tall;
|
||||
pWindow->GetSize( wide, tall );
|
||||
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
|
||||
// Slide everything over to the center
|
||||
pWindow->SetBounds( 0, 0, screenW, screenH );
|
||||
|
||||
if ( wide != screenW || tall != screenH )
|
||||
{
|
||||
wide = GetAlternateProportionalValueFromScaled( pWindow->GetScheme(), wide);
|
||||
tall = GetAlternateProportionalValueFromScaled( pWindow->GetScheme(), tall);
|
||||
|
||||
offsetX = (screenW - wide)/2;
|
||||
offsetY = (screenH - tall)/2;
|
||||
|
||||
ResizeWindowControls( pWindow, tall, wide, offsetX, offsetY );
|
||||
}
|
||||
|
||||
// now that the panels are moved/resized, look for some bg panels, and re-align them
|
||||
FixupBackgroundPanels( pWindow, offsetX, offsetY );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSBACKGROUND_H
|
||||
#define CSBACKGROUND_H
|
||||
|
||||
#include <vgui_controls/Frame.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates background image panels
|
||||
//-----------------------------------------------------------------------------
|
||||
void CreateBackground( vgui::EditablePanel *pWindow );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and
|
||||
// centers them on the screen. Sub-controls are also resized and moved.
|
||||
//-----------------------------------------------------------------------------
|
||||
void LayoutBackgroundPanel( vgui::EditablePanel *pWindow );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets colors etc for background image panels
|
||||
//-----------------------------------------------------------------------------
|
||||
void ApplyBackgroundSchemeSettings( vgui::EditablePanel *pWindow, vgui::IScheme *pScheme );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ResizeWindowControls( vgui::EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: transform a standard scaled value into one that is scaled based the minimum
|
||||
// of the horizontal and vertical ratios
|
||||
//-----------------------------------------------------------------------------
|
||||
int GetAlternateProportionalValueFromScaled( vgui::HScheme scheme, int scaledValue );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void DrawRoundedBackground( Color bgColor, int wide, int tall );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void DrawRoundedBorder( Color borderColor, int wide, int tall );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // CSBACKGROUND_H
|
||||
@@ -1,359 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "tier3/tier3.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "lifetime_stats_page.h"
|
||||
#include <vgui_controls/SectionedListPanel.h>
|
||||
#include "cs_client_gamestats.h"
|
||||
#include "filesystem.h"
|
||||
#include "cs_weapon_parse.h"
|
||||
#include "buy_presets/buy_presets.h"
|
||||
#include "../vgui_controls/ScrollBar.h"
|
||||
#include "stat_card.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
KeyValues *g_pPreloadedCSBaseStatGroupLayout = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: creates child panels, passes down name to pick up any settings from res files.
|
||||
//-----------------------------------------------------------------------------
|
||||
CBaseStatsPage::CBaseStatsPage(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSBaseStatsDialog")
|
||||
{
|
||||
vgui::IScheme *pScheme = scheme()->GetIScheme( GetScheme() );
|
||||
|
||||
m_listItemFont = pScheme->GetFont( "StatsPageText", IsProportional() );
|
||||
|
||||
m_statsList = new SectionedListPanel( this, "StatsList" );
|
||||
m_statsList->SetClickable(false);
|
||||
m_statsList->SetDrawHeaders(false);
|
||||
|
||||
m_bottomBar = new ImagePanel(this, "BottomBar");
|
||||
|
||||
m_pGroupsList = new vgui::PanelListPanel( this, "listpanel_groups" );
|
||||
m_pGroupsList->SetFirstColumnWidth( 0 );
|
||||
|
||||
SetBounds(0, 0, 900, 780);
|
||||
SetMinimumSize( 256, 780 );
|
||||
|
||||
SetBgColor(GetSchemeColor("ListPanel.BgColor", GetBgColor(), pScheme));
|
||||
|
||||
m_pStatCard = new StatCard(this, "ignored");
|
||||
|
||||
ListenForGameEvent( "player_stats_updated" );
|
||||
|
||||
m_bStatsDirty = true;
|
||||
}
|
||||
|
||||
CBaseStatsPage::~CBaseStatsPage()
|
||||
{
|
||||
delete m_statsList;
|
||||
}
|
||||
|
||||
|
||||
void CBaseStatsPage::MoveToFront()
|
||||
{
|
||||
UpdateStatsData();
|
||||
m_pStatCard->UpdateInfo();
|
||||
}
|
||||
|
||||
void CBaseStatsPage::UpdateStatsData()
|
||||
{
|
||||
// Hide the group list scrollbar
|
||||
if (m_pGroupsList->GetScrollbar())
|
||||
{
|
||||
m_pGroupsList->GetScrollbar()->SetWide(0);
|
||||
}
|
||||
|
||||
UpdateGroupPanels();
|
||||
RepopulateStats();
|
||||
|
||||
m_bStatsDirty = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads settings from statsdialog.res in hl2/resource/ui/
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseStatsPage::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
LoadControlSettings("resource/ui/CSBaseStatsDialog.res");
|
||||
|
||||
m_statsList->SetClickable(false);
|
||||
m_statsList->SetDrawHeaders(false);
|
||||
|
||||
m_statsList->SetVerticalScrollbar(true);
|
||||
|
||||
SetBgColor(Color(86,86,86,255));
|
||||
|
||||
//Remove any pre-existing sections and add then fresh (this can happen on a resolution change)
|
||||
m_statsList->RemoveAllSections();
|
||||
|
||||
m_statsList->AddSection( 0, "Players");
|
||||
|
||||
m_statsList->SetFontSection(0, m_listItemFont);
|
||||
|
||||
m_pGroupsList->SetBgColor(Color(86,86,86,255));
|
||||
m_statsList->SetBgColor(Color(52,52,52,255));
|
||||
}
|
||||
|
||||
void CBaseStatsPage::SetActiveStatGroup (CBaseStatGroupPanel* groupPanel)
|
||||
{
|
||||
for (int i = 0; i < m_pGroupsList->GetItemCount(); i++)
|
||||
{
|
||||
CBaseStatGroupPanel *pPanel = (CBaseStatGroupPanel*)m_pGroupsList->GetItemPanel(i);
|
||||
if ( pPanel )
|
||||
{
|
||||
if ( pPanel != groupPanel )
|
||||
{
|
||||
pPanel->SetGroupActive( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPanel->SetGroupActive( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseStatsPage::UpdateGroupPanels()
|
||||
{
|
||||
int iGroupCount = m_pGroupsList->GetItemCount();
|
||||
vgui::IScheme *pGroupScheme = scheme()->GetIScheme( GetScheme() );
|
||||
|
||||
for ( int i = 0; i < iGroupCount; i++ )
|
||||
{
|
||||
CBaseStatGroupPanel *pPanel = (CBaseStatGroupPanel*)m_pGroupsList->GetItemPanel(i);
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->Update( pGroupScheme );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBaseStatsPage::OnSizeChanged(int newWide, int newTall)
|
||||
{
|
||||
BaseClass::OnSizeChanged(newWide, newTall);
|
||||
|
||||
if (m_statsList)
|
||||
{
|
||||
int labelX, labelY, listX, listY, listWide, listTall;
|
||||
m_statsList->GetBounds(listX, listY, listWide, listTall);
|
||||
|
||||
if (m_bottomBar)
|
||||
{
|
||||
m_bottomBar->GetPos(labelX, labelY);
|
||||
m_bottomBar->SetPos(labelX, listY + listTall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* CBaseStatsPage::TranslateWeaponKillIDToAlias( int statKillID )
|
||||
{
|
||||
CSWeaponID weaponIDIndex = WEAPON_MAX;
|
||||
for ( int i = 0; WeaponName_StatId_Table[i].killStatId != CSSTAT_UNDEFINED; ++i )
|
||||
{
|
||||
if( WeaponName_StatId_Table[i].killStatId == statKillID )
|
||||
{
|
||||
weaponIDIndex = WeaponName_StatId_Table[i].weaponId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (weaponIDIndex == WEAPON_MAX)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return WeaponIDToDisplayName(weaponIDIndex);
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* CBaseStatsPage::LocalizeTagOrUseDefault( const char* tag, const wchar_t* def )
|
||||
{
|
||||
const wchar_t* result = g_pVGuiLocalize->Find( tag );
|
||||
|
||||
if ( !result )
|
||||
result = def ? def : L"\0";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CBaseStatGroupPanel* CBaseStatsPage::AddGroup( const wchar_t* name, const char* title_tag, const wchar_t* def )
|
||||
{
|
||||
CBaseStatGroupPanel* newGroup = new CBaseStatGroupPanel( m_pGroupsList, this, "StatGroupPanel", 0 );
|
||||
newGroup->SetGroupInfo( name, LocalizeTagOrUseDefault( title_tag, def ) );
|
||||
newGroup->SetGroupActive( false );
|
||||
|
||||
m_pGroupsList->AddItem( NULL, newGroup );
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
void CBaseStatsPage::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
|
||||
if ( 0 == Q_strcmp( type, "player_stats_updated" ) )
|
||||
m_bStatsDirty = true;
|
||||
}
|
||||
|
||||
void CBaseStatsPage::OnThink()
|
||||
{
|
||||
if ( m_bStatsDirty )
|
||||
UpdateStatsData();
|
||||
}
|
||||
|
||||
CBaseStatGroupPanel::CBaseStatGroupPanel( vgui::PanelListPanel *parent, CBaseStatsPage *owner, const char* name, int iListItemID ) : BaseClass( parent, name )
|
||||
{
|
||||
m_pParent = parent;
|
||||
m_pOwner = owner;
|
||||
m_pSchemeSettings = NULL;
|
||||
|
||||
m_pGroupIcon = SETUP_PANEL(new vgui::ImagePanel( this, "GroupIcon" ));
|
||||
m_pBaseStatGroupLabel = new vgui::Label( this, "GroupName", "name" );
|
||||
m_pGroupButton = new CBaseStatGroupButton(this, "GroupButton", "" );
|
||||
m_pGroupButton->SetPos( 0, 0 );
|
||||
m_pGroupButton->SetZPos( 20 );
|
||||
m_pGroupButton->SetWide( 256 );
|
||||
m_pGroupButton->SetTall( 64 );
|
||||
SetMouseInputEnabled( true );
|
||||
parent->SetMouseInputEnabled( true );
|
||||
|
||||
m_bActiveButton = false;
|
||||
}
|
||||
|
||||
CBaseStatGroupPanel::~CBaseStatGroupPanel()
|
||||
{
|
||||
delete m_pBaseStatGroupLabel;
|
||||
delete m_pGroupIcon;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the parameter pIconPanel to display the specified achievement's icon file.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBaseStatGroupPanel::LoadIcon( const char* pFilename)
|
||||
{
|
||||
char imagePath[_MAX_PATH];
|
||||
Q_strncpy( imagePath, "achievements\\", sizeof(imagePath) );
|
||||
Q_strncat( imagePath, pFilename, sizeof(imagePath), COPY_ALL_CHARACTERS );
|
||||
Q_strncat( imagePath, ".vtf", sizeof(imagePath), COPY_ALL_CHARACTERS );
|
||||
|
||||
char checkFile[_MAX_PATH];
|
||||
Q_snprintf( checkFile, sizeof(checkFile), "materials\\vgui\\%s", imagePath );
|
||||
if ( !g_pFullFileSystem->FileExists( checkFile ) )
|
||||
{
|
||||
Q_snprintf( imagePath, sizeof(imagePath), "hud\\icon_locked.vtf" );
|
||||
}
|
||||
|
||||
m_pGroupIcon->SetShouldScaleImage( true );
|
||||
m_pGroupIcon->SetImage( imagePath );
|
||||
m_pGroupIcon->SetVisible( true );
|
||||
|
||||
return m_pGroupIcon->IsVisible();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads settings from hl2/resource/ui/achievementitem.res
|
||||
// Sets display info for this achievement item.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseStatGroupPanel::ApplySchemeSettings( vgui::IScheme* pScheme )
|
||||
{
|
||||
if ( !g_pPreloadedCSBaseStatGroupLayout )
|
||||
{
|
||||
PreloadResourceFile();
|
||||
}
|
||||
|
||||
LoadControlSettings( "", NULL, g_pPreloadedCSBaseStatGroupLayout );
|
||||
|
||||
m_pSchemeSettings = pScheme;
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
void CBaseStatGroupPanel::Update( vgui::IScheme* pScheme )
|
||||
{
|
||||
if ( m_pSchemeSettings )
|
||||
{
|
||||
|
||||
// Set group name text
|
||||
m_pBaseStatGroupLabel->SetText( m_pGroupTitle );
|
||||
m_pBaseStatGroupLabel->SetFgColor(Color(157, 194, 80, 255));
|
||||
|
||||
if ( !m_bActiveButton )
|
||||
{
|
||||
LoadIcon( "achievement-btn-up" );
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadIcon( "achievement-btn-select" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseStatGroupPanel::PreloadResourceFile( void )
|
||||
{
|
||||
const char *controlResourceName = "resource/ui/StatGroup.res";
|
||||
|
||||
g_pPreloadedCSBaseStatGroupLayout = new KeyValues(controlResourceName);
|
||||
g_pPreloadedCSBaseStatGroupLayout->LoadFromFile(g_pFullFileSystem, controlResourceName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Assigns a name and achievement id bounds for an achievement group.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseStatGroupPanel::SetGroupInfo ( const wchar_t* name, const wchar_t* title)
|
||||
{
|
||||
// Store away the group name
|
||||
short _textLen = (short)wcslen(name) + 1;
|
||||
m_pGroupName = new wchar_t[_textLen];
|
||||
Q_memcpy( m_pGroupName, name, _textLen * sizeof(wchar_t) );
|
||||
|
||||
_textLen = (short)wcslen(title) + 1;
|
||||
m_pGroupTitle = new wchar_t[_textLen];
|
||||
Q_memcpy( m_pGroupTitle, title, _textLen * sizeof(wchar_t) );
|
||||
}
|
||||
|
||||
|
||||
CBaseStatGroupButton::CBaseStatGroupButton( vgui::Panel *pParent, const char *pName, const char *pText ) :
|
||||
BaseClass( pParent, pName, pText )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handle the case where the user presses an achievement group button.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseStatGroupButton::DoClick( void )
|
||||
{
|
||||
// Process when a group button is hit
|
||||
CBaseStatGroupPanel* pParent = static_cast<CBaseStatGroupPanel*>(GetParent());
|
||||
|
||||
if (pParent)
|
||||
{
|
||||
CBaseStatsPage* pBaseStatsPage = static_cast<CBaseStatsPage*>(pParent->GetOwner());
|
||||
|
||||
if (pBaseStatsPage)
|
||||
{
|
||||
pBaseStatsPage->SetActiveStatGroup( pParent );
|
||||
pBaseStatsPage->UpdateStatsData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSBASESTATSPAGE_H
|
||||
#define CSBASESTATSPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "vgui_controls/PropertyPage.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
struct PlayerStatData_t;
|
||||
class IScheme;
|
||||
class CBaseStatGroupPanel;
|
||||
class StatCard;
|
||||
struct StatsCollection_t;
|
||||
struct RoundStatsDirectAverage_t;
|
||||
|
||||
class CBaseStatsPage : public vgui::PropertyPage, public CGameEventListener
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE ( CBaseStatsPage, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
CBaseStatsPage( vgui::Panel *parent, const char *name );
|
||||
|
||||
~CBaseStatsPage();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void MoveToFront();
|
||||
virtual void OnSizeChanged(int wide, int tall);
|
||||
virtual void OnThink();
|
||||
|
||||
void UpdateStatsData();
|
||||
void SetActiveStatGroup (CBaseStatGroupPanel* groupPanel);
|
||||
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
|
||||
protected:
|
||||
|
||||
void UpdateGroupPanels();
|
||||
CBaseStatGroupPanel* AddGroup( const wchar_t* name, const char* title_tag, const wchar_t* def = NULL );
|
||||
const wchar_t* TranslateWeaponKillIDToAlias( int statKillID );
|
||||
const wchar_t* LocalizeTagOrUseDefault( const char* tag, const wchar_t* def = NULL );
|
||||
|
||||
virtual void RepopulateStats() = 0;
|
||||
|
||||
vgui::SectionedListPanel *m_statsList;
|
||||
vgui::HFont m_listItemFont;
|
||||
|
||||
private:
|
||||
|
||||
vgui::PanelListPanel *m_pGroupsList;
|
||||
vgui::ImagePanel* m_bottomBar;
|
||||
StatCard* m_pStatCard;
|
||||
bool m_bStatsDirty;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CBaseStatGroupButton : public vgui::Button
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBaseStatGroupButton, vgui::Button );
|
||||
|
||||
public:
|
||||
|
||||
CBaseStatGroupButton( vgui::Panel *pParent, const char *pName, const char *pText );
|
||||
|
||||
virtual void DoClick( void );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CBaseStatGroupPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBaseStatGroupPanel, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CBaseStatGroupPanel( vgui::PanelListPanel *parent, CBaseStatsPage *owner, const char* name, int iListItemID );
|
||||
~CBaseStatGroupPanel();
|
||||
|
||||
void SetGroupInfo ( const wchar_t* name, const wchar_t* title);
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
void Update( vgui::IScheme* pScheme );
|
||||
|
||||
vgui::PanelListPanel* GetParent() { return m_pParent; }
|
||||
CBaseStatsPage* GetOwner() { return m_pOwner; }
|
||||
|
||||
void SetGroupActive(bool active) { m_bActiveButton = active; }
|
||||
bool IsGroupActive() { return m_bActiveButton; }
|
||||
|
||||
protected:
|
||||
|
||||
// Loads an icon into a specified image panel, or turns the panel off if no icon was found.
|
||||
bool LoadIcon( const char* pFilename);
|
||||
|
||||
private:
|
||||
void PreloadResourceFile( void );
|
||||
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
CBaseStatsPage *m_pOwner;
|
||||
|
||||
vgui::Label *m_pBaseStatGroupLabel;
|
||||
|
||||
CBaseStatGroupButton *m_pGroupButton;
|
||||
|
||||
vgui::ImagePanel *m_pGroupIcon;
|
||||
|
||||
vgui::IScheme *m_pSchemeSettings;
|
||||
|
||||
bool m_bActiveButton;
|
||||
|
||||
wchar_t *m_pGroupName;
|
||||
wchar_t *m_pGroupTitle;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CSBASESTATSPAGE_H
|
||||
@@ -1,27 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//-------------------------------------------------------------
|
||||
// File: BorderedPanel.cpp
|
||||
// Desc:
|
||||
// Author: Peter Freese <peter@hiddenpath.com>
|
||||
// Date: 2009/05/20
|
||||
// Copyright: <09> 2009 Hidden Path Entertainment
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#include "cbase.h"
|
||||
#include "bordered_panel.h"
|
||||
#include "backgroundpanel.h" // rounded border support
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
void BorderedPanel::PaintBackground()
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
|
||||
DrawRoundedBackground( GetBgColor(), wide, tall );
|
||||
DrawRoundedBorder( GetFgColor(), wide, tall );
|
||||
}
|
||||
|
||||
DECLARE_BUILD_FACTORY( BorderedPanel );
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//-------------------------------------------------------------
|
||||
// File: bordered_panel.h
|
||||
// Desc:
|
||||
// Author: Peter Freese <peter@hiddenpath.com>
|
||||
// Date: 2009/05/20
|
||||
// Copyright: <09> 2009 Hidden Path Entertainment
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#ifndef INCLUDED_BorderedPanel
|
||||
#define INCLUDED_BorderedPanel
|
||||
#pragma once
|
||||
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Editable panel with a forced rounded/outlined border
|
||||
//-----------------------------------------------------------------------------
|
||||
class BorderedPanel : public EditablePanel
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_SIMPLE( BorderedPanel, EditablePanel );
|
||||
|
||||
BorderedPanel( Panel *parent, const char *name ) :
|
||||
EditablePanel( parent, name )
|
||||
{
|
||||
}
|
||||
|
||||
void PaintBackground();
|
||||
};
|
||||
|
||||
|
||||
#endif // INCLUDED_BorderedPanel
|
||||
@@ -1,397 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BUYMOUSEOVERPANELBUTTON_H
|
||||
#define BUYMOUSEOVERPANELBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <filesystem.h>
|
||||
#include "mouseoverpanelbutton.h"
|
||||
#include "hud.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui_controls/ImagePanel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Triggers a new panel when the mouse goes over the button
|
||||
//-----------------------------------------------------------------------------
|
||||
class BuyMouseOverPanelButton : public MouseOverPanelButton
|
||||
{
|
||||
private:
|
||||
typedef MouseOverPanelButton BaseClass;
|
||||
public:
|
||||
BuyMouseOverPanelButton(vgui::Panel *parent, const char *panelName, vgui::EditablePanel *panel) :
|
||||
MouseOverPanelButton( parent, panelName, panel)
|
||||
{
|
||||
m_iPrice = 0;
|
||||
m_iPreviousPrice = 0;
|
||||
m_iASRestrict = 0;
|
||||
m_iDEUseOnly = 0;
|
||||
m_command = NULL;
|
||||
m_bIsBargain = false;
|
||||
|
||||
m_pBlackMarketPrice = NULL;//new EditablePanel( parent, "BlackMarket_Labels" );
|
||||
if ( m_pBlackMarketPrice )
|
||||
{
|
||||
m_pBlackMarketPrice->LoadControlSettings( "Resource/UI/BlackMarket_Labels.res" );
|
||||
|
||||
int x,y,wide,tall;
|
||||
GetClassPanel()->GetBounds( x, y, wide, tall );
|
||||
m_pBlackMarketPrice->SetBounds( x, y, wide, tall );
|
||||
int px, py;
|
||||
GetClassPanel()->GetPinOffset( px, py );
|
||||
int rx, ry;
|
||||
GetClassPanel()->GetResizeOffset( rx, ry );
|
||||
// Apply pin settings from template, too
|
||||
m_pBlackMarketPrice->SetAutoResize( GetClassPanel()->GetPinCorner(), GetClassPanel()->GetAutoResize(), px, py, rx, ry );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ApplySettings( KeyValues *resourceData )
|
||||
{
|
||||
BaseClass::ApplySettings( resourceData );
|
||||
|
||||
KeyValues *kv = resourceData->FindKey( "cost", false );
|
||||
if( kv ) // if this button has a cost defined for it
|
||||
{
|
||||
m_iPrice = kv->GetInt(); // save the price away
|
||||
}
|
||||
|
||||
kv = resourceData->FindKey( "as_restrict", false );
|
||||
if( kv ) // if this button has a map limitation for it
|
||||
{
|
||||
m_iASRestrict = kv->GetInt(); // save the as_restrict away
|
||||
}
|
||||
|
||||
kv = resourceData->FindKey( "de_useonly", false );
|
||||
if( kv ) // if this button has a map limitation for it
|
||||
{
|
||||
m_iDEUseOnly = kv->GetInt(); // save the de_useonly away
|
||||
}
|
||||
|
||||
if ( m_command )
|
||||
{
|
||||
delete[] m_command;
|
||||
m_command = NULL;
|
||||
}
|
||||
kv = resourceData->FindKey( "command", false );
|
||||
if ( kv )
|
||||
{
|
||||
m_command = CloneString( kv->GetString() );
|
||||
}
|
||||
|
||||
SetPriceState();
|
||||
SetMapTypeState();
|
||||
}
|
||||
|
||||
int GetASRestrict() { return m_iASRestrict; }
|
||||
|
||||
int GetDEUseOnly() { return m_iDEUseOnly; }
|
||||
|
||||
virtual void PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
SetPriceState();
|
||||
SetMapTypeState();
|
||||
|
||||
#ifndef CS_SHIELD_ENABLED
|
||||
if ( !Q_stricmp( GetName(), "shield" ) )
|
||||
{
|
||||
SetVisible( false );
|
||||
SetEnabled( false );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
m_avaliableColor = pScheme->GetColor( "Label.TextColor", Color( 0, 0, 0, 0 ) );
|
||||
m_unavailableColor = pScheme->GetColor( "Label.DisabledFgColor2", Color( 0, 0, 0, 0 ) );
|
||||
m_bargainColor = Color( 0, 255, 0, 192 );
|
||||
|
||||
SetPriceState();
|
||||
SetMapTypeState();
|
||||
}
|
||||
|
||||
void SetPriceState()
|
||||
{
|
||||
if ( CSGameRules() && CSGameRules()->IsBlackMarket() )
|
||||
{
|
||||
SetMarketState();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( GetParent() )
|
||||
{
|
||||
Panel *pPanel = dynamic_cast< Panel * >(GetParent()->FindChildByName( "MarketSticker" ) );
|
||||
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
m_bIsBargain = false;
|
||||
}
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( m_iPrice && ( pPlayer && m_iPrice > pPlayer->GetAccount() ) )
|
||||
{
|
||||
SetFgColor( m_unavailableColor );
|
||||
SetCommand( "buy_unavailable" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_bIsBargain == false )
|
||||
{
|
||||
SetFgColor( m_avaliableColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFgColor( m_bargainColor );
|
||||
}
|
||||
|
||||
SetCommand( m_command );
|
||||
}
|
||||
}
|
||||
|
||||
void SetMarketState( void )
|
||||
{
|
||||
Panel *pClassPanel = GetClassPanel();
|
||||
if ( pClassPanel )
|
||||
{
|
||||
pClassPanel->SetVisible( false );
|
||||
}
|
||||
|
||||
if ( m_pBlackMarketPrice )
|
||||
{
|
||||
Label *pLabel = dynamic_cast< Label * >(m_pBlackMarketPrice->FindChildByName( "pricelabel" ) );
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
const int BufLen = 2048;
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_MarketPreviousPrice");
|
||||
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
|
||||
char strPrice[16];
|
||||
wchar_t szPrice[64];
|
||||
Q_snprintf( strPrice, sizeof( strPrice ), "%d", m_iPreviousPrice );
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strPrice, szPrice, sizeof(szPrice));
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, szPrice );
|
||||
pLabel->SetText( wbuf );
|
||||
pLabel->SetVisible( true );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarketPrice->FindChildByName( "price" ) );
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
const int BufLen = 2048;
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_MarketCurrentPrice");
|
||||
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
|
||||
char strPrice[16];
|
||||
wchar_t szPrice[64];
|
||||
Q_snprintf( strPrice, sizeof( strPrice ), "%d", m_iPrice );
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strPrice, szPrice, sizeof(szPrice));
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, szPrice );
|
||||
pLabel->SetText( wbuf );
|
||||
pLabel->SetVisible( true );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarketPrice->FindChildByName( "difference" ) );
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
const int BufLen = 2048;
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_MarketDeltaPrice");
|
||||
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
|
||||
char strPrice[16];
|
||||
wchar_t szPrice[64];
|
||||
|
||||
int iDifference = m_iPreviousPrice - m_iPrice;
|
||||
|
||||
if ( iDifference >= 0 )
|
||||
{
|
||||
pLabel->SetFgColor( m_bargainColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
pLabel->SetFgColor( Color( 192, 28, 0, 255 ) );
|
||||
}
|
||||
|
||||
Q_snprintf( strPrice, sizeof( strPrice ), "%d", abs( iDifference ) );
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strPrice, szPrice, sizeof(szPrice));
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, szPrice );
|
||||
pLabel->SetText( wbuf );
|
||||
pLabel->SetVisible( true );
|
||||
}
|
||||
|
||||
ImagePanel *pImage = dynamic_cast< ImagePanel * >(m_pBlackMarketPrice->FindChildByName( "classimage" ) );
|
||||
|
||||
if ( pImage )
|
||||
{
|
||||
ImagePanel *pClassImage = dynamic_cast< ImagePanel * >(GetClassPanel()->FindChildByName( "classimage" ) );
|
||||
|
||||
if ( pClassImage )
|
||||
{
|
||||
pImage->SetSize( pClassImage->GetWide(), pClassImage->GetTall() );
|
||||
pImage->SetImage( pClassImage->GetImage() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( GetParent() )
|
||||
{
|
||||
Panel *pPanel = dynamic_cast< Panel * >(GetParent()->FindChildByName( "MarketSticker" ) );
|
||||
|
||||
if ( pPanel )
|
||||
{
|
||||
if ( m_bIsBargain )
|
||||
{
|
||||
pPanel->SetVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPanel->SetVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMapTypeState()
|
||||
{
|
||||
CCSGameRules *pRules = CSGameRules();
|
||||
|
||||
if ( pRules )
|
||||
{
|
||||
if( pRules->IsVIPMap() )
|
||||
{
|
||||
if ( m_iASRestrict )
|
||||
{
|
||||
SetFgColor( m_unavailableColor );
|
||||
SetCommand( "buy_unavailable" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pRules->IsBombDefuseMap() )
|
||||
{
|
||||
if ( m_iDEUseOnly )
|
||||
{
|
||||
SetFgColor( m_unavailableColor );
|
||||
SetCommand( "buy_unavailable" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetBargainButton( bool state )
|
||||
{
|
||||
m_bIsBargain = state;
|
||||
}
|
||||
|
||||
void SetCurrentPrice( int iPrice )
|
||||
{
|
||||
m_iPrice = iPrice;
|
||||
}
|
||||
|
||||
void SetPreviousPrice( int iPrice )
|
||||
{
|
||||
m_iPreviousPrice = iPrice;
|
||||
}
|
||||
|
||||
const char *GetBuyCommand( void )
|
||||
{
|
||||
return m_command;
|
||||
}
|
||||
|
||||
virtual void ShowPage()
|
||||
{
|
||||
if ( g_lastPanel )
|
||||
{
|
||||
for( int i = 0; i< g_lastPanel->GetParent()->GetChildCount(); i++ )
|
||||
{
|
||||
MouseOverPanelButton *buyButton = dynamic_cast<MouseOverPanelButton *>(g_lastPanel->GetParent()->GetChild(i));
|
||||
|
||||
if ( buyButton )
|
||||
{
|
||||
buyButton->HidePage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::ShowPage();
|
||||
|
||||
if ( !Q_stricmp( m_command, "vguicancel" ) )
|
||||
return;
|
||||
|
||||
if ( CSGameRules() && CSGameRules()->IsBlackMarket() )
|
||||
{
|
||||
if ( m_pBlackMarketPrice && !m_pBlackMarketPrice->IsVisible() )
|
||||
{
|
||||
m_pBlackMarketPrice->SetVisible( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void HidePage()
|
||||
{
|
||||
BaseClass::HidePage();
|
||||
|
||||
if ( m_pBlackMarketPrice && m_pBlackMarketPrice->IsVisible() )
|
||||
{
|
||||
m_pBlackMarketPrice->SetVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int m_iPrice;
|
||||
int m_iPreviousPrice;
|
||||
int m_iASRestrict;
|
||||
int m_iDEUseOnly;
|
||||
bool m_bIsBargain;
|
||||
|
||||
Color m_avaliableColor;
|
||||
Color m_unavailableColor;
|
||||
Color m_bargainColor;
|
||||
|
||||
char *m_command;
|
||||
|
||||
public:
|
||||
vgui::EditablePanel *m_pBlackMarketPrice;
|
||||
};
|
||||
|
||||
|
||||
#endif // BUYMOUSEOVERPANELBUTTON_H
|
||||
@@ -1,577 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "weapon_csbase.h"
|
||||
#include "cs_ammodef.h"
|
||||
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "vgui_controls/BuildGroup.h"
|
||||
#include "vgui_controls/BitmapImagePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui_controls/TextImage.h"
|
||||
#include "vgui_controls/RichText.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
#include "career_box.h"
|
||||
#include "buypreset_listbox.h"
|
||||
#include "buypreset_weaponsetlabel.h"
|
||||
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
WeaponImageInfo::WeaponImageInfo()
|
||||
{
|
||||
m_needLayout = m_isCentered = false;
|
||||
m_left = m_top = m_wide = m_tall = 0;
|
||||
m_isPrimary = false;
|
||||
memset( &m_weapon, 0, sizeof(ImageInfo) );
|
||||
memset( &m_ammo, 0, sizeof(ImageInfo) );
|
||||
m_weaponScale = m_ammoScale = 0;
|
||||
m_pAmmoText = new TextImage( "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
WeaponImageInfo::~WeaponImageInfo()
|
||||
{
|
||||
delete m_pAmmoText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::ApplyTextSettings( vgui::IScheme *pScheme, bool isProportional )
|
||||
{
|
||||
Color color = pScheme->GetColor( "FgColor", Color( 0, 0, 0, 0 ) );
|
||||
|
||||
m_pAmmoText->SetColor( color );
|
||||
m_pAmmoText->SetFont( pScheme->GetFont( "Default", isProportional ) );
|
||||
m_pAmmoText->SetWrap( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::SetBounds( int left, int top, int wide, int tall )
|
||||
{
|
||||
m_left = left;
|
||||
m_top = top;
|
||||
m_wide = wide;
|
||||
m_tall = tall;
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::SetCentered( bool isCentered )
|
||||
{
|
||||
m_isCentered = isCentered;
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::SetScaleAt1024( int weaponScale, int ammoScale )
|
||||
{
|
||||
m_weaponScale = weaponScale;
|
||||
m_ammoScale = ammoScale;
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::SetWeapon( const BuyPresetWeapon *pWeapon, bool isPrimary, bool useCurrentAmmoType )
|
||||
{
|
||||
m_pAmmoText->SetText( L"" );
|
||||
m_weapon.image = NULL;
|
||||
m_ammo.image = NULL;
|
||||
m_isPrimary = isPrimary;
|
||||
|
||||
if ( !pWeapon )
|
||||
return;
|
||||
|
||||
wchar_t *multiplierString = g_pVGuiLocalize->Find("#Cstrike_BuyMenuPresetMultiplier");
|
||||
if ( !multiplierString )
|
||||
multiplierString = L"";
|
||||
const int BufLen = 32;
|
||||
wchar_t buf[BufLen];
|
||||
|
||||
if ( pWeapon->GetAmmoType() == AMMO_CLIPS )
|
||||
{
|
||||
CSWeaponID weaponID = pWeapon->GetWeaponID();
|
||||
const CCSWeaponInfo *info = GetWeaponInfo( weaponID );
|
||||
int numClips = pWeapon->GetAmmoAmount();
|
||||
if ( info )
|
||||
{
|
||||
int maxRounds = GetCSAmmoDef()->MaxCarry( info->iAmmoType );
|
||||
int buyClipSize = GetCSAmmoDef()->GetBuySize( info->iAmmoType );
|
||||
|
||||
int maxClips = (buyClipSize > 0) ? ceil(maxRounds/(float)buyClipSize) : 0;
|
||||
numClips = MIN( numClips, maxClips );
|
||||
m_weapon.image = scheme()->GetImage( ImageFnameFromWeaponID( weaponID, m_isPrimary ), true );
|
||||
if ( numClips == 0 )
|
||||
{
|
||||
m_ammo.image = NULL;
|
||||
}
|
||||
else if ( info->m_WeaponType == WEAPONTYPE_SHOTGUN )
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/shell", true );
|
||||
}
|
||||
else if ( isPrimary )
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/bullet", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/cartridge", true );
|
||||
}
|
||||
|
||||
if ( numClips > 1 )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( buf, sizeof(buf), multiplierString, 1, NumAsWString( numClips ) );
|
||||
m_pAmmoText->SetText( buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAmmoText->SetText( L"" );
|
||||
}
|
||||
}
|
||||
else if ( numClips > 0 || !useCurrentAmmoType )
|
||||
{
|
||||
if ( useCurrentAmmoType )
|
||||
{
|
||||
CSWeaponID currentID = GetClientWeaponID( isPrimary );
|
||||
m_weapon.image = scheme()->GetImage( ImageFnameFromWeaponID( currentID, m_isPrimary ), true );
|
||||
info = GetWeaponInfo( currentID );
|
||||
if ( !info )
|
||||
{
|
||||
m_weapon.image = NULL;
|
||||
numClips = 0;
|
||||
}
|
||||
else if ( info->m_WeaponType == WEAPONTYPE_SHOTGUN )
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/shell", true );
|
||||
}
|
||||
else if ( isPrimary )
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/bullet", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/cartridge", true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_weapon.image = scheme()->GetImage( ImageFnameFromWeaponID( weaponID, m_isPrimary ), true );
|
||||
if ( numClips == 0 )
|
||||
{
|
||||
m_ammo.image = NULL;
|
||||
}
|
||||
else if ( isPrimary )
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/bullet", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ammo.image = scheme()->GetImage( "gfx/vgui/cartridge", true );
|
||||
}
|
||||
}
|
||||
if ( numClips > 1 )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( buf, sizeof(buf), multiplierString, 1, NumAsWString( numClips ) );
|
||||
m_pAmmoText->SetText( buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAmmoText->SetText( L"" );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::Paint()
|
||||
{
|
||||
if ( m_needLayout )
|
||||
PerformLayout();
|
||||
|
||||
m_weapon.Paint();
|
||||
m_ammo.Paint();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::PaintText()
|
||||
{
|
||||
if ( m_needLayout )
|
||||
PerformLayout();
|
||||
|
||||
m_pAmmoText->Paint();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponImageInfo::PerformLayout()
|
||||
{
|
||||
m_needLayout = false;
|
||||
|
||||
m_weapon.FitInBounds( m_left, m_top, m_wide*0.8, m_tall, m_isCentered, m_weaponScale );
|
||||
int ammoX = MIN( m_wide*5/6, m_weapon.w );
|
||||
int ammoSize = m_tall * 9 / 16;
|
||||
if ( !m_isPrimary )
|
||||
{
|
||||
ammoSize = ammoSize * 25 / 40;
|
||||
ammoX = MIN( m_wide*5/6, m_weapon.w*3/4 );
|
||||
}
|
||||
if ( ammoX + ammoSize > m_wide )
|
||||
{
|
||||
ammoX = m_wide - ammoSize;
|
||||
}
|
||||
m_ammo.FitInBounds( m_left + ammoX, m_top + m_tall - ammoSize, ammoSize, ammoSize, false, m_ammoScale );
|
||||
|
||||
int w, h;
|
||||
m_pAmmoText->ResizeImageToContent();
|
||||
m_pAmmoText->GetSize( w, h );
|
||||
if ( m_isPrimary )
|
||||
{
|
||||
if ( m_ammoScale < 75 )
|
||||
{
|
||||
m_pAmmoText->SetPos( m_left + ammoX + ammoSize*1.25f - w, m_top + m_tall - h );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAmmoText->SetPos( m_left + ammoX + ammoSize - w, m_top + m_tall - h );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAmmoText->SetPos( m_left + ammoX + ammoSize, m_top + m_tall - h );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
WeaponLabel::WeaponLabel(Panel *parent, const char *panelName) : BaseClass( parent, panelName )
|
||||
{
|
||||
SetSize( 10, 10 );
|
||||
SetMouseInputEnabled( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
WeaponLabel::~WeaponLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponLabel::SetWeapon( const BuyPresetWeapon *pWeapon, bool isPrimary, bool showAmmo )
|
||||
{
|
||||
BuyPresetWeapon weapon(WEAPON_NONE);
|
||||
if ( pWeapon )
|
||||
weapon = *pWeapon;
|
||||
if ( !showAmmo )
|
||||
weapon.SetAmmoAmount( 0 );
|
||||
m_weapon.SetWeapon( &weapon, isPrimary, false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponLabel::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
m_weapon.ApplyTextSettings( pScheme, IsProportional() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponLabel::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
m_weapon.SetBounds( 0, 0, wide, tall );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void WeaponLabel::Paint()
|
||||
{
|
||||
BaseClass::Paint();
|
||||
|
||||
m_weapon.Paint();
|
||||
m_weapon.PaintText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
ItemImageInfo::ItemImageInfo()
|
||||
{
|
||||
m_needLayout = false;
|
||||
m_left = m_top = m_wide = m_tall = 0;
|
||||
m_count = 0;
|
||||
memset( &m_image, 0, sizeof(ImageInfo) );
|
||||
m_pText = new TextImage( "" );
|
||||
|
||||
SetBounds( 0, 0, 100, 100 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
ItemImageInfo::~ItemImageInfo()
|
||||
{
|
||||
delete m_pText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::ApplyTextSettings( vgui::IScheme *pScheme, bool isProportional )
|
||||
{
|
||||
Color color = pScheme->GetColor( "Label.TextColor", Color( 0, 0, 0, 0 ) );
|
||||
|
||||
m_pText->SetColor( color );
|
||||
m_pText->SetFont( pScheme->GetFont( "Default", isProportional ) );
|
||||
m_pText->SetWrap( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::SetBounds( int left, int top, int wide, int tall )
|
||||
{
|
||||
m_left = left;
|
||||
m_top = top;
|
||||
m_wide = wide;
|
||||
m_tall = tall;
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::SetItem( const char *imageFname, int count )
|
||||
{
|
||||
m_pText->SetText( L"" );
|
||||
m_count = count;
|
||||
|
||||
if ( imageFname )
|
||||
m_image.image = scheme()->GetImage( imageFname, true );
|
||||
else
|
||||
m_image.image = NULL;
|
||||
|
||||
if ( count > 1 )
|
||||
{
|
||||
wchar_t *multiplierString = g_pVGuiLocalize->Find("#Cstrike_BuyMenuPresetMultiplier");
|
||||
if ( !multiplierString )
|
||||
multiplierString = L"";
|
||||
const int BufLen = 32;
|
||||
wchar_t buf[BufLen];
|
||||
|
||||
g_pVGuiLocalize->ConstructString( buf, sizeof(buf), multiplierString, 1, NumAsWString( count ) );
|
||||
m_pText->SetText( buf );
|
||||
}
|
||||
m_needLayout = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::Paint()
|
||||
{
|
||||
if ( m_needLayout )
|
||||
PerformLayout();
|
||||
|
||||
if ( m_count )
|
||||
m_image.Paint();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::PaintText()
|
||||
{
|
||||
if ( m_needLayout )
|
||||
PerformLayout();
|
||||
|
||||
m_pText->Paint();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ItemImageInfo::PerformLayout()
|
||||
{
|
||||
m_needLayout = false;
|
||||
|
||||
m_image.FitInBounds( m_left, m_top, m_wide, m_tall, false, 0 );
|
||||
|
||||
int w, h;
|
||||
m_pText->ResizeImageToContent();
|
||||
m_pText->GetSize( w, h );
|
||||
m_pText->SetPos( m_left + m_image.w - w, m_top + m_tall - h );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
EquipmentLabel::EquipmentLabel(Panel *parent, const char *panelName, const char *imageFname) : BaseClass( parent, panelName )
|
||||
{
|
||||
SetSize( 10, 10 );
|
||||
m_item.SetItem( imageFname, 0 );
|
||||
SetMouseInputEnabled( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
EquipmentLabel::~EquipmentLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void EquipmentLabel::SetItem( const char *imageFname, int count )
|
||||
{
|
||||
m_item.SetItem( imageFname, count );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void EquipmentLabel::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
m_item.ApplyTextSettings( pScheme, IsProportional() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void EquipmentLabel::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
m_item.SetBounds( 0, 0, wide, tall );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void EquipmentLabel::Paint()
|
||||
{
|
||||
BaseClass::Paint();
|
||||
|
||||
m_item.Paint();
|
||||
m_item.PaintText();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/// Helper function: draws a simple dashed line
|
||||
void DrawDashedLine(int x0, int y0, int x1, int y1, int dashLen, int gapLen)
|
||||
{
|
||||
// work out which way the line goes
|
||||
if ((x1 - x0) > (y1 - y0))
|
||||
{
|
||||
// x direction line
|
||||
while (1)
|
||||
{
|
||||
if (x0 + dashLen > x1)
|
||||
{
|
||||
// draw partial
|
||||
surface()->DrawFilledRect(x0, y0, x1, y1+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface()->DrawFilledRect(x0, y0, x0 + dashLen, y1+1);
|
||||
}
|
||||
|
||||
x0 += dashLen;
|
||||
|
||||
if (x0 + gapLen > x1)
|
||||
break;
|
||||
|
||||
x0 += gapLen;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// y direction
|
||||
while (1)
|
||||
{
|
||||
if (y0 + dashLen > y1)
|
||||
{
|
||||
// draw partial
|
||||
surface()->DrawFilledRect(x0, y0, x1+1, y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface()->DrawFilledRect(x0, y0, x1+1, y0 + dashLen);
|
||||
}
|
||||
|
||||
y0 += dashLen;
|
||||
|
||||
if (y0 + gapLen > y1)
|
||||
break;
|
||||
|
||||
y0 += gapLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ImageInfo::Paint()
|
||||
{
|
||||
if ( !image )
|
||||
return;
|
||||
|
||||
image->SetSize( w, h );
|
||||
image->SetPos( x, y );
|
||||
image->Paint();
|
||||
image->SetSize( 0, 0 ); // restore image size to content size to not mess up other places that use the same image
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void ImageInfo::FitInBounds( int baseX, int baseY, int width, int height, bool center, int scaleAt1024, bool halfHeight )
|
||||
{
|
||||
if ( !image )
|
||||
{
|
||||
x = y = w = h = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
image->GetContentSize(fullW, fullH);
|
||||
|
||||
if ( scaleAt1024 )
|
||||
{
|
||||
int screenW, screenH;
|
||||
GetHudSize( screenW, screenH );
|
||||
|
||||
w = fullW * screenW / 1024 * scaleAt1024 / 100;
|
||||
h = fullH * screenW / 1024 * scaleAt1024 / 100;
|
||||
|
||||
if ( fullH > 64 && scaleAt1024 == 100 )
|
||||
{
|
||||
w = w * 64 / fullH;
|
||||
h = h * 64 / fullH;
|
||||
}
|
||||
|
||||
if ( h > height * 1.2 )
|
||||
scaleAt1024 = 0;
|
||||
}
|
||||
if ( !scaleAt1024 )
|
||||
{
|
||||
w = fullW;
|
||||
h = fullH;
|
||||
|
||||
if ( h != height )
|
||||
{
|
||||
w = (int) w * 1.0f * height / h;
|
||||
h = height;
|
||||
}
|
||||
|
||||
if ( w > width )
|
||||
{
|
||||
h = (int) h * 1.0f * width / w;
|
||||
w = width;
|
||||
}
|
||||
}
|
||||
|
||||
if ( center )
|
||||
{
|
||||
x = baseX + (width - w)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = baseX;
|
||||
}
|
||||
y = baseY + (height - h)/2;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,406 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/MouseCode.h>
|
||||
#include <vgui/IInput.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include <vgui_controls/ScrollBar.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include "buypreset_listbox.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetListBox::BuyPresetListBox( vgui::Panel *parent, char const *panelName ) : Panel( parent, panelName )
|
||||
{
|
||||
m_visibleIndex = 0;
|
||||
m_lastSize = 0;
|
||||
|
||||
SetBounds( 0, 0, 100, 100 );
|
||||
|
||||
m_vbar = new ScrollBar(this, "PanelListPanelVScroll", true);
|
||||
m_vbar->SetBounds( 0, 0, 20, 20 );
|
||||
m_vbar->SetVisible(true);
|
||||
m_vbar->AddActionSignalTarget( this );
|
||||
|
||||
m_pPanelEmbedded = new EditablePanel(this, "PanelListEmbedded");
|
||||
m_pPanelEmbedded->SetBounds(0, 0, 20, 20);
|
||||
m_pPanelEmbedded->SetPaintBackgroundEnabled( false );
|
||||
m_pPanelEmbedded->SetPaintBorderEnabled(false);
|
||||
|
||||
if( IsProportional() )
|
||||
{
|
||||
int width, height;
|
||||
int sw,sh;
|
||||
surface()->GetProportionalBase( width, height );
|
||||
GetHudSize(sw, sh);
|
||||
|
||||
// resize scrollbar, etc
|
||||
m_iScrollbarSize = static_cast<int>( static_cast<float>( SCROLLBAR_SIZE )*( static_cast<float>( sw )/ static_cast<float>( width )));
|
||||
m_iDefaultHeight = static_cast<int>( static_cast<float>( DEFAULT_HEIGHT )*( static_cast<float>( sw )/ static_cast<float>( width )));
|
||||
m_iPanelBuffer = static_cast<int>( static_cast<float>( PANELBUFFER )*( static_cast<float>( sw )/ static_cast<float>( width )));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iScrollbarSize = SCROLLBAR_SIZE;
|
||||
m_iDefaultHeight = DEFAULT_HEIGHT;
|
||||
m_iPanelBuffer = PANELBUFFER;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetListBox::~BuyPresetListBox()
|
||||
{
|
||||
// free data from table
|
||||
DeleteAllItems();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Passes commands up to the parent
|
||||
*/
|
||||
void BuyPresetListBox::OnCommand( const char *command )
|
||||
{
|
||||
GetParent()->OnCommand( command );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Scrolls the list according to the mouse wheel movement
|
||||
*/
|
||||
void BuyPresetListBox::OnMouseWheeled(int delta)
|
||||
{
|
||||
int scale = 3;
|
||||
if ( m_items.Count() )
|
||||
{
|
||||
Panel *panel = m_items[0].panel;
|
||||
if ( panel )
|
||||
{
|
||||
scale = panel->GetTall() + m_iPanelBuffer;
|
||||
}
|
||||
}
|
||||
int val = m_vbar->GetValue();
|
||||
val -= (delta * scale);
|
||||
m_vbar->SetValue(val);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Computes vertical pixels needed by listbox contents
|
||||
*/
|
||||
int BuyPresetListBox::computeVPixelsNeeded( void )
|
||||
{
|
||||
int pixels = 0;
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < m_items.Count(); i++ )
|
||||
{
|
||||
Panel *panel = m_items[i].panel;
|
||||
if ( !panel )
|
||||
continue;
|
||||
|
||||
int w, h;
|
||||
panel->GetSize( w, h );
|
||||
|
||||
pixels += m_iPanelBuffer; // add in buffer. between items.
|
||||
pixels += h;
|
||||
}
|
||||
|
||||
pixels += m_iPanelBuffer; // add in buffer below last item
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Adds an item to the end of the listbox. UserData is assumed to be a pointer that can be freed by the listbox if non-NULL.
|
||||
*/
|
||||
int BuyPresetListBox::AddItem( vgui::Panel *panel, IBuyPresetListBoxUserData * userData )
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
DataItem item = { panel, userData };
|
||||
|
||||
panel->SetParent( m_pPanelEmbedded );
|
||||
|
||||
m_items.AddToTail( item );
|
||||
|
||||
InvalidateLayout();
|
||||
return m_items.Count();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Exchanges two items in the listbox
|
||||
*/
|
||||
void BuyPresetListBox::SwapItems( int index1, int index2 )
|
||||
{
|
||||
if ( index1 < 0 || index2 < 0 || index1 >= m_items.Count() || index2 >= m_items.Count() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataItem temp = m_items[index1];
|
||||
m_items[index1] = m_items[index2];
|
||||
m_items[index2] = temp;
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the number of items in the listbox
|
||||
*/
|
||||
int BuyPresetListBox::GetItemCount( void ) const
|
||||
{
|
||||
return m_items.Count();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the panel in the given index, or NULL
|
||||
*/
|
||||
Panel * BuyPresetListBox::GetItemPanel(int index) const
|
||||
{
|
||||
if ( index < 0 || index >= m_items.Count() )
|
||||
return NULL;
|
||||
|
||||
return m_items[index].panel;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the userData in the given index, or NULL
|
||||
*/
|
||||
auto BuyPresetListBox::GetItemUserData(int index) -> IBuyPresetListBoxUserData *
|
||||
{
|
||||
if ( index < 0 || index >= m_items.Count() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_items[index].userData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the userData in the given index
|
||||
*/
|
||||
void BuyPresetListBox::SetItemUserData( int index, IBuyPresetListBoxUserData * userData )
|
||||
{
|
||||
if ( index < 0 || index >= m_items.Count() )
|
||||
return;
|
||||
|
||||
m_items[index].userData = userData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Removes an item from the table (changing the indices of all following items), deleting the panel and userData
|
||||
*/
|
||||
void BuyPresetListBox::RemoveItem(int index)
|
||||
{
|
||||
if ( index < 0 || index >= m_items.Count() )
|
||||
return;
|
||||
|
||||
DataItem item = m_items[index];
|
||||
if ( item.panel )
|
||||
{
|
||||
item.panel->MarkForDeletion();
|
||||
}
|
||||
if ( item.userData )
|
||||
{
|
||||
delete item.userData;
|
||||
}
|
||||
|
||||
m_items.Remove( index );
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* clears the listbox, deleting all panels and userData
|
||||
*/
|
||||
void BuyPresetListBox::DeleteAllItems()
|
||||
{
|
||||
while ( m_items.Count() )
|
||||
{
|
||||
RemoveItem( 0 );
|
||||
}
|
||||
|
||||
// move the scrollbar to the top of the list
|
||||
m_vbar->SetValue(0);
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Handles Count changes
|
||||
*/
|
||||
void BuyPresetListBox::OnSizeChanged(int wide, int tall)
|
||||
{
|
||||
BaseClass::OnSizeChanged(wide, tall);
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Positions listbox items, etc after internal changes
|
||||
*/
|
||||
void BuyPresetListBox::PerformLayout()
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
|
||||
int vpixels = computeVPixelsNeeded();
|
||||
|
||||
int visibleIndex = m_visibleIndex;
|
||||
|
||||
//!! need to make it recalculate scroll positions
|
||||
m_vbar->SetVisible(true);
|
||||
m_vbar->SetEnabled(false);
|
||||
m_vbar->SetRange( 0, (MAX( 0, vpixels - tall + m_iDefaultHeight )) );
|
||||
m_vbar->SetRangeWindow( m_iDefaultHeight );
|
||||
m_vbar->SetButtonPressedScrollValue( m_iDefaultHeight ); // standard height of labels/buttons etc.
|
||||
m_vbar->SetPos(wide - m_iScrollbarSize, 1);
|
||||
m_vbar->SetSize(m_iScrollbarSize, tall - 2);
|
||||
|
||||
m_visibleIndex = visibleIndex;
|
||||
|
||||
int top = MAX( 0, m_vbar->GetValue() );
|
||||
|
||||
m_pPanelEmbedded->SetPos( 1, -top );
|
||||
m_pPanelEmbedded->SetSize( wide-m_iScrollbarSize -2, vpixels );
|
||||
|
||||
// Now lay out the controls on the embedded panel
|
||||
int y = 0;
|
||||
int h = 0;
|
||||
int totalh = 0;
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < m_items.Count(); i++, y += h )
|
||||
{
|
||||
// add in a little buffer between panels
|
||||
y += m_iPanelBuffer;
|
||||
DataItem item = m_items[i];
|
||||
|
||||
h = item.panel->GetTall();
|
||||
|
||||
totalh += h;
|
||||
item.panel->SetBounds( 8, y, wide - m_iScrollbarSize - 8 - 8, h );
|
||||
item.panel->InvalidateLayout();
|
||||
}
|
||||
|
||||
if ( m_visibleIndex >= 0 && m_visibleIndex < m_items.Count() )
|
||||
{
|
||||
|
||||
int vpos = 0;
|
||||
|
||||
int tempWide, tempTall;
|
||||
GetSize( tempWide, tempTall );
|
||||
|
||||
int vtop, vbottom;
|
||||
m_vbar->GetRange( vtop, vbottom );
|
||||
|
||||
int tempTop = MAX( 0, m_vbar->GetValue() ); // top pixel in the embedded panel
|
||||
int bottom = tempTop + tempTall - 2;
|
||||
|
||||
int itemTop, itemLeft, itemBottom, itemRight;
|
||||
m_items[m_visibleIndex].panel->GetBounds( itemLeft, itemTop, itemRight, itemBottom );
|
||||
itemBottom += itemTop;
|
||||
itemRight += itemLeft;
|
||||
|
||||
if ( itemTop < tempTop )
|
||||
{
|
||||
// item's top is too high
|
||||
vpos -= ( tempTop - itemTop );
|
||||
|
||||
m_vbar->SetValue(vpos);
|
||||
OnSliderMoved(vpos);
|
||||
}
|
||||
else if ( itemBottom > bottom )
|
||||
{
|
||||
// item's bottom is too low
|
||||
vpos += ( itemBottom - bottom );
|
||||
|
||||
m_vbar->SetValue(vpos);
|
||||
OnSliderMoved(vpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_lastSize == vpixels )
|
||||
{
|
||||
m_visibleIndex = -1;
|
||||
}
|
||||
m_lastSize = vpixels;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Try to ensure that the given index is visible
|
||||
*/
|
||||
void BuyPresetListBox::MakeItemVisible( int index )
|
||||
{
|
||||
m_visibleIndex = index;
|
||||
m_lastSize = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Loads colors, fonts, etc
|
||||
*/
|
||||
void BuyPresetListBox::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
|
||||
SetBgColor(GetSchemeColor("BuyPresetListBox.BgColor", GetBgColor(), pScheme));
|
||||
|
||||
SetBorder(pScheme->GetBorder("BrowserBorder"));
|
||||
m_vbar->SetBorder(pScheme->GetBorder("BrowserBorder"));
|
||||
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Handles slider being dragged
|
||||
*/
|
||||
void BuyPresetListBox::OnSliderMoved( int position )
|
||||
{
|
||||
InvalidateLayout();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Moves slider to the top
|
||||
*/
|
||||
void BuyPresetListBox::MoveScrollBarToTop()
|
||||
{
|
||||
m_vbar->SetValue(0);
|
||||
OnSliderMoved(0);
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BUYPRESET_LISTBOX_H
|
||||
#define BUYPRESET_LISTBOX_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui/VGUI.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
#include <utlvector.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* ListBox-style control with behavior needed by weapon lists for BuyPreset editing
|
||||
*/
|
||||
class BuyPresetListBox : public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( BuyPresetListBox, vgui::Panel );
|
||||
|
||||
public:
|
||||
BuyPresetListBox( vgui::Panel *parent, char const *panelName );
|
||||
~BuyPresetListBox();
|
||||
|
||||
class IBuyPresetListBoxUserData
|
||||
{
|
||||
protected:
|
||||
friend BuyPresetListBox;
|
||||
virtual ~IBuyPresetListBoxUserData() {};
|
||||
};
|
||||
|
||||
virtual int AddItem( vgui::Panel *panel, IBuyPresetListBoxUserData *userData ); ///< Adds an item to the end of the listbox. UserData is assumed to be a pointer that will be deleted by the listbox if non-NULL.
|
||||
virtual int GetItemCount( void ) const; ///< Returns the number of items in the listbox
|
||||
void SwapItems( int index1, int index2 ); ///< Exchanges two items in the listbox
|
||||
void MakeItemVisible( int index ); ///< Try to ensure that the given index is visible
|
||||
|
||||
vgui::Panel * GetItemPanel( int index ) const; ///< Returns the panel in the given index, or NULL
|
||||
IBuyPresetListBoxUserData * GetItemUserData( int index ); ///< Returns the userData in the given index, or NULL
|
||||
void SetItemUserData( int index, IBuyPresetListBoxUserData * userData ); ///< Sets the userData in the given index
|
||||
|
||||
virtual void RemoveItem( int index ); ///< Removes an item from the table (changing the indices of all following items), deleting the panel and userData
|
||||
virtual void DeleteAllItems(); ///< clears the listbox, deleting all panels and userData
|
||||
|
||||
// overrides
|
||||
virtual void OnSizeChanged(int wide, int tall); ////< Handles size changes
|
||||
MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position ); ///< Handles slider being dragged
|
||||
virtual void OnMouseWheeled(int delta); ///< Scrolls the list according to the mouse wheel movement
|
||||
virtual void MoveScrollBarToTop(); ///< Moves slider to the top
|
||||
|
||||
protected:
|
||||
|
||||
virtual int computeVPixelsNeeded( void ); ///< Computes vertical pixels needed by listbox contents
|
||||
|
||||
virtual void PerformLayout(); ///< Positions listbox items, etc after internal changes
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); ///< Loads colors, fonts, etc
|
||||
|
||||
virtual void OnCommand( const char *command ); ///< Passes commands up to the parent
|
||||
|
||||
private:
|
||||
enum { SCROLLBAR_SIZE = 18, DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
|
||||
|
||||
typedef struct dataitem_s
|
||||
{
|
||||
vgui::Panel *panel;
|
||||
IBuyPresetListBoxUserData * userData;
|
||||
} DataItem;
|
||||
CUtlVector< DataItem > m_items;
|
||||
|
||||
vgui::ScrollBar *m_vbar;
|
||||
vgui::Panel *m_pPanelEmbedded;
|
||||
|
||||
int m_iScrollbarSize;
|
||||
int m_iDefaultHeight;
|
||||
int m_iPanelBuffer;
|
||||
|
||||
int m_visibleIndex;
|
||||
int m_lastSize;
|
||||
};
|
||||
|
||||
#endif // BUYPRESET_LISTBOX_H
|
||||
@@ -1,447 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "weapon_csbase.h"
|
||||
#include "cs_ammodef.h"
|
||||
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "vgui_controls/BuildGroup.h"
|
||||
#include "vgui_controls/BitmapImagePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui_controls/TextImage.h"
|
||||
#include "vgui_controls/RichText.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
#include "career_box.h"
|
||||
#include "buypreset_listbox.h"
|
||||
#include "buypreset_weaponsetlabel.h"
|
||||
#include "backgroundpanel.h"
|
||||
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
const float horizTitleRatio = 18.0f/68.0f;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
class PresetNameTextEntry : public TextEntry
|
||||
{
|
||||
public:
|
||||
PresetNameTextEntry(Panel *parent, CBuyPresetEditMainMenu *menu, const char *name ) : TextEntry( parent, name )
|
||||
{
|
||||
m_pMenu = menu;
|
||||
}
|
||||
|
||||
virtual void FireActionSignal()
|
||||
{
|
||||
TextEntry::FireActionSignal();
|
||||
if ( m_pMenu )
|
||||
{
|
||||
m_pMenu->SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CBuyPresetEditMainMenu *m_pMenu;
|
||||
};
|
||||
*/
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
int GetScaledValue( HScheme hScheme, int unscaled )
|
||||
{
|
||||
int val = scheme()->GetProportionalScaledValueEx( hScheme, unscaled );
|
||||
return GetAlternateProportionalValueFromScaled( hScheme, val );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class PresetBackgroundPanel : public vgui::Panel
|
||||
{
|
||||
typedef vgui::Panel BaseClass;
|
||||
|
||||
public:
|
||||
PresetBackgroundPanel( vgui::Panel *parent, const char *panelName ) : BaseClass( parent, panelName )
|
||||
{
|
||||
};
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
SetBorder( pScheme->GetBorder("ButtonBorder") );
|
||||
m_lineColor = pScheme->GetColor( "Border.Bright", Color( 0, 0, 0, 0 ) );
|
||||
}
|
||||
|
||||
virtual void ApplySettings( KeyValues *inResourceData )
|
||||
{
|
||||
BaseClass::ApplySettings( inResourceData );
|
||||
|
||||
m_lines.RemoveAll();
|
||||
KeyValues *lines = inResourceData->FindKey( "lines", false );
|
||||
if ( lines )
|
||||
{
|
||||
KeyValues *line = lines->GetFirstValue();
|
||||
while ( line )
|
||||
{
|
||||
const char *str = line->GetString( nullptr, "" );
|
||||
Vector4D p;
|
||||
int numPoints = sscanf( str, "%f %f %f %f", &p[0], &p[1], &p[2], &p[3] );
|
||||
if ( numPoints == 4 )
|
||||
{
|
||||
m_lines.AddToTail( p );
|
||||
}
|
||||
line = line->GetNextValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void PaintBackground( void )
|
||||
{
|
||||
BaseClass::PaintBackground();
|
||||
|
||||
vgui::surface()->DrawSetColor( m_lineColor );
|
||||
vgui::surface()->DrawSetTextColor( m_lineColor );
|
||||
for ( int i=0; i<m_scaledLines.Count(); ++i )
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
|
||||
x1 = m_scaledLines[i][0];
|
||||
y1 = m_scaledLines[i][1];
|
||||
x2 = m_scaledLines[i][2];
|
||||
y2 = m_scaledLines[i][3];
|
||||
|
||||
vgui::surface()->DrawFilledRect( x1, y1, x2, y2 );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void PerformLayout( void )
|
||||
{
|
||||
m_scaledLines.RemoveAll();
|
||||
for ( int i=0; i<m_lines.Count(); ++i )
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
|
||||
x1 = GetScaledValue( GetScheme(), m_lines[i][0] );
|
||||
y1 = GetScaledValue( GetScheme(), m_lines[i][1] );
|
||||
x2 = GetScaledValue( GetScheme(), m_lines[i][2] );
|
||||
y2 = GetScaledValue( GetScheme(), m_lines[i][3] );
|
||||
|
||||
if ( x1 == x2 )
|
||||
{
|
||||
++x2;
|
||||
}
|
||||
|
||||
if ( y1 == y2 )
|
||||
{
|
||||
++y2;
|
||||
}
|
||||
|
||||
m_scaledLines.AddToTail( Vector4D( x1, y1, x2, y2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Color m_lineColor;
|
||||
CUtlVector< Vector4D > m_lines;
|
||||
CUtlVector< Vector4D > m_scaledLines;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetEditPanel::BuyPresetEditPanel( Panel *parent, const char *panelName, const char *resourceFilename, int fallbackIndex, bool editableName ) : BaseClass( parent, panelName )
|
||||
{
|
||||
SetProportional( parent->IsProportional() );
|
||||
if ( IsProportional() )
|
||||
{
|
||||
m_baseWide = m_baseTall = scheme()->GetProportionalScaledValueEx( GetScheme(), 100 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_baseWide = m_baseTall = 100;
|
||||
}
|
||||
SetSize( m_baseWide, m_baseTall );
|
||||
|
||||
m_fallbackIndex = fallbackIndex;
|
||||
|
||||
m_pBgPanel = new PresetBackgroundPanel( this, "mainBackground" );
|
||||
|
||||
m_pTitleEntry = NULL;
|
||||
m_pTitleLabel = NULL;
|
||||
m_pCostLabel = NULL;
|
||||
/*
|
||||
m_pTitleEntry = new PresetNameTextEntry( this, dynamic_cast<CBuyPresetEditMainMenu *>(parent), "titleEntry" );
|
||||
m_pTitleLabel = new Label( this, "title", "" );
|
||||
m_pCostLabel = new Label( this, "cost", "" );
|
||||
*/
|
||||
|
||||
m_pPrimaryWeapon = new WeaponLabel( this, "primary" );
|
||||
m_pSecondaryWeapon = new WeaponLabel( this, "secondary" );
|
||||
|
||||
m_pHEGrenade = new EquipmentLabel( this, "hegrenade" );
|
||||
m_pSmokeGrenade = new EquipmentLabel( this, "smokegrenade" );
|
||||
m_pFlashbangs = new EquipmentLabel( this, "flashbang" );
|
||||
|
||||
m_pDefuser = new EquipmentLabel( this, "defuser" );
|
||||
m_pNightvision = new EquipmentLabel( this, "nightvision" );
|
||||
|
||||
m_pArmor = new EquipmentLabel( this, "armor" );
|
||||
|
||||
if ( resourceFilename )
|
||||
{
|
||||
LoadControlSettings( resourceFilename );
|
||||
}
|
||||
|
||||
int x, y, w, h;
|
||||
m_pBgPanel->GetBounds( x, y, w, h );
|
||||
|
||||
m_baseWide = x + w;
|
||||
m_baseTall = y + h;
|
||||
SetSize( m_baseWide, m_baseTall );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetEditPanel::~BuyPresetEditPanel()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void BuyPresetEditPanel::SetWeaponSet( const WeaponSet *pWeaponSet, bool current )
|
||||
{
|
||||
// set to empty state
|
||||
Reset();
|
||||
|
||||
// now fill in items
|
||||
if ( pWeaponSet )
|
||||
{
|
||||
if ( m_pTitleLabel )
|
||||
{
|
||||
m_pTitleLabel->SetText( SharedVarArgs( "#Cstrike_BuyPresetChoice%d", m_fallbackIndex ) );
|
||||
}
|
||||
if ( m_pTitleEntry )
|
||||
{
|
||||
m_pTitleEntry->SetText( SharedVarArgs( "#Cstrike_BuyPresetChoice%d", m_fallbackIndex ) );
|
||||
}
|
||||
|
||||
if ( m_pCostLabel )
|
||||
{
|
||||
const int BufLen = 256;
|
||||
wchar_t wbuf[BufLen];
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof( wbuf ),
|
||||
g_pVGuiLocalize->Find( "#Cstrike_BuyPresetPlainCost" ),
|
||||
1, NumAsWString( pWeaponSet->FullCost() ) );
|
||||
m_pCostLabel->SetText( wbuf );
|
||||
}
|
||||
|
||||
m_pPrimaryWeapon->SetWeapon( &pWeaponSet->m_primaryWeapon, true, true );
|
||||
m_pSecondaryWeapon->SetWeapon( &pWeaponSet->m_secondaryWeapon, false, true );
|
||||
|
||||
if ( pWeaponSet->m_HEGrenade )
|
||||
m_pHEGrenade->SetItem( "gfx/vgui/hegrenade_square", 1 );
|
||||
if ( pWeaponSet->m_smokeGrenade )
|
||||
m_pSmokeGrenade->SetItem( "gfx/vgui/smokegrenade_square", 1 );
|
||||
if ( pWeaponSet->m_flashbangs )
|
||||
m_pFlashbangs->SetItem( "gfx/vgui/flashbang_square", pWeaponSet->m_flashbangs );
|
||||
|
||||
if ( pWeaponSet->m_defuser )
|
||||
m_pDefuser->SetItem( "gfx/vgui/defuser", 1 );
|
||||
if ( pWeaponSet->m_nightvision )
|
||||
m_pNightvision->SetItem( "gfx/vgui/nightvision", 1 );
|
||||
|
||||
if ( pWeaponSet->m_armor )
|
||||
{
|
||||
if ( pWeaponSet->m_helmet )
|
||||
m_pArmor->SetItem( "gfx/vgui/kevlar_helmet", 1 );
|
||||
else
|
||||
m_pArmor->SetItem( "gfx/vgui/kevlar", 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void BuyPresetEditPanel::SetText( const wchar_t *text )
|
||||
{
|
||||
if ( !text )
|
||||
text = L"";
|
||||
if ( m_pTitleLabel )
|
||||
{
|
||||
m_pTitleLabel->SetText( text );
|
||||
}
|
||||
if ( m_pTitleEntry )
|
||||
{
|
||||
m_pTitleEntry->SetText( text );
|
||||
}
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Handle command callbacks
|
||||
*/
|
||||
void BuyPresetEditPanel::OnCommand( const char *command )
|
||||
{
|
||||
if (stricmp(command, "close"))
|
||||
{
|
||||
PostActionSignal( new KeyValues("Command", "command", SharedVarArgs( "%s %d", command, m_fallbackIndex )) );
|
||||
}
|
||||
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void BuyPresetEditPanel::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
|
||||
IBorder *pBorder = NULL;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GetChildCount(); i++)
|
||||
{
|
||||
// perform auto-layout on the child panel
|
||||
Panel *child = GetChild(i);
|
||||
if (!child)
|
||||
continue;
|
||||
|
||||
if ( !stricmp( "button", child->GetClassName() ) )
|
||||
{
|
||||
Button *pButton = dynamic_cast<Button *>(child);
|
||||
if ( pButton )
|
||||
{
|
||||
pButton->SetDefaultBorder( pBorder );
|
||||
pButton->SetDepressedBorder( pBorder );
|
||||
pButton->SetKeyFocusBorder( pBorder );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pBorder = pScheme->GetBorder("BuyPresetButtonBorder");
|
||||
|
||||
const int NumButtons = 4;
|
||||
const char * buttonNames[4] = { "editPrimary", "editSecondary", "editGrenades", "editEquipment" };
|
||||
for ( i=0; i<NumButtons; ++i )
|
||||
{
|
||||
Panel *pPanel = FindChildByName( buttonNames[i] );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetBorder( pBorder );
|
||||
if ( !stricmp( "button", pPanel->GetClassName() ) )
|
||||
{
|
||||
Button *pButton = dynamic_cast<Button *>(pPanel);
|
||||
if ( pButton )
|
||||
{
|
||||
pButton->SetDefaultBorder( pBorder );
|
||||
pButton->SetDepressedBorder( pBorder );
|
||||
pButton->SetKeyFocusBorder( pBorder );
|
||||
|
||||
Color fgColor, bgColor;
|
||||
fgColor = GetSchemeColor("Label.TextDullColor", GetFgColor(), pScheme);
|
||||
bgColor = Color( 0, 0, 0, 0 );
|
||||
pButton->SetDefaultColor( fgColor, bgColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Overrides EditablePanel's resizing of children to scale them proportionally to the main panel's change.
|
||||
*/
|
||||
void BuyPresetEditPanel::OnSizeChanged( int wide, int tall )
|
||||
{
|
||||
if ( !m_baseWide )
|
||||
m_baseWide = 1;
|
||||
if ( !m_baseTall )
|
||||
m_baseTall = 1;
|
||||
|
||||
Panel::OnSizeChanged(wide, tall);
|
||||
InvalidateLayout();
|
||||
|
||||
if ( wide == m_baseWide && tall == m_baseTall )
|
||||
{
|
||||
Repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
float xScale = wide / (float) m_baseWide;
|
||||
float yScale = tall / (float) m_baseTall;
|
||||
|
||||
for (int i = 0; i < GetChildCount(); i++)
|
||||
{
|
||||
// perform auto-layout on the child panel
|
||||
Panel *child = GetChild(i);
|
||||
if (!child)
|
||||
continue;
|
||||
|
||||
int x, y, w, t;
|
||||
child->GetBounds(x, y, w, t);
|
||||
|
||||
int newX = (int) x * xScale;
|
||||
int newY = (int) y * yScale;
|
||||
int newW = (int) (x+w) * xScale - newX;
|
||||
int newT = (int) t * yScale;
|
||||
|
||||
// make sure the child isn't too big...
|
||||
if(newX+newW>wide)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(newY+newT>tall)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
child->SetBounds(newX, newY, newW, newT);
|
||||
child->InvalidateLayout();
|
||||
}
|
||||
Repaint();
|
||||
|
||||
// update the baselines
|
||||
m_baseWide = wide;
|
||||
m_baseTall = tall;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void BuyPresetEditPanel::Reset()
|
||||
{
|
||||
if ( m_pTitleLabel )
|
||||
{
|
||||
m_pTitleLabel->SetText( "#Cstrike_BuyPresetNewChoice" );
|
||||
}
|
||||
if ( m_pTitleEntry )
|
||||
{
|
||||
m_pTitleEntry->SetText( "#Cstrike_BuyPresetNewChoice" );
|
||||
}
|
||||
if ( m_pCostLabel )
|
||||
{
|
||||
m_pCostLabel->SetText( "" );
|
||||
}
|
||||
|
||||
BuyPresetWeapon weapon;
|
||||
m_pPrimaryWeapon->SetWeapon( &weapon, true, false );
|
||||
m_pSecondaryWeapon->SetWeapon( &weapon, false, false );
|
||||
|
||||
m_pHEGrenade->SetItem( NULL, 1 );
|
||||
m_pSmokeGrenade->SetItem( NULL, 1 );
|
||||
m_pFlashbangs->SetItem( NULL, 1 );
|
||||
|
||||
m_pDefuser->SetItem( NULL, 1 );
|
||||
m_pNightvision->SetItem( NULL, 1 );
|
||||
|
||||
m_pArmor->SetItem( NULL, 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,302 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BUYPRESET_WEAPONSETLABEL_H
|
||||
#define BUYPRESET_WEAPONSETLABEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui/VGUI.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include <vgui/IImage.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class TextImage;
|
||||
class TextEntry;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/// Helper function: draws a simple dashed line
|
||||
void DrawDashedLine(int x0, int y0, int x1, int y1, int dashLen, int gapLen);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Purpose: Wraps an IImage to perform resizes properly
|
||||
class BuyPresetImage : public vgui::IImage
|
||||
{
|
||||
public:
|
||||
BuyPresetImage( vgui::IImage *realImage )
|
||||
{
|
||||
m_image = realImage;
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->GetSize( m_wide, m_tall );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wide = m_tall = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Call to Paint the image
|
||||
// Image will draw within the current panel context at the specified position
|
||||
virtual void Paint()
|
||||
{
|
||||
if ( !m_image )
|
||||
return;
|
||||
|
||||
m_image->Paint();
|
||||
}
|
||||
|
||||
// Set the position of the image
|
||||
virtual void SetPos(int x, int y)
|
||||
{
|
||||
if ( !m_image )
|
||||
return;
|
||||
|
||||
m_image->SetPos( x, y );
|
||||
}
|
||||
|
||||
// Gets the size of the content
|
||||
virtual void GetContentSize(int &wide, int &tall)
|
||||
{
|
||||
if ( !m_image )
|
||||
return;
|
||||
|
||||
m_image->GetSize( wide, tall );
|
||||
}
|
||||
|
||||
// Get the size the image will actually draw in (usually defaults to the content size)
|
||||
virtual void GetSize(int &wide, int &tall)
|
||||
{
|
||||
if ( !m_image )
|
||||
{
|
||||
wide = tall = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
wide = m_wide;
|
||||
tall = m_tall;
|
||||
}
|
||||
|
||||
// Sets the size of the image
|
||||
virtual void SetSize(int wide, int tall)
|
||||
{
|
||||
m_wide = wide;
|
||||
m_tall = tall;
|
||||
if ( !m_image )
|
||||
return;
|
||||
|
||||
m_image->SetSize( wide, tall );
|
||||
}
|
||||
|
||||
// Set the draw color
|
||||
virtual void SetColor(Color col)
|
||||
{
|
||||
if ( !m_image )
|
||||
return;
|
||||
|
||||
m_image->SetColor( col );
|
||||
}
|
||||
|
||||
virtual bool Evict()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int GetNumFrames()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void SetFrame( int nFrame )
|
||||
{
|
||||
}
|
||||
|
||||
virtual vgui::HTexture GetID()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void SetRotation( int iRotation )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
vgui::IImage *m_image;
|
||||
int m_wide, m_tall;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
struct ImageInfo {
|
||||
vgui::IImage *image;
|
||||
int w;
|
||||
int h;
|
||||
int x;
|
||||
int y;
|
||||
int fullW;
|
||||
int fullH;
|
||||
|
||||
void FitInBounds( int baseX, int baseY, int width, int height, bool center, int scaleAt1024, bool halfHeight = false );
|
||||
void Paint();
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class WeaponImageInfo
|
||||
{
|
||||
public:
|
||||
WeaponImageInfo();
|
||||
~WeaponImageInfo();
|
||||
|
||||
void SetBounds( int left, int top, int wide, int tall );
|
||||
void SetCentered( bool isCentered );
|
||||
void SetScaleAt1024( int weaponScale, int ammoScale );
|
||||
void SetWeapon( const BuyPresetWeapon *pWeapon, bool isPrimary, bool useCurrentAmmoType );
|
||||
|
||||
void ApplyTextSettings( vgui::IScheme *pScheme, bool isProportional );
|
||||
|
||||
void Paint();
|
||||
void PaintText();
|
||||
|
||||
private:
|
||||
void PerformLayout();
|
||||
|
||||
int m_left;
|
||||
int m_top;
|
||||
int m_wide;
|
||||
int m_tall;
|
||||
|
||||
bool m_isPrimary;
|
||||
|
||||
int m_weaponScale;
|
||||
int m_ammoScale;
|
||||
|
||||
bool m_needLayout;
|
||||
bool m_isCentered;
|
||||
ImageInfo m_weapon;
|
||||
ImageInfo m_ammo;
|
||||
|
||||
vgui::TextImage *m_pAmmoText;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class ItemImageInfo
|
||||
{
|
||||
public:
|
||||
ItemImageInfo();
|
||||
~ItemImageInfo();
|
||||
|
||||
void SetBounds( int left, int top, int wide, int tall );
|
||||
void SetItem( const char *imageFname, int count );
|
||||
void ApplyTextSettings( vgui::IScheme *pScheme, bool isProportional );
|
||||
|
||||
void Paint();
|
||||
void PaintText();
|
||||
|
||||
private:
|
||||
void PerformLayout();
|
||||
|
||||
int m_left;
|
||||
int m_top;
|
||||
int m_wide;
|
||||
int m_tall;
|
||||
|
||||
int m_count;
|
||||
|
||||
bool m_needLayout;
|
||||
ImageInfo m_image;
|
||||
|
||||
vgui::TextImage *m_pText;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class WeaponLabel : public vgui::Panel
|
||||
{
|
||||
typedef vgui::Panel BaseClass;
|
||||
public:
|
||||
WeaponLabel(vgui::Panel *parent, const char *panelName);
|
||||
~WeaponLabel();
|
||||
|
||||
void SetWeapon( const BuyPresetWeapon *pWeapon, bool isPrimary, bool showAmmo = false );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
virtual void PerformLayout();
|
||||
virtual void Paint();
|
||||
|
||||
protected:
|
||||
WeaponImageInfo m_weapon;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class EquipmentLabel : public vgui::Panel
|
||||
{
|
||||
typedef vgui::Panel BaseClass;
|
||||
public:
|
||||
EquipmentLabel(vgui::Panel *parent, const char *panelName, const char *imageFname = NULL);
|
||||
~EquipmentLabel();
|
||||
|
||||
void SetItem( const char *imageFname, int count );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
virtual void PerformLayout();
|
||||
virtual void Paint();
|
||||
|
||||
protected:
|
||||
ItemImageInfo m_item;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* BuyPresetEditPanel is a panel displaying a graphical representation of a buy preset.
|
||||
*/
|
||||
class BuyPresetEditPanel : public vgui::EditablePanel
|
||||
{
|
||||
typedef vgui::EditablePanel BaseClass;
|
||||
public:
|
||||
BuyPresetEditPanel( vgui::Panel *parent, const char *panelName, const char *resourceFilename, int fallbackIndex, bool editableName );
|
||||
virtual ~BuyPresetEditPanel();
|
||||
|
||||
void SetWeaponSet( const WeaponSet *pWeaponSet, bool current );
|
||||
virtual void SetText( const wchar_t *text );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
void OnCommand( const char *command); ///< Handle command callbacks
|
||||
|
||||
virtual void OnSizeChanged( int wide, int tall );
|
||||
|
||||
void SetPanelBgColor( Color color ) { if (m_pBgPanel) m_pBgPanel->SetBgColor( color ); }
|
||||
|
||||
protected:
|
||||
void Reset();
|
||||
|
||||
vgui::Panel *m_pBgPanel;
|
||||
|
||||
vgui::TextEntry *m_pTitleEntry;
|
||||
vgui::Label *m_pTitleLabel;
|
||||
vgui::Label *m_pCostLabel;
|
||||
|
||||
WeaponLabel *m_pPrimaryWeapon;
|
||||
WeaponLabel *m_pSecondaryWeapon;
|
||||
|
||||
EquipmentLabel *m_pHEGrenade;
|
||||
EquipmentLabel *m_pSmokeGrenade;
|
||||
EquipmentLabel *m_pFlashbangs;
|
||||
|
||||
EquipmentLabel *m_pDefuser;
|
||||
EquipmentLabel *m_pNightvision;
|
||||
|
||||
EquipmentLabel *m_pArmor;
|
||||
|
||||
int m_baseWide;
|
||||
int m_baseTall;
|
||||
|
||||
int m_fallbackIndex;
|
||||
};
|
||||
|
||||
|
||||
#endif // BUYPRESET_WEAPONSETLABEL_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,202 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
// Author: Matthew D. Campbell (matt@turtlerockstudios.com), 2003
|
||||
|
||||
#ifndef CAREER_BOX_H
|
||||
#define CAREER_BOX_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui_controls/Frame.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
#include "weapon_csbase.h"
|
||||
#include "buy_presets/buy_presets.h"
|
||||
#include "buypreset_listbox.h"
|
||||
#include "buypreset_weaponsetlabel.h"
|
||||
|
||||
class ConVarToggleCheckButton;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Base class for career popup dialogs (handles custom backgrounds, etc)
|
||||
*/
|
||||
class CCareerBaseBox : public vgui::Frame
|
||||
{
|
||||
public:
|
||||
CCareerBaseBox(vgui::Panel *parent, const char *panelName, bool loadResources = true, bool useCareerButtons = false );
|
||||
virtual void ShowWindow();
|
||||
void DoModal();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void PaintBackground();
|
||||
virtual void PaintBorder();
|
||||
virtual void PerformLayout();
|
||||
void SetLabelText( const char *text );
|
||||
void SetLabelText( const wchar_t *text );
|
||||
void SetCancelButtonAsDefault();
|
||||
vgui::Button * GetOkButton() { return m_pOkButton; }
|
||||
virtual vgui::Panel *CreateControlByName(const char *controlName);
|
||||
|
||||
private:
|
||||
typedef vgui::Frame BaseClass;
|
||||
vgui::Button *m_pOkButton;
|
||||
vgui::Button *m_pCancelButton;
|
||||
vgui::Dar<vgui::Button *> m_buttons;
|
||||
vgui::Dar<ConVarToggleCheckButton *> m_conVarCheckButtons;
|
||||
|
||||
Color m_bgColor;
|
||||
Color m_borderColor;
|
||||
vgui::Label *m_pTextLabel;
|
||||
bool m_cancelFocus;
|
||||
|
||||
protected:
|
||||
void SetLabelVisible( bool visible ) { m_pTextLabel->SetVisible( visible ); }
|
||||
virtual void OnKeyCodeTyped( vgui::KeyCode code );
|
||||
virtual void OnCommand( const char *command ); ///< Handle button presses
|
||||
void AddButton( vgui::Button *pButton ); ///< Add a button to our list of buttons for rollover sounds
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Popup dialog with functionality similar to QueryBox, bot with different layout
|
||||
*/
|
||||
class CCareerQueryBox : public CCareerBaseBox
|
||||
{
|
||||
public:
|
||||
CCareerQueryBox(vgui::Panel *parent, const char *panelName, const char *resourceName = NULL);
|
||||
CCareerQueryBox(const char *title, const char *labelText, const char *panelName, vgui::Panel *parent = NULL);
|
||||
CCareerQueryBox(const wchar_t *title, const wchar_t *labelText, const char *panelName, vgui::Panel *parent = NULL);
|
||||
|
||||
virtual ~CCareerQueryBox();
|
||||
|
||||
private:
|
||||
typedef CCareerBaseBox BaseClass;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Popup dialog for selecting and editing a primary weapon (ammo to buy, side-availability)
|
||||
*/
|
||||
class CWeaponSelectBox : public CCareerBaseBox
|
||||
{
|
||||
public:
|
||||
CWeaponSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet, bool isSecondary );
|
||||
|
||||
virtual ~CWeaponSelectBox();
|
||||
|
||||
virtual void ActivateBuildMode();
|
||||
|
||||
void UpdateClips();
|
||||
|
||||
protected:
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
private:
|
||||
void PopulateControls();
|
||||
void SetClipsVisible( bool visible );
|
||||
|
||||
CSWeaponID GetSelectedWeaponID();
|
||||
|
||||
typedef CCareerBaseBox BaseClass;
|
||||
vgui::ComboBox *m_pClips; ///< Number of clips to purchase
|
||||
vgui::Label *m_pBullets; ///< Label showing "M of N Bullets"
|
||||
|
||||
WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
|
||||
bool m_isSecondary; ///< is this weapon primary or secondary?
|
||||
BuyPresetListBox *m_pListBox; ///< List of weapons from which to choose
|
||||
|
||||
int m_numWeapons;
|
||||
CSWeaponID *m_weaponIDs;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Base class for editing grenades and equipment
|
||||
*/
|
||||
class CBaseSelectBox : public CCareerBaseBox
|
||||
{
|
||||
typedef CCareerBaseBox BaseClass;
|
||||
|
||||
public:
|
||||
CBaseSelectBox( vgui::Panel *parent, const char *panelName, bool loadResources = true ) : BaseClass( parent, panelName, loadResources ) {}
|
||||
|
||||
virtual void OnControlChanged() = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Popup dialog for editing grenades in a buy preset fallback
|
||||
*/
|
||||
class CGrenadeSelectBox : public CBaseSelectBox
|
||||
{
|
||||
typedef CBaseSelectBox BaseClass;
|
||||
|
||||
public:
|
||||
CGrenadeSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet );
|
||||
|
||||
void OnControlChanged(); ///< Updates item costs
|
||||
|
||||
private:
|
||||
WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
|
||||
|
||||
// Equipment controls
|
||||
vgui::ComboBox *m_pHEGrenade;
|
||||
EquipmentLabel *m_pHEGrenadeImage;
|
||||
vgui::Label *m_pHELabel;
|
||||
|
||||
vgui::ComboBox *m_pSmokeGrenade;
|
||||
EquipmentLabel *m_pSmokeGrenadeImage;
|
||||
vgui::Label *m_pSmokeLabel;
|
||||
|
||||
vgui::ComboBox *m_pFlashbangs;
|
||||
EquipmentLabel *m_pFlashbangImage;
|
||||
vgui::Label *m_pFlashLabel;
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Popup dialog for selecting an equipment set
|
||||
*/
|
||||
class CEquipmentSelectBox : public CBaseSelectBox
|
||||
{
|
||||
typedef CBaseSelectBox BaseClass;
|
||||
|
||||
public:
|
||||
CEquipmentSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet );
|
||||
|
||||
void OnControlChanged();
|
||||
|
||||
private:
|
||||
WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
|
||||
|
||||
// Equipment controls
|
||||
vgui::ComboBox *m_pKevlar;
|
||||
vgui::Label *m_pKevlarLabel;
|
||||
EquipmentLabel *m_pKevlarImage;
|
||||
|
||||
vgui::ComboBox *m_pHelmet;
|
||||
vgui::Label *m_pHelmetLabel;
|
||||
EquipmentLabel *m_pHelmetImage;
|
||||
|
||||
vgui::ComboBox *m_pDefuser;
|
||||
vgui::Label *m_pDefuserLabel;
|
||||
EquipmentLabel *m_pDefuserImage;
|
||||
|
||||
vgui::ComboBox *m_pNightvision;
|
||||
vgui::Label *m_pNightvisionLabel;
|
||||
EquipmentLabel *m_pNightvisionImage;
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
};
|
||||
|
||||
#endif // CAREER_BOX_H
|
||||
@@ -1,189 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include <convar.h>
|
||||
#include "cdll_int.h"
|
||||
#include <ienginevgui.h>
|
||||
#include "filesystem.h"
|
||||
#include <vgui/ISystem.h>
|
||||
#include "career_button.h"
|
||||
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/URLLabel.h>
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui_controls/ScrollBar.h>
|
||||
#include <vgui_controls/BuildGroup.h>
|
||||
#include <vgui_controls/ImageList.h>
|
||||
#include <vgui_controls/TextImage.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
|
||||
#include "KeyValues.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#ifndef _DEBUG
|
||||
#define PROPORTIONAL_CAREER_FRAMES 1
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
CCareerButton::CCareerButton(vgui::Panel *parent, const char *buttonName, const char *buttonText, const char *image, bool textFirst) : BaseClass( parent, buttonName, "" )
|
||||
{
|
||||
m_armedBorder = NULL;
|
||||
|
||||
m_textImage = new TextImage(buttonText);
|
||||
m_image = scheme()->GetImage(image, true);
|
||||
m_textFirst = textFirst;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void CCareerButton::SetImage( const char *image )
|
||||
{
|
||||
m_image = scheme()->GetImage(image, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void CCareerButton::Paint()
|
||||
{
|
||||
int buttonWide, buttonTall;
|
||||
GetSize(buttonWide, buttonTall);
|
||||
|
||||
int imageWide, imageTall;
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->GetSize(imageWide, imageTall);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageWide = imageTall = 0;
|
||||
}
|
||||
|
||||
int textOffset = m_textPad;
|
||||
|
||||
if (m_textFirst)
|
||||
{
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->SetPos(buttonWide - imageWide - m_imagePad, (buttonTall - imageTall)/2);
|
||||
m_image->Paint();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->SetPos(m_imagePad, (buttonTall - imageTall)/2);
|
||||
m_image->Paint();
|
||||
}
|
||||
textOffset += imageWide + m_imagePad;
|
||||
}
|
||||
|
||||
int textTall, textWide;
|
||||
m_textImage->GetSize(textWide, textTall);
|
||||
|
||||
int textSpace = buttonWide - imageWide - m_imagePad - 2*m_textPad;
|
||||
|
||||
if ( IsEnabled() )
|
||||
{
|
||||
m_textImage->SetColor( m_textNormalColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textImage->SetColor( m_textDisabledColor );
|
||||
}
|
||||
m_textImage->SetPos(textOffset + (textSpace - textWide)/2, (buttonTall - textTall)/2);
|
||||
m_textImage->Paint();
|
||||
|
||||
if (HasFocus() && IsEnabled() )
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
x0 = 3, y0 = 3, x1 = buttonWide - 4 , y1 = buttonTall - 2;
|
||||
DrawFocusBorder(x0, y0, x1, y1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void CCareerButton::SetArmedBorder(IBorder *border)
|
||||
{
|
||||
m_armedBorder = border;
|
||||
InvalidateLayout(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
IBorder* CCareerButton::GetBorder(bool depressed, bool armed, bool selected, bool keyfocus)
|
||||
{
|
||||
if ( /*_buttonBorderEnabled &&*/ armed && !depressed && IsEnabled() )
|
||||
{
|
||||
return m_armedBorder;
|
||||
}
|
||||
|
||||
return BaseClass::GetBorder( depressed, armed, selected, keyfocus );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void CCareerButton::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetDefaultBorder( pScheme->GetBorder("CareerButtonBorder") );
|
||||
SetDepressedBorder( pScheme->GetBorder("CareerButtonDepressedBorder") );
|
||||
m_armedBorder = pScheme->GetBorder("CareerButtonArmedBorder");
|
||||
|
||||
m_textNormalColor = pScheme->GetColor( "Label.TextBrightColor", Color(255, 255, 255, 255) );
|
||||
m_textDisabledColor = pScheme->GetColor( "Label.DisabledFgColor2", Color(128, 128, 128, 255) );
|
||||
m_textImage->SetColor( m_textNormalColor );
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->SetColor( GetFgColor() );
|
||||
}
|
||||
|
||||
m_textImage->SetFont( pScheme->GetFont( "Default", IsProportional() ) );
|
||||
|
||||
m_textPad = atoi(pScheme->GetResourceString( "CareerButtonTextPad" ));
|
||||
m_imagePad = atoi(pScheme->GetResourceString( "CareerButtonImagePad" ));
|
||||
if (IsProportional())
|
||||
{
|
||||
m_textPad = scheme()->GetProportionalScaledValueEx( GetScheme(),m_textPad);
|
||||
m_imagePad = scheme()->GetProportionalScaledValueEx( GetScheme(),m_imagePad);
|
||||
}
|
||||
|
||||
const int BufLen = 128;
|
||||
char buf[BufLen];
|
||||
GetText(buf, BufLen);
|
||||
m_textImage->SetText(buf);
|
||||
m_textImage->ResizeImageToContent();
|
||||
|
||||
int buttonWide, buttonTall;
|
||||
GetSize(buttonWide, buttonTall);
|
||||
|
||||
int imageWide, imageTall;
|
||||
if ( m_image )
|
||||
{
|
||||
m_image->GetSize(imageWide, imageTall);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageWide = imageTall = 0;
|
||||
}
|
||||
|
||||
int textSpace = buttonWide - imageWide - m_imagePad - 2*m_textPad;
|
||||
|
||||
int textWide, textTall;
|
||||
m_textImage->GetContentSize(textWide, textTall);
|
||||
if (textSpace < textWide)
|
||||
m_textImage->SetSize(textSpace, textTall);
|
||||
|
||||
Color bgColor = pScheme->GetColor( "CareerButtonBG", Color(0, 0, 0, 0) );
|
||||
SetDefaultColor( bgColor, bgColor );
|
||||
SetArmedColor( bgColor, bgColor );
|
||||
SetDepressedColor( bgColor, bgColor );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,57 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CAREER_BUTTON_H
|
||||
#define CAREER_BUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui/VGUI.h>
|
||||
#include <vgui_controls/Frame.h>
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include <vgui_controls/BitmapImagePanel.h>
|
||||
#include <vgui_controls/PanelListPanel.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui/KeyCode.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* This class adds border functionality necessary for next/prev/start buttons on map and bot screens
|
||||
*/
|
||||
class CCareerButton : public vgui::Button
|
||||
{
|
||||
public:
|
||||
CCareerButton(vgui::Panel *parent, const char *buttonName, const char *buttonText, const char *image, bool textFirst );
|
||||
|
||||
// Set armed button border attributes. Added in CCareerButton.
|
||||
virtual void SetArmedBorder(vgui::IBorder *border);
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
virtual void Paint();
|
||||
|
||||
void SetImage( const char *image );
|
||||
|
||||
protected:
|
||||
|
||||
// Get button border attributes.
|
||||
virtual vgui::IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
|
||||
|
||||
vgui::IBorder *m_armedBorder;
|
||||
vgui::IImage *m_image;
|
||||
vgui::TextImage *m_textImage;
|
||||
bool m_textFirst;
|
||||
int m_textPad;
|
||||
int m_imagePad;
|
||||
|
||||
Color m_textNormalColor;
|
||||
Color m_textDisabledColor;
|
||||
|
||||
private:
|
||||
typedef vgui::Button BaseClass;
|
||||
};
|
||||
|
||||
#endif // CAREER_BUTTON_H
|
||||
@@ -1,322 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client DLL VGUI2 Viewport
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#pragma warning( disable : 4800 ) // disable forcing int to bool performance warning
|
||||
|
||||
// VGUI panel includes
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/Cursor.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/VGUI.h>
|
||||
|
||||
// client dll/engine defines
|
||||
#include "hud.h"
|
||||
#include <voice_status.h>
|
||||
|
||||
// cstrike specific dialogs
|
||||
#include "cstriketextwindow.h"
|
||||
#include "cstriketeammenu.h"
|
||||
#include "cstrikeclassmenu.h"
|
||||
#include "cstrikebuymenu.h"
|
||||
#include "cstrikebuyequipmenu.h"
|
||||
#include "cstrikespectatorgui.h"
|
||||
#include "cstrikeclientscoreboard.h"
|
||||
#include "clientmode_csnormal.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
|
||||
// viewport definitions
|
||||
#include <baseviewport.h>
|
||||
#include "counterstrikeviewport.h"
|
||||
#include "cs_gamerules.h"
|
||||
// #include "c_user_message_register.h"
|
||||
#include "vguicenterprint.h"
|
||||
#include "text_message.h"
|
||||
|
||||
|
||||
static void OpenPanelWithCheck( const char *panelToOpen, const char *panelToCheck )
|
||||
{
|
||||
IViewPortPanel *checkPanel = gViewPortInterface->FindPanelByName( panelToCheck );
|
||||
if ( !checkPanel || !checkPanel->IsVisible() )
|
||||
{
|
||||
gViewPortInterface->ShowPanel( panelToOpen, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CON_COMMAND( buyequip, "Show equipment buy menu" )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if( pPlayer && pPlayer->m_lifeState == LIFE_ALIVE && pPlayer->State_Get() == STATE_ACTIVE )
|
||||
{
|
||||
if( !pPlayer->IsInBuyZone() )
|
||||
{
|
||||
internalCenterPrint->Print( "#Cstrike_NotInBuyZone" );
|
||||
}
|
||||
else if( CSGameRules()->IsBuyTimeElapsed() )
|
||||
{
|
||||
char strBuyTime[16];
|
||||
Q_snprintf( strBuyTime, sizeof( strBuyTime ), "%d", (int)CSGameRules()->GetBuyTimeLength() );
|
||||
|
||||
wchar_t buffer[128];
|
||||
wchar_t buytime[16];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strBuyTime, buytime, sizeof(buytime) );
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#Cstrike_TitlesTXT_Cant_buy"), 1, buytime );
|
||||
internalCenterPrint->Print( buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pPlayer->GetTeamNumber() == TEAM_CT )
|
||||
{
|
||||
OpenPanelWithCheck( PANEL_BUY_EQUIP_CT, PANEL_BUY_CT );
|
||||
}
|
||||
else if( pPlayer->GetTeamNumber() == TEAM_TERRORIST )
|
||||
{
|
||||
OpenPanelWithCheck( PANEL_BUY_EQUIP_TER, PANEL_BUY_TER );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CON_COMMAND( buymenu, "Show main buy menu" )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if( pPlayer )
|
||||
{
|
||||
if ( pPlayer->m_lifeState != LIFE_ALIVE && pPlayer->State_Get() != STATE_ACTIVE )
|
||||
return;
|
||||
|
||||
if( !pPlayer->IsInBuyZone() )
|
||||
{
|
||||
internalCenterPrint->Print( "#Cstrike_NotInBuyZone" );
|
||||
}
|
||||
else if( CSGameRules()->IsBuyTimeElapsed() )
|
||||
{
|
||||
char strBuyTime[16];
|
||||
Q_snprintf( strBuyTime, sizeof( strBuyTime ), "%d", (int)CSGameRules()->GetBuyTimeLength() );
|
||||
|
||||
wchar_t buffer[128];
|
||||
wchar_t buytime[16];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strBuyTime, buytime, sizeof(buytime) );
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#Cstrike_TitlesTXT_Cant_buy"), 1, buytime );
|
||||
internalCenterPrint->Print( buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pPlayer->GetTeamNumber() == TEAM_CT )
|
||||
{
|
||||
OpenPanelWithCheck( PANEL_BUY_CT, PANEL_BUY_EQUIP_CT );
|
||||
}
|
||||
else if( pPlayer->GetTeamNumber() == TEAM_TERRORIST )
|
||||
{
|
||||
OpenPanelWithCheck( PANEL_BUY_TER, PANEL_BUY_EQUIP_TER );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CON_COMMAND( chooseteam, "Choose a new team" )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer && pPlayer->CanShowTeamMenu() )
|
||||
{
|
||||
gViewPortInterface->ShowPanel( PANEL_TEAM, true );
|
||||
}
|
||||
}
|
||||
|
||||
CON_COMMAND_F( spec_help, "Show spectator help screen", FCVAR_CLIENTCMD_CAN_EXECUTE)
|
||||
{
|
||||
if ( gViewPortInterface )
|
||||
gViewPortInterface->ShowPanel( PANEL_INFO, true );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( spec_menu, "Activates spectator menu", FCVAR_CLIENTCMD_CAN_EXECUTE)
|
||||
{
|
||||
bool bShowIt = true;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer && !pPlayer->IsObserver() )
|
||||
return;
|
||||
|
||||
if ( args.ArgC() == 2 )
|
||||
{
|
||||
bShowIt = atoi( args[ 1 ] ) == 1;
|
||||
}
|
||||
|
||||
if ( gViewPortInterface )
|
||||
gViewPortInterface->ShowPanel( PANEL_SPECMENU, bShowIt );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( togglescores, "Toggles score panel", FCVAR_CLIENTCMD_CAN_EXECUTE)
|
||||
{
|
||||
if ( !gViewPortInterface )
|
||||
return;
|
||||
|
||||
IViewPortPanel *scoreboard = gViewPortInterface->FindPanelByName( PANEL_SCOREBOARD );
|
||||
|
||||
if ( !scoreboard )
|
||||
return;
|
||||
|
||||
if ( scoreboard->IsVisible() )
|
||||
{
|
||||
gViewPortInterface->ShowPanel( scoreboard, false );
|
||||
GetClientVoiceMgr()->StopSquelchMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
gViewPortInterface->ShowPanel( scoreboard, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called when the VGUI subsystem starts up
|
||||
// Creates the sub panels and initialises them
|
||||
//-----------------------------------------------------------------------------
|
||||
void CounterStrikeViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager )
|
||||
{
|
||||
BaseClass::Start( pGameUIFuncs, pGameEventManager );
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
gHUD.InitColors( pScheme );
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
}
|
||||
|
||||
|
||||
IViewPortPanel* CounterStrikeViewport::CreatePanelByName(const char *szPanelName)
|
||||
{
|
||||
IViewPortPanel* newpanel = NULL;
|
||||
|
||||
// overwrite MOD specific panel creation
|
||||
|
||||
if ( Q_strcmp(PANEL_SCOREBOARD, szPanelName) == 0)
|
||||
{
|
||||
newpanel = new CCSClientScoreBoardDialog( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_SPECGUI, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSSpectatorGUI( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_CLASS_CT, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CClassMenu_CT( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_CLASS_TER, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CClassMenu_TER( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_BUY_CT, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSBuyMenu_CT( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_BUY_TER, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSBuyMenu_TER( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_BUY_EQUIP_CT, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSBuyEquipMenu_CT( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_BUY_EQUIP_TER, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSBuyEquipMenu_TER( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSTeamMenu( this );
|
||||
}
|
||||
|
||||
else if ( Q_strcmp(PANEL_INFO, szPanelName) == 0 )
|
||||
{
|
||||
newpanel = new CCSTextWindow( this );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// create a generic base panel, don't add twice
|
||||
newpanel = BaseClass::CreatePanelByName( szPanelName );
|
||||
}
|
||||
|
||||
return newpanel;
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::CreateDefaultPanels( void )
|
||||
{
|
||||
AddNewPanel( CreatePanelByName( PANEL_TEAM ), "PANEL_TEAM" );
|
||||
AddNewPanel( CreatePanelByName( PANEL_CLASS_CT ), "PANEL_CLASS_CT" );
|
||||
AddNewPanel( CreatePanelByName( PANEL_CLASS_TER ), "PANEL_CLASS_TER" );
|
||||
|
||||
AddNewPanel( CreatePanelByName( PANEL_BUY_CT ), "PANEL_BUY_CT" );
|
||||
AddNewPanel( CreatePanelByName( PANEL_BUY_TER ), "PANEL_BUY_TER" );
|
||||
AddNewPanel( CreatePanelByName( PANEL_BUY_EQUIP_CT ), "PANEL_BUY_EQUIP_CT" );
|
||||
AddNewPanel( CreatePanelByName( PANEL_BUY_EQUIP_TER ), "PANEL_BUY_EQUIP_TER" );
|
||||
|
||||
BaseClass::CreateDefaultPanels();
|
||||
|
||||
}
|
||||
|
||||
int CounterStrikeViewport::GetDeathMessageStartHeight( void )
|
||||
{
|
||||
int x = YRES(2);
|
||||
|
||||
if ( g_pSpectatorGUI && g_pSpectatorGUI->IsVisible() )
|
||||
{
|
||||
x += g_pSpectatorGUI->GetTopBarHeight();
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_ChatInputPosition
|
||||
|
||||
Sets the location of the input for chat text
|
||||
==========================
|
||||
*/
|
||||
//MIKETODO: positioning of chat text (and other engine output)
|
||||
/*
|
||||
#include "Exports.h"
|
||||
|
||||
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
|
||||
{
|
||||
RecClChatInputPosition( x, y );
|
||||
if ( gViewPortInterface )
|
||||
{
|
||||
gViewPortInterface->ChatInputPosition( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE(CounterStrikeViewport, IClientVGUI, CLIENTVGUI_INTERFACE_VERSION);
|
||||
*/
|
||||
@@ -1,61 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef COUNTERSTRIKEVIEWPORT_H
|
||||
#define COUNTERSTRIKEVIEWPORT_H
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
#include "baseviewport.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
class Label;
|
||||
class CBitmapImagePanel;
|
||||
}
|
||||
|
||||
class CCSTeamMenu;
|
||||
class CCSClassMenu;
|
||||
class CCSSpectatorGUI;
|
||||
class CCSClientScoreBoard;
|
||||
class CBuyMenu;
|
||||
class CCSClientScoreBoardDialog;
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class CounterStrikeViewport : public CBaseViewport
|
||||
{
|
||||
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CounterStrikeViewport, CBaseViewport );
|
||||
|
||||
public:
|
||||
|
||||
IViewPortPanel* CreatePanelByName(const char *szPanelName);
|
||||
void CreateDefaultPanels( void );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager );
|
||||
|
||||
int GetDeathMessageStartHeight( void );
|
||||
|
||||
virtual void ShowBackGround(bool bShow)
|
||||
{
|
||||
m_pBackGround->SetVisible( false ); // CS:S menus paint their own backgrounds...
|
||||
}
|
||||
|
||||
private:
|
||||
void CenterWindow( vgui::Frame *win );
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // COUNTERSTRIKEVIEWPORT_H
|
||||
@@ -1,111 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cstrikebuyequipmenu.h"
|
||||
#include "cs_shareddefs.h"
|
||||
#include "cstrikebuysubmenu.h"
|
||||
#include "backgroundpanel.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor for CT Equipment menu
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSBuyEquipMenu_CT::CCSBuyEquipMenu_CT(IViewPort *pViewPort) : CBuyMenu( pViewPort )
|
||||
{
|
||||
SetTitle( "#Cstrike_Buy_Menu", true);
|
||||
|
||||
SetProportional( true );
|
||||
|
||||
m_pMainMenu = new CCSBuySubMenu( this, "BuySubMenu" );
|
||||
m_pMainMenu->LoadControlSettings( "Resource/UI/BuyEquipment_CT.res" );
|
||||
m_pMainMenu->SetVisible( false );
|
||||
|
||||
m_iTeam = TEAM_CT;
|
||||
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor for Terrorist Equipment menu
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSBuyEquipMenu_TER::CCSBuyEquipMenu_TER(IViewPort *pViewPort) : CBuyMenu( pViewPort )
|
||||
{
|
||||
SetTitle( "#Cstrike_Buy_Menu", true);
|
||||
|
||||
SetProportional( true );
|
||||
|
||||
m_pMainMenu = new CCSBuySubMenu( this, "BuySubMenu" );
|
||||
m_pMainMenu->LoadControlSettings( "Resource/UI/BuyEquipment_TER.res" );
|
||||
m_pMainMenu->SetVisible( false );
|
||||
|
||||
m_iTeam = TEAM_TERRORIST;
|
||||
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_CT::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_CT::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_CT::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_TER::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_TER::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuyEquipMenu_TER::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTRIKEBUYEQUIPMENU_H
|
||||
#define CSTRIKEBUYEQUIPMENU_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/WizardPanel.h>
|
||||
|
||||
#include <buymenu.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
}
|
||||
|
||||
//============================
|
||||
// CT Equipment menu
|
||||
//============================
|
||||
class CCSBuyEquipMenu_CT : public CBuyMenu
|
||||
{
|
||||
private:
|
||||
typedef vgui::WizardPanel BaseClass;
|
||||
|
||||
public:
|
||||
CCSBuyEquipMenu_CT(IViewPort *pViewPort);
|
||||
|
||||
virtual const char *GetName( void ) { return PANEL_BUY_EQUIP_CT; }
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
|
||||
//============================
|
||||
// Terrorist Equipment menu
|
||||
//============================
|
||||
|
||||
class CCSBuyEquipMenu_TER : public CBuyMenu
|
||||
{
|
||||
private:
|
||||
typedef vgui::WizardPanel BaseClass;
|
||||
|
||||
public:
|
||||
CCSBuyEquipMenu_TER(IViewPort *pViewPort);
|
||||
|
||||
virtual const char *GetName( void ) { return PANEL_BUY_EQUIP_TER; }
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
#endif // CSTRIKEBUYEQUIPMENU_H
|
||||
@@ -1,883 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cstrikebuysubmenu.h"
|
||||
#include "cstrikebuymenu.h"
|
||||
#include "cs_shareddefs.h"
|
||||
#include "backgroundpanel.h"
|
||||
#include "buy_presets/buy_presets.h"
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "buypreset_weaponsetlabel.h"
|
||||
#include "career_box.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "vgui_controls/RichText.h"
|
||||
#include "cs_weapon_parse.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_ammodef.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
* This button resizes any images to fit in the width/height constraints
|
||||
*/
|
||||
class BuyPresetButton : public vgui::Button
|
||||
{
|
||||
typedef vgui::Button BaseClass;
|
||||
|
||||
public:
|
||||
BuyPresetButton(vgui::Panel *parent, const char *buttonName, const char *buttonText );
|
||||
virtual ~BuyPresetButton();
|
||||
|
||||
virtual void PerformLayout( void );
|
||||
virtual void ClearImages( void );
|
||||
|
||||
virtual void SetFgColor( Color c )
|
||||
{
|
||||
BaseClass::SetFgColor( c );
|
||||
}
|
||||
|
||||
void SetAvailable( bool available )
|
||||
{
|
||||
m_available = available;
|
||||
}
|
||||
|
||||
virtual int AddImage( vgui::IImage *image, int offset )
|
||||
{
|
||||
if ( image )
|
||||
{
|
||||
if ( !m_available )
|
||||
{
|
||||
image->SetColor( Color( 128, 128, 128, 255 ) );
|
||||
}
|
||||
}
|
||||
return BaseClass::AddImage( image, offset );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
m_availableColor = pScheme->GetColor( "Label.TextColor", Color( 0, 0, 0, 0 ) );
|
||||
m_unavailableColor = pScheme->GetColor( "Label.DisabledFgColor2", Color( 0, 0, 0, 0 ) );
|
||||
}
|
||||
|
||||
virtual Color GetButtonFgColor( void )
|
||||
{
|
||||
return ( m_available ) ? m_availableColor : m_unavailableColor;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool m_available;
|
||||
Color m_availableColor;
|
||||
Color m_unavailableColor;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BuyPresetButton::BuyPresetButton(vgui::Panel *parent, const char *buttonName, const char *buttonText ) : Button( parent, buttonName, buttonText )
|
||||
{
|
||||
m_available = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BuyPresetButton::~BuyPresetButton()
|
||||
{
|
||||
ClearImages();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void BuyPresetButton::ClearImages( void )
|
||||
{
|
||||
int imageCount = GetImageCount();
|
||||
for ( int i=0; i<imageCount; ++i )
|
||||
{
|
||||
BuyPresetImage *image = dynamic_cast< BuyPresetImage * >(GetImageAtIndex( i ));
|
||||
if ( image )
|
||||
{
|
||||
delete image;
|
||||
}
|
||||
}
|
||||
|
||||
Button::ClearImages();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void BuyPresetButton::PerformLayout( void )
|
||||
{
|
||||
// resize images
|
||||
int imageCount = GetImageCount();
|
||||
if ( imageCount > 1 )
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
|
||||
for ( int i=1; i<imageCount; ++i )
|
||||
{
|
||||
IImage *image = GetImageAtIndex( i );
|
||||
if ( image )
|
||||
{
|
||||
int imageWide, imageTall;
|
||||
image->GetSize( imageWide, imageTall );
|
||||
|
||||
float scaleX = 1.0f, scaleY = 1.0f;
|
||||
float widthPercent = 0.2f;
|
||||
if ( i == 1 )
|
||||
{
|
||||
widthPercent = 0.6f;
|
||||
}
|
||||
|
||||
if ( imageWide > wide * widthPercent )
|
||||
{
|
||||
scaleX = (float)wide * widthPercent / (float)imageWide;
|
||||
}
|
||||
if ( imageTall > tall )
|
||||
{
|
||||
scaleY = (float)tall / (float)imageTall;
|
||||
}
|
||||
|
||||
float scale = MIN( scaleX, scaleY );
|
||||
if ( scale < 1.0f )
|
||||
{
|
||||
imageWide *= scale;
|
||||
imageTall *= scale;
|
||||
image->SetSize( imageWide, imageTall );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button::PerformLayout();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSBuyMenu_CT::CCSBuyMenu_CT(IViewPort *pViewPort) : CCSBaseBuyMenu( pViewPort, "BuySubMenu_CT" )
|
||||
{
|
||||
m_pMainMenu->LoadControlSettings( "Resource/UI/BuyMenu_CT.res" );
|
||||
m_pMainMenu->SetVisible( false );
|
||||
|
||||
m_iTeam = TEAM_CT;
|
||||
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSBuyMenu_TER::CCSBuyMenu_TER(IViewPort *pViewPort) : CCSBaseBuyMenu( pViewPort, "BuySubMenu_TER" )
|
||||
{
|
||||
m_pMainMenu->LoadControlSettings( "Resource/UI/BuyMenu_TER.res" );
|
||||
m_pMainMenu->SetVisible( false );
|
||||
|
||||
m_iTeam = TEAM_TERRORIST;
|
||||
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSBaseBuyMenu::CCSBaseBuyMenu(IViewPort *pViewPort, const char *subPanelName) : CBuyMenu( pViewPort )
|
||||
{
|
||||
SetTitle( "#Cstrike_Buy_Menu", true);
|
||||
|
||||
SetProportional( true );
|
||||
|
||||
m_pMainMenu = new CCSBuySubMenu( this, subPanelName );
|
||||
m_pMainMenu->SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
|
||||
#if USE_BUY_PRESETS
|
||||
for ( int i=0; i<NUM_BUY_PRESET_BUTTONS; ++i )
|
||||
{
|
||||
m_pBuyPresetButtons[i] = new BuyPresetButton( m_pMainMenu, VarArgs( "BuyPresetButton%c", 'A' + i ), "" );
|
||||
}
|
||||
m_pMoney = new Label( m_pMainMenu, "money", "" );
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [pfreese] mainBackground was the little orange box outside that buy window
|
||||
// that shouldn't have been there. Maybe this was left over from some
|
||||
// copied code.
|
||||
//=============================================================================
|
||||
|
||||
m_pMainBackground = NULL;
|
||||
// m_pMainBackground = new Panel( m_pMainMenu, "mainBackground" );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
m_pLoadout = new BuyPresetEditPanel( m_pMainMenu, "loadoutPanel", "Resource/UI/Loadout.res", 0, false );
|
||||
#else
|
||||
for ( int i=0; i<NUM_BUY_PRESET_BUTTONS; ++i )
|
||||
{
|
||||
m_pBuyPresetButtons[i] = NULL;
|
||||
}
|
||||
m_pMoney = NULL;
|
||||
m_pMainBackground = NULL;
|
||||
#endif // USE_BUY_PRESETS
|
||||
m_lastMoney = -1;
|
||||
|
||||
m_pBlackMarket = new EditablePanel( m_pMainMenu, "BlackMarket_Bargains" );
|
||||
m_pBlackMarket->LoadControlSettings( "Resource/UI/BlackMarket_Bargains.res" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::SetVisible(bool state)
|
||||
{
|
||||
BaseClass::SetVisible(state);
|
||||
|
||||
if ( state )
|
||||
{
|
||||
Panel *defaultButton = FindChildByName( "CancelButton" );
|
||||
if ( defaultButton )
|
||||
{
|
||||
defaultButton->RequestFocus();
|
||||
}
|
||||
SetMouseInputEnabled( true );
|
||||
m_pMainMenu->SetMouseInputEnabled( true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shows/hides the buy menu
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::ShowPanel(bool bShow)
|
||||
{
|
||||
CBuyMenu::ShowPanel( bShow );
|
||||
|
||||
#if USE_BUY_PRESETS
|
||||
if ( bShow )
|
||||
{
|
||||
UpdateBuyPresets( true );
|
||||
}
|
||||
#endif // USE_BUY_PRESETS
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void GetPanelBounds( Panel *pPanel, wrect_t& bounds )
|
||||
{
|
||||
if ( !pPanel )
|
||||
{
|
||||
bounds.bottom = bounds.left = bounds.right = bounds.top = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPanel->GetBounds( bounds.left, bounds.top, bounds.right, bounds.bottom );
|
||||
bounds.right += bounds.left;
|
||||
bounds.bottom += bounds.top;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::Paint()
|
||||
{
|
||||
#if USE_BUY_PRESETS
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
int account = (pPlayer) ? pPlayer->GetAccount() : 0;
|
||||
|
||||
if ( m_pMoney && m_lastMoney != account )
|
||||
{
|
||||
m_lastMoney = account;
|
||||
|
||||
const int BufLen = 128;
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_Current_Money");
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, NumAsWString( m_lastMoney ) );
|
||||
m_pMoney->SetText( wbuf );
|
||||
}
|
||||
#endif // USE_BUY_PRESETS
|
||||
|
||||
CBuyMenu::Paint();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::UpdateBuyPresets( bool showDefaultPanel )
|
||||
{
|
||||
bool setPanelVisible = false;
|
||||
if ( !showDefaultPanel )
|
||||
{
|
||||
setPanelVisible = true;
|
||||
}
|
||||
|
||||
if ( !TheBuyPresets )
|
||||
TheBuyPresets = new BuyPresetManager();
|
||||
|
||||
int i;
|
||||
// show buy preset buttons
|
||||
int numPresets = MIN( TheBuyPresets->GetNumPresets(), NUM_BUY_PRESET_BUTTONS );
|
||||
for ( i=0; i<numPresets; ++i )
|
||||
{
|
||||
if ( !m_pBuyPresetButtons[i] )
|
||||
continue;
|
||||
|
||||
const BuyPreset *preset = TheBuyPresets->GetPreset(i);
|
||||
|
||||
int setIndex;
|
||||
int currentCost = -1;
|
||||
WeaponSet currentSet;
|
||||
const WeaponSet *fullSet = NULL;
|
||||
for ( setIndex = 0; setIndex < preset->GetNumSets(); ++setIndex )
|
||||
{
|
||||
const WeaponSet *itemSet = preset->GetSet( setIndex );
|
||||
if ( itemSet )
|
||||
{
|
||||
itemSet->GetCurrent( currentCost, currentSet );
|
||||
if ( currentCost >= 0 )
|
||||
{
|
||||
fullSet = itemSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !fullSet && preset->GetNumSets() )
|
||||
{
|
||||
fullSet = preset->GetSet( 0 );
|
||||
}
|
||||
|
||||
// set the button's images
|
||||
m_pBuyPresetButtons[i]->ClearImages();
|
||||
m_pBuyPresetButtons[i]->SetTextImageIndex( 0 );
|
||||
m_pBuyPresetButtons[i]->SetText( "" );
|
||||
|
||||
m_pBuyPresetButtons[i]->SetAvailable( currentCost >= 0 );
|
||||
|
||||
const char *imageName = "";
|
||||
if ( fullSet )
|
||||
{
|
||||
if ( fullSet->GetPrimaryWeapon().GetWeaponID() != WEAPON_NONE )
|
||||
{
|
||||
imageName = ImageFnameFromWeaponID( fullSet->GetPrimaryWeapon().GetWeaponID(), true );
|
||||
BuyPresetImage * image = new BuyPresetImage( scheme()->GetImage(imageName, true) );
|
||||
m_pBuyPresetButtons[i]->AddImage( image, 0 );
|
||||
}
|
||||
if ( fullSet->GetSecondaryWeapon().GetWeaponID() != WEAPON_NONE )
|
||||
{
|
||||
imageName = ImageFnameFromWeaponID( fullSet->GetSecondaryWeapon().GetWeaponID(), false );
|
||||
BuyPresetImage * image = new BuyPresetImage( scheme()->GetImage(imageName, true) );
|
||||
m_pBuyPresetButtons[i]->AddImage( image, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
int displayCost = currentCost;
|
||||
if ( displayCost < 0 )
|
||||
displayCost = 0;
|
||||
|
||||
const int BufLen = 1024;
|
||||
char aBuf[BufLen];
|
||||
Q_snprintf(aBuf, BufLen, "#Cstrike_BuyMenuPreset%d", i + 1);
|
||||
m_pBuyPresetButtons[i]->SetText( g_pVGuiLocalize->Find(aBuf) );
|
||||
Q_snprintf(aBuf, BufLen, "cl_buy_favorite %d", i + 1);
|
||||
m_pBuyPresetButtons[i]->SetCommand( aBuf );
|
||||
m_pBuyPresetButtons[i]->SetVisible( true );
|
||||
m_pBuyPresetButtons[i]->SetEnabled( true );
|
||||
}
|
||||
|
||||
// hide unused buy preset buttons
|
||||
for ( i=numPresets+1; i<NUM_BUY_PRESET_BUTTONS; ++i )
|
||||
{
|
||||
if ( m_pBuyPresetButtons[i] )
|
||||
{
|
||||
m_pBuyPresetButtons[i]->SetVisible( false );
|
||||
m_pBuyPresetButtons[i]->SetEnabled( true );
|
||||
}
|
||||
}
|
||||
|
||||
HandleBlackMarket();
|
||||
}
|
||||
|
||||
const char *g_pWeaponNames[] =
|
||||
{
|
||||
" ",
|
||||
"#Cstrike_TitlesTXT_P228",
|
||||
"#Cstrike_TitlesTXT_Glock18",
|
||||
"#Cstrike_TitlesTXT_Scout",
|
||||
"#Cstrike_TitlesTXT_HE_Grenade",
|
||||
"#Cstrike_TitlesTXT_XM1014",
|
||||
" ",
|
||||
"#Cstrike_TitlesTXT_Mac10",
|
||||
"#Cstrike_TitlesTXT_Aug",
|
||||
"#Cstrike_TitlesTXT_Smoke_Grenade",
|
||||
"#Cstrike_TitlesTXT_Dual40",
|
||||
"#Cstrike_TitlesTXT_FiveSeven",
|
||||
"#Cstrike_TitlesTXT_UMP45",
|
||||
"#Cstrike_TitlesTXT_SG550",
|
||||
"#Cstrike_TitlesTXT_Galil",
|
||||
"#Cstrike_TitlesTXT_Famas",
|
||||
"#Cstrike_TitlesTXT_USP45",
|
||||
"#Cstrike_TitlesTXT_Magnum",
|
||||
"#Cstrike_TitlesTXT_mp5navy",
|
||||
"#Cstrike_TitlesTXT_ESM249",
|
||||
"#Cstrike_TitlesTXT_Leone12",
|
||||
"#Cstrike_TitlesTXT_M4A1",
|
||||
"#Cstrike_TitlesTXT_tmp",
|
||||
"#Cstrike_TitlesTXT_G3SG1",
|
||||
"#Cstrike_TitlesTXT_Flashbang",
|
||||
"#Cstrike_TitlesTXT_DesertEagle",
|
||||
"#Cstrike_TitlesTXT_SG552",
|
||||
"#Cstrike_TitlesTXT_AK47",
|
||||
" ",
|
||||
"#Cstrike_TitlesTXT_FNP90",
|
||||
" ",
|
||||
"#Cstrike_TitlesTXT_Kevlar_Vest",
|
||||
"#Cstrike_TitlesTXT_Kevlar_Vest_Ballistic_Helmet",
|
||||
"#Cstrike_TitlesTXT_Nightvision_Goggles"
|
||||
};
|
||||
|
||||
int GetWeeklyBargain( void )
|
||||
{
|
||||
if ( CSGameRules() == NULL || CSGameRules()->m_pPrices == NULL )
|
||||
return 0;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer == NULL )
|
||||
return 0;
|
||||
|
||||
int iBestIndex = 0;
|
||||
int iBestBargain = 99999;
|
||||
|
||||
for ( int i = 1; i < WEAPON_MAX; i++ )
|
||||
{
|
||||
if ( i == WEAPON_SHIELDGUN )
|
||||
continue;
|
||||
|
||||
CCSWeaponInfo *info = GetWeaponInfo( (CSWeaponID)i );
|
||||
|
||||
if ( info == NULL )
|
||||
continue;
|
||||
|
||||
if ( info->m_iTeam == TEAM_UNASSIGNED || info->m_iTeam == pPlayer->m_iTeamNum )
|
||||
{
|
||||
int iBargain = info->GetWeaponPrice() - info->GetPrevousPrice();
|
||||
|
||||
if ( iBargain < iBestBargain )
|
||||
{
|
||||
iBestIndex = i;
|
||||
iBestBargain = iBargain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iBestIndex;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
ConVar cs_testbargain( "cs_testbargain", "1" );
|
||||
#endif
|
||||
|
||||
void CCSBaseBuyMenu::HandleBlackMarket( void )
|
||||
{
|
||||
if ( CSGameRules() == NULL )
|
||||
return;
|
||||
|
||||
if ( m_pLoadout )
|
||||
{
|
||||
if ( CSGameRules()->IsBlackMarket() )
|
||||
{
|
||||
if ( CSGameRules()->m_pPrices == NULL )
|
||||
return;
|
||||
|
||||
if ( m_pBlackMarket == NULL )
|
||||
return;
|
||||
|
||||
int iBargain = GetWeeklyBargain();
|
||||
CCSWeaponInfo *info = GetWeaponInfo( (CSWeaponID)iBargain );
|
||||
|
||||
wchar_t *wszWeaponName = g_pVGuiLocalize->Find( g_pWeaponNames[iBargain]);
|
||||
|
||||
if ( wszWeaponName == NULL )
|
||||
return;
|
||||
|
||||
if ( info == NULL )
|
||||
return;
|
||||
|
||||
m_pLoadout->SetVisible( false );
|
||||
Label *pLabel = dynamic_cast< Label * >(m_pMainMenu->FindChildByName( "loadoutLabel" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
pLabel->SetVisible( false );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarket->FindChildByName( "MarketHeadline" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
const int BufLen = 2048;
|
||||
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_MarketHeadline");
|
||||
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, wszWeaponName );
|
||||
pLabel->SetText( wbuf );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarket->FindChildByName( "MarketBargain" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
const int BufLen = 2048;
|
||||
wchar_t wbuf[BufLen] = L"";
|
||||
const wchar_t *formatStr = g_pVGuiLocalize->Find("#Cstrike_MarketBargain");
|
||||
|
||||
if ( !formatStr )
|
||||
formatStr = L"%s1";
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), formatStr, 1, wszWeaponName );
|
||||
pLabel->SetText( wbuf );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarket->FindChildByName( "MarketStickerPrice" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
char wbuf[16];
|
||||
|
||||
Q_snprintf( wbuf, 16, "%d", CSGameRules()->m_pPrices->iCurrentPrice[iBargain] );
|
||||
|
||||
pLabel->SetText( wbuf );
|
||||
}
|
||||
|
||||
RichText *pText = dynamic_cast< RichText * >(m_pBlackMarket->FindChildByName( "MarketDescription" ));
|
||||
|
||||
if ( pText )
|
||||
{
|
||||
char wbuf[2048];
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( g_pVGuiLocalize->Find("#Cstrike_MarketDescription"), wbuf, 2048 );
|
||||
|
||||
pText->SetText( "" );
|
||||
pText->InsertPossibleURLString( wbuf, Color( 255, 255, 255, 255 ), Color( 255, 176, 0, 255 ) );
|
||||
pText->SetVerticalScrollbar( false );
|
||||
pText->SetPaintBorderEnabled( false );
|
||||
pText->SetUnderlineFont( m_hUnderlineFont );
|
||||
}
|
||||
|
||||
pLabel = dynamic_cast< Label * >(m_pBlackMarket->FindChildByName( "MarketBargainIcon" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
char wbuff[12];
|
||||
Q_snprintf( wbuff, 12, "%c", info->iconActive->cCharacterInFont );
|
||||
|
||||
pLabel->SetText( wbuff );
|
||||
}
|
||||
|
||||
Button *pButton = dynamic_cast< Button * >(m_pMainMenu->FindChildByName( "BargainbuyButton" ));
|
||||
|
||||
if ( pButton )
|
||||
{
|
||||
char command[512];
|
||||
char *pWeaponName = Q_stristr( info->szClassName, "_" );
|
||||
|
||||
if ( pWeaponName )
|
||||
{
|
||||
pWeaponName++;
|
||||
|
||||
Q_snprintf( command, 512, "buy %s", pWeaponName );
|
||||
}
|
||||
|
||||
pButton->SetCommand( command );
|
||||
pButton->SetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
m_pBlackMarket->SetVisible( true );
|
||||
m_pBlackMarket->SetZPos( -2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponSet ws;
|
||||
|
||||
TheBuyPresets->GetCurrentLoadout( &ws );
|
||||
m_pLoadout->SetWeaponSet( &ws, true );
|
||||
|
||||
m_pLoadout->SetVisible( true );
|
||||
Panel *pLabel = dynamic_cast< Label * >(m_pMainMenu->FindChildByName( "loadoutLabel" ));
|
||||
|
||||
if ( pLabel )
|
||||
{
|
||||
pLabel->SetVisible( true );
|
||||
}
|
||||
|
||||
if ( m_pBlackMarket )
|
||||
{
|
||||
m_pBlackMarket->SetVisible( false );
|
||||
|
||||
Button *pButton = dynamic_cast< Button * >(m_pMainMenu->FindChildByName( "BargainbuyButton" ));
|
||||
|
||||
if ( pButton )
|
||||
{
|
||||
pButton->SetVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBaseBuyMenu::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
|
||||
if ( m_pMainBackground )
|
||||
{
|
||||
m_pMainBackground->SetBorder(pScheme->GetBorder("ButtonDepressedBorder"));
|
||||
m_pMainBackground->SetBgColor( GetSchemeColor( "Button.BgColor", GetBgColor(), pScheme ) );
|
||||
}
|
||||
|
||||
m_hUnderlineFont = pScheme->GetFont( "CSUnderline", IsProportional() );
|
||||
|
||||
#if USE_BUY_PRESETS
|
||||
UpdateBuyPresets( true );
|
||||
#endif // USE_BUY_PRESETS
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool IsWeaponInvalid( CSWeaponID weaponID )
|
||||
{
|
||||
if ( weaponID == WEAPON_NONE )
|
||||
return false;
|
||||
|
||||
return !CanBuyWeapon( WEAPON_NONE, WEAPON_NONE, weaponID );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuySubMenu::OnThink()
|
||||
{
|
||||
UpdateVestHelmPrice();
|
||||
BaseClass::OnThink();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: When buying vest+helmet, if you already have a vest with no damage
|
||||
// then the price is reduced to just the helmet. Because this can change during
|
||||
// the game, we need to update the enable/disable state of the menu item dynamically.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuySubMenu::UpdateVestHelmPrice()
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer == NULL )
|
||||
return;
|
||||
|
||||
BuyMouseOverPanelButton *pButton = dynamic_cast< BuyMouseOverPanelButton * > ( FindChildByName( "kevlar_helmet", false ) );
|
||||
if ( pButton )
|
||||
{
|
||||
// Set its price to the current value from the player.
|
||||
pButton->SetCurrentPrice( pPlayer->GetCurrentAssaultSuitPrice() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuySubMenu::OnCommand( const char *command )
|
||||
{
|
||||
#if USE_BUY_PRESETS
|
||||
const char *buyPresetSetString = "cl_buy_favorite_query_set ";
|
||||
if ( !strnicmp( command, buyPresetSetString, strlen( buyPresetSetString ) ) )
|
||||
{
|
||||
bool invalid = IsWeaponInvalid( GetClientWeaponID( true ) ) || IsWeaponInvalid( GetClientWeaponID( false ) );
|
||||
if ( invalid )
|
||||
{
|
||||
// can't save the favorite because it has an invalid weapon (colt for a T, etc)
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.CantBuy" );
|
||||
}
|
||||
|
||||
if ( cl_buy_favorite_nowarn.GetBool() )
|
||||
{
|
||||
BaseClass::OnCommand( "vguicancel" );
|
||||
}
|
||||
else
|
||||
{
|
||||
CCareerQueryBox *pBox = new CCareerQueryBox( this, "SetLoadoutError", "Resource/UI/SetLoadoutError.res" );
|
||||
pBox->AddActionSignalTarget( this );
|
||||
pBox->DoModal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// can save
|
||||
if ( cl_buy_favorite_quiet.GetBool() )
|
||||
{
|
||||
BaseClass::OnCommand( VarArgs( "cl_buy_favorite_set %d", atoi( command + strlen( buyPresetSetString ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
CCareerQueryBox *pBox = new CCareerQueryBox( this, "SetLoadoutQuery", "Resource/UI/SetLoadoutQuery.res" );
|
||||
pBox->SetCancelButtonAsDefault();
|
||||
if ( pBox->GetOkButton() )
|
||||
{
|
||||
pBox->GetOkButton()->SetCommand( VarArgs( "cl_buy_favorite_set %d", atoi( command + strlen( buyPresetSetString ) ) ) );
|
||||
}
|
||||
pBox->AddActionSignalTarget( this );
|
||||
pBox->DoModal();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif // USE_BUY_PRESETS
|
||||
|
||||
if ( FStrEq( command, "buy_unavailable" ) )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.CantBuy" );
|
||||
}
|
||||
BaseClass::OnCommand( "vguicancel" );
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
|
||||
void CCSBuySubMenu::OnSizeChanged(int newWide, int newTall)
|
||||
{
|
||||
m_backgroundLayoutFinished = false;
|
||||
BaseClass::OnSizeChanged( newWide, newTall );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSBuySubMenu::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// Buy submenus need to be shoved over for widescreen
|
||||
int screenW, screenH;
|
||||
GetHudSize( screenW, screenH );
|
||||
|
||||
int fullW, fullH;
|
||||
fullW = scheme()->GetProportionalScaledValueEx( GetScheme(), 640 );
|
||||
fullH = scheme()->GetProportionalScaledValueEx( GetScheme(), 480 );
|
||||
|
||||
fullW = GetAlternateProportionalValueFromScaled( GetScheme(), fullW );
|
||||
fullH = GetAlternateProportionalValueFromScaled( GetScheme(), fullH );
|
||||
|
||||
int offsetX = (screenW - fullW)/2;
|
||||
int offsetY = (screenH - fullH)/2;
|
||||
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
ResizeWindowControls( this, GetWide(), GetTall(), offsetX, offsetY );
|
||||
m_backgroundLayoutFinished = true;
|
||||
|
||||
HandleBlackMarket();
|
||||
}
|
||||
|
||||
void CCSBuySubMenu::HandleBlackMarket( void )
|
||||
{
|
||||
if ( CSGameRules() == NULL )
|
||||
return;
|
||||
|
||||
int iBestBargain = 99999;
|
||||
BuyMouseOverPanelButton *pButtonBargain = NULL;
|
||||
|
||||
for (int i = 0; i < GetChildCount(); i++)
|
||||
{
|
||||
BuyMouseOverPanelButton *pButton = dynamic_cast< BuyMouseOverPanelButton * > ( GetChild(i) );
|
||||
if (!pButton)
|
||||
continue;
|
||||
|
||||
pButton->SetBargainButton( false );
|
||||
|
||||
const char *pWeaponName = Q_stristr( pButton->GetBuyCommand(), " " );
|
||||
|
||||
if ( pWeaponName )
|
||||
{
|
||||
pWeaponName++;
|
||||
|
||||
int iWeaponID = AliasToWeaponID(GetTranslatedWeaponAlias(pWeaponName));
|
||||
|
||||
if ( iWeaponID == 0 )
|
||||
continue;
|
||||
|
||||
CCSWeaponInfo *info = GetWeaponInfo( (CSWeaponID)iWeaponID );
|
||||
|
||||
if ( info == NULL )
|
||||
continue;
|
||||
|
||||
if ( CSGameRules()->IsBlackMarket() == false )
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [dwenger] Removed to avoid clearing of default price when not in black market mode
|
||||
//=============================================================================
|
||||
|
||||
// pButton->SetCurrentPrice( info->GetDefaultPrice() );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
else
|
||||
{
|
||||
int iBargain = info->GetWeaponPrice() - info->GetPrevousPrice();
|
||||
|
||||
pButton->SetCurrentPrice( info->GetWeaponPrice() );
|
||||
pButton->SetPreviousPrice( info->GetPrevousPrice() );
|
||||
|
||||
if ( iBargain < iBestBargain )
|
||||
{
|
||||
iBestBargain = iBargain;
|
||||
pButtonBargain = pButton;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( pButtonBargain )
|
||||
{
|
||||
pButtonBargain->SetBargainButton( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTRIKEBUYMENU_H
|
||||
#define CSTRIKEBUYMENU_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/WizardPanel.h>
|
||||
|
||||
#include <buymenu.h>
|
||||
|
||||
class BuyPresetEditPanel;
|
||||
class BuyPresetButton;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
class Button;
|
||||
class Label;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
NUM_BUY_PRESET_BUTTONS = 4,
|
||||
};
|
||||
|
||||
//============================
|
||||
// Base CS buy Menu
|
||||
//============================
|
||||
class CCSBaseBuyMenu : public CBuyMenu
|
||||
{
|
||||
private:
|
||||
typedef vgui::WizardPanel BaseClass;
|
||||
|
||||
public:
|
||||
CCSBaseBuyMenu(IViewPort *pViewPort, const char *subPanelName);
|
||||
|
||||
virtual void ShowPanel( bool bShow );
|
||||
virtual void Paint( void );
|
||||
virtual void SetVisible( bool state );
|
||||
|
||||
void HandleBlackMarket( void );
|
||||
|
||||
private:
|
||||
void UpdateBuyPresets( bool showDefaultPanel = false ); ///< Update the Buy Preset buttons and their info panels on the main buy menu
|
||||
vgui::Panel *m_pMainBackground;
|
||||
BuyPresetButton *m_pBuyPresetButtons[NUM_BUY_PRESET_BUTTONS];
|
||||
BuyPresetEditPanel *m_pLoadout;
|
||||
vgui::Label *m_pMoney;
|
||||
int m_lastMoney;
|
||||
|
||||
vgui::EditablePanel *m_pBlackMarket;
|
||||
HFont m_hUnderlineFont;
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
//============================
|
||||
// CT main buy Menu
|
||||
//============================
|
||||
class CCSBuyMenu_CT : public CCSBaseBuyMenu
|
||||
{
|
||||
private:
|
||||
typedef vgui::WizardPanel BaseClass;
|
||||
|
||||
public:
|
||||
CCSBuyMenu_CT(IViewPort *pViewPort);
|
||||
|
||||
virtual const char *GetName( void ) { return PANEL_BUY_CT; }
|
||||
};
|
||||
|
||||
|
||||
//============================
|
||||
// Terrorist main buy Menu
|
||||
//============================
|
||||
class CCSBuyMenu_TER : public CCSBaseBuyMenu
|
||||
{
|
||||
private:
|
||||
typedef vgui::WizardPanel BaseClass;
|
||||
|
||||
public:
|
||||
CCSBuyMenu_TER(IViewPort *pViewPort);
|
||||
|
||||
virtual const char *GetName( void ) { return PANEL_BUY_TER; }
|
||||
};
|
||||
|
||||
#endif // CSTRIKEBUYMENU_H
|
||||
@@ -1,56 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSBUYSUBMENU_H
|
||||
#define CSBUYSUBMENU_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <buysubmenu.h>
|
||||
#include <buymouseoverpanelbutton.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class CCSBuySubMenu : public CBuySubMenu
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE(CCSBuySubMenu, CBuySubMenu);
|
||||
|
||||
public:
|
||||
CCSBuySubMenu (vgui::Panel *parent,const char *name = "BuySubMenu") : CBuySubMenu( parent, name )
|
||||
{
|
||||
m_backgroundLayoutFinished = false;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnThink();
|
||||
void UpdateVestHelmPrice();
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
|
||||
MouseOverPanelButton* CreateNewMouseOverPanelButton(EditablePanel * panel)
|
||||
{
|
||||
return new BuyMouseOverPanelButton(this, NULL, panel);
|
||||
}
|
||||
|
||||
CBuySubMenu* CreateNewSubMenu() { return new CCSBuySubMenu( this, "BuySubMenu" ); }
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
virtual void PerformLayout();
|
||||
virtual void OnSizeChanged(int newWide, int newTall); // called after the size of a panel has been changed
|
||||
|
||||
void HandleBlackMarket( void );
|
||||
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
#endif //CSBUYSUBMENU_H
|
||||
@@ -1,272 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cstrikeclassmenu.h"
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <filesystem.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui/IVGui.h>
|
||||
|
||||
#include "hud.h" // for gEngfuncs
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- //
|
||||
// Class image panels. These maintain a list of the class image panels so
|
||||
// it can render 3D images into them.
|
||||
// ----------------------------------------------------------------------------- //
|
||||
|
||||
CUtlVector<CCSClassImagePanel*> g_ClassImagePanels;
|
||||
|
||||
|
||||
CCSClassImagePanel::CCSClassImagePanel( vgui::Panel *pParent, const char *pName )
|
||||
: vgui::ImagePanel( pParent, pName )
|
||||
{
|
||||
g_ClassImagePanels.AddToTail( this );
|
||||
m_ModelName[0] = 0;
|
||||
}
|
||||
|
||||
CCSClassImagePanel::~CCSClassImagePanel()
|
||||
{
|
||||
g_ClassImagePanels.FindAndRemove( this );
|
||||
}
|
||||
|
||||
void CCSClassImagePanel::ApplySettings( KeyValues *inResourceData )
|
||||
{
|
||||
const char *pName = inResourceData->GetString( "3DModel" );
|
||||
if ( pName )
|
||||
{
|
||||
Q_strncpy( m_ModelName, pName, sizeof( m_ModelName ) );
|
||||
}
|
||||
|
||||
BaseClass::ApplySettings( inResourceData );
|
||||
}
|
||||
|
||||
|
||||
void CCSClassImagePanel::Paint()
|
||||
{
|
||||
BaseClass::Paint();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- //
|
||||
// CClassMenu_TER
|
||||
// ----------------------------------------------------------------------------- //
|
||||
|
||||
CClassMenu_TER::CClassMenu_TER(IViewPort *pViewPort) : CClassMenu(pViewPort, PANEL_CLASS_TER)
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/ClassMenu_TER.res" );
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
const char *CClassMenu_TER::GetName( void )
|
||||
{
|
||||
return PANEL_CLASS_TER;
|
||||
}
|
||||
|
||||
void CClassMenu_TER::ShowPanel(bool bShow)
|
||||
{
|
||||
if ( bShow)
|
||||
{
|
||||
engine->CheckPoint( "ClassMenu" );
|
||||
}
|
||||
|
||||
BaseClass::ShowPanel( bShow );
|
||||
|
||||
}
|
||||
|
||||
void CClassMenu_TER::SetVisible(bool state)
|
||||
{
|
||||
BaseClass::SetVisible(state);
|
||||
|
||||
if ( state )
|
||||
{
|
||||
Panel *pAutoButton = FindChildByName( "autoselect_t" );
|
||||
if ( pAutoButton )
|
||||
{
|
||||
pAutoButton->RequestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool modelExists( const char *search, const CUtlVector< const char * > &names )
|
||||
{
|
||||
for ( int i=0; i<names.Count(); ++i )
|
||||
{
|
||||
if ( Q_stristr( names[i], search ) != NULL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CClassMenu_TER::Update()
|
||||
{
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pLocalPlayer && pLocalPlayer->PlayerClass() >= FIRST_T_CLASS && pLocalPlayer->PlayerClass() <= LAST_T_CLASS )
|
||||
{
|
||||
SetVisibleButton( "CancelButton", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisibleButton( "CancelButton", false );
|
||||
}
|
||||
|
||||
// if we don't have the new models installed,
|
||||
// turn off the militia and spetsnaz buttons
|
||||
SetVisibleButton( "militia", false );
|
||||
}
|
||||
|
||||
|
||||
Panel *CClassMenu_TER::CreateControlByName(const char *controlName)
|
||||
{
|
||||
if ( Q_stricmp( controlName, "CSClassImagePanel" ) == 0 )
|
||||
{
|
||||
return new CCSClassImagePanel( NULL, controlName );
|
||||
}
|
||||
|
||||
return BaseClass::CreateControlByName( controlName );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- //
|
||||
// CClassMenu_CT
|
||||
// ----------------------------------------------------------------------------- //
|
||||
|
||||
CClassMenu_CT::CClassMenu_CT(IViewPort *pViewPort) : CClassMenu(pViewPort, PANEL_CLASS_CT)
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/ClassMenu_CT.res" );
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
Panel *CClassMenu_CT::CreateControlByName(const char *controlName)
|
||||
{
|
||||
if ( Q_stricmp( controlName, "CSClassImagePanel" ) == 0 )
|
||||
{
|
||||
return new CCSClassImagePanel( NULL, controlName );
|
||||
}
|
||||
|
||||
return BaseClass::CreateControlByName( controlName );
|
||||
}
|
||||
|
||||
const char *CClassMenu_CT::GetName( void )
|
||||
{
|
||||
return PANEL_CLASS_CT;
|
||||
}
|
||||
|
||||
void CClassMenu_CT::ShowPanel(bool bShow)
|
||||
{
|
||||
if ( bShow)
|
||||
{
|
||||
engine->CheckPoint( "ClassMenu" );
|
||||
}
|
||||
|
||||
BaseClass::ShowPanel( bShow );
|
||||
|
||||
}
|
||||
|
||||
void CClassMenu_CT::SetVisible(bool state)
|
||||
{
|
||||
BaseClass::SetVisible(state);
|
||||
|
||||
if ( state )
|
||||
{
|
||||
Panel *pAutoButton = FindChildByName( "autoselect_ct" );
|
||||
if ( pAutoButton )
|
||||
{
|
||||
pAutoButton->RequestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CClassMenu_CT::Update()
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer && pPlayer->PlayerClass() >= FIRST_CT_CLASS && pPlayer->PlayerClass() <= LAST_CT_CLASS )
|
||||
{
|
||||
SetVisibleButton( "CancelButton", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisibleButton( "CancelButton", false );
|
||||
}
|
||||
|
||||
// if we don't have the new models installed,
|
||||
// turn off the militia and spetsnaz buttons
|
||||
SetVisibleButton( "spetsnaz", false );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_TER::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_TER::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_TER::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_CT::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_CT::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenu_CT::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSCLASSMENU_H
|
||||
#define CSCLASSMENU_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <classmenu.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include <filesystem.h>
|
||||
#include <cs_shareddefs.h>
|
||||
#include "cbase.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "backgroundpanel.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// These are maintained in a list so the renderer can draw a 3D character
|
||||
// model on top of them.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CCSClassImagePanel : public vgui::ImagePanel
|
||||
{
|
||||
public:
|
||||
|
||||
typedef vgui::ImagePanel BaseClass;
|
||||
|
||||
CCSClassImagePanel( vgui::Panel *pParent, const char *pName );
|
||||
virtual ~CCSClassImagePanel();
|
||||
virtual void ApplySettings( KeyValues *inResourceData );
|
||||
virtual void Paint();
|
||||
|
||||
|
||||
public:
|
||||
char m_ModelName[128];
|
||||
};
|
||||
|
||||
extern CUtlVector<CCSClassImagePanel*> g_ClassImagePanels;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draws the Terrorist class menu
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CClassMenu_TER : public CClassMenu
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CClassMenu_TER, CClassMenu );
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
|
||||
public:
|
||||
CClassMenu_TER(IViewPort *pViewPort);
|
||||
virtual Panel* CreateControlByName(const char *controlName);
|
||||
const char *GetName( void );
|
||||
void ShowPanel(bool bShow);
|
||||
void Update();
|
||||
virtual void SetVisible(bool state);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draws the Counter-Terrorist class menu
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CClassMenu_CT : public CClassMenu
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CClassMenu_CT, CClassMenu );
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
|
||||
public:
|
||||
CClassMenu_CT(IViewPort *pViewPort);
|
||||
virtual Panel *CreateControlByName(const char *controlName);
|
||||
const char *GetName( void );
|
||||
void ShowPanel(bool bShow);
|
||||
void Update();
|
||||
virtual void SetVisible(bool state);
|
||||
};
|
||||
|
||||
#endif // CSCLASSMENU_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTRIKECLIENTSCOREBOARDDIALOG_H
|
||||
#define CSTRIKECLIENTSCOREBOARDDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <clientscoreboarddialog.h>
|
||||
#include <vgui_controls/ImagePanel.h>
|
||||
#include "cs_shareddefs.h"
|
||||
#include <vgui_controls/Frame.h>
|
||||
#include "vgui_avatarimage.h"
|
||||
|
||||
|
||||
const int cMaxScoreLines = 32; // This value must be > 2
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Game ScoreBoard
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSClientScoreBoardDialog : public CClientScoreBoardDialog
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSClientScoreBoardDialog, CClientScoreBoardDialog );
|
||||
|
||||
public:
|
||||
CCSClientScoreBoardDialog( IViewPort *pViewPort );
|
||||
~CCSClientScoreBoardDialog();
|
||||
|
||||
virtual void Update();
|
||||
|
||||
// vgui overrides for rounded corner background
|
||||
void UpdateMvpElements();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
virtual void ResetFromGameOverState();
|
||||
|
||||
// [tj] Hook in here to hide other UI
|
||||
virtual void ShowPanel( bool state );
|
||||
|
||||
// [tj] So we can do processing every frame
|
||||
virtual void OnThink();
|
||||
|
||||
protected:
|
||||
|
||||
struct PlayerScoreInfo
|
||||
{
|
||||
const char* szName;
|
||||
const char* szClanTag;
|
||||
int playerIndex;
|
||||
int frags;
|
||||
int deaths;
|
||||
int ping;
|
||||
const char* szStatus;
|
||||
bool bStatusPlayerColor;
|
||||
};
|
||||
|
||||
struct PlayerDisplay
|
||||
{
|
||||
vgui::Label* pNameLabel;
|
||||
vgui::Label* pClanLabel;
|
||||
vgui::Label* pScoreLabel;
|
||||
vgui::Label* pDeathsLabel;
|
||||
vgui::Label* pPingLabel;
|
||||
vgui::Label* pMVPCountLabel;
|
||||
CAvatarImagePanel* pAvatar;
|
||||
vgui::ImagePanel* pStatusImage;
|
||||
vgui::ImagePanel* pMVPImage;
|
||||
vgui::ImagePanel* pSelect;
|
||||
};
|
||||
|
||||
struct TeamDisplayInfo
|
||||
{
|
||||
Color playerDataColor;
|
||||
Color playerClanColor;
|
||||
PlayerDisplay playerDisplay[cMaxScoreLines];
|
||||
CUtlVector<PlayerScoreInfo*> playerScores; // For sorting team members outside of the listboxes
|
||||
int scoreAreaInnerHeight;
|
||||
int scoreAreaLineHeight;
|
||||
int scoreAreaLinePreferredLeading;
|
||||
int scoreAreaStartY;
|
||||
int scoreAreaMinX;
|
||||
int scoreAreaMaxX;
|
||||
int maxPlayersVisible;
|
||||
};
|
||||
|
||||
bool GetPlayerScoreInfo( int playerIndex, PlayerScoreInfo& playerScoreInfo );
|
||||
void UpdateTeamPlayerDisplay( TeamDisplayInfo& teamDisplay );
|
||||
void SetupTeamDisplay( TeamDisplayInfo& teamDisplay, const char* szTeamPrefix );
|
||||
|
||||
void UpdateTeamInfo();
|
||||
void UpdatePlayerList();
|
||||
|
||||
bool ForceLocalPlayerVisible( TeamDisplayInfo& teamDisplay );
|
||||
void UpdateSpectatorList();
|
||||
void UpdateHLTVList( void );
|
||||
void UpdateMatchEndText();
|
||||
|
||||
bool ShouldShowAsSpectator( int iPlayerIndex );
|
||||
void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void UpdatePlayerColors( void );
|
||||
void AdjustFontToFit( const char *pString, vgui::Label *pLabel );
|
||||
|
||||
static int PlayerSortFunction( PlayerScoreInfo* const* pPS1, PlayerScoreInfo* const* pPS2 );
|
||||
|
||||
private:
|
||||
vgui::HFont m_listItemFont;
|
||||
vgui::HFont m_listItemFontSmaller;
|
||||
vgui::HFont m_listItemFontSmallest;
|
||||
vgui::HFont m_MVPFont;
|
||||
|
||||
int m_iImageDead;
|
||||
int m_iImageMVP; // Not used in the section list explicitly. Drawn over it
|
||||
int m_iImageDominated;
|
||||
int m_iImageNemesis;
|
||||
int m_iImageBomb;
|
||||
int m_iImageVIP;
|
||||
int m_iImageFriend;
|
||||
int m_iImageNemesisDead;
|
||||
int m_iImageDominationDead;
|
||||
|
||||
Color m_DeadPlayerDataColor;
|
||||
Color m_PlayerDataBgColor;
|
||||
Color m_DeadPlayerClanColor;
|
||||
|
||||
vgui::Label* m_pWinConditionLabel;
|
||||
vgui::Label* m_pClockLabel;
|
||||
vgui::Label* m_pLabelMapName;
|
||||
vgui::Label* m_pServerLabel;
|
||||
|
||||
bool m_gameOver;
|
||||
|
||||
wchar_t m_pMapName[256];
|
||||
wchar_t m_pServerName[256];
|
||||
wchar_t m_pStatsEnabled[256];
|
||||
wchar_t m_pStatsDisabled[256];
|
||||
|
||||
int m_LocalPlayerItemID;
|
||||
int m_MVPXOffset;
|
||||
|
||||
TeamDisplayInfo m_teamDisplayT;
|
||||
TeamDisplayInfo m_teamDisplayCT;
|
||||
};
|
||||
|
||||
|
||||
#endif // CSTRIKECLIENTSCOREBOARDDIALOG_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,279 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSSPECTATORGUI_H
|
||||
#define CSSPECTATORGUI_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "spectatorgui.h"
|
||||
#include "mapoverview.h"
|
||||
#include "cs_shareddefs.h"
|
||||
|
||||
extern ConVar mp_playerid; // in cs_gamerules.h
|
||||
extern ConVar mp_forcecamera; // in gamevars_shared.h
|
||||
extern ConVar mp_fadetoblack;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Cstrike Spectator UI
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSSpectatorGUI : public CSpectatorGUI
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSSpectatorGUI, CSpectatorGUI );
|
||||
|
||||
public:
|
||||
CCSSpectatorGUI( IViewPort *pViewPort );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
virtual void UpdateSpectatorPlayerList( void );
|
||||
virtual void Update( void );
|
||||
virtual bool NeedsUpdate( void );
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [smessick]
|
||||
//=============================================================================
|
||||
virtual void ShowPanel( bool bShow );
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
protected:
|
||||
|
||||
void UpdateTimer();
|
||||
void UpdateAccount();
|
||||
|
||||
int m_nLastAccount;
|
||||
int m_nLastTime;
|
||||
int m_nLastSpecMode;
|
||||
CBaseEntity *m_nLastSpecTarget;
|
||||
|
||||
void StoreWidths( void );
|
||||
void ResizeControls( void );
|
||||
bool ControlsPresent( void ) const;
|
||||
|
||||
vgui::Label *m_pCTLabel;
|
||||
vgui::Label *m_pCTScore;
|
||||
vgui::Label *m_pTerLabel;
|
||||
vgui::Label *m_pTerScore;
|
||||
vgui::Label *m_pTimer;
|
||||
vgui::Label *m_pTimerLabel;
|
||||
vgui::Panel *m_pDivider;
|
||||
vgui::Label *m_pExtraInfo;
|
||||
|
||||
bool m_modifiedWidths;
|
||||
|
||||
int m_scoreWidth;
|
||||
int m_extraInfoWidth;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define DESIRED_RADAR_RESOLUTION 450
|
||||
|
||||
class CCSMapOverview : public CMapOverview
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCSMapOverview, CMapOverview );
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
MAP_ICON_T = 0,
|
||||
MAP_ICON_CT,
|
||||
MAP_ICON_HOSTAGE,
|
||||
MAP_ICON_COUNT
|
||||
};
|
||||
|
||||
CCSMapOverview( const char *pElementName );
|
||||
virtual ~CCSMapOverview();
|
||||
|
||||
virtual bool ShouldDraw( void );
|
||||
vgui::Panel *GetAsPanel(){ return this; }
|
||||
virtual bool AllowConCommandsWhileAlive(){return false;}
|
||||
virtual void SetPlayerPreferredMode( int mode );
|
||||
virtual void SetPlayerPreferredViewSize( float viewSize );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
|
||||
protected: // private structures & types
|
||||
|
||||
// list of game events the hLTV takes care of
|
||||
|
||||
typedef struct {
|
||||
int xpos;
|
||||
int ypos;
|
||||
} FootStep_t;
|
||||
|
||||
// Extra stuff in a this-level parallel array
|
||||
typedef struct CSMapPlayer_s {
|
||||
int overrideIcon; // if not -1, the icon to use instead
|
||||
int overrideIconOffscreen; // to use with overrideIcon
|
||||
float overrideFadeTime; // Time to start fading the override icon
|
||||
float overrideExpirationTime; // Time to not use the override icon any more
|
||||
Vector overridePosition; // Where the overridden icon will draw
|
||||
QAngle overrideAngle; // And at what angle
|
||||
bool isDead; // Death latch, since client can be behind the times on health messages.
|
||||
float timeLastSeen; // curtime that we last saw this guy.
|
||||
float timeFirstSeen; // curtime that we started seeing this guy
|
||||
bool isHostage; // Not a full player, a hostage. Special icon, different death event
|
||||
float flashUntilTime;
|
||||
float nextFlashPeakTime;
|
||||
int currentFlashAlpha;
|
||||
} CSMapPlayer_t;
|
||||
|
||||
typedef struct CSMapBomb_s
|
||||
{
|
||||
Vector position;
|
||||
|
||||
enum BombState
|
||||
{
|
||||
BOMB_PLANTED, //planted and ticking down
|
||||
BOMB_DROPPED, //dropped and lying loose
|
||||
BOMB_CARRIED, //in the arms of a player
|
||||
BOMB_GONE, //defused or exploded, but was planted
|
||||
BOMB_INVALID //no bomb
|
||||
};
|
||||
BombState state;
|
||||
|
||||
float timeLastSeen;
|
||||
float timeFirstSeen;
|
||||
float timeFade;
|
||||
float timeGone;
|
||||
|
||||
float currentRingRadius;
|
||||
float currentRingAlpha;
|
||||
float maxRingRadius;
|
||||
float ringTravelTime;
|
||||
} CSMapBomb_t;
|
||||
|
||||
typedef struct CSMapGoal_s
|
||||
{
|
||||
Vector position;
|
||||
int iconToUse;
|
||||
} CSMapGoal_t;
|
||||
|
||||
public: // IViewPortPanel interface:
|
||||
|
||||
virtual void Update();
|
||||
virtual void Init( void );
|
||||
|
||||
// both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
|
||||
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
|
||||
virtual bool IsVisible() { return BaseClass::IsVisible(); }
|
||||
virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
|
||||
|
||||
// IGameEventListener
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event);
|
||||
|
||||
// VGUI overrides
|
||||
|
||||
// Player settings:
|
||||
void SetPlayerSeen( int index );
|
||||
void SetBombSeen( bool seen );
|
||||
|
||||
// general settings:
|
||||
virtual void SetMap(const char * map);
|
||||
virtual void SetMode( int mode );
|
||||
|
||||
// Object settings
|
||||
virtual void FlashEntity( int entityID );
|
||||
|
||||
// rules that define if you can see a player on the overview or not
|
||||
virtual bool CanPlayerBeSeen(MapPlayer_t *player);
|
||||
|
||||
virtual int GetIconNumberFromTeamNumber( int teamNumber );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DrawCamera();
|
||||
virtual void DrawMapTexture();
|
||||
virtual void DrawMapPlayers();
|
||||
void DrawHostages();
|
||||
void DrawBomb();
|
||||
void DrawGoalIcons();
|
||||
virtual void ResetRound();
|
||||
virtual void InitTeamColorsAndIcons();
|
||||
virtual void UpdateSizeAndPosition();
|
||||
void UpdateGoalIcons();
|
||||
void ClearGoalIcons();
|
||||
virtual bool IsRadarLocked();
|
||||
Vector2D PanelToMap( const Vector2D &panelPos );
|
||||
|
||||
bool AdjustPointToPanel(Vector2D *pos);
|
||||
MapPlayer_t* GetPlayerByEntityID( int entityID );
|
||||
MapPlayer_t* GetHostageByEntityID( int entityID );
|
||||
virtual void UpdatePlayers();
|
||||
void UpdateHostages();///< Update hostages in the MapPlayer list
|
||||
void UpdateBomb();
|
||||
void UpdateFlashes();
|
||||
bool CreateRadarImage(const char *mapName, const char *radarFileName);
|
||||
virtual bool RunHudAnimations(){ return false; }
|
||||
|
||||
private:
|
||||
bool DrawIconCS( int textureID,
|
||||
int offscreenTextureID,
|
||||
Vector pos,
|
||||
float scale,
|
||||
float angle,
|
||||
int alpha,
|
||||
bool allowRotation = true,
|
||||
const char *text = NULL,
|
||||
Color *textColor = NULL,
|
||||
float status = -1,
|
||||
Color *statusColor = NULL
|
||||
);
|
||||
|
||||
int GetMasterAlpha( void );// The main alpha that the map part should be, determined by using the mode to look at the right convar
|
||||
int GetBorderSize( void );// How far in from the edge of the panel we draw, based on mode. Let's the background fancy corners show.
|
||||
CSMapPlayer_t* GetCSInfoForPlayerIndex( int index );
|
||||
CSMapPlayer_t* GetCSInfoForPlayer(MapPlayer_t *player);
|
||||
CSMapPlayer_t* GetCSInfoForHostage(MapPlayer_t *hostage);
|
||||
bool CanHostageBeSeen(MapPlayer_t *hostage);
|
||||
|
||||
CSMapPlayer_t m_PlayersCSInfo[MAX_PLAYERS];
|
||||
CSMapBomb_t m_bomb;
|
||||
MapPlayer_t m_Hostages[MAX_HOSTAGES];
|
||||
CSMapPlayer_t m_HostagesCSInfo[MAX_HOSTAGES];
|
||||
|
||||
CUtlVector< CSMapGoal_t > m_goalIcons;
|
||||
bool m_goalIconsLoaded;
|
||||
|
||||
int m_TeamIconsSelf[MAP_ICON_COUNT];
|
||||
int m_TeamIconsDead[MAP_ICON_COUNT];
|
||||
int m_TeamIconsOffscreen[MAP_ICON_COUNT];
|
||||
int m_TeamIconsDeadOffscreen[MAP_ICON_COUNT];
|
||||
|
||||
int m_bombIconPlanted;
|
||||
int m_bombIconDropped;
|
||||
int m_bombIconCarried;
|
||||
int m_bombRingPlanted;
|
||||
int m_bombRingDropped;
|
||||
int m_bombRingCarried;
|
||||
int m_bombRingCarriedOffscreen;
|
||||
int m_radioFlash;
|
||||
int m_radioFlashOffscreen;
|
||||
int m_radarTint;
|
||||
int m_hostageFollowing;
|
||||
int m_hostageFollowingOffscreen;
|
||||
int m_playerFacing;
|
||||
int m_cameraIconFirst;
|
||||
int m_cameraIconThird;
|
||||
int m_cameraIconFree;
|
||||
int m_hostageRescueIcon;
|
||||
int m_bombSiteIconA;
|
||||
int m_bombSiteIconB;
|
||||
|
||||
int m_nRadarMapTextureID; // texture id for radar version of current overview image
|
||||
|
||||
int m_playerPreferredMode; // The mode the player wants to be in for when we aren't being the radar
|
||||
};
|
||||
|
||||
#endif // CSSPECTATORGUI_H
|
||||
@@ -1,201 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cstriketeammenu.h"
|
||||
#include "backgroundpanel.h"
|
||||
#include <convar.h>
|
||||
#include "hud.h" // for gEngfuncs
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSTeamMenu::CCSTeamMenu(IViewPort *pViewPort) : CTeamMenu(pViewPort)
|
||||
{
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSTeamMenu::~CCSTeamMenu()
|
||||
{
|
||||
}
|
||||
|
||||
void CCSTeamMenu::ShowPanel(bool bShow)
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
engine->CheckPoint( "TeamMenu" );
|
||||
}
|
||||
|
||||
BaseClass::ShowPanel( bShow );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called to update the menu with new information
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::Update( void )
|
||||
{
|
||||
BaseClass::Update();
|
||||
|
||||
const ConVar *allowspecs = cvar->FindVar( "mp_allowspectators" );
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( !pPlayer || !CSGameRules() )
|
||||
return;
|
||||
|
||||
if ( allowspecs && allowspecs->GetBool() )
|
||||
{
|
||||
// if we're not already a CT or T...or the freeze time isn't over yet...or we're dead
|
||||
if ( pPlayer->GetTeamNumber() == TEAM_UNASSIGNED ||
|
||||
CSGameRules()->IsFreezePeriod() ||
|
||||
( pPlayer && pPlayer->IsPlayerDead() ) )
|
||||
{
|
||||
SetVisibleButton("specbutton", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisibleButton("specbutton", false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisibleButton("specbutton", false );
|
||||
}
|
||||
|
||||
m_bVIPMap = false;
|
||||
|
||||
char mapName[MAX_MAP_NAME];
|
||||
|
||||
Q_FileBase( engine->GetLevelName(), mapName, sizeof(mapName) );
|
||||
|
||||
if ( !Q_strncmp( mapName, "maps/as_", 8 ) )
|
||||
{
|
||||
m_bVIPMap = true;
|
||||
}
|
||||
|
||||
// if this isn't a VIP map or we're a spectator/terrorist, then disable the VIP button
|
||||
if ( !CSGameRules()->IsVIPMap() || ( pPlayer->GetTeamNumber() != TEAM_CT ) )
|
||||
{
|
||||
SetVisibleButton("vipbutton", false);
|
||||
}
|
||||
else // this must be a VIP map and we must already be a CT
|
||||
{
|
||||
SetVisibleButton("vipbutton", true);
|
||||
}
|
||||
|
||||
if( pPlayer->GetTeamNumber() == TEAM_UNASSIGNED ) // we aren't on a team yet
|
||||
{
|
||||
SetVisibleButton("CancelButton", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisibleButton("CancelButton", true);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::SetVisible(bool state)
|
||||
{
|
||||
BaseClass::SetVisible(state);
|
||||
|
||||
if ( state )
|
||||
{
|
||||
Button *pAutoButton = dynamic_cast< Button* >( FindChildByName( "autobutton" ) );
|
||||
if ( pAutoButton )
|
||||
{
|
||||
pAutoButton->RequestFocus();
|
||||
pAutoButton->SetArmed( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: When a team button is pressed it triggers this function to
|
||||
// cause the player to join a team
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::OnCommand( const char *command )
|
||||
{
|
||||
if ( Q_stricmp( command, "vguicancel" ) )
|
||||
{
|
||||
engine->ClientCmd( command );
|
||||
}
|
||||
|
||||
|
||||
BaseClass::OnCommand(command);
|
||||
|
||||
gViewPortInterface->ShowBackGround( false );
|
||||
OnClose();
|
||||
}
|
||||
|
||||
|
||||
void CCSTeamMenu::OnKeyCodePressed( vgui::KeyCode code )
|
||||
{
|
||||
if ( code == KEY_ENTER )
|
||||
{
|
||||
Button *pAutoButton = dynamic_cast< Button* >( FindChildByName( "autobutton" ) );
|
||||
if ( pAutoButton )
|
||||
{
|
||||
pAutoButton->DoClick();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed( code );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the visibility of a button by name
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::SetVisibleButton(const char *textEntryName, bool state)
|
||||
{
|
||||
Button *entry = dynamic_cast<Button *>(FindChildByName(textEntryName));
|
||||
if (entry)
|
||||
{
|
||||
entry->SetVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTeamMenu::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTEAMMENU_H
|
||||
#define CSTEAMMENU_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <teammenu.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays the team menu
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSTeamMenu : public CTeamMenu
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSTeamMenu, CTeamMenu );
|
||||
|
||||
public:
|
||||
CCSTeamMenu(IViewPort *pViewPort);
|
||||
~CCSTeamMenu();
|
||||
|
||||
void Update();
|
||||
void ShowPanel( bool bShow );
|
||||
virtual void SetVisible(bool state);
|
||||
|
||||
private:
|
||||
enum { NUM_TEAMS = 3 };
|
||||
|
||||
// VGUI2 override
|
||||
virtual void OnCommand( const char *command);
|
||||
virtual void OnKeyCodePressed( vgui::KeyCode code );
|
||||
// helper functions
|
||||
void SetVisibleButton(const char *textEntryName, bool state);
|
||||
|
||||
bool m_bVIPMap;
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
#endif // CSTEAMMENU_H
|
||||
@@ -1,146 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cstriketextwindow.h"
|
||||
#include "backgroundpanel.h"
|
||||
#include <cdll_client_int.h>
|
||||
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <filesystem.h>
|
||||
#include <KeyValues.h>
|
||||
#include <convar.h>
|
||||
#include <vgui_controls/ImageList.h>
|
||||
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui_controls/BuildGroup.h>
|
||||
|
||||
#include "IGameUIFuncs.h" // for key bindings
|
||||
#include <igameresources.h>
|
||||
extern IGameUIFuncs *gameuifuncs; // for key binding details
|
||||
|
||||
#include <game/client/iviewport.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSTextWindow::CCSTextWindow(IViewPort *pViewPort) : CTextWindow( pViewPort )
|
||||
{
|
||||
SetProportional( true );
|
||||
|
||||
m_iScoreBoardKey = BUTTON_CODE_INVALID; // this is looked up in Activate()
|
||||
|
||||
CreateBackground( this );
|
||||
m_backgroundLayoutFinished = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSTextWindow::~CCSTextWindow()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::Update()
|
||||
{
|
||||
BaseClass::Update();
|
||||
|
||||
m_pOK->RequestFocus();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::SetVisible(bool state)
|
||||
{
|
||||
BaseClass::SetVisible(state);
|
||||
|
||||
if ( state )
|
||||
{
|
||||
m_pOK->RequestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shows the text window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::ShowPanel(bool bShow)
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
// get key binding if shown
|
||||
if ( m_iScoreBoardKey == BUTTON_CODE_INVALID ) // you need to lookup the jump key AFTER the engine has loaded
|
||||
{
|
||||
m_iScoreBoardKey = gameuifuncs->GetButtonCodeForBind( "showscores" );
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::ShowPanel( bShow );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::OnKeyCodePressed( KeyCode code )
|
||||
{
|
||||
//We manually intercept the ENTER key so in case the button loses focus
|
||||
//ENTER still moves you through the MOTD screen.
|
||||
if ( code == KEY_ENTER || code == KEY_XBUTTON_A || code == KEY_XBUTTON_B )
|
||||
{
|
||||
m_pOK->DoClick();
|
||||
}
|
||||
else if ( m_iScoreBoardKey != BUTTON_CODE_INVALID && m_iScoreBoardKey == code )
|
||||
{
|
||||
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
|
||||
gViewPortInterface->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed( code );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The CS background is painted by image panels, so we should do nothing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::PaintBackground()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scale / center the window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// stretch the window to fullscreen
|
||||
if ( !m_backgroundLayoutFinished )
|
||||
LayoutBackgroundPanel( this );
|
||||
m_backgroundLayoutFinished = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSTextWindow::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
ApplyBackgroundSchemeSettings( this, pScheme );
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTEXTWINDOW_H
|
||||
#define CSTEXTWINDOW_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vguitextwindow.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: displays the MOTD
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CCSTextWindow : public CTextWindow
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSTextWindow, CTextWindow );
|
||||
|
||||
public:
|
||||
CCSTextWindow(IViewPort *pViewPort);
|
||||
virtual ~CCSTextWindow();
|
||||
|
||||
virtual void Update();
|
||||
virtual void SetVisible(bool state);
|
||||
virtual void ShowPanel( bool bShow );
|
||||
virtual void OnKeyCodePressed(vgui::KeyCode code);
|
||||
|
||||
protected:
|
||||
ButtonCode_t m_iScoreBoardKey;
|
||||
|
||||
// Background panel -------------------------------------------------------
|
||||
|
||||
public:
|
||||
virtual void PaintBackground();
|
||||
virtual void PerformLayout();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
bool m_backgroundLayoutFinished;
|
||||
|
||||
// End background panel ---------------------------------------------------
|
||||
};
|
||||
|
||||
|
||||
#endif // CSTEXTWINDOW_H
|
||||
@@ -1,257 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "lifetime_stats_page.h"
|
||||
#include <vgui_controls/SectionedListPanel.h>
|
||||
#include "cs_client_gamestats.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: creates child panels, passes down name to pick up any settings from res files.
|
||||
//-----------------------------------------------------------------------------
|
||||
CLifetimeStatsPage::CLifetimeStatsPage(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSLifetimeStatsDialog")
|
||||
{
|
||||
m_allStatsGroupPanel = AddGroup( L"all", "Stats_Button_All", L"All" );
|
||||
m_detailedWeaponStatsGroupPanel = AddGroup( L"weapon", "Stats_Button_Weapon", L"Weapon Stats" );
|
||||
m_specialSkillsStatsGroupPanel = AddGroup( L"skills", "Stats_Button_Skills", L"Special Skills" );
|
||||
m_mapAndMiscellanyStatsGroupPanel = AddGroup( L"map", "Stats_Button_Misc", L"Miscellaneous" );
|
||||
m_mapVictoryStatsGroupPanel = AddGroup( L"map", "Stats_Button_Victories", L"Map Victories" );
|
||||
m_missionAndObjectiveStatsGroupPanel = AddGroup( L"mission", "Stats_Button_Mission", L"Mission && Objectives" );
|
||||
|
||||
m_allStatsGroupPanel->SetGroupActive(true);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads settings from statsdialog.res in hl2/resource/ui/
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLifetimeStatsPage::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
LoadControlSettings("resource/ui/CSLifetimeStatsDialog.res");
|
||||
|
||||
m_statsList->AddColumnToSection( 0, "name", "", SectionedListPanel::COLUMN_CENTER, 280);
|
||||
m_statsList->AddColumnToSection( 0, "playerValue", "", SectionedListPanel::COLUMN_CENTER, 250);
|
||||
}
|
||||
|
||||
void CLifetimeStatsPage::RepopulateStats()
|
||||
{
|
||||
m_statsList->RemoveAll();
|
||||
|
||||
const StatsCollection_t& personalLifetimeStats = g_CSClientGameStats.GetLifetimeStats();
|
||||
|
||||
if (m_missionAndObjectiveStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_ROUNDS_WON, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_DEATHS, personalLifetimeStats);
|
||||
AddKillToDeathStat(personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_DAMAGE, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BOMBS_PLANTED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BOMBS_DEFUSED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_NUM_HOSTAGES_RESCUED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_PISTOLROUNDS_WON, personalLifetimeStats);
|
||||
}
|
||||
|
||||
if (m_specialSkillsStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_MVPS, personalLifetimeStats);
|
||||
AddFavoriteWeaponStat(personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_SHOTS_FIRED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_SHOTS_HIT, personalLifetimeStats);
|
||||
AddAccuracyStat(personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_DOMINATIONS, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_DOMINATION_OVERKILLS, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_REVENGES, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_HEADSHOT, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_AGAINST_ZOOMED_SNIPER, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_ENEMY_BLINDED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_ENEMY_WEAPON, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_KNIFE_FIGHT, personalLifetimeStats);
|
||||
}
|
||||
|
||||
if (m_mapAndMiscellanyStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_MONEY_EARNED, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_DECAL_SPRAYS, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_NIGHTVISION_DAMAGE, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BROKEN_WINDOWS, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_WEAPONS_DONATED, personalLifetimeStats);
|
||||
}
|
||||
|
||||
if (m_mapVictoryStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_ASSAULT, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_COMPOUND, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_HAVANA, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_ITALY, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_MILITIA, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_CS_OFFICE, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_AZTEC, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_CBBLE, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_CHATEAU, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_DUST2, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_DUST, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_INFERNO, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_NUKE, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_PIRANESI, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_PORT, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_PRODIGY, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_TIDES, personalLifetimeStats);
|
||||
AddSimpleStat(CSSTAT_MAP_WINS_DE_TRAIN, personalLifetimeStats);
|
||||
}
|
||||
|
||||
|
||||
if (m_detailedWeaponStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
CSStatType_t hitsStat = CSSTAT_HITS_DEAGLE;
|
||||
CSStatType_t shotsStat = CSSTAT_SHOTS_DEAGLE;
|
||||
for (CSStatType_t killStat = CSSTAT_KILLS_DEAGLE ; killStat <= CSSTAT_KILLS_HEGRENADE ; killStat = (CSStatType_t)(killStat + 1))
|
||||
{
|
||||
if (shotsStat <= CSSTAT_SHOTS_M249)
|
||||
{
|
||||
AddSimpleStat(shotsStat, personalLifetimeStats);
|
||||
}
|
||||
if (hitsStat <= CSSTAT_HITS_M249)
|
||||
{
|
||||
AddSimpleStat(hitsStat, personalLifetimeStats);
|
||||
}
|
||||
AddSimpleStat(killStat, personalLifetimeStats);
|
||||
|
||||
hitsStat = (CSStatType_t)(hitsStat + 1);
|
||||
shotsStat = (CSStatType_t)(shotsStat + 1);
|
||||
}
|
||||
}
|
||||
|
||||
int itemCount = m_statsList->GetItemCount();
|
||||
for (int i = 0; i < itemCount ; ++i)
|
||||
{
|
||||
m_statsList->SetItemBgColor(i, Color(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
int CLifetimeStatsPage::AddSimpleStat( int desiredStat, const StatsCollection_t& personalLifetimeStats)
|
||||
{
|
||||
PlayerStatData_t stat = g_CSClientGameStats.GetStatById(desiredStat);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", stat.pStatDisplayName );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
char buf[64];
|
||||
Q_snprintf( buf, sizeof( buf ), "%d", personalLifetimeStats[stat.iStatId] );
|
||||
pKeyValues->SetString( "playerValue", (personalLifetimeStats[stat.iStatId])?buf:"" );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
int CLifetimeStatsPage::AddFavoriteWeaponStat(const StatsCollection_t& personalLifetimeStats)
|
||||
{
|
||||
PlayerStatData_t statPlayerBestWeapon;
|
||||
statPlayerBestWeapon.iStatId = CSSTAT_UNDEFINED;
|
||||
|
||||
int previousBestKills = 0;
|
||||
|
||||
for (CSStatType_t statId = CSSTAT_KILLS_DEAGLE ; statId <= CSSTAT_KILLS_M249; statId = (CSStatType_t)(statId + 1))
|
||||
{
|
||||
PlayerStatData_t stat = g_CSClientGameStats.GetStatById( statId );
|
||||
|
||||
//Compare this to previous Weapons
|
||||
int playerKillsWithWeapon = personalLifetimeStats[statId];
|
||||
{
|
||||
if (playerKillsWithWeapon > previousBestKills)
|
||||
{
|
||||
statPlayerBestWeapon = stat;
|
||||
previousBestKills = playerKillsWithWeapon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", LocalizeTagOrUseDefault( "Stats_FavoriteWeapon", L"Favorite Weapon" ) );
|
||||
|
||||
pKeyValues->SetWString( "playerValue", TranslateWeaponKillIDToAlias(statPlayerBestWeapon.iStatId) );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
int CLifetimeStatsPage::AddKillToDeathStat(const StatsCollection_t& personalLifetimeStats)
|
||||
{
|
||||
PlayerStatData_t statKills = g_CSClientGameStats.GetStatById(CSSTAT_KILLS);
|
||||
PlayerStatData_t statDeaths = g_CSClientGameStats.GetStatById(CSSTAT_DEATHS);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", LocalizeTagOrUseDefault( "Stats_KillToDeathRatio", L"Kill to Death Ratio" ) );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
float playerKills = personalLifetimeStats[statKills.iStatId];
|
||||
float playerDeaths = personalLifetimeStats[statDeaths.iStatId];
|
||||
float playerKillToDeathRatio = 1.0f;
|
||||
|
||||
if (playerDeaths > 0)
|
||||
{
|
||||
playerKillToDeathRatio = playerKills / playerDeaths;
|
||||
}
|
||||
|
||||
char buf[64];
|
||||
Q_snprintf( buf, sizeof( buf ), "%.2f", playerKillToDeathRatio );
|
||||
pKeyValues->SetString( "playerValue", (playerKillToDeathRatio)?buf:"" );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
int CLifetimeStatsPage::AddAccuracyStat(const StatsCollection_t& personalLifetimeStats)
|
||||
{
|
||||
PlayerStatData_t statHits = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_HIT);
|
||||
PlayerStatData_t statShots = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_FIRED);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", LocalizeTagOrUseDefault( "Stats_Accuracy", L"Accuracy" ) );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
float playerHits = personalLifetimeStats[statHits.iStatId];
|
||||
float playerShots = personalLifetimeStats[statShots.iStatId];
|
||||
float playerAccuracy = 0.0;
|
||||
|
||||
if (playerShots > 0)
|
||||
{
|
||||
playerAccuracy = 100.0f * playerHits / playerShots;
|
||||
}
|
||||
|
||||
char buf[64];
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f%%", playerAccuracy );
|
||||
pKeyValues->SetString( "playerValue", (playerAccuracy)?buf:"" );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSLifetimeSTATSPAGE_H
|
||||
#define CSLifetimeSTATSPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "base_stats_page.h"
|
||||
|
||||
class CLifetimeStatsPage : public CBaseStatsPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE ( CLifetimeStatsPage, CBaseStatsPage );
|
||||
|
||||
public:
|
||||
CLifetimeStatsPage( vgui::Panel *parent, const char *name );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
void RepopulateStats();
|
||||
int AddSimpleStat( int desiredStat, const StatsCollection_t& personalLifetimeStats);
|
||||
int AddAccuracyStat(const StatsCollection_t& personalLifetimeStats);
|
||||
int AddFavoriteWeaponStat(const StatsCollection_t& personalLifetimeStats);
|
||||
int AddKillToDeathStat(const StatsCollection_t& personalLifetimeStats);
|
||||
|
||||
CBaseStatGroupPanel* m_allStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_detailedWeaponStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_specialSkillsStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_mapAndMiscellanyStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_mapVictoryStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_missionAndObjectiveStatsGroupPanel;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CSLifetimeSTATSPAGE_H
|
||||
@@ -1,334 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "match_stats_page.h"
|
||||
#include <vgui_controls/SectionedListPanel.h>
|
||||
#include "c_team.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: creates child panels, passes down name to pick up any settings from res files.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMatchStatsPage::CMatchStatsPage(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSMatchStatsDialog")
|
||||
{
|
||||
m_allStatsGroupPanel = AddGroup( L"all", "Stats_Button_All", L"All" );
|
||||
m_detailedWeaponStatsGroupPanel = AddGroup( L"weapon", "Stats_Button_Weapon", L"Weapon Stats" );
|
||||
m_specialSkillsStatsGroupPanel = AddGroup( L"skills", "Stats_Button_Skills", L"Special Skills" );
|
||||
m_mapAndMiscellanyStatsGroupPanel = AddGroup( L"map", "Stats_Button_Misc", L"Miscellaneous" );
|
||||
m_missionAndObjectiveStatsGroupPanel = AddGroup( L"mission", "Stats_Button_Mission", L"Mission && Objectives" );
|
||||
|
||||
m_allStatsGroupPanel->SetGroupActive(true);
|
||||
|
||||
m_ResetNotice = new Label( this, "ResetNotice", "");
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads settings from statsdialog.res in hl2/resource/ui/
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMatchStatsPage::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
LoadControlSettings("resource/ui/CSMatchStatsDialog.res");
|
||||
m_statsList->AddColumnToSection( 0, "name", "", SectionedListPanel::COLUMN_CENTER, 180);
|
||||
m_statsList->AddColumnToSection( 0, "playerValue", "", SectionedListPanel::COLUMN_CENTER, 100);
|
||||
m_statsList->AddColumnToSection( 0, "ctValue", "", SectionedListPanel::COLUMN_CENTER, 100);
|
||||
m_statsList->AddColumnToSection( 0, "tValue", " ", SectionedListPanel::COLUMN_CENTER, 100);
|
||||
m_statsList->AddColumnToSection( 0, "serverValue", "", SectionedListPanel::COLUMN_CENTER, 100);
|
||||
}
|
||||
|
||||
void CMatchStatsPage::RepopulateStats()
|
||||
{
|
||||
m_statsList->RemoveAll();
|
||||
|
||||
RoundStatsDirectAverage_t* tStats = g_CSClientGameStats.GetDirectTStatsAverages();
|
||||
RoundStatsDirectAverage_t* ctStats = g_CSClientGameStats.GetDirectCTStatsAverages();
|
||||
RoundStatsDirectAverage_t* serverStats = g_CSClientGameStats.GetDirectPlayerStatsAverages();
|
||||
const StatsCollection_t& personalMatchStats = g_CSClientGameStats.GetMatchStats();
|
||||
|
||||
if (m_missionAndObjectiveStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_ROUNDS_WON, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_DEATHS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddKillToDeathStat(personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_DAMAGE, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BOMBS_PLANTED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BOMBS_DEFUSED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_NUM_HOSTAGES_RESCUED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_PISTOLROUNDS_WON, personalMatchStats, tStats, ctStats, serverStats);
|
||||
}
|
||||
|
||||
if (m_specialSkillsStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_MVPS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_SHOTS_FIRED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_SHOTS_HIT, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddAccuracyStat(personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_DOMINATIONS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_DOMINATION_OVERKILLS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_REVENGES, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_HEADSHOT, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_AGAINST_ZOOMED_SNIPER, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_ENEMY_BLINDED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_ENEMY_WEAPON, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_KILLS_KNIFE_FIGHT, personalMatchStats, tStats, ctStats, serverStats);
|
||||
}
|
||||
|
||||
if (m_mapAndMiscellanyStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
AddSimpleStat(CSSTAT_MONEY_EARNED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_DECAL_SPRAYS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_NIGHTVISION_DAMAGE, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_NUM_BROKEN_WINDOWS, personalMatchStats, tStats, ctStats, serverStats);
|
||||
AddSimpleStat(CSSTAT_WEAPONS_DONATED, personalMatchStats, tStats, ctStats, serverStats);
|
||||
}
|
||||
|
||||
if (m_detailedWeaponStatsGroupPanel->IsGroupActive() || m_allStatsGroupPanel->IsGroupActive())
|
||||
{
|
||||
CSStatType_t hitsStat = CSSTAT_HITS_DEAGLE;
|
||||
CSStatType_t shotsStat = CSSTAT_SHOTS_DEAGLE;
|
||||
for (CSStatType_t killStat = CSSTAT_KILLS_DEAGLE ; killStat <= CSSTAT_KILLS_HEGRENADE ; killStat = (CSStatType_t)(killStat + 1))
|
||||
{
|
||||
if (shotsStat <= CSSTAT_SHOTS_M249)
|
||||
{
|
||||
AddSimpleStat(shotsStat, personalMatchStats, tStats, ctStats, serverStats);
|
||||
}
|
||||
|
||||
if (hitsStat <= CSSTAT_HITS_M249)
|
||||
{
|
||||
AddSimpleStat(hitsStat, personalMatchStats, tStats, ctStats, serverStats);
|
||||
}
|
||||
AddSimpleStat(killStat, personalMatchStats, tStats, ctStats, serverStats);
|
||||
|
||||
hitsStat = (CSStatType_t)(hitsStat + 1);
|
||||
shotsStat = (CSStatType_t)(shotsStat + 1);
|
||||
}
|
||||
}
|
||||
|
||||
int itemCount = m_statsList->GetItemCount();
|
||||
for (int i = 0; i < itemCount ; ++i)
|
||||
{
|
||||
m_statsList->SetItemBgColor(i, Color(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
int CMatchStatsPage::AddSimpleStat( int desiredStat, const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats )
|
||||
{
|
||||
PlayerStatData_t stat = g_CSClientGameStats.GetStatById(desiredStat);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", stat.pStatDisplayName );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
char buf[64];
|
||||
Q_snprintf( buf, sizeof( buf ), "%d", personalMatchStats[stat.iStatId] );
|
||||
pKeyValues->SetString( "playerValue", (personalMatchStats[stat.iStatId])?buf:"" );
|
||||
|
||||
if (desiredStat == CSSTAT_ROUNDS_WON)
|
||||
{
|
||||
C_Team *ts = GetGlobalTeam(TEAM_TERRORIST);
|
||||
if (ts)
|
||||
{
|
||||
Q_snprintf( buf, sizeof( buf ), "%d", ts->Get_Score() );
|
||||
pKeyValues->SetString( "tValue", buf );
|
||||
}
|
||||
|
||||
C_Team *cts = GetGlobalTeam(TEAM_CT);
|
||||
if (cts){
|
||||
Q_snprintf( buf, sizeof( buf ), "%d", cts->Get_Score());
|
||||
pKeyValues->SetString( "ctValue", buf );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f", tStats->m_fStat[stat.iStatId] );
|
||||
pKeyValues->SetString( "tValue", (tStats->m_fStat[stat.iStatId]||personalMatchStats[stat.iStatId])?buf:"" );
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f", ctStats->m_fStat[stat.iStatId] );
|
||||
pKeyValues->SetString( "ctValue", (ctStats->m_fStat[stat.iStatId]||personalMatchStats[stat.iStatId])?buf:"" );
|
||||
}
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f", serverStats->m_fStat[stat.iStatId] );
|
||||
pKeyValues->SetString( "serverValue", (serverStats->m_fStat[stat.iStatId]||personalMatchStats[stat.iStatId])?buf:"" );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
int CMatchStatsPage::AddKillToDeathStat(const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats )
|
||||
{
|
||||
PlayerStatData_t statKills = g_CSClientGameStats.GetStatById(CSSTAT_KILLS);
|
||||
PlayerStatData_t statDeaths = g_CSClientGameStats.GetStatById(CSSTAT_DEATHS);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
|
||||
pKeyValues->SetWString( "name", LocalizeTagOrUseDefault( "Stats_KillToDeathRatio", L"Kill to Death Ratio" ) );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
float playerKills = personalMatchStats[statKills.iStatId];
|
||||
float tKills = tStats->m_fStat[statKills.iStatId];
|
||||
float ctKills = ctStats->m_fStat[statKills.iStatId];
|
||||
float serverKills = serverStats->m_fStat[statKills.iStatId];
|
||||
|
||||
float playerDeaths = personalMatchStats[statDeaths.iStatId];
|
||||
float tDeaths = tStats->m_fStat[statDeaths.iStatId];
|
||||
float ctDeaths = ctStats->m_fStat[statDeaths.iStatId];
|
||||
float serverDeaths = serverStats->m_fStat[statDeaths.iStatId];
|
||||
|
||||
char buf[64];
|
||||
|
||||
if (playerDeaths > 0)
|
||||
{
|
||||
float playerKillToDeathRatio = playerKills / playerDeaths;
|
||||
Q_snprintf( buf, sizeof( buf ), "%.2f", playerKillToDeathRatio );
|
||||
pKeyValues->SetString( "playerValue", (playerKillToDeathRatio)?buf:"" );
|
||||
}
|
||||
else
|
||||
{
|
||||
pKeyValues->SetString( "playerValue", "" );
|
||||
}
|
||||
|
||||
|
||||
if (tDeaths > 0)
|
||||
{
|
||||
float tKillToDeathRatio = tKills / tDeaths;
|
||||
Q_snprintf( buf, sizeof( buf ), "%.2f", tKillToDeathRatio );
|
||||
pKeyValues->SetString( "tValue", ((playerKills&&playerDeaths)||tKillToDeathRatio)?buf:"" );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pKeyValues->SetString( "tValue", "" );
|
||||
}
|
||||
|
||||
if (ctDeaths > 0)
|
||||
{
|
||||
float ctKillToDeathRatio = ctKills / ctDeaths;
|
||||
Q_snprintf( buf, sizeof( buf ), "%.2f", ctKillToDeathRatio);
|
||||
pKeyValues->SetString( "ctValue", ((playerKills&&playerDeaths)||ctKillToDeathRatio)?buf:"" );
|
||||
}
|
||||
else
|
||||
{
|
||||
pKeyValues->SetString( "ctValue", "" );
|
||||
}
|
||||
|
||||
if (serverDeaths > 0)
|
||||
{
|
||||
float serverKillToDeathRatio = serverKills / serverDeaths;
|
||||
Q_snprintf( buf, sizeof( buf ), "%.2f", serverKillToDeathRatio );
|
||||
pKeyValues->SetString( "serverValue", ((playerKills&&playerDeaths)||serverKillToDeathRatio)?buf:"" );
|
||||
}
|
||||
else
|
||||
{
|
||||
pKeyValues->SetString( "serverValue", "" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CMatchStatsPage::AddAccuracyStat(const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats )
|
||||
{
|
||||
PlayerStatData_t statHits = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_HIT);
|
||||
PlayerStatData_t statShots = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_FIRED);
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
pKeyValues->SetWString( "name", LocalizeTagOrUseDefault( "Stats_Accuracy", L"Accuracy" ) );
|
||||
pKeyValues->SetFloat( "playerValue", 0 );
|
||||
|
||||
float playerHits = personalMatchStats[statHits.iStatId];
|
||||
float tHits = tStats->m_fStat[statHits.iStatId];
|
||||
float ctHits = ctStats->m_fStat[statHits.iStatId];
|
||||
float serverHits = serverStats->m_fStat[statHits.iStatId];
|
||||
|
||||
float playerShots = personalMatchStats[statShots.iStatId];
|
||||
float tShots = tStats->m_fStat[statShots.iStatId];
|
||||
float ctShots = ctStats->m_fStat[statShots.iStatId];
|
||||
float serverShots = serverStats->m_fStat[statShots.iStatId];
|
||||
|
||||
float playerAccuracy = 0.0;
|
||||
float tAccuracy = 0.0;
|
||||
float ctAccuracy = 0.0;
|
||||
float serverAccuracy = 0.0;
|
||||
|
||||
if (playerShots > 0)
|
||||
{
|
||||
playerAccuracy = 100.0f * playerHits / playerShots;
|
||||
}
|
||||
|
||||
if (tShots > 0)
|
||||
{
|
||||
tAccuracy = 100.0f * tHits / tShots;
|
||||
}
|
||||
|
||||
if (ctShots > 0)
|
||||
{
|
||||
ctAccuracy = 100.0f * ctHits / ctShots;
|
||||
}
|
||||
|
||||
if (serverShots > 0)
|
||||
{
|
||||
serverAccuracy = 100.0f * serverHits / serverShots;
|
||||
}
|
||||
|
||||
char buf[64];
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f%%", playerAccuracy );
|
||||
pKeyValues->SetString( "playerValue", (playerAccuracy)?buf:"" );
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f%%", tAccuracy);
|
||||
pKeyValues->SetString( "tValue", (playerAccuracy||tAccuracy)?buf:"" );
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f%%", ctAccuracy );
|
||||
pKeyValues->SetString( "ctValue", (playerAccuracy||ctAccuracy)?buf:"" );
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%.1f%%", serverAccuracy );
|
||||
pKeyValues->SetString( "serverValue", (playerAccuracy||serverAccuracy)?buf:"" );
|
||||
|
||||
int newItem = m_statsList->AddItem(0, pKeyValues);
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
m_statsList->SetItemFont(newItem , m_listItemFont);
|
||||
m_statsList->SetItemFgColor(newItem, Color(197,197,197,255));
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
void CMatchStatsPage::OnSizeChanged(int newWide, int newTall)
|
||||
{
|
||||
BaseClass::OnSizeChanged(newWide, newTall);
|
||||
|
||||
if (m_statsList)
|
||||
{
|
||||
if (m_ResetNotice)
|
||||
{
|
||||
int labelX, labelY, listX, listY, listWide, listTall;
|
||||
m_statsList->GetBounds(listX, listY, listWide, listTall);
|
||||
|
||||
m_ResetNotice->GetPos(labelX, labelY);
|
||||
m_ResetNotice->SetPos(labelX, listY + listTall + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSMATCHSTATSPAGE_H
|
||||
#define CSMATCHSTATSPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "base_stats_page.h"
|
||||
|
||||
class CMatchStatsPage : public CBaseStatsPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE ( CMatchStatsPage, CBaseStatsPage );
|
||||
|
||||
public:
|
||||
CMatchStatsPage( vgui::Panel *parent, const char *name );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
void RepopulateStats();
|
||||
int AddSimpleStat( int desiredStat, const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats );
|
||||
int AddAccuracyStat(const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats );
|
||||
int AddKillToDeathStat(const StatsCollection_t& personalMatchStats, RoundStatsDirectAverage_t* tStats, RoundStatsDirectAverage_t* ctStats, RoundStatsDirectAverage_t* serverStats );
|
||||
virtual void OnSizeChanged(int wide, int tall);
|
||||
|
||||
CBaseStatGroupPanel* m_allStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_detailedWeaponStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_specialSkillsStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_mapAndMiscellanyStatsGroupPanel;
|
||||
CBaseStatGroupPanel* m_missionAndObjectiveStatsGroupPanel;
|
||||
|
||||
vgui::Label* m_ResetNotice;
|
||||
};
|
||||
|
||||
#endif // CSMATCHSTATSPAGE_H
|
||||
@@ -1,106 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Create and display a win panel at the end of a round displaying interesting stats and info about the round.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "stat_card.h"
|
||||
#include "vgui_controls/AnimationController.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_playerresource.h"
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "fmtstr.h"
|
||||
#include "../../public/steam/steam_api.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
StatCard::StatCard(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSStatCard")
|
||||
{
|
||||
//m_pAvatarDefault = new ImagePanel(this, "");
|
||||
//m_pBackgroundArt = new ImagePanel(this, "BackgroundArt");
|
||||
m_pAvatar = new CAvatarImagePanel(this, "Avatar");
|
||||
m_pAvatar->SetShouldScaleImage(true);
|
||||
m_pAvatar->SetShouldDrawFriendIcon(false);
|
||||
m_pAvatar->SetSize(64,64);
|
||||
|
||||
m_pName= new Label(this, "Name", "Name");
|
||||
m_pKillToDeathRatio = new Label(this, "KillToDeath", "KillToDeath");
|
||||
m_pStars = new Label(this, "Stars", "Stars");
|
||||
}
|
||||
|
||||
StatCard::~StatCard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void StatCard::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
LoadControlSettings("Resource/UI/CSStatCard.res");
|
||||
|
||||
//m_pBackgroundArt->SetShouldScaleImage(true);
|
||||
//m_pBackgroundArt->SetImage("../VGUI/achievements/achievement-btn-up");
|
||||
|
||||
SetBgColor(Color(0,0,0,0));
|
||||
|
||||
UpdateInfo();
|
||||
}
|
||||
|
||||
void StatCard::UpdateInfo()
|
||||
{
|
||||
const StatsCollection_t& personalLifetimeStats = g_CSClientGameStats.GetLifetimeStats();
|
||||
|
||||
int stars = personalLifetimeStats[CSSTAT_MVPS];
|
||||
float kills = personalLifetimeStats[CSSTAT_KILLS];
|
||||
float deaths = personalLifetimeStats[CSSTAT_DEATHS];
|
||||
wchar_t buf[64], numBuf[64];
|
||||
|
||||
if (deaths > 0)
|
||||
{
|
||||
float killToDeath = kills / deaths;
|
||||
|
||||
_snwprintf( numBuf, ARRAYSIZE( numBuf ), L"%.2f", killToDeath);
|
||||
g_pVGuiLocalize->ConstructString( buf, sizeof(buf),
|
||||
g_pVGuiLocalize->Find( "#GameUI_Stats_LastMatch_KDRatio" ), 1, numBuf );
|
||||
m_pKillToDeathRatio->SetText( buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pKillToDeathRatio->SetText("");
|
||||
}
|
||||
|
||||
_snwprintf( numBuf, ARRAYSIZE( numBuf ), L"%i", stars);
|
||||
g_pVGuiLocalize->ConstructString( buf, sizeof(buf),
|
||||
g_pVGuiLocalize->Find( "#GameUI_Stats_LastMatch_MVPS" ), 1, numBuf );
|
||||
m_pStars->SetText( buf );
|
||||
|
||||
if (steamapicontext)
|
||||
{
|
||||
ISteamFriends* friends = steamapicontext->SteamFriends();
|
||||
if (friends)
|
||||
{
|
||||
m_pName->SetText(friends->GetPersonaName());
|
||||
}
|
||||
}
|
||||
|
||||
// Display the player avatar
|
||||
if (m_pAvatar && steamapicontext && steamapicontext->SteamUser())
|
||||
{
|
||||
m_pAvatar->SetPlayer( steamapicontext->SteamUser()->GetSteamID(), k_EAvatarSize64x64 );
|
||||
m_pAvatar->SetVisible( true );
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef STATCARD_H
|
||||
#define STATCARD_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui/IScheme.h>
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "vgui_avatarimage.h"
|
||||
#include "cs_shareddefs.h"
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class StatCard : public EditablePanel
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( StatCard, EditablePanel );
|
||||
|
||||
public:
|
||||
StatCard(vgui::Panel *parent, const char *name);
|
||||
~StatCard();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
void UpdateInfo();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
ImagePanel* m_pAvatarDefault;
|
||||
//ImagePanel* m_pBackgroundArt;
|
||||
CAvatarImagePanel* m_pAvatar;
|
||||
|
||||
Label* m_pName;
|
||||
Label* m_pKillToDeathRatio;
|
||||
Label* m_pStars;
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif //STATCARD_H
|
||||
@@ -1,684 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Display a list of achievements for the current game
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "stats_summary.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "ixboxsystem.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "vgui_controls/ComboBox.h"
|
||||
#include "vgui_controls/CheckButton.h"
|
||||
#include "vgui_controls/ImageList.h"
|
||||
#include "fmtstr.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
|
||||
#include "../../../public/steam/steam_api.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "../../../../public/vgui/IScheme.h"
|
||||
#include "../vgui_controls/ScrollBar.h"
|
||||
#include "stat_card.h"
|
||||
|
||||
#include "weapon_csbase.h"
|
||||
#include "cs_weapon_parse.h"
|
||||
#include "buy_presets/buy_presets.h"
|
||||
#include "win_panel_round.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
#include "achievements_cs.h"
|
||||
#include "ienginevgui.h"
|
||||
|
||||
|
||||
#define STAT_NUM_ARRAY_LENGTH 8
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
#include <locale.h>
|
||||
|
||||
extern CAchievementMgr g_AchievementMgrCS;
|
||||
|
||||
const int maxRecentAchievementToDisplay = 10;
|
||||
|
||||
/**
|
||||
* public ConvertNumberToMantissaSuffixForm()
|
||||
*
|
||||
* Convert a floating point number to a string form incorporating a mantissa and a magnitude suffix (such as "K" for thousands).
|
||||
*
|
||||
* Parameters:
|
||||
* fNum -
|
||||
* textBuffer - output buffer
|
||||
* textBufferLen - size of output buffer in characters
|
||||
* bTrimTrailingZeros - indicates whether to remove trailing zeros of numbers without suffixes (e.g., "32.00000" becomes "32")
|
||||
* iSignificantDigits - the desired number of significant digits in the result (e.g, "1.23" has 3 significant digits)
|
||||
*
|
||||
* Returns:
|
||||
* bool - true on success
|
||||
*/
|
||||
bool ConvertNumberToMantissaSuffixForm(float fNum, wchar_t* textBuffer, int textBufferLen, bool bTrimTrailingZeros = true, int iSignificantDigits = 3)
|
||||
{
|
||||
// we need room for at least iSignificantDigits + 3 characters
|
||||
Assert(textBufferLen >= iSignificantDigits + 3);
|
||||
|
||||
// find the correct power of 1000 exponent
|
||||
Assert(fNum >= 0.0f);
|
||||
int iExponent = 0;
|
||||
while (fNum >= powf(10.0f, iExponent + 3))
|
||||
{
|
||||
iExponent += 3;
|
||||
}
|
||||
|
||||
// look in the localization table for the matching suffix; fallback to lower suffixes when necessary
|
||||
wchar_t *pSuffix = NULL;
|
||||
for (; iExponent > 0; iExponent -= 3)
|
||||
{
|
||||
char localizationToken[64];
|
||||
V_snprintf(localizationToken, sizeof(localizationToken), "#GameUI_NumSuffix_E%i", iExponent);
|
||||
pSuffix = g_pVGuiLocalize->Find(localizationToken);
|
||||
if (pSuffix != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
V_snwprintf(textBuffer, textBufferLen, L"%f", fNum / powf(10.0f, iExponent));
|
||||
textBuffer[textBufferLen - 1] = L'\0';
|
||||
|
||||
lconv* pLocaleSettings = localeconv();
|
||||
wchar_t decimalWChar = *pLocaleSettings->decimal_point;
|
||||
wchar_t* pDecimalPos = wcschr(textBuffer, decimalWChar);
|
||||
if (pDecimalPos == NULL)
|
||||
{
|
||||
Msg("ConvertNumberToMantissaSuffixForm(): decimal point not found in string %S for value %f\n", textBuffer, fNum);
|
||||
return false;
|
||||
}
|
||||
|
||||
// trim trailing zeros
|
||||
int iNumCharsInBuffer = wcslen(textBuffer);
|
||||
if (pSuffix == NULL && bTrimTrailingZeros)
|
||||
{
|
||||
wchar_t* pLastChar;
|
||||
for (pLastChar = &textBuffer[iNumCharsInBuffer - 1]; pLastChar > pDecimalPos; --pLastChar)
|
||||
{
|
||||
if (*pLastChar != L'0') // note that this is checking for '0', not a NULL terminator
|
||||
break;
|
||||
|
||||
*pLastChar = L'\0';
|
||||
}
|
||||
if (pLastChar == pDecimalPos)
|
||||
*pLastChar = L'\0';
|
||||
}
|
||||
|
||||
// truncate the mantissa to the right of the decimal point so that it doesn't exceed the significant digits
|
||||
if (pDecimalPos != NULL && iNumCharsInBuffer > iSignificantDigits + 1)
|
||||
{
|
||||
if (pDecimalPos - &textBuffer[0] < iSignificantDigits)
|
||||
textBuffer[iSignificantDigits + 1] = L'\0'; // truncate at the correct number of significant digits
|
||||
else
|
||||
*pDecimalPos = L'\0'; // no room for any digits to the right of the decimal point, just truncate it at the "."
|
||||
}
|
||||
|
||||
if (pSuffix != NULL)
|
||||
{
|
||||
#ifdef WIN32
|
||||
int retVal = V_snwprintf( textBuffer, textBufferLen, L"%s%s", textBuffer, pSuffix );
|
||||
#else
|
||||
int retVal = V_snwprintf( textBuffer, textBufferLen, L"%S%S", textBuffer, pSuffix );
|
||||
#endif
|
||||
|
||||
if ( retVal < 0 )
|
||||
{
|
||||
Msg("ConvertNumberToMantissaSuffixForm(): unable to add suffix %S for value %f (buffer size was %i)\n", pSuffix, fNum, textBufferLen);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CStatsSummary::CStatsSummary(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSAchievementsDialog"),
|
||||
m_StatImageMap(DefLessFunc(CSStatType_t))
|
||||
{
|
||||
m_iFixedWidth = 900; // Give this an initial value in order to set a proper size
|
||||
SetBounds(0, 0, 900, 780);
|
||||
SetMinimumSize(256, 780);
|
||||
|
||||
m_pStatCard = new StatCard(this, "ignored");
|
||||
|
||||
m_pImageList = NULL;
|
||||
m_iDefaultWeaponImage = -1;
|
||||
m_iDefaultMapImage = -1;
|
||||
|
||||
m_pImagePanelFavWeapon = new ImagePanel(this, "FavoriteWeaponImage");
|
||||
m_pImagePanelLastMapFavWeapon = new ImagePanel(this, "FavWeaponIcon");
|
||||
m_pImagePanelFavMap = new ImagePanel(this, "FavoriteMapImage");
|
||||
|
||||
//Setup the recent achievement list by adding all achieved achievements to the list
|
||||
m_pRecentAchievementsList = new vgui::PanelListPanel(this, "RecentAchievementsListPanel");
|
||||
m_pRecentAchievementsList->SetFirstColumnWidth(0);
|
||||
|
||||
ListenForGameEvent( "player_stats_updated" );
|
||||
ListenForGameEvent( "achievement_earned_local" );
|
||||
|
||||
m_bRecentAchievementsDirty = true;
|
||||
m_bStatsDirty = true;
|
||||
}
|
||||
|
||||
CStatsSummary::~CStatsSummary()
|
||||
{
|
||||
if (m_pRecentAchievementsList)
|
||||
{
|
||||
m_pRecentAchievementsList->DeleteAllItems();
|
||||
}
|
||||
|
||||
delete m_pRecentAchievementsList;
|
||||
delete m_pImageList;
|
||||
}
|
||||
|
||||
void CStatsSummary::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
LoadControlSettings("Resource/UI/CSStatsSummary.res");
|
||||
|
||||
SetBgColor(Color(86,86,86,255));
|
||||
|
||||
if (m_pImageList)
|
||||
delete m_pImageList;
|
||||
m_pImageList = new ImageList(false);
|
||||
|
||||
if (m_pImageList)
|
||||
{
|
||||
//Load defaults
|
||||
m_iDefaultWeaponImage = m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/defaultweapon", true));
|
||||
m_iDefaultMapImage = m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_generic_map", true));
|
||||
|
||||
//load weapon images
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_DEAGLE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/deserteagle", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_USP, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/usp45", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_GLOCK, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/glock18", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_P228, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/p228", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_ELITE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/elites", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_FIVESEVEN, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/fiveseven", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_AWP, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/awp", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_AK47, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/ak47", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_M4A1, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/m4a1", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_AUG, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/aug", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_SG552, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/sg552", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_SG550, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/sg550", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_GALIL, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/galil", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_FAMAS, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/famas", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_SCOUT, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/scout", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_G3SG1, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/g3sg1", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_P90, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/p90", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_MP5NAVY, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/mp5", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_TMP, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/tmp", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_MAC10, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/mac10", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_UMP45, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/ump45", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_M3, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/m3", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_XM1014, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/xm1014", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_KILLS_M249, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/m249", true)));
|
||||
|
||||
//load map images
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_ASSAULT, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_assault", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_COMPOUND, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_compound", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_HAVANA, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_havana", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_ITALY, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_italy", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_MILITIA, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_militia", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_CS_OFFICE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_cs_office", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_AZTEC, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_aztec", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_CBBLE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_cbble", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_CHATEAU, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_chateau", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_DUST2, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_dust2", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_DUST, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_dust", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_INFERNO, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_inferno", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_NUKE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_nuke", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_PIRANESI, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_piranesi", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_PORT, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_port", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_PRODIGY, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_prodigy", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_TIDES, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_tides", true)));
|
||||
m_StatImageMap.Insert(CSSTAT_MAP_WINS_DE_TRAIN, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/summary_maps/summary_de_train", true)));
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
// Get the width we're going to lock at
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::ApplySettings(KeyValues *pResourceData)
|
||||
{
|
||||
m_iFixedWidth = pResourceData->GetInt("wide", 512);
|
||||
|
||||
BaseClass::ApplySettings(pResourceData);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Preserve our width to the one in the .res file
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::OnSizeChanged(int newWide, int newTall)
|
||||
{
|
||||
// Lock the width, but allow height scaling
|
||||
if (newWide != m_iFixedWidth)
|
||||
{
|
||||
SetSize(m_iFixedWidth, newTall);
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnSizeChanged(newWide, newTall);
|
||||
}
|
||||
|
||||
|
||||
void CStatsSummary::OnThink()
|
||||
{
|
||||
if ( m_bRecentAchievementsDirty )
|
||||
UpdateRecentAchievements();
|
||||
|
||||
if ( m_bStatsDirty )
|
||||
UpdateStatsData();
|
||||
}
|
||||
|
||||
|
||||
void CStatsSummary::OnPageShow()
|
||||
{
|
||||
UpdateStatsData();
|
||||
UpdateRecentAchievements();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Update all of the stats displays
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::UpdateStatsData()
|
||||
{
|
||||
UpdateStatsSummary();
|
||||
UpdateKillHistory();
|
||||
UpdateFavoriteWeaponData();
|
||||
UpdateMapsData();
|
||||
|
||||
|
||||
UpdateLastMatchStats();
|
||||
m_pStatCard->UpdateInfo();
|
||||
|
||||
m_bStatsDirty = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Update the stats located in the stats summary section
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::UpdateStatsSummary()
|
||||
{
|
||||
DisplayCompressedLocalizedStat(CSSTAT_ROUNDS_PLAYED, "roundsplayed");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_ROUNDS_WON, "roundswon");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_SHOTS_HIT, "shotshit");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_SHOTS_FIRED, "shotsfired");
|
||||
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
|
||||
//Calculate Win Ratio
|
||||
int wins = g_CSClientGameStats.GetStatById(CSSTAT_ROUNDS_WON).iStatValue;
|
||||
int rounds = g_CSClientGameStats.GetStatById(CSSTAT_ROUNDS_PLAYED).iStatValue;
|
||||
float winRatio = 0;
|
||||
if (rounds > 0)
|
||||
{
|
||||
winRatio = ((float)wins / (float)rounds) * 100.0f;
|
||||
}
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f%%", winRatio);
|
||||
SetDialogVariable("winratio", tempWNumString);
|
||||
|
||||
|
||||
//Calculate accuracy
|
||||
int hits = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_HIT).iStatValue;
|
||||
int shots = g_CSClientGameStats.GetStatById(CSSTAT_SHOTS_FIRED).iStatValue;
|
||||
float accuracy = 0;
|
||||
if (shots > 0)
|
||||
{
|
||||
accuracy = ((float)hits / (float)shots) * 100.0f;
|
||||
}
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f%%", accuracy);
|
||||
SetDialogVariable("hitratio", tempWNumString);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Update the stats located in the stats summary section
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::UpdateKillHistory()
|
||||
{
|
||||
DisplayCompressedLocalizedStat(CSSTAT_KILLS, "kills");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_DEATHS, "deaths");
|
||||
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
|
||||
//Calculate Win Ratio
|
||||
int kills = g_CSClientGameStats.GetStatById(CSSTAT_KILLS).iStatValue;
|
||||
int deaths = g_CSClientGameStats.GetStatById(CSSTAT_DEATHS).iStatValue;
|
||||
float killDeathRatio = 0;
|
||||
if (deaths > 0)
|
||||
{
|
||||
killDeathRatio = (float)kills / (float)deaths;
|
||||
}
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f", killDeathRatio);
|
||||
SetDialogVariable("killdeathratio", tempWNumString);
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
// Update the stats located in the favorite weapon section
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::UpdateFavoriteWeaponData()
|
||||
{
|
||||
// First set the image to the favorite weapon
|
||||
if (m_pImageList)
|
||||
{
|
||||
//start with a dummy stat
|
||||
const WeaponName_StatId* pFavoriteWeaponStatEntry = NULL;
|
||||
|
||||
//Find the weapon stat with the most kills
|
||||
int numKills = 0;
|
||||
for (int i = 0; WeaponName_StatId_Table[i].killStatId != CSSTAT_UNDEFINED; ++i)
|
||||
{
|
||||
// ignore weapons with no hit counts (knife and grenade)
|
||||
if (WeaponName_StatId_Table[i].hitStatId == CSSTAT_UNDEFINED )
|
||||
continue;
|
||||
|
||||
const WeaponName_StatId& weaponStatEntry = WeaponName_StatId_Table[i];
|
||||
PlayerStatData_t stat = g_CSClientGameStats.GetStatById(weaponStatEntry.killStatId);
|
||||
if (stat.iStatValue > numKills)
|
||||
{
|
||||
pFavoriteWeaponStatEntry = &weaponStatEntry;
|
||||
numKills = stat.iStatValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFavoriteWeaponStatEntry)
|
||||
{
|
||||
CUtlMap<CSStatType_t, int>::IndexType_t idx = m_StatImageMap.Find((CSStatType_t)pFavoriteWeaponStatEntry->killStatId);
|
||||
if (m_StatImageMap.IsValidIndex(idx))
|
||||
{
|
||||
m_pImagePanelFavWeapon->SetImage(m_pImageList->GetImage(m_StatImageMap[idx]));
|
||||
}
|
||||
|
||||
DisplayCompressedLocalizedStat(pFavoriteWeaponStatEntry->hitStatId, "weaponhits", "#GameUI_Stats_WeaponShotsHit");
|
||||
DisplayCompressedLocalizedStat(pFavoriteWeaponStatEntry->shotStatId, "weaponshotsfired", "#GameUI_Stats_WeaponShotsFired");
|
||||
DisplayCompressedLocalizedStat(pFavoriteWeaponStatEntry->killStatId, "weaponkills", "#GameUI_Stats_WeaponKills");
|
||||
|
||||
//Calculate accuracy
|
||||
int kills = g_CSClientGameStats.GetStatById(pFavoriteWeaponStatEntry->killStatId).iStatValue;
|
||||
int shots = g_CSClientGameStats.GetStatById(pFavoriteWeaponStatEntry->shotStatId).iStatValue;
|
||||
float killsPerShot = 0;
|
||||
if (shots > 0)
|
||||
{
|
||||
killsPerShot = (float)kills / (float)shots;
|
||||
}
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f", (killsPerShot));
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponKillRatio", tempWNumString, "weaponkillratio");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_iDefaultWeaponImage != -1)
|
||||
{
|
||||
m_pImagePanelFavWeapon->SetImage(m_pImageList->GetImage(m_iDefaultWeaponImage));
|
||||
}
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponShotsHit", L"0", "weaponhits");
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponShotsFired", L"0", "weaponshotsfired");
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponKills", L"0", "weaponkills");
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponKillRatio", L"0", "weaponkillratio");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Update the stats located in the favorite weapon section
|
||||
//----------------------------------------------------------
|
||||
void CStatsSummary::UpdateMapsData()
|
||||
{
|
||||
//start with a dummy stat
|
||||
const MapName_MapStatId* pFavoriteMapStat = NULL;
|
||||
int numRounds = 0;
|
||||
for (int i = 0; MapName_StatId_Table[i].statWinsId != CSSTAT_UNDEFINED; ++i)
|
||||
{
|
||||
const MapName_MapStatId& mapStatId = MapName_StatId_Table[i];
|
||||
PlayerStatData_t stat = g_CSClientGameStats.GetStatById(mapStatId.statRoundsId);
|
||||
if (stat.iStatValue > numRounds)
|
||||
{
|
||||
pFavoriteMapStat = &mapStatId;
|
||||
numRounds = stat.iStatValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFavoriteMapStat)
|
||||
{
|
||||
CUtlMap<CSStatType_t, int>::IndexType_t idx = m_StatImageMap.Find((CSStatType_t)pFavoriteMapStat->statWinsId);
|
||||
if (m_StatImageMap.IsValidIndex(idx))
|
||||
{
|
||||
m_pImagePanelFavMap->SetImage(m_pImageList->GetImage(m_StatImageMap[idx]));
|
||||
}
|
||||
|
||||
// map name
|
||||
SetDialogVariable("mapname", pFavoriteMapStat->szMapName);
|
||||
|
||||
// rounds played
|
||||
DisplayCompressedLocalizedStat(pFavoriteMapStat->statRoundsId,"mapplayed", "#GameUI_Stats_MapPlayed");
|
||||
DisplayCompressedLocalizedStat(pFavoriteMapStat->statWinsId, "mapwins", "#GameUI_Stats_MapWins");
|
||||
|
||||
//Calculate Win Ratio
|
||||
int wins = g_CSClientGameStats.GetStatById(pFavoriteMapStat->statWinsId).iStatValue;
|
||||
int rounds = g_CSClientGameStats.GetStatById(pFavoriteMapStat->statRoundsId).iStatValue;
|
||||
float winRatio = 0;
|
||||
if (rounds > 0)
|
||||
{
|
||||
winRatio = ((float)wins / (float)rounds) * 100.0f;
|
||||
}
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f%%", winRatio);
|
||||
DisplayFormattedLabel("#GameUI_Stats_MapWinRatio", tempWNumString, "mapwinratio");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_iDefaultMapImage != -1)
|
||||
{
|
||||
m_pImagePanelFavMap->SetImage(m_pImageList->GetImage(m_iDefaultMapImage));
|
||||
}
|
||||
SetDialogVariable("mapname", L"");
|
||||
DisplayFormattedLabel("#GameUI_Stats_MapPlayed", L"0", "mapplayed");
|
||||
DisplayFormattedLabel("#GameUI_Stats_MapWins", L"0", "mapwins");
|
||||
DisplayFormattedLabel("#GameUI_Stats_MapWinRatio", L"0", "mapwinratio");
|
||||
}
|
||||
}
|
||||
|
||||
int CStatsSummary::AchivementDateSortPredicate( CCSBaseAchievement* const* pLeft, CCSBaseAchievement* const* pRight )
|
||||
{
|
||||
if (!pLeft || !pRight || !(*pLeft) || ! (*pRight))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*pLeft)->GetSortKey() < (*pRight)->GetSortKey())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if ((*pLeft)->GetSortKey() > (*pRight)->GetSortKey())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CStatsSummary::UpdateRecentAchievements()
|
||||
{
|
||||
CUtlVector<CCSBaseAchievement*> sortedAchivementList;
|
||||
|
||||
//Get a list of all the achievements that have been earned
|
||||
int iCount = g_AchievementMgrCS.GetAchievementCount();
|
||||
sortedAchivementList.EnsureCapacity(iCount);
|
||||
|
||||
for (int i = 0; i < iCount; ++i)
|
||||
{
|
||||
CCSBaseAchievement* pAchievement = (CCSBaseAchievement*)g_AchievementMgrCS.GetAchievementByIndex(i);
|
||||
if (pAchievement && pAchievement->IsAchieved())
|
||||
{
|
||||
sortedAchivementList.AddToTail(pAchievement);
|
||||
}
|
||||
}
|
||||
|
||||
//Sort the earned achievements by time and date earned.
|
||||
sortedAchivementList.Sort(AchivementDateSortPredicate);
|
||||
|
||||
//Clear the UI list
|
||||
m_pRecentAchievementsList->DeleteAllItems();
|
||||
|
||||
// Add each achievement in the sorted list as a panel.
|
||||
int numPanelsToAdd = MIN(maxRecentAchievementToDisplay, sortedAchivementList.Count());
|
||||
for ( int i = 0; i < numPanelsToAdd; i++ )
|
||||
{
|
||||
CCSBaseAchievement* pAchievement = sortedAchivementList[i];
|
||||
if (pAchievement)
|
||||
{
|
||||
CAchievementsPageItemPanel *achievementItemPanel = new CAchievementsPageItemPanel(m_pRecentAchievementsList, "AchievementDialogItemPanel");
|
||||
achievementItemPanel->SetAchievementInfo(pAchievement);
|
||||
|
||||
// force all our new panel to have the correct internal layout and size so that our parent container can layout properly
|
||||
achievementItemPanel->InvalidateLayout(true, true);
|
||||
|
||||
m_pRecentAchievementsList->AddItem(NULL, achievementItemPanel);
|
||||
}
|
||||
}
|
||||
|
||||
m_bRecentAchievementsDirty = false;
|
||||
}
|
||||
|
||||
void CStatsSummary::UpdateLastMatchStats()
|
||||
{
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_T_ROUNDS_WON, "lastmatchtwins", "#GameUI_Stats_LastMatch_TWins");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_CT_ROUNDS_WON, "lastmatchctwins", "#GameUI_Stats_LastMatch_CTWins");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_ROUNDS_WON, "lastmatchwins", "#GameUI_Stats_LastMatch_RoundsWon");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_MAX_PLAYERS, "lastmatchmaxplayers", "#GameUI_Stats_LastMatch_MaxPlayers");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_MVPS, "lastmatchstars", "#GameUI_Stats_LastMatch_MVPS");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_KILLS, "lastmatchkills", "#GameUI_Stats_WeaponKills");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_DEATHS, "lastmatchdeaths", "#GameUI_Stats_LastMatch_Deaths");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_DAMAGE, "lastmatchtotaldamage", "#GameUI_Stats_LastMatch_Damage");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_DOMINATIONS, "lastmatchdominations", "#GameUI_Stats_LastMatch_Dominations");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_REVENGES, "lastmatchrevenges", "#GameUI_Stats_LastMatch_Revenges");
|
||||
|
||||
UpdateLastMatchFavoriteWeaponStats();
|
||||
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
|
||||
//Calculate Kill:Death ratio
|
||||
int deaths = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_DEATHS).iStatValue;
|
||||
int kills = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_KILLS).iStatValue;
|
||||
float killDeathRatio = deaths;
|
||||
if (deaths != 0)
|
||||
{
|
||||
killDeathRatio = (float)kills / (float)deaths;
|
||||
}
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f", killDeathRatio);
|
||||
DisplayFormattedLabel("#GameUI_Stats_LastMatch_KDRatio", tempWNumString, "lastmatchkilldeathratio");
|
||||
|
||||
//Calculate cost per kill
|
||||
PlayerStatData_t statMoneySpent = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_MONEYSPENT);
|
||||
int costPerKill = 0;
|
||||
if (kills > 0)
|
||||
{
|
||||
costPerKill = statMoneySpent.iStatValue / kills;
|
||||
}
|
||||
ConvertNumberToMantissaSuffixForm(costPerKill, tempWNumString, STAT_NUM_ARRAY_LENGTH);
|
||||
DisplayFormattedLabel("#GameUI_Stats_LastMatch_MoneySpentPerKill", tempWNumString, "lastmatchmoneyspentperkill");
|
||||
}
|
||||
|
||||
void CStatsSummary::UpdateLastMatchFavoriteWeaponStats()
|
||||
{
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
|
||||
PlayerStatData_t statFavWeaponId = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_FAVWEAPON_ID);
|
||||
const WeaponName_StatId& favoriteWeaponStat = GetWeaponTableEntryFromWeaponId((CSWeaponID)statFavWeaponId.iStatValue);
|
||||
|
||||
// If we have a valid weapon use it's data; otherwise use nothing. We check the shot ID to make sure it is a weapon with bullets.
|
||||
if (favoriteWeaponStat.hitStatId != CSSTAT_UNDEFINED)
|
||||
{
|
||||
// Set the image and (non-copyright) name of this weapon
|
||||
CUtlMap<CSStatType_t, int>::IndexType_t idx = m_StatImageMap.Find((CSStatType_t)favoriteWeaponStat.killStatId);
|
||||
if (m_StatImageMap.IsValidIndex(idx))
|
||||
{
|
||||
m_pImagePanelLastMapFavWeapon->SetImage(m_pImageList->GetImage(m_StatImageMap[idx]));
|
||||
}
|
||||
|
||||
const wchar_t* tempName = WeaponIDToDisplayName(favoriteWeaponStat.weaponId);
|
||||
if (tempName)
|
||||
{
|
||||
SetDialogVariable("lastmatchfavweaponname", tempName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable("lastmatchfavweaponname", L"");
|
||||
}
|
||||
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_FAVWEAPON_KILLS, "lastmatchfavweaponkills", "#GameUI_Stats_WeaponKills");
|
||||
DisplayCompressedLocalizedStat(CSSTAT_LASTMATCH_FAVWEAPON_HITS, "lastmatchfavweaponhits", "#GameUI_Stats_WeaponShotsHit");
|
||||
|
||||
int shots = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_FAVWEAPON_SHOTS).iStatValue;
|
||||
int hits = g_CSClientGameStats.GetStatById(CSSTAT_LASTMATCH_FAVWEAPON_HITS).iStatValue;
|
||||
float accuracy = 0.0f;
|
||||
if (shots != 0)
|
||||
{
|
||||
accuracy = ((float)hits / (float)shots) * 100.0f;
|
||||
}
|
||||
V_snwprintf(tempWNumString, ARRAYSIZE(tempWNumString), L"%.1f%%", accuracy);
|
||||
DisplayFormattedLabel("#GameUI_Stats_LastMatch_FavWeaponAccuracy", tempWNumString, "lastmatchfavweaponaccuracy");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_iDefaultWeaponImage != -1)
|
||||
{
|
||||
m_pImagePanelLastMapFavWeapon->SetImage(m_pImageList->GetImage(m_iDefaultWeaponImage));
|
||||
}
|
||||
|
||||
|
||||
//Set this label to diferent text, indicating that there is not a favorite weapon
|
||||
SetDialogVariable("lastmatchfavweaponname", g_pVGuiLocalize->Find("#GameUI_Stats_LastMatch_NoFavWeapon"));
|
||||
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponKills", L"0", "lastmatchfavweaponkills");
|
||||
DisplayFormattedLabel("#GameUI_Stats_WeaponShotsHit", L"0", "lastmatchfavweaponhits");
|
||||
DisplayFormattedLabel("#GameUI_Stats_LastMatch_FavWeaponAccuracy", L"0", "lastmatchfavweaponaccuracy");
|
||||
}
|
||||
}
|
||||
|
||||
void CStatsSummary::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
|
||||
if ( 0 == Q_strcmp( type, "achievement_earned_local" ) )
|
||||
{
|
||||
m_bRecentAchievementsDirty = true;
|
||||
}
|
||||
|
||||
else if ( 0 == Q_strcmp( type, "player_stats_updated" ) )
|
||||
{
|
||||
m_bStatsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CStatsSummary::DisplayCompressedLocalizedStat(CSStatType_t stat, const char* dialogVariable, const char* localizationToken /* = NULL */)
|
||||
{
|
||||
wchar_t tempWNumString[STAT_NUM_ARRAY_LENGTH];
|
||||
int statValue = g_CSClientGameStats.GetStatById(stat).iStatValue;
|
||||
ConvertNumberToMantissaSuffixForm(statValue, tempWNumString, STAT_NUM_ARRAY_LENGTH);
|
||||
if (localizationToken)
|
||||
{
|
||||
DisplayFormattedLabel(localizationToken, tempWNumString, dialogVariable);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable(dialogVariable, tempWNumString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CStatsSummary::DisplayFormattedLabel( const char* localizationToken, const wchar_t* valueText, const char* dialogVariable )
|
||||
{
|
||||
wchar_t tempWStatString[256];
|
||||
g_pVGuiLocalize->ConstructString(tempWStatString, sizeof(tempWStatString),
|
||||
g_pVGuiLocalize->Find(localizationToken), 1, valueText);
|
||||
SetDialogVariable(dialogVariable, tempWStatString);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSSTATSSUMMARY_H
|
||||
#define CSSTATSSUMMARY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "vgui_controls/PropertyPage.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "achievements_page.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "utlmap.h"
|
||||
|
||||
class IAchievement;
|
||||
class IScheme;
|
||||
class CAchievementsPageGroupPanel;
|
||||
class StatCard;
|
||||
class CCSBaseAchievement;
|
||||
|
||||
class CStatsSummary : public vgui::PropertyPage, public CGameEventListener
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE ( CStatsSummary, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
CStatsSummary( vgui::Panel *parent, const char *name );
|
||||
~CStatsSummary();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void ApplySettings( KeyValues *pResourceData );
|
||||
virtual void OnSizeChanged( int newWide, int newTall );
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
virtual void OnThink();
|
||||
virtual void OnPageShow();
|
||||
|
||||
void UpdateStatsData();
|
||||
void UpdateStatsSummary();
|
||||
void UpdateKillHistory();
|
||||
void UpdateFavoriteWeaponData();
|
||||
void UpdateMapsData();
|
||||
void UpdateRecentAchievements();
|
||||
void UpdateLastMatchStats();
|
||||
|
||||
void UpdateLastMatchFavoriteWeaponStats();
|
||||
|
||||
private:
|
||||
|
||||
static int AchivementDateSortPredicate( CCSBaseAchievement* const* pLeft, CCSBaseAchievement* const* pRight);
|
||||
void DisplayCompressedLocalizedStat(CSStatType_t stat, const char* dialogVariable, const char* localizationToken = NULL);
|
||||
void DisplayFormattedLabel(const char* localizationToken, const wchar_t* valueText, const char* dialogVariable);
|
||||
|
||||
int m_iFixedWidth;
|
||||
int m_iDefaultWeaponImage;
|
||||
int m_iDefaultMapImage;
|
||||
|
||||
vgui::Label* m_pLabelRoundsPlayed;
|
||||
vgui::Label* m_pLabelRoundsWon;
|
||||
vgui::ImagePanel* m_pImagePanelFavWeapon;
|
||||
vgui::ImagePanel* m_pImagePanelLastMapFavWeapon;
|
||||
vgui::ImagePanel* m_pImagePanelFavMap;
|
||||
|
||||
vgui::ImageList *m_pImageList;
|
||||
|
||||
vgui::PanelListPanel *m_pRecentAchievementsList;
|
||||
|
||||
StatCard* m_pStatCard;
|
||||
|
||||
bool m_bRecentAchievementsDirty;
|
||||
bool m_bStatsDirty;
|
||||
|
||||
CUtlMap<CSStatType_t, int> m_StatImageMap;
|
||||
};
|
||||
#endif // CSSTATSSUMMARY_H
|
||||
@@ -1,470 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Create and display a win panel at the end of a round displaying interesting stats and info about the round.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "win_panel_round.h"
|
||||
#include "vgui_controls/AnimationController.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_playerresource.h"
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include "fmtstr.h"
|
||||
#include "cs_gamestats_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
ConVar cl_round_win_fade_time( "cl_round_win_fade_time", "1.5", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( WinPanel_Round, 1 ); // 1 is foreground
|
||||
extern const wchar_t *LocalizeFindSafe( const char *pTokenName );
|
||||
|
||||
|
||||
// helper function for converting wstrings to upper-case inline
|
||||
// NB: this returns a pointer to a static buffer
|
||||
wchar_t* UpperCaseWideString( const wchar_t* wszSource )
|
||||
{
|
||||
static wchar_t wszBuffer[256];
|
||||
V_wcsncpy(wszBuffer, wszSource, sizeof(wszBuffer));
|
||||
V_wcsupr(wszBuffer);
|
||||
return wszBuffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
WinPanel_Round::WinPanel_Round( const char *pElementName ) :
|
||||
BorderedPanel( NULL, pElementName ),
|
||||
CHudElement( pElementName ),
|
||||
m_bIsFading(false),
|
||||
m_fFadeBeginTime(0.0f)
|
||||
{
|
||||
SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
|
||||
SetParent(g_pClientMode->GetViewport());
|
||||
|
||||
SetScheme( "ClientScheme" );
|
||||
|
||||
RegisterForRenderGroup( "hide_for_scoreboard" );
|
||||
|
||||
m_bShouldBeVisible = false;
|
||||
}
|
||||
|
||||
WinPanel_Round::~WinPanel_Round()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void WinPanel_Round::Reset()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
void WinPanel_Round::Init()
|
||||
{
|
||||
CHudElement::Init();
|
||||
|
||||
// listen for events
|
||||
ListenForGameEvent( "round_end" );
|
||||
ListenForGameEvent( "round_start" );
|
||||
ListenForGameEvent( "cs_win_panel_round" );
|
||||
ListenForGameEvent( "cs_win_panel_match" );
|
||||
ListenForGameEvent( "round_mvp" );
|
||||
|
||||
InitLayout();
|
||||
|
||||
m_bShouldBeVisible = false;
|
||||
m_bShowTimerDefend = false;
|
||||
m_bShowTimerAttack = false;
|
||||
}
|
||||
|
||||
|
||||
void WinPanel_Round::InitLayout()
|
||||
{
|
||||
// reload control settings when resolution changes to force update of proportional layout
|
||||
LoadControlSettings("Resource/UI/Win_Round.res");
|
||||
|
||||
CAvatarImagePanel* pMVP_Avatar = dynamic_cast<CAvatarImagePanel*>(FindChildByName("MVP_Avatar"));
|
||||
pMVP_Avatar->SetDefaultAvatar(scheme()->GetImage( CSTRIKE_DEFAULT_AVATAR, true));
|
||||
pMVP_Avatar->SetShouldDrawFriendIcon(false);
|
||||
}
|
||||
|
||||
|
||||
void WinPanel_Round::VidInit()
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Allow win panel to be turned off on client
|
||||
//=============================================================================
|
||||
ConVar cl_nowinpanel(
|
||||
"cl_nowinpanel",
|
||||
"0",
|
||||
FCVAR_ARCHIVE,
|
||||
"Turn on/off win panel on client"
|
||||
);
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
void WinPanel_Round::FireGameEvent( IGameEvent* event )
|
||||
{
|
||||
const char *pEventName = event->GetName();
|
||||
|
||||
if ( Q_strcmp( "round_end", pEventName ) == 0 )
|
||||
{
|
||||
}
|
||||
else if ( Q_strcmp( "round_start", pEventName ) == 0 )
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
else if( Q_strcmp( "cs_win_panel_match", pEventName ) == 0 )
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
else if( Q_strcmp( "round_mvp", pEventName ) == 0 )
|
||||
{
|
||||
C_BasePlayer *basePlayer = UTIL_PlayerByUserId( event->GetInt( "userid" ) );
|
||||
CSMvpReason_t mvpReason = (CSMvpReason_t)event->GetInt( "reason" );
|
||||
|
||||
if( basePlayer )
|
||||
{
|
||||
SetMVP( ToCSPlayer( basePlayer ), mvpReason );
|
||||
}
|
||||
}
|
||||
else if ( Q_strcmp( "cs_win_panel_round", pEventName ) == 0 )
|
||||
{
|
||||
/*
|
||||
"show_timer_defend" "bool"
|
||||
"show_timer_attack" "bool"
|
||||
"timer_time" "int"
|
||||
|
||||
"final_event" "byte" // 0 - no event, 1 - bomb exploded, 2 - flag capped, 3 - timer expired
|
||||
|
||||
"funfact_type" "byte" //WINPANEL_FUNFACT in cs_shareddef.h
|
||||
"funfact_player" "byte"
|
||||
"funfact_data1" "long"
|
||||
"funfact_data2" "long"
|
||||
"funfact_data3" "long"
|
||||
*/
|
||||
|
||||
if ( !g_PR )
|
||||
return;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Check if win panel is disabled.
|
||||
//=============================================================================
|
||||
static ConVarRef sv_nowinpanel( "sv_nowinpanel" );
|
||||
if ( sv_nowinpanel.GetBool() || cl_nowinpanel.GetBool() )
|
||||
return;
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
m_bShowTimerDefend = event->GetBool( "show_timer_defend" );
|
||||
m_bShowTimerAttack = event->GetBool( "show_timer_attack" );
|
||||
int iTimerTime = event->GetInt( "timer_time" );
|
||||
|
||||
int minutes = clamp( iTimerTime / 60, 0, 99 );
|
||||
int seconds = clamp( iTimerTime % 60, 0, 59 );
|
||||
|
||||
wchar_t time[8];
|
||||
_snwprintf( time, ARRAYSIZE( time ), L"%d:%02d", minutes, seconds );
|
||||
|
||||
SetDialogVariable("TIMER_TEXT", time);
|
||||
|
||||
// Final Fun Fact
|
||||
SetFunFactLabel( L"");
|
||||
int iFunFactPlayer = event->GetInt("funfact_player");
|
||||
const char* funfactToken = event->GetString("funfact_token", "");
|
||||
|
||||
if (strlen(funfactToken) != 0)
|
||||
{
|
||||
wchar_t funFactText[256];
|
||||
wchar_t playerText[64];
|
||||
wchar_t dataText1[8], dataText2[8], dataText3[8];
|
||||
int param1 = event->GetInt("funfact_data1");
|
||||
int param2 = event->GetInt("funfact_data2");
|
||||
int param3 = event->GetInt("funfact_data3");
|
||||
if ( iFunFactPlayer >= 1 && iFunFactPlayer <= MAX_PLAYERS )
|
||||
{
|
||||
const char* playerName = g_PR->GetPlayerName( iFunFactPlayer );
|
||||
if( playerName && Q_strcmp( playerName, PLAYER_UNCONNECTED_NAME ) != 0 && Q_strcmp( playerName, PLAYER_ERROR_NAME ) != 0 )
|
||||
{
|
||||
V_strtowcs( g_PR->GetPlayerName( iFunFactPlayer ), 64, playerText, sizeof( playerText ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
_snwprintf( playerText, ARRAYSIZE( playerText ), L"%s", LocalizeFindSafe( "#winpanel_former_player" ) );
|
||||
#else
|
||||
_snwprintf( playerText, ARRAYSIZE( playerText ), L"%S", LocalizeFindSafe( "#winpanel_former_player" ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_snwprintf( playerText, ARRAYSIZE( playerText ), L"" );
|
||||
}
|
||||
_snwprintf( dataText1, ARRAYSIZE( dataText1 ), L"%i", param1 );
|
||||
_snwprintf( dataText2, ARRAYSIZE( dataText2 ), L"%i", param2 );
|
||||
_snwprintf( dataText3, ARRAYSIZE( dataText3 ), L"%i", param3 );
|
||||
g_pVGuiLocalize->ConstructString( funFactText, sizeof(funFactText), (wchar_t *)LocalizeFindSafe(funfactToken), 4,
|
||||
playerText, dataText1, dataText2, dataText3 );
|
||||
SetFunFactLabel(funFactText);
|
||||
}
|
||||
|
||||
int iEndEvent = event->GetInt( "final_event" );
|
||||
|
||||
//Map the round end events onto localized strings
|
||||
const char* endEventToString[RoundEndReason_Count];
|
||||
V_memset(endEventToString, 0, sizeof(endEventToString));
|
||||
|
||||
//terrorist win events
|
||||
endEventToString[Target_Bombed] = "#winpanel_end_target_bombed";
|
||||
endEventToString[VIP_Assassinated] = "#winpanel_end_vip_assassinated";
|
||||
endEventToString[Terrorists_Escaped] = "#winpanel_end_terrorists_escaped";
|
||||
endEventToString[Terrorists_Win] = "#winpanel_end_terrorists__kill";
|
||||
endEventToString[Hostages_Not_Rescued] = "#winpanel_end_hostages_not_rescued";
|
||||
endEventToString[VIP_Not_Escaped] = "#winpanel_end_vip_not_escaped";
|
||||
|
||||
//CT win events
|
||||
endEventToString[VIP_Escaped] = "#winpanel_end_vip_escaped";
|
||||
endEventToString[CTs_PreventEscape] = "#winpanel_end_cts_prevent_escape";
|
||||
endEventToString[Escaping_Terrorists_Neutralized] = "#winpanel_end_escaping_terrorists_neutralized";
|
||||
endEventToString[Bomb_Defused] = "#winpanel_end_bomb_defused";
|
||||
endEventToString[CTs_Win] = "#winpanel_end_cts_win";
|
||||
endEventToString[All_Hostages_Rescued] = "#winpanel_end_all_hostages_rescued";
|
||||
endEventToString[Target_Saved] = "#winpanel_end_target_saved";
|
||||
endEventToString[Terrorists_Not_Escaped] = "#winpanel_end_terrorists_not_escaped";
|
||||
|
||||
//We don't show a round end panel for these
|
||||
endEventToString[Game_Commencing] = "";
|
||||
endEventToString[Round_Draw] = "";
|
||||
|
||||
const wchar_t* wszEventMessage = NULL;
|
||||
if(iEndEvent >=0 && iEndEvent < RoundEndReason_Count)
|
||||
wszEventMessage = LocalizeFindSafe(endEventToString[iEndEvent]);
|
||||
|
||||
if ( wszEventMessage != NULL )
|
||||
{
|
||||
SetDialogVariable("WIN_DESCRIPTION", UpperCaseWideString(wszEventMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable("WIN_DESCRIPTION", "");
|
||||
}
|
||||
|
||||
Label* pWinLabel = dynamic_cast<Label*>(FindChildByName("WinLabel"));
|
||||
switch(iEndEvent)
|
||||
{
|
||||
case Target_Bombed:
|
||||
case VIP_Assassinated:
|
||||
case Terrorists_Escaped:
|
||||
case Terrorists_Win:
|
||||
case Hostages_Not_Rescued:
|
||||
case VIP_Not_Escaped:
|
||||
pWinLabel->SetText(UpperCaseWideString(LocalizeFindSafe("#winpanel_t_win")));
|
||||
pWinLabel->SetFgColor(Color(184,0,0,255));
|
||||
break;
|
||||
|
||||
case VIP_Escaped:
|
||||
case CTs_PreventEscape:
|
||||
case Escaping_Terrorists_Neutralized:
|
||||
case Bomb_Defused:
|
||||
case CTs_Win:
|
||||
case All_Hostages_Rescued:
|
||||
case Target_Saved:
|
||||
case Terrorists_Not_Escaped:
|
||||
pWinLabel->SetText(UpperCaseWideString(LocalizeFindSafe("#winpanel_ct_win")));
|
||||
pWinLabel->SetFgColor(Color(71,152,237,255));
|
||||
break;
|
||||
|
||||
case Round_Draw:
|
||||
pWinLabel->SetText(UpperCaseWideString(LocalizeFindSafe("#winpanel_draw")));
|
||||
pWinLabel->SetFgColor(Color(204,204,204,255));
|
||||
break;
|
||||
}
|
||||
|
||||
//[tj] We set the icon to the generic one right before we show it.
|
||||
// The expected result is that we replace it immediately with
|
||||
// the round MVP. if there is none, we just use the generic.
|
||||
SetMVP( NULL, CSMVP_UNDEFINED );
|
||||
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
void WinPanel_Round::SetMVP( C_CSPlayer* pPlayer, CSMvpReason_t reason )
|
||||
{
|
||||
CAvatarImagePanel* pMVP_Avatar = dynamic_cast<CAvatarImagePanel*>(FindChildByName("MVP_Avatar"));
|
||||
|
||||
if ( pMVP_Avatar )
|
||||
{
|
||||
pMVP_Avatar->ClearAvatar();
|
||||
}
|
||||
|
||||
//First set the text to the name of the player
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Allow MVP to be turned off for a server
|
||||
//=============================================================================
|
||||
bool isThereAnMVP = ( pPlayer != NULL );
|
||||
if ( isThereAnMVP )
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
{
|
||||
|
||||
const char* mvpReasonToken = NULL;
|
||||
switch ( reason )
|
||||
{
|
||||
case CSMVP_ELIMINATION:
|
||||
mvpReasonToken = "winpanel_mvp_award_kills";
|
||||
break;
|
||||
case CSMVP_BOMBPLANT:
|
||||
mvpReasonToken = "winpanel_mvp_award_bombplant";
|
||||
break;
|
||||
case CSMVP_BOMBDEFUSE:
|
||||
mvpReasonToken = "winpanel_mvp_award_bombdefuse";
|
||||
break;
|
||||
case CSMVP_HOSTAGERESCUE:
|
||||
mvpReasonToken = "winpanel_mvp_award_rescue";
|
||||
break;
|
||||
default:
|
||||
mvpReasonToken = "winpanel_mvp_award";
|
||||
break;
|
||||
}
|
||||
|
||||
wchar_t wszBuf[256], wszPlayerName[64];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode(UTIL_SafeName(pPlayer->GetPlayerName()), wszPlayerName, sizeof(wszPlayerName));
|
||||
|
||||
wchar_t *pReason = (wchar_t *)LocalizeFindSafe( mvpReasonToken );
|
||||
if ( !pReason )
|
||||
{
|
||||
pReason = L"%s1";
|
||||
}
|
||||
|
||||
g_pVGuiLocalize->ConstructString( wszBuf, sizeof( wszBuf ), pReason, 1, wszPlayerName );
|
||||
SetDialogVariable( "MVP_TEXT", wszBuf );
|
||||
|
||||
player_info_t pi;
|
||||
if ( engine->GetPlayerInfo(pPlayer->entindex(), &pi) )
|
||||
{
|
||||
if ( pMVP_Avatar )
|
||||
{
|
||||
pMVP_Avatar->SetDefaultAvatar( GetDefaultAvatarImage( pPlayer ) );
|
||||
pMVP_Avatar->SetPlayer( pPlayer, k_EAvatarSize64x64 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable( "MVP_TEXT", "");
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Allow MVP to be turned off for a server
|
||||
//=============================================================================
|
||||
// The avatar image and its accompanying elements should be hidden if there is no MVP for the round.
|
||||
if ( pMVP_Avatar )
|
||||
{
|
||||
pMVP_Avatar->SetVisible( isThereAnMVP );
|
||||
}
|
||||
ImagePanel* pMVP_AvatarGlow = dynamic_cast<ImagePanel*>(FindChildByName("MVP_AvatarGlow"));
|
||||
if ( pMVP_AvatarGlow )
|
||||
{
|
||||
pMVP_AvatarGlow->SetVisible( isThereAnMVP );
|
||||
}
|
||||
ImagePanel* pMVP_Foreground_Star = dynamic_cast<ImagePanel*>(FindChildByName("MVP_Foreground_Star"));
|
||||
if ( pMVP_Foreground_Star )
|
||||
{
|
||||
pMVP_Foreground_Star->SetVisible( isThereAnMVP );
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
|
||||
void WinPanel_Round::SetFunFactLabel( const wchar *szFunFact )
|
||||
{
|
||||
SetDialogVariable( "FUNFACT", szFunFact );
|
||||
}
|
||||
|
||||
void WinPanel_Round::Show( void )
|
||||
{
|
||||
int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "hide_for_round_panel" );
|
||||
if ( iRenderGroup >= 0)
|
||||
{
|
||||
gHUD.LockRenderGroup( iRenderGroup );
|
||||
}
|
||||
|
||||
m_bShouldBeVisible = true;
|
||||
SetAlpha(255);
|
||||
m_bIsFading = false;
|
||||
}
|
||||
|
||||
void WinPanel_Round::Hide( void )
|
||||
{
|
||||
if ( m_bShouldBeVisible && !m_bIsFading )
|
||||
{
|
||||
m_bIsFading = true;
|
||||
m_fFadeBeginTime = gpGlobals->realtime;
|
||||
}
|
||||
}
|
||||
|
||||
void WinPanel_Round::OnThink()
|
||||
{
|
||||
if ( m_bShouldBeVisible && m_bIsFading )
|
||||
{
|
||||
float fAlpha = 1.0f - (gpGlobals->realtime - m_fFadeBeginTime) / cl_round_win_fade_time.GetFloat();
|
||||
|
||||
if (fAlpha >= 0.0f)
|
||||
{
|
||||
SetAlpha(RoundFloatToInt(fAlpha * 255.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "hide_for_round_panel" );
|
||||
if ( iRenderGroup >= 0 )
|
||||
{
|
||||
gHUD.UnlockRenderGroup( iRenderGroup );
|
||||
}
|
||||
m_bShouldBeVisible = false;
|
||||
SetAlpha(0);
|
||||
m_bIsFading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WinPanel_Round::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetFgColor(Color(251,176,59,255));
|
||||
SetBgColor(Color(0,0,0,212));
|
||||
}
|
||||
|
||||
void WinPanel_Round::OnScreenSizeChanged( int nOldWide, int nOldTall )
|
||||
{
|
||||
BaseClass::OnScreenSizeChanged(nOldWide, nOldTall);
|
||||
|
||||
InitLayout();
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool WinPanel_Round::ShouldDraw( void )
|
||||
{
|
||||
return ( m_bShouldBeVisible && CHudElement::ShouldDraw());
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Create and display a win panel at the end of a round displaying interesting stats and info about the round.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSWINPANEL_ROUND_H
|
||||
#define CSWINPANEL_ROUND_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "VGUI/bordered_panel.h"
|
||||
#include <game/client/iviewport.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "vgui_avatarimage.h"
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class WinPanel_Round : public BorderedPanel, public CHudElement
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( WinPanel_Round, BorderedPanel );
|
||||
|
||||
public:
|
||||
WinPanel_Round(const char *pElementName);
|
||||
~WinPanel_Round();
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Init();
|
||||
virtual void VidInit();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void Paint( void ) {};
|
||||
virtual void OnScreenSizeChanged(int nOldWide, int nOldTall);
|
||||
|
||||
virtual void OnThink();
|
||||
|
||||
void InitLayout();
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
protected:
|
||||
void SetMVP( C_CSPlayer* pPlayer, CSMvpReason_t reason );
|
||||
void SetFunFactLabel( const wchar *szFunFact );
|
||||
|
||||
private:
|
||||
bool m_bShowTimerDefend;
|
||||
bool m_bShowTimerAttack;
|
||||
|
||||
bool m_bShouldBeVisible;
|
||||
|
||||
// fade tracking
|
||||
bool m_bIsFading;
|
||||
float m_fFadeBeginTime;
|
||||
};
|
||||
|
||||
#endif //CSWINPANEL_ROUND_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,65 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
// Author: Matthew D. Campbell (matt@turtlerockstudios.com), 2004
|
||||
|
||||
#include "cbase.h"
|
||||
#include "buy_preset_debug.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BUY_PRESET_DEBUGGING 1
|
||||
#else
|
||||
#define BUY_PRESET_DEBUGGING 0
|
||||
#endif
|
||||
|
||||
#if BUY_PRESET_DEBUGGING
|
||||
|
||||
static ConVar cl_preset_debug( "cl_preset_debug", "0", 0, "Controls debug information about buy presets" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetDebuggingEnabled()
|
||||
{
|
||||
return cl_preset_debug.GetInt() >= 1.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetFullCostDebuggingEnabled()
|
||||
{
|
||||
return cl_preset_debug.GetInt() == 2.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetCurrentCostDebuggingEnabled()
|
||||
{
|
||||
return cl_preset_debug.GetInt() == 3.0f;
|
||||
}
|
||||
|
||||
#else // ! BUY_PRESET_DEBUGGING
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetDebuggingEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetFullCostDebuggingEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
bool IsPresetCurrentCostDebuggingEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // ! BUY_PRESET_DEBUGGING
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,25 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BUY_PRESET_DEBUG_H
|
||||
#define BUY_PRESET_DEBUG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Utility functions for the debugging macros below
|
||||
bool IsPresetDebuggingEnabled(); ///< cl_preset_debug >= 1.0f
|
||||
bool IsPresetFullCostDebuggingEnabled(); ///< cl_preset_debug == 2.0f
|
||||
bool IsPresetCurrentCostDebuggingEnabled(); ///< cl_preset_debug == 3.0f
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Macros for conditional debugging of buy presets
|
||||
#define PRESET_DEBUG if (IsPresetDebuggingEnabled()) DevMsg
|
||||
#define FULLCOST_DEBUG if (IsPresetFullCostDebuggingEnabled()) DevMsg
|
||||
#define CURRENTCOST_DEBUG if (IsPresetCurrentCostDebuggingEnabled()) DevMsg
|
||||
|
||||
#endif // BUY_PRESET_DEBUG_H
|
||||
@@ -1,364 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: BuyPresetWeapon implementation, and misc knowledge relating to weapons
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "buy_preset_debug.h"
|
||||
#include "buy_presets.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "cs_ammodef.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include "c_cs_player.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
struct WeaponDisplayNameInfo
|
||||
{
|
||||
CSWeaponID id;
|
||||
const char *displayName;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// NOTE: Array must be NULL-terminated
|
||||
static WeaponDisplayNameInfo weaponDisplayNameInfo[] =
|
||||
{
|
||||
{ WEAPON_P228, "#Cstrike_TitlesTXT_P228" },
|
||||
{ WEAPON_GLOCK, "#Cstrike_TitlesTXT_Glock18" },
|
||||
{ WEAPON_SCOUT, "#Cstrike_TitlesTXT_Scout" },
|
||||
{ WEAPON_XM1014, "#Cstrike_TitlesTXT_AutoShotgun" },
|
||||
{ WEAPON_MAC10, "#Cstrike_TitlesTXT_Mac10_Short" },
|
||||
{ WEAPON_AUG, "#Cstrike_TitlesTXT_Aug" },
|
||||
{ WEAPON_ELITE, "#Cstrike_TitlesTXT_Beretta96G" },
|
||||
{ WEAPON_FIVESEVEN, "#Cstrike_TitlesTXT_ESFiveSeven" },
|
||||
{ WEAPON_UMP45, "#Cstrike_TitlesTXT_KMUMP45" },
|
||||
{ WEAPON_SG550, "#Cstrike_TitlesTXT_SG550" },
|
||||
{ WEAPON_GALIL, "#Cstrike_TitlesTXT_Galil" },
|
||||
{ WEAPON_FAMAS, "#Cstrike_TitlesTXT_Famas" },
|
||||
{ WEAPON_USP, "#Cstrike_TitlesTXT_USP45" },
|
||||
{ WEAPON_AWP, "#Cstrike_TitlesTXT_ArcticWarfareMagnum" },
|
||||
{ WEAPON_MP5NAVY, "#Cstrike_TitlesTXT_mp5navy" },
|
||||
{ WEAPON_M249, "#Cstrike_TitlesTXT_ESM249" },
|
||||
{ WEAPON_M3, "#Cstrike_TitlesTXT_Leone12" },
|
||||
{ WEAPON_M4A1, "#Cstrike_TitlesTXT_M4A1_Short" },
|
||||
{ WEAPON_TMP, "#Cstrike_TitlesTXT_tmp" },
|
||||
{ WEAPON_G3SG1, "#Cstrike_TitlesTXT_G3SG1" },
|
||||
{ WEAPON_DEAGLE, "#Cstrike_TitlesTXT_DesertEagle" },
|
||||
{ WEAPON_SG552, "#Cstrike_TitlesTXT_SG552" },
|
||||
{ WEAPON_AK47, "#Cstrike_TitlesTXT_AK47" },
|
||||
{ WEAPON_P90, "#Cstrike_TitlesTXT_ESC90" },
|
||||
{ WEAPON_SHIELDGUN, "#Cstrike_TitlesTXT_TactShield" },
|
||||
|
||||
{ WEAPON_NONE, "#Cstrike_CurrentWeapon" }
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the display name for a weapon, based on it's weaponID
|
||||
*/
|
||||
const wchar_t* WeaponIDToDisplayName( CSWeaponID weaponID )
|
||||
{
|
||||
for( int i=0; weaponDisplayNameInfo[i].displayName; ++i )
|
||||
if ( weaponDisplayNameInfo[i].id == weaponID )
|
||||
return g_pVGuiLocalize->Find( weaponDisplayNameInfo[i].displayName );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetWeapon::BuyPresetWeapon()
|
||||
{
|
||||
m_name = NULL;
|
||||
m_weaponID = WEAPON_NONE;
|
||||
m_ammoType = AMMO_CLIPS;
|
||||
m_ammoAmount = 0;
|
||||
m_fillAmmo = true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetWeapon::BuyPresetWeapon( CSWeaponID weaponID )
|
||||
{
|
||||
m_name = WeaponIDToDisplayName( weaponID );
|
||||
m_weaponID = weaponID;
|
||||
m_ammoType = AMMO_CLIPS;
|
||||
m_ammoAmount = (weaponID == WEAPON_NONE) ? 0 : 1;
|
||||
m_fillAmmo = true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
BuyPresetWeapon& BuyPresetWeapon::operator= (const BuyPresetWeapon& other)
|
||||
{
|
||||
m_name = other.m_name;
|
||||
m_weaponID = other.m_weaponID;
|
||||
m_ammoType = other.m_ammoType;
|
||||
m_ammoAmount = other.m_ammoAmount;
|
||||
m_fillAmmo = other.m_fillAmmo;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the WEAPON_* weapon ID (and resets ammo, etc)
|
||||
*/
|
||||
void BuyPresetWeapon::SetWeaponID( CSWeaponID weaponID )
|
||||
{
|
||||
m_name = WeaponIDToDisplayName( weaponID );
|
||||
m_weaponID = weaponID;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the number of clips that will have to be bought for the specified BuyPresetWeapon
|
||||
*/
|
||||
int CalcClipsNeeded( const BuyPresetWeapon *pWeapon, const CCSWeaponInfo *pInfo, const int ammo[MAX_AMMO_TYPES] )
|
||||
{
|
||||
if ( !pWeapon || !pInfo )
|
||||
return 0;
|
||||
|
||||
int maxRounds = GetCSAmmoDef()->MaxCarry( pInfo->iAmmoType );
|
||||
int buySize = GetCSAmmoDef()->GetBuySize( pInfo->iAmmoType );
|
||||
|
||||
int numClips = 0;
|
||||
if ( buySize && pInfo->iAmmoType >= 0 )
|
||||
{
|
||||
switch ( pWeapon->GetAmmoType() )
|
||||
{
|
||||
case AMMO_CLIPS:
|
||||
numClips = pWeapon->GetAmmoAmount();
|
||||
if ( pWeapon->GetWeaponID() == WEAPON_NONE && numClips >= 4 )
|
||||
{
|
||||
numClips = ceil(maxRounds/(float)buySize);
|
||||
}
|
||||
numClips = MIN( ceil(maxRounds/(float)buySize), numClips );
|
||||
|
||||
numClips -= ammo[pInfo->iAmmoType]/buySize;
|
||||
if ( numClips < 0 || ammo[pInfo->iAmmoType] == maxRounds )
|
||||
{
|
||||
numClips = 0;
|
||||
}
|
||||
break;
|
||||
case AMMO_ROUNDS:
|
||||
{
|
||||
int roundsNeeded = pWeapon->GetAmmoAmount() - ammo[pInfo->iAmmoType];
|
||||
if ( roundsNeeded > 0 )
|
||||
{
|
||||
numClips = ceil(roundsNeeded/(float)buySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
numClips = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AMMO_PERCENT:
|
||||
{
|
||||
int roundsNeeded = maxRounds*pWeapon->GetAmmoAmount() - ammo[pInfo->iAmmoType];
|
||||
roundsNeeded *= 0.01f;
|
||||
if ( roundsNeeded > 0 )
|
||||
{
|
||||
numClips = ceil(roundsNeeded/(float)buySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
numClips = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return numClips;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the client can currently buy the weapon according to class/gamemode restrictions. Returns
|
||||
* true also if the player owns the weapon already.
|
||||
*/
|
||||
bool CanBuyWeapon( CSWeaponID currentPrimaryID, CSWeaponID currentSecondaryID, CSWeaponID weaponID )
|
||||
{
|
||||
if ( currentPrimaryID == WEAPON_SHIELDGUN && weaponID == WEAPON_ELITE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( currentSecondaryID == WEAPON_ELITE && weaponID == WEAPON_SHIELDGUN )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return false;
|
||||
|
||||
CCSWeaponInfo *info = GetWeaponInfo( weaponID );
|
||||
if ( !info )
|
||||
return false;
|
||||
|
||||
/// @TODO: assasination maps have a specific set of weapons that can be used in them.
|
||||
if ( info->m_iTeam != TEAM_UNASSIGNED && pPlayer->GetTeamNumber() != info->m_iTeam )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the CSWeaponType is a primary class
|
||||
*/
|
||||
static bool IsPrimaryWeaponClassID( CSWeaponType classId )
|
||||
{
|
||||
switch (classId)
|
||||
{
|
||||
case WEAPONTYPE_SUBMACHINEGUN:
|
||||
case WEAPONTYPE_SHOTGUN:
|
||||
case WEAPONTYPE_MACHINEGUN:
|
||||
case WEAPONTYPE_RIFLE:
|
||||
case WEAPONTYPE_SNIPER_RIFLE:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the weapon ID is for a primary weapon
|
||||
*/
|
||||
static bool IsPrimaryWeaponID( CSWeaponID id )
|
||||
{
|
||||
if ( id == WEAPON_SHIELDGUN )
|
||||
return true;
|
||||
|
||||
CCSWeaponInfo *info = GetWeaponInfo( id );
|
||||
if ( !info )
|
||||
return false;
|
||||
|
||||
return IsPrimaryWeaponClassID( info->m_WeaponType );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the CSWeaponType is a secondary class
|
||||
*/
|
||||
static bool IsSecondaryWeaponClassID( CSWeaponType classId )
|
||||
{
|
||||
return (classId == WEAPONTYPE_PISTOL);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the weapon ID is for a secondary weapon
|
||||
*/
|
||||
static bool IsSecondaryWeaponID( CSWeaponID id )
|
||||
{
|
||||
if ( id == WEAPON_SHIELDGUN )
|
||||
return false;
|
||||
|
||||
CCSWeaponInfo *info = GetWeaponInfo( id );
|
||||
if ( !info )
|
||||
return false;
|
||||
|
||||
return IsSecondaryWeaponClassID( info->m_WeaponType );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Fills the ammo array with the ammo currently owned by the local player
|
||||
*/
|
||||
void FillClientAmmo( int ammo[MAX_AMMO_TYPES] )
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<MAX_AMMO_TYPES; ++i )
|
||||
{
|
||||
ammo[i] = 0;
|
||||
}
|
||||
|
||||
C_CSPlayer *localPlayer = CCSPlayer::GetLocalCSPlayer();
|
||||
if ( !localPlayer )
|
||||
return;
|
||||
|
||||
for ( i=0; i<WEAPON_MAX; ++i )
|
||||
{
|
||||
CSWeaponID gameWeaponID = (CSWeaponID)i;
|
||||
if ( gameWeaponID == WEAPON_NONE || gameWeaponID >= WEAPON_SHIELDGUN )
|
||||
continue;
|
||||
|
||||
const CCSWeaponInfo *info = GetWeaponInfo( gameWeaponID );
|
||||
if ( !info )
|
||||
continue;
|
||||
|
||||
int clientAmmoType = info->iAmmoType;
|
||||
int clientAmmoCount = localPlayer->GetAmmoCount( clientAmmoType );
|
||||
if ( clientAmmoCount > 0 )
|
||||
{
|
||||
ammo[ clientAmmoType ] = MAX( ammo[ clientAmmoType ], clientAmmoCount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the weapon in the specified slot
|
||||
//-----------------------------------------------------------------------------
|
||||
CWeaponCSBase *GetWeaponInSlot( int iSlot, int iSlotPos )
|
||||
{
|
||||
C_CSPlayer *player = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !player )
|
||||
return NULL;
|
||||
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
CWeaponCSBase *pWeapon = dynamic_cast< CWeaponCSBase * >(player->GetWeapon(i));
|
||||
|
||||
if ( pWeapon == NULL )
|
||||
continue;
|
||||
|
||||
if ( pWeapon->GetSlot() == iSlot && pWeapon->GetPosition() == iSlotPos )
|
||||
return pWeapon;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the client's WEAPON_* value for the currently owned weapon, or WEAPON_NONE if no weapon is owned
|
||||
*/
|
||||
CSWeaponID GetClientWeaponID( bool primary )
|
||||
{
|
||||
C_CSPlayer *localPlayer = CCSPlayer::GetLocalCSPlayer();
|
||||
if ( !localPlayer )
|
||||
return WEAPON_NONE;
|
||||
|
||||
int slot = (primary)?0:1;
|
||||
CWeaponCSBase *pWeapon = GetWeaponInSlot( slot, slot );
|
||||
if ( !pWeapon )
|
||||
return WEAPON_NONE;
|
||||
|
||||
return pWeapon->GetWeaponID();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,454 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "buy_preset_debug.h"
|
||||
#include "buy_presets.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "game/client/iviewport.h"
|
||||
#include "filesystem.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include "c_cs_player.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BuyPresetManager *TheBuyPresets = NULL;
|
||||
|
||||
#if USE_BUY_PRESETS
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
ConVar cl_buy_favorite_quiet( "cl_buy_favorite_quiet", "0", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_CAN_EXECUTE, "Skips the prompt when saving a buy favorite in the buy menu" );
|
||||
ConVar cl_buy_favorite_nowarn( "cl_buy_favorite_nowarn", "0", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_CAN_EXECUTE, "Skips the error prompt when saving an invalid buy favorite" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
static void PrintBuyPresetUsage( void )
|
||||
{
|
||||
if ( TheBuyPresets->GetNumPresets() )
|
||||
{
|
||||
Msg( "usage: cl_buy_favorite <1...%d>\n", TheBuyPresets->GetNumPresets() );
|
||||
for ( int i=0; i<TheBuyPresets->GetNumPresets(); ++i )
|
||||
{
|
||||
const BuyPreset *preset = TheBuyPresets->GetPreset( i );
|
||||
if ( preset && preset->GetName() && preset->GetName()[0] )
|
||||
{
|
||||
char buffer[64];
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( preset->GetName(), buffer, sizeof( buffer ) );
|
||||
Msg( " %d. %s\n", i+1, buffer );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "cl_buy_favorite: no favorites are defined\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Callback function for handling the "cl_buy_favorite" command
|
||||
*/
|
||||
CON_COMMAND_F( cl_buy_favorite, "Purchase a favorite weapon/equipment loadout", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !engine->IsConnected() )
|
||||
return;
|
||||
|
||||
if ( !TheBuyPresets )
|
||||
TheBuyPresets = new BuyPresetManager();
|
||||
|
||||
if ( args.ArgC() != 2 )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite: no favorite specified\n" );
|
||||
PrintBuyPresetUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
int presetIndex = atoi( args[1] ) - 1;
|
||||
if ( presetIndex < 0 || presetIndex >= TheBuyPresets->GetNumPresets() )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite: favorite %d doesn't exist\n", presetIndex );
|
||||
PrintBuyPresetUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
TheBuyPresets->PurchasePreset( presetIndex );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Callback function for handling the "cl_buy_favorite_set" command
|
||||
*/
|
||||
CON_COMMAND_F( cl_buy_favorite_set, "Saves the current loadout as a favorite", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !engine->IsConnected() )
|
||||
return;
|
||||
|
||||
if ( !TheBuyPresets )
|
||||
TheBuyPresets = new BuyPresetManager();
|
||||
|
||||
if ( args.ArgC() != 2 )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite_set: no favorite specified\n" );
|
||||
PrintBuyPresetUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
int presetIndex = atoi( args[ 1 ] ) - 1;
|
||||
if ( presetIndex < 0 || presetIndex >= TheBuyPresets->GetNumPresets() )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite_set: favorite %d doesn't exist\n", presetIndex );
|
||||
PrintBuyPresetUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
const BuyPreset *preset = TheBuyPresets->GetPreset( presetIndex );
|
||||
if ( !preset )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponSet ws;
|
||||
TheBuyPresets->GetCurrentLoadout( &ws );
|
||||
BuyPreset newPreset( *preset );
|
||||
newPreset.ReplaceSet( 0, ws );
|
||||
|
||||
TheBuyPresets->SetPreset( presetIndex, &newPreset );
|
||||
TheBuyPresets->Save();
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.Updated" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Callback function for handling the "cl_buy_favorite_reset" command
|
||||
*/
|
||||
void __CmdFunc_BuyPresetsReset(void)
|
||||
{
|
||||
if ( !engine->IsConnected() )
|
||||
return;
|
||||
|
||||
if ( !TheBuyPresets )
|
||||
TheBuyPresets = new BuyPresetManager();
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer || ( pPlayer->GetTeamNumber() != TEAM_CT && pPlayer->GetTeamNumber() != TEAM_TERRORIST ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TheBuyPresets->ResetEditToDefaults();
|
||||
TheBuyPresets->SetPresets( TheBuyPresets->GetEditPresets() );
|
||||
TheBuyPresets->Save();
|
||||
}
|
||||
ConCommand cl_buy_favorite_reset( "cl_buy_favorite_reset", __CmdFunc_BuyPresetsReset, "Reset favorite loadouts to the default", FCVAR_CLIENTCMD_CAN_EXECUTE );
|
||||
#endif // USE_BUY_PRESETS
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Creates the BuyPresetManager singleton
|
||||
*/
|
||||
BuyPresetManager::BuyPresetManager()
|
||||
{
|
||||
m_loadedTeam = TEAM_UNASSIGNED;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Resets the BuyPresetManager, loading BuyPresets from disk. If no presets are defined, it loads the
|
||||
* default presets instead.
|
||||
*/
|
||||
void BuyPresetManager::VerifyLoadedTeam( void )
|
||||
{
|
||||
#if USE_BUY_PRESETS
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
int playerTeam = pPlayer->GetTeamNumber();
|
||||
|
||||
if ( playerTeam == m_loadedTeam )
|
||||
return;
|
||||
|
||||
if ( playerTeam != TEAM_CT && playerTeam != TEAM_TERRORIST )
|
||||
return;
|
||||
|
||||
m_presets.RemoveAll();
|
||||
|
||||
const char *filename = "cfg/BuyPresets_TER.vdf";
|
||||
if ( playerTeam == TEAM_CT )
|
||||
{
|
||||
filename = "cfg/BuyPresets_CT.vdf";
|
||||
}
|
||||
|
||||
KeyValues *data;
|
||||
KeyValues *presetKey;
|
||||
data = new KeyValues( "Presets" );
|
||||
bool fileExists = data->LoadFromFile( filesystem, filename, NULL );
|
||||
|
||||
presetKey = data->GetFirstSubKey();
|
||||
while ( presetKey )
|
||||
{
|
||||
BuyPreset preset;
|
||||
preset.Parse( presetKey );
|
||||
m_presets.AddToTail(preset);
|
||||
|
||||
presetKey = presetKey->GetNextKey();
|
||||
}
|
||||
|
||||
if ( !m_presets.Count() )
|
||||
{
|
||||
const char *filename = "cfg/BuyPresetsDefault_TER.vdf";
|
||||
if ( playerTeam == TEAM_CT )
|
||||
{
|
||||
filename = "cfg/BuyPresetsDefault_CT.vdf";
|
||||
}
|
||||
|
||||
KeyValues *data;
|
||||
KeyValues *presetKey;
|
||||
data = new KeyValues( "Presets" );
|
||||
data->LoadFromFile( filesystem, filename, NULL );
|
||||
|
||||
presetKey = data->GetFirstSubKey();
|
||||
while ( presetKey )
|
||||
{
|
||||
BuyPreset preset;
|
||||
preset.Parse( presetKey );
|
||||
m_presets.AddToTail(preset);
|
||||
|
||||
presetKey = presetKey->GetNextKey();
|
||||
}
|
||||
|
||||
data->deleteThis();
|
||||
}
|
||||
|
||||
// Guarantee we have at least this many presets, even if they are blank
|
||||
while ( m_presets.Count() < NUM_PRESETS )
|
||||
{
|
||||
BuyPreset preset;
|
||||
m_presets.AddToTail(preset);
|
||||
}
|
||||
|
||||
data->deleteThis();
|
||||
m_editPresets = m_presets;
|
||||
|
||||
if ( !fileExists )
|
||||
Save();
|
||||
#endif // USE_BUY_PRESETS
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Loads the default presets into the editing presets (e.g. when hitting the "Use Defaults" button)
|
||||
*/
|
||||
void BuyPresetManager::ResetEditToDefaults( void )
|
||||
{
|
||||
#if USE_BUY_PRESETS
|
||||
VerifyLoadedTeam();
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
int playerTeam = pPlayer->GetTeamNumber();
|
||||
|
||||
if ( playerTeam != TEAM_CT && playerTeam != TEAM_TERRORIST )
|
||||
return;
|
||||
|
||||
m_editPresets.RemoveAll();
|
||||
|
||||
const char *filename = "cfg/BuyPresetsDefault_TER.vdf";
|
||||
if ( playerTeam == TEAM_CT )
|
||||
{
|
||||
filename = "cfg/BuyPresetsDefault_CT.vdf";
|
||||
}
|
||||
|
||||
KeyValues *data;
|
||||
KeyValues *presetKey;
|
||||
data = new KeyValues( "Presets" );
|
||||
data->LoadFromFile( filesystem, filename, NULL );
|
||||
|
||||
presetKey = data->GetFirstSubKey();
|
||||
while ( presetKey )
|
||||
{
|
||||
BuyPreset preset;
|
||||
preset.Parse( presetKey );
|
||||
m_editPresets.AddToTail(preset);
|
||||
|
||||
presetKey = presetKey->GetNextKey();
|
||||
}
|
||||
|
||||
data->deleteThis();
|
||||
#endif // USE_BUY_PRESETS
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Saves the current BuyPresets to disk
|
||||
*/
|
||||
void BuyPresetManager::Save()
|
||||
{
|
||||
#if USE_BUY_PRESETS
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
const char *filename = "cfg/BuyPresets_TER.vdf";
|
||||
switch ( pPlayer->GetTeamNumber() )
|
||||
{
|
||||
case TEAM_CT:
|
||||
filename = "cfg/BuyPresets_CT.vdf";
|
||||
break;
|
||||
case TEAM_TERRORIST:
|
||||
filename = "cfg/BuyPresets_TER.vdf";
|
||||
break;
|
||||
default:
|
||||
return; // don't bother saving presets unless we're on a team
|
||||
}
|
||||
|
||||
KeyValues *data = new KeyValues( "Presets" );
|
||||
for( int i=0; i<m_presets.Count(); ++i )
|
||||
{
|
||||
m_presets[i].Save( data );
|
||||
}
|
||||
data->SaveToFile( filesystem, filename, NULL );
|
||||
data->deleteThis();
|
||||
#endif // USE_BUY_PRESETS
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the specified "live" preset, or NULL if it doesn't exist
|
||||
*/
|
||||
const BuyPreset * BuyPresetManager::GetPreset( int index ) const
|
||||
{
|
||||
if ( index < 0 || index >= m_presets.Count() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_presets[index]);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void BuyPresetManager::SetPreset( int index, const BuyPreset *preset )
|
||||
{
|
||||
if ( index < 0 || index >= m_presets.Count() || !preset )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_presets[index] = *preset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the specified editing preset, or NULL if it doesn't exist
|
||||
*/
|
||||
BuyPreset * BuyPresetManager::GetEditPreset( int index )
|
||||
{
|
||||
if ( index < 0 || index >= m_editPresets.Count() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_editPresets[index]);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Generates and sends buy commands to buy a specific preset
|
||||
*/
|
||||
void BuyPresetManager::PurchasePreset( int presetIndex )
|
||||
{
|
||||
if ( presetIndex >= 0 && presetIndex < m_presets.Count() )
|
||||
{
|
||||
const BuyPreset *preset = &(m_presets[presetIndex]);
|
||||
|
||||
int setIndex;
|
||||
for ( setIndex = 0; setIndex < preset->GetNumSets(); ++setIndex )
|
||||
{
|
||||
// Try to buy this weapon set.
|
||||
const WeaponSet *itemSet = preset->GetSet( setIndex );
|
||||
if ( itemSet )
|
||||
{
|
||||
int currentCost;
|
||||
WeaponSet currentSet;
|
||||
itemSet->GetCurrent( currentCost, currentSet );
|
||||
if ( currentCost > 0 )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite: buying %ls for a total of $%d.\n",
|
||||
preset->GetName(),
|
||||
currentCost );
|
||||
char buf[BUY_PRESET_COMMAND_LEN];
|
||||
currentSet.GenerateBuyCommands( buf );
|
||||
|
||||
// Send completed string
|
||||
PRESET_DEBUG( "%s\n", buf );
|
||||
engine->ClientCmd( buf );
|
||||
return;
|
||||
}
|
||||
else if ( currentCost == 0 )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.AlreadyBought" );
|
||||
}
|
||||
|
||||
// We have everything already. Let the player know.
|
||||
if ( setIndex == 0 )
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite: already have a complete %ls set.\n", preset->GetName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
PRESET_DEBUG( "cl_buy_favorite: can't afford anything better from %ls.\n", preset->GetName() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.CantBuy" );
|
||||
}
|
||||
|
||||
PRESET_DEBUG( "cl_buy_favorite: can't afford anything better from %ls.\n", preset->GetName() );
|
||||
return;
|
||||
}
|
||||
|
||||
// We failed to buy anything. Let the player know.
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pPlayer->EmitSound( "BuyPreset.CantBuy" );
|
||||
}
|
||||
|
||||
PRESET_DEBUG( "cl_buy_favorite: preset %d doesn't exist.\n", presetIndex );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -1,276 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BUY_PRESETS_H
|
||||
#define BUY_PRESETS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define USE_BUY_PRESETS 1
|
||||
|
||||
/**
|
||||
* CLASS STRUCTURE:
|
||||
* Buy presets are managed by TheBuyPresetManager, which has a list of BuyPreset objects.
|
||||
* Each BuyPreset has a list of fallback WeaponSets. Each WeaponSet is a complete set of
|
||||
* weapons and equipment that could be purchased by a buy preset.
|
||||
*
|
||||
* BUYING:
|
||||
* When purchasing a buy preset, the fallback WeaponSets are considered in order from first
|
||||
* to last. When one is deemed to be purchasable, the buy commands are generated and
|
||||
* processing stops.
|
||||
*
|
||||
* EDITING:
|
||||
* When editing buy presets, TheBuyPresetManager maintains a second list of BuyPresets, to
|
||||
* allow an all-or-nothing undo system. The editing is done on two main VGUI menus: a
|
||||
* list of the four main buy presets (CBuyPresetEditMainMenu), and a menu showing the
|
||||
* fallbacks for a single preset (CBuyPresetEditOutfitListMenu).
|
||||
*
|
||||
* Presets and fallbacks can be copied, created, deleted, etc from these pages. From the
|
||||
* fallback menu, a wizard can edit the contents of a fallback, specifying primary weapon,
|
||||
* pistol, and equipment.
|
||||
*/
|
||||
|
||||
#include "weapon_csbase.h"
|
||||
#include <KeyValues.h>
|
||||
#include <utlvector.h>
|
||||
|
||||
class BuyPreset;
|
||||
class CCSWeaponInfo;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
enum BuyPresetStringSizes
|
||||
{
|
||||
BUY_PRESET_COMMAND_LEN = 256,
|
||||
MaxBuyPresetName = 64,
|
||||
MaxBuyPresetImageFname = 64,
|
||||
};
|
||||
|
||||
enum AmmoSizeType
|
||||
{
|
||||
AMMO_PERCENT,
|
||||
AMMO_CLIPS,
|
||||
AMMO_ROUNDS
|
||||
};
|
||||
|
||||
enum { NUM_PRESETS = 4 };
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* A BuyPresetWeapon stores the mp.dll version of the WeaponID, the increment for buying ammo (clips, rounds, etc),
|
||||
* the number of increments to buy, etc. This is the basic info for buying a weapon that is present in an
|
||||
* item set.
|
||||
*/
|
||||
class BuyPresetWeapon
|
||||
{
|
||||
public:
|
||||
BuyPresetWeapon();
|
||||
BuyPresetWeapon( CSWeaponID weaponID );
|
||||
BuyPresetWeapon& operator= (const BuyPresetWeapon& other);
|
||||
|
||||
const wchar_t* GetName() const { return m_name; } ///< Returns the display name corresponding to the weapon ID
|
||||
CSWeaponID GetWeaponID() const { return m_weaponID; } ///< Returns the WEAPON_* weapon ID
|
||||
void SetWeaponID( CSWeaponID weaponID ); ///< Sets the WEAPON_* weapon ID (and resets ammo, etc)
|
||||
|
||||
void SetAmmoType( AmmoSizeType ammoType ) { m_ammoType = ammoType; } ///< Sets the ammo type - percent (unused), clips, or rounds (unused)
|
||||
void SetAmmoAmount( int ammoAmount ) { m_ammoAmount = ammoAmount; } ///< Sets the amount of ammo, in units relevant to the ammo type
|
||||
void SetFillAmmo( bool fill ) { m_fillAmmo = fill; } ///< Sets whether the weapon's ammo should be topped off
|
||||
|
||||
AmmoSizeType GetAmmoType() const { return m_ammoType; } ///< Returns ammo type - percent (unused), clips, or rounds (unused)
|
||||
int GetAmmoAmount() const { return m_ammoAmount; } ///< Returns the amount of ammo, in units relevant to the ammo type
|
||||
bool GetFillAmmo() const { return m_fillAmmo; } ///< Returns true if the weapon's ammo should be topped off
|
||||
|
||||
protected:
|
||||
const wchar_t *m_name;
|
||||
CSWeaponID m_weaponID;
|
||||
AmmoSizeType m_ammoType;
|
||||
int m_ammoAmount;
|
||||
bool m_fillAmmo;
|
||||
};
|
||||
|
||||
typedef CUtlVector< BuyPresetWeapon > BuyPresetWeaponList;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* A WeaponSet is part of a buy preset. Each buy preset is composed of a series of (fallback) WeaponSets.
|
||||
* The WeaponSet contains a snapshot of a set of weapons and equipment that should be bought.
|
||||
*/
|
||||
class WeaponSet
|
||||
{
|
||||
public:
|
||||
WeaponSet();
|
||||
|
||||
void GetCurrent( int& cost, WeaponSet& ws ) const; ///< Generates a WeaponSet containing only items that would be bought right now
|
||||
void GetFromScratch( int& cost, WeaponSet& ws ) const; ///< Generates a WeaponSet containing everything that would be bought from scratch
|
||||
|
||||
void GenerateBuyCommands( char command[BUY_PRESET_COMMAND_LEN] ) const; ///< Generates a list of commands to buy the current WeaponSet.
|
||||
|
||||
int FullCost() const; ///< Calculates the full cost of the WeaponSet, including all optional items
|
||||
|
||||
void Reset( void );
|
||||
|
||||
const BuyPresetWeapon& GetPrimaryWeapon() const { return m_primaryWeapon; }
|
||||
const BuyPresetWeapon& GetSecondaryWeapon() const { return m_secondaryWeapon; }
|
||||
|
||||
BuyPresetWeapon m_primaryWeapon;
|
||||
BuyPresetWeapon m_secondaryWeapon;
|
||||
|
||||
// Equipment --------------------------------
|
||||
int m_armor;
|
||||
bool m_helmet;
|
||||
bool m_smokeGrenade;
|
||||
bool m_HEGrenade;
|
||||
int m_flashbangs;
|
||||
bool m_defuser;
|
||||
bool m_nightvision;
|
||||
};
|
||||
|
||||
typedef CUtlVector< WeaponSet > WeaponSetList;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The BuyPreset is a complete representation of a buy preset. Essentially, it consists of the preset name,
|
||||
* whether or not the preset is used for autobuy, and a list of fallback WeaponSets.
|
||||
*/
|
||||
class BuyPreset
|
||||
{
|
||||
public:
|
||||
BuyPreset();
|
||||
~BuyPreset();
|
||||
BuyPreset(const BuyPreset& other);
|
||||
|
||||
void SetName( const wchar_t *name );
|
||||
const wchar_t * GetName() const { return m_name; }
|
||||
|
||||
void Parse( KeyValues *data ); ///< Populates data from a KeyValues structure, for loading
|
||||
void Save( KeyValues *data ); ///< Fills in a KeyValues structure with data, for saving
|
||||
|
||||
int GetNumSets() const { return m_weaponList.Count(); } ///< Returns the number of fallback WeaponSets
|
||||
const WeaponSet * GetSet( int index ) const; ///< Returns the specified fallback WeaponSet, or NULL if it doesn't exist
|
||||
|
||||
int FullCost() const; ///< Calculates the full cost of the preset, which is exactly the full cost of the first fallback WeaponSet
|
||||
|
||||
// editing functions --------------------
|
||||
void DeleteSet( int index ); ///< Deletes a fallback
|
||||
void SwapSet( int firstIndex, int secondIndex ); ///< Switches the order of two fallbacks
|
||||
void ReplaceSet( int index, const WeaponSet& weaponSet ); ///< Replaces a fallback with the supplied WeaponSet
|
||||
|
||||
private:
|
||||
wchar_t m_name[MaxBuyPresetName];
|
||||
|
||||
WeaponSetList m_weaponList;
|
||||
};
|
||||
|
||||
typedef CUtlVector< BuyPreset > BuyPresetList;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The BuyPresetManager singleton manages saving/loading/buying the individual BuyPresets. It also tracks the
|
||||
* ownership of some items that aren't explicitly known by the client (defuser, nightvision).
|
||||
*
|
||||
* Two sets of BuyPresets are maintained - the live set used for purchasing, and a set that is acted upon for
|
||||
* editing. This provides the basic save changes/abandon changes ability when editing presets.
|
||||
*/
|
||||
class BuyPresetManager
|
||||
{
|
||||
public:
|
||||
BuyPresetManager();
|
||||
|
||||
void Save();
|
||||
|
||||
void PurchasePreset( int presetIndex ); ///< Generates and sends buy commands to buy a specific preset
|
||||
|
||||
int GetNumPresets() { VerifyLoadedTeam(); return m_presets.Count(); }
|
||||
const BuyPreset * GetPreset( int index ) const; ///< Returns the specified "live" preset, or NULL if it doesn't exist
|
||||
void SetPreset( int index, const BuyPreset *preset );
|
||||
|
||||
void SetPresets( const BuyPresetList& presets ) { m_presets = presets; }
|
||||
|
||||
void SetEditPresets( const BuyPresetList& presets ) { m_editPresets = presets; }
|
||||
int GetNumEditPresets() const { return m_editPresets.Count(); }
|
||||
|
||||
BuyPreset * GetEditPreset( int index ); ///< Returns the specified editing preset, or NULL if it doesn't exist
|
||||
const CUtlVector< BuyPreset >& GetEditPresets() const { return m_editPresets; }
|
||||
|
||||
void ResetEditPresets() { m_editPresets = m_presets; } ///< Resets the editing presets to the live presets (e.g. when starting editing)
|
||||
void ResetEditToDefaults( void ); ///< Loads the default presets into the editing presets (e.g. when hitting the "Use Defaults" button)
|
||||
|
||||
void GetCurrentLoadout( WeaponSet *weaponSet );
|
||||
|
||||
private:
|
||||
BuyPresetList m_presets; ///< Current (live) presets
|
||||
BuyPresetList m_editPresets; ///< BuyPresets used when editing
|
||||
|
||||
int m_loadedTeam;
|
||||
void VerifyLoadedTeam( void );
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
extern BuyPresetManager *TheBuyPresets;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Functions for controlling the display of the various buy preset editing menus. Opening one closes any
|
||||
* others open.
|
||||
*/
|
||||
enum { REOPEN_YES, REOPEN_NO, REOPEN_DONTCHANGE }; ///< Determines if we need to re-open the buy menu when done editing.
|
||||
void ShowBuyPresetMainMenu( bool runUpdate, int reopenBuyMenu ); ///< Open the main preset editing menu
|
||||
void ShowBuyPresetEditMenu( int presetIndex ); ///< Open the menu for editing the list of fallbacks for an individual preset
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the image filename for a given WEAPON_* weapon ID. Primary is specified because WEAPON_NONE returns
|
||||
* separate images for primary and pistol, to facilitate showing an outline version for "Current Weapon".
|
||||
*/
|
||||
const char *ImageFnameFromWeaponID( CSWeaponID weaponID, bool isPrimary );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Constructs a list of weapons that will satisfy the any unfinished weapon-specific career tasks:
|
||||
* 1. If there are no unfinished career tasks, the source list is returned
|
||||
* 2. If there are unfinished career tasks, all weapons that can be used for the tasks are added
|
||||
* to the front of the list. This list of career weapons is sorted according to the order of
|
||||
* weapons in the source list, so that if any weapons in the source list can be used for career
|
||||
* tasks, they will be.
|
||||
*/
|
||||
BuyPresetWeaponList CareerWeaponList( const BuyPresetWeaponList& source, bool isPrimary, CSWeaponID currentClientID );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the number of clips that will have to be bought for the specified BuyPresetWeapon
|
||||
*/
|
||||
class CCSWeaponInfo;
|
||||
int CalcClipsNeeded( const BuyPresetWeapon *pWeapon, const CCSWeaponInfo *pInfo, const int ammo[MAX_AMMO_TYPES] );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Fills the ammo array with the ammo currently owned by the local player
|
||||
*/
|
||||
void FillClientAmmo( int ammo[MAX_AMMO_TYPES] );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the client can currently buy the weapon according to class/gamemode restrictions. Returns
|
||||
* true also if the player owns the weapon already.
|
||||
*/
|
||||
bool CanBuyWeapon( CSWeaponID currentPrimaryID, CSWeaponID currentSecondaryID, CSWeaponID weaponID );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the display name for a weapon, based on it's weaponID
|
||||
*/
|
||||
const wchar_t* WeaponIDToDisplayName( CSWeaponID weaponID );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// If our weapon is NONE, we want to be able to buy up to this many clips for the current gun we're holding
|
||||
enum { NUM_CLIPS_FOR_CURRENT = 4 };
|
||||
|
||||
#if USE_BUY_PRESETS
|
||||
extern ConVar cl_buy_favorite_quiet;
|
||||
extern ConVar cl_buy_favorite_nowarn;
|
||||
#endif // USE_BUY_PRESETS
|
||||
|
||||
#endif // BUY_PRESETS_H
|
||||
@@ -1,518 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side C_CHostage class
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_cs_hostage.h"
|
||||
#include <bitbuf.h>
|
||||
#include "ragdoll_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
#undef CHostage
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static float HOSTAGE_HEAD_TURN_RATE = 130;
|
||||
|
||||
|
||||
CUtlVector< C_CHostage* > g_Hostages;
|
||||
CUtlVector< EHANDLE > g_HostageRagdolls;
|
||||
|
||||
extern ConVar g_ragdoll_fadespeed;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const int NumInterestingPoseParameters = 6;
|
||||
static const char* InterestingPoseParameters[NumInterestingPoseParameters] =
|
||||
{
|
||||
"body_yaw",
|
||||
"spine_yaw",
|
||||
"neck_trans",
|
||||
"head_pitch",
|
||||
"head_yaw",
|
||||
"head_roll"
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_LowViolenceHostageDeathModel : public C_BaseAnimating
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_LowViolenceHostageDeathModel, C_BaseAnimating );
|
||||
|
||||
C_LowViolenceHostageDeathModel();
|
||||
~C_LowViolenceHostageDeathModel();
|
||||
|
||||
bool SetupLowViolenceModel( C_CHostage *pHostage );
|
||||
|
||||
// fading out
|
||||
void ClientThink( void );
|
||||
|
||||
private:
|
||||
|
||||
void Interp_Copy( VarMapping_t *pDest, CBaseEntity *pSourceEntity, VarMapping_t *pSrc );
|
||||
|
||||
float m_flFadeOutStart;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_LowViolenceHostageDeathModel::C_LowViolenceHostageDeathModel()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_LowViolenceHostageDeathModel::~C_LowViolenceHostageDeathModel()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_LowViolenceHostageDeathModel::Interp_Copy( VarMapping_t *pDest, CBaseEntity *pSourceEntity, VarMapping_t *pSrc )
|
||||
{
|
||||
if ( !pDest || !pSrc )
|
||||
return;
|
||||
|
||||
if ( pDest->m_Entries.Count() != pSrc->m_Entries.Count() )
|
||||
{
|
||||
Assert( false );
|
||||
return;
|
||||
}
|
||||
|
||||
int c = pDest->m_Entries.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
pDest->m_Entries[ i ].watcher->Copy( pSrc->m_Entries[i].watcher );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_LowViolenceHostageDeathModel::SetupLowViolenceModel( C_CHostage *pHostage )
|
||||
{
|
||||
const model_t *model = pHostage->GetModel();
|
||||
const char *pModelName = modelinfo->GetModelName( model );
|
||||
if ( InitializeAsClientEntity( pModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
|
||||
{
|
||||
Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Play the low-violence death anim
|
||||
if ( LookupSequence( "death1" ) == -1 )
|
||||
{
|
||||
Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_flFadeOutStart = gpGlobals->curtime + 5.0f;
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
|
||||
SetSequence( LookupSequence( "death1" ) );
|
||||
ForceClientSideAnimationOn();
|
||||
|
||||
if ( pHostage && !pHostage->IsDormant() )
|
||||
{
|
||||
SetNetworkOrigin( pHostage->GetAbsOrigin() );
|
||||
SetAbsOrigin( pHostage->GetAbsOrigin() );
|
||||
SetAbsVelocity( pHostage->GetAbsVelocity() );
|
||||
|
||||
// move my current model instance to the ragdoll's so decals are preserved.
|
||||
pHostage->SnatchModelInstance( this );
|
||||
|
||||
SetAbsAngles( pHostage->GetRenderAngles() );
|
||||
SetNetworkAngles( pHostage->GetRenderAngles() );
|
||||
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
|
||||
// update pose parameters
|
||||
float poseParameter[MAXSTUDIOPOSEPARAM];
|
||||
GetPoseParameters( pStudioHdr, poseParameter );
|
||||
for ( int i=0; i<NumInterestingPoseParameters; ++i )
|
||||
{
|
||||
int poseParameterIndex = LookupPoseParameter( pStudioHdr, InterestingPoseParameters[i] );
|
||||
SetPoseParameter( pStudioHdr, poseParameterIndex, poseParameter[poseParameterIndex] );
|
||||
}
|
||||
}
|
||||
|
||||
Interp_Reset( GetVarMapping() );
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_LowViolenceHostageDeathModel::ClientThink( void )
|
||||
{
|
||||
if ( m_flFadeOutStart > gpGlobals->curtime )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int iAlpha = GetRenderColor().a;
|
||||
|
||||
iAlpha = MAX( iAlpha - ( g_ragdoll_fadespeed.GetInt() * gpGlobals->frametime ), 0 );
|
||||
|
||||
SetRenderMode( kRenderTransAlpha );
|
||||
SetRenderColorA( iAlpha );
|
||||
|
||||
if ( iAlpha == 0 )
|
||||
{
|
||||
Release();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::RecvProxy_Rescued( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
C_CHostage *pHostage= (C_CHostage *) pStruct;
|
||||
|
||||
bool isRescued = pData->m_Value.m_Int != 0;
|
||||
|
||||
if ( isRescued && !pHostage->m_isRescued )
|
||||
{
|
||||
// hostage was rescued
|
||||
pHostage->m_flDeadOrRescuedTime = gpGlobals->curtime + 2;
|
||||
pHostage->SetRenderMode( kRenderGlow );
|
||||
pHostage->SetNextClientThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
pHostage->m_isRescued = isRescued;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_CHostage, DT_CHostage, CHostage)
|
||||
|
||||
RecvPropInt( RECVINFO( m_isRescued ), 0, C_CHostage::RecvProxy_Rescued ),
|
||||
RecvPropInt( RECVINFO( m_iHealth ) ),
|
||||
RecvPropInt( RECVINFO( m_iMaxHealth ) ),
|
||||
RecvPropInt( RECVINFO( m_lifeState ) ),
|
||||
|
||||
RecvPropEHandle( RECVINFO( m_leader ) ),
|
||||
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CHostage::C_CHostage()
|
||||
{
|
||||
g_Hostages.AddToTail( this );
|
||||
|
||||
m_flDeadOrRescuedTime = 0.0;
|
||||
m_flLastBodyYaw = 0;
|
||||
m_createdLowViolenceRagdoll = false;
|
||||
|
||||
// TODO: Get IK working on the steep slopes CS has, then enable it on characters.
|
||||
m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK;
|
||||
|
||||
// set the model so the PlayerAnimState uses the Hostage activities/sequences
|
||||
SetModelName( "models/Characters/Hostage_01.mdl" );
|
||||
|
||||
m_PlayerAnimState = CreateHostageAnimState( this, this, LEGANIM_8WAY, false );
|
||||
|
||||
m_leader = NULL;
|
||||
m_blinkTimer.Invalidate();
|
||||
m_seq = -1;
|
||||
|
||||
m_flCurrentHeadPitch = 0;
|
||||
m_flCurrentHeadYaw = 0;
|
||||
|
||||
m_eyeAttachment = -1;
|
||||
m_chestAttachment = -1;
|
||||
m_headYawPoseParam = -1;
|
||||
m_headPitchPoseParam = -1;
|
||||
m_lookAt = Vector( 0, 0, 0 );
|
||||
m_isInit = false;
|
||||
m_lookAroundTimer.Invalidate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CHostage::~C_CHostage()
|
||||
{
|
||||
g_Hostages.FindAndRemove( this );
|
||||
m_PlayerAnimState->Release();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::Spawn( void )
|
||||
{
|
||||
m_leader = NULL;
|
||||
m_blinkTimer.Invalidate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_CHostage::ShouldDraw( void )
|
||||
{
|
||||
if ( m_createdLowViolenceRagdoll )
|
||||
return false;
|
||||
|
||||
return BaseClass::ShouldDraw();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseAnimating * C_CHostage::BecomeRagdollOnClient()
|
||||
{
|
||||
if ( g_RagdollLVManager.IsLowViolence() )
|
||||
{
|
||||
// We can't just play the low-violence anim ourselves, since we're about to be deleted by the server.
|
||||
// So, let's create another entity that can play the anim and stick around.
|
||||
C_LowViolenceHostageDeathModel *pLowViolenceModel = new C_LowViolenceHostageDeathModel();
|
||||
m_createdLowViolenceRagdoll = pLowViolenceModel->SetupLowViolenceModel( this );
|
||||
if ( m_createdLowViolenceRagdoll )
|
||||
{
|
||||
UpdateVisibility();
|
||||
g_HostageRagdolls.AddToTail( pLowViolenceModel );
|
||||
return pLowViolenceModel;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we don't have a low-violence death anim, don't create a ragdoll.
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
C_BaseAnimating *pRagdoll = BaseClass::BecomeRagdollOnClient();
|
||||
if ( pRagdoll && pRagdoll != this )
|
||||
{
|
||||
g_HostageRagdolls.AddToTail( pRagdoll );
|
||||
}
|
||||
return pRagdoll;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
* Set up attachment and pose param indices.
|
||||
* We can't do this in the constructor or Spawn() because the data isn't
|
||||
* there yet.
|
||||
*/
|
||||
void C_CHostage::Initialize( )
|
||||
{
|
||||
m_eyeAttachment = LookupAttachment( "eyes" );
|
||||
m_chestAttachment = LookupAttachment( "chest" );
|
||||
|
||||
m_headYawPoseParam = LookupPoseParameter( "head_yaw" );
|
||||
GetPoseParameterRange( m_headYawPoseParam, m_headYawMin, m_headYawMax );
|
||||
|
||||
m_headPitchPoseParam = LookupPoseParameter( "head_pitch" );
|
||||
GetPoseParameterRange( m_headPitchPoseParam, m_headPitchMin, m_headPitchMax );
|
||||
|
||||
m_bodyYawPoseParam = LookupPoseParameter( "body_yaw" );
|
||||
GetPoseParameterRange( m_bodyYawPoseParam, m_bodyYawMin, m_bodyYawMax );
|
||||
|
||||
Vector pos;
|
||||
QAngle angles;
|
||||
|
||||
if (!GetAttachment( m_eyeAttachment, pos, angles ))
|
||||
{
|
||||
m_vecViewOffset = Vector( 0, 0, 50.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vecViewOffset = pos - GetAbsOrigin();
|
||||
}
|
||||
|
||||
|
||||
if (!GetAttachment( m_chestAttachment, pos, angles ))
|
||||
{
|
||||
m_lookAt = Vector( 0, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector forward;
|
||||
AngleVectors( angles, &forward );
|
||||
m_lookAt = EyePosition() + 100.0f * forward;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CWeaponCSBase* C_CHostage::CSAnim_GetActiveWeapon()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_CHostage::CSAnim_CanMove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
* Orient head and eyes towards m_lookAt.
|
||||
*/
|
||||
void C_CHostage::UpdateLookAt( CStudioHdr *pStudioHdr )
|
||||
{
|
||||
if (!m_isInit)
|
||||
{
|
||||
m_isInit = true;
|
||||
Initialize( );
|
||||
}
|
||||
|
||||
// head yaw
|
||||
if (m_headYawPoseParam < 0 || m_bodyYawPoseParam < 0 || m_headPitchPoseParam < 0)
|
||||
return;
|
||||
|
||||
if (GetLeader())
|
||||
{
|
||||
m_lookAt = GetLeader()->EyePosition();
|
||||
}
|
||||
|
||||
// orient eyes
|
||||
m_viewtarget = m_lookAt;
|
||||
|
||||
// blinking
|
||||
if (m_blinkTimer.IsElapsed())
|
||||
{
|
||||
m_blinktoggle = !m_blinktoggle;
|
||||
m_blinkTimer.Start( RandomFloat( 1.5f, 4.0f ) );
|
||||
}
|
||||
|
||||
// Figure out where we want to look in world space.
|
||||
QAngle desiredAngles;
|
||||
Vector to = m_lookAt - EyePosition();
|
||||
VectorAngles( to, desiredAngles );
|
||||
|
||||
// Figure out where our body is facing in world space.
|
||||
float poseParams[MAXSTUDIOPOSEPARAM];
|
||||
GetPoseParameters( pStudioHdr, poseParams );
|
||||
QAngle bodyAngles( 0, 0, 0 );
|
||||
bodyAngles[YAW] = GetRenderAngles()[YAW] + RemapVal( poseParams[m_bodyYawPoseParam], 0, 1, m_bodyYawMin, m_bodyYawMax );
|
||||
|
||||
|
||||
float flBodyYawDiff = bodyAngles[YAW] - m_flLastBodyYaw;
|
||||
m_flLastBodyYaw = bodyAngles[YAW];
|
||||
|
||||
|
||||
// Set the head's yaw.
|
||||
float desired = AngleNormalize( desiredAngles[YAW] - bodyAngles[YAW] );
|
||||
desired = clamp( desired, m_headYawMin, m_headYawMax );
|
||||
m_flCurrentHeadYaw = ApproachAngle( desired, m_flCurrentHeadYaw, HOSTAGE_HEAD_TURN_RATE * gpGlobals->frametime );
|
||||
|
||||
// Counterrotate the head from the body rotation so it doesn't rotate past its target.
|
||||
m_flCurrentHeadYaw = AngleNormalize( m_flCurrentHeadYaw - flBodyYawDiff );
|
||||
desired = clamp( desired, m_headYawMin, m_headYawMax );
|
||||
|
||||
SetPoseParameter( pStudioHdr, m_headYawPoseParam, m_flCurrentHeadYaw );
|
||||
|
||||
|
||||
// Set the head's yaw.
|
||||
desired = AngleNormalize( desiredAngles[PITCH] );
|
||||
desired = clamp( desired, m_headPitchMin, m_headPitchMax );
|
||||
|
||||
m_flCurrentHeadPitch = ApproachAngle( desired, m_flCurrentHeadPitch, HOSTAGE_HEAD_TURN_RATE * gpGlobals->frametime );
|
||||
m_flCurrentHeadPitch = AngleNormalize( m_flCurrentHeadPitch );
|
||||
SetPoseParameter( pStudioHdr, m_headPitchPoseParam, m_flCurrentHeadPitch );
|
||||
|
||||
SetPoseParameter( pStudioHdr, "head_roll", 0.0f );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
* Look around at various interesting things
|
||||
*/
|
||||
void C_CHostage::LookAround( void )
|
||||
{
|
||||
if (GetLeader() == NULL && m_lookAroundTimer.IsElapsed())
|
||||
{
|
||||
m_lookAroundTimer.Start( RandomFloat( 3.0f, 15.0f ) );
|
||||
|
||||
Vector forward;
|
||||
QAngle angles = GetAbsAngles();
|
||||
angles[ YAW ] += RandomFloat( m_headYawMin, m_headYawMax );
|
||||
angles[ PITCH ] += RandomFloat( m_headPitchMin, m_headPitchMax );
|
||||
AngleVectors( angles, &forward );
|
||||
m_lookAt = EyePosition() + 100.0f * forward;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::UpdateClientSideAnimation()
|
||||
{
|
||||
if (IsDormant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_PlayerAnimState->Update( GetAbsAngles()[YAW], GetAbsAngles()[PITCH] );
|
||||
|
||||
// initialize pose parameters
|
||||
char *setToZero[] =
|
||||
{
|
||||
"spine_yaw",
|
||||
"head_roll"
|
||||
};
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
for ( int i=0; i < ARRAYSIZE( setToZero ); i++ )
|
||||
{
|
||||
int index = LookupPoseParameter( pStudioHdr, setToZero[i] );
|
||||
if ( index >= 0 )
|
||||
SetPoseParameter( pStudioHdr, index, 0 );
|
||||
}
|
||||
|
||||
// orient head and eyes
|
||||
LookAround();
|
||||
UpdateLookAt( pStudioHdr );
|
||||
|
||||
|
||||
BaseClass::UpdateClientSideAnimation();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::ClientThink()
|
||||
{
|
||||
C_BaseCombatCharacter::ClientThink();
|
||||
|
||||
int speed = 2;
|
||||
int a = m_clrRender->a;
|
||||
|
||||
a = MAX( 0, a - speed );
|
||||
|
||||
SetRenderColorA( a );
|
||||
|
||||
if ( m_clrRender->a > 0 )
|
||||
{
|
||||
SetNextClientThink( gpGlobals->curtime + 0.001 );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_CHostage::WasRecentlyKilledOrRescued( void )
|
||||
{
|
||||
return ( gpGlobals->curtime < m_flDeadOrRescuedTime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::OnPreDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnPreDataChanged( updateType );
|
||||
|
||||
m_OldLifestate = m_lifeState;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
if ( m_OldLifestate != m_lifeState )
|
||||
{
|
||||
if( m_lifeState == LIFE_DEAD || m_lifeState == LIFE_DYING )
|
||||
m_flDeadOrRescuedTime = gpGlobals->curtime + 2;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName )
|
||||
{
|
||||
static ConVar *violence_hblood = cvar->FindVar( "violence_hblood" );
|
||||
if ( violence_hblood && !violence_hblood->GetBool() )
|
||||
return;
|
||||
|
||||
BaseClass::ImpactTrace( pTrace, iDamageType, pCustomImpactName );
|
||||
}
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side CHostage class
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_CHOSTAGE_H
|
||||
#define C_CHOSTAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_ai_basenpc.h"
|
||||
#include "utlvector.h"
|
||||
#include "util_shared.h"
|
||||
#include "cs_playeranimstate.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
|
||||
// for shared code
|
||||
#define CHostage C_CHostage
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The client-side implementation of the Hostage
|
||||
*/
|
||||
class C_CHostage : public C_BaseCombatCharacter, public ICSPlayerAnimStateHelpers
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_CHostage, C_BaseCombatCharacter );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_CHostage();
|
||||
virtual ~C_CHostage();
|
||||
|
||||
// ICSPlayerAnimState overrides.
|
||||
public:
|
||||
virtual CWeaponCSBase* CSAnim_GetActiveWeapon();
|
||||
virtual bool CSAnim_CanMove();
|
||||
|
||||
public:
|
||||
virtual void Spawn( void );
|
||||
virtual void UpdateClientSideAnimation();
|
||||
|
||||
void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
bool IsRescued( void ) { return m_isRescued; }
|
||||
bool WasRecentlyKilledOrRescued( void );
|
||||
|
||||
int GetHealth( void ) const { return m_iHealth; }
|
||||
int GetMaxHealth( void ) const { return m_iMaxHealth; }
|
||||
|
||||
virtual void ClientThink( void );
|
||||
|
||||
C_CSPlayer *GetLeader( void ) const; // return who we are following or NULL
|
||||
|
||||
virtual C_BaseAnimating * BecomeRagdollOnClient();
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
|
||||
private:
|
||||
int m_OldLifestate;
|
||||
int m_iMaxHealth;
|
||||
|
||||
ICSPlayerAnimState *m_PlayerAnimState;
|
||||
|
||||
CNetworkVar( EHANDLE, m_leader ); // who we are following, or NULL
|
||||
|
||||
CNetworkVar( bool, m_isRescued );
|
||||
float m_flDeadOrRescuedTime;
|
||||
static void RecvProxy_Rescued( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
CountdownTimer m_blinkTimer;
|
||||
|
||||
Vector m_lookAt; // point in space we are looking at
|
||||
void UpdateLookAt( CStudioHdr *pStudioHdr ); // orient head and eyes towards m_lookAt
|
||||
void LookAround( void ); // look around at various interesting things
|
||||
CountdownTimer m_lookAroundTimer;
|
||||
|
||||
bool m_isInit;
|
||||
void Initialize( void ); // set up attachment and pose param indices
|
||||
|
||||
int m_eyeAttachment;
|
||||
int m_chestAttachment;
|
||||
|
||||
int m_bodyYawPoseParam;
|
||||
float m_bodyYawMin;
|
||||
float m_bodyYawMax;
|
||||
|
||||
int m_headYawPoseParam;
|
||||
float m_headYawMin;
|
||||
float m_headYawMax;
|
||||
float m_flCurrentHeadYaw;
|
||||
float m_flLastBodyYaw;
|
||||
|
||||
int m_headPitchPoseParam;
|
||||
float m_headPitchMin;
|
||||
float m_headPitchMax;
|
||||
float m_flCurrentHeadPitch;
|
||||
|
||||
int m_seq;
|
||||
|
||||
bool m_createdLowViolenceRagdoll;
|
||||
|
||||
private:
|
||||
C_CHostage( const C_CHostage & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
inline C_CSPlayer *C_CHostage::GetLeader( void ) const
|
||||
{
|
||||
return ToCSPlayer( m_leader.m_Value );
|
||||
}
|
||||
|
||||
|
||||
extern CUtlVector< C_CHostage* > g_Hostages;
|
||||
extern CUtlVector< EHANDLE > g_HostageRagdolls;
|
||||
|
||||
|
||||
#endif // C_CHOSTAGE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,419 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_CS_PLAYER_H
|
||||
#define C_CS_PLAYER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "cs_playeranimstate.h"
|
||||
#include "c_baseplayer.h"
|
||||
#include "cs_shareddefs.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "baseparticleentity.h"
|
||||
#include "beamdraw.h"
|
||||
|
||||
|
||||
class C_PhysicsProp;
|
||||
|
||||
extern ConVar cl_disablefreezecam;
|
||||
|
||||
class CAddonModel
|
||||
{
|
||||
public:
|
||||
CHandle<C_BaseAnimating> m_hEnt; // The model for the addon.
|
||||
int m_iAddon; // One of the ADDON_ bits telling which model this is.
|
||||
int m_iAttachmentPoint; // Which attachment point on the player model this guy is on.
|
||||
};
|
||||
|
||||
|
||||
|
||||
class C_CSPlayer : public C_BasePlayer, public ICSPlayerAnimStateHelpers
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_CSPlayer, C_BasePlayer );
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_INTERPOLATION();
|
||||
|
||||
C_CSPlayer();
|
||||
~C_CSPlayer();
|
||||
|
||||
virtual void Simulate();
|
||||
|
||||
bool HasDefuser() const;
|
||||
|
||||
void GiveDefuser();
|
||||
void RemoveDefuser();
|
||||
|
||||
bool HasNightVision() const;
|
||||
|
||||
static C_CSPlayer* GetLocalCSPlayer();
|
||||
CSPlayerState State_Get() const;
|
||||
|
||||
virtual float GetMinFOV() const;
|
||||
|
||||
// Get how much $$$ this guy has.
|
||||
int GetAccount() const;
|
||||
|
||||
// Returns one of the CS_CLASS_ enums.
|
||||
int PlayerClass() const;
|
||||
|
||||
bool IsInBuyZone();
|
||||
bool CanShowTeamMenu() const; // Returns true if we're allowed to show the team menu right now.
|
||||
|
||||
// Get the amount of armor the player has.
|
||||
int ArmorValue() const;
|
||||
bool HasHelmet() const;
|
||||
int GetCurrentAssaultSuitPrice();
|
||||
|
||||
virtual const QAngle& EyeAngles();
|
||||
virtual const QAngle& GetRenderAngles();
|
||||
virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
|
||||
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
|
||||
virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
|
||||
virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
|
||||
|
||||
virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
|
||||
|
||||
// Get the ID target entity index. The ID target is the player that is behind our crosshairs, used to
|
||||
// display the player's name.
|
||||
int GetIDTarget() const;
|
||||
|
||||
virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
|
||||
virtual void ClientThink();
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t type );
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
virtual bool Interpolate( float currentTime );
|
||||
virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
|
||||
virtual surfacedata_t * GetFootstepSurface( const Vector &origin, const char *surfaceName );
|
||||
virtual void ValidateModelIndex( void );
|
||||
|
||||
virtual int GetMaxHealth() const;
|
||||
|
||||
bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
|
||||
|
||||
virtual void UpdateClientSideAnimation();
|
||||
virtual void ProcessMuzzleFlashEvent();
|
||||
|
||||
virtual const Vector& GetRenderOrigin( void );
|
||||
|
||||
bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
|
||||
|
||||
CUtlVector< C_BaseParticleEntity* > m_SmokeGrenades;
|
||||
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
|
||||
|
||||
virtual C_BaseAnimating * BecomeRagdollOnClient();
|
||||
virtual IRagdoll* GetRepresentativeRagdoll() const;
|
||||
|
||||
void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
|
||||
|
||||
// Have this player play the sounds from his view model's reload animation.
|
||||
void PlayReloadEffect();
|
||||
|
||||
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
|
||||
bool HasC4( void );
|
||||
|
||||
virtual void CreateLightEffects( void ) {} //no dimlight effects
|
||||
|
||||
// Sometimes the server wants to update the client's cycle to get the two to run in sync (for proper hit detection)
|
||||
virtual void SetServerIntendedCycle( float intended ) { m_serverIntendedCycle = intended; }
|
||||
virtual float GetServerIntendedCycle( void ) { return m_serverIntendedCycle; }
|
||||
|
||||
virtual bool ShouldReceiveProjectedTextures( int flags )
|
||||
{
|
||||
return ( this != C_BasePlayer::GetLocalPlayer() );
|
||||
}
|
||||
|
||||
void ClearSoundEvents()
|
||||
{
|
||||
m_SoundEvents.RemoveAll();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Returns whether this player is dominating or is being dominated by the specified player
|
||||
//=============================================================================
|
||||
bool IsPlayerDominated( int iPlayerIndex );
|
||||
bool IsPlayerDominatingMe( int iPlayerIndex );
|
||||
|
||||
virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
|
||||
virtual float GetDeathCamInterpolationTime();
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
|
||||
// Called by shared code.
|
||||
public:
|
||||
|
||||
// ICSPlayerAnimState overrides.
|
||||
virtual CWeaponCSBase* CSAnim_GetActiveWeapon();
|
||||
virtual bool CSAnim_CanMove();
|
||||
|
||||
|
||||
void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
|
||||
|
||||
|
||||
// Implemented in shared code.
|
||||
public:
|
||||
virtual float GetPlayerMaxSpeed();
|
||||
|
||||
void GetBulletTypeParameters(
|
||||
int iBulletType,
|
||||
float &fPenetrationPower,
|
||||
float &flPenetrationDistance );
|
||||
|
||||
void FireBullet(
|
||||
Vector vecSrc,
|
||||
const QAngle &shootAngles,
|
||||
float flDistance,
|
||||
int iPenetration,
|
||||
int iBulletType,
|
||||
int iDamage,
|
||||
float flRangeModifier,
|
||||
CBaseEntity *pevAttacker,
|
||||
bool bDoEffects,
|
||||
float xSpread, float ySpread );
|
||||
|
||||
void KickBack(
|
||||
float up_base,
|
||||
float lateral_base,
|
||||
float up_modifier,
|
||||
float lateral_modifier,
|
||||
float up_max,
|
||||
float lateral_max,
|
||||
int direction_change );
|
||||
|
||||
// Returns true if the player is allowed to move.
|
||||
bool CanMove() const;
|
||||
|
||||
void OnJump( float fImpulse );
|
||||
void OnLand( float fVelocity );
|
||||
|
||||
bool HasC4() const; // Is this player carrying a C4 bomb?
|
||||
bool IsVIP() const; // Is this player the VIP?
|
||||
|
||||
virtual void SetAnimation( PLAYER_ANIM playerAnim );
|
||||
|
||||
|
||||
public:
|
||||
|
||||
void UpdateIDTarget( void );
|
||||
void RemoveAddonModels( void );
|
||||
void UpdateMinModels( void );
|
||||
|
||||
void SetActivity( Activity eActivity );
|
||||
Activity GetActivity( void ) const;
|
||||
|
||||
ICSPlayerAnimState *GetPlayerAnimState() { return m_PlayerAnimState; }
|
||||
|
||||
public:
|
||||
|
||||
ICSPlayerAnimState *m_PlayerAnimState;
|
||||
|
||||
// Used to control animation state.
|
||||
Activity m_Activity;
|
||||
|
||||
// Predicted variables.
|
||||
CNetworkVar( bool, m_bResumeZoom );
|
||||
CNetworkVar( int , m_iLastZoom ); // after firing a shot, set the FOV to 90, and after showing the animation, bring the FOV back to last zoom level.
|
||||
CNetworkVar( CSPlayerState, m_iPlayerState ); // SupraFiend: this gives the current state in the joining process, the states are listed above
|
||||
CNetworkVar( bool, m_bIsDefusing ); // tracks whether this player is currently defusing a bomb
|
||||
CNetworkVar( bool, m_bInBombZone );
|
||||
CNetworkVar( bool, m_bInBuyZone );
|
||||
CNetworkVar( int, m_iThrowGrenadeCounter ); // used to trigger grenade throw animations.
|
||||
|
||||
bool IsInHostageRescueZone( void );
|
||||
|
||||
// This is a combination of the ADDON_ flags in cs_shareddefs.h.
|
||||
CNetworkVar( int, m_iAddonBits );
|
||||
|
||||
// Clients don't know about holstered weapons, so we need to be told about them here
|
||||
CNetworkVar( int, m_iPrimaryAddon );
|
||||
CNetworkVar( int, m_iSecondaryAddon );
|
||||
|
||||
// How long the progress bar takes to get to the end. If this is 0, then the progress bar
|
||||
// should not be drawn.
|
||||
CNetworkVar( int, m_iProgressBarDuration );
|
||||
|
||||
// When the progress bar should start.
|
||||
CNetworkVar( float, m_flProgressBarStartTime );
|
||||
|
||||
CNetworkVar( float, m_flStamina );
|
||||
CNetworkVar( int, m_iDirection ); // The current lateral kicking direction; 1 = right, 0 = left
|
||||
CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
|
||||
CNetworkVar( bool, m_bNightVisionOn );
|
||||
CNetworkVar( bool, m_bHasNightVision );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [dwenger] Added for fun-fact support
|
||||
//=============================================================================
|
||||
|
||||
//CNetworkVar( bool, m_bPickedUpDefuser );
|
||||
//CNetworkVar( bool, m_bDefusedWithPickedUpKit );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
CNetworkVar( float, m_flVelocityModifier );
|
||||
|
||||
bool m_bDetected;
|
||||
|
||||
EHANDLE m_hRagdoll;
|
||||
|
||||
CWeaponCSBase* GetActiveCSWeapon() const;
|
||||
CWeaponCSBase* GetCSWeapon( CSWeaponID id ) const;
|
||||
|
||||
virtual ShadowType_t ShadowCastType();
|
||||
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
bool HasShield( void ) { return m_bHasShield; }
|
||||
bool IsShieldDrawn( void ) { return m_bShieldDrawn; }
|
||||
void SetShieldDrawnState( bool bState ) { m_bShieldDrawn = bState; }
|
||||
#else
|
||||
bool HasShield( void ) { return false; }
|
||||
bool IsShieldDrawn( void ) { return false; }
|
||||
void SetShieldDrawnState( bool bState ) {}
|
||||
#endif
|
||||
|
||||
float m_flNightVisionAlpha;
|
||||
|
||||
float m_flFlashAlpha;
|
||||
float m_flFlashBangTime;
|
||||
CNetworkVar( float, m_flFlashMaxAlpha );
|
||||
CNetworkVar( float, m_flFlashDuration );
|
||||
|
||||
// Having the RecvProxy in the player allows us to keep the var private
|
||||
static void RecvProxy_CycleLatch( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
// Bots and hostages auto-duck during jumps
|
||||
bool m_duckUntilOnGround;
|
||||
|
||||
Vector m_lastStandingPos; // used by the gamemovement code for finding ladders
|
||||
|
||||
void SurpressLadderChecks( const Vector& pos, const Vector& normal );
|
||||
bool CanGrabLadder( const Vector& pos, const Vector& normal );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
//=============================================================================
|
||||
|
||||
// [tj] checks if this player has another given player on their Steam friends list.
|
||||
bool HasPlayerAsFriend(C_CSPlayer* player);
|
||||
|
||||
private:
|
||||
CountdownTimer m_ladderSurpressionTimer;
|
||||
Vector m_lastLadderNormal;
|
||||
Vector m_lastLadderPos;
|
||||
|
||||
void UpdateRadar();
|
||||
void UpdateSoundEvents();
|
||||
|
||||
void CreateAddonModel( int i );
|
||||
void UpdateAddonModels();
|
||||
|
||||
void PushawayThink();
|
||||
|
||||
int m_iAccount;
|
||||
bool m_bHasHelmet;
|
||||
int m_iClass;
|
||||
int m_ArmorValue;
|
||||
QAngle m_angEyeAngles;
|
||||
bool m_bHasDefuser;
|
||||
bool m_bInHostageRescueZone;
|
||||
float m_fNextThinkPushAway;
|
||||
|
||||
bool m_bPlayingFreezeCamSound;
|
||||
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
bool m_bHasShield;
|
||||
bool m_bShieldDrawn;
|
||||
#endif
|
||||
|
||||
Vector m_vecRagdollVelocity;
|
||||
|
||||
CInterpolatedVar< QAngle > m_iv_angEyeAngles;
|
||||
|
||||
// ID Target
|
||||
int m_iIDEntIndex;
|
||||
CountdownTimer m_delayTargetIDTimer;
|
||||
|
||||
// Show the ID target after the cursor leaves the entity
|
||||
int m_iOldIDEntIndex;
|
||||
CountdownTimer m_holdTargetIDTimer;
|
||||
|
||||
void ReleaseFlashlight( void );
|
||||
Beam_t *m_pFlashlightBeam;
|
||||
|
||||
class CCSSoundEvent
|
||||
{
|
||||
public:
|
||||
string_t m_SoundName;
|
||||
float m_flEventTime; // Play the event when gpGlobals->curtime goes past this.
|
||||
};
|
||||
CUtlLinkedList<CCSSoundEvent,int> m_SoundEvents;
|
||||
|
||||
|
||||
// This is the list of addons hanging off the guy (grenades, C4, nightvision, etc).
|
||||
CUtlLinkedList<CAddonModel, int> m_AddonModels;
|
||||
int m_iLastAddonBits;
|
||||
int m_iLastPrimaryAddon;
|
||||
int m_iLastSecondaryAddon;
|
||||
|
||||
int m_cycleLatch; // server periodically updates this to fix up our anims, here it is a 4 bit fixed point
|
||||
float m_serverIntendedCycle; // server periodically updates this to fix up our anims, here it is the float we want, or -1 for no override
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [tj] Network variables that track who are dominating and being dominated by
|
||||
//=============================================================================
|
||||
|
||||
CNetworkArray( bool, m_bPlayerDominated, MAX_PLAYERS+1 ); // array of state per other player whether player is dominating other players
|
||||
CNetworkArray( bool, m_bPlayerDominatingMe, MAX_PLAYERS+1 ); // array of state per other player whether other players are dominating this player
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
|
||||
|
||||
C_CSPlayer( const C_CSPlayer & );
|
||||
};
|
||||
|
||||
C_CSPlayer* GetLocalOrInEyeCSPlayer( void );
|
||||
|
||||
inline C_CSPlayer *ToCSPlayer( CBaseEntity *pEntity )
|
||||
{
|
||||
if ( !pEntity || !pEntity->IsPlayer() )
|
||||
return NULL;
|
||||
|
||||
return dynamic_cast<C_CSPlayer*>( pEntity );
|
||||
}
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class IImage;
|
||||
}
|
||||
|
||||
vgui::IImage* GetDefaultAvatarImage( C_BasePlayer *pPlayer );
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // C_CS_PLAYER_H
|
||||
@@ -1,206 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: CS's custom C_PlayerResource
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include <shareddefs.h>
|
||||
#include <cs_shareddefs.h>
|
||||
#include "hud.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_CS_PlayerResource, DT_CSPlayerResource, CCSPlayerResource)
|
||||
RecvPropInt( RECVINFO( m_iPlayerC4 ) ),
|
||||
RecvPropInt( RECVINFO( m_iPlayerVIP ) ),
|
||||
RecvPropVector( RECVINFO(m_vecC4) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_bHostageAlive), RecvPropInt( RECVINFO(m_bHostageAlive[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_isHostageFollowingSomeone), RecvPropInt( RECVINFO(m_isHostageFollowingSomeone[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_iHostageEntityIDs), RecvPropInt( RECVINFO(m_iHostageEntityIDs[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_iHostageX), RecvPropInt( RECVINFO(m_iHostageX[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_iHostageY), RecvPropInt( RECVINFO(m_iHostageY[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_iHostageZ), RecvPropInt( RECVINFO(m_iHostageZ[0]))),
|
||||
RecvPropVector( RECVINFO(m_bombsiteCenterA) ),
|
||||
RecvPropVector( RECVINFO(m_bombsiteCenterB) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hostageRescueX), RecvPropInt( RECVINFO(m_hostageRescueX[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hostageRescueY), RecvPropInt( RECVINFO(m_hostageRescueY[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hostageRescueZ), RecvPropInt( RECVINFO(m_hostageRescueZ[0]))),
|
||||
RecvPropInt( RECVINFO( m_bBombSpotted ) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_bPlayerSpotted), RecvPropInt( RECVINFO(m_bPlayerSpotted[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_iMVPs), RecvPropInt( RECVINFO(m_iMVPs[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_bHasDefuser), RecvPropInt( RECVINFO(m_bHasDefuser[0]))),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_szClan), RecvPropString( RECVINFO(m_szClan[0]))),
|
||||
END_RECV_TABLE()
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CS_PlayerResource::C_CS_PlayerResource()
|
||||
{
|
||||
m_Colors[TEAM_TERRORIST] = COLOR_RED;
|
||||
m_Colors[TEAM_CT] = COLOR_BLUE;
|
||||
memset( m_iMVPs, 0, sizeof( m_iMVPs ) );
|
||||
memset( m_bHasDefuser, 0, sizeof( m_bHasDefuser ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CS_PlayerResource::~C_CS_PlayerResource()
|
||||
{
|
||||
}
|
||||
|
||||
bool C_CS_PlayerResource::IsVIP(int iIndex )
|
||||
{
|
||||
return m_iPlayerVIP == iIndex;
|
||||
}
|
||||
|
||||
bool C_CS_PlayerResource::HasC4(int iIndex )
|
||||
{
|
||||
return m_iPlayerC4 == iIndex;
|
||||
}
|
||||
|
||||
bool C_CS_PlayerResource::IsHostageAlive(int iIndex)
|
||||
{
|
||||
if ( iIndex < 0 || iIndex >= MAX_HOSTAGES )
|
||||
return false;
|
||||
|
||||
return m_bHostageAlive[iIndex];
|
||||
}
|
||||
|
||||
bool C_CS_PlayerResource::IsHostageFollowingSomeone(int iIndex)
|
||||
{
|
||||
if ( iIndex < 0 || iIndex >= MAX_HOSTAGES )
|
||||
return false;
|
||||
|
||||
return m_isHostageFollowingSomeone[iIndex];
|
||||
}
|
||||
|
||||
int C_CS_PlayerResource::GetHostageEntityID(int iIndex)
|
||||
{
|
||||
if ( iIndex < 0 || iIndex >= MAX_HOSTAGES )
|
||||
return -1;
|
||||
|
||||
return m_iHostageEntityIDs[iIndex];
|
||||
}
|
||||
|
||||
const Vector C_CS_PlayerResource::GetHostagePosition( int iIndex )
|
||||
{
|
||||
if ( iIndex < 0 || iIndex >= MAX_HOSTAGES )
|
||||
return vec3_origin;
|
||||
|
||||
Vector ret;
|
||||
|
||||
ret.x = m_iHostageX[iIndex];
|
||||
ret.y = m_iHostageY[iIndex];
|
||||
ret.z = m_iHostageZ[iIndex];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Vector C_CS_PlayerResource::GetC4Postion()
|
||||
{
|
||||
if ( m_iPlayerC4 > 0 )
|
||||
{
|
||||
// C4 is carried by player
|
||||
C_BasePlayer *pPlayer = UTIL_PlayerByIndex( m_iPlayerC4 );
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
return pPlayer->GetAbsOrigin();
|
||||
}
|
||||
}
|
||||
|
||||
// C4 is lying on ground
|
||||
return m_vecC4;
|
||||
}
|
||||
|
||||
const Vector C_CS_PlayerResource::GetBombsiteAPosition()
|
||||
{
|
||||
return m_bombsiteCenterA;
|
||||
}
|
||||
|
||||
const Vector C_CS_PlayerResource::GetBombsiteBPosition()
|
||||
{
|
||||
return m_bombsiteCenterB;
|
||||
}
|
||||
|
||||
const Vector C_CS_PlayerResource::GetHostageRescuePosition( int iIndex )
|
||||
{
|
||||
if ( iIndex < 0 || iIndex >= MAX_HOSTAGE_RESCUES )
|
||||
return vec3_origin;
|
||||
|
||||
Vector ret;
|
||||
|
||||
ret.x = m_hostageRescueX[iIndex];
|
||||
ret.y = m_hostageRescueY[iIndex];
|
||||
ret.z = m_hostageRescueZ[iIndex];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int C_CS_PlayerResource::GetPlayerClass( int iIndex )
|
||||
{
|
||||
if ( !IsConnected( iIndex ) )
|
||||
{
|
||||
return CS_CLASS_NONE;
|
||||
}
|
||||
|
||||
return m_iPlayerClasses[ iIndex ];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool C_CS_PlayerResource::IsBombSpotted( void ) const
|
||||
{
|
||||
return m_bBombSpotted;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool C_CS_PlayerResource::IsPlayerSpotted( int iIndex )
|
||||
{
|
||||
if ( !IsConnected( iIndex ) )
|
||||
return false;
|
||||
|
||||
return m_bPlayerSpotted[iIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *C_CS_PlayerResource::GetClanTag( int iIndex )
|
||||
{
|
||||
if ( iIndex < 1 || iIndex > MAX_PLAYERS )
|
||||
{
|
||||
Assert( false );
|
||||
return "";
|
||||
}
|
||||
|
||||
if ( !IsConnected( iIndex ) )
|
||||
return "";
|
||||
|
||||
return m_szClan[iIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_CS_PlayerResource::GetNumMVPs( int iIndex )
|
||||
{
|
||||
if ( !IsConnected( iIndex ) )
|
||||
return false;
|
||||
|
||||
return m_iMVPs[iIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_CS_PlayerResource::HasDefuser( int iIndex )
|
||||
{
|
||||
if ( !IsConnected( iIndex ) )
|
||||
return false;
|
||||
|
||||
return m_bHasDefuser[iIndex];
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: CS's custom C_PlayerResource
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_CS_PLAYERRESOURCE_H
|
||||
#define C_CS_PLAYERRESOURCE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
#include "c_playerresource.h"
|
||||
|
||||
class C_CS_PlayerResource : public C_PlayerResource
|
||||
{
|
||||
DECLARE_CLASS( C_CS_PlayerResource, C_PlayerResource );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_CS_PlayerResource();
|
||||
virtual ~C_CS_PlayerResource();
|
||||
|
||||
bool IsVIP(int iIndex );
|
||||
bool HasC4(int iIndex );
|
||||
bool IsHostageAlive(int iIndex);
|
||||
bool IsHostageFollowingSomeone(int iIndex);
|
||||
const Vector GetHostagePosition( int index );
|
||||
int GetHostageEntityID(int iIndex);
|
||||
const Vector GetC4Postion();
|
||||
const Vector GetBombsiteAPosition();
|
||||
const Vector GetBombsiteBPosition();
|
||||
const Vector GetHostageRescuePosition( int index );
|
||||
int GetPlayerClass( int iIndex );
|
||||
|
||||
bool IsBombSpotted( void ) const;
|
||||
bool IsPlayerSpotted( int iIndex );
|
||||
|
||||
const char *GetClanTag( int index );
|
||||
|
||||
int GetNumMVPs( int iIndex );
|
||||
bool HasDefuser( int iIndex );
|
||||
|
||||
protected:
|
||||
|
||||
int m_iPlayerC4; // entity index of C4 carrier or 0
|
||||
int m_iPlayerVIP; // entity index of VIP player or 0
|
||||
Vector m_vecC4; // position of C4
|
||||
Vector m_bombsiteCenterA;
|
||||
Vector m_bombsiteCenterB;
|
||||
|
||||
bool m_bHostageAlive[MAX_HOSTAGES];
|
||||
bool m_isHostageFollowingSomeone[MAX_HOSTAGES];
|
||||
int m_iHostageEntityIDs[MAX_HOSTAGES];
|
||||
int m_iHostageX[MAX_HOSTAGES];
|
||||
int m_iHostageY[MAX_HOSTAGES];
|
||||
int m_iHostageZ[MAX_HOSTAGES];
|
||||
|
||||
int m_hostageRescueX[MAX_HOSTAGE_RESCUES];
|
||||
int m_hostageRescueY[MAX_HOSTAGE_RESCUES];
|
||||
int m_hostageRescueZ[MAX_HOSTAGE_RESCUES];
|
||||
|
||||
bool m_bBombSpotted;
|
||||
bool m_bPlayerSpotted[ MAX_PLAYERS + 1 ];
|
||||
int m_iPlayerClasses[ MAX_PLAYERS + 1 ];
|
||||
|
||||
char m_szClan[MAX_PLAYERS+1][MAX_CLAN_TAG_LENGTH];
|
||||
|
||||
int m_iMVPs[ MAX_PLAYERS + 1 ];
|
||||
bool m_bHasDefuser[ MAX_PLAYERS + 1 ];
|
||||
};
|
||||
|
||||
|
||||
#endif // C_CS_PLAYERRESOURCE_H
|
||||
@@ -1,33 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side C_CSTeam class
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "hud.h"
|
||||
#include "recvproxy.h"
|
||||
#include "c_cs_team.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_CSTeam, DT_CSTeam, CCSTeam)
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CSTeam::C_CSTeam()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CSTeam::~C_CSTeam()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side CTFTeam class
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_CS_TEAM_H
|
||||
#define C_CS_TEAM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_team.h"
|
||||
#include "shareddefs.h"
|
||||
|
||||
class C_BaseEntity;
|
||||
class C_BaseObject;
|
||||
class CBaseTechnology;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: TF's Team manager
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_CSTeam : public C_Team
|
||||
{
|
||||
DECLARE_CLASS( C_CSTeam, C_Team );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_CSTeam();
|
||||
virtual ~C_CSTeam();
|
||||
};
|
||||
|
||||
|
||||
#endif // C_CS_TEAM_H
|
||||
@@ -1,86 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_csrootpanel.h"
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include <vgui/IVGui.h>
|
||||
#include "clientmode_csnormal.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *parent -
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CSRootPanel::C_CSRootPanel( vgui::VPANEL parent )
|
||||
: BaseClass( NULL, "CounterStrike Root Panel" )
|
||||
{
|
||||
SetParent( parent );
|
||||
SetPaintEnabled( false );
|
||||
SetPaintBorderEnabled( false );
|
||||
SetPaintBackgroundEnabled( false );
|
||||
|
||||
// This panel does post child painting
|
||||
SetPostChildPaintEnabled( true );
|
||||
|
||||
int w, h;
|
||||
surface()->GetScreenSize( w, h );
|
||||
|
||||
// Make it screen sized
|
||||
SetBounds( 0, 0, w, h );
|
||||
|
||||
// Ask for OnTick messages
|
||||
vgui::ivgui()->AddTickSignal( GetVPanel() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_CSRootPanel::~C_CSRootPanel( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CSRootPanel::PostChildPaint()
|
||||
{
|
||||
BaseClass::PostChildPaint();
|
||||
|
||||
// Draw all panel effects
|
||||
RenderPanelEffects();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: For each panel effect, check if it wants to draw and draw it on
|
||||
// this panel/surface if so
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CSRootPanel::RenderPanelEffects( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CSRootPanel::OnTick( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reset effects on level load/shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CSRootPanel::LevelInit( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CSRootPanel::LevelShutdown( void )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_CSRootPanel_H
|
||||
#define C_CSRootPanel_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include "utlvector.h"
|
||||
|
||||
class CPanelEffect;
|
||||
class ITFHintItem;
|
||||
|
||||
// Serial under of effect, for safe lookup
|
||||
typedef unsigned int EFFECT_HANDLE;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sits between engine and client .dll panels
|
||||
// Responsible for drawing screen overlays
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_CSRootPanel : public vgui::Panel
|
||||
{
|
||||
typedef vgui::Panel BaseClass;
|
||||
public:
|
||||
C_CSRootPanel( vgui::VPANEL parent );
|
||||
virtual ~C_CSRootPanel( void );
|
||||
|
||||
// Draw Panel effects here
|
||||
virtual void PostChildPaint();
|
||||
|
||||
// Clear list of Panel Effects
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
|
||||
// Run effects and let them decide whether to remove themselves
|
||||
void OnTick( void );
|
||||
|
||||
private:
|
||||
|
||||
// Render all panel effects
|
||||
void RenderPanelEffects( void );
|
||||
|
||||
// List of current panel effects
|
||||
CUtlVector< CPanelEffect *> m_Effects;
|
||||
};
|
||||
|
||||
extern C_CSRootPanel *g_pTF2RootPanel;
|
||||
|
||||
#endif // C_CSRootPanel_H
|
||||
@@ -1,219 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_plantedc4.h"
|
||||
#include "c_te_legacytempents.h"
|
||||
#include "tempent.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "dlight.h"
|
||||
#include "iefx.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include <bitbuf.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define PLANTEDC4_MSG_JUSTBLEW 1
|
||||
|
||||
ConVar cl_c4dynamiclight( "cl_c4dynamiclight", "0", 0, "Draw dynamic light when planted c4 flashes" );
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_PlantedC4, DT_PlantedC4, CPlantedC4)
|
||||
RecvPropBool( RECVINFO(m_bBombTicking) ),
|
||||
RecvPropFloat( RECVINFO(m_flC4Blow) ),
|
||||
RecvPropFloat( RECVINFO(m_flTimerLength) ),
|
||||
RecvPropFloat( RECVINFO(m_flDefuseLength) ),
|
||||
RecvPropFloat( RECVINFO(m_flDefuseCountDown) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
CUtlVector< C_PlantedC4* > g_PlantedC4s;
|
||||
|
||||
C_PlantedC4::C_PlantedC4()
|
||||
{
|
||||
g_PlantedC4s.AddToTail( this );
|
||||
|
||||
m_flNextRadarFlashTime = gpGlobals->curtime;
|
||||
m_bRadarFlash = true;
|
||||
m_pC4Explosion = NULL;
|
||||
|
||||
// Don't beep right away, leave time for the planting sound
|
||||
m_flNextGlow = gpGlobals->curtime + 1.0;
|
||||
m_flNextBeep = gpGlobals->curtime + 1.0;
|
||||
}
|
||||
|
||||
|
||||
C_PlantedC4::~C_PlantedC4()
|
||||
{
|
||||
g_PlantedC4s.FindAndRemove( this );
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Upon the new round remove the remaining bomb explosion particle effect
|
||||
//=============================================================================
|
||||
|
||||
if (m_pC4Explosion)
|
||||
{
|
||||
m_pC4Explosion->SetRemoveFlag();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
|
||||
void C_PlantedC4::SetDormant( bool bDormant )
|
||||
{
|
||||
BaseClass::SetDormant( bDormant );
|
||||
|
||||
// Remove us from the list of planted C4s.
|
||||
if ( bDormant )
|
||||
{
|
||||
g_PlantedC4s.FindAndRemove( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( g_PlantedC4s.Find( this ) == -1 )
|
||||
g_PlantedC4s.AddToTail( this );
|
||||
}
|
||||
}
|
||||
|
||||
void C_PlantedC4::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
void C_PlantedC4::ClientThink( void )
|
||||
{
|
||||
BaseClass::ClientThink();
|
||||
|
||||
// If it's dormant, don't beep or anything..
|
||||
if ( IsDormant() )
|
||||
return;
|
||||
|
||||
if ( !m_bBombTicking )
|
||||
{
|
||||
// disable C4 thinking if not armed
|
||||
SetNextClientThink( CLIENT_THINK_NEVER );
|
||||
return;
|
||||
}
|
||||
|
||||
if( gpGlobals->curtime > m_flNextBeep )
|
||||
{
|
||||
// as it gets closer to going off, increase the radius
|
||||
|
||||
CLocalPlayerFilter filter;
|
||||
float attenuation;
|
||||
float freq;
|
||||
|
||||
//the percent complete of the bomb timer
|
||||
float fComplete = ( ( m_flC4Blow - gpGlobals->curtime ) / m_flTimerLength );
|
||||
|
||||
fComplete = clamp( fComplete, 0.0f, 1.0f );
|
||||
|
||||
attenuation = MIN( 0.3 + 0.6 * fComplete, 1.0 );
|
||||
|
||||
CSoundParameters params;
|
||||
|
||||
if ( GetParametersForSound( "C4.PlantSound", params, NULL ) )
|
||||
{
|
||||
EmitSound_t ep( params );
|
||||
ep.m_SoundLevel = ATTN_TO_SNDLVL( attenuation );
|
||||
ep.m_pOrigin = &GetAbsOrigin();
|
||||
|
||||
EmitSound( filter, SOUND_FROM_WORLD, ep );
|
||||
}
|
||||
|
||||
freq = MAX( 0.1 + 0.9 * fComplete, 0.15 );
|
||||
|
||||
m_flNextBeep = gpGlobals->curtime + freq;
|
||||
}
|
||||
|
||||
if( gpGlobals->curtime > m_flNextGlow )
|
||||
{
|
||||
int modelindex = modelinfo->GetModelIndex( "sprites/ledglow.vmt" );
|
||||
|
||||
float scale = 0.8f;
|
||||
Vector vPos = GetAbsOrigin();
|
||||
const Vector offset( 0, 0, 4 );
|
||||
|
||||
// See if the c4 ended up underwater - we need to pull the flash up, or it won't get seen
|
||||
if ( enginetrace->GetPointContents( vPos ) & (CONTENTS_WATER|CONTENTS_SLIME) )
|
||||
{
|
||||
C_CSPlayer *player = GetLocalOrInEyeCSPlayer();
|
||||
if ( player )
|
||||
{
|
||||
const Vector& eyes = player->EyePosition();
|
||||
|
||||
if ( ( enginetrace->GetPointContents( eyes ) & (CONTENTS_WATER|CONTENTS_SLIME) ) == 0 )
|
||||
{
|
||||
// trace from the player to the water
|
||||
trace_t waterTrace;
|
||||
UTIL_TraceLine( eyes, vPos, (CONTENTS_WATER|CONTENTS_SLIME), player, COLLISION_GROUP_NONE, &waterTrace );
|
||||
|
||||
if( waterTrace.allsolid != 1 )
|
||||
{
|
||||
// now trace from the C4 to the edge of the water (in case there was something solid in the water)
|
||||
trace_t solidTrace;
|
||||
UTIL_TraceLine( vPos, waterTrace.endpos, MASK_SOLID, this, COLLISION_GROUP_NONE, &solidTrace );
|
||||
|
||||
if( solidTrace.allsolid != 1 )
|
||||
{
|
||||
float waterDist = (solidTrace.endpos - vPos).Length();
|
||||
float remainingDist = (solidTrace.endpos - eyes).Length();
|
||||
|
||||
scale = scale * remainingDist / ( remainingDist + waterDist );
|
||||
vPos = solidTrace.endpos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vPos += offset;
|
||||
|
||||
tempents->TempSprite( vPos, vec3_origin, scale, modelindex, kRenderTransAdd, 0, 1.0, 0.05, FTENT_SPRANIMATE | FTENT_SPRANIMATELOOP );
|
||||
|
||||
if( cl_c4dynamiclight.GetBool() )
|
||||
{
|
||||
dlight_t *dl;
|
||||
|
||||
dl = effects->CL_AllocDlight( entindex() );
|
||||
|
||||
if( dl )
|
||||
{
|
||||
dl->origin = GetAbsOrigin() + offset; // can't use vPos because it might have been moved
|
||||
dl->color.r = 255;
|
||||
dl->color.g = 0;
|
||||
dl->color.b = 0;
|
||||
dl->radius = 64;
|
||||
dl->die = gpGlobals->curtime + 0.01;
|
||||
}
|
||||
}
|
||||
|
||||
float freq = 0.1 + 0.9 * ( ( m_flC4Blow - gpGlobals->curtime ) / m_flTimerLength );
|
||||
|
||||
if( freq < 0.15 ) freq = 0.15;
|
||||
|
||||
m_flNextGlow = gpGlobals->curtime + freq;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Create the client side explosion particle effect for when the bomb explodes and hide the bomb
|
||||
//=============================================================================
|
||||
void C_PlantedC4::Explode( void )
|
||||
{
|
||||
m_pC4Explosion = ParticleProp()->Create( "bomb_explosion_huge", PATTACH_ABSORIGIN );
|
||||
AddEffects( EF_NODRAW );
|
||||
SetDormant( true );
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
@@ -1,73 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef C_PLANTEDC4_H
|
||||
#define C_PLANTEDC4_H
|
||||
|
||||
#include "cbase.h"
|
||||
#include "in_buttons.h"
|
||||
#include "decals.h"
|
||||
|
||||
#include "c_cs_player.h"
|
||||
|
||||
#include "utlvector.h"
|
||||
|
||||
// ------------------------------------------------------------------------------------------ //
|
||||
// CPlantedC4 class.
|
||||
// For now to show the planted c4 on the radar - client proxy to remove the CBaseAnimating
|
||||
// network vars?
|
||||
// ------------------------------------------------------------------------------------------ //
|
||||
|
||||
class C_PlantedC4 : public C_BaseAnimating
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_PlantedC4, CBaseAnimating );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_PlantedC4();
|
||||
virtual ~C_PlantedC4();
|
||||
|
||||
void Explode( void );
|
||||
void Spawn( void );
|
||||
virtual void SetDormant( bool bDormant );
|
||||
|
||||
void ClientThink( void );
|
||||
|
||||
int GetSecondsRemaining( void ) { return ceil( m_flC4Blow - gpGlobals->curtime ); }
|
||||
|
||||
inline bool IsBombActive( void ) { return m_bBombTicking; }
|
||||
CNetworkVar( bool, m_bBombTicking );
|
||||
|
||||
float m_flNextGlow;
|
||||
float m_flNextBeep;
|
||||
|
||||
float m_flC4Blow;
|
||||
float m_flTimerLength;
|
||||
|
||||
CNetworkVar( float, m_flDefuseLength );
|
||||
CNetworkVar( float, m_flDefuseCountDown );
|
||||
|
||||
float GetDefuseProgress( void )
|
||||
{
|
||||
float flProgress = 1.0f;
|
||||
|
||||
if( m_flDefuseLength > 0.0 )
|
||||
{
|
||||
flProgress = ( ( m_flDefuseCountDown - gpGlobals->curtime ) / m_flDefuseLength );
|
||||
}
|
||||
|
||||
return flProgress;
|
||||
}
|
||||
|
||||
float m_flNextRadarFlashTime; // next time to change flash state
|
||||
bool m_bRadarFlash; // is the flash on or off
|
||||
CNewParticleEffect *m_pC4Explosion; // client side explosion particle effect for the bomb
|
||||
};
|
||||
|
||||
extern CUtlVector< C_PlantedC4* > g_PlantedC4s;
|
||||
|
||||
#endif //C_PLANTEDC4_H
|
||||
@@ -1,74 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_basetempentity.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "hud_radar.h"
|
||||
#include "radio_status.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Kills Player Attachments
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_TERadioIcon : public C_BaseTempEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_TERadioIcon, C_BaseTempEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_TERadioIcon( void );
|
||||
virtual ~C_TERadioIcon( void );
|
||||
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
|
||||
public:
|
||||
int m_iAttachToClient;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_TERadioIcon::C_TERadioIcon( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_TERadioIcon::~C_TERadioIcon( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : bool -
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_TERadioIcon::PostDataUpdate( DataUpdateType_t updateType )
|
||||
{
|
||||
//Flash them on the radar
|
||||
//this could be in a better place.
|
||||
C_CSPlayer *pPlayer = static_cast<C_CSPlayer*>( cl_entitylist->GetEnt(m_iAttachToClient) );
|
||||
|
||||
if ( pPlayer && !pPlayer->IsDormant() )
|
||||
{
|
||||
// Create the flashy above player's head
|
||||
RadioManager()->UpdateRadioStatus( m_iAttachToClient, 1.5f );
|
||||
}
|
||||
|
||||
Radar_FlashPlayer( m_iAttachToClient );
|
||||
}
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TERadioIcon, DT_TERadioIcon, CTERadioIcon)
|
||||
RecvPropInt( RECVINFO(m_iAttachToClient)),
|
||||
END_RECV_TABLE()
|
||||
@@ -1,100 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "fx_cs_shared.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_basetempentity.h"
|
||||
#include <cliententitylist.h>
|
||||
|
||||
|
||||
class C_TEFireBullets : public C_BaseTempEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_TEFireBullets, C_BaseTempEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
|
||||
public:
|
||||
int m_iPlayer;
|
||||
Vector m_vecOrigin;
|
||||
QAngle m_vecAngles;
|
||||
int m_iWeaponID;
|
||||
int m_iMode;
|
||||
int m_iSeed;
|
||||
float m_fInaccuracy;
|
||||
float m_fSpread;
|
||||
};
|
||||
|
||||
|
||||
void C_TEFireBullets::PostDataUpdate( DataUpdateType_t updateType )
|
||||
{
|
||||
// Create the effect.
|
||||
|
||||
m_vecAngles.z = 0;
|
||||
|
||||
FX_FireBullets(
|
||||
m_iPlayer+1,
|
||||
m_vecOrigin,
|
||||
m_vecAngles,
|
||||
m_iWeaponID,
|
||||
m_iMode,
|
||||
m_iSeed,
|
||||
m_fInaccuracy,
|
||||
m_fSpread
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_EVENT( C_TEFireBullets, DT_TEFireBullets, CTEFireBullets );
|
||||
|
||||
|
||||
BEGIN_RECV_TABLE_NOBASE(C_TEFireBullets, DT_TEFireBullets)
|
||||
RecvPropVector( RECVINFO( m_vecOrigin ) ),
|
||||
RecvPropFloat( RECVINFO( m_vecAngles[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vecAngles[1] ) ),
|
||||
RecvPropInt( RECVINFO( m_iWeaponID ) ),
|
||||
RecvPropInt( RECVINFO( m_iMode ) ),
|
||||
RecvPropInt( RECVINFO( m_iSeed ) ),
|
||||
RecvPropInt( RECVINFO( m_iPlayer ) ),
|
||||
RecvPropFloat( RECVINFO( m_fInaccuracy ) ),
|
||||
RecvPropFloat( RECVINFO( m_fSpread ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
class C_TEPlantBomb : public C_BaseTempEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_TEPlantBomb, C_BaseTempEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
|
||||
public:
|
||||
int m_iPlayer;
|
||||
Vector m_vecOrigin;
|
||||
PlantBombOption_t m_option;
|
||||
};
|
||||
|
||||
|
||||
void C_TEPlantBomb::PostDataUpdate( DataUpdateType_t updateType )
|
||||
{
|
||||
// Create the effect.
|
||||
FX_PlantBomb( m_iPlayer+1, m_vecOrigin, m_option );
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_EVENT( C_TEPlantBomb, DT_TEPlantBomb, CTEPlantBomb );
|
||||
|
||||
|
||||
BEGIN_RECV_TABLE_NOBASE(C_TEPlantBomb, DT_TEPlantBomb)
|
||||
RecvPropVector( RECVINFO( m_vecOrigin ) ),
|
||||
RecvPropInt( RECVINFO( m_iPlayer ) ),
|
||||
RecvPropInt( RECVINFO( m_option ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,68 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CS_CLIENTMODE_H
|
||||
#define CS_CLIENTMODE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "clientmode_shared.h"
|
||||
#include "counterstrikeviewport.h"
|
||||
|
||||
class ClientModeCSNormal : public ClientModeShared
|
||||
{
|
||||
DECLARE_CLASS( ClientModeCSNormal, ClientModeShared );
|
||||
|
||||
private:
|
||||
|
||||
// IClientMode overrides.
|
||||
public:
|
||||
|
||||
ClientModeCSNormal();
|
||||
|
||||
virtual void Init();
|
||||
virtual void InitViewport();
|
||||
virtual void Update();
|
||||
|
||||
virtual int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
|
||||
|
||||
virtual float GetViewModelFOV( void );
|
||||
|
||||
int GetDeathMessageStartHeight( void );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
virtual void PostRenderVGui();
|
||||
|
||||
virtual bool ShouldDrawViewModel( void );
|
||||
|
||||
virtual bool CanRecordDemo( char *errorMsg, int length ) const;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Save server information shown to the client in a persistent place
|
||||
//=============================================================================
|
||||
|
||||
virtual wchar_t* GetServerName() { return m_pServerName; }
|
||||
virtual void SetServerName(wchar_t* name);
|
||||
virtual wchar_t* GetMapName() { return m_pMapName; }
|
||||
virtual void SetMapName(wchar_t* name);
|
||||
|
||||
private:
|
||||
wchar_t m_pServerName[256];
|
||||
wchar_t m_pMapName[256];
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
};
|
||||
|
||||
|
||||
extern IClientMode *GetClientModeNormal();
|
||||
extern ClientModeCSNormal* GetClientModeCSNormal();
|
||||
|
||||
|
||||
#endif // CS_CLIENTMODE_H
|
||||
@@ -1,789 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//-------------------------------------------------------------
|
||||
// File: cs_client_gamestats.cpp
|
||||
// Desc: Manages client side stat storage, accumulation, and access
|
||||
// Author: Peter Freese <peter@hiddenpath.com>
|
||||
// Date: 2009/09/11
|
||||
// Copyright: <09> 2009 Hidden Path Entertainment
|
||||
//
|
||||
// Keywords:
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "engine/imatchmaking.h"
|
||||
#include "ipresence.h"
|
||||
#include "usermessages.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "achievements_cs.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "c_team.h"
|
||||
#include "../shared/steamworks_gamestats.h"
|
||||
|
||||
CCSClientGameStats g_CSClientGameStats;
|
||||
|
||||
void MsgFunc_PlayerStatsUpdate( bf_read &msg )
|
||||
{
|
||||
g_CSClientGameStats.MsgFunc_PlayerStatsUpdate(msg);
|
||||
}
|
||||
|
||||
void MsgFunc_MatchStatsUpdate( bf_read &msg )
|
||||
{
|
||||
g_CSClientGameStats.MsgFunc_MatchStatsUpdate(msg);
|
||||
}
|
||||
|
||||
CCSClientGameStats::StatContainerList_t* CCSClientGameStats::s_StatLists = new CCSClientGameStats::StatContainerList_t();
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSClientGameStats::CCSClientGameStats()
|
||||
{
|
||||
m_bSteamStatsDownload = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called at init time after all systems are init'd. We have to
|
||||
// do this in PostInit because the Steam app ID is not available earlier
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::PostInit()
|
||||
{
|
||||
// listen for events
|
||||
ListenForGameEvent( "player_stats_updated" );
|
||||
ListenForGameEvent( "user_data_downloaded" );
|
||||
ListenForGameEvent( "round_end" );
|
||||
ListenForGameEvent( "round_start" );
|
||||
|
||||
|
||||
usermessages->HookMessage( "PlayerStatsUpdate", ::MsgFunc_PlayerStatsUpdate );
|
||||
usermessages->HookMessage( "MatchStatsUpdate", ::MsgFunc_MatchStatsUpdate );
|
||||
|
||||
GetSteamWorksSGameStatsUploader().StartSession();
|
||||
|
||||
m_RoundEndReason = Invalid_Round_End_Reason;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called at level shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::LevelShutdownPreEntity()
|
||||
{
|
||||
// This is a good opportunity to update our last match stats
|
||||
UpdateLastMatchStats();
|
||||
|
||||
// upload user stats to Steam on every map change
|
||||
UpdateSteamStats();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called at app shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::Shutdown()
|
||||
{
|
||||
GetSteamWorksSGameStatsUploader().EndSession();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::LevelShutdownPreClearSteamAPIContext( void )
|
||||
{
|
||||
UploadRoundData();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called when the stats have changed in-game
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
const char *pEventName = event->GetName();
|
||||
if ( 0 == Q_strcmp( pEventName, "player_stats_updated" ) )
|
||||
{
|
||||
UpdateSteamStats();
|
||||
}
|
||||
else if ( 0 == Q_strcmp( pEventName, "user_data_downloaded" ) )
|
||||
{
|
||||
RetrieveSteamStats();
|
||||
}
|
||||
else if ( Q_strcmp( pEventName, "round_end" ) == 0 )
|
||||
{
|
||||
// Store off the reason the round ended. Used with the OGS data.
|
||||
m_RoundEndReason = event->GetInt( "reason", Invalid_Round_End_Reason );
|
||||
|
||||
// update player count for last match stats
|
||||
int iCurrentPlayerCount = 0;
|
||||
if ( GetGlobalTeam(TEAM_CT) != NULL )
|
||||
iCurrentPlayerCount += GetGlobalTeam(TEAM_CT)->Get_Number_Players();
|
||||
if ( GetGlobalTeam(TEAM_TERRORIST) != NULL )
|
||||
iCurrentPlayerCount += GetGlobalTeam(TEAM_TERRORIST)->Get_Number_Players();
|
||||
|
||||
m_matchMaxPlayerCount = MAX(m_matchMaxPlayerCount, iCurrentPlayerCount);
|
||||
}
|
||||
|
||||
// The user stats for a round get sent piece meal, so we'll wait until a new round starts
|
||||
// before sending the previous round stats.
|
||||
else if ( Q_strcmp( pEventName, "round_start" ) == 0 && m_roundStats[CSSTAT_PLAYTIME] > 0 )
|
||||
{
|
||||
SRoundData *pRoundStatData = new SRoundData( &m_roundStats);
|
||||
C_CSPlayer *pPlayer = ToCSPlayer( C_BasePlayer::GetLocalPlayer() );
|
||||
if ( pPlayer )
|
||||
{
|
||||
// Our current money + what we spent is what we started with at the beginning of round
|
||||
pRoundStatData->nStartingMoney = pPlayer->GetAccount() + m_roundStats[CSSTAT_MONEY_SPENT];
|
||||
}
|
||||
m_RoundStatData.AddToTail( pRoundStatData );
|
||||
UploadRoundData();
|
||||
m_roundStats.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void CCSClientGameStats::RetrieveSteamStats()
|
||||
{
|
||||
Assert( steamapicontext->SteamUserStats() );
|
||||
if ( !steamapicontext->SteamUserStats() )
|
||||
return;
|
||||
|
||||
// we shouldn't be downloading stats more than once
|
||||
Assert(m_bSteamStatsDownload == false);
|
||||
if (m_bSteamStatsDownload)
|
||||
return;
|
||||
|
||||
int nStatFailCount = 0;
|
||||
for ( int i = 0; i < CSSTAT_MAX; ++i )
|
||||
{
|
||||
if ( CSStatProperty_Table[i].szSteamName == NULL )
|
||||
continue;
|
||||
|
||||
int iData;
|
||||
if ( steamapicontext->SteamUserStats()->GetStat( CSStatProperty_Table[i].szSteamName, &iData ) )
|
||||
{
|
||||
m_lifetimeStats[CSStatProperty_Table[i].statId] = iData;
|
||||
}
|
||||
else
|
||||
{
|
||||
++nStatFailCount;
|
||||
}
|
||||
}
|
||||
|
||||
if ( nStatFailCount > 0 )
|
||||
{
|
||||
Msg("RetrieveSteamStats: failed to get %i stats\n", nStatFailCount);
|
||||
return;
|
||||
}
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "player_stats_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
|
||||
m_bSteamStatsDownload = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Uploads stats for current Steam user to Steam
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::UpdateSteamStats()
|
||||
{
|
||||
// only upload if Steam is running
|
||||
if ( !steamapicontext->SteamUserStats() )
|
||||
return;
|
||||
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
Assert(pAchievementMgr != NULL);
|
||||
if (!pAchievementMgr)
|
||||
return;
|
||||
|
||||
// don't upload any stats if we haven't successfully download stats yet
|
||||
if ( !m_bSteamStatsDownload )
|
||||
{
|
||||
// try to periodically download stats from Steam if we haven't gotten them yet
|
||||
static float fLastStatsRetrieveTime = 0.0f;
|
||||
const float kRetrieveInterval = 30.0f;
|
||||
if ( gpGlobals->curtime > fLastStatsRetrieveTime + kRetrieveInterval )
|
||||
{
|
||||
pAchievementMgr->DownloadUserData();
|
||||
fLastStatsRetrieveTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < CSSTAT_MAX; ++i )
|
||||
{
|
||||
if ( CSStatProperty_Table[i].szSteamName == NULL )
|
||||
continue;
|
||||
|
||||
// set the stats locally in Steam client
|
||||
steamapicontext->SteamUserStats()->SetStat( CSStatProperty_Table[i].szSteamName, m_lifetimeStats[CSStatProperty_Table[i].statId]);
|
||||
}
|
||||
|
||||
// let the achievement manager know the stats have changed
|
||||
pAchievementMgr->SetDirty(true);
|
||||
}
|
||||
|
||||
CON_COMMAND_F( stats_reset, "Resets all player stats", FCVAR_CLIENTDLL )
|
||||
{
|
||||
g_CSClientGameStats.ResetAllStats();
|
||||
}
|
||||
|
||||
CON_COMMAND_F( stats_dump, "Dumps all player stats", FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
Msg( "Accumulated stats on Steam\n");
|
||||
|
||||
const StatsCollection_t& accumulatedStats = g_CSClientGameStats.GetLifetimeStats();
|
||||
|
||||
for ( int i = 0; i < CSSTAT_MAX; ++i )
|
||||
{
|
||||
if ( CSStatProperty_Table[i].szSteamName == NULL )
|
||||
continue;
|
||||
|
||||
Msg( "%42s: %i\n", CSStatProperty_Table[i].szSteamName, accumulatedStats[CSStatProperty_Table[i].statId]);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_DEBUG)
|
||||
CON_COMMAND_F( stats_preload, "Load stats with data ripe for getting achievmenets", FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
struct DataSet
|
||||
{
|
||||
CSStatType_t statId;
|
||||
int value;
|
||||
};
|
||||
|
||||
DataSet statData[] =
|
||||
{
|
||||
{ CSSTAT_KILLS, 9999},
|
||||
{ CSSTAT_ROUNDS_WON, 4999},
|
||||
{ CSSTAT_PISTOLROUNDS_WON, 249},
|
||||
{ CSSTAT_MONEY_EARNED, 49999999},
|
||||
{ CSSTAT_DAMAGE, 999999},
|
||||
{ CSSTAT_KILLS_DEAGLE, 199},
|
||||
{ CSSTAT_KILLS_USP, 199},
|
||||
{ CSSTAT_KILLS_GLOCK, 199},
|
||||
{ CSSTAT_KILLS_P228, 199},
|
||||
{ CSSTAT_KILLS_ELITE, 99},
|
||||
{ CSSTAT_KILLS_FIVESEVEN, 99},
|
||||
{ CSSTAT_KILLS_AWP, 999},
|
||||
{ CSSTAT_KILLS_AK47, 999},
|
||||
{ CSSTAT_KILLS_M4A1, 999},
|
||||
{ CSSTAT_KILLS_AUG, 499},
|
||||
{ CSSTAT_KILLS_SG552, 499},
|
||||
{ CSSTAT_KILLS_SG550, 499},
|
||||
{ CSSTAT_KILLS_GALIL, 499},
|
||||
{ CSSTAT_KILLS_FAMAS, 499},
|
||||
{ CSSTAT_KILLS_SCOUT, 999},
|
||||
{ CSSTAT_KILLS_G3SG1, 499},
|
||||
{ CSSTAT_KILLS_P90, 999},
|
||||
{ CSSTAT_KILLS_MP5NAVY, 999},
|
||||
{ CSSTAT_KILLS_TMP, 499},
|
||||
{ CSSTAT_KILLS_MAC10, 499},
|
||||
{ CSSTAT_KILLS_UMP45, 999},
|
||||
{ CSSTAT_KILLS_M3, 199},
|
||||
{ CSSTAT_KILLS_XM1014, 199},
|
||||
{ CSSTAT_KILLS_M249, 499},
|
||||
{ CSSTAT_KILLS_KNIFE, 99},
|
||||
{ CSSTAT_KILLS_HEGRENADE, 499},
|
||||
{ CSSTAT_KILLS_HEADSHOT, 249},
|
||||
{ CSSTAT_KILLS_ENEMY_WEAPON, 99},
|
||||
{ CSSTAT_KILLS_ENEMY_BLINDED, 24},
|
||||
{ CSSTAT_NUM_BOMBS_DEFUSED, 99},
|
||||
{ CSSTAT_NUM_BOMBS_PLANTED, 99},
|
||||
{ CSSTAT_NUM_HOSTAGES_RESCUED, 499},
|
||||
{ CSSTAT_KILLS_KNIFE_FIGHT, 99},
|
||||
{ CSSTAT_DECAL_SPRAYS, 99},
|
||||
{ CSSTAT_NIGHTVISION_DAMAGE, 4999},
|
||||
{ CSSTAT_KILLS_AGAINST_ZOOMED_SNIPER, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_ASSAULT, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_COMPOUND, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_HAVANA, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_ITALY, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_MILITIA, 99},
|
||||
{ CSSTAT_MAP_WINS_CS_OFFICE, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_AZTEC, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_CBBLE, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_CHATEAU, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_DUST2, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_DUST, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_INFERNO, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_NUKE, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_PIRANESI, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_PORT, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_PRODIGY, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_TIDES, 99},
|
||||
{ CSSTAT_MAP_WINS_DE_TRAIN, 99},
|
||||
{ CSSTAT_WEAPONS_DONATED, 99},
|
||||
{ CSSTAT_DOMINATIONS, 9},
|
||||
{ CSSTAT_DOMINATION_OVERKILLS, 99},
|
||||
{ CSSTAT_REVENGES, 19},
|
||||
};
|
||||
|
||||
StatsCollection_t& lifetimeStats = const_cast<StatsCollection_t&>(g_CSClientGameStats.GetLifetimeStats());
|
||||
|
||||
for ( int i = 0; i < ARRAYSIZE(statData); ++i )
|
||||
{
|
||||
CSStatType_t statId = statData[i].statId;
|
||||
lifetimeStats[statId] = statData[i].value;
|
||||
}
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "player_stats_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG)
|
||||
CON_COMMAND_F( stats_corrupt, "Load stats with corrupt values", FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
struct DataSet
|
||||
{
|
||||
CSStatType_t statId;
|
||||
int value;
|
||||
};
|
||||
|
||||
DataSet badData[] =
|
||||
{
|
||||
{ CSSTAT_SHOTS_HIT, 0x40000089 },
|
||||
{ CSSTAT_SHOTS_FIRED, 0x400002BE },
|
||||
{ CSSTAT_KILLS, 0x40000021 },
|
||||
{ CSSTAT_DEATHS, 0x00000056 },
|
||||
{ CSSTAT_DAMAGE, 0x00000FE3 },
|
||||
{ CSSTAT_NUM_BOMBS_PLANTED, 0x00000004 },
|
||||
{ CSSTAT_NUM_BOMBS_DEFUSED, 0x00000000 },
|
||||
{ CSSTAT_PLAYTIME, 0x40000F46 },
|
||||
{ CSSTAT_ROUNDS_WON, 0x40000028 },
|
||||
{ CSSTAT_ROUNDS_PLAYED, 0x40001019 },
|
||||
{ CSSTAT_PISTOLROUNDS_WON, 0x00000001 },
|
||||
{ CSSTAT_MONEY_EARNED, 0x00021E94 },
|
||||
{ CSSTAT_KILLS_DEAGLE, 0x00000009 },
|
||||
{ CSSTAT_KILLS_USP, 0x00000000 },
|
||||
{ CSSTAT_KILLS_GLOCK, 0x00000002 },
|
||||
{ CSSTAT_KILLS_P228, 0x00000000 },
|
||||
{ CSSTAT_KILLS_ELITE, 0x00000000 },
|
||||
{ CSSTAT_KILLS_FIVESEVEN, 0x00000000 },
|
||||
{ CSSTAT_KILLS_AWP, 0x00000000 },
|
||||
{ CSSTAT_KILLS_AK47, 0x00000001 },
|
||||
{ CSSTAT_KILLS_M4A1, 0x00000000 },
|
||||
{ CSSTAT_KILLS_AUG, 0x00000000 },
|
||||
{ CSSTAT_KILLS_SG552, 0x00000000 },
|
||||
{ CSSTAT_KILLS_SG550, 0x00000000 },
|
||||
{ CSSTAT_KILLS_GALIL, 0x00000000 },
|
||||
{ CSSTAT_KILLS_FAMAS, 0x00000001 },
|
||||
{ CSSTAT_KILLS_SCOUT, 0x00000000 },
|
||||
{ CSSTAT_KILLS_G3SG1, 0x00000000 },
|
||||
{ CSSTAT_KILLS_P90, 0x00000001 },
|
||||
{ CSSTAT_KILLS_MP5NAVY, 0x00000000 },
|
||||
{ CSSTAT_KILLS_TMP, 0x00000002 },
|
||||
{ CSSTAT_KILLS_MAC10, 0x00000000 },
|
||||
{ CSSTAT_KILLS_UMP45, 0x00000001 },
|
||||
{ CSSTAT_KILLS_M3, 0x00000000 },
|
||||
{ CSSTAT_KILLS_XM1014, 0x0000000A },
|
||||
{ CSSTAT_KILLS_M249, 0x00000000 },
|
||||
{ CSSTAT_KILLS_KNIFE, 0x00000000 },
|
||||
{ CSSTAT_KILLS_HEGRENADE, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_DEAGLE, 0x0000004C },
|
||||
{ CSSTAT_SHOTS_USP, 0x00000001 },
|
||||
{ CSSTAT_SHOTS_GLOCK, 0x00000017 },
|
||||
{ CSSTAT_SHOTS_P228, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_ELITE, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_FIVESEVEN, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_AWP, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_AK47, 0x0000000E },
|
||||
{ CSSTAT_SHOTS_M4A1, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_AUG, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_SG552, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_SG550, 0x00000008 },
|
||||
{ CSSTAT_SHOTS_GALIL, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_FAMAS, 0x00000010 },
|
||||
{ CSSTAT_SHOTS_SCOUT, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_G3SG1, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_P90, 0x0000007F },
|
||||
{ CSSTAT_SHOTS_MP5NAVY, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_TMP, 0x00000010 },
|
||||
{ CSSTAT_SHOTS_MAC10, 0x00000000 },
|
||||
{ CSSTAT_SHOTS_UMP45, 0x00000015 },
|
||||
{ CSSTAT_SHOTS_M3, 0x00000009 },
|
||||
{ CSSTAT_SHOTS_XM1014, 0x0000024C },
|
||||
{ CSSTAT_SHOTS_M249, 0x00000000 },
|
||||
{ CSSTAT_HITS_DEAGLE, 0x00000019 },
|
||||
{ CSSTAT_HITS_USP, 0x00000000 },
|
||||
{ CSSTAT_HITS_GLOCK, 0x0000000A },
|
||||
{ CSSTAT_HITS_P228, 0x00000000 },
|
||||
{ CSSTAT_HITS_ELITE, 0x00000000 },
|
||||
{ CSSTAT_HITS_FIVESEVEN, 0x00000000 },
|
||||
{ CSSTAT_HITS_AWP, 0x00000000 },
|
||||
{ CSSTAT_HITS_AK47, 0x00000003 },
|
||||
{ CSSTAT_HITS_M4A1, 0x00000000 },
|
||||
{ CSSTAT_HITS_AUG, 0x00000000 },
|
||||
{ CSSTAT_HITS_SG552, 0x00000000 },
|
||||
{ CSSTAT_HITS_SG550, 0x00000001 },
|
||||
{ CSSTAT_HITS_GALIL, 0x00000000 },
|
||||
{ CSSTAT_HITS_FAMAS, 0x00000007 },
|
||||
{ CSSTAT_HITS_SCOUT, 0x00000000 },
|
||||
{ CSSTAT_HITS_G3SG1, 0x00000000 },
|
||||
{ CSSTAT_HITS_P90, 0x0000000D },
|
||||
{ CSSTAT_HITS_MP5NAVY, 0x00000000 },
|
||||
{ CSSTAT_HITS_TMP, 0x00000006 },
|
||||
{ CSSTAT_HITS_MAC10, 0x00000000 },
|
||||
{ CSSTAT_HITS_UMP45, 0x00000006 },
|
||||
{ CSSTAT_HITS_M3, 0x00000000 },
|
||||
{ CSSTAT_HITS_XM1014, 0x0000004C },
|
||||
{ CSSTAT_HITS_M249, 0x00000000 },
|
||||
{ CSSTAT_KILLS_HEADSHOT, 0x00000013 },
|
||||
{ CSSTAT_KILLS_ENEMY_BLINDED, 0x00000002 },
|
||||
{ CSSTAT_KILLS_ENEMY_WEAPON, 0x00000002 },
|
||||
{ CSSTAT_KILLS_KNIFE_FIGHT, 0x00000000 },
|
||||
{ CSSTAT_DECAL_SPRAYS, 0x00000000 },
|
||||
{ CSSTAT_NIGHTVISION_DAMAGE, 0x00000000 },
|
||||
{ CSSTAT_NUM_HOSTAGES_RESCUED, 0x00000000 },
|
||||
{ CSSTAT_NUM_BROKEN_WINDOWS, 0x00000000 },
|
||||
{ CSSTAT_KILLS_AGAINST_ZOOMED_SNIPER, 0x00000000 },
|
||||
{ CSSTAT_WEAPONS_DONATED, 0x00000000 },
|
||||
{ CSSTAT_DOMINATIONS, 0x00000001 },
|
||||
{ CSSTAT_DOMINATION_OVERKILLS, 0x00000000 },
|
||||
{ CSSTAT_REVENGES, 0x00000000 },
|
||||
{ CSSTAT_MVPS, 0x00000005 },
|
||||
{ CSSTAT_MAP_WINS_CS_ASSAULT, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_CS_COMPOUND, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_CS_HAVANA, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_CS_ITALY, 0x40000002 },
|
||||
{ CSSTAT_MAP_WINS_CS_MILITIA, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_CS_OFFICE, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_AZTEC, 0x0000000A },
|
||||
{ CSSTAT_MAP_WINS_DE_CBBLE, 0x40000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_CHATEAU, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_DUST2, 0x0000000B },
|
||||
{ CSSTAT_MAP_WINS_DE_DUST, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_INFERNO, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_NUKE, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_PIRANESI, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_PORT, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_PRODIGY, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_TIDES, 0x00000000 },
|
||||
{ CSSTAT_MAP_WINS_DE_TRAIN, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_ASSAULT, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_COMPOUND, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_HAVANA, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_ITALY, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_MILITIA, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_CS_OFFICE, 0x00000003 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_AZTEC, 0x00000019 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_CBBLE, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_CHATEAU, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_DUST2, 0x00000014 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_DUST, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_INFERNO, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_NUKE, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_PIRANESI, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_PORT, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_PRODIGY, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_TIDES, 0x00000000 },
|
||||
{ CSSTAT_MAP_ROUNDS_DE_TRAIN, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_T_ROUNDS_WON, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_CT_ROUNDS_WON, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_ROUNDS_WON, 0x40000000 },
|
||||
{ CSSTAT_LASTMATCH_KILLS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_DEATHS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_MVPS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_DAMAGE, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_MONEYSPENT, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_DOMINATIONS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_REVENGES, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_MAX_PLAYERS, 0x0000001B },
|
||||
{ CSSTAT_LASTMATCH_FAVWEAPON_ID, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_FAVWEAPON_SHOTS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_FAVWEAPON_HITS, 0x00000000 },
|
||||
{ CSSTAT_LASTMATCH_FAVWEAPON_KILLS, 0x00000000 },
|
||||
};
|
||||
|
||||
StatsCollection_t& lifetimeStats = const_cast<StatsCollection_t&>(g_CSClientGameStats.GetLifetimeStats());
|
||||
for ( int i = 0; i < ARRAYSIZE(badData); ++i )
|
||||
{
|
||||
CSStatType_t statId = badData[i].statId;
|
||||
lifetimeStats[statId] = badData[i].value;
|
||||
}
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "player_stats_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int CCSClientGameStats::GetStatCount()
|
||||
{
|
||||
return CSSTAT_MAX;
|
||||
}
|
||||
|
||||
PlayerStatData_t CCSClientGameStats::GetStatByIndex( int index )
|
||||
{
|
||||
PlayerStatData_t statData;
|
||||
|
||||
statData.iStatId = CSStatProperty_Table[index].statId;
|
||||
statData.iStatValue = m_lifetimeStats[statData.iStatId];
|
||||
|
||||
// we can make this more efficient by caching the localized names
|
||||
statData.pStatDisplayName = g_pVGuiLocalize->Find( CSStatProperty_Table[index].szLocalizationToken );
|
||||
|
||||
return statData;
|
||||
}
|
||||
|
||||
PlayerStatData_t CCSClientGameStats::GetStatById( int id )
|
||||
{
|
||||
Assert(id >= 0 && id < CSSTAT_MAX);
|
||||
if ( id >= 0 && id < CSSTAT_MAX)
|
||||
{
|
||||
return GetStatByIndex(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerStatData_t dummy;
|
||||
dummy.pStatDisplayName = NULL;
|
||||
dummy.iStatId = CSSTAT_UNDEFINED;
|
||||
dummy.iStatValue = 0;
|
||||
return dummy;
|
||||
}
|
||||
}
|
||||
|
||||
void CCSClientGameStats::UpdateStats( const StatsCollection_t &stats )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
// don't count stats if cheats on, commentary mode, etc
|
||||
if ( !g_AchievementMgrCS.CheckAchievementsEnabled() )
|
||||
return;
|
||||
|
||||
// Update the accumulated stats
|
||||
m_lifetimeStats.Aggregate(stats);
|
||||
m_matchStats.Aggregate(stats);
|
||||
m_roundStats.Aggregate(stats);
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "player_stats_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
|
||||
void CCSClientGameStats::ResetAllStats( void )
|
||||
{
|
||||
m_lifetimeStats.Reset();
|
||||
m_matchStats.Reset();
|
||||
m_roundStats.Reset();
|
||||
|
||||
// reset the stats on Steam
|
||||
if (steamapicontext && steamapicontext->SteamUserStats())
|
||||
{
|
||||
steamapicontext->SteamUserStats()->ResetAllStats(false);
|
||||
}
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "player_stats_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
|
||||
void CCSClientGameStats::MsgFunc_MatchStatsUpdate( bf_read &msg )
|
||||
{
|
||||
int firstStat = msg.ReadShort();
|
||||
|
||||
for (int iStat = firstStat; iStat < CSSTAT_MAX && msg.GetNumBytesLeft() > 0; iStat++ )
|
||||
{
|
||||
m_directTStatAverages.m_fStat[iStat] = msg.ReadFloat();
|
||||
m_directCTStatAverages.m_fStat[iStat] = msg.ReadFloat();
|
||||
m_directPlayerStatAverages.m_fStat[iStat] = msg.ReadFloat();
|
||||
}
|
||||
|
||||
// sanity check: the message should contain exactly the # of bytes we expect based on the bit field
|
||||
Assert( !msg.IsOverflowed() );
|
||||
Assert( 0 == msg.GetNumBytesLeft() );
|
||||
}
|
||||
|
||||
void CCSClientGameStats::MsgFunc_PlayerStatsUpdate( bf_read &msg )
|
||||
{
|
||||
// Note: if any check fails while decoding this message, bail out and disregard this data to avoid
|
||||
// potentially polluting player stats
|
||||
|
||||
StatsCollection_t deltaStats;
|
||||
|
||||
CRC32_t crc;
|
||||
CRC32_Init( &crc );
|
||||
|
||||
const uint32 key = 0x82DA9F4C; // this key should match the key in cs_gamestats.cpp
|
||||
CRC32_ProcessBuffer( &crc, &key, sizeof(key));
|
||||
|
||||
const byte version = 0x01;
|
||||
CRC32_ProcessBuffer( &crc, &version, sizeof(version));
|
||||
|
||||
if (msg.ReadByte() != version)
|
||||
{
|
||||
Warning("PlayerStatsUpdate message: ignoring unsupported version\n");
|
||||
return;
|
||||
}
|
||||
|
||||
byte iStatsToRead = msg.ReadByte();
|
||||
CRC32_ProcessBuffer( &crc, &iStatsToRead, sizeof(iStatsToRead));
|
||||
|
||||
for ( int i = 0; i < iStatsToRead; ++i)
|
||||
{
|
||||
byte iStat = msg.ReadByte();
|
||||
CRC32_ProcessBuffer( &crc, &iStat, sizeof(iStat));
|
||||
|
||||
if (iStat >= CSSTAT_MAX)
|
||||
{
|
||||
Warning("PlayerStatsUpdate: invalid statId encountered; ignoring stats update\n");
|
||||
return;
|
||||
}
|
||||
short delta = msg.ReadShort();
|
||||
deltaStats[iStat] = delta;
|
||||
CRC32_ProcessBuffer( &crc, &delta, sizeof(delta));
|
||||
}
|
||||
|
||||
CRC32_Final( &crc );
|
||||
CRC32_t readCRC = msg.ReadLong();
|
||||
|
||||
if (readCRC != crc || msg.IsOverflowed() || ( 0 != msg.GetNumBytesLeft() ) )
|
||||
{
|
||||
Warning("PlayerStatsUpdate message from server is corrupt; ignoring\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// do one additional pass for out of band values
|
||||
for ( int iStat = CSSTAT_FIRST; iStat < CSSTAT_MAX; ++iStat )
|
||||
{
|
||||
if (deltaStats[iStat] < 0 || deltaStats[iStat] >= 0x4000)
|
||||
{
|
||||
Warning("PlayerStatsUpdate message from server has out of band values; ignoring\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// everything looks okay at this point; add these stats for the player's round, match, and lifetime stats
|
||||
UpdateStats(deltaStats);
|
||||
}
|
||||
|
||||
void CCSClientGameStats::UploadRoundData()
|
||||
{
|
||||
// If there's nothing to send, don't bother
|
||||
if ( !m_RoundStatData.Count() )
|
||||
return;
|
||||
|
||||
// Temporary ConVar to disable stats
|
||||
if ( sv_noroundstats.GetBool() )
|
||||
{
|
||||
m_RoundStatData.PurgeAndDeleteElements();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send off all OGS stats at level shutdown
|
||||
KeyValues *pKV = new KeyValues( "basedata" );
|
||||
if ( !pKV )
|
||||
return;
|
||||
|
||||
pKV->SetString( "MapID", MapName() );
|
||||
|
||||
// Add all the vector based stats
|
||||
for ( int k=0 ; k < m_RoundStatData.Count() ; ++k )
|
||||
{
|
||||
m_RoundStatData[ k ] ->nRoundEndReason = m_RoundEndReason;
|
||||
SubmitStat( m_RoundStatData[ k ] );
|
||||
}
|
||||
|
||||
// Perform the actual submission
|
||||
SubmitGameStats( pKV );
|
||||
|
||||
// Clear out the per map stats
|
||||
m_RoundStatData.Purge();
|
||||
pKV->deleteThis();
|
||||
|
||||
// Reset the last round's ending status.
|
||||
m_RoundEndReason = Invalid_Round_End_Reason;
|
||||
}
|
||||
|
||||
void CCSClientGameStats::ResetMatchStats()
|
||||
{
|
||||
m_roundStats.Reset();
|
||||
m_matchStats.Reset();
|
||||
m_matchMaxPlayerCount = 0;
|
||||
}
|
||||
|
||||
void CCSClientGameStats::UpdateLastMatchStats()
|
||||
{
|
||||
// only update that last match if we actually have valid data
|
||||
if ( m_matchStats[CSSTAT_ROUNDS_PLAYED] == 0 )
|
||||
return;
|
||||
|
||||
// check to see if the player materially participate; they could have been spectating or joined just in time for the ending.
|
||||
int s = 0;
|
||||
s += m_matchStats[CSSTAT_ROUNDS_WON];
|
||||
s += m_matchStats[CSSTAT_KILLS];
|
||||
s += m_matchStats[CSSTAT_DEATHS];
|
||||
s += m_matchStats[CSSTAT_MVPS];
|
||||
s += m_matchStats[CSSTAT_DAMAGE];
|
||||
s += m_matchStats[CSSTAT_MONEY_SPENT];
|
||||
|
||||
if ( s == 0 )
|
||||
return;
|
||||
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_T_ROUNDS_WON] = m_matchStats[CSSTAT_T_ROUNDS_WON];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_CT_ROUNDS_WON] = m_matchStats[CSSTAT_CT_ROUNDS_WON];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_ROUNDS_WON] = m_matchStats[CSSTAT_ROUNDS_WON];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_KILLS] = m_matchStats[CSSTAT_KILLS];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_DEATHS] = m_matchStats[CSSTAT_DEATHS];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_MVPS] = m_matchStats[CSSTAT_MVPS];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_DAMAGE] = m_matchStats[CSSTAT_DAMAGE];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_MONEYSPENT] = m_matchStats[CSSTAT_MONEY_SPENT];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_DOMINATIONS] = m_matchStats[CSSTAT_DOMINATIONS];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_REVENGES] = m_matchStats[CSSTAT_REVENGES];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_MAX_PLAYERS] = m_matchMaxPlayerCount;
|
||||
|
||||
CalculateMatchFavoriteWeapons();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Calculate and store the match favorite weapon for each player as only deltaStats for that weapon are stored on Steam
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSClientGameStats::CalculateMatchFavoriteWeapons()
|
||||
{
|
||||
int maxKills = 0, maxKillId = -1;
|
||||
|
||||
for( int j = CSSTAT_KILLS_DEAGLE; j <= CSSTAT_KILLS_M249; ++j )
|
||||
{
|
||||
if ( m_matchStats[j] > maxKills )
|
||||
{
|
||||
maxKills = m_matchStats[j];
|
||||
maxKillId = j;
|
||||
}
|
||||
}
|
||||
if ( maxKillId == -1 )
|
||||
{
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_ID] = WEAPON_NONE;
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_SHOTS] = 0;
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_HITS] = 0;
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_KILLS] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int statTableID = -1;
|
||||
for (int j = 0; WeaponName_StatId_Table[j].killStatId != CSSTAT_UNDEFINED; ++j)
|
||||
{
|
||||
if ( WeaponName_StatId_Table[j].killStatId == maxKillId )
|
||||
{
|
||||
statTableID = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert( statTableID != -1 );
|
||||
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_ID] = WeaponName_StatId_Table[statTableID].weaponId;
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_SHOTS] = m_matchStats[WeaponName_StatId_Table[statTableID].shotStatId];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_HITS] = m_matchStats[WeaponName_StatId_Table[statTableID].hitStatId];
|
||||
m_lifetimeStats[CSSTAT_LASTMATCH_FAVWEAPON_KILLS] = m_matchStats[WeaponName_StatId_Table[statTableID].killStatId];
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CS_STEAMSTATS_H
|
||||
#define CS_STEAMSTATS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "steam/steam_api.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "../game/shared/cstrike/cs_gamestats_shared.h"
|
||||
|
||||
struct SRoundData : public BaseStatData
|
||||
{
|
||||
SRoundData( const StatsCollection_t *pRoundData )
|
||||
{
|
||||
nRoundTime = (*pRoundData)[CSSTAT_PLAYTIME];
|
||||
nWasKilled = (*pRoundData)[CSSTAT_DEATHS];
|
||||
nIsMVP = (*pRoundData)[CSSTAT_MVPS];
|
||||
nMoneySpent = (*pRoundData)[CSSTAT_MONEY_SPENT];
|
||||
nStartingMoney = -1;// We'll get this data separately
|
||||
nRoundEndReason = Invalid_Round_End_Reason;// We'll get this data separately
|
||||
nRevenges = (*pRoundData)[CSSTAT_REVENGES];
|
||||
nDamageDealt = (*pRoundData)[CSSTAT_DAMAGE];
|
||||
|
||||
if ( (*pRoundData)[CSSTAT_T_ROUNDS_WON] )
|
||||
{
|
||||
nWinningTeamID = TEAM_TERRORIST;
|
||||
if ( (*pRoundData)[CSSTAT_ROUNDS_WON] )
|
||||
{
|
||||
nTeamID = TEAM_TERRORIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
nTeamID = TEAM_CT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nWinningTeamID = TEAM_CT;
|
||||
if ( (*pRoundData)[CSSTAT_ROUNDS_WON] )
|
||||
{
|
||||
nTeamID = TEAM_CT;
|
||||
}
|
||||
else
|
||||
{
|
||||
nTeamID = TEAM_TERRORIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32 nRoundTime;
|
||||
int nTeamID;
|
||||
int nWinningTeamID;
|
||||
int nWasKilled;
|
||||
int nIsMVP;
|
||||
int nDamageDealt;
|
||||
int nMoneySpent;
|
||||
int nStartingMoney;
|
||||
int nRevenges;
|
||||
int nRoundEndReason;
|
||||
|
||||
BEGIN_STAT_TABLE( "CSSRoundData" )
|
||||
REGISTER_STAT_NAMED( nRoundTime, "RoundTime" )
|
||||
REGISTER_STAT_NAMED( nTeamID, "TeamID" )
|
||||
REGISTER_STAT_NAMED( nWinningTeamID, "WinningTeamID" )
|
||||
REGISTER_STAT_NAMED( nWasKilled, "WasKilled" )
|
||||
REGISTER_STAT_NAMED( nIsMVP, "IsMvp" )
|
||||
REGISTER_STAT_NAMED( nDamageDealt, "DamageDealt" )
|
||||
REGISTER_STAT_NAMED( nMoneySpent, "MoneySpent" )
|
||||
REGISTER_STAT_NAMED( nStartingMoney, "StartingMoney" )
|
||||
REGISTER_STAT_NAMED( nRevenges, "Revenges" )
|
||||
REGISTER_STAT_NAMED( nRoundEndReason, "RoundEndReason" )
|
||||
END_STAT_TABLE()
|
||||
};
|
||||
typedef CUtlVector< SRoundData* > VectorRoundData;
|
||||
|
||||
struct PlayerStatData_t
|
||||
{
|
||||
wchar_t* pStatDisplayName; // Localized display name of the stat
|
||||
int iStatId; // CSStatType_t enum value of stat
|
||||
int32 iStatValue; // Value of the stat
|
||||
};
|
||||
|
||||
class CCSClientGameStats : public CAutoGameSystem, public CGameEventListener, public IGameStatTracker
|
||||
{
|
||||
public:
|
||||
CCSClientGameStats();
|
||||
virtual void PostInit();
|
||||
virtual void LevelShutdownPreEntity();
|
||||
virtual void Shutdown();
|
||||
virtual void LevelShutdownPreClearSteamAPIContext();
|
||||
|
||||
int GetStatCount();
|
||||
PlayerStatData_t GetStatByIndex(int index);
|
||||
PlayerStatData_t GetStatById(int id);
|
||||
|
||||
void ResetAllStats( void );
|
||||
void ResetMatchStats();
|
||||
void UploadRoundData( void );
|
||||
|
||||
const StatsCollection_t& GetLifetimeStats() { return m_lifetimeStats; }
|
||||
const StatsCollection_t& GetMatchStats() { return m_matchStats; }
|
||||
|
||||
RoundStatsDirectAverage_t* GetDirectCTStatsAverages() { return &m_directCTStatAverages; }
|
||||
RoundStatsDirectAverage_t* GetDirectTStatsAverages() { return &m_directTStatAverages; }
|
||||
RoundStatsDirectAverage_t* GetDirectPlayerStatsAverages() { return &m_directPlayerStatAverages; }
|
||||
|
||||
void MsgFunc_MatchStatsUpdate( bf_read &msg );
|
||||
void MsgFunc_PlayerStatsUpdate( bf_read &msg );
|
||||
|
||||
// Steamworks Gamestats
|
||||
virtual void SubmitGameStats( KeyValues *pKV )
|
||||
{
|
||||
int listCount = s_StatLists->Count();
|
||||
for( int i=0; i < listCount; ++i )
|
||||
{
|
||||
// Create a master key value that has stats everybody should share (map name, session ID, etc)
|
||||
(*s_StatLists)[i]->SendData(pKV);
|
||||
(*s_StatLists)[i]->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
virtual StatContainerList_t* GetStatContainerList( void )
|
||||
{
|
||||
return s_StatLists;
|
||||
}
|
||||
|
||||
protected:
|
||||
void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void UpdateSteamStats();
|
||||
void RetrieveSteamStats();
|
||||
void UpdateStats( const StatsCollection_t &stats );
|
||||
void CalculateMatchFavoriteWeapons();
|
||||
void UpdateLastMatchStats();
|
||||
|
||||
private:
|
||||
StatsCollection_t m_lifetimeStats;
|
||||
StatsCollection_t m_matchStats;
|
||||
StatsCollection_t m_roundStats;
|
||||
|
||||
RoundStatsDirectAverage_t m_directCTStatAverages;
|
||||
RoundStatsDirectAverage_t m_directTStatAverages;
|
||||
RoundStatsDirectAverage_t m_directPlayerStatAverages;
|
||||
int m_matchMaxPlayerCount;
|
||||
bool m_bSteamStatsDownload;
|
||||
VectorRoundData m_RoundStatData;
|
||||
|
||||
int m_RoundEndReason;
|
||||
|
||||
// A static list of all the stat containers, one for each data structure being tracked
|
||||
static StatContainerList_t * s_StatLists;
|
||||
};
|
||||
|
||||
extern CCSClientGameStats g_CSClientGameStats;
|
||||
|
||||
#endif //CS_STEAMSTATS_H
|
||||
@@ -1,415 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cs_hud_achievement_announce.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "vgui_controls/AnimationController.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "fmtstr.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "view.h"
|
||||
#include "ivieweffects.h"
|
||||
#include "viewrender.h"
|
||||
#include "usermessages.h"
|
||||
#include "hud_macros.h"
|
||||
#include "c_baseanimating.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( CCSAchievementAnnouncePanel, 1 );
|
||||
|
||||
#define CALLOUT_WIDE (XRES(100))
|
||||
#define CALLOUT_TALL (XRES(50))
|
||||
|
||||
|
||||
namespace Interpolators
|
||||
|
||||
{
|
||||
inline float Linear( float t ) { return t; }
|
||||
|
||||
inline float SmoothStep( float t )
|
||||
{
|
||||
t = 3 * t * t - 2.0f * t * t * t;
|
||||
return t;
|
||||
}
|
||||
|
||||
inline float SmoothStep2( float t )
|
||||
{
|
||||
return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
|
||||
}
|
||||
|
||||
inline float SmoothStepStart( float t )
|
||||
{
|
||||
t = 0.5f * t;
|
||||
t = 3 * t * t - 2.0f * t * t * t;
|
||||
t = t* 2.0f;
|
||||
return t;
|
||||
}
|
||||
|
||||
inline float SmoothStepEnd( float t )
|
||||
{
|
||||
t = 0.5f * t + 0.5f;
|
||||
t = 3 * t * t - 2.0f * t * t * t;
|
||||
t = (t - 0.5f) * 2.0f;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSAchievementAnnouncePanel::CCSAchievementAnnouncePanel( const char *pElementName )
|
||||
: EditablePanel( NULL, "AchievementAnnouncePanel" ), CHudElement( pElementName )
|
||||
{
|
||||
vgui::Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
m_bShouldBeVisible = false;
|
||||
SetScheme( "ClientScheme" );
|
||||
m_currentDisplayedAchievement = CSInvalidAchievement;
|
||||
m_pGlowPanel = NULL;
|
||||
|
||||
RegisterForRenderGroup( "hide_for_scoreboard" );
|
||||
|
||||
//Create the grey popup that has the name, text and icon.
|
||||
m_pAchievementInfoPanel = new CCSAchivementInfoPanel(this, "InfoPanel");
|
||||
}
|
||||
|
||||
CCSAchievementAnnouncePanel::~CCSAchievementAnnouncePanel()
|
||||
{
|
||||
if (m_pAchievementInfoPanel)
|
||||
{
|
||||
delete m_pAchievementInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCSAchievementAnnouncePanel::Reset()
|
||||
{
|
||||
//We don't want to hide the UI here since we want the achievement popup to show through death
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::Init()
|
||||
{
|
||||
ListenForGameEvent( "achievement_earned_local" );
|
||||
|
||||
Hide();
|
||||
|
||||
CHudElement::Init();
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
LoadControlSettings( "Resource/UI/Achievement_Glow.res" );
|
||||
|
||||
//This is the glowy flash that comes up under the popup
|
||||
m_pGlowPanel = dynamic_cast<EditablePanel *>( FindChildByName("GlowPanel") );
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
ConVar cl_show_achievement_popups( "cl_show_achievement_popups", "1", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );
|
||||
|
||||
|
||||
void CCSAchievementAnnouncePanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *pEventName = event->GetName();
|
||||
|
||||
if ( cl_show_achievement_popups.GetBool() )
|
||||
{
|
||||
if ( Q_strcmp( "achievement_earned_local", pEventName ) == 0 )
|
||||
{
|
||||
//Add achievement to queue and show the UI (since the UI doesn't "Think()" until it is shown
|
||||
Show();
|
||||
m_achievementQueue.Insert((eCSAchievementType)event->GetInt("achievement"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::Show()
|
||||
{
|
||||
m_bShouldBeVisible = true;
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::Hide()
|
||||
{
|
||||
m_bShouldBeVisible = false;
|
||||
}
|
||||
|
||||
bool CCSAchievementAnnouncePanel::ShouldDraw( void )
|
||||
{
|
||||
return (m_bShouldBeVisible && CHudElement::ShouldDraw());
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::Paint( void )
|
||||
{
|
||||
}
|
||||
|
||||
void CCSAchievementAnnouncePanel::OnThink( void )
|
||||
{
|
||||
BaseClass::OnThink();
|
||||
|
||||
if (!m_pAchievementInfoPanel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if we have an achievement, update it
|
||||
if (m_currentDisplayedAchievement != CSInvalidAchievement)
|
||||
{
|
||||
//If the match restarts, we need to move the start time for the achievement back.
|
||||
if (m_displayStartTime > gpGlobals->curtime)
|
||||
{
|
||||
m_displayStartTime = gpGlobals->curtime;
|
||||
}
|
||||
float timeSinceDisplayStart = gpGlobals->curtime - m_displayStartTime;
|
||||
float glowAlpha;
|
||||
float achievementPanelAlpha;
|
||||
|
||||
//Update the flash
|
||||
if (m_pGlowPanel)
|
||||
{
|
||||
GetGlowAlpha(timeSinceDisplayStart, glowAlpha);
|
||||
m_pGlowPanel->SetAlpha(glowAlpha);
|
||||
}
|
||||
|
||||
if (GetAchievementPanelAlpha(timeSinceDisplayStart, achievementPanelAlpha))
|
||||
{
|
||||
m_pAchievementInfoPanel->SetAlpha(achievementPanelAlpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
//achievement is faded, so we are done
|
||||
m_pAchievementInfoPanel->SetAlpha(0);
|
||||
m_currentDisplayedAchievement = CSInvalidAchievement;
|
||||
|
||||
if (m_achievementQueue.Count() == 0)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check if we need to start the next announcement in the queue. We won't update it this frame, but no time has elapsed anyway.
|
||||
if (m_achievementQueue.Count() > 0)
|
||||
{
|
||||
m_currentDisplayedAchievement = m_achievementQueue.RemoveAtHead();
|
||||
m_displayStartTime = gpGlobals->curtime;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [dwenger] Play the achievement earned sound effect
|
||||
//=============================================================================
|
||||
|
||||
vgui::surface()->PlaySound( "UI/achievement_earned.wav" );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
//Here we get the achievement to be displayed and set that in the popup windows
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByID( m_currentDisplayedAchievement );
|
||||
if ( pAchievement )
|
||||
{
|
||||
m_pAchievementInfoPanel->SetAchievement(pAchievement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CCSAchievementAnnouncePanel::GetAlphaFromTime(float elapsedTime, float delay, float fadeInTime, float holdTime, float fadeOutTime, float&alpha)
|
||||
{
|
||||
//We just pass through each phase, subtracting off the full time if we are already done with that phase
|
||||
//We return whether the control should still be active
|
||||
|
||||
//I. Delay before fading in
|
||||
if (elapsedTime > delay)
|
||||
{
|
||||
elapsedTime -= delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//II. Fade in time
|
||||
if (elapsedTime > fadeInTime)
|
||||
{
|
||||
elapsedTime -= fadeInTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = 255.0f * elapsedTime / fadeInTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//III. Hold at full alpha time
|
||||
if (elapsedTime > holdTime)
|
||||
{
|
||||
elapsedTime -= holdTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = 255.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
//IV. Fade out time
|
||||
if (elapsedTime > fadeOutTime)
|
||||
{
|
||||
alpha = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = 1.0f - (elapsedTime / fadeOutTime);
|
||||
alpha = Interpolators::SmoothStepStart(alpha);
|
||||
alpha *= 255.0f;
|
||||
|
||||
if (m_achievementQueue.Count() > 0 && alpha < 128.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ConVar glow_delay( "glow_delay", "0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar glow_fadeInTime( "glow_fadeInTime", "0.1", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar glow_holdTime( "glow_holdTime", "0.1", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar glow_fadeOutTime( "glow_fadeOutTime", "2.5", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
|
||||
bool CCSAchievementAnnouncePanel::GetGlowAlpha (float time, float& alpha)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
float delay = 0.0f;
|
||||
float fadeInTime = 0.3f;
|
||||
float holdTime = 0.1f;
|
||||
float fadeOutTime = 0.4f;
|
||||
*/
|
||||
|
||||
//return GetAlphaFromTime(time, delay, fadeInTime, holdTime, fadeOutTime, alpha);
|
||||
|
||||
return GetAlphaFromTime(time, glow_delay.GetFloat(), glow_fadeInTime.GetFloat(), glow_holdTime.GetFloat(), glow_fadeOutTime.GetFloat(), alpha);
|
||||
}
|
||||
|
||||
|
||||
ConVar popup_delay( "popup_delay", "0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar popup_fadeInTime( "popup_fadeInTime", "0.3", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar popup_holdTime( "popup_holdTime", "3.5", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
ConVar popup_fadeOutTime( "popup_fadeOutTime", "3.0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY);
|
||||
|
||||
bool CCSAchievementAnnouncePanel::GetAchievementPanelAlpha (float time, float& alpha)
|
||||
{
|
||||
/*
|
||||
float delay = 0.2f;
|
||||
float fadeInTime = 0.3f;
|
||||
float holdTime = 3.0f;
|
||||
float fadeOutTime = 2.0f;
|
||||
*/
|
||||
|
||||
//return GetAlphaFromTime(time, delay, fadeInTime, holdTime, fadeOutTime, alpha);
|
||||
|
||||
return GetAlphaFromTime(time, popup_delay.GetFloat(), popup_fadeInTime.GetFloat(), popup_holdTime.GetFloat(), popup_fadeOutTime.GetFloat(), alpha);
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: creates child panels, passes down name to pick up any settings from res files.
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSAchivementInfoPanel::CCSAchivementInfoPanel( vgui::Panel *parent, const char* name ) : BaseClass( parent, name )
|
||||
{
|
||||
//Create the main components of the display and attach them to the panel
|
||||
m_pAchievementIcon = SETUP_PANEL(new vgui::ScalableImagePanel( this, "Icon" ));
|
||||
m_pAchievementNameLabel = new vgui::Label( this, "Name", "name" );
|
||||
m_pAchievementDescLabel = new vgui::Label( this, "Description", "desc" );
|
||||
}
|
||||
|
||||
CCSAchivementInfoPanel::~CCSAchivementInfoPanel()
|
||||
{
|
||||
if (m_pAchievementIcon)
|
||||
{
|
||||
delete m_pAchievementIcon;
|
||||
}
|
||||
|
||||
if (m_pAchievementNameLabel)
|
||||
{
|
||||
delete m_pAchievementNameLabel;
|
||||
}
|
||||
|
||||
if (m_pAchievementDescLabel)
|
||||
{
|
||||
delete m_pAchievementDescLabel;
|
||||
}
|
||||
}
|
||||
|
||||
void CCSAchivementInfoPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/Achievement_Popup.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
//Override the automatic scheme setting that happen above
|
||||
SetBgColor( pScheme->GetColor( "AchievementsLightGrey", Color(255, 0, 0, 255) ) );
|
||||
m_pAchievementNameLabel->SetFgColor(pScheme->GetColor("SteamLightGreen", Color(255, 255, 255, 255)));
|
||||
m_pAchievementDescLabel->SetFgColor(pScheme->GetColor("White", Color(255, 255, 255, 255)));
|
||||
}
|
||||
|
||||
void CCSAchivementInfoPanel::SetAchievement(IAchievement* pAchievement)
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [dwenger] Get achievement name and description text from the localized file
|
||||
//=============================================================================
|
||||
|
||||
// Set name and description
|
||||
m_pAchievementNameLabel->SetText( ACHIEVEMENT_LOCALIZED_NAME( pAchievement ) );
|
||||
m_pAchievementDescLabel->SetText( ACHIEVEMENT_LOCALIZED_DESC( pAchievement ) );
|
||||
|
||||
//Find, load and show the achievement icon
|
||||
char imagePath[_MAX_PATH];
|
||||
Q_strncpy( imagePath, "achievements\\", sizeof(imagePath) );
|
||||
Q_strncat( imagePath, pAchievement->GetName(), sizeof(imagePath), COPY_ALL_CHARACTERS );
|
||||
Q_strncat( imagePath, ".vtf", sizeof(imagePath), COPY_ALL_CHARACTERS );
|
||||
|
||||
char checkFile[_MAX_PATH];
|
||||
Q_snprintf( checkFile, sizeof(checkFile), "materials\\vgui\\%s", imagePath );
|
||||
if ( !g_pFullFileSystem->FileExists( checkFile ) )
|
||||
{
|
||||
Q_snprintf( imagePath, sizeof(imagePath), "hud\\icon_locked.vtf" );
|
||||
}
|
||||
|
||||
m_pAchievementIcon->SetImage( imagePath );
|
||||
m_pAchievementIcon->SetVisible( true );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CS_HUD_ACHIVEMENT_ANNOUNCE_H
|
||||
#define CS_HUD_ACHIVEMENT_ANNOUNCE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include <vgui_controls/ScalableImagePanel.h>
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui_avatarimage.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "cs_hud_playerhealth.h"
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class IAchievement;
|
||||
|
||||
|
||||
class CCSAchivementInfoPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCSAchivementInfoPanel, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CCSAchivementInfoPanel( vgui::Panel *parent, const char* name);
|
||||
~CCSAchivementInfoPanel();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
void SetAchievement(IAchievement* pAchievement);
|
||||
|
||||
private:
|
||||
vgui::Label *m_pAchievementNameLabel;
|
||||
vgui::Label *m_pAchievementDescLabel;
|
||||
vgui::ScalableImagePanel *m_pAchievementIcon;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CCSAchievementAnnouncePanel: public EditablePanel, public CHudElement
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSAchievementAnnouncePanel, EditablePanel );
|
||||
|
||||
public:
|
||||
CCSAchievementAnnouncePanel( const char *pElementName );
|
||||
~CCSAchievementAnnouncePanel();
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Init();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void Paint( void );
|
||||
void OnThink( void );
|
||||
bool GetAlphaFromTime(float elapsedTime, float delay, float fadeInTime, float holdTime, float fadeOutTime, float&alpha);
|
||||
|
||||
int HudElementKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
|
||||
|
||||
protected:
|
||||
bool GetGlowAlpha (float time, float& alpha);
|
||||
bool GetAchievementPanelAlpha (float time, float& alpha);
|
||||
|
||||
private:
|
||||
|
||||
CUtlQueue<eCSAchievementType> m_achievementQueue;
|
||||
eCSAchievementType m_currentDisplayedAchievement;
|
||||
float m_displayStartTime;
|
||||
|
||||
|
||||
vgui::EditablePanel *m_pGlowPanel;
|
||||
CCSAchivementInfoPanel *m_pAchievementInfoPanel;
|
||||
|
||||
bool m_bShouldBeVisible;
|
||||
};
|
||||
|
||||
#endif //CS_HUD_ACHIVEMENT_ANNOUNCE_H
|
||||
@@ -1,68 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
#include "cbase.h"
|
||||
#include "hud_baseachievement_tracker.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "iachievementmgr.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// The number of counter-strike HUD achievements to display
|
||||
const int cMaxCSHUDAchievments = 4;
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class CHudAchievementTracker : public CHudBaseAchievementTracker
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudAchievementTracker, CHudBaseAchievementTracker );
|
||||
|
||||
public:
|
||||
CHudAchievementTracker( const char *pElementName );
|
||||
virtual void OnThink();
|
||||
virtual void PerformLayout();
|
||||
virtual int GetMaxAchievementsShown();
|
||||
virtual bool ShouldShowAchievement( IAchievement *pAchievement );
|
||||
|
||||
private:
|
||||
CPanelAnimationVarAliasType( int, m_iNormalY, "NormalY", "5", "proportional_int" );
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CHudAchievementTracker );
|
||||
|
||||
|
||||
CHudAchievementTracker::CHudAchievementTracker( const char *pElementName ) : BaseClass( pElementName )
|
||||
{
|
||||
RegisterForRenderGroup( "hide_for_scoreboard" );
|
||||
}
|
||||
|
||||
void CHudAchievementTracker::OnThink()
|
||||
{
|
||||
BaseClass::OnThink();
|
||||
}
|
||||
|
||||
int CHudAchievementTracker::GetMaxAchievementsShown()
|
||||
{
|
||||
return MIN( BaseClass::GetMaxAchievementsShown(), cMaxCSHUDAchievments );
|
||||
}
|
||||
|
||||
void CHudAchievementTracker::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
int x, y;
|
||||
GetPos( x, y );
|
||||
SetPos( x, m_iNormalY );
|
||||
}
|
||||
|
||||
bool CHudAchievementTracker::ShouldShowAchievement( IAchievement *pAchievement )
|
||||
{
|
||||
if ( !BaseClass::ShouldShowAchievement(pAchievement) )
|
||||
return false;
|
||||
|
||||
C_CSPlayer *pPlayer = CCSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_macros.h"
|
||||
#include "hud_numericdisplay.h"
|
||||
#include "iclientmode.h"
|
||||
#include "ihudlcd.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays current ammunition level
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudAmmo : public CHudNumericDisplay, public CHudElement
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudAmmo, CHudNumericDisplay );
|
||||
|
||||
public:
|
||||
CHudAmmo( const char *pElementName );
|
||||
void Init( void );
|
||||
void VidInit( void );
|
||||
|
||||
void SetAmmo(int ammo, bool playAnimation);
|
||||
void SetAmmo2(int ammo2, bool playAnimation);
|
||||
|
||||
protected:
|
||||
virtual void OnThink();
|
||||
virtual void Paint( void );
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
private:
|
||||
CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
|
||||
int m_iAmmo;
|
||||
int m_iAmmo2;
|
||||
|
||||
bool m_bUsesClips;
|
||||
|
||||
int m_iAdditiveWhiteID;
|
||||
|
||||
CPanelAnimationVarAliasType( float, digit_xpos, "digit_xpos", "50", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, digit_ypos, "digit_ypos", "2", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, digit2_xpos, "digit2_xpos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, digit2_ypos, "digit2_ypos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, bar_xpos, "bar_xpos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, bar_ypos, "bar_ypos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, bar_width, "bar_width", "2", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, bar_height, "bar_height", "2", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, icon_xpos, "icon_xpos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, icon_ypos, "icon_ypos", "0", "proportional_float" );
|
||||
|
||||
CPanelAnimationVar( Color, m_TextColor, "TextColor", "FgColor" );
|
||||
CPanelAnimationVar( vgui::HFont, m_hNumberFont, "NumberFont", "HudNumbers" );
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CHudAmmo );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CHudAmmo::CHudAmmo( const char *pElementName ) : BaseClass(NULL, "HudAmmo"), CHudElement( pElementName )
|
||||
{
|
||||
m_iAdditiveWhiteID = vgui::surface()->CreateNewTextureID();
|
||||
vgui::surface()->DrawSetTextureFile( m_iAdditiveWhiteID, "vgui/white_additive" , true, false);
|
||||
|
||||
SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_WEAPONSELECTION );
|
||||
|
||||
hudlcd->SetGlobalStat( "(ammo_primary)", "0" );
|
||||
hudlcd->SetGlobalStat( "(ammo_secondary)", "0" );
|
||||
hudlcd->SetGlobalStat( "(weapon_print_name)", "" );
|
||||
hudlcd->SetGlobalStat( "(weapon_name)", "" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudAmmo::Init( void )
|
||||
{
|
||||
m_iAmmo = -1;
|
||||
m_iAmmo2 = -1;
|
||||
}
|
||||
|
||||
void CHudAmmo::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudAmmo::VidInit( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called every frame to get ammo info from the weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudAmmo::OnThink()
|
||||
{
|
||||
C_BaseCombatWeapon *wpn = GetActiveWeapon();
|
||||
|
||||
hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
|
||||
hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );
|
||||
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if (!wpn || !player || !wpn->UsesPrimaryAmmo())
|
||||
{
|
||||
hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
|
||||
hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
|
||||
|
||||
SetPaintEnabled(false);
|
||||
SetPaintBackgroundEnabled(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPaintEnabled(true);
|
||||
SetPaintBackgroundEnabled(true);
|
||||
}
|
||||
|
||||
// get the ammo in our clip
|
||||
int ammo1 = wpn->Clip1();
|
||||
int ammo2;
|
||||
if (ammo1 < 0)
|
||||
{
|
||||
// we don't use clip ammo, just use the total ammo count
|
||||
ammo1 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
|
||||
ammo2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we use clip ammo, so the second ammo is the total ammo
|
||||
ammo2 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
|
||||
}
|
||||
|
||||
hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
|
||||
hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );
|
||||
|
||||
if (wpn == m_hCurrentActiveWeapon)
|
||||
{
|
||||
// same weapon, just update counts
|
||||
SetAmmo(ammo1, true);
|
||||
SetAmmo2(ammo2, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// diferent weapon, change without triggering
|
||||
SetAmmo(ammo1, false);
|
||||
SetAmmo2(ammo2, false);
|
||||
|
||||
// update whether or not we show the total ammo display
|
||||
if (wpn->UsesClipsForAmmo1())
|
||||
{
|
||||
m_bUsesClips = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bUsesClips = false;
|
||||
}
|
||||
|
||||
m_hCurrentActiveWeapon = wpn;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Updates ammo display
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudAmmo::SetAmmo(int ammo, bool playAnimation)
|
||||
{
|
||||
if (ammo != m_iAmmo)
|
||||
{
|
||||
if (ammo == 0)
|
||||
{
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("PrimaryAmmoEmpty");
|
||||
}
|
||||
else if (ammo < m_iAmmo)
|
||||
{
|
||||
// ammo has decreased
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("PrimaryAmmoDecrement");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ammunition has increased
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("PrimaryAmmoIncrement");
|
||||
}
|
||||
|
||||
m_iAmmo = ammo;
|
||||
}
|
||||
|
||||
SetDisplayValue(ammo);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Updates 2nd ammo display
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudAmmo::SetAmmo2(int ammo2, bool playAnimation)
|
||||
{
|
||||
if (ammo2 != m_iAmmo2)
|
||||
{
|
||||
if (ammo2 == 0)
|
||||
{
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SecondaryAmmoEmpty");
|
||||
}
|
||||
else if (ammo2 < m_iAmmo2)
|
||||
{
|
||||
// ammo has decreased
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SecondaryAmmoDecrement");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ammunition has increased
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SecondaryAmmoIncrement");
|
||||
}
|
||||
|
||||
m_iAmmo2 = ammo2;
|
||||
}
|
||||
}
|
||||
|
||||
void CHudAmmo::Paint( void )
|
||||
{
|
||||
float alpha = 1.0f;
|
||||
Color fgColor = GetFgColor();
|
||||
fgColor[3] *= alpha;
|
||||
SetFgColor( fgColor );
|
||||
|
||||
int x, y;
|
||||
|
||||
if( m_bUsesClips )
|
||||
{
|
||||
x = digit_xpos;
|
||||
y = digit_ypos;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = digit2_xpos;
|
||||
y = digit2_ypos;
|
||||
}
|
||||
|
||||
// Assume constant width font
|
||||
int charWidth = vgui::surface()->GetCharacterWidth( m_hNumberFont, '0' );
|
||||
|
||||
int digits = clamp( log10((double)m_iAmmo)+1, 1, 3 );
|
||||
|
||||
x += ( 3 - digits ) * charWidth;
|
||||
|
||||
// draw primary ammo
|
||||
vgui::surface()->DrawSetTextColor(GetFgColor());
|
||||
PaintNumbers( m_hNumberFont, x, y, m_iAmmo );
|
||||
|
||||
//draw reserve ammo
|
||||
if( m_bUsesClips )
|
||||
{
|
||||
//draw the divider
|
||||
Color c = GetFgColor();
|
||||
vgui::surface()->DrawSetColor(c);
|
||||
vgui::surface()->DrawSetTexture( m_iAdditiveWhiteID );
|
||||
vgui::surface()->DrawTexturedRect( bar_xpos, bar_ypos, bar_xpos + bar_width, bar_ypos + bar_height );
|
||||
|
||||
digits = clamp( log10((double)m_iAmmo2)+1, 1, 3 );
|
||||
x = digit2_xpos + ( 3 - digits ) * charWidth;
|
||||
|
||||
// draw secondary ammo
|
||||
vgui::surface()->DrawSetTextColor(GetFgColor());
|
||||
PaintNumbers( m_hNumberFont, x, digit2_ypos, m_iAmmo2 );
|
||||
}
|
||||
|
||||
//draw the icon
|
||||
C_BaseCombatWeapon *wpn = GetActiveWeapon();
|
||||
if( wpn )
|
||||
{
|
||||
int ammoType = wpn->GetPrimaryAmmoType();
|
||||
|
||||
CHudTexture *icon = gWR.GetAmmoIconFromWeapon( ammoType );
|
||||
|
||||
if( icon )
|
||||
{
|
||||
float icon_tall = GetTall() - YRES(2);
|
||||
float scale = icon_tall / (float)icon->Height();
|
||||
float icon_wide = ( scale ) * (float)icon->Width();
|
||||
|
||||
icon->DrawSelf( icon_xpos, icon_ypos, icon_wide, icon_tall, GetFgColor() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,355 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud_radar.h"
|
||||
#include "cs_hud_chat.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "hud_macros.h"
|
||||
#include "text_message.h"
|
||||
#include "vguicenterprint.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "radio_status.h"
|
||||
#include "cstrike/bot/shared_util.h"
|
||||
#include "ihudlcd.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( CHudChat );
|
||||
|
||||
DECLARE_HUD_MESSAGE( CHudChat, RadioText );
|
||||
DECLARE_HUD_MESSAGE( CHudChat, SayText );
|
||||
DECLARE_HUD_MESSAGE( CHudChat, SayText2 );
|
||||
DECLARE_HUD_MESSAGE( CHudChat, TextMsg );
|
||||
DECLARE_HUD_MESSAGE( CHudChat, RawAudio );
|
||||
|
||||
|
||||
//=====================
|
||||
//CHudChatLine
|
||||
//=====================
|
||||
|
||||
CHudChatLine::CHudChatLine( vgui::Panel *parent, const char *panelName ) : CBaseHudChatLine( parent, panelName )
|
||||
{
|
||||
m_text = NULL;
|
||||
}
|
||||
|
||||
void CHudChatLine::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
//=====================
|
||||
//CHudChatInputLine
|
||||
//=====================
|
||||
|
||||
void CHudChatInputLine::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
|
||||
vgui::HFont hFont = pScheme->GetFont( "ChatFont" );
|
||||
|
||||
m_pPrompt->SetFont( hFont );
|
||||
m_pInput->SetFont( hFont );
|
||||
|
||||
m_pInput->SetFgColor( pScheme->GetColor( "Chat.TypingText", pScheme->GetColor( "Panel.FgColor", Color( 255, 255, 255, 255 ) ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=====================
|
||||
//CHudChat
|
||||
//=====================
|
||||
|
||||
CHudChat::CHudChat( const char *pElementName ) : BaseClass( pElementName )
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [tj] Add this to the render group that disappears when the scoreboard is up
|
||||
//
|
||||
// [pmf] Removed from render group so that chat still works during intermission
|
||||
// (when the scoreboard is forced to be up). The downside is that chat shows
|
||||
// over the scoreboard during regular play, but this might be less of an issue
|
||||
// if we reduce the need to display it constantly by adding HUD support for
|
||||
// live player counts.
|
||||
//=============================================================================
|
||||
// RegisterForRenderGroup("hide_for_scoreboard");
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
|
||||
void CHudChat::CreateChatInputLine( void )
|
||||
{
|
||||
m_pChatInput = new CHudChatInputLine( this, "ChatInputLine" );
|
||||
m_pChatInput->SetVisible( false );
|
||||
}
|
||||
|
||||
void CHudChat::CreateChatLines( void )
|
||||
{
|
||||
#ifndef _XBOX
|
||||
m_ChatLine = new CHudChatLine( this, "ChatLine1" );
|
||||
m_ChatLine->SetVisible( false );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void CHudChat::Init( void )
|
||||
{
|
||||
BaseClass::Init();
|
||||
|
||||
HOOK_HUD_MESSAGE( CHudChat, RadioText );
|
||||
HOOK_HUD_MESSAGE( CHudChat, SayText );
|
||||
HOOK_HUD_MESSAGE( CHudChat, SayText2 );
|
||||
HOOK_HUD_MESSAGE( CHudChat, TextMsg );
|
||||
HOOK_HUD_MESSAGE( CHudChat, RawAudio );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Overrides base reset to not cancel chat at round restart
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudChat::Reset( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reads in a player's Radio text from the server
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudChat::MsgFunc_RadioText( bf_read &msg )
|
||||
{
|
||||
int msg_dest = msg.ReadByte();
|
||||
NOTE_UNUSED( msg_dest );
|
||||
int client = msg.ReadByte();
|
||||
|
||||
wchar_t szBuf[6][128];
|
||||
wchar_t *msg_text = ReadLocalizedString( msg, szBuf[0], sizeof( szBuf[0] ), false );
|
||||
|
||||
// keep reading strings and using C format strings for subsituting the strings into the localised text string
|
||||
ReadChatTextString ( msg, szBuf[1], sizeof( szBuf[1] ) ); // player name
|
||||
ReadLocalizedString( msg, szBuf[2], sizeof( szBuf[2] ), true ); // location
|
||||
ReadLocalizedString( msg, szBuf[3], sizeof( szBuf[3] ), true ); // radio text
|
||||
ReadLocalizedString( msg, szBuf[4], sizeof( szBuf[4] ), true ); // unused :(
|
||||
|
||||
g_pVGuiLocalize->ConstructString( szBuf[5], sizeof( szBuf[5] ), msg_text, 4, szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
|
||||
char ansiString[512];
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( ConvertCRtoNL( szBuf[5] ), ansiString, sizeof( ansiString ) );
|
||||
ChatPrintf( client, CHAT_FILTER_TEAMCHANGE, "%s", ansiString );
|
||||
|
||||
CLocalPlayerFilter filter;
|
||||
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HudChat.Message" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reads in a player's Chat text from the server
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudChat::MsgFunc_SayText2( bf_read &msg )
|
||||
{
|
||||
// Got message during connection
|
||||
if ( !g_PR )
|
||||
return;
|
||||
|
||||
int client = msg.ReadByte();
|
||||
bool bWantsToChat = msg.ReadByte();
|
||||
|
||||
wchar_t szBuf[6][256];
|
||||
char untranslated_msg_text[256];
|
||||
wchar_t *msg_text = ReadLocalizedString( msg, szBuf[0], sizeof( szBuf[0] ), false, untranslated_msg_text, sizeof( untranslated_msg_text ) );
|
||||
|
||||
// keep reading strings and using C format strings for subsituting the strings into the localised text string
|
||||
ReadChatTextString ( msg, szBuf[1], sizeof( szBuf[1] ) ); // player name
|
||||
ReadChatTextString ( msg, szBuf[2], sizeof( szBuf[2] ) ); // chat text
|
||||
ReadLocalizedString( msg, szBuf[3], sizeof( szBuf[3] ), true ); // location
|
||||
ReadLocalizedString( msg, szBuf[4], sizeof( szBuf[4] ), true ); // unused :(
|
||||
|
||||
g_pVGuiLocalize->ConstructString( szBuf[5], sizeof( szBuf[5] ), msg_text, 4, szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
|
||||
char ansiString[512];
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( ConvertCRtoNL( szBuf[5] ), ansiString, sizeof( ansiString ) );
|
||||
|
||||
// flash speaking player dot
|
||||
if ( client > 0 )
|
||||
Radar_FlashPlayer( client );
|
||||
|
||||
if ( bWantsToChat )
|
||||
{
|
||||
int iFilter = CHAT_FILTER_NONE;
|
||||
bool playChatSound = true;
|
||||
|
||||
if ( client > 0 && (g_PR->GetTeam( client ) != g_PR->GetTeam( GetLocalPlayerIndex() )) )
|
||||
{
|
||||
iFilter = CHAT_FILTER_PUBLICCHAT;
|
||||
if ( !( iFilter & GetFilterFlags() ) )
|
||||
{
|
||||
playChatSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
// print raw chat text
|
||||
ChatPrintf( client, iFilter, "%s", ansiString );
|
||||
|
||||
Msg( "%s\n", RemoveColorMarkup(ansiString) );
|
||||
|
||||
if ( playChatSound )
|
||||
{
|
||||
CLocalPlayerFilter filter;
|
||||
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HudChat.Message" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// print raw chat text
|
||||
ChatPrintf( client, GetFilterForString( untranslated_msg_text), "%s", ansiString );
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CHudChat::GetChatInputOffset( void )
|
||||
{
|
||||
if ( m_pChatInput->IsVisible() )
|
||||
{
|
||||
return m_iFontHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reads in an Audio message from the server (wav file to be played
|
||||
// via the player's voice, i.e. for bot chatter)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudChat::MsgFunc_RawAudio( bf_read &msg )
|
||||
{
|
||||
char szString[2048];
|
||||
int pitch = msg.ReadByte();
|
||||
int playerIndex = msg.ReadByte();
|
||||
float feedbackDuration = msg.ReadFloat();
|
||||
msg.ReadString( szString, sizeof(szString) );
|
||||
|
||||
EmitSound_t ep;
|
||||
ep.m_nChannel = CHAN_VOICE;
|
||||
ep.m_pSoundName = szString;
|
||||
ep.m_flVolume = 1.0f;
|
||||
ep.m_SoundLevel = SNDLVL_NORM;
|
||||
ep.m_nPitch = pitch;
|
||||
|
||||
CLocalPlayerFilter filter;
|
||||
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, ep );
|
||||
|
||||
if ( feedbackDuration > 0.0f )
|
||||
{
|
||||
//Flash them on the radar
|
||||
C_CSPlayer *pPlayer = static_cast<C_CSPlayer*>( cl_entitylist->GetEnt(playerIndex) );
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
// Create the flashy above player's head
|
||||
RadioManager()->UpdateVoiceStatus( playerIndex, feedbackDuration );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Color CHudChat::GetClientColor( int clientIndex )
|
||||
{
|
||||
if ( clientIndex == 0 ) // console msg
|
||||
{
|
||||
return g_ColorGreen;
|
||||
}
|
||||
else if( g_PR )
|
||||
{
|
||||
switch ( g_PR->GetTeam( clientIndex ) )
|
||||
{
|
||||
case 2 : return g_ColorRed;
|
||||
case 3 : return g_ColorBlue;
|
||||
default : return g_ColorGrey;
|
||||
}
|
||||
}
|
||||
|
||||
return g_ColorYellow;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
Color CHudChat::GetTextColorForClient( TextColor colorNum, int clientIndex )
|
||||
{
|
||||
Color c;
|
||||
switch ( colorNum )
|
||||
{
|
||||
case COLOR_PLAYERNAME:
|
||||
c = GetClientColor( clientIndex );
|
||||
break;
|
||||
|
||||
case COLOR_LOCATION:
|
||||
c = g_ColorDarkGreen;
|
||||
break;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [tj] Adding support for achievement coloring.
|
||||
// Just doing what all the other games do
|
||||
//=============================================================================
|
||||
|
||||
case COLOR_ACHIEVEMENT:
|
||||
{
|
||||
vgui::IScheme *pSourceScheme = vgui::scheme()->GetIScheme( vgui::scheme()->GetScheme( "SourceScheme" ) );
|
||||
if ( pSourceScheme )
|
||||
{
|
||||
c = pSourceScheme->GetColor( "SteamLightGreen", GetBgColor() );
|
||||
}
|
||||
else
|
||||
{
|
||||
c = GetDefaultTextColor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
|
||||
default:
|
||||
c = g_ColorYellow;
|
||||
}
|
||||
|
||||
return Color( c[0], c[1], c[2], 255 );
|
||||
}
|
||||
|
||||
int CHudChat::GetFilterForString( const char *pString )
|
||||
{
|
||||
int iFilter = BaseClass::GetFilterForString( pString );
|
||||
|
||||
if ( iFilter == CHAT_FILTER_NONE )
|
||||
{
|
||||
if ( !Q_stricmp( pString, "#CStrike_Name_Change" ) )
|
||||
{
|
||||
return CHAT_FILTER_NAMECHANGE;
|
||||
}
|
||||
}
|
||||
|
||||
return iFilter;
|
||||
}
|
||||
|
||||
void CHudChat::StartMessageMode( int iMessageModeType )
|
||||
{
|
||||
BaseClass::StartMessageMode(iMessageModeType);
|
||||
|
||||
vgui::ipanel()->SetTopmostPopup(GetVPanel(), true);
|
||||
}
|
||||
|
||||
void CHudChat::StopMessageMode( void )
|
||||
{
|
||||
vgui::ipanel()->SetTopmostPopup(GetVPanel(), false);
|
||||
|
||||
BaseClass::StopMessageMode();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CS_HUD_CHAT_H
|
||||
#define CS_HUD_CHAT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <hud_basechat.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
class CHudChatLine : public CBaseHudChatLine
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudChatLine, CBaseHudChatLine );
|
||||
|
||||
public:
|
||||
CHudChatLine( vgui::Panel *parent, const char *panelName );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
private:
|
||||
CHudChatLine( const CHudChatLine & ); // not defined, not accessible
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The prompt and text entry area for chat messages
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudChatInputLine : public CBaseHudChatInputLine
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudChatInputLine, CBaseHudChatInputLine );
|
||||
|
||||
public:
|
||||
CHudChatInputLine( CBaseHudChat *parent, char const *panelName ) : CBaseHudChatInputLine( parent, panelName ) {}
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
};
|
||||
|
||||
class CHudChat : public CBaseHudChat
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudChat, CBaseHudChat );
|
||||
|
||||
public:
|
||||
CHudChat( const char *pElementName );
|
||||
|
||||
virtual void CreateChatInputLine( void );
|
||||
virtual void CreateChatLines( void );
|
||||
|
||||
virtual void Init( void );
|
||||
virtual void Reset( void );
|
||||
|
||||
virtual void StartMessageMode( int iMessageModeType );
|
||||
virtual void StopMessageMode( void );
|
||||
|
||||
virtual void MsgFunc_SayText2( bf_read &msg );
|
||||
virtual void MsgFunc_RadioText( bf_read &msg );
|
||||
void MsgFunc_RawAudio( bf_read &msg );
|
||||
|
||||
int GetChatInputOffset( void );
|
||||
|
||||
|
||||
virtual Color GetTextColorForClient( TextColor colorNum, int clientIndex );
|
||||
virtual Color GetClientColor( int clientIndex );
|
||||
|
||||
virtual int GetFilterForString( const char *pString );
|
||||
};
|
||||
|
||||
#endif //CS_HUD_CHAT_H
|
||||
@@ -1,362 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "text_message.h"
|
||||
#include "hud_macros.h"
|
||||
#include "iclientmode.h"
|
||||
#include "view.h"
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "IEffects.h"
|
||||
#include "hudelement.h"
|
||||
// NVNT damage
|
||||
#include "haptics/haptic_utils.h"
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: HDU Damage indication
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudDamageIndicator : public CHudElement, public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudDamageIndicator, vgui::Panel );
|
||||
|
||||
public:
|
||||
CHudDamageIndicator( const char *pElementName );
|
||||
|
||||
void Init( void );
|
||||
void Reset( void );
|
||||
bool ShouldDraw( void );
|
||||
|
||||
// Handler for our message
|
||||
void MsgFunc_Damage( bf_read &msg );
|
||||
|
||||
private:
|
||||
void Paint();
|
||||
void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
private:
|
||||
void CalcDamageDirection( const Vector &vecFrom );
|
||||
void DrawDamageIndicatorFront( float flFade );
|
||||
void DrawDamageIndicatorRear( float flFade );
|
||||
void DrawDamageIndicatorLeft( float flFade );
|
||||
void DrawDamageIndicatorRight( float flFade );
|
||||
|
||||
private:
|
||||
float m_flAttackFront;
|
||||
float m_flAttackRear;
|
||||
float m_flAttackLeft;
|
||||
float m_flAttackRight;
|
||||
|
||||
Color m_clrIndicator;
|
||||
|
||||
CHudTexture *icon_up;
|
||||
CHudTexture *icon_down;
|
||||
CHudTexture *icon_left;
|
||||
CHudTexture *icon_right;
|
||||
|
||||
float m_flFadeCompleteTime; //don't draw past this time
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CHudDamageIndicator );
|
||||
DECLARE_HUD_MESSAGE( CHudDamageIndicator, Damage );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CHudDamageIndicator::CHudDamageIndicator( const char *pElementName ) : CHudElement( pElementName ), BaseClass(NULL, "HudDamageIndicator")
|
||||
{
|
||||
vgui::Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
SetHiddenBits( HIDEHUD_HEALTH );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudDamageIndicator::Reset( void )
|
||||
{
|
||||
m_flAttackFront = 0.0;
|
||||
m_flAttackRear = 0.0;
|
||||
m_flAttackRight = 0.0;
|
||||
m_flAttackLeft = 0.0;
|
||||
|
||||
m_flFadeCompleteTime = 0.0;
|
||||
|
||||
m_clrIndicator.SetColor( 250, 0, 0, 255 );
|
||||
}
|
||||
|
||||
void CHudDamageIndicator::Init( void )
|
||||
{
|
||||
HOOK_HUD_MESSAGE( CHudDamageIndicator, Damage );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHudDamageIndicator::ShouldDraw( void )
|
||||
{
|
||||
if ( !CHudElement::ShouldDraw() )
|
||||
return false;
|
||||
|
||||
if ( ( m_flAttackFront <= 0.0 ) && ( m_flAttackRear <= 0.0 ) && ( m_flAttackLeft <= 0.0 ) && ( m_flAttackRight <= 0.0 ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CHudDamageIndicator::DrawDamageIndicatorFront( float flFade )
|
||||
{
|
||||
if ( m_flAttackFront > 0.4 )
|
||||
{
|
||||
if ( !icon_up )
|
||||
{
|
||||
icon_up = gHUD.GetIcon( "pain_up" );
|
||||
}
|
||||
|
||||
if ( !icon_up )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = ( ScreenWidth() / 2 ) - icon_up->Width() / 2;
|
||||
int y = ( ScreenHeight() / 2 ) - icon_up->Height() * 3;
|
||||
icon_up->DrawSelf( x, y, m_clrIndicator );
|
||||
|
||||
m_flAttackFront = MAX( 0.0, m_flAttackFront - flFade );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flAttackFront = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
void CHudDamageIndicator::DrawDamageIndicatorRear( float flFade )
|
||||
{
|
||||
if ( m_flAttackRear > 0.4 )
|
||||
{
|
||||
if ( !icon_down )
|
||||
{
|
||||
icon_down = gHUD.GetIcon( "pain_down" );
|
||||
}
|
||||
|
||||
if ( !icon_down )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = ( ScreenWidth() / 2 ) - icon_down->Width() / 2;
|
||||
int y = ( ScreenHeight() / 2 ) + icon_down->Height() * 2;
|
||||
icon_down->DrawSelf( x, y, m_clrIndicator );
|
||||
|
||||
m_flAttackRear = MAX( 0.0, m_flAttackRear - flFade );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flAttackRear = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHudDamageIndicator::DrawDamageIndicatorLeft( float flFade )
|
||||
{
|
||||
if ( m_flAttackLeft > 0.4 )
|
||||
{
|
||||
if ( !icon_left )
|
||||
{
|
||||
icon_left = gHUD.GetIcon( "pain_left" );
|
||||
}
|
||||
|
||||
if ( !icon_left )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = ( ScreenWidth() / 2 ) - icon_left->Width() * 3;
|
||||
int y = ( ScreenHeight() / 2 ) - icon_left->Height() / 2;
|
||||
icon_left->DrawSelf( x, y, m_clrIndicator );
|
||||
|
||||
m_flAttackLeft = MAX( 0.0, m_flAttackLeft - flFade );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flAttackLeft = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHudDamageIndicator::DrawDamageIndicatorRight( float flFade )
|
||||
{
|
||||
if ( m_flAttackRight > 0.4 )
|
||||
{
|
||||
if ( !icon_right )
|
||||
{
|
||||
icon_right = gHUD.GetIcon( "pain_right" );
|
||||
}
|
||||
|
||||
if ( !icon_right )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = ( ScreenWidth() / 2 ) + icon_right->Width() * 2;
|
||||
int y = ( ScreenHeight() / 2 ) - icon_right->Height() / 2;
|
||||
icon_right->DrawSelf( x, y, m_clrIndicator );
|
||||
|
||||
m_flAttackRight = MAX( 0.0, m_flAttackRight - flFade );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flAttackRight = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Paints the damage display
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudDamageIndicator::Paint()
|
||||
{
|
||||
if( m_flFadeCompleteTime > gpGlobals->curtime )
|
||||
{
|
||||
float flFade = gpGlobals->frametime * 2;
|
||||
// draw damage indicators
|
||||
DrawDamageIndicatorFront( flFade );
|
||||
DrawDamageIndicatorRear( flFade );
|
||||
DrawDamageIndicatorLeft( flFade );
|
||||
DrawDamageIndicatorRight( flFade );
|
||||
}
|
||||
}
|
||||
// NVNT static to pass damage
|
||||
static float hap_damage_amount = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Message handler for Damage message
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudDamageIndicator::MsgFunc_Damage( bf_read &msg )
|
||||
{
|
||||
int damageTaken = msg.ReadByte();
|
||||
|
||||
Vector vecFrom;
|
||||
msg.ReadBitVec3Coord( vecFrom );
|
||||
|
||||
// NVNT pass damage to static holder
|
||||
hap_damage_amount = damageTaken;
|
||||
|
||||
if ( damageTaken > 0 )
|
||||
{
|
||||
m_flFadeCompleteTime = gpGlobals->curtime + 1.0;
|
||||
CalcDamageDirection( vecFrom );
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Added reads for the added location based parameters to this message
|
||||
//=============================================================================
|
||||
msg.ReadLong();
|
||||
msg.ReadBitVec3Coord( vecFrom );
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
|
||||
void CHudDamageIndicator::CalcDamageDirection( const Vector &vecFrom )
|
||||
{
|
||||
if ( vecFrom == vec3_origin )
|
||||
{
|
||||
m_flAttackFront = 0.0;
|
||||
m_flAttackRear = 0.0;
|
||||
m_flAttackRight = 0.0;
|
||||
m_flAttackLeft = 0.0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pLocalPlayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vecDelta = ( vecFrom - pLocalPlayer->GetRenderOrigin() );
|
||||
|
||||
if ( vecDelta.Length() <= 50 )
|
||||
{
|
||||
m_flAttackFront = 1.0;
|
||||
m_flAttackRear = 1.0;
|
||||
m_flAttackRight = 1.0;
|
||||
m_flAttackLeft = 1.0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VectorNormalize( vecDelta );
|
||||
|
||||
Vector forward;
|
||||
Vector right;
|
||||
Vector up;
|
||||
AngleVectors( MainViewAngles(), &forward, &right, &up );
|
||||
|
||||
|
||||
float flFront = DotProduct( vecDelta, forward );
|
||||
float flSide = DotProduct( vecDelta, right );
|
||||
float flUp = DotProduct( vecDelta, up);
|
||||
|
||||
if ( flFront > 0 )
|
||||
{
|
||||
if ( flFront > 0.3 )
|
||||
m_flAttackFront = MAX( m_flAttackFront, flFront );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( flFront );
|
||||
if ( f > 0.3 )
|
||||
m_flAttackRear = MAX( m_flAttackRear, f );
|
||||
}
|
||||
|
||||
if ( flSide > 0 )
|
||||
{
|
||||
if ( flSide > 0.3 )
|
||||
m_flAttackRight = MAX( m_flAttackRight, flSide );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( flSide );
|
||||
if ( f > 0.3 )
|
||||
m_flAttackLeft = MAX( m_flAttackLeft, f );
|
||||
}
|
||||
|
||||
// NVNT pass damage. (use hap_damage amount to apply)
|
||||
// do rotation
|
||||
Vector hapDir(-flSide,-flUp,flFront);
|
||||
if ( haptics )
|
||||
haptics->ApplyDamageEffect(hap_damage_amount, 0, hapDir);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: hud scheme settings
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudDamageIndicator::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
SetPaintBackgroundEnabled(false);
|
||||
|
||||
int wide, tall;
|
||||
GetHudSize(wide, tall);
|
||||
SetSize(wide, tall);
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cs_hud_freezepanel.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "vgui_controls/AnimationController.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "VGUI/bordered_panel.h"
|
||||
#include "fmtstr.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "view.h"
|
||||
#include "ivieweffects.h"
|
||||
#include "viewrender.h"
|
||||
#include "usermessages.h"
|
||||
#include "hud_macros.h"
|
||||
#include "c_baseanimating.h"
|
||||
#include "backgroundpanel.h" // rounded border support
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( CCSFreezePanel, 1 );
|
||||
// DECLARE_HUD_MESSAGE( CCSFreezePanel, Damage );
|
||||
// DECLARE_HUD_MESSAGE( CCSFreezePanel, DroppedEquipment );
|
||||
|
||||
#define CALLOUT_WIDE (XRES(100))
|
||||
#define CALLOUT_TALL (XRES(50))
|
||||
|
||||
|
||||
ConVar cl_disablefreezecam(
|
||||
"cl_disablefreezecam",
|
||||
"0",
|
||||
FCVAR_ARCHIVE,
|
||||
"Turn on/off freezecam on client"
|
||||
);
|
||||
|
||||
|
||||
Color LerpColors( Color cStart, Color cEnd, float flPercent )
|
||||
{
|
||||
float r = (float)((float)(cStart.r()) + (float)(cEnd.r() - cStart.r()) * flPercent);
|
||||
float g = (float)((float)(cStart.g()) + (float)(cEnd.g() - cStart.g()) * flPercent);
|
||||
float b = (float)((float)(cStart.b()) + (float)(cEnd.b() - cStart.b()) * flPercent);
|
||||
float a = (float)((float)(cStart.a()) + (float)(cEnd.a() - cStart.a()) * flPercent);
|
||||
return Color( r, g, b, a );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Clips the health image to the appropriate percentage
|
||||
//-----------------------------------------------------------------------------
|
||||
class HorizontalGauge : public vgui::Panel
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_SIMPLE( HorizontalGauge, vgui::Panel );
|
||||
|
||||
HorizontalGauge( Panel *parent, const char *name ) :
|
||||
vgui::Panel( parent, name ),
|
||||
m_fPercent(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
void ApplySettings(KeyValues *inResourceData)
|
||||
{
|
||||
BaseClass::ApplySettings(inResourceData);
|
||||
|
||||
Color color0 = inResourceData->GetColor( "color0");
|
||||
Color color1 = inResourceData->GetColor( "color1");
|
||||
}
|
||||
*/
|
||||
|
||||
void PaintBackground()
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize(wide, tall);
|
||||
|
||||
surface()->DrawSetColor( Color(0, 0, 0, 128) );
|
||||
surface()->DrawFilledRect(0, 0, wide, tall);
|
||||
|
||||
// do the border explicitly here
|
||||
surface()->DrawSetColor( Color(0,0,0,255));
|
||||
surface()->DrawOutlinedRect(0, 0, wide, tall);
|
||||
}
|
||||
|
||||
virtual void Paint()
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize(wide, tall);
|
||||
|
||||
Color lowHealth(192, 32, 32, 255);
|
||||
Color highHealth(32, 255, 32, 255);
|
||||
|
||||
surface()->DrawSetColor( LerpColors(lowHealth, highHealth, m_fPercent) );
|
||||
surface()->DrawFilledRect(1, 1, (int)((wide - 1) * m_fPercent), tall - 1);
|
||||
}
|
||||
|
||||
void SetPercent( float fPercent ) { m_fPercent = fPercent; }
|
||||
|
||||
private:
|
||||
float m_fPercent;
|
||||
};
|
||||
|
||||
DECLARE_BUILD_FACTORY( HorizontalGauge );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSFreezePanel::CCSFreezePanel( const char *pElementName ) :
|
||||
EditablePanel( NULL, "FreezePanel" ),
|
||||
CHudElement( pElementName ),
|
||||
m_pBackgroundPanel(NULL),
|
||||
m_pKillerHealth(NULL),
|
||||
m_pAvatar(NULL),
|
||||
m_pDominationIcon(NULL)
|
||||
{
|
||||
SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
|
||||
SetParent(g_pClientMode->GetViewport());
|
||||
m_bShouldBeVisible = false;
|
||||
SetScheme( "ClientScheme" );
|
||||
RegisterForRenderGroup( "hide_for_scoreboard" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::Reset()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::Init()
|
||||
{
|
||||
CHudElement::Init();
|
||||
|
||||
// listen for events
|
||||
ListenForGameEvent( "show_freezepanel" );
|
||||
ListenForGameEvent( "hide_freezepanel" );
|
||||
ListenForGameEvent( "freezecam_started" );
|
||||
ListenForGameEvent( "player_death" );
|
||||
|
||||
Hide();
|
||||
|
||||
InitLayout();
|
||||
|
||||
}
|
||||
|
||||
void CCSFreezePanel::InitLayout()
|
||||
{
|
||||
LoadControlSettings( "resource/UI/FreezePanel_Basic.res" );
|
||||
|
||||
m_pBackgroundPanel = dynamic_cast<BorderedPanel*>( FindChildByName("FreezePanelBG"));
|
||||
m_pAvatar = dynamic_cast<CAvatarImagePanel*>( m_pBackgroundPanel->FindChildByName("AvatarImage"));
|
||||
m_pKillerHealth = dynamic_cast<HorizontalGauge*>( m_pBackgroundPanel->FindChildByName("KillerHealth"));
|
||||
m_pDominationIcon = dynamic_cast<ImagePanel*>( m_pBackgroundPanel->FindChildByName("DominationIcon"));
|
||||
|
||||
m_pAvatar->SetDefaultAvatar(scheme()->GetImage( CSTRIKE_DEFAULT_AVATAR, true ));
|
||||
m_pAvatar->SetShouldScaleImage(true);
|
||||
m_pAvatar->SetShouldDrawFriendIcon(false);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Applies scheme settings
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *pEventName = event->GetName();
|
||||
|
||||
if ( Q_strcmp( "player_death", pEventName ) == 0 )
|
||||
{
|
||||
// see if the local player died
|
||||
int iPlayerIndexVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
|
||||
int iPlayerIndexKiller = engine->GetPlayerForUserID( event->GetInt( "attacker" ) );
|
||||
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
CCSPlayer* pKiller = ToCSPlayer(ClientEntityList().GetBaseEntity(iPlayerIndexKiller));
|
||||
|
||||
if ( pLocalPlayer && iPlayerIndexVictim == pLocalPlayer->entindex() )
|
||||
{
|
||||
// the local player is dead, see if this is a new nemesis or a revenge
|
||||
if ( event->GetInt( "dominated" ) > 0)
|
||||
{
|
||||
m_pDominationIcon->SetImage("../hud/freeze_nemesis");
|
||||
m_pDominationIcon->SetVisible(true);
|
||||
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel1", g_pVGuiLocalize->Find("#FreezePanel_NewNemesis1"));
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel2", g_pVGuiLocalize->Find("#FreezePanel_NewNemesis2"));
|
||||
}
|
||||
// was the killer your pre-existing nemesis?
|
||||
else if ( pKiller != NULL && pKiller->IsPlayerDominated(iPlayerIndexVictim) )
|
||||
{
|
||||
m_pDominationIcon->SetImage("../hud/freeze_nemesis");
|
||||
m_pDominationIcon->SetVisible(true);
|
||||
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel1", g_pVGuiLocalize->Find("#FreezePanel_OldNemesis1"));
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel2", g_pVGuiLocalize->Find("#FreezePanel_OldNemesis2"));
|
||||
}
|
||||
else if ( event->GetInt( "revenge" ) > 0 )
|
||||
{
|
||||
m_pDominationIcon->SetImage("../hud/freeze_revenge");
|
||||
m_pDominationIcon->SetVisible(true);
|
||||
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel1", g_pVGuiLocalize->Find("#FreezePanel_Revenge1"));
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel2", g_pVGuiLocalize->Find("#FreezePanel_Revenge2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pDominationIcon->SetVisible(false);
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel1", g_pVGuiLocalize->Find("#FreezePanel_Killer1"));
|
||||
m_pBackgroundPanel->SetDialogVariable( "InfoLabel2", g_pVGuiLocalize->Find("#FreezePanel_Killer2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Q_strcmp( "hide_freezepanel", pEventName ) == 0 )
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
else if ( Q_strcmp( "freezecam_started", pEventName ) == 0 )
|
||||
{
|
||||
}
|
||||
else if ( Q_strcmp( "show_freezepanel", pEventName ) == 0 )
|
||||
{
|
||||
C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
|
||||
if ( !cs_PR )
|
||||
return;
|
||||
|
||||
Show();
|
||||
|
||||
// Get the entity who killed us
|
||||
int iKillerIndex = event->GetInt( "killer" );
|
||||
CCSPlayer* pKiller = ToCSPlayer(ClientEntityList().GetBaseEntity(iKillerIndex));
|
||||
m_pAvatar->ClearAvatar();
|
||||
|
||||
if ( pKiller )
|
||||
{
|
||||
int iMaxHealth = pKiller->GetMaxHealth();
|
||||
int iKillerHealth = pKiller->GetHealth();
|
||||
if ( !pKiller->IsAlive() )
|
||||
{
|
||||
iKillerHealth = 0;
|
||||
}
|
||||
|
||||
m_pKillerHealth->SetPercent( (float)iKillerHealth / iMaxHealth );
|
||||
|
||||
char killerName[128];
|
||||
V_snprintf( killerName, sizeof(killerName), "%s", g_PR->GetPlayerName(iKillerIndex) );
|
||||
// V_strupr( killerName );
|
||||
|
||||
m_pBackgroundPanel->SetDialogVariable( "killername", killerName);
|
||||
|
||||
int iKillerIndex = pKiller->entindex();
|
||||
player_info_t pi;
|
||||
|
||||
m_pAvatar->SetDefaultAvatar( GetDefaultAvatarImage( pKiller ) );
|
||||
|
||||
if ( engine->GetPlayerInfo(iKillerIndex, &pi) )
|
||||
{
|
||||
m_pAvatar->SetPlayer( (C_BasePlayer*)pKiller, k_EAvatarSize64x64);
|
||||
m_pAvatar->SetVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCSFreezePanel::ShouldDraw( void )
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Added sv_disablefreezecam check
|
||||
//=============================================================================
|
||||
static ConVarRef sv_disablefreezecam( "sv_disablefreezecam" );
|
||||
return ( m_bShouldBeVisible && !cl_disablefreezecam.GetBool() && !sv_disablefreezecam.GetBool() && CHudElement::ShouldDraw() );
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
}
|
||||
|
||||
void CCSFreezePanel::OnScreenSizeChanged( int nOldWide, int nOldTall )
|
||||
{
|
||||
BaseClass::OnScreenSizeChanged(nOldWide, nOldTall);
|
||||
|
||||
InitLayout();
|
||||
}
|
||||
|
||||
void CCSFreezePanel::SetActive( bool bActive )
|
||||
{
|
||||
CHudElement::SetActive( bActive );
|
||||
|
||||
if ( bActive )
|
||||
{
|
||||
// Setup replay key binding in UI
|
||||
const char *pKey = engine->Key_LookupBinding( "save_replay" );
|
||||
if ( pKey == NULL || FStrEq( pKey, "(null)" ) )
|
||||
{
|
||||
pKey = "<NOT BOUND>";
|
||||
}
|
||||
|
||||
char szKey[16];
|
||||
Q_snprintf( szKey, sizeof(szKey), "%s", pKey );
|
||||
wchar_t wKey[16];
|
||||
wchar_t wLabel[256];
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szKey, wKey, sizeof( wKey ) );
|
||||
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#FreezePanel_SaveReplay" ), 1, wKey );
|
||||
|
||||
m_pBackgroundPanel->SetDialogVariable( "savereplay", wLabel );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::Show()
|
||||
{
|
||||
m_bShouldBeVisible = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSFreezePanel::Hide()
|
||||
{
|
||||
m_bShouldBeVisible = false;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CS_HUD_FREEZEPANEL_H
|
||||
#define CS_HUD_FREEZEPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui_avatarimage.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "cs_hud_playerhealth.h"
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class HorizontalGauge;
|
||||
class BorderedPanel;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSFreezePanel : public EditablePanel, public CHudElement
|
||||
{
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CCSFreezePanel, EditablePanel );
|
||||
|
||||
public:
|
||||
CCSFreezePanel( const char *pElementName );
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Init();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual bool ShouldDraw();
|
||||
virtual void OnScreenSizeChanged(int nOldWide, int nOldTall);
|
||||
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
void InitLayout();
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
int HudElementKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
BorderedPanel* m_pBackgroundPanel;
|
||||
HorizontalGauge* m_pKillerHealth;
|
||||
CAvatarImagePanel* m_pAvatar;
|
||||
ImagePanel* m_pDominationIcon;
|
||||
|
||||
bool m_bShouldBeVisible;
|
||||
};
|
||||
|
||||
#endif //CS_HUD_FREEZEPANEL_H
|
||||
@@ -1,175 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
//
|
||||
// Health.cpp
|
||||
//
|
||||
// implementation of CHudHealth class
|
||||
//
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "iclientmode.h"
|
||||
|
||||
#define PAIN_NAME "sprites/%d_pain.vmt"
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "hud_numericdisplay.h"
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
#include "convar.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Health panel
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudHealth : public CHudElement, public CHudNumericDisplay
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudHealth, CHudNumericDisplay );
|
||||
|
||||
public:
|
||||
CHudHealth( const char *pElementName );
|
||||
virtual void Init( void );
|
||||
virtual void VidInit( void );
|
||||
virtual void Reset( void );
|
||||
virtual void OnThink();
|
||||
|
||||
virtual void Paint( void );
|
||||
virtual void ApplySchemeSettings( IScheme *scheme );
|
||||
|
||||
private:
|
||||
// old variables
|
||||
int m_iHealth;
|
||||
|
||||
int m_bitsDamage;
|
||||
|
||||
CHudTexture *m_pHealthIcon;
|
||||
|
||||
CPanelAnimationVarAliasType( float, icon_xpos, "icon_xpos", "0", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, icon_ypos, "icon_ypos", "0", "proportional_float" );
|
||||
|
||||
// CPanelAnimationVar( Color, m_LowHealthColor, "LowHealthColor", "255 0 0 255" );
|
||||
|
||||
float icon_tall;
|
||||
float icon_wide;
|
||||
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CHudHealth );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CHudHealth::CHudHealth( const char *pElementName ) : CHudElement( pElementName ), CHudNumericDisplay(NULL, "HudHealth")
|
||||
{
|
||||
SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudHealth::Init()
|
||||
{
|
||||
m_iHealth = 100;
|
||||
m_bitsDamage = 0;
|
||||
icon_tall = 0;
|
||||
icon_wide = 0;
|
||||
SetIndent(true);
|
||||
SetDisplayValue(m_iHealth);
|
||||
}
|
||||
|
||||
void CHudHealth::ApplySchemeSettings( IScheme *scheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( scheme );
|
||||
|
||||
if( !m_pHealthIcon )
|
||||
{
|
||||
m_pHealthIcon = gHUD.GetIcon( "health_icon" );
|
||||
}
|
||||
|
||||
if( m_pHealthIcon )
|
||||
{
|
||||
|
||||
icon_tall = GetTall() - YRES(2);
|
||||
float scale = icon_tall / (float)m_pHealthIcon->Height();
|
||||
icon_wide = ( scale ) * (float)m_pHealthIcon->Width();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: reset health to normal color at round restart
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudHealth::Reset()
|
||||
{
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("HealthRestored");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudHealth::VidInit()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudHealth::OnThink()
|
||||
{
|
||||
int realHealth = 0;
|
||||
C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
|
||||
if ( local )
|
||||
{
|
||||
// Never below zero
|
||||
realHealth = MAX( local->GetHealth(), 0 );
|
||||
}
|
||||
|
||||
// Only update the fade if we've changed health
|
||||
if ( realHealth == m_iHealth )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( realHealth > m_iHealth)
|
||||
{
|
||||
// round restarted, we have 100 again
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("HealthRestored");
|
||||
}
|
||||
else if ( realHealth <= 25 )
|
||||
{
|
||||
// we are badly injured
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("HealthLow");
|
||||
}
|
||||
else if( realHealth < m_iHealth )
|
||||
{
|
||||
// took a hit
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("HealthTookDamage");
|
||||
}
|
||||
|
||||
m_iHealth = realHealth;
|
||||
|
||||
SetDisplayValue(m_iHealth);
|
||||
}
|
||||
|
||||
void CHudHealth::Paint( void )
|
||||
{
|
||||
if( m_pHealthIcon )
|
||||
{
|
||||
m_pHealthIcon->DrawSelf( icon_xpos, icon_ypos, icon_wide, icon_tall, GetFgColor() );
|
||||
}
|
||||
|
||||
//draw the health icon
|
||||
BaseClass::Paint();
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: To display the player's health with the use of one graphic over another. A cross in this case
|
||||
// Currently this is only used on the freeze cam panel
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cs_hud_freezepanel.h"
|
||||
#include "vgui_controls/AnimationController.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
DECLARE_BUILD_FACTORY( CCSHudPlayerHealth );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSHudPlayerHealth::CCSHudPlayerHealth( Panel *parent, const char *name ) : EditablePanel( parent, name )
|
||||
{
|
||||
m_pHealthImage = new CCSHealthPanel( this, "PlayerStatusHealthImage" );
|
||||
m_pHealthImageBG = new ImagePanel( this, "PlayerStatusHealthImageBG" );
|
||||
|
||||
m_flNextThink = 0.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSHudPlayerHealth::Reset()
|
||||
{
|
||||
//m_flNextThink = gpGlobals->curtime + 0.05f;
|
||||
m_nHealth = -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSHudPlayerHealth::ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
// load control settings...
|
||||
LoadControlSettings( GetResFilename() );
|
||||
|
||||
m_flNextThink = 0.0f;
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSHudPlayerHealth::SetHealth( int iNewHealth, int iMaxHealth, int iMaxBuffedHealth )
|
||||
{
|
||||
int nPrevHealth = m_nHealth;
|
||||
|
||||
// set our health
|
||||
m_nHealth = iNewHealth;
|
||||
m_nMaxHealth = iMaxHealth;
|
||||
m_pHealthImage->SetHealth( (float)(m_nHealth) / (float)(m_nMaxHealth) );
|
||||
|
||||
if ( m_pHealthImage )
|
||||
{
|
||||
m_pHealthImage->SetFgColor( Color( 255, 255, 255, 255 ) );
|
||||
}
|
||||
|
||||
if ( m_nHealth <= 0 )
|
||||
{
|
||||
if ( m_pHealthImageBG->IsVisible() )
|
||||
{
|
||||
m_pHealthImageBG->SetVisible( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !m_pHealthImageBG->IsVisible() )
|
||||
{
|
||||
m_pHealthImageBG->SetVisible( true );
|
||||
}
|
||||
}
|
||||
|
||||
// set our health display value
|
||||
if ( nPrevHealth != m_nHealth )
|
||||
{
|
||||
if ( m_nHealth > 0 )
|
||||
{
|
||||
SetDialogVariable( "Health", m_nHealth );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable( "Health", "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCSHealthPanel::CCSHealthPanel( Panel *parent, const char *name ) : vgui::Panel( parent, name )
|
||||
{
|
||||
m_flHealth = 1.0f;
|
||||
|
||||
m_iMaterialIndex = surface()->DrawGetTextureId( "hud/health_color" );
|
||||
if ( m_iMaterialIndex == -1 ) // we didn't find it, so create a new one
|
||||
{
|
||||
m_iMaterialIndex = surface()->CreateNewTextureID();
|
||||
}
|
||||
|
||||
surface()->DrawSetTextureFile( m_iMaterialIndex, "hud/health_color", true, false );
|
||||
|
||||
m_iDeadMaterialIndex = surface()->DrawGetTextureId( "hud/health_dead" );
|
||||
if ( m_iDeadMaterialIndex == -1 ) // we didn't find it, so create a new one
|
||||
{
|
||||
m_iDeadMaterialIndex = surface()->CreateNewTextureID();
|
||||
}
|
||||
surface()->DrawSetTextureFile( m_iDeadMaterialIndex, "hud/health_dead", true, false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSHealthPanel::Paint()
|
||||
{
|
||||
BaseClass::Paint();
|
||||
|
||||
int x, y, w, h;
|
||||
GetBounds( x, y, w, h );
|
||||
|
||||
Vertex_t vert[4];
|
||||
float uv1 = 0.0f;
|
||||
float uv2 = 1.0f;
|
||||
int xpos = 0, ypos = 0;
|
||||
|
||||
if ( m_flHealth <= 0 )
|
||||
{
|
||||
// Draw the dead material
|
||||
surface()->DrawSetTexture( m_iDeadMaterialIndex );
|
||||
|
||||
vert[0].Init( Vector2D( xpos, ypos ), Vector2D( uv1, uv1 ) );
|
||||
vert[1].Init( Vector2D( xpos + w, ypos ), Vector2D( uv2, uv1 ) );
|
||||
vert[2].Init( Vector2D( xpos + w, ypos + h ), Vector2D( uv2, uv2 ) );
|
||||
vert[3].Init( Vector2D( xpos, ypos + h ), Vector2D( uv1, uv2 ) );
|
||||
|
||||
surface()->DrawSetColor( Color(255,255,255,255) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float flDamageY = h * ( 1.0f - m_flHealth );
|
||||
|
||||
// blend in the red "damage" part
|
||||
surface()->DrawSetTexture( m_iMaterialIndex );
|
||||
|
||||
Vector2D uv11( uv1, uv2 - m_flHealth );
|
||||
Vector2D uv21( uv2, uv2 - m_flHealth );
|
||||
Vector2D uv22( uv2, uv2 );
|
||||
Vector2D uv12( uv1, uv2 );
|
||||
|
||||
vert[0].Init( Vector2D( xpos, flDamageY ), uv11 );
|
||||
vert[1].Init( Vector2D( xpos + w, flDamageY ), uv21 );
|
||||
vert[2].Init( Vector2D( xpos + w, ypos + h ), uv22 );
|
||||
vert[3].Init( Vector2D( xpos, ypos + h ), uv12 );
|
||||
|
||||
surface()->DrawSetColor( GetFgColor() );
|
||||
}
|
||||
|
||||
surface()->DrawTexturedPolygon( 4, vert );
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: To display the player's health with the use of one graphic over another. A cross in this case
|
||||
// Currently this is only used on the freeze cam panel
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#ifndef CS_HUD_HEALTHPANEL_H
|
||||
#define CS_HUD_HEALTHPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Clips the health image to the appropriate percentage
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSHealthPanel : public vgui::Panel
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_SIMPLE( CCSHealthPanel, vgui::Panel );
|
||||
|
||||
CCSHealthPanel( vgui::Panel *parent, const char *name );
|
||||
virtual void Paint();
|
||||
void SetHealth( float flHealth ){ m_flHealth = ( flHealth <= 1.0 ) ? flHealth : 1.0f; }
|
||||
|
||||
private:
|
||||
|
||||
float m_flHealth; // percentage from 0.0 -> 1.0
|
||||
int m_iMaterialIndex;
|
||||
int m_iDeadMaterialIndex;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays player health data
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSHudPlayerHealth : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCSHudPlayerHealth, EditablePanel );
|
||||
|
||||
public:
|
||||
|
||||
CCSHudPlayerHealth( Panel *parent, const char *name );
|
||||
|
||||
virtual const char *GetResFilename( void ) { return "resource/UI/FreezePanelKillerHealth.res"; }
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Reset();
|
||||
|
||||
void SetHealth( int iNewHealth, int iMaxHealth, int iMaxBuffedHealth );
|
||||
void HideHealthBonusImage( void );
|
||||
|
||||
protected:
|
||||
//virtual void OnThink();
|
||||
|
||||
protected:
|
||||
float m_flNextThink;
|
||||
|
||||
private:
|
||||
CCSHealthPanel *m_pHealthImage;
|
||||
vgui::ImagePanel *m_pHealthImageBG;
|
||||
|
||||
int m_nHealth;
|
||||
int m_nMaxHealth;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,203 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_macros.h"
|
||||
#include "hud_numericdisplay.h"
|
||||
#include "iclientmode.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <KeyValues.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draws the zoom screen
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudScope : public vgui::Panel, public CHudElement
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudScope, vgui::Panel );
|
||||
|
||||
public:
|
||||
CHudScope( const char *pElementName );
|
||||
|
||||
void Init( void );
|
||||
void LevelInit( void );
|
||||
|
||||
protected:
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *scheme);
|
||||
virtual void Paint( void );
|
||||
|
||||
private:
|
||||
CMaterialReference m_ScopeMaterial;
|
||||
CMaterialReference m_DustOverlayMaterial;
|
||||
|
||||
int m_iScopeArcTexture;
|
||||
int m_iScopeDustTexture;
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( CHudScope, 70 );
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CHudScope::CHudScope( const char *pElementName ) : CHudElement(pElementName), BaseClass(NULL, "HudScope")
|
||||
{
|
||||
vgui::Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
SetHiddenBits( HIDEHUD_PLAYERDEAD );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: standard hud element init function
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudScope::Init( void )
|
||||
{
|
||||
m_iScopeArcTexture = vgui::surface()->CreateNewTextureID();
|
||||
vgui::surface()->DrawSetTextureFile(m_iScopeArcTexture, "sprites/scope_arc", true, false);
|
||||
|
||||
m_iScopeDustTexture = vgui::surface()->CreateNewTextureID();
|
||||
vgui::surface()->DrawSetTextureFile(m_iScopeDustTexture, "overlays/scope_lens", true, false);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: standard hud element init function
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudScope::LevelInit( void )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets scheme colors
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudScope::ApplySchemeSettings( vgui::IScheme *scheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(scheme);
|
||||
|
||||
SetPaintBackgroundEnabled(false);
|
||||
SetPaintBorderEnabled(false);
|
||||
|
||||
int screenWide, screenTall;
|
||||
GetHudSize(screenWide, screenTall);
|
||||
SetBounds(0, 0, screenWide, screenTall);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: draws the zoom effect
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudScope::Paint( void )
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast<C_CSPlayer *>(C_BasePlayer::GetLocalPlayer());
|
||||
|
||||
if ( pPlayer == NULL )
|
||||
return;
|
||||
|
||||
CWeaponCSBase *pWeapon = pPlayer->GetActiveCSWeapon();
|
||||
|
||||
if( !pWeapon )
|
||||
return;
|
||||
|
||||
Assert( m_iScopeArcTexture );
|
||||
Assert( m_iScopeDustTexture );
|
||||
|
||||
// see if we're zoomed with a sniper rifle
|
||||
if( pPlayer->GetFOV() != pPlayer->GetDefaultFOV() &&
|
||||
pWeapon->GetCSWpnData().m_WeaponType == WEAPONTYPE_SNIPER_RIFLE )
|
||||
{
|
||||
int screenWide, screenTall;
|
||||
GetHudSize(screenWide, screenTall);
|
||||
|
||||
// calculate the bounds in which we should draw the scope
|
||||
int inset = screenTall / 16;
|
||||
int y1 = inset;
|
||||
int x1 = (screenWide - screenTall) / 2 + inset;
|
||||
int y2 = screenTall - inset;
|
||||
int x2 = screenWide - x1;
|
||||
|
||||
int x = screenWide / 2;
|
||||
int y = screenTall / 2;
|
||||
|
||||
float uv1 = 0.5f / 256.0f, uv2 = 1.0f - uv1;
|
||||
|
||||
vgui::Vertex_t vert[4];
|
||||
|
||||
Vector2D uv11( uv1, uv1 );
|
||||
Vector2D uv12( uv1, uv2 );
|
||||
Vector2D uv21( uv2, uv1 );
|
||||
Vector2D uv22( uv2, uv2 );
|
||||
|
||||
int xMod = ( screenWide / 2 );
|
||||
int yMod = ( screenTall / 2 );
|
||||
|
||||
int iMiddleX = (screenWide / 2 );
|
||||
int iMiddleY = (screenTall / 2 );
|
||||
|
||||
vgui::surface()->DrawSetTexture( m_iScopeDustTexture );
|
||||
vgui::surface()->DrawSetColor( 255, 255, 255, 255 );
|
||||
|
||||
vert[0].Init( Vector2D( iMiddleX + xMod, iMiddleY + yMod ), uv21 );
|
||||
vert[1].Init( Vector2D( iMiddleX - xMod, iMiddleY + yMod ), uv11 );
|
||||
vert[2].Init( Vector2D( iMiddleX - xMod, iMiddleY - yMod ), uv12 );
|
||||
vert[3].Init( Vector2D( iMiddleX + xMod, iMiddleY - yMod ), uv22 );
|
||||
vgui::surface()->DrawTexturedPolygon( 4, vert );
|
||||
|
||||
vgui::surface()->DrawSetColor(0,0,0,255);
|
||||
|
||||
//Draw the reticle with primitives
|
||||
vgui::surface()->DrawLine( 0, y, screenWide, y );
|
||||
vgui::surface()->DrawLine( x, 0, x, screenTall );
|
||||
|
||||
//Draw the outline
|
||||
vgui::surface()->DrawSetTexture(m_iScopeArcTexture);
|
||||
|
||||
// bottom right
|
||||
vert[0].Init( Vector2D( x, y ), uv11 );
|
||||
vert[1].Init( Vector2D( x2, y ), uv21 );
|
||||
vert[2].Init( Vector2D( x2, y2 ), uv22 );
|
||||
vert[3].Init( Vector2D( x, y2 ), uv12 );
|
||||
vgui::surface()->DrawTexturedPolygon( 4, vert );
|
||||
|
||||
// top right
|
||||
vert[0].Init( Vector2D( x - 1, y1 ), uv12 );
|
||||
vert[1].Init( Vector2D ( x2, y1 ), uv22 );
|
||||
vert[2].Init( Vector2D( x2, y + 1 ), uv21 );
|
||||
vert[3].Init( Vector2D( x - 1, y + 1 ), uv11 );
|
||||
vgui::surface()->DrawTexturedPolygon(4, vert);
|
||||
|
||||
// bottom left
|
||||
vert[0].Init( Vector2D( x1, y ), uv21 );
|
||||
vert[1].Init( Vector2D( x, y ), uv11 );
|
||||
vert[2].Init( Vector2D( x, y2 ), uv12 );
|
||||
vert[3].Init( Vector2D( x1, y2), uv22 );
|
||||
vgui::surface()->DrawTexturedPolygon(4, vert);
|
||||
|
||||
// top left
|
||||
vert[0].Init( Vector2D( x1, y1 ), uv22 );
|
||||
vert[1].Init( Vector2D( x, y1 ), uv12 );
|
||||
vert[2].Init( Vector2D( x, y ), uv11 );
|
||||
vert[3].Init( Vector2D( x1, y ), uv21 );
|
||||
vgui::surface()->DrawTexturedPolygon(4, vert);
|
||||
|
||||
vgui::surface()->DrawFilledRect(0, 0, screenWide, y1); // top
|
||||
vgui::surface()->DrawFilledRect(0, y2, screenWide, screenTall); // bottom
|
||||
vgui::surface()->DrawFilledRect(0, y1, x1, screenTall); // left
|
||||
vgui::surface()->DrawFilledRect(x2, y1, screenWide, screenTall); // right
|
||||
}
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: HUD Target ID element
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_playerresource.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "vgui_entitypanel.h"
|
||||
#include "iclientmode.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
|
||||
#include "c_cs_hostage.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define PLAYER_HINT_DISTANCE 150
|
||||
#define PLAYER_HINT_DISTANCE_SQ (PLAYER_HINT_DISTANCE*PLAYER_HINT_DISTANCE)
|
||||
|
||||
extern CUtlVector< C_CHostage* > g_Hostages;
|
||||
|
||||
static ConVar hud_showtargetpos( "hud_showtargetpos", "0", FCVAR_ARCHIVE, "0: center, 1: upper left, 2 upper right, 3: lower left, 4: lower right" );
|
||||
static ConVar hud_showtargetid( "hud_showtargetid", "1", FCVAR_ARCHIVE, "Enables display of target names" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTargetID : public CHudElement, public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CTargetID, vgui::Panel );
|
||||
|
||||
public:
|
||||
CTargetID( const char *pElementName );
|
||||
void Init( void );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
virtual void Paint( void );
|
||||
void VidInit( void );
|
||||
|
||||
private:
|
||||
Color GetColorForTargetTeam( int iTeamNumber );
|
||||
|
||||
vgui::HFont m_hFont;
|
||||
int m_iLastEntIndex;
|
||||
float m_flLastChangeTime;
|
||||
|
||||
Color m_cCTColor;
|
||||
Color m_cTerroristColor;
|
||||
Color m_cHostageColor;
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CTargetID );
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CTargetID::CTargetID( const char *pElementName ) :
|
||||
CHudElement( pElementName ), BaseClass( NULL, "TargetID" )
|
||||
{
|
||||
vgui::Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
m_hFont = g_hFontTrebuchet24;
|
||||
m_flLastChangeTime = 0;
|
||||
m_iLastEntIndex = 0;
|
||||
|
||||
SetHiddenBits( HIDEHUD_MISCSTATUS );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Setup
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTargetID::Init( void )
|
||||
{
|
||||
};
|
||||
|
||||
void CTargetID::ApplySchemeSettings( vgui::IScheme *scheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( scheme );
|
||||
|
||||
m_cTerroristColor = scheme->GetColor( "T_Red", Color( 255, 64, 64, 255 ) );
|
||||
m_cCTColor = scheme->GetColor( "CT_Blue", Color( 255, 64, 64, 255 ) );
|
||||
m_cHostageColor = scheme->GetColor( "Hostage_yellow", Color( 255, 160, 0, 255 ) );
|
||||
m_hFont = scheme->GetFont( "TargetID", true );
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: clear out string etc between levels
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTargetID::VidInit()
|
||||
{
|
||||
CHudElement::VidInit();
|
||||
|
||||
// set our size to the current viewport size
|
||||
SetSize(g_pClientMode->GetViewport()->GetWide(), g_pClientMode->GetViewport()->GetTall());
|
||||
|
||||
m_flLastChangeTime = 0;
|
||||
m_iLastEntIndex = 0;
|
||||
}
|
||||
|
||||
Color CTargetID::GetColorForTargetTeam( int iTeamNumber )
|
||||
{
|
||||
switch( iTeamNumber )
|
||||
{
|
||||
case TEAM_CT:
|
||||
return m_cCTColor;
|
||||
break;
|
||||
|
||||
case TEAM_TERRORIST:
|
||||
return m_cTerroristColor;
|
||||
break;
|
||||
|
||||
default:
|
||||
return m_cHostageColor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw function for the element
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTargetID::Paint()
|
||||
{
|
||||
if ( hud_showtargetid.GetBool() == false )
|
||||
return;
|
||||
|
||||
#define MAX_ID_STRING 256
|
||||
wchar_t sIDString[ MAX_ID_STRING ];
|
||||
sIDString[0] = 0;
|
||||
|
||||
Color c = m_cHostageColor;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
// don't show target IDs when flashed
|
||||
if ( pPlayer->m_flFlashBangTime > (gpGlobals->curtime+0.5) )
|
||||
return;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Don't show target ID's when in freezecam mode
|
||||
//=============================================================================
|
||||
|
||||
if ( pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM )
|
||||
return;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
// Get our target's ent index
|
||||
int iEntIndex = pPlayer->GetIDTarget();
|
||||
// Didn't find one?
|
||||
if ( !iEntIndex )
|
||||
{
|
||||
// Check to see if we should clear our ID
|
||||
if ( m_flLastChangeTime && (gpGlobals->curtime > (m_flLastChangeTime + 0.5)) )
|
||||
{
|
||||
m_flLastChangeTime = 0;
|
||||
sIDString[0] = 0;
|
||||
m_iLastEntIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Keep re-using the old one
|
||||
iEntIndex = m_iLastEntIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flLastChangeTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
// Is this an entindex sent by the server?
|
||||
if ( iEntIndex )
|
||||
{
|
||||
C_BasePlayer *pPlayer = static_cast<C_BasePlayer*>(cl_entitylist->GetEnt( iEntIndex ));
|
||||
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
const char *printFormatString = NULL;
|
||||
wchar_t wszClanTag[ MAX_PLAYER_NAME_LENGTH ];
|
||||
wchar_t wszPlayerName[ MAX_PLAYER_NAME_LENGTH ];
|
||||
wchar_t wszHealthText[ 10 ];
|
||||
bool bShowHealth = false;
|
||||
bool bShowPlayerName = false;
|
||||
|
||||
// Some entities we always want to check, cause the text may change
|
||||
// even while we're looking at it
|
||||
// Is it a player?
|
||||
if ( IsPlayerIndex( iEntIndex ) )
|
||||
{
|
||||
if ( !pPlayer )
|
||||
{
|
||||
// This can happen because the object was destroyed
|
||||
sIDString[0] = 0;
|
||||
m_iLastEntIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = GetColorForTargetTeam( pPlayer->GetTeamNumber() );
|
||||
|
||||
bShowPlayerName = true;
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pPlayer->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
|
||||
|
||||
C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
|
||||
|
||||
char szClan[MAX_PLAYER_NAME_LENGTH];
|
||||
if ( cs_PR && Q_strlen( cs_PR->GetClanTag( iEntIndex ) ) > 1 )
|
||||
{
|
||||
Q_snprintf( szClan, sizeof( szClan ), "%s ", cs_PR->GetClanTag( iEntIndex ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
szClan[ 0 ] = 0;
|
||||
}
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szClan, wszClanTag, sizeof( wszClanTag ) );
|
||||
|
||||
if ( pPlayer->InSameTeam(pLocalPlayer) )
|
||||
{
|
||||
printFormatString = "#Cstrike_playerid_sameteam";
|
||||
bShowHealth = true;
|
||||
}
|
||||
else if ( pLocalPlayer->GetTeamNumber() != TEAM_CT && pLocalPlayer->GetTeamNumber() != TEAM_TERRORIST )
|
||||
{
|
||||
printFormatString = "#Cstrike_playerid_noteam";
|
||||
bShowHealth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printFormatString = "#Cstrike_playerid_diffteam";
|
||||
}
|
||||
|
||||
if ( bShowHealth )
|
||||
{
|
||||
_snwprintf( wszHealthText, ARRAYSIZE(wszHealthText) - 1, L"%.0f%%", ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 );
|
||||
wszHealthText[ ARRAYSIZE(wszHealthText)-1 ] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
C_BaseEntity *pEnt = cl_entitylist->GetEnt( iEntIndex );
|
||||
|
||||
//Hostages!
|
||||
|
||||
//"Hostage : Health 100%"
|
||||
|
||||
/*
|
||||
if( long range )
|
||||
{
|
||||
m_flDisplayHistory |= DHF_HOSTAGE_SEEN_FAR;
|
||||
switch ( pLocalPlayer->GetTeamNumber() )
|
||||
{
|
||||
case TERRORIST:
|
||||
HintMessage( "#Hint_prevent_hostage_rescue", TRUE );
|
||||
break;
|
||||
|
||||
case CT:
|
||||
HintMessage( "#Hint_rescue_the_hostages", TRUE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flDisplayHistory |= DHF_HOSTAGE_SEEN_NEAR;
|
||||
m_flDisplayHistory |= DHF_HOSTAGE_SEEN_FAR; // Don't want the other msg to appear now
|
||||
HintMessage( "#Hint_press_use_so_hostage_will_follow", FALSE );
|
||||
}
|
||||
*/
|
||||
|
||||
C_CHostage *pHostage = NULL;
|
||||
|
||||
for( int i=0;i<g_Hostages.Count();i++ )
|
||||
{
|
||||
// compare entity pointers
|
||||
if( g_Hostages[i] == pEnt )
|
||||
{
|
||||
pHostage = g_Hostages[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( pHostage != NULL )
|
||||
{
|
||||
c = m_cHostageColor;
|
||||
printFormatString = "#Cstrike_playerid_hostage";
|
||||
_snwprintf( wszHealthText, ARRAYSIZE(wszHealthText) - 1, L"%.0f%%", ((float)pHostage->GetHealth() / (float)pHostage->GetMaxHealth() ) * 100 );
|
||||
wszHealthText[ ARRAYSIZE(wszHealthText)-1 ] = '\0';
|
||||
bShowHealth = true;
|
||||
}
|
||||
else if ( !pEnt || !pEnt->InSameTeam(pLocalPlayer) )
|
||||
{
|
||||
// This can happen because the object was destroyed
|
||||
sIDString[0] = 0;
|
||||
m_iLastEntIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't check validity if it's sent by the server
|
||||
c = m_cHostageColor;
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pEnt->GetIDString(), sIDString, sizeof(sIDString) );
|
||||
m_iLastEntIndex = iEntIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if ( printFormatString )
|
||||
{
|
||||
if ( bShowPlayerName && bShowHealth )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( sIDString, sizeof(sIDString), g_pVGuiLocalize->Find(printFormatString), 3, wszClanTag, wszPlayerName, wszHealthText );
|
||||
}
|
||||
else if ( bShowPlayerName )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( sIDString, sizeof(sIDString), g_pVGuiLocalize->Find(printFormatString), 2, wszClanTag, wszPlayerName );
|
||||
}
|
||||
else if ( bShowHealth )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( sIDString, sizeof(sIDString), g_pVGuiLocalize->Find(printFormatString), 1, wszHealthText );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( sIDString, sizeof(sIDString), g_pVGuiLocalize->Find(printFormatString), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( sIDString[0] )
|
||||
{
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
bool bObserverMode = pPlayer && pPlayer->IsObserver();
|
||||
|
||||
int wide, tall;
|
||||
vgui::surface()->GetTextSize( m_hFont, sIDString, wide, tall );
|
||||
|
||||
int ypos;
|
||||
int xpos;
|
||||
|
||||
switch ( hud_showtargetpos.GetInt() )
|
||||
{
|
||||
case 0: // center
|
||||
default:
|
||||
xpos = (ScreenWidth() - wide) / 2;
|
||||
ypos = YRES(260) - tall / 2;
|
||||
break;
|
||||
case 1: // upper left
|
||||
xpos = XRES(10);
|
||||
ypos = bObserverMode ? YRES(55) : YRES(5);
|
||||
break;
|
||||
case 2: // upper right
|
||||
xpos = XRES(630) - wide;
|
||||
ypos = bObserverMode ? YRES(55) : YRES(5);
|
||||
break;
|
||||
case 3: // lower left
|
||||
xpos = XRES(10);
|
||||
ypos = bObserverMode ? YRES(415) : YRES(445) - tall;
|
||||
break;
|
||||
case 4: // lower right
|
||||
xpos = XRES(630) - wide;
|
||||
ypos = bObserverMode ? YRES(415) : YRES(410) - tall;
|
||||
break;
|
||||
}
|
||||
|
||||
vgui::surface()->DrawSetTextFont( m_hFont );
|
||||
vgui::surface()->DrawSetTextPos( xpos, ypos );
|
||||
vgui::surface()->DrawSetTextColor( c );
|
||||
vgui::surface()->DrawPrintText( sIDString, wcslen(sIDString) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,845 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "weapon_selection.h"
|
||||
#include "iclientmode.h"
|
||||
#include "history_resource.h"
|
||||
#include "iinput.h"
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui_controls/AnimationController.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
#include "vgui/ILocalize.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: cstrike weapon selection hud element
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudWeaponSelection : public CBaseHudWeaponSelection, public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CHudWeaponSelection, vgui::Panel );
|
||||
|
||||
public:
|
||||
CHudWeaponSelection(const char *pElementName );
|
||||
|
||||
virtual bool ShouldDraw();
|
||||
virtual void OnWeaponPickup( C_BaseCombatWeapon *pWeapon );
|
||||
|
||||
virtual void CycleToNextWeapon( void );
|
||||
virtual void CycleToPrevWeapon( void );
|
||||
virtual void SwitchToLastWeapon( void );
|
||||
|
||||
virtual C_BaseCombatWeapon *GetWeaponInSlot( int iSlot, int iSlotPos );
|
||||
virtual void SelectWeaponSlot( int iSlot );
|
||||
virtual void SelectWeapon( void );
|
||||
|
||||
virtual C_BaseCombatWeapon *GetSelectedWeapon( void )
|
||||
{
|
||||
return m_hSelectedWeapon;
|
||||
}
|
||||
|
||||
virtual void OpenSelection( void );
|
||||
virtual void HideSelection( void );
|
||||
|
||||
virtual void CancelWeaponSelection( void );
|
||||
|
||||
virtual void LevelInit();
|
||||
|
||||
protected:
|
||||
virtual void OnThink();
|
||||
virtual void Paint();
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
virtual bool IsWeaponSelectable()
|
||||
{
|
||||
if (IsInSelectionMode())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool IsHudMenuTakingInput();
|
||||
virtual bool IsHudMenuPreventingWeaponSelection();
|
||||
|
||||
private:
|
||||
C_BaseCombatWeapon *FindNextWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition);
|
||||
C_BaseCombatWeapon *FindPrevWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition);
|
||||
|
||||
virtual void SetSelectedWeapon( C_BaseCombatWeapon *pWeapon )
|
||||
{
|
||||
m_hSelectedWeapon = pWeapon;
|
||||
}
|
||||
|
||||
void DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, int number);
|
||||
|
||||
CPanelAnimationVar( vgui::HFont, m_hNumberFont, "NumberFont", "HudSelectionNumbers" );
|
||||
CPanelAnimationVar( vgui::HFont, m_hTextFont, "TextFont", "HudSelectionText" );
|
||||
|
||||
CPanelAnimationVarAliasType( float, m_flSmallBoxSize, "SmallBoxSize", "32", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, m_flLargeBoxWide, "LargeBoxWide", "108", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, m_flLargeBoxTall, "LargeBoxTall", "72", "proportional_float" );
|
||||
|
||||
CPanelAnimationVarAliasType( float, m_flBoxGap, "BoxGap", "12", "proportional_float" );
|
||||
|
||||
CPanelAnimationVarAliasType( float, m_flSelectionNumberXPos, "SelectionNumberXPos", "4", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, m_flSelectionNumberYPos, "SelectionNumberYPos", "4", "proportional_float" );
|
||||
|
||||
CPanelAnimationVarAliasType( float, m_flIconXPos, "IconXPos", "16", "proportional_float" );
|
||||
CPanelAnimationVarAliasType( float, m_flIconYPos, "IconYPos", "8", "proportional_float" );
|
||||
|
||||
CPanelAnimationVarAliasType( float, m_flTextYPos, "TextYPos", "54", "proportional_float" );
|
||||
|
||||
CPanelAnimationVar( float, m_flAlphaOverride, "Alpha", "255" );
|
||||
CPanelAnimationVar( float, m_flSelectionAlphaOverride, "SelectionAlpha", "255" );
|
||||
|
||||
|
||||
CPanelAnimationVar( Color, m_TextColor, "TextColor", "SelectionTextFg" );
|
||||
CPanelAnimationVar( Color, m_NumberColor, "NumberColor", "SelectionNumberFg" );
|
||||
CPanelAnimationVar( Color, m_EmptyBoxColor, "EmptyBoxColor", "SelectionEmptyBoxBg" );
|
||||
CPanelAnimationVar( Color, m_BoxColor, "BoxColor", "SelectionBoxBg" );
|
||||
CPanelAnimationVar( Color, m_SelectedBoxColor, "SelectedBoxClor", "SelectionSelectedBoxBg" );
|
||||
|
||||
CPanelAnimationVar( float, m_flWeaponPickupGrowTime, "SelectionGrowTime", "0.1" );
|
||||
|
||||
CPanelAnimationVar( float, m_flTextScan, "TextScan", "1.0" );
|
||||
|
||||
CPanelAnimationVar( int, m_iMaxSlots, "MaxSlots", "6" );
|
||||
CPanelAnimationVar( bool, m_bPlaySelectionSounds, "PlaySelectSounds", "1" );
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( CHudWeaponSelection );
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CHudWeaponSelection::CHudWeaponSelection( const char *pElementName ) : CBaseHudWeaponSelection(pElementName), BaseClass(NULL, "HudWeaponSelection")
|
||||
{
|
||||
vgui::Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
SetHiddenBits( HIDEHUD_WEAPONSELECTION | HIDEHUD_PLAYERDEAD );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets up display for showing weapon pickup
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::OnWeaponPickup( C_BaseCombatWeapon *pWeapon )
|
||||
{
|
||||
// add to pickup history
|
||||
CHudHistoryResource *pHudHR = GET_HUDELEMENT( CHudHistoryResource );
|
||||
if ( pHudHR )
|
||||
{
|
||||
pHudHR->AddToHistory( pWeapon );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: updates animation status
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::OnThink()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the CHudMenu should take slot1, etc commands
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHudWeaponSelection::IsHudMenuTakingInput()
|
||||
{
|
||||
return CBaseHudWeaponSelection::IsHudMenuTakingInput();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the weapon selection hud should be hidden because
|
||||
// the CHudMenu is open
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHudWeaponSelection::IsHudMenuPreventingWeaponSelection()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the panel should draw
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHudWeaponSelection::ShouldDraw()
|
||||
{
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( IsInSelectionMode() )
|
||||
{
|
||||
HideSelection();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bret = CBaseHudWeaponSelection::ShouldDraw();
|
||||
if ( !bret )
|
||||
return false;
|
||||
|
||||
return ( m_bSelectionVisible ) ? true : false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::LevelInit()
|
||||
{
|
||||
CHudElement::LevelInit();
|
||||
|
||||
m_iMaxSlots = clamp( m_iMaxSlots, 0, MAX_WEAPON_SLOTS );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Purpose: draws the selection area
|
||||
//-------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::Paint()
|
||||
{
|
||||
if (!ShouldDraw())
|
||||
return;
|
||||
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
// find and display our current selection
|
||||
C_BaseCombatWeapon *pSelectedWeapon = GetSelectedWeapon();
|
||||
if ( !pSelectedWeapon )
|
||||
return;
|
||||
|
||||
int iActiveSlot = (pSelectedWeapon ? pSelectedWeapon->GetSlot() : -1);
|
||||
|
||||
// interpolate the selected box size between the small box size and the large box size
|
||||
// interpolation has been removed since there is no weapon pickup animation anymore, so it's all at the largest size
|
||||
float percentageDone = 1.0f; //min(1.0f, (gpGlobals->curtime - m_flPickupStartTime) / m_flWeaponPickupGrowTime);
|
||||
int largeBoxWide = m_flSmallBoxSize + ((m_flLargeBoxWide - m_flSmallBoxSize) * percentageDone);
|
||||
int largeBoxTall = m_flSmallBoxSize + ((m_flLargeBoxTall - m_flSmallBoxSize) * percentageDone);
|
||||
Color selectedColor;
|
||||
{for (int i = 0; i < 4; i++)
|
||||
{
|
||||
selectedColor[i] = m_BoxColor[i] + ((m_SelectedBoxColor[i] - m_BoxColor[i]) * percentageDone);
|
||||
}}
|
||||
|
||||
// calculate where to start drawing
|
||||
int width = (m_iMaxSlots - 1) * (m_flSmallBoxSize + m_flBoxGap) + largeBoxWide;
|
||||
int xpos = (GetWide() - width) / 2;
|
||||
int ypos = 0;
|
||||
|
||||
// iterate over all the weapon slots
|
||||
for ( int i = 0; i < m_iMaxSlots; i++ )
|
||||
{
|
||||
if ( i == iActiveSlot )
|
||||
{
|
||||
bool bFirstItem = true;
|
||||
for (int slotpos = 0; slotpos < MAX_WEAPON_POSITIONS; slotpos++)
|
||||
{
|
||||
C_BaseCombatWeapon *pWeapon = GetWeaponInSlot(i, slotpos);
|
||||
if ( !pWeapon )
|
||||
continue;
|
||||
|
||||
// draw selected weapon
|
||||
DrawBox(xpos, ypos, largeBoxWide, largeBoxTall, selectedColor, m_flSelectionAlphaOverride, bFirstItem ? i + 1 : -1);
|
||||
|
||||
// draw icon
|
||||
Color col = GetFgColor();
|
||||
// icons use old system, drawing in screen space
|
||||
if ( pWeapon->GetSpriteActive() )
|
||||
{
|
||||
if (!pWeapon->CanBeSelected())
|
||||
{
|
||||
// unselectable weapon, display as such
|
||||
col = Color(255, 0, 0, col[3]);
|
||||
}
|
||||
else if (pWeapon == pSelectedWeapon)
|
||||
{
|
||||
// currently selected weapon, display brighter
|
||||
col[3] = m_flSelectionAlphaOverride;
|
||||
}
|
||||
pWeapon->GetSpriteActive()->DrawSelf( xpos + m_flIconXPos, ypos + m_flIconYPos, col );
|
||||
}
|
||||
|
||||
// draw text
|
||||
col = m_TextColor;
|
||||
const FileWeaponInfo_t &weaponInfo = pWeapon->GetWpnData();
|
||||
|
||||
if (pWeapon == pSelectedWeapon)
|
||||
{
|
||||
wchar_t text[128];
|
||||
wchar_t *tempString = g_pVGuiLocalize->Find(weaponInfo.szPrintName);
|
||||
|
||||
// setup our localized string
|
||||
if ( tempString )
|
||||
{
|
||||
#ifdef WIN32
|
||||
_snwprintf(text, sizeof(text)/sizeof(wchar_t) - 1, L"%s", tempString);
|
||||
#else
|
||||
_snwprintf(text, sizeof(text)/sizeof(wchar_t) - 1, L"%S", tempString);
|
||||
#endif
|
||||
text[sizeof(text)/sizeof(wchar_t) - 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// string wasn't found by g_pVGuiLocalize->Find()
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode(weaponInfo.szPrintName, text, sizeof(text));
|
||||
}
|
||||
|
||||
surface()->DrawSetTextColor( col );
|
||||
surface()->DrawSetTextFont( m_hTextFont );
|
||||
|
||||
// count the position
|
||||
int slen = 0, charCount = 0, maxslen = 0;
|
||||
{
|
||||
for (wchar_t *pch = text; *pch != 0; pch++)
|
||||
{
|
||||
if (*pch == '\n')
|
||||
{
|
||||
// newline character, drop to the next line
|
||||
if (slen > maxslen)
|
||||
{
|
||||
maxslen = slen;
|
||||
}
|
||||
slen = 0;
|
||||
}
|
||||
else if (*pch == '\r')
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
slen += surface()->GetCharacterWidth( m_hTextFont, *pch );
|
||||
charCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slen > maxslen)
|
||||
{
|
||||
maxslen = slen;
|
||||
}
|
||||
|
||||
int tx = xpos + ((largeBoxWide - maxslen) / 2);
|
||||
int ty = ypos + (int)m_flTextYPos;
|
||||
surface()->DrawSetTextPos( tx, ty );
|
||||
// adjust the charCount by the scan amount
|
||||
charCount *= m_flTextScan;
|
||||
for (wchar_t *pch = text; charCount > 0; pch++)
|
||||
{
|
||||
if (*pch == '\n')
|
||||
{
|
||||
// newline character, move to the next line
|
||||
surface()->DrawSetTextPos( xpos + ((largeBoxWide - slen) / 2), ty + (surface()->GetFontTall(m_hTextFont) * 1.1f));
|
||||
}
|
||||
else if (*pch == '\r')
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
surface()->DrawUnicodeChar(*pch);
|
||||
charCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ypos += (largeBoxTall + m_flBoxGap);
|
||||
bFirstItem = false;
|
||||
}
|
||||
|
||||
xpos += largeBoxWide;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check to see if there is a weapons in this bucket
|
||||
if ( GetFirstPos( i ) )
|
||||
{
|
||||
// draw has weapon in slot
|
||||
DrawBox(xpos, ypos, m_flSmallBoxSize, m_flSmallBoxSize, m_BoxColor, m_flAlphaOverride, i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// draw empty slot
|
||||
DrawBox(xpos, ypos, m_flSmallBoxSize, m_flSmallBoxSize, m_EmptyBoxColor, m_flAlphaOverride, -1);
|
||||
}
|
||||
|
||||
xpos += m_flSmallBoxSize;
|
||||
}
|
||||
|
||||
// reset position
|
||||
ypos = 0;
|
||||
xpos += m_flBoxGap;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: draws a selection box
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, int number)
|
||||
{
|
||||
BaseClass::DrawBox( x, y, wide, tall, color, normalizedAlpha / 255.0f );
|
||||
|
||||
// draw the number
|
||||
if (number >= 0)
|
||||
{
|
||||
Color numberColor = m_NumberColor;
|
||||
numberColor[3] *= normalizedAlpha / 255.0f;
|
||||
surface()->DrawSetTextColor(numberColor);
|
||||
surface()->DrawSetTextFont(m_hNumberFont);
|
||||
wchar_t wch = '0' + number;
|
||||
surface()->DrawSetTextPos(x + m_flSelectionNumberXPos, y + m_flSelectionNumberYPos);
|
||||
surface()->DrawUnicodeChar(wch);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: hud scheme settings
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
SetPaintBackgroundEnabled(false);
|
||||
|
||||
// set our size
|
||||
int screenWide, screenTall;
|
||||
int x, y;
|
||||
GetPos(x, y);
|
||||
GetHudSize(screenWide, screenTall);
|
||||
SetBounds(0, y, screenWide, screenTall - y);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Opens weapon selection control
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::OpenSelection( void )
|
||||
{
|
||||
Assert(!IsInSelectionMode());
|
||||
|
||||
CBaseHudWeaponSelection::OpenSelection();
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("OpenWeaponSelectionMenu");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Closes weapon selection control
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::HideSelection( void )
|
||||
{
|
||||
CBaseHudWeaponSelection::HideSelection();
|
||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("CloseWeaponSelectionMenu");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the next available weapon item in the weapon selection
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatWeapon *CHudWeaponSelection::FindNextWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition)
|
||||
{
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return NULL;
|
||||
|
||||
C_BaseCombatWeapon *pNextWeapon = NULL;
|
||||
|
||||
// search all the weapons looking for the closest next
|
||||
int iLowestNextSlot = MAX_WEAPON_SLOTS;
|
||||
int iLowestNextPosition = MAX_WEAPON_POSITIONS;
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
C_BaseCombatWeapon *pWeapon = pPlayer->GetWeapon(i);
|
||||
if ( !pWeapon )
|
||||
continue;
|
||||
|
||||
if ( pWeapon->CanBeSelected() )
|
||||
{
|
||||
int weaponSlot = pWeapon->GetSlot(), weaponPosition = pWeapon->GetPosition();
|
||||
|
||||
// see if this weapon is further ahead in the selection list
|
||||
if ( weaponSlot > iCurrentSlot || (weaponSlot == iCurrentSlot && weaponPosition > iCurrentPosition) )
|
||||
{
|
||||
// see if this weapon is closer than the current lowest
|
||||
if ( weaponSlot < iLowestNextSlot || (weaponSlot == iLowestNextSlot && weaponPosition < iLowestNextPosition) )
|
||||
{
|
||||
iLowestNextSlot = weaponSlot;
|
||||
iLowestNextPosition = weaponPosition;
|
||||
pNextWeapon = pWeapon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pNextWeapon;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the prior available weapon item in the weapon selection
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatWeapon *CHudWeaponSelection::FindPrevWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition)
|
||||
{
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return NULL;
|
||||
|
||||
C_BaseCombatWeapon *pPrevWeapon = NULL;
|
||||
|
||||
// search all the weapons looking for the closest next
|
||||
int iLowestPrevSlot = -1;
|
||||
int iLowestPrevPosition = -1;
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
C_BaseCombatWeapon *pWeapon = pPlayer->GetWeapon(i);
|
||||
if ( !pWeapon )
|
||||
continue;
|
||||
|
||||
if ( pWeapon->CanBeSelected() )
|
||||
{
|
||||
int weaponSlot = pWeapon->GetSlot(), weaponPosition = pWeapon->GetPosition();
|
||||
|
||||
// see if this weapon is further ahead in the selection list
|
||||
if ( weaponSlot < iCurrentSlot || (weaponSlot == iCurrentSlot && weaponPosition < iCurrentPosition) )
|
||||
{
|
||||
// see if this weapon is closer than the current lowest
|
||||
if ( weaponSlot > iLowestPrevSlot || (weaponSlot == iLowestPrevSlot && weaponPosition > iLowestPrevPosition) )
|
||||
{
|
||||
iLowestPrevSlot = weaponSlot;
|
||||
iLowestPrevPosition = weaponPosition;
|
||||
pPrevWeapon = pWeapon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pPrevWeapon;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Moves the selection to the next item in the menu
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::CycleToNextWeapon( void )
|
||||
{
|
||||
// Get the local player.
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
C_BaseCombatWeapon *pNextWeapon = NULL;
|
||||
if ( IsInSelectionMode() )
|
||||
{
|
||||
// find the next selection spot
|
||||
C_BaseCombatWeapon *pWeapon = GetSelectedWeapon();
|
||||
if ( !pWeapon )
|
||||
return;
|
||||
|
||||
pNextWeapon = FindNextWeaponInWeaponSelection( pWeapon->GetSlot(), pWeapon->GetPosition() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// open selection at the current place
|
||||
pNextWeapon = pPlayer->GetActiveWeapon();
|
||||
if ( pNextWeapon )
|
||||
{
|
||||
pNextWeapon = FindNextWeaponInWeaponSelection( pNextWeapon->GetSlot(), pNextWeapon->GetPosition() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pNextWeapon )
|
||||
{
|
||||
// wrap around back to start
|
||||
pNextWeapon = FindNextWeaponInWeaponSelection(-1, -1);
|
||||
}
|
||||
|
||||
if ( pNextWeapon )
|
||||
{
|
||||
SetSelectedWeapon( pNextWeapon );
|
||||
|
||||
if( hud_fastswitch.GetInt() > 0 )
|
||||
{
|
||||
SelectWeapon();
|
||||
}
|
||||
else if ( !IsInSelectionMode() )
|
||||
{
|
||||
OpenSelection();
|
||||
}
|
||||
|
||||
// Play the "cycle to next weapon" sound
|
||||
if( m_bPlaySelectionSounds )
|
||||
pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Moves the selection to the previous item in the menu
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::CycleToPrevWeapon( void )
|
||||
{
|
||||
// Get the local player.
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
if ( pPlayer->IsPlayerDead() )
|
||||
return;
|
||||
|
||||
C_BaseCombatWeapon *pNextWeapon = NULL;
|
||||
if ( IsInSelectionMode() )
|
||||
{
|
||||
// find the next selection spot
|
||||
C_BaseCombatWeapon *pWeapon = GetSelectedWeapon();
|
||||
if ( !pWeapon )
|
||||
return;
|
||||
|
||||
pNextWeapon = FindPrevWeaponInWeaponSelection( pWeapon->GetSlot(), pWeapon->GetPosition() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// open selection at the current place
|
||||
pNextWeapon = pPlayer->GetActiveWeapon();
|
||||
if ( pNextWeapon )
|
||||
{
|
||||
pNextWeapon = FindPrevWeaponInWeaponSelection( pNextWeapon->GetSlot(), pNextWeapon->GetPosition() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pNextWeapon )
|
||||
{
|
||||
// wrap around back to end of weapon list
|
||||
pNextWeapon = FindPrevWeaponInWeaponSelection(MAX_WEAPON_SLOTS, MAX_WEAPON_POSITIONS);
|
||||
}
|
||||
|
||||
if ( pNextWeapon )
|
||||
{
|
||||
SetSelectedWeapon( pNextWeapon );
|
||||
|
||||
if( hud_fastswitch.GetInt() > 0 )
|
||||
{
|
||||
SelectWeapon();
|
||||
}
|
||||
else if ( !IsInSelectionMode() )
|
||||
{
|
||||
OpenSelection();
|
||||
}
|
||||
|
||||
// Play the "cycle to next weapon" sound
|
||||
if( m_bPlaySelectionSounds )
|
||||
pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Switches the last weapon the player was using
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::SwitchToLastWeapon( void )
|
||||
{
|
||||
// Get the player's last weapon
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
if ( player->IsPlayerDead() )
|
||||
return;
|
||||
|
||||
C_BaseCombatWeapon *lastWeapon = player->GetLastWeapon();
|
||||
C_BaseCombatWeapon *activeWeapon = player->GetActiveWeapon();
|
||||
|
||||
if ( lastWeapon == activeWeapon )
|
||||
lastWeapon = NULL;
|
||||
|
||||
// make sure our last weapon is still with us and valid (has ammo etc)
|
||||
if ( lastWeapon )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
C_BaseCombatWeapon *weapon = player->GetWeapon(i);
|
||||
|
||||
if ( !weapon || !weapon->CanBeSelected() )
|
||||
continue;
|
||||
|
||||
if (weapon == lastWeapon )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == MAX_WEAPONS )
|
||||
lastWeapon = NULL; // weapon not found/valid
|
||||
}
|
||||
|
||||
// if we don't have a 'last weapon' choose best weapon
|
||||
if ( !lastWeapon )
|
||||
{
|
||||
lastWeapon = GameRules()->GetNextBestWeapon( player, activeWeapon );
|
||||
}
|
||||
|
||||
::input->MakeWeaponSelection( lastWeapon );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the weapon in the specified slot
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatWeapon *CHudWeaponSelection::GetWeaponInSlot( int iSlot, int iSlotPos )
|
||||
{
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return NULL;
|
||||
|
||||
if ( player->IsPlayerDead() )
|
||||
return NULL;
|
||||
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
C_BaseCombatWeapon *pWeapon = player->GetWeapon(i);
|
||||
|
||||
if ( pWeapon == NULL )
|
||||
continue;
|
||||
|
||||
if ( pWeapon->GetSlot() == iSlot && pWeapon->GetPosition() == iSlotPos )
|
||||
return pWeapon;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Player has chosen to draw the currently selected weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::SelectWeapon( void )
|
||||
{
|
||||
if ( !GetSelectedWeapon() )
|
||||
{
|
||||
engine->ClientCmd( "cancelselect\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
C_BaseCombatWeapon *activeWeapon = player->GetActiveWeapon();
|
||||
|
||||
// Don't allow selections of weapons that can't be selected (out of ammo, etc)
|
||||
if ( !GetSelectedWeapon()->CanBeSelected() )
|
||||
{
|
||||
player->EmitSound( "Player.DenyWeaponSelection" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only play the "weapon selected" sound if they are selecting
|
||||
// a weapon different than the one that is already active.
|
||||
if (GetSelectedWeapon() != activeWeapon)
|
||||
{
|
||||
// Play the "weapon selected" sound
|
||||
player->EmitSound( "Player.WeaponSelected" );
|
||||
}
|
||||
|
||||
SetWeaponSelected();
|
||||
|
||||
m_hSelectedWeapon = NULL;
|
||||
|
||||
engine->ClientCmd( "cancelselect\n" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Abort selecting a weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::CancelWeaponSelection()
|
||||
{
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
// Fastswitches happen in a single frame, so the Weapon Selection HUD Element isn't visible
|
||||
// yet, but it's going to be next frame. We need to ask it if it thinks it's going to draw,
|
||||
// instead of checking it's IsActive flag.
|
||||
if ( ShouldDraw() )
|
||||
{
|
||||
HideSelection();
|
||||
|
||||
m_hSelectedWeapon = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
engine->ClientCmd("escape");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Moves selection to the specified slot
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudWeaponSelection::SelectWeaponSlot( int iSlot )
|
||||
{
|
||||
// iSlot is one higher than it should be, since it's the number key, not the 0-based index into the weapons
|
||||
--iSlot;
|
||||
|
||||
// Get the local player.
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
// Don't try and read past our possible number of slots
|
||||
if ( iSlot > MAX_WEAPON_SLOTS )
|
||||
return;
|
||||
|
||||
// Make sure the player's allowed to switch weapons
|
||||
if ( pPlayer->IsAllowedToSwitchWeapons() == false )
|
||||
return;
|
||||
|
||||
int slotPos = 0;
|
||||
C_BaseCombatWeapon *pActiveWeapon = GetSelectedWeapon();
|
||||
|
||||
// start later in the list
|
||||
if ( IsInSelectionMode() && pActiveWeapon && pActiveWeapon->GetSlot() == iSlot )
|
||||
{
|
||||
slotPos = pActiveWeapon->GetPosition() + 1;
|
||||
}
|
||||
|
||||
// find the weapon in this slot
|
||||
pActiveWeapon = GetNextActivePos( iSlot, slotPos );
|
||||
if ( !pActiveWeapon )
|
||||
{
|
||||
pActiveWeapon = GetNextActivePos( iSlot, 0 );
|
||||
}
|
||||
|
||||
if ( pActiveWeapon != NULL )
|
||||
{
|
||||
// Mark the change
|
||||
SetSelectedWeapon( pActiveWeapon );
|
||||
|
||||
bool bMultipleWeaponsInSlot = false;
|
||||
|
||||
for( int i=0;i<MAX_WEAPON_POSITIONS;i++ )
|
||||
{
|
||||
C_BaseCombatWeapon *pSlotWpn = GetWeaponInSlot( pActiveWeapon->GetSlot(), i );
|
||||
|
||||
if( pSlotWpn != NULL && pSlotWpn != pActiveWeapon )
|
||||
{
|
||||
bMultipleWeaponsInSlot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if fast weapon switch is on, then weapons can be selected in a single keypress
|
||||
// but only if there is only one item in the bucket
|
||||
if( hud_fastswitch.GetInt() > 0 && bMultipleWeaponsInSlot == false )
|
||||
{
|
||||
// only one active item in bucket, so change directly to weapon
|
||||
SelectWeapon();
|
||||
}
|
||||
else if ( !IsInSelectionMode() )
|
||||
{
|
||||
// open the weapon selection
|
||||
OpenSelection();
|
||||
}
|
||||
}
|
||||
|
||||
if( m_bPlaySelectionSounds )
|
||||
pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: TF2 specific input handling
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "kbutton.h"
|
||||
#include "input.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: TF Input interface
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSInput : public CInput
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
static CCSInput g_Input;
|
||||
|
||||
// Expose this interface
|
||||
IInput *input = ( IInput * )&g_Input;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "prediction.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "igamemovement.h"
|
||||
|
||||
|
||||
static CMoveData g_MoveData;
|
||||
CMoveData *g_pMoveData = &g_MoveData;
|
||||
|
||||
|
||||
class CCSPrediction : public CPrediction
|
||||
{
|
||||
DECLARE_CLASS( CCSPrediction, CPrediction );
|
||||
|
||||
public:
|
||||
virtual void SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
|
||||
virtual void FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSPrediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper,
|
||||
CMoveData *move )
|
||||
{
|
||||
player->AvoidPhysicsProps( ucmd );
|
||||
|
||||
// Call the default SetupMove code.
|
||||
BaseClass::SetupMove( player, ucmd, pHelper, move );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSPrediction::FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move )
|
||||
{
|
||||
// Call the default FinishMove code.
|
||||
BaseClass::FinishMove( player, ucmd, move );
|
||||
}
|
||||
|
||||
|
||||
// Expose interface to engine
|
||||
// Expose interface to engine
|
||||
static CCSPrediction g_Prediction;
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CCSPrediction, IPrediction, VCLIENT_PREDICTION_INTERFACE_VERSION, g_Prediction );
|
||||
|
||||
CPrediction *prediction = &g_Prediction;
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//=======================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( REPLAY_ENABLED )
|
||||
|
||||
#include "cs_replay.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
#include "clientmode_shared.h"
|
||||
#include "replay/ireplaymoviemanager.h"
|
||||
#include "replay/ireplayfactory.h"
|
||||
#include "replay/ireplayscreenshotmanager.h"
|
||||
#include "replay/screenshot.h"
|
||||
#include <time.h>
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
extern IReplayScreenshotManager *g_pReplayScreenshotManager;
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
CCSReplay::CCSReplay()
|
||||
{
|
||||
}
|
||||
|
||||
CCSReplay::~CCSReplay()
|
||||
{
|
||||
}
|
||||
|
||||
void CCSReplay::OnBeginRecording()
|
||||
{
|
||||
BaseClass::OnBeginRecording();
|
||||
|
||||
// Setup the newly created replay
|
||||
C_CSPlayer* pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
SetPlayerClass( pPlayer->PlayerClass() );
|
||||
SetPlayerTeam( pPlayer->GetTeamNumber() );
|
||||
}
|
||||
}
|
||||
|
||||
void CCSReplay::OnEndRecording()
|
||||
{
|
||||
if ( gameeventmanager )
|
||||
{
|
||||
gameeventmanager->RemoveListener( this );
|
||||
}
|
||||
|
||||
BaseClass::OnEndRecording();
|
||||
}
|
||||
|
||||
void CCSReplay::OnComplete()
|
||||
{
|
||||
BaseClass::OnComplete();
|
||||
}
|
||||
|
||||
void CCSReplay::Update()
|
||||
{
|
||||
BaseClass::Update();
|
||||
}
|
||||
|
||||
float CCSReplay::GetSentryKillScreenshotDelay()
|
||||
{
|
||||
ConVarRef replay_screenshotsentrykilldelay( "replay_screenshotsentrykilldelay" );
|
||||
return replay_screenshotsentrykilldelay.IsValid() ? replay_screenshotsentrykilldelay.GetFloat() : 0.5f;
|
||||
}
|
||||
|
||||
void CCSReplay::FireGameEvent( IGameEvent *pEvent )
|
||||
{
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pLocalPlayer )
|
||||
return;
|
||||
|
||||
CaptureScreenshotParams_t params;
|
||||
V_memset( ¶ms, 0, sizeof( params ) );
|
||||
|
||||
if ( FStrEq( pEvent->GetName(), "player_death" ) )
|
||||
{
|
||||
ConVarRef replay_debug( "replay_debug" );
|
||||
if ( replay_debug.IsValid() && replay_debug.GetBool() )
|
||||
{
|
||||
DevMsg( "%i: CCSReplay::FireGameEvent(): player_death\n", gpGlobals->tickcount );
|
||||
}
|
||||
|
||||
int nKillerID = pEvent->GetInt( "attacker" );
|
||||
int nVictimID = pEvent->GetInt( "userid" );
|
||||
int nDeathFlags = pEvent->GetInt( "death_flags" );
|
||||
|
||||
const char *pWeaponName = pEvent->GetString( "weapon" );
|
||||
|
||||
// Suicide?
|
||||
bool bSuicide = nKillerID == nVictimID;
|
||||
|
||||
// Try to get killer
|
||||
C_CSPlayer *pKiller = ToCSPlayer( USERID2PLAYER( nKillerID ) );
|
||||
|
||||
// Try to get victim
|
||||
C_CSPlayer *pVictim = ToCSPlayer( USERID2PLAYER( nVictimID ) );
|
||||
|
||||
// Inflictor was a sentry gun?
|
||||
bool bSentry = V_strnicmp( pWeaponName, "obj_sentrygun", 13 ) == 0;
|
||||
|
||||
// Is the killer the local player?
|
||||
if ( nKillerID == pLocalPlayer->GetUserID() &&
|
||||
!bSuicide &&
|
||||
!bSentry )
|
||||
{
|
||||
// Domination?
|
||||
if ( nDeathFlags & REPLAY_DEATH_DOMINATION )
|
||||
{
|
||||
AddDomination( nVictimID );
|
||||
}
|
||||
|
||||
// Revenge?
|
||||
if ( pEvent->GetInt( "death_flags" ) & REPLAY_DEATH_REVENGE )
|
||||
{
|
||||
AddRevenge( nVictimID );
|
||||
}
|
||||
|
||||
// Add victim info to kill list
|
||||
if ( pVictim )
|
||||
{
|
||||
AddKill( pVictim->GetPlayerName(), pVictim->PlayerClass() );
|
||||
}
|
||||
|
||||
// Take a quick screenshot with some delay
|
||||
ConVarRef replay_screenshotkilldelay( "replay_screenshotkilldelay" );
|
||||
if ( replay_screenshotkilldelay.IsValid() )
|
||||
{
|
||||
params.m_flDelay = GetKillScreenshotDelay();
|
||||
g_pReplayScreenshotManager->CaptureScreenshot( params );
|
||||
}
|
||||
}
|
||||
|
||||
// Player death?
|
||||
else if ( pKiller &&
|
||||
nVictimID == pLocalPlayer->GetUserID() )
|
||||
{
|
||||
// Record who killed the player if not a suicide
|
||||
if ( !bSuicide )
|
||||
{
|
||||
RecordPlayerDeath( pKiller->GetPlayerName(), pKiller->PlayerClass() );
|
||||
}
|
||||
|
||||
// Take screenshot - taking a screenshot during feign death is cool, too.
|
||||
ConVarRef replay_deathcammaxverticaloffset( "replay_deathcammaxverticaloffset" );
|
||||
ConVarRef replay_playerdeathscreenshotdelay( "replay_playerdeathscreenshotdelay" );
|
||||
params.m_flDelay = replay_playerdeathscreenshotdelay.IsValid() ? replay_playerdeathscreenshotdelay.GetFloat() : 0.0f;
|
||||
params.m_nEntity = pLocalPlayer->entindex();
|
||||
params.m_posCamera.Init( 0,0, replay_deathcammaxverticaloffset.IsValid() ? replay_deathcammaxverticaloffset.GetFloat() : 150 );
|
||||
params.m_angCamera.Init( 90, 0, 0 ); // Look straight down
|
||||
params.m_bUseCameraAngles = true;
|
||||
params.m_bIgnoreMinTimeBetweenScreenshots = true;
|
||||
g_pReplayScreenshotManager->CaptureScreenshot( params );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CCSReplay::IsValidClass( int iClass ) const
|
||||
{
|
||||
return ( iClass >= CS_CLASS_NONE && iClass < CS_NUM_CLASSES );
|
||||
}
|
||||
|
||||
bool CCSReplay::IsValidTeam( int iTeam ) const
|
||||
{
|
||||
return ( iTeam == TEAM_TERRORIST || iTeam == TEAM_CT );
|
||||
}
|
||||
|
||||
bool CCSReplay::GetCurrentStats( RoundStats_t &out )
|
||||
{
|
||||
out = g_CSClientGameStats.GetLifetimeStats();
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *CCSReplay::GetStatString( int iStat ) const
|
||||
{
|
||||
return CSStatProperty_Table[ iStat ].szSteamName;
|
||||
}
|
||||
|
||||
const char *CCSReplay::GetPlayerClass( int iClass ) const
|
||||
{
|
||||
Assert( iClass >= CS_CLASS_NONE && iClass < CS_NUM_CLASSES );
|
||||
return GetCSClassInfo( iClass )->m_pClassName;
|
||||
}
|
||||
|
||||
bool CCSReplay::Read( KeyValues *pIn )
|
||||
{
|
||||
return BaseClass::Read( pIn );
|
||||
}
|
||||
|
||||
void CCSReplay::Write( KeyValues *pOut )
|
||||
{
|
||||
BaseClass::Write( pOut );
|
||||
}
|
||||
|
||||
const char *CCSReplay::GetMaterialFriendlyPlayerClass() const
|
||||
{
|
||||
return BaseClass::GetMaterialFriendlyPlayerClass();
|
||||
}
|
||||
|
||||
void CCSReplay::DumpGameSpecificData() const
|
||||
{
|
||||
BaseClass::DumpGameSpecificData();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
class CCSReplayFactory : public IReplayFactory
|
||||
{
|
||||
public:
|
||||
virtual CReplay *Create()
|
||||
{
|
||||
return new CCSReplay();
|
||||
}
|
||||
};
|
||||
|
||||
static CCSReplayFactory s_ReplayManager;
|
||||
IReplayFactory *g_pReplayFactory = &s_ReplayManager;
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CCSReplayFactory, IReplayFactory, INTERFACE_VERSION_REPLAY_FACTORY, s_ReplayManager );
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//=======================================================================================//
|
||||
|
||||
#if defined( REPLAY_ENABLED )
|
||||
|
||||
#ifndef CS_REPLAY_H
|
||||
#define CS_REPLAY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
#include "replay/genericclassbased_replay.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
class CCSReplay : public CGenericClassBasedReplay
|
||||
{
|
||||
typedef CGenericClassBasedReplay BaseClass;
|
||||
public:
|
||||
CCSReplay();
|
||||
~CCSReplay();
|
||||
|
||||
virtual void OnBeginRecording();
|
||||
virtual void OnEndRecording();
|
||||
virtual void OnComplete();
|
||||
virtual void FireGameEvent( IGameEvent *pEvent );
|
||||
|
||||
virtual bool Read( KeyValues *pIn );
|
||||
virtual void Write( KeyValues *pOut );
|
||||
|
||||
virtual void DumpGameSpecificData() const;
|
||||
|
||||
virtual const char *GetPlayerClass() const { return GetCSClassInfo( m_nPlayerClass )->m_pClassName; }
|
||||
virtual const char *GetPlayerTeam() const { return m_nPlayerTeam == TEAM_TERRORIST ? "terrorists" : "counterterrorists"; }
|
||||
virtual const char *GetMaterialFriendlyPlayerClass() const;
|
||||
|
||||
private:
|
||||
virtual void Update();
|
||||
float GetSentryKillScreenshotDelay();
|
||||
|
||||
virtual bool IsValidClass( int nClass ) const;
|
||||
virtual bool IsValidTeam( int iTeam ) const;
|
||||
virtual bool GetCurrentStats( RoundStats_t &out );
|
||||
virtual const char *GetStatString( int iStat ) const;
|
||||
virtual const char *GetPlayerClass( int iClass ) const;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
inline CCSReplay *ToCSReplay( CReplay *pClientReplay )
|
||||
{
|
||||
return static_cast< CCSReplay * >( pClientReplay );
|
||||
}
|
||||
|
||||
inline const CCSReplay *ToCSReplay( const CReplay *pClientReplay )
|
||||
{
|
||||
return static_cast< const CCSReplay * >( pClientReplay );
|
||||
}
|
||||
|
||||
inline CCSReplay *GetCSReplay( ReplayHandle_t hReplay )
|
||||
{
|
||||
return ToCSReplay( g_pClientReplayContext->GetReplay( hReplay ) );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
#endif // CS_REPLAY_H
|
||||
|
||||
#endif
|
||||
@@ -1,325 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Responsible for drawing the scene
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "view.h"
|
||||
#include "iviewrender.h"
|
||||
#include "view_shared.h"
|
||||
#include "ivieweffects.h"
|
||||
#include "iinput.h"
|
||||
#include "model_types.h"
|
||||
#include "clientsideeffects.h"
|
||||
#include "particlemgr.h"
|
||||
#include "viewrender.h"
|
||||
#include "iclientmode.h"
|
||||
#include "voice_status.h"
|
||||
#include "radio_status.h"
|
||||
#include "glow_overlay.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "detailobjectsystem.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "engine/IEngineTrace.h"
|
||||
#include "engine/ivmodelinfo.h"
|
||||
#include "view_scene.h"
|
||||
#include "particles_ez.h"
|
||||
#include "engine/IStaticPropMgr.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "cs_view_scene.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "shake.h"
|
||||
#include "clienteffectprecachesystem.h"
|
||||
#include <vgui/ISurface.h>
|
||||
|
||||
CLIENTEFFECT_REGISTER_BEGIN( PrecacheCSViewScene )
|
||||
CLIENTEFFECT_MATERIAL( "effects/flashbang" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/flashbang_white" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/nightvision" )
|
||||
CLIENTEFFECT_REGISTER_END()
|
||||
|
||||
static CCSViewRender g_ViewRender;
|
||||
|
||||
CCSViewRender::CCSViewRender()
|
||||
{
|
||||
view = ( IViewRender * )&g_ViewRender;
|
||||
m_pFlashTexture = NULL;
|
||||
}
|
||||
|
||||
struct ConVarFlags
|
||||
{
|
||||
const char *name;
|
||||
int flags;
|
||||
};
|
||||
|
||||
ConVarFlags s_flaggedConVars[] =
|
||||
{
|
||||
{ "r_screenfademinsize", FCVAR_CHEAT },
|
||||
{ "r_screenfademaxsize", FCVAR_CHEAT },
|
||||
{ "developer", FCVAR_CHEAT },
|
||||
};
|
||||
|
||||
void CCSViewRender::Init( void )
|
||||
{
|
||||
for ( int i=0; i<ARRAYSIZE( s_flaggedConVars ); ++i )
|
||||
{
|
||||
ConVar *flaggedConVar = cvar->FindVar( s_flaggedConVars[i].name );
|
||||
if ( flaggedConVar )
|
||||
{
|
||||
flaggedConVar->AddFlags( s_flaggedConVars[i].flags );
|
||||
}
|
||||
}
|
||||
|
||||
CViewRender::Init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the min/max fade distances
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSViewRender::GetScreenFadeDistances( float *min, float *max )
|
||||
{
|
||||
if ( min )
|
||||
{
|
||||
*min = 0.0f;
|
||||
}
|
||||
|
||||
if ( max )
|
||||
{
|
||||
*max = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCSViewRender::PerformNightVisionEffect( const CViewSetup &view )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
if (pPlayer->GetObserverMode() == OBS_MODE_IN_EYE)
|
||||
{
|
||||
CBaseEntity *target = pPlayer->GetObserverTarget();
|
||||
if (target && target->IsPlayer())
|
||||
{
|
||||
pPlayer = (C_CSPlayer *)target;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pPlayer && pPlayer->m_flNightVisionAlpha > 0 )
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindMaterial( "effects/nightvision", TEXTURE_GROUP_CLIENT_EFFECTS, true );
|
||||
|
||||
if ( pMaterial )
|
||||
{
|
||||
int iMaxValue = 255;
|
||||
byte overlaycolor[4] = { 0, 255, 0, 255 };
|
||||
|
||||
if ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 80 )
|
||||
{
|
||||
UpdateScreenEffectTexture( 0, view.x, view.y, view.width, view.height );
|
||||
}
|
||||
else
|
||||
{
|
||||
// In DX7, use the values CS:goldsrc uses.
|
||||
iMaxValue = 225;
|
||||
overlaycolor[0] = overlaycolor[2] = 50 / 2;
|
||||
overlaycolor[1] = 225 / 2;
|
||||
}
|
||||
|
||||
if ( pPlayer->m_bNightVisionOn )
|
||||
{
|
||||
pPlayer->m_flNightVisionAlpha += 15;
|
||||
|
||||
pPlayer->m_flNightVisionAlpha = MIN( pPlayer->m_flNightVisionAlpha, iMaxValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->m_flNightVisionAlpha -= 40;
|
||||
|
||||
pPlayer->m_flNightVisionAlpha = MAX( pPlayer->m_flNightVisionAlpha, 0 );
|
||||
|
||||
}
|
||||
|
||||
overlaycolor[3] = pPlayer->m_flNightVisionAlpha;
|
||||
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
|
||||
// Only one pass in DX7.
|
||||
if ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 80 )
|
||||
{
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
pRenderContext->DrawScreenSpaceQuad( pMaterial );
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
pRenderContext->DrawScreenSpaceQuad( pMaterial );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Adrian - Super Nifty Flashbang Effect(tm)
|
||||
// this does the burn in for the flashbang effect.
|
||||
void CCSViewRender::PerformFlashbangEffect( const CViewSetup &view )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer == NULL )
|
||||
return;
|
||||
|
||||
if ( pPlayer->m_flFlashBangTime < gpGlobals->curtime )
|
||||
return;
|
||||
|
||||
IMaterial *pMaterial = materials->FindMaterial( "effects/flashbang", TEXTURE_GROUP_CLIENT_EFFECTS, true );
|
||||
|
||||
if ( !pMaterial )
|
||||
return;
|
||||
|
||||
byte overlaycolor[4] = { 255, 255, 255, 255 };
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
|
||||
if ( pPlayer->m_flFlashAlpha < pPlayer->m_flFlashMaxAlpha )
|
||||
{
|
||||
pPlayer->m_flFlashAlpha += 45;
|
||||
|
||||
pPlayer->m_flFlashAlpha = MIN( pPlayer->m_flFlashAlpha, pPlayer->m_flFlashMaxAlpha );
|
||||
|
||||
overlaycolor[0] = overlaycolor[1] = overlaycolor[2] = pPlayer->m_flFlashAlpha;
|
||||
|
||||
m_pFlashTexture = GetFullFrameFrameBufferTexture( 1 );
|
||||
|
||||
bool foundVar;
|
||||
|
||||
IMaterialVar* m_BaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );
|
||||
|
||||
Rect_t srcRect;
|
||||
srcRect.x = view.x;
|
||||
srcRect.y = view.y;
|
||||
srcRect.width = view.width;
|
||||
srcRect.height = view.height;
|
||||
m_BaseTextureVar->SetTextureValue( m_pFlashTexture );
|
||||
pRenderContext->CopyRenderTargetToTextureEx( m_pFlashTexture, 0, &srcRect, NULL );
|
||||
pRenderContext->SetFrameBufferCopyTexture( m_pFlashTexture );
|
||||
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
|
||||
// just do one pass for dxlevel < 80.
|
||||
if (g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 80)
|
||||
{
|
||||
pRenderContext->DrawScreenSpaceRectangle( pMaterial, view.x, view.y, view.width, view.height,
|
||||
0, 0, m_pFlashTexture->GetActualWidth()-1, m_pFlashTexture->GetActualHeight()-1,
|
||||
m_pFlashTexture->GetActualWidth(), m_pFlashTexture->GetActualHeight() );
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
pRenderContext->DrawScreenSpaceRectangle( pMaterial, view.x, view.y, view.width, view.height,
|
||||
0, 0, m_pFlashTexture->GetActualWidth()-1, m_pFlashTexture->GetActualHeight()-1,
|
||||
m_pFlashTexture->GetActualWidth(), m_pFlashTexture->GetActualHeight() );
|
||||
}
|
||||
}
|
||||
else if ( m_pFlashTexture )
|
||||
{
|
||||
float flAlpha = pPlayer->m_flFlashMaxAlpha * (pPlayer->m_flFlashBangTime - gpGlobals->curtime) / pPlayer->m_flFlashDuration;
|
||||
|
||||
flAlpha = clamp( flAlpha, 0, pPlayer->m_flFlashMaxAlpha );
|
||||
|
||||
overlaycolor[0] = overlaycolor[1] = overlaycolor[2] = flAlpha;
|
||||
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
|
||||
// just do one pass for dxlevel < 80.
|
||||
if (g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 80)
|
||||
{
|
||||
pRenderContext->DrawScreenSpaceRectangle( pMaterial, view.x, view.y, view.width, view.height,
|
||||
0, 0, m_pFlashTexture->GetActualWidth()-1, m_pFlashTexture->GetActualHeight()-1,
|
||||
m_pFlashTexture->GetActualWidth(), m_pFlashTexture->GetActualHeight() );
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
pRenderContext->DrawScreenSpaceRectangle( pMaterial, view.x, view.y, view.width, view.height,
|
||||
0, 0, m_pFlashTexture->GetActualWidth()-1, m_pFlashTexture->GetActualHeight()-1,
|
||||
m_pFlashTexture->GetActualWidth(), m_pFlashTexture->GetActualHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
// this does the pure white overlay part of the flashbang effect.
|
||||
pMaterial = materials->FindMaterial( "effects/flashbang_white", TEXTURE_GROUP_CLIENT_EFFECTS, true );
|
||||
|
||||
if ( !pMaterial )
|
||||
return;
|
||||
|
||||
float flAlpha = 255;
|
||||
|
||||
if ( pPlayer->m_flFlashAlpha < pPlayer->m_flFlashMaxAlpha )
|
||||
{
|
||||
flAlpha = pPlayer->m_flFlashAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
float flFlashTimeLeft = pPlayer->m_flFlashBangTime - gpGlobals->curtime;
|
||||
float flAlphaPercentage = 1.0;
|
||||
const float certainBlindnessTimeThresh = 3.0; // yes this is a magic number, necessary to match CS/CZ flashbang effectiveness cause the rendering system is completely different.
|
||||
|
||||
if (flFlashTimeLeft > certainBlindnessTimeThresh)
|
||||
{
|
||||
// if we still have enough time of blindness left, make sure the player can't see anything yet.
|
||||
flAlphaPercentage = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// blindness effects shorter than 'certainBlindnessTimeThresh' will start off at less than 255 alpha.
|
||||
flAlphaPercentage = flFlashTimeLeft / certainBlindnessTimeThresh;
|
||||
|
||||
if (g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 80)
|
||||
{
|
||||
// reduce alpha level quicker with dx 8 support and higher to compensate
|
||||
// for having the burn-in effect.
|
||||
flAlphaPercentage *= flAlphaPercentage;
|
||||
}
|
||||
}
|
||||
|
||||
flAlpha = flAlphaPercentage *= pPlayer->m_flFlashMaxAlpha; // scale a [0..1) value to a [0..MaxAlpha] value for the alpha.
|
||||
|
||||
// make sure the alpha is in the range of [0..MaxAlpha]
|
||||
flAlpha = MAX ( flAlpha, 0 );
|
||||
flAlpha = MIN ( flAlpha, pPlayer->m_flFlashMaxAlpha);
|
||||
}
|
||||
|
||||
overlaycolor[0] = overlaycolor[1] = overlaycolor[2] = flAlpha;
|
||||
render->ViewDrawFade( overlaycolor, pMaterial );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Renders extra 2D effects in derived classes while the 2D view is on the stack
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSViewRender::Render2DEffectsPreHUD( const CViewSetup &view )
|
||||
{
|
||||
PerformNightVisionEffect( view ); // this needs to come before the HUD is drawn, or it will wash the HUD out
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Renders extra 2D effects in derived classes while the 2D view is on the stack
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSViewRender::Render2DEffectsPostHUD( const CViewSetup &view )
|
||||
{
|
||||
PerformFlashbangEffect( view );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Renders voice feedback and other sprites attached to players
|
||||
// Input : none
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCSViewRender::RenderPlayerSprites()
|
||||
{
|
||||
GetClientVoiceMgr()->SetHeadLabelOffset( 40 );
|
||||
|
||||
CViewRender::RenderPlayerSprites();
|
||||
RadioManager()->DrawHeadLabels();
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CS_VIEW_SCENE_H
|
||||
#define CS_VIEW_SCENE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "viewrender.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Implements the interview to view rendering for the client .dll
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCSViewRender : public CViewRender
|
||||
{
|
||||
public:
|
||||
CCSViewRender();
|
||||
|
||||
virtual void Init( void );
|
||||
|
||||
virtual void GetScreenFadeDistances( float *min, float *max );
|
||||
|
||||
virtual void Render2DEffectsPreHUD( const CViewSetup &view );
|
||||
virtual void Render2DEffectsPostHUD( const CViewSetup &view );
|
||||
virtual void RenderPlayerSprites( void );
|
||||
|
||||
private:
|
||||
|
||||
void PerformFlashbangEffect( const CViewSetup &view );
|
||||
void PerformNightVisionEffect( const CViewSetup &view );
|
||||
|
||||
ITexture *m_pFlashTexture;
|
||||
};
|
||||
|
||||
#endif //CS_VIEW_SCENE_H
|
||||
@@ -1,482 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: A blood spray effect to expose successful hits.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "clienteffectprecachesystem.h"
|
||||
#include "fx_sparks.h"
|
||||
#include "iefx.h"
|
||||
#include "c_te_effect_dispatch.h"
|
||||
#include "particles_ez.h"
|
||||
#include "decals.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "fx_quad.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "shareddefs.h"
|
||||
#include "fx_blood.h"
|
||||
#include "view.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectCSBloodSpray )
|
||||
CLIENTEFFECT_MATERIAL( "effects/blood_gore" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/blood_drop" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/blood_puff" )
|
||||
CLIENTEFFECT_REGISTER_END()
|
||||
|
||||
|
||||
class CHitEffectRamp
|
||||
{
|
||||
public:
|
||||
float m_flDamageAmount;
|
||||
|
||||
float m_flMinAlpha;
|
||||
float m_flMaxAlpha;
|
||||
|
||||
float m_flMinSize;
|
||||
float m_flMaxSize;
|
||||
|
||||
float m_flMinVelocity;
|
||||
float m_flMaxVelocity;
|
||||
};
|
||||
|
||||
|
||||
void InterpolateRamp(
|
||||
const CHitEffectRamp &a,
|
||||
const CHitEffectRamp &b,
|
||||
CHitEffectRamp &out,
|
||||
int iDamage )
|
||||
{
|
||||
float t = RemapVal( iDamage, a.m_flDamageAmount, b.m_flDamageAmount, 0, 1 );
|
||||
|
||||
out.m_flMinAlpha = FLerp( a.m_flMinAlpha, b.m_flMinAlpha, t );
|
||||
out.m_flMaxAlpha = FLerp( a.m_flMaxAlpha, b.m_flMaxAlpha, t );
|
||||
out.m_flMinAlpha = clamp( out.m_flMinAlpha, 0, 255 );
|
||||
out.m_flMaxAlpha = clamp( out.m_flMaxAlpha, 0, 255 );
|
||||
|
||||
out.m_flMinSize = FLerp( a.m_flMinSize, b.m_flMinSize, t );
|
||||
out.m_flMaxSize = FLerp( a.m_flMaxSize, b.m_flMaxSize, t );
|
||||
|
||||
out.m_flMinVelocity = FLerp( a.m_flMinVelocity, b.m_flMinVelocity, t );
|
||||
out.m_flMaxVelocity = FLerp( a.m_flMaxVelocity, b.m_flMaxVelocity, t );
|
||||
}
|
||||
|
||||
|
||||
void FX_HitEffectSmoke(
|
||||
CSmartPtr<CBloodSprayEmitter> pEmitter,
|
||||
int iDamage,
|
||||
const Vector &vEntryPoint,
|
||||
const Vector &vDirection,
|
||||
float flScale)
|
||||
{
|
||||
SimpleParticle newParticle;
|
||||
PMaterialHandle hMaterial = ParticleMgr()->GetPMaterial( "effects/blood_gore" );
|
||||
|
||||
// These parameters create a ramp based on how much damage the shot did.
|
||||
CHitEffectRamp ramps[2] =
|
||||
{
|
||||
{
|
||||
0,
|
||||
30, // min/max alpha
|
||||
70,
|
||||
0.5, // min/max size
|
||||
1,
|
||||
0, // min/max velocity (not used here)
|
||||
0
|
||||
},
|
||||
|
||||
{
|
||||
50,
|
||||
30, // min/max alpha
|
||||
70,
|
||||
1, // min/max size
|
||||
2,
|
||||
0, // min/max velocity (not used here)
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
CHitEffectRamp interpolatedRamp;
|
||||
InterpolateRamp(
|
||||
ramps[0],
|
||||
ramps[1],
|
||||
interpolatedRamp,
|
||||
iDamage );
|
||||
|
||||
for ( int i=0; i < 2; i++ )
|
||||
{
|
||||
SimpleParticle &newParticle = *pEmitter->AddSimpleParticle( hMaterial, vEntryPoint, 0, 0 );
|
||||
|
||||
newParticle.m_flLifetime = 0.0f;
|
||||
newParticle.m_flDieTime = 3.0f;
|
||||
|
||||
newParticle.m_uchStartSize = random->RandomInt(
|
||||
interpolatedRamp.m_flMinSize,
|
||||
interpolatedRamp.m_flMaxSize ) * flScale;
|
||||
newParticle.m_uchEndSize = newParticle.m_uchStartSize * 4;
|
||||
|
||||
newParticle.m_vecVelocity = Vector( 0, 0, 5 ) + RandomVector( -2, 2 );
|
||||
newParticle.m_uchStartAlpha = random->RandomInt(
|
||||
interpolatedRamp.m_flMinSize,
|
||||
interpolatedRamp.m_flMaxSize );
|
||||
newParticle.m_uchEndAlpha = 0;
|
||||
|
||||
newParticle.m_flRoll = random->RandomFloat( 0, 360 );
|
||||
newParticle.m_flRollDelta = random->RandomFloat( -1, 1 );
|
||||
|
||||
newParticle.m_iFlags = SIMPLE_PARTICLE_FLAG_NO_VEL_DECAY;
|
||||
|
||||
float colorRamp = random->RandomFloat( 0.5f, 1.25f );
|
||||
|
||||
newParticle.m_uchColor[0] = MIN( 1.0f, colorRamp ) * 255.0f;
|
||||
newParticle.m_uchColor[1] = MIN( 1.0f, colorRamp ) * 255.0f;
|
||||
newParticle.m_uchColor[2] = MIN( 1.0f, colorRamp ) * 255.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FX_HitEffectBloodSpray(
|
||||
CSmartPtr<CBloodSprayEmitter> pEmitter,
|
||||
int iDamage,
|
||||
const Vector &vEntryPoint,
|
||||
const Vector &vSprayNormal,
|
||||
const char *pMaterialName,
|
||||
float flLODDistance,
|
||||
float flDistanceScale,
|
||||
float flScale,
|
||||
float flSpeed )
|
||||
{
|
||||
PMaterialHandle hMaterial = ParticleMgr()->GetPMaterial( pMaterialName );
|
||||
SimpleParticle *pParticle;
|
||||
|
||||
float color[3] = { 1.0, 0, 0 };
|
||||
|
||||
Vector up( 0, 0, 1 );
|
||||
Vector right = up.Cross( vSprayNormal );
|
||||
VectorNormalize( right );
|
||||
|
||||
// These parameters create a ramp based on how much damage the shot did.
|
||||
CHitEffectRamp ramps[2] =
|
||||
{
|
||||
{
|
||||
0,
|
||||
80, // min/max alpha
|
||||
128,
|
||||
flScale/2,// min/max size
|
||||
flScale,
|
||||
10, // min/max velocity
|
||||
20
|
||||
},
|
||||
|
||||
{
|
||||
50,
|
||||
80, // min/max alpha
|
||||
128,
|
||||
flScale/2,// min/max size
|
||||
flScale,
|
||||
30, // min/max velocity
|
||||
60
|
||||
}
|
||||
};
|
||||
|
||||
CHitEffectRamp interpolatedRamp;
|
||||
InterpolateRamp(
|
||||
ramps[0],
|
||||
ramps[1],
|
||||
interpolatedRamp,
|
||||
iDamage );
|
||||
|
||||
for ( int i = 0; i < 6; i++ )
|
||||
{
|
||||
// Originate from within a circle '2 * scale' inches in diameter.
|
||||
Vector offset = vEntryPoint + ( flScale * vSprayNormal * 0.5 );
|
||||
offset += right * random->RandomFloat( -1, 1 ) * flScale;
|
||||
offset += up * random->RandomFloat( -1, 1 ) * flScale;
|
||||
|
||||
pParticle = pEmitter->AddSimpleParticle( hMaterial, offset, 0, 0 );
|
||||
|
||||
if ( pParticle != NULL )
|
||||
{
|
||||
pParticle->m_flLifetime = 0.0f;
|
||||
pParticle->m_flDieTime = random->RandomFloat( 0.7f, 1.3f);
|
||||
|
||||
// All the particles are between red and white. The whiter the particle is, the slower it goes.
|
||||
float whiteness = random->RandomFloat( 0.1, 0.7 );
|
||||
float speedFactor = 1 - whiteness;
|
||||
|
||||
float spread = 0.5f;
|
||||
pParticle->m_vecVelocity.Random( -spread, spread );
|
||||
pParticle->m_vecVelocity += vSprayNormal * random->RandomInt( interpolatedRamp.m_flMinVelocity, interpolatedRamp.m_flMaxVelocity ) * flSpeed * speedFactor;
|
||||
|
||||
float colorRamp = random->RandomFloat( 0.5f, 0.75f ) + flLODDistance;
|
||||
|
||||
pParticle->m_uchColor[0] = MIN( 1.0f, color[0] * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[1] = MIN( 1.0f, whiteness * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[2] = MIN( 1.0f, whiteness * colorRamp ) * 255.0f;
|
||||
|
||||
pParticle->m_uchStartSize = random->RandomFloat( interpolatedRamp.m_flMinSize, interpolatedRamp.m_flMaxSize ) * flDistanceScale;
|
||||
pParticle->m_uchEndSize = pParticle->m_uchStartSize * 4 * flDistanceScale;
|
||||
|
||||
pParticle->m_uchStartAlpha = random->RandomInt( interpolatedRamp.m_flMinAlpha, interpolatedRamp.m_flMaxAlpha );
|
||||
pParticle->m_uchEndAlpha = 0;
|
||||
|
||||
pParticle->m_flRoll = random->RandomInt( 0, 360 );
|
||||
pParticle->m_flRollDelta = random->RandomFloat( -4.0f, 4.0f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FX_HitEffectBloodSplatter(
|
||||
CSmartPtr<CBloodSprayEmitter> pTrailEmitter,
|
||||
int iDamage,
|
||||
const Vector &vExitPoint,
|
||||
const Vector &vSplatterNormal,
|
||||
float flLODDistance )
|
||||
{
|
||||
float flScale = 4;
|
||||
|
||||
pTrailEmitter->SetSortOrigin( vExitPoint );
|
||||
PMaterialHandle hMaterial = ParticleMgr()->GetPMaterial( "effects/blood_drop" );
|
||||
|
||||
Vector up( 0, 0, 1 );
|
||||
Vector right = up.Cross( vSplatterNormal );
|
||||
VectorNormalize( right );
|
||||
|
||||
// These parameters create a ramp based on how much damage the shot did.
|
||||
CHitEffectRamp ramps[2] =
|
||||
{
|
||||
{
|
||||
0,
|
||||
0, // min/max alpha
|
||||
75,
|
||||
1.5f, // min/max size
|
||||
2.0f,
|
||||
25.0f * flScale, // min/max velocity
|
||||
35.0f * flScale
|
||||
},
|
||||
|
||||
{
|
||||
50,
|
||||
0, // min/max alpha
|
||||
140,
|
||||
1.5f,// min/max size
|
||||
2.0f,
|
||||
65.0f * flScale, // min/max velocity
|
||||
75.0f * flScale
|
||||
}
|
||||
};
|
||||
|
||||
CHitEffectRamp interpolatedRamp;
|
||||
InterpolateRamp(
|
||||
ramps[0],
|
||||
ramps[1],
|
||||
interpolatedRamp,
|
||||
iDamage );
|
||||
|
||||
|
||||
for ( int i = 0; i < 20; i++ )
|
||||
{
|
||||
// Originate from within a circle 'scale' inches in diameter.
|
||||
Vector offset = vExitPoint;
|
||||
offset += right * random->RandomFloat( -0.15f, 0.15f ) * flScale;
|
||||
offset += up * random->RandomFloat( -0.15f, 0.15f ) * flScale;
|
||||
|
||||
SimpleParticle *tParticle = (SimpleParticle*)pTrailEmitter->AddSimpleParticle(
|
||||
hMaterial,
|
||||
vExitPoint,
|
||||
random->RandomFloat( 0.225f, 0.35f ),
|
||||
random->RandomFloat( interpolatedRamp.m_flMinSize, interpolatedRamp.m_flMaxSize )
|
||||
);
|
||||
|
||||
if ( tParticle == NULL )
|
||||
break;
|
||||
|
||||
Vector offDir = vSplatterNormal + RandomVector( -0.05f, 0.05f );
|
||||
|
||||
tParticle->m_vecVelocity = offDir * random->RandomFloat( interpolatedRamp.m_flMinVelocity, interpolatedRamp.m_flMaxVelocity );
|
||||
|
||||
tParticle->m_iFlags = SIMPLE_PARTICLE_FLAG_NO_VEL_DECAY;
|
||||
tParticle->m_uchColor[0] = 150;
|
||||
tParticle->m_uchColor[1] = 0;
|
||||
tParticle->m_uchColor[2] = 0;
|
||||
tParticle->m_uchStartAlpha = interpolatedRamp.m_flMaxAlpha / 2;
|
||||
tParticle->m_uchEndAlpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : origin -
|
||||
// normal -
|
||||
// scale -
|
||||
//-----------------------------------------------------------------------------
|
||||
void FX_CS_BloodSpray( const Vector &origin, const Vector &normal, float flDamage )
|
||||
{
|
||||
if ( UTIL_IsLowViolence() )
|
||||
return;
|
||||
|
||||
static ConVar *violence_hblood = cvar->FindVar( "violence_hblood" );
|
||||
if ( violence_hblood && !violence_hblood->GetBool() )
|
||||
return;
|
||||
|
||||
Vector offset;
|
||||
int i;
|
||||
|
||||
float r = 64;
|
||||
float g = 0;
|
||||
float b = 4;
|
||||
|
||||
float scale = 0.5 + clamp( flDamage/50.f, 0.0, 1.0 ) ;
|
||||
|
||||
//Find area ambient light color and use it to tint smoke
|
||||
Vector worldLight = WorldGetLightForPoint( origin, true );
|
||||
Vector color = Vector( (float)(worldLight[0] * r) / 255.0f, (float)(worldLight[1] * g) / 255.0f, (float)(worldLight[2] * b) / 255.0f );
|
||||
float colorRamp;
|
||||
|
||||
Vector offDir;
|
||||
|
||||
CSmartPtr<CBloodSprayEmitter> pSimple = CBloodSprayEmitter::Create( "bloodgore" );
|
||||
if ( !pSimple )
|
||||
return;
|
||||
|
||||
pSimple->SetSortOrigin( origin );
|
||||
pSimple->SetGravity( 0 );
|
||||
|
||||
// Blood impact
|
||||
PMaterialHandle hMaterial = ParticleMgr()->GetPMaterial( "effects/blood_core" );
|
||||
|
||||
SimpleParticle *pParticle;
|
||||
|
||||
Vector dir = normal * RandomVector( -0.5f, 0.5f );
|
||||
|
||||
offset = origin + ( 2.0f * normal );
|
||||
|
||||
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), hMaterial, offset );
|
||||
|
||||
if ( pParticle != NULL )
|
||||
{
|
||||
pParticle->m_flLifetime = 0.0f;
|
||||
pParticle->m_flDieTime = 0.75f;
|
||||
|
||||
pParticle->m_vecVelocity = dir * random->RandomFloat( 16.0f, 32.0f );
|
||||
pParticle->m_vecVelocity[2] -= random->RandomFloat( 8.0f, 16.0f );
|
||||
|
||||
colorRamp = random->RandomFloat( 0.75f, 2.0f );
|
||||
|
||||
pParticle->m_uchColor[0] = MIN( 1.0f, color[0] * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[1] = MIN( 1.0f, color[1] * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[2] = MIN( 1.0f, color[2] * colorRamp ) * 255.0f;
|
||||
|
||||
pParticle->m_uchStartSize = 8;
|
||||
pParticle->m_uchEndSize = 32;
|
||||
|
||||
pParticle->m_uchStartAlpha = 255;
|
||||
pParticle->m_uchEndAlpha = 0;
|
||||
|
||||
pParticle->m_flRoll = random->RandomInt( 0, 360 );
|
||||
pParticle->m_flRollDelta = 0;
|
||||
}
|
||||
|
||||
hMaterial = ParticleMgr()->GetPMaterial( "effects/blood_gore" );
|
||||
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
offset = origin + ( 2.0f * normal );
|
||||
|
||||
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), hMaterial, offset );
|
||||
|
||||
if ( pParticle != NULL )
|
||||
{
|
||||
pParticle->m_flLifetime = 0.0f;
|
||||
pParticle->m_flDieTime = random->RandomFloat( 0.75f, 1.0f);
|
||||
|
||||
pParticle->m_vecVelocity = dir * random->RandomFloat( 16.0f, 32.0f )*(i+1);
|
||||
pParticle->m_vecVelocity[2] -= random->RandomFloat( 16.0f, 32.0f )*(i+1);
|
||||
|
||||
colorRamp = random->RandomFloat( 0.75f, 2.0f );
|
||||
|
||||
pParticle->m_uchColor[0] = MIN( 1.0f, color[0] * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[1] = MIN( 1.0f, color[1] * colorRamp ) * 255.0f;
|
||||
pParticle->m_uchColor[2] = MIN( 1.0f, color[2] * colorRamp ) * 255.0f;
|
||||
|
||||
pParticle->m_uchStartSize = scale * random->RandomInt( 4, 8 );
|
||||
pParticle->m_uchEndSize = pParticle->m_uchStartSize * 4;
|
||||
|
||||
pParticle->m_uchStartAlpha = 255;
|
||||
pParticle->m_uchEndAlpha = 0;
|
||||
|
||||
pParticle->m_flRoll = random->RandomInt( 0, 360 );
|
||||
pParticle->m_flRollDelta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Dump out drops
|
||||
//
|
||||
TrailParticle *tParticle;
|
||||
|
||||
CSmartPtr<CTrailParticles> pTrailEmitter = CTrailParticles::Create( "blooddrops" );
|
||||
if ( !pTrailEmitter )
|
||||
return;
|
||||
|
||||
pTrailEmitter->SetSortOrigin( origin );
|
||||
|
||||
// Partial gravity on blood drops
|
||||
pTrailEmitter->SetGravity( 400.0 );
|
||||
|
||||
// Enable simple collisions with nearby surfaces
|
||||
pTrailEmitter->Setup(origin, &normal, 1, 10, 100, 400, 0.2, 0 );
|
||||
|
||||
hMaterial = ParticleMgr()->GetPMaterial( "effects/blood_drop" );
|
||||
|
||||
//
|
||||
// Shorter droplets
|
||||
//
|
||||
for ( i = 0; i < 32; i++ )
|
||||
{
|
||||
// Originate from within a circle 'scale' inches in diameter
|
||||
offset = origin;
|
||||
|
||||
tParticle = (TrailParticle *) pTrailEmitter->AddParticle( sizeof(TrailParticle), hMaterial, offset );
|
||||
|
||||
if ( tParticle == NULL )
|
||||
break;
|
||||
|
||||
tParticle->m_flLifetime = 0.0f;
|
||||
|
||||
offDir = RandomVector( -1.0f, 1.0f );
|
||||
|
||||
tParticle->m_vecVelocity = offDir * random->RandomFloat( 32.0f, 128.0f );
|
||||
|
||||
tParticle->m_flWidth = scale * random->RandomFloat( 1.0f, 3.0f );
|
||||
tParticle->m_flLength = random->RandomFloat( 0.1f, 0.15f );
|
||||
tParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
|
||||
|
||||
FloatToColor32( tParticle->m_color, color[0], color[1], color[2], 1.0f );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : bloodtype -
|
||||
// r -
|
||||
// g -
|
||||
// b -
|
||||
//-----------------------------------------------------------------------------
|
||||
void GetBloodColorForTeam( int iTeam, unsigned char &r, unsigned char &g, unsigned char &b )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Intercepts the blood spray message.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSBloodSprayCallback( const CEffectData &data )
|
||||
{
|
||||
FX_CS_BloodSpray( data.m_vOrigin, data.m_vNormal, data.m_flMagnitude );
|
||||
}
|
||||
|
||||
DECLARE_CLIENT_EFFECT( "csblood", CSBloodSprayCallback );
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user