initial
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
//========= Copyright © 1996-2012, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side interactive, shootable chicken
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_chicken.h"
|
||||
#include "c_breakableprop.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#undef CChicken
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_CChicken, DT_CChicken, CChicken )
|
||||
RecvPropInt( RECVINFO( m_jumpedThisFrame ), 0, C_CChicken::RecvProxy_Jumped ),
|
||||
RecvPropEHandle( RECVINFO( m_leader ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
C_CChicken::C_CChicken()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
C_CChicken::~C_CChicken()
|
||||
{
|
||||
SetClientSideHolidayHatAddon( false );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void C_CChicken::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
|
||||
SetClientSideHolidayHatAddon( false );
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CChicken::RecvProxy_Jumped( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
// C_CHostage *pHostage = ( C_CHostage * ) pStruct;
|
||||
//
|
||||
// bool jumped = pData->m_Value.m_Int != 0;
|
||||
//
|
||||
// if ( jumped )
|
||||
// {
|
||||
// // hostage jumped
|
||||
// pHostage->m_PlayerAnimState->DoAnimationEvent( PLAYERANIMEVENT_JUMP );
|
||||
// pHostage->SetNextClientThink( gpGlobals->curtime );
|
||||
// }
|
||||
//
|
||||
// pHostage->m_jumpedThisFrame = jumped;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void C_CChicken::ClientThink()
|
||||
{
|
||||
BaseClass::ClientThink();
|
||||
|
||||
Activity currentActivity = GetSequenceActivity( GetSequence() );
|
||||
if ( m_lastActivity != currentActivity )
|
||||
{
|
||||
if ( currentActivity == ACT_CLIMB_UP )
|
||||
SetCycle( 0 );
|
||||
m_lastActivity = currentActivity;
|
||||
}
|
||||
|
||||
bool bEnableHolidayHat = false;
|
||||
|
||||
#if CSGO_CLIENT_CHICKEN_ANTLERS_IN_FREEZE_CAM
|
||||
//
|
||||
// This code was enabling chicken antlers in freezecam
|
||||
//
|
||||
|
||||
// Client-side only addons are required for the duration of the freeze shot
|
||||
{
|
||||
static ConVarRef ref_cl_disablefreezecam( "cl_disablefreezecam" );
|
||||
static ConVarRef ref_sv_disablefreezecam( "sv_disablefreezecam" );
|
||||
extern bool IsTakingAFreezecamScreenshot( void );
|
||||
if ( IsTakingAFreezecamScreenshot() && !ref_cl_disablefreezecam.GetBool() && !ref_sv_disablefreezecam.GetBool() )
|
||||
{
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( pLocalPlayer && pLocalPlayer->GetObserverTarget() && ( pLocalPlayer->GetObserverTarget() != pLocalPlayer ) )
|
||||
{
|
||||
bEnableHolidayHat = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SetClientSideHolidayHatAddon( bEnableHolidayHat );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CChicken::SetClientSideHolidayHatAddon( bool bEnable )
|
||||
{
|
||||
/*
|
||||
if ( bEnable && !m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
// Create the hat
|
||||
C_BreakableProp *pEnt = new C_BreakableProp;
|
||||
pEnt->InitializeAsClientEntity( "models/antlers/antlers.mdl", false );
|
||||
pEnt->FollowEntity( this );
|
||||
pEnt->SetLocalOrigin( Vector( 0, 0, 0 ) );
|
||||
pEnt->SetLocalAngles( QAngle( 0, 0, 0 ) );
|
||||
pEnt->SetUseParentLightingOrigin( true );// This will make it so the weapons get lit with the same ambient cube that the player gets lit with.
|
||||
m_hHolidayHatAddon.Set( pEnt );
|
||||
}
|
||||
if ( !bEnable && m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
// Remove the hat
|
||||
m_hHolidayHatAddon->Release();
|
||||
m_hHolidayHatAddon.Term();
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//========= Copyright © 1996-2012, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side interactive, shootable chicken
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#ifndef C_CHICKEN_H
|
||||
#define C_CHICKEN_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_props.h"
|
||||
|
||||
#define CChicken C_CChicken
|
||||
|
||||
class C_CChicken : public C_DynamicProp
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_CChicken, C_DynamicProp );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_CChicken();
|
||||
virtual ~C_CChicken();
|
||||
|
||||
private:
|
||||
C_CChicken( const C_CChicken& ); // not defined, not accessible
|
||||
|
||||
public:
|
||||
void SetClientSideHolidayHatAddon( bool bEnable );
|
||||
|
||||
public:
|
||||
virtual void Spawn();
|
||||
|
||||
static void RecvProxy_Jumped( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
virtual void ClientThink( );
|
||||
|
||||
private:
|
||||
CHandle<C_BaseAnimating> m_hHolidayHatAddon;
|
||||
Activity m_lastActivity;
|
||||
|
||||
CNetworkVar( bool, m_jumpedThisFrame );
|
||||
CNetworkVar( EHANDLE, m_leader ); // who we are following, or NULL
|
||||
|
||||
};
|
||||
|
||||
#endif // C_CHICKEN_H
|
||||
@@ -0,0 +1,632 @@
|
||||
// ClientInferno.cpp
|
||||
// Render client-side Inferno effects
|
||||
// Author: Michael Booth, February 2005
|
||||
// Copyright (c) 2005 Turtle Rock Studios, Inc. - All Rights Reserved
|
||||
|
||||
#include "cbase.h"
|
||||
#include "igamesystem.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
#include "enginesprite.h"
|
||||
#include "precache_register.h"
|
||||
#include "iefx.h"
|
||||
#include "dlight.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "debugoverlay_shared.h"
|
||||
#include "basecsgrenade_projectile.h"
|
||||
#include "clientinferno.h"
|
||||
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
PRECACHE_REGISTER_BEGIN( GLOBAL, InfernoMaterials )
|
||||
PRECACHE( MATERIAL, "sprites/white" )
|
||||
PRECACHE_REGISTER_END()
|
||||
|
||||
ConVar InfernoDlightSpacing( "inferno_dlight_spacing", "200", FCVAR_CHEAT, "Inferno dlights are at least this far apart" );
|
||||
ConVar InfernoDlights( "inferno_dlights", "30", 0, "Min FPS at which molotov dlights will be created" );
|
||||
//ConVar InfernoParticles( "inferno_particles", "molotov_groundfire", FCVAR_REPLICATED | FCVAR_CHEAT );
|
||||
ConVar InfernoFire( "inferno_fire", "2" );
|
||||
enum FireMaskType
|
||||
{
|
||||
OLD_FIRE_MASK = 1,
|
||||
NEW_FIRE_MASK = 2
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_Inferno, DT_Inferno, CInferno )
|
||||
RecvPropArray3( RECVINFO_ARRAY( m_fireXDelta ), RecvPropInt( RECVINFO(m_fireXDelta[0] ) ) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY( m_fireYDelta ), RecvPropInt( RECVINFO(m_fireYDelta[0] ) ) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY( m_fireZDelta ), RecvPropInt( RECVINFO(m_fireZDelta[0] ) ) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY( m_bFireIsBurning ), RecvPropBool( RECVINFO(m_bFireIsBurning[0] ) ) ),
|
||||
//RecvPropArray3( RECVINFO_ARRAY( m_BurnNormal ), RecvPropVector( RECVINFO(m_BurnNormal[0] ) ) ),
|
||||
RecvPropInt( RECVINFO( m_fireCount ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
C_Inferno::C_Inferno()
|
||||
{
|
||||
m_maxFireHalfWidth = 30.0f;
|
||||
m_maxFireHeight = 80.0f;
|
||||
m_burnParticleEffect = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
C_Inferno::~C_Inferno()
|
||||
{
|
||||
if ( m_burnParticleEffect.IsValid() )
|
||||
{
|
||||
m_burnParticleEffect->StopEmission();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void C_Inferno::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
|
||||
|
||||
m_fireCount = 0;
|
||||
m_lastFireCount = 0;
|
||||
|
||||
m_drawableCount = 0;
|
||||
m_burnParticleEffect = NULL;
|
||||
|
||||
m_minBounds = Vector( 0, 0, 0 );
|
||||
m_maxBounds = Vector( 0, 0, 0 );
|
||||
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Monitor changes and recompute render bounds
|
||||
*/
|
||||
void C_Inferno::ClientThink()
|
||||
{
|
||||
VPROF_BUDGET( "C_Inferno::ClientThink", "Magic" );
|
||||
|
||||
bool bIsAttachedToMovingObject = (GetMoveParent() != NULL) ? true : false;
|
||||
|
||||
if (true || m_lastFireCount != m_fireCount || bIsAttachedToMovingObject )
|
||||
{
|
||||
SynchronizeDrawables();
|
||||
m_lastFireCount = m_fireCount;
|
||||
}
|
||||
|
||||
bool bDidRecomputeBounds = false;
|
||||
|
||||
// update Drawables
|
||||
for( int i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
Drawable *draw = &m_drawable[i];
|
||||
|
||||
switch( draw->m_state )
|
||||
{
|
||||
case STARTING:
|
||||
{
|
||||
float growRate = draw->m_maxSize/2.0f;
|
||||
draw->m_size = growRate * (gpGlobals->realtime - draw->m_stateTimestamp);
|
||||
if (draw->m_size > draw->m_maxSize)
|
||||
{
|
||||
draw->m_size = draw->m_maxSize;
|
||||
draw->SetState( BURNING );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GOING_OUT:
|
||||
{
|
||||
float dieRate = draw->m_maxSize/2.0f;
|
||||
draw->m_size = draw->m_maxSize - dieRate * (gpGlobals->realtime - draw->m_stateTimestamp);
|
||||
if (draw->m_size <= 0.0f)
|
||||
{
|
||||
draw->SetState( FIRE_OUT );
|
||||
|
||||
// render bounds changed
|
||||
RecomputeBounds();
|
||||
bDidRecomputeBounds = true;
|
||||
if ( GetRenderHandle() != INVALID_CLIENT_RENDER_HANDLE )
|
||||
{
|
||||
ClientLeafSystem()->RenderableChanged( GetRenderHandle() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( bIsAttachedToMovingObject && !bDidRecomputeBounds )
|
||||
{
|
||||
RecomputeBounds();
|
||||
}
|
||||
|
||||
UpdateParticles();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_Inferno::OnNewParticleEffect( const char *pszParticleName, CNewParticleEffect *pNewParticleEffect )
|
||||
{
|
||||
if ( FStrEq( pszParticleName, GetParticleEffectName() ) )
|
||||
{
|
||||
m_burnParticleEffect = pNewParticleEffect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_Inferno::OnParticleEffectDeleted( CNewParticleEffect *pParticleEffect )
|
||||
{
|
||||
if ( m_burnParticleEffect == pParticleEffect )
|
||||
{
|
||||
m_burnParticleEffect = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_Inferno::UpdateParticles( void )
|
||||
{
|
||||
if ( m_drawableCount > 0 && (InfernoFire.GetInt() & NEW_FIRE_MASK) != 0 )
|
||||
{
|
||||
if ( !m_burnParticleEffect.IsValid() )
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
m_burnParticleEffect = ParticleProp()->Create( GetParticleEffectName(), PATTACH_ABSORIGIN_FOLLOW );
|
||||
/*
|
||||
DevMsg( "inferno @ %f %f %f / %f %f %f\n",
|
||||
GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z,
|
||||
GetAbsAngles()[PITCH], GetAbsAngles()[YAW], GetAbsAngles()[ROLL] );
|
||||
NDebugOverlay::Cross3D( GetAbsOrigin(), 5, 255, 0, 0, false, 30.0f );
|
||||
NDebugOverlay::Cross3D( GetAbsOrigin(), 5, 128, 0, 0, true, 30.0f );
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i=0; i<m_drawableCount && i<MAX_PARTICLE_CONTROL_POINTS; ++i )
|
||||
{
|
||||
Drawable *draw = &m_drawable[i];
|
||||
// TODO: need a way to disable a control point!!!
|
||||
if ( draw->m_state >= FIRE_OUT )
|
||||
{
|
||||
Vector vecCenter = draw->m_pos;
|
||||
//VectorLerp( m_minBounds, m_maxBounds, 0.5f, vecCenter );
|
||||
draw->m_pos = vecCenter + Vector( 0, 0, -9999 );
|
||||
draw->m_size = 0;
|
||||
// this sucks
|
||||
if ( i != 0 )
|
||||
m_burnParticleEffect->SetControlPoint( i, vec3_invalid );
|
||||
|
||||
//engine->Con_NPrintf( i + 10, "0 0 0" );
|
||||
|
||||
//NDebugOverlay::Cross3D( draw->m_pos, 5, 0, 0, 255, false, 5.1f );
|
||||
}
|
||||
else
|
||||
{
|
||||
//NDebugOverlay::Cross3D( draw->m_pos, 5, 0, 0, 255, false, 0.1f );
|
||||
//NDebugOverlay::Line( GetAbsOrigin(), draw->m_pos, 0, 255, 0, true, 0.1f );
|
||||
m_burnParticleEffect->SetControlPointEntity( i, NULL );
|
||||
m_burnParticleEffect->SetControlPoint( i, draw->m_pos );
|
||||
|
||||
// FIXME - Set orientation to burn normal once we have per particle normals.
|
||||
//m_burnParticleEffect->SetControlPointOrientation( i, Orientation );
|
||||
|
||||
if ( i % 2 == 0 )
|
||||
{
|
||||
//Elight, for perf reasons only for every other fire
|
||||
dlight_t *el = effects->CL_AllocElight( draw->m_dlightIndex );
|
||||
el->origin = draw->m_pos;
|
||||
el->origin[2] += 64;
|
||||
el->color.r = 254;
|
||||
el->color.g = 100;
|
||||
el->color.b = 10;
|
||||
el->radius = random->RandomFloat(60, 120);
|
||||
el->die = gpGlobals->curtime + random->RandomFloat( 0.01, 0.025 );
|
||||
el->color.exponent = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetNextClientThink( 0.1f );
|
||||
m_burnParticleEffect->SetNeedsBBoxUpdate( true );
|
||||
|
||||
Vector vecCenter = GetRenderOrigin();
|
||||
m_burnParticleEffect->SetSortOrigin( vecCenter );
|
||||
|
||||
//NDebugOverlay::Cross3D( vecCenter, 5, 255, 0, 255, false, 0.5f );
|
||||
Vector vecMin, vecMax;
|
||||
GetRenderBounds( vecMin, vecMax );
|
||||
//NDebugOverlay::Box( vecCenter, vecMin, vecMax, 255, 0, 255, 255, 0.5 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_burnParticleEffect.IsValid() )
|
||||
{
|
||||
m_burnParticleEffect->StopEmission();
|
||||
// m_burnParticleEffect->SetRemoveFlag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void C_Inferno::GetRenderBounds( Vector& mins, Vector& maxs )
|
||||
{
|
||||
if (m_drawableCount)
|
||||
{
|
||||
mins = m_minBounds - GetRenderOrigin();
|
||||
maxs = m_maxBounds - GetRenderOrigin();
|
||||
}
|
||||
else
|
||||
{
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the bounds as an AABB in worldspace
|
||||
*/
|
||||
void C_Inferno::GetRenderBoundsWorldspace( Vector& mins, Vector& maxs )
|
||||
{
|
||||
if (m_drawableCount)
|
||||
{
|
||||
mins = m_minBounds;
|
||||
maxs = m_maxBounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void C_Inferno::RecomputeBounds( void )
|
||||
{
|
||||
m_minBounds = GetAbsOrigin() + Vector( 64.9f, 64.9f, 64.9f );
|
||||
m_maxBounds = GetAbsOrigin() + Vector( -64.9f, -64.9f, -64.9f );
|
||||
|
||||
for( int i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
Drawable *draw = &m_drawable[i];
|
||||
|
||||
if (draw->m_state == FIRE_OUT)
|
||||
continue;
|
||||
|
||||
if (draw->m_pos.x - m_maxFireHalfWidth < m_minBounds.x)
|
||||
m_minBounds.x = draw->m_pos.x - m_maxFireHalfWidth;
|
||||
|
||||
if (draw->m_pos.x + m_maxFireHalfWidth > m_maxBounds.x)
|
||||
m_maxBounds.x = draw->m_pos.x + m_maxFireHalfWidth;
|
||||
|
||||
if (draw->m_pos.y - m_maxFireHalfWidth < m_minBounds.y)
|
||||
m_minBounds.y = draw->m_pos.y - m_maxFireHalfWidth;
|
||||
|
||||
if (draw->m_pos.y + m_maxFireHalfWidth > m_maxBounds.y)
|
||||
m_maxBounds.y = draw->m_pos.y + m_maxFireHalfWidth;
|
||||
|
||||
if (draw->m_pos.z < m_minBounds.z)
|
||||
m_minBounds.z = draw->m_pos.z;
|
||||
|
||||
if (draw->m_pos.z + m_maxFireHeight > m_maxBounds.z)
|
||||
m_maxBounds.z = draw->m_pos.z + m_maxFireHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Given a position, return the fire there
|
||||
*/
|
||||
C_Inferno::Drawable *C_Inferno::GetDrawable( const Vector &pos )
|
||||
{
|
||||
for( int i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
const float equalTolerance = 12.0f;
|
||||
if (VectorsAreEqual( m_drawable[i].m_pos, pos, equalTolerance ))
|
||||
{
|
||||
m_drawable[ i ].m_pos = pos;
|
||||
return &m_drawable[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Compare m_fireX etc to m_drawable and update states
|
||||
*/
|
||||
void C_Inferno::SynchronizeDrawables( void )
|
||||
{
|
||||
VPROF_BUDGET( "C_Inferno::SynchronizeDrawables", "Magic" );
|
||||
|
||||
int i;
|
||||
|
||||
// mark all fires that are "burning" as "unknown" - active ones will be reset
|
||||
for( i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
if (m_drawable[i].m_state == BURNING)
|
||||
{
|
||||
m_drawable[i].m_state = UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
Vector vInfernoOrigin = GetAbsOrigin();
|
||||
|
||||
for( i=0; i<m_fireCount; ++i )
|
||||
{
|
||||
Vector firePos = vInfernoOrigin;
|
||||
|
||||
Vector vecFlamePos = Vector( m_fireXDelta[ i ], m_fireYDelta[ i ], m_fireZDelta[ i ] );
|
||||
|
||||
firePos.x += vecFlamePos.x;
|
||||
firePos.y += vecFlamePos.y;
|
||||
firePos.z += vecFlamePos.z;
|
||||
|
||||
Vector fireNormal = m_BurnNormal[i];
|
||||
Drawable *info = GetDrawable( firePos );
|
||||
|
||||
if ( m_bFireIsBurning[i] == false )
|
||||
{
|
||||
if ( info && info->m_state != FIRE_OUT )
|
||||
{
|
||||
info->m_state = FIRE_OUT;
|
||||
|
||||
// render bounds changed
|
||||
RecomputeBounds();
|
||||
if ( GetRenderHandle() != INVALID_CLIENT_RENDER_HANDLE )
|
||||
{
|
||||
ClientLeafSystem()->RenderableChanged( GetRenderHandle() );
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( info )
|
||||
{
|
||||
// existing fire continues to burn
|
||||
if (info->m_state == UNKNOWN)
|
||||
{
|
||||
info->m_state = BURNING;
|
||||
}
|
||||
}
|
||||
else if (m_drawableCount < MAX_INFERNO_FIRES)
|
||||
{
|
||||
// new fire
|
||||
info = &m_drawable[ m_drawableCount ];
|
||||
|
||||
info->SetState( STARTING );
|
||||
info->m_pos = firePos;
|
||||
info->m_normal = fireNormal;
|
||||
info->m_frame = 0;
|
||||
info->m_framerate = random->RandomFloat( 0.04f, 0.06f );
|
||||
info->m_mirror = (random->RandomInt( 0, 100 ) < 50);
|
||||
info->m_size = 0.0f;
|
||||
info->m_maxSize = random->RandomFloat( 70.0f, 90.0f );
|
||||
|
||||
bool closeDlight = false;
|
||||
for ( int i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
if ( m_drawable[i].m_state != FIRE_OUT )
|
||||
{
|
||||
if ( m_drawable[i].m_dlightIndex > 0 )
|
||||
{
|
||||
if ( m_drawable[i].m_pos.DistToSqr( firePos ) < InfernoDlightSpacing.GetFloat() * InfernoDlightSpacing.GetFloat() )
|
||||
{
|
||||
closeDlight = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( closeDlight )
|
||||
{
|
||||
info->m_dlightIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->m_dlightIndex = LIGHT_INDEX_TE_DYNAMIC + index + m_drawableCount;
|
||||
}
|
||||
|
||||
// render bounds changed
|
||||
RecomputeBounds();
|
||||
if ( GetRenderHandle() != INVALID_CLIENT_RENDER_HANDLE )
|
||||
{
|
||||
ClientLeafSystem()->RenderableChanged( GetRenderHandle() );
|
||||
}
|
||||
|
||||
++m_drawableCount;
|
||||
}
|
||||
}
|
||||
|
||||
// any fires still in the UNKNOWN state are now GOING_OUT
|
||||
for( i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
if (m_drawable[i].m_state == UNKNOWN)
|
||||
{
|
||||
m_drawable[i].SetState( GOING_OUT );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
int C_Inferno::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
VPROF_BUDGET( "C_Inferno::DrawModel", "DeadRun" );
|
||||
|
||||
IMaterial *material;
|
||||
CEngineSprite *sprite;
|
||||
const model_t *model;
|
||||
|
||||
if ( (InfernoFire.GetInt() & OLD_FIRE_MASK) == 0 )
|
||||
return 0;
|
||||
|
||||
model = modelinfo->GetModel( modelinfo->GetModelIndex( "sprites/fire1.vmt" ) );
|
||||
if (model == NULL)
|
||||
return 0;
|
||||
|
||||
sprite = (CEngineSprite *)modelinfo->GetModelExtraData( model );
|
||||
if (sprite == NULL)
|
||||
return 0;
|
||||
|
||||
material = sprite->GetMaterial( kRenderTransAdd );
|
||||
if (material == NULL)
|
||||
return 0;
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
pRenderContext->Bind( material );
|
||||
IMesh *pMesh = pRenderContext->GetDynamicMesh();
|
||||
if ( pMesh )
|
||||
{
|
||||
// draw the actual flames
|
||||
for( int i=0; i<m_drawableCount; ++i )
|
||||
{
|
||||
int frame = (int)(gpGlobals->realtime/m_drawable[i].m_framerate) % sprite->GetNumFrames();
|
||||
sprite->SetFrame( kRenderTransAdd, frame );
|
||||
|
||||
DrawFire( &m_drawable[i], pMesh );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Render an individual fire sprite
|
||||
*/
|
||||
void C_Inferno::DrawFire( C_Inferno::Drawable *fire, IMesh *mesh )
|
||||
{
|
||||
const float halfWidth = fire->m_size/3.0f;
|
||||
//unsigned char color[4] = { 255,255,255,255 };
|
||||
unsigned char color[4] = { 150,150,150,255 };
|
||||
|
||||
CMeshBuilder meshBuilder;
|
||||
meshBuilder.Begin( mesh, MATERIAL_QUADS, 1 );
|
||||
|
||||
const Vector &right = (fire->m_mirror) ? -CurrentViewRight() : CurrentViewRight();
|
||||
Vector up( 0.0f, 0.0f, 1.0f );
|
||||
Vector top = fire->m_pos + up * fire->m_size;
|
||||
const Vector &bottom = fire->m_pos;
|
||||
|
||||
Vector pos = top + right * halfWidth;
|
||||
|
||||
meshBuilder.Position3fv( pos.Base() );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, 1, 0 );
|
||||
meshBuilder.AdvanceVertex();
|
||||
|
||||
pos = bottom + right * halfWidth;
|
||||
|
||||
meshBuilder.Position3fv( pos.Base() );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, 1, 1 );
|
||||
meshBuilder.AdvanceVertex();
|
||||
|
||||
pos = bottom - right * halfWidth;
|
||||
|
||||
meshBuilder.Position3fv( pos.Base() );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, 0, 1 );
|
||||
meshBuilder.AdvanceVertex();
|
||||
|
||||
pos = top - right * halfWidth;
|
||||
|
||||
meshBuilder.Position3fv( pos.Base() );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, 0, 0 );
|
||||
meshBuilder.AdvanceVertex();
|
||||
|
||||
meshBuilder.End();
|
||||
mesh->Draw();
|
||||
|
||||
if ( fire->m_dlightIndex > 0 && InfernoDlights.GetFloat() >= 1 )
|
||||
{
|
||||
static float lastRealTime = -1.0f;
|
||||
float realFrameTime = gpGlobals->realtime - lastRealTime;
|
||||
if ( realFrameTime > 2 )
|
||||
{
|
||||
realFrameTime = -1.0f;
|
||||
}
|
||||
if ( realFrameTime > 0 )
|
||||
{
|
||||
static float AverageFPS = -1;
|
||||
static int high = -1;
|
||||
static int low = -1;
|
||||
int nFps = -1;
|
||||
|
||||
const float NewWeight = 0.1f;
|
||||
float NewFrame = 1.0f / realFrameTime;
|
||||
|
||||
if ( AverageFPS < 0.0f )
|
||||
{
|
||||
|
||||
AverageFPS = NewFrame;
|
||||
high = (int)AverageFPS;
|
||||
low = (int)AverageFPS;
|
||||
}
|
||||
else
|
||||
{
|
||||
AverageFPS *= ( 1.0f - NewWeight ) ;
|
||||
AverageFPS += ( ( NewFrame ) * NewWeight );
|
||||
}
|
||||
|
||||
int NewFrameInt = (int)NewFrame;
|
||||
if( NewFrameInt < low ) low = NewFrameInt;
|
||||
if( NewFrameInt > high ) high = NewFrameInt;
|
||||
|
||||
nFps = static_cast<int>( AverageFPS );
|
||||
if ( nFps < InfernoDlights.GetFloat() )
|
||||
{
|
||||
fire->m_dlightIndex = 0;
|
||||
lastRealTime = gpGlobals->realtime;
|
||||
return;
|
||||
}
|
||||
}
|
||||
lastRealTime = gpGlobals->realtime;
|
||||
|
||||
// These are the dlight params from the Ep1 fire glows, with a slightly larger flicker
|
||||
// (radius delta is larger, starting from 250 instead of 400).
|
||||
float scale = fire->m_size / fire->m_maxSize * 1.5f;
|
||||
|
||||
dlight_t *el = effects->CL_AllocElight( fire->m_dlightIndex );
|
||||
el->origin = bottom;
|
||||
el->origin[2] += 16.0f * scale;
|
||||
el->color.r = 254;
|
||||
el->color.g = 100;
|
||||
el->color.b = 10;
|
||||
el->radius = random->RandomFloat(50, 131) * scale;
|
||||
el->die = gpGlobals->curtime + 0.1f;
|
||||
el->color.exponent = 5;
|
||||
|
||||
|
||||
/*
|
||||
dlight_t *dl = effects->CL_AllocDlight ( fire->m_dlightIndex );
|
||||
dl->origin = bottom;
|
||||
dl->origin[2] += 16.0f * scale;
|
||||
dl->color.r = 254;
|
||||
dl->color.g = 174;
|
||||
dl->color.b = 10;
|
||||
dl->radius = random->RandomFloat(350,431) * scale;
|
||||
dl->die = gpGlobals->curtime + 0.1f;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_FireCrackerBlast, DT_FireCrackerBlast, CFireCrackerBlast )
|
||||
END_RECV_TABLE()
|
||||
@@ -0,0 +1,103 @@
|
||||
// ClientInferno.cpp
|
||||
// Render client-side Inferno effects
|
||||
// Author: Michael Booth, February 2005
|
||||
// Copyright (c) 2005 Turtle Rock Studios, Inc. - All Rights Reserved
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The client-side Inferno effect
|
||||
*/
|
||||
class C_Inferno : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_Inferno, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_Inferno();
|
||||
virtual ~C_Inferno();
|
||||
|
||||
virtual void Spawn( void );
|
||||
virtual void ClientThink();
|
||||
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
virtual bool ShouldDraw() { return true; }
|
||||
virtual RenderableTranslucencyType_t ComputeTranslucencyType() { return RENDERABLE_IS_TRANSLUCENT; }
|
||||
|
||||
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
|
||||
|
||||
// returns the bounds as an AABB in worldspace
|
||||
virtual void GetRenderBoundsWorldspace( Vector& mins, Vector& maxs );
|
||||
|
||||
virtual void OnNewParticleEffect( const char *pszParticleName, CNewParticleEffect *pNewParticleEffect );
|
||||
virtual void OnParticleEffectDeleted( CNewParticleEffect *pParticleEffect );
|
||||
|
||||
virtual const char* GetParticleEffectName();
|
||||
|
||||
private:
|
||||
void UpdateParticles( void );
|
||||
CUtlReference<CNewParticleEffect> m_burnParticleEffect;
|
||||
|
||||
enum { MAX_INFERNO_FIRES = 100 };
|
||||
int m_fireXDelta[ MAX_INFERNO_FIRES ];
|
||||
int m_fireYDelta[ MAX_INFERNO_FIRES ];
|
||||
int m_fireZDelta[ MAX_INFERNO_FIRES ];
|
||||
bool m_bFireIsBurning[ MAX_INFERNO_FIRES ];
|
||||
Vector m_BurnNormal[ MAX_INFERNO_FIRES ];
|
||||
int m_fireUniqueID[ MAX_INFERNO_FIRES ];
|
||||
int m_fireCount;
|
||||
int m_nInfernoType;
|
||||
int m_lastFireCount; ///< used to detect changes
|
||||
|
||||
// these are the actual visible fires
|
||||
enum FireState { STARTING, BURNING, GOING_OUT, FIRE_OUT, UNKNOWN };
|
||||
struct Drawable
|
||||
{
|
||||
Vector m_pos; ///< position of flame
|
||||
Vector m_normal; ///< normal of flame surface
|
||||
int m_frame; ///< current animation frame
|
||||
float m_framerate; ///< rate of animation
|
||||
bool m_mirror; ///< if true, flame is mirrored about vertical axis
|
||||
|
||||
int m_dlightIndex;
|
||||
|
||||
FireState m_state; ///< the state of this fire
|
||||
float m_stateTimestamp; ///< when the fire entered its current state
|
||||
void SetState( FireState state )
|
||||
{
|
||||
m_state = state;
|
||||
m_stateTimestamp = gpGlobals->realtime;
|
||||
}
|
||||
|
||||
float m_size; ///< current flame size
|
||||
float m_maxSize; ///< maximum size of full-grown flame
|
||||
|
||||
void Draw( void ); ///< render this flame
|
||||
};
|
||||
Drawable m_drawable[ MAX_INFERNO_FIRES ];
|
||||
int m_drawableCount;
|
||||
|
||||
void SynchronizeDrawables( void ); ///< compare m_fireX etc to m_drawable and update states
|
||||
Drawable *GetDrawable( const Vector &pos ); ///< given a position, return the fire there
|
||||
|
||||
float m_maxFireHalfWidth;
|
||||
float m_maxFireHeight;
|
||||
Vector m_minBounds, m_maxBounds;
|
||||
|
||||
void DrawFire( C_Inferno::Drawable *fire, IMesh *mesh ); ///< render an individual flame
|
||||
void RecomputeBounds( void );
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
//---------------------------------------------------------
|
||||
class C_FireCrackerBlast: public C_Inferno
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_FireCrackerBlast, C_Inferno );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual const char* GetParticleEffectName();
|
||||
};
|
||||
@@ -0,0 +1,338 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD element to show we are having connectivity trouble
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhud_autodisconnect.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "inetchannelinfo.h"
|
||||
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "cs_client_gamestats.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudAutodisconnect );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudAutodisconnect, Autodisconnect );
|
||||
|
||||
SFHudAutodisconnect::SFHudAutodisconnect( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_sfuiControlBg( NULL ), m_sfuiControlTopLabel( NULL ), m_sfuiControlBottomLabel( NULL ), m_sfuiControlTimerLabel( NULL ), m_sfuiControlTimerIcon( NULL )
|
||||
{
|
||||
// This HUD element should never be hidden, so do not call SetHiddenBits
|
||||
}
|
||||
|
||||
SFHudAutodisconnect::~SFHudAutodisconnect()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( bShow )
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowPanel", NULL, 0 );
|
||||
else
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConVar cl_connection_trouble_show( "cl_connection_trouble_show", "0", FCVAR_RELEASE, "Show connection trouble HUD warnings" );
|
||||
DEVELOPMENT_ONLY_CONVAR( cl_connection_trouble_force, 0 );
|
||||
static bool Helper_ShouldInformPlayerAboutConnectionLossChoke()
|
||||
{
|
||||
static ConVarRef cl_connection_trouble_info( "cl_connection_trouble_info" );
|
||||
if ( !cl_connection_trouble_info.IsValid() )
|
||||
return false;
|
||||
|
||||
// No error - nothing to show
|
||||
if ( !cl_connection_trouble_info.GetString()[ 0 ] )
|
||||
return false;
|
||||
|
||||
// Not a transient error - always show
|
||||
if ( cl_connection_trouble_info.GetString()[ 0 ] != '@' )
|
||||
return true;
|
||||
|
||||
// UI debugging feature
|
||||
if ( cl_connection_trouble_force.GetInt() == 1 ) // Allow to always show for testing
|
||||
return true;
|
||||
|
||||
// Don't care when playing demos or GOTV or on listen server
|
||||
if ( g_bEngineIsHLTV || engine->IsClientLocalToActiveServer() )
|
||||
return false;
|
||||
|
||||
// Not when loading
|
||||
if ( engine->IsDrawingLoadingImage() )
|
||||
return false;
|
||||
|
||||
// No local player - don't show
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pLocalPlayer )
|
||||
return false;
|
||||
|
||||
// Show only when on active team
|
||||
switch ( pLocalPlayer->GetTeamNumber() )
|
||||
{
|
||||
case TEAM_TERRORIST:
|
||||
case TEAM_CT:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !pLocalPlayer->IsAlive() )
|
||||
return false;
|
||||
|
||||
// Need game rules
|
||||
if ( !CSGameRules() )
|
||||
return false;
|
||||
|
||||
// If the round is already won, then don't show warnings (things will start resetting and cause a spike)
|
||||
if ( CSGameRules()->IsRoundOver() )
|
||||
return false;
|
||||
|
||||
// Don't show warnings during freeze period or warmup (that's when players are joining)
|
||||
if ( CSGameRules()->IsFreezePeriod() || CSGameRules()->IsWarmupPeriod() )
|
||||
return false;
|
||||
|
||||
// Don't show warning for 3 seconds after freezetime ended (need to accumulate choke/loss)
|
||||
if ( gpGlobals->curtime < CSGameRules()->GetRoundStartTime() + 3.0f )
|
||||
return false;
|
||||
|
||||
// Don't show warnings if local player just spawned or respawned (AR / DM / etc.)
|
||||
if ( pLocalPlayer->m_flLastSpawnTimeIndex > gpGlobals->curtime - 3.0f )
|
||||
return false;
|
||||
|
||||
//
|
||||
// OGS recording
|
||||
//
|
||||
static double s_dTimeLastOgsRecordWritten = 0;
|
||||
static double s_dTimeTrackingPeakStarted = 0;
|
||||
static float s_flTrackedPeakValue = 0;
|
||||
static CSClientCsgoGameEventType_t s_chTypeTrackingPeak = k_CSClientCsgoGameEventType_ConnectionProblem_Generic;
|
||||
double dTimeNow = Plat_FloatTime();
|
||||
if ( dTimeNow > s_dTimeLastOgsRecordWritten + 60 )
|
||||
{
|
||||
bool bRecordNow = false;
|
||||
CSClientCsgoGameEventType_t chType = k_CSClientCsgoGameEventType_ConnectionProblem_Generic;
|
||||
float flCurrentValue = 0;
|
||||
if ( INetChannelInfo *pChannelInfo = engine->GetNetChannelInfo() )
|
||||
{
|
||||
float flPacketLoss = pChannelInfo->GetAvgLoss( FLOW_INCOMING );
|
||||
float flPacketChoke = pChannelInfo->GetAvgChoke( FLOW_INCOMING );
|
||||
if ( flPacketLoss > 0 )
|
||||
{
|
||||
chType = k_CSClientCsgoGameEventType_ConnectionProblem_Loss;
|
||||
flCurrentValue = flPacketLoss;
|
||||
}
|
||||
else if ( flPacketChoke > 0 )
|
||||
{
|
||||
chType = k_CSClientCsgoGameEventType_ConnectionProblem_Choke;
|
||||
flCurrentValue = flPacketChoke;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( chType != s_chTypeTrackingPeak ) || ( dTimeNow > s_dTimeTrackingPeakStarted + 0.75 ) )
|
||||
{ // Start tracking this problem type (or weren't tracking for some time?)
|
||||
s_chTypeTrackingPeak = chType;
|
||||
s_dTimeTrackingPeakStarted = dTimeNow;
|
||||
s_flTrackedPeakValue = 0;
|
||||
}
|
||||
else if ( dTimeNow > s_dTimeTrackingPeakStarted + 0.25 )
|
||||
{ // Have been tracking for 0.25 seconds: time to record
|
||||
bRecordNow = true;
|
||||
}
|
||||
|
||||
// Track max value over the period
|
||||
s_flTrackedPeakValue = MAX( s_flTrackedPeakValue, flCurrentValue );
|
||||
|
||||
if ( bRecordNow )
|
||||
{
|
||||
s_dTimeLastOgsRecordWritten = dTimeNow;
|
||||
uint64 ullData = int(s_flTrackedPeakValue * 1000);
|
||||
g_CSClientGameStats.AddClientCSGOGameEvent( chType, pLocalPlayer->GetAbsOrigin(), pLocalPlayer->EyeAngles(), ullData );
|
||||
DevMsg( "%s (peak at %.1f%%)\n", cl_connection_trouble_info.GetString(), s_flTrackedPeakValue*100 );
|
||||
|
||||
// Reset the data
|
||||
s_chTypeTrackingPeak = k_CSClientCsgoGameEventType_ConnectionProblem_Generic;
|
||||
s_flTrackedPeakValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !cl_connection_trouble_show.GetBool() ) // Allow to always hide transient errors (data collection only)
|
||||
return false;
|
||||
|
||||
// Does not hide with the rest of the HUD
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::ProcessInput( void )
|
||||
{
|
||||
static ConVarRef cl_connection_trouble_info( "cl_connection_trouble_info" );
|
||||
if ( FlashAPIIsValid() && m_bActive && cl_connection_trouble_info.IsValid() && cl_connection_trouble_info.GetString()[0] )
|
||||
{
|
||||
//
|
||||
// See cl_main.cpp CL_Move
|
||||
// bool hasProblem = cl.m_NetChannel->IsTimingOut() && !demoplayer->IsPlayingBack() && cl.IsActive();
|
||||
//
|
||||
|
||||
// Check for disconnect?
|
||||
float TimeoutValue = -1.0f, Percentage = -1.0f;
|
||||
|
||||
if ( 1 == sscanf( cl_connection_trouble_info.GetString(), "disconnect(%f)", &TimeoutValue ) )
|
||||
{
|
||||
if ( TimeoutValue < 0 )
|
||||
TimeoutValue = 0;
|
||||
|
||||
char cTimerStr[ 128 ];
|
||||
V_snprintf( cTimerStr, sizeof(cTimerStr), "%02d:%02d", Floor2Int( TimeoutValue / 60.f ), ( Floor2Int(TimeoutValue) % 60 ) );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlTopLabel, "#SFUI_CONNWARNING_HEADER" );
|
||||
if ( m_sfuiControlBottomLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlBottomLabel, "#SFUI_CONNWARNING_BODY" );
|
||||
if ( m_sfuiControlTimerLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlTimerLabel, cTimerStr );
|
||||
|
||||
if ( m_sfuiControlBg ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBg, true );
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTopLabel, true );
|
||||
if ( m_sfuiControlBottomLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBottomLabel, true );
|
||||
if ( m_sfuiControlTimerLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerLabel, true );
|
||||
if ( m_sfuiControlTimerIcon ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerIcon, true );
|
||||
}
|
||||
}
|
||||
else if ( 2 == sscanf( cl_connection_trouble_info.GetString(), "@%f:loss(%f)", &TimeoutValue, &Percentage ) )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlTopLabel, "#SFUI_CONNWARNING_Bandwidth_PacketLoss" );
|
||||
|
||||
if ( m_sfuiControlBg ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBg, false );
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTopLabel, true );
|
||||
if ( m_sfuiControlBottomLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBottomLabel, false );
|
||||
if ( m_sfuiControlTimerLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerLabel, false );
|
||||
if ( m_sfuiControlTimerIcon ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerIcon, false );
|
||||
}
|
||||
}
|
||||
else if ( 2 == sscanf( cl_connection_trouble_info.GetString(), "@%f:choke(%f)", &TimeoutValue, &Percentage ) )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlTopLabel, "#SFUI_CONNWARNING_Bandwidth_Choking" );
|
||||
|
||||
if ( m_sfuiControlBg ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBg, false );
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTopLabel, true );
|
||||
if ( m_sfuiControlBottomLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBottomLabel, false );
|
||||
if ( m_sfuiControlTimerLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerLabel, false );
|
||||
if ( m_sfuiControlTimerIcon ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerIcon, false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetText( m_sfuiControlTopLabel, "#SFUI_CONNWARNING_HEADER" );
|
||||
|
||||
if ( m_sfuiControlBg ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBg, false );
|
||||
if ( m_sfuiControlTopLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTopLabel, true );
|
||||
if ( m_sfuiControlBottomLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlBottomLabel, false );
|
||||
if ( m_sfuiControlTimerLabel ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerLabel, false );
|
||||
if ( m_sfuiControlTimerIcon ) m_pScaleformUI->Value_SetVisible( m_sfuiControlTimerIcon, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::FlashReady( void )
|
||||
{
|
||||
// Grab a pointer to the timeout text box
|
||||
if ( SFVALUE panelRoot = m_pScaleformUI->Value_GetMember( m_FlashAPI, "Panel" ) )
|
||||
{
|
||||
if ( SFVALUE panelAnim = m_pScaleformUI->Value_GetMember( panelRoot, "PanelAnim" ) )
|
||||
{
|
||||
m_sfuiControlBg = m_pScaleformUI->Value_GetMember( panelAnim, "AutoDisconnectBg" );
|
||||
|
||||
if ( SFVALUE text = m_pScaleformUI->Value_GetMember( panelAnim, "Text" ) )
|
||||
{
|
||||
m_sfuiControlTopLabel = m_pScaleformUI->Value_GetMember( text, "AutoDisconnectText1" );
|
||||
m_sfuiControlBottomLabel = m_pScaleformUI->Value_GetMember( text, "AutoDisconnectText2" );
|
||||
m_sfuiControlTimerLabel = m_pScaleformUI->Value_GetMember( text, "TimerText" );
|
||||
m_sfuiControlTimerIcon = m_pScaleformUI->Value_GetMember( text, "TimerIcon" );
|
||||
|
||||
SafeReleaseSFVALUE( text );
|
||||
}
|
||||
|
||||
SafeReleaseSFVALUE( panelAnim );
|
||||
}
|
||||
|
||||
SafeReleaseSFVALUE( panelRoot );
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudAutodisconnect::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_sfuiControlBg );
|
||||
SafeReleaseSFVALUE( m_sfuiControlTopLabel );
|
||||
SafeReleaseSFVALUE( m_sfuiControlBottomLabel );
|
||||
SafeReleaseSFVALUE( m_sfuiControlTimerLabel );
|
||||
SafeReleaseSFVALUE( m_sfuiControlTimerIcon );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
// We assume we are offline-only for splitscreen multiplayer, so we allow this to be displayed in the split screen slot like
|
||||
// the rest of the HUD is. If we support splitscreen online down the road, this should be moved into the fullscreen slot.
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudAutodisconnect, this, Autodisconnect );
|
||||
}
|
||||
|
||||
// When initially loaded, hide any previous message
|
||||
ShowPanel( false );
|
||||
m_bActive = false;
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::Reset( void )
|
||||
{
|
||||
ShowPanel( false );
|
||||
}
|
||||
|
||||
bool SFHudAutodisconnect::ShouldDraw( void )
|
||||
{
|
||||
return Helper_ShouldInformPlayerAboutConnectionLossChoke();
|
||||
}
|
||||
|
||||
void SFHudAutodisconnect::SetActive( bool bActive )
|
||||
{
|
||||
if ( m_bActive != bActive )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD element to show we are having connectivity trouble
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SFHUDAUTODISCONNECT_H_
|
||||
#define SFHUDAUTODISCONNECT_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
class SFHudAutodisconnect : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudAutodisconnect( const char *value );
|
||||
virtual ~SFHudAutodisconnect();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
virtual void Reset( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
protected:
|
||||
void ShowPanel( bool bShow );
|
||||
|
||||
protected:
|
||||
SFVALUE m_sfuiControlBg, m_sfuiControlTopLabel, m_sfuiControlBottomLabel, m_sfuiControlTimerLabel, m_sfuiControlTimerIcon;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDAUTODISCONNECT_H_ */
|
||||
@@ -0,0 +1,276 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jpaquin] The text chat widget ("say all" or "say team")
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "iclientmode.h"
|
||||
#include "clientmode_csnormal.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "sfhud_chat.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudChat );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( OnCancel ),
|
||||
SFUI_DECL_METHOD( OnOK ),
|
||||
SFUI_END_GAME_API_DEF( SFHudChat, Chat );
|
||||
|
||||
// Max number of characters in chat history
|
||||
#define HISTORY_LENGTH_MAX 10 * 1024
|
||||
// Number of character to delete if chat buffer is full
|
||||
#define HISTORY_LENGTH_PURGE 1 * 1024
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
SFHudChat::SFHudChat( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_bVisible( false ),
|
||||
m_iMode( MM_NONE )
|
||||
{
|
||||
m_pHistoryString = new wchar_t[ HISTORY_LENGTH_MAX ];
|
||||
|
||||
SetHiddenBits( /* HIDEHUD_MISCSTATUS */ 0 );
|
||||
}
|
||||
|
||||
|
||||
SFHudChat::~SFHudChat()
|
||||
{
|
||||
if ( m_pHistoryString )
|
||||
{
|
||||
delete [] m_pHistoryString;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
m_fLastShowTime = 0.0f;
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudChat, this, Chat );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
m_iMode = MM_NONE;
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::SetActive( bool bActive )
|
||||
{
|
||||
ShowPanel( bActive, false );
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
// exposed here as non-constant so CEG can populate the value at DLL init time
|
||||
static DWORD CEG_ALLOW_TEXTCHAT = 0x01B3; // will override
|
||||
|
||||
CEG_NOINLINE DWORD InitHudAllowTextChatFlag( void )
|
||||
{
|
||||
CEG_GCV_PRE();
|
||||
CEG_ALLOW_TEXTCHAT = CEG_GET_CONSTANT_VALUE( HudAllowTextChatFlag );
|
||||
CEG_GCV_POST();
|
||||
|
||||
return CEG_ALLOW_TEXTCHAT;
|
||||
}
|
||||
|
||||
bool SFHudChat::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() || (CSGameRules() && CSGameRules()->IsPlayingTraining()) )
|
||||
return false;
|
||||
|
||||
const float kCloseAnimTime = 0.6f;
|
||||
|
||||
if ( m_bVisible )
|
||||
{
|
||||
m_fLastShowTime = gpGlobals->curtime;
|
||||
}
|
||||
else if ( gpGlobals->curtime < ( m_fLastShowTime + kCloseAnimTime ) )
|
||||
{
|
||||
// Prevent the panel being raised again while it is already being lowered
|
||||
return false;
|
||||
}
|
||||
|
||||
// disallow text chat when CEG fails
|
||||
if ( CEG_ALLOW_TEXTCHAT & ~ALLOW_TEXTCHAT_FLAG )
|
||||
return false;
|
||||
|
||||
bool result = cl_drawhud.GetBool();
|
||||
return result && ( m_iMode != MM_NONE ) && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
void SFHudChat::OnOK( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_iMode = MM_NONE;
|
||||
}
|
||||
|
||||
void SFHudChat::OnCancel( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_iMode = MM_NONE;
|
||||
}
|
||||
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
void SFHudChat::FlashReady( void )
|
||||
{
|
||||
ShowPanel( m_bVisible, true );
|
||||
|
||||
memset( m_pHistoryString, 0, HISTORY_LENGTH_MAX * sizeof( wchar_t ) );
|
||||
}
|
||||
|
||||
|
||||
void SFHudChat::StartMessageMode( int mode )
|
||||
{
|
||||
if ( !ChatRaised() && FlashAPIIsValid() )
|
||||
{
|
||||
if ( !GetHud().HudDisabled() )
|
||||
{
|
||||
m_iMode = mode;
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, mode );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetMode", args, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudChat::ChatRaised( void )
|
||||
{
|
||||
return m_iMode != MM_NONE;
|
||||
}
|
||||
|
||||
|
||||
void SFHudChat::ShowPanel( bool bShow, bool force )
|
||||
{
|
||||
if ( ( bShow != m_bVisible ) || force )
|
||||
{
|
||||
m_bVisible = bShow;
|
||||
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
if ( m_bVisible )
|
||||
{
|
||||
g_pScaleformUI->SetIMEFocus( SF_SS_SLOT( 0 ) );
|
||||
g_pScaleformUI->SetIMEEnabled( true );
|
||||
|
||||
ListenForGameEvent( "cs_handle_ime_event" );
|
||||
UpdateHistory();
|
||||
WITH_SLOT_LOCKED
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pScaleformUI->SetIMEEnabled( false );
|
||||
|
||||
StopListeningForAllEvents();
|
||||
WITH_SLOT_LOCKED
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::AddStringToHistory( const wchar_t *string )
|
||||
{
|
||||
const int nMaxLengthInBytes = HISTORY_LENGTH_MAX * sizeof( wchar_t );
|
||||
int stringLen = V_wcslen( string );
|
||||
int historyLen = V_wcslen( m_pHistoryString );
|
||||
|
||||
if ( ( historyLen + stringLen + 2 ) > HISTORY_LENGTH_MAX )
|
||||
{
|
||||
// m_pHistoryStrig buffer is full. Delete lines at the start of the buffer
|
||||
if ( historyLen > HISTORY_LENGTH_PURGE )
|
||||
{
|
||||
const wchar_t *nextreturn = wcsstr( &m_pHistoryString[HISTORY_LENGTH_PURGE], L"\n" );
|
||||
if ( nextreturn != NULL )
|
||||
{
|
||||
memmove( m_pHistoryString, nextreturn, ( V_wcslen( nextreturn ) + 1 ) * sizeof( wchar_t ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
memset( m_pHistoryString, 0, nMaxLengthInBytes );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset( m_pHistoryString, 0, nMaxLengthInBytes );
|
||||
}
|
||||
}
|
||||
// Add new line
|
||||
V_wcsncat( m_pHistoryString, string, nMaxLengthInBytes, COPY_ALL_CHARACTERS );
|
||||
V_wcsncat( m_pHistoryString, L"\n", nMaxLengthInBytes, COPY_ALL_CHARACTERS );
|
||||
|
||||
if ( m_bVisible )
|
||||
{
|
||||
// Only update actionscript side if the chat panel is visible
|
||||
UpdateHistory();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::ClearHistory()
|
||||
{
|
||||
memset( m_pHistoryString, 0, HISTORY_LENGTH_MAX * sizeof( wchar_t ) );
|
||||
UpdateHistory();
|
||||
}
|
||||
|
||||
// Update actionscript side
|
||||
void SFHudChat::UpdateHistory()
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_SetMember( m_FlashAPI, "historyString", m_pHistoryString );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "UpdateHistory", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudChat::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
|
||||
if ( !V_strcmp( type, "cs_handle_ime_event" ) )
|
||||
{
|
||||
type = event->GetString( "eventtype" );
|
||||
const wchar_t* data = event->GetWString( "eventdata" );
|
||||
|
||||
if ( !V_strcmp( type, "addchars" ) )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, data );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "AddIMEChar", args, 1 );
|
||||
}
|
||||
}
|
||||
else if ( !V_strcmp( type, "setcomposition" ) )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, data );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetIMECompositionString", args, 1 );
|
||||
}
|
||||
}
|
||||
else if ( !V_strcmp( type, "cancelcomposition" ) )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "CancelIMEComposition", NULL, 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef SFHUDCHAT_H
|
||||
#define SFHUDCHAT_H
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "ammodef.h"
|
||||
#include "iclientmode.h"
|
||||
|
||||
|
||||
class SFHudChat : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudChat( const char *value );
|
||||
|
||||
virtual ~SFHudChat();
|
||||
|
||||
//void ProcessInput( void );
|
||||
|
||||
void LevelInit( void );
|
||||
|
||||
virtual void LevelShutdown( void );
|
||||
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
|
||||
void StartMessageMode( int mode );
|
||||
|
||||
void OnOK( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnCancel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
bool ChatRaised( void );
|
||||
void AddStringToHistory( const wchar_t *string );
|
||||
|
||||
void ClearHistory();
|
||||
|
||||
// overloads for the CGameEventListener class
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
protected:
|
||||
|
||||
void ShowPanel( bool bShow, bool force );
|
||||
|
||||
void UpdateHistory( void );
|
||||
|
||||
protected:
|
||||
bool m_bVisible;
|
||||
int m_iMode;
|
||||
float m_fLastShowTime;
|
||||
|
||||
wchar_t* m_pHistoryString;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,729 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhud_deathnotice.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "utlvector.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vstdlib/vstrtools.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
#include "strtools.h"
|
||||
#include "c_cs_team.h"
|
||||
#include <engine/IEngineSound.h>
|
||||
#include "hltvreplaysystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudDeathNoticeAndBotStatus );
|
||||
//
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( SetConfig ),
|
||||
SFUI_END_GAME_API_DEF( SFHudDeathNoticeAndBotStatus, DeathNotice );
|
||||
|
||||
static const float NOTICE_UPDATE_INTERVAL = 0.05f;
|
||||
static const float EXTRA_NOTICE_PADDING = 0.0f;
|
||||
|
||||
extern ConVar mp_display_kill_assists;
|
||||
extern ConVar cl_show_clan_in_death_notice;
|
||||
|
||||
SFHudDeathNoticeAndBotStatus::SFHudDeathNoticeAndBotStatus( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_nNotificationDisplayMax( 0 ),
|
||||
m_fNotificationLifetime( 0.0f ),
|
||||
m_fNotificationFadeLength( 0.0f ),
|
||||
m_fNotificationScrollLength( 0.0f ),
|
||||
m_fLocalPlayerLifetimeMod( 0.f ),
|
||||
m_bVisible( false )
|
||||
{
|
||||
m_wCTColor[0] = 0x0;
|
||||
m_wTColor[0] = 0x0;
|
||||
|
||||
m_vecNoticeText.EnsureCapacity( engine->GetMaxClients() );
|
||||
SetHiddenBits( HIDEHUD_MISCSTATUS );
|
||||
|
||||
m_vecNoticeText.EnsureCapacity( 16 );
|
||||
m_vecPendingNoticeText.EnsureCapacity( 16 );
|
||||
m_vecNoticeHandleCache.EnsureCapacity( 16 );
|
||||
}
|
||||
|
||||
|
||||
SFHudDeathNoticeAndBotStatus::~SFHudDeathNoticeAndBotStatus()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::FlashReady( void )
|
||||
{
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
ListenForGameEvent( "player_death" );
|
||||
ShowPanel( false );
|
||||
|
||||
// Populate cache
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
for ( int i = 0; i < 16; ++i )
|
||||
{
|
||||
SFVALUE result = m_pScaleformUI->Value_Invoke( m_FlashAPI, "AddPanel", NULL, 0 );
|
||||
|
||||
IScaleformUI::_ValueType resultType = m_pScaleformUI->Value_GetType( result );
|
||||
|
||||
if ( resultType == IScaleformUI::VT_DisplayObject )
|
||||
{
|
||||
m_vecNoticeHandleCache.AddToTail( result );
|
||||
}
|
||||
else
|
||||
{
|
||||
SafeReleaseSFVALUE( result );
|
||||
Assert( false && "AddPanel failed. Probably referencing a bad name." );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SFHudDeathNoticeAndBotStatus::PreUnloadFlash( void )
|
||||
{
|
||||
// cleanup
|
||||
StopListeningForAllEvents();
|
||||
|
||||
for ( int nPos = 0; nPos < m_vecNoticeText.Count(); nPos++ )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_vecNoticeText[nPos].m_pPanel );
|
||||
}
|
||||
|
||||
for ( int nPos = 0; nPos < m_vecPendingNoticeText.Count(); nPos++ )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_vecPendingNoticeText[nPos].m_pPanel );
|
||||
}
|
||||
|
||||
for ( int nPos = 0; nPos < m_vecNoticeHandleCache.Count(); nPos++ )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_vecNoticeHandleCache[nPos] );
|
||||
}
|
||||
|
||||
m_vecNoticeText.Purge();
|
||||
m_vecPendingNoticeText.Purge();
|
||||
m_vecNoticeHandleCache.Purge();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudDeathNoticeAndBotStatus, this, DeathNotice );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::ShowPanel( const bool bShow )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConVar cl_drawhud_force_deathnotices( "cl_drawhud_force_deathnotices", "0", FCVAR_RELEASE, "0: default; 1: draw deathnotices even if hud disabled; -1: force no deathnotices" );
|
||||
bool SFHudDeathNoticeAndBotStatus::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
return ( cl_drawhud_force_deathnotices.GetInt() >= 0 ) && (
|
||||
( cl_drawhud_force_deathnotices.GetInt() > 0 ) ||
|
||||
cl_drawhud.GetBool()
|
||||
) && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::SetActive( bool bActive )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
if ( bActive != m_bVisible )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bActive == false && m_bActive == true )
|
||||
{
|
||||
// We want to continue to run ProcessInput while the HUD element is hidden
|
||||
// so that the notifications continue advancing down the screen
|
||||
return;
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
|
||||
if ( !V_strcmp( type, "player_death" ) )
|
||||
{
|
||||
if ( !g_HltvReplaySystem.GetHltvReplayDelay() || event->GetBool( "realtime_passthrough" ) )
|
||||
OnPlayerDeath( event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::OnPlayerDeath( IGameEvent * event )
|
||||
{
|
||||
C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
|
||||
|
||||
if ( !cs_PR )
|
||||
{
|
||||
Assert( false );
|
||||
return;
|
||||
}
|
||||
|
||||
int nAttacker = engine->GetPlayerForUserID( event->GetInt( "attacker" ) );
|
||||
int nVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
|
||||
int nAssister = mp_display_kill_assists.GetBool() ? engine->GetPlayerForUserID( event->GetInt( "assister" ) ) : 0;
|
||||
|
||||
const char * szWeapon = event->GetString( "weapon" );
|
||||
if ( szWeapon == NULL || szWeapon[ 0 ] == 0 )
|
||||
return;
|
||||
|
||||
bool bHeadshot = event->GetInt( "headshot" ) > 0;
|
||||
bool bSuicide = ( nAttacker == 0 || nAttacker == nVictim );
|
||||
bool bDominated = false;
|
||||
bool bRevenge = false;
|
||||
bool isVictim = GetLocalPlayerIndex() == nVictim;
|
||||
bool bPenetrated = ( event->GetInt( "penetrated" ) > 0 );
|
||||
bool isKiller = !isVictim && ( GetLocalPlayerIndex() == nAttacker || GetLocalPlayerIndex() == nAssister ); //Need to check isVictim because the player is both killer and victim in a suicide
|
||||
|
||||
wchar_t szAttackerName[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
wchar_t szVictimName[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
wchar_t szAssisterName[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
|
||||
szAttackerName[ 0 ] = L'\0';
|
||||
szVictimName[ 0 ] = L'\0';
|
||||
szAssisterName[ 0 ] = L'\0';
|
||||
|
||||
EDecoratedPlayerNameFlag_t kDontShowClanName = k_EDecoratedPlayerNameFlag_DontShowClanName;
|
||||
if ( cl_show_clan_in_death_notice.GetInt() > 0 )
|
||||
kDontShowClanName = k_EDecoratedPlayerNameFlag_Simple;
|
||||
|
||||
if ( nAttacker > 0 )
|
||||
{
|
||||
cs_PR->GetDecoratedPlayerName( nAttacker, szAttackerName, sizeof( szAttackerName ), EDecoratedPlayerNameFlag_t( k_EDecoratedPlayerNameFlag_AddBotToNameIfControllingBot | kDontShowClanName ) );
|
||||
}
|
||||
|
||||
if ( nVictim > 0 )
|
||||
{
|
||||
cs_PR->GetDecoratedPlayerName( nVictim, szVictimName, sizeof( szVictimName ), EDecoratedPlayerNameFlag_t( k_EDecoratedPlayerNameFlag_AddBotToNameIfControllingBot | kDontShowClanName ) );
|
||||
}
|
||||
|
||||
if ( nAssister > 0 )
|
||||
{
|
||||
// if our attacker is the same as our assiter, it means a bot attacked the victim and a player took over that bot
|
||||
if ( nAssister == nAttacker )
|
||||
nAssister = 0;
|
||||
else
|
||||
{
|
||||
cs_PR->GetDecoratedPlayerName( nAssister, szAssisterName, sizeof( szAssisterName ), EDecoratedPlayerNameFlag_t( k_EDecoratedPlayerNameFlag_AddBotToNameIfControllingBot | kDontShowClanName ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Highlight "The Suspect" in death feed
|
||||
if ( CDemoPlaybackParameters_t const *pParameters = engine->GetDemoPlaybackParameters() )
|
||||
{
|
||||
if ( pParameters->m_uiLockFirstPersonAccountID )
|
||||
{
|
||||
player_info_t pinfo;
|
||||
engine->GetPlayerInfo( nAttacker, &pinfo );
|
||||
if ( pParameters->m_uiLockFirstPersonAccountID == CSteamID( pinfo.xuid ).GetAccountID() )
|
||||
{
|
||||
isKiller = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( bSuicide )
|
||||
{
|
||||
STEAMWORKS_TESTSECRETALWAYS();
|
||||
}
|
||||
int nVictimTeam = nVictim > 0 ? cs_PR->GetTeam( nVictim ) : 0;
|
||||
int nAtackerTeam = nAttacker > 0 ? cs_PR->GetTeam( nAttacker ) : 0;
|
||||
int nAssisterTeam = nAssister > 0 ? cs_PR->GetTeam( nAssister ) : 0;
|
||||
|
||||
CCSPlayer* pCSPlayerKiller = ToCSPlayer( ClientEntityList().GetBaseEntity( nAttacker ) );
|
||||
CCSPlayer* pCSPlayerAssister = ToCSPlayer( ClientEntityList().GetBaseEntity( nAssister ) );
|
||||
|
||||
if ( event->GetInt( "dominated" ) > 0 || ( pCSPlayerKiller != NULL && pCSPlayerKiller->IsPlayerDominated( nVictim ) ) )
|
||||
{
|
||||
bDominated = true;
|
||||
}
|
||||
else if ( event->GetInt( "revenge" ) > 0 )
|
||||
{
|
||||
bRevenge = true;
|
||||
}
|
||||
|
||||
// Setup HTML
|
||||
wchar_t szDomination[ 64 ];
|
||||
GetIconHTML( L"domination", szDomination, ARRAYSIZE( szDomination ) );
|
||||
|
||||
wchar_t szHeadshot[ 64 ];
|
||||
GetIconHTML( L"headshot", szHeadshot, ARRAYSIZE( szHeadshot ) );
|
||||
|
||||
wchar_t szPenetration[ 64 ];
|
||||
GetIconHTML( L"penetrate", szPenetration, ARRAYSIZE( szPenetration ) );
|
||||
|
||||
wchar_t szRevenge[ 64 ];
|
||||
GetIconHTML( L"revenge", szRevenge, ARRAYSIZE( szRevenge ) );
|
||||
|
||||
wchar_t szSuicide[ 64 ];
|
||||
GetIconHTML( L"suicide", szSuicide, ARRAYSIZE( szSuicide ) );
|
||||
|
||||
C_CSPlayer *pLocalCSPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pLocalCSPlayer )
|
||||
return;
|
||||
|
||||
bool bAssisterIsTarget = pCSPlayerAssister && pCSPlayerAssister->IsAssassinationTarget();
|
||||
bool bAttackerIsTarget = pCSPlayerKiller && pCSPlayerKiller->IsAssassinationTarget();
|
||||
|
||||
if ( nAssister > 0 )
|
||||
{
|
||||
if ( !bAttackerIsTarget )
|
||||
TruncatePlayerName( szAttackerName, ARRAYSIZE( szAttackerName ), DEATH_NOTICE_ASSIST_NAME_TRUNCATE_AT );
|
||||
|
||||
if ( !bAssisterIsTarget )
|
||||
TruncatePlayerName( szAssisterName, ARRAYSIZE( szAssisterName ), DEATH_NOTICE_ASSIST_SHORT_NAME_TRUNCATE_AT );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !bAttackerIsTarget )
|
||||
TruncatePlayerName( szAttackerName, ARRAYSIZE( szAttackerName ), DEATH_NOTICE_NAME_TRUNCATE_AT );
|
||||
}
|
||||
|
||||
wchar_t szAttackerHTML[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
V_snwprintf( szAttackerHTML, ARRAYSIZE( szAttackerHTML ), DEATH_NOTICE_FONT_STRING, ( nAtackerTeam == TEAM_CT ) ? m_wCTColor : m_wTColor, ( !bSuicide ) ? szAttackerName : L"" );
|
||||
wchar_t szAssisterHTML[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
V_snwprintf( szAssisterHTML, ARRAYSIZE( szAssisterHTML ), DEATH_NOTICE_FONT_STRING, ( nAssisterTeam == TEAM_CT ) ? m_wCTColor : m_wTColor, ( nAssister > 0 ) ? szAssisterName : L"" );
|
||||
|
||||
CCSPlayer* pCSPlayerVictim = ToCSPlayer( ClientEntityList().GetBaseEntity( nVictim ) );
|
||||
bool bVictimIsTarget = pCSPlayerVictim && pCSPlayerVictim->IsAssassinationTarget();
|
||||
if ( !bVictimIsTarget )
|
||||
{
|
||||
if ( nAssister > 0 )
|
||||
TruncatePlayerName( szVictimName, ARRAYSIZE( szVictimName ), DEATH_NOTICE_ASSIST_NAME_TRUNCATE_AT );
|
||||
else
|
||||
TruncatePlayerName( szVictimName, ARRAYSIZE( szVictimName ), DEATH_NOTICE_NAME_TRUNCATE_AT );
|
||||
}
|
||||
|
||||
wchar_t szVictimHTML[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
V_snwprintf( szVictimHTML, ARRAYSIZE( szVictimHTML ), DEATH_NOTICE_FONT_STRING, ( nVictimTeam == TEAM_CT ) ? m_wCTColor : m_wTColor, szVictimName );
|
||||
|
||||
wchar_t szAttAssComboHTML[ MAX_DECORATED_PLAYER_NAME_LENGTH ];
|
||||
V_snwprintf( szAttAssComboHTML, ARRAYSIZE( szAttAssComboHTML ), ( nAssister > 0 ) ? DEATH_NOTICE_ATTACKER_PLUS_ASSISTER : DEATH_NOTICE_ATTACKER_NO_ASSIST, bSuicide ? szVictimHTML : szAttackerHTML, szAssisterHTML );
|
||||
|
||||
if ( Q_strcmp( "knifegg", szWeapon ) == 0 )
|
||||
szWeapon = "knife";
|
||||
else if ( Q_strcmp( "molotov_projectile_impact", szWeapon ) == 0 )
|
||||
szWeapon = "inferno";
|
||||
|
||||
if ( Q_strcmp( "knife", szWeapon ) == 0 )
|
||||
{
|
||||
if ( pCSPlayerKiller && pCSPlayerKiller->GetTeamNumber() == TEAM_CT )
|
||||
{
|
||||
szWeapon = "knife_default_ct";
|
||||
}
|
||||
else
|
||||
{
|
||||
szWeapon = "knife_default_t";
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t wszWeapon[ 64 ];
|
||||
V_UTF8ToUnicode( szWeapon, wszWeapon, sizeof( wszWeapon ) );
|
||||
|
||||
wchar_t szWeaponHTML[ 64 ];
|
||||
GetIconHTML( wszWeapon, szWeaponHTML, ARRAYSIZE( szWeaponHTML ) );
|
||||
|
||||
wchar_t szNotice[ COMPILETIME_MAX( DEATH_NOTICE_TEXT_MAX, 3 * MAX_DECORATED_PLAYER_NAME_LENGTH ) ];
|
||||
|
||||
V_snwprintf( szNotice,
|
||||
ARRAYSIZE( szNotice ),
|
||||
#if defined(_PS3) || defined(POSIX)
|
||||
L"%ls%ls%ls%ls%ls%ls%ls%ls",
|
||||
#else
|
||||
L"%s%s%s%s%s%s%s%s",
|
||||
#endif
|
||||
bRevenge ? szRevenge : L"",
|
||||
bDominated ? szDomination : L"",
|
||||
szAttAssComboHTML,
|
||||
bSuicide ? L"" : szWeaponHTML,
|
||||
bPenetrated ? szPenetration : L"",
|
||||
bHeadshot ? szHeadshot : L"",
|
||||
bSuicide ? szSuicide : L"",
|
||||
szVictimHTML );
|
||||
|
||||
PushNotice( szNotice, isVictim, isKiller );
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::ClearNotices( void )
|
||||
{
|
||||
ScaleformDisplayInfo dinfo;
|
||||
|
||||
FOR_EACH_VEC_BACK( m_vecNoticeText, i )
|
||||
{
|
||||
dinfo.Clear();
|
||||
dinfo.SetVisibility( false );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( m_vecNoticeText[i].m_pPanel, &dinfo );
|
||||
|
||||
m_vecNoticeHandleCache.AddToTail( m_vecNoticeText[i].m_pPanel );
|
||||
m_vecNoticeText.Remove( i );
|
||||
}
|
||||
|
||||
FOR_EACH_VEC_BACK( m_vecPendingNoticeText, i )
|
||||
{
|
||||
m_vecNoticeHandleCache.AddToTail( m_vecPendingNoticeText[i].m_pPanel );
|
||||
m_vecPendingNoticeText.Remove( i );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::PushNotice( const char * szNoticeText, bool isVictim, bool isKiller )
|
||||
{
|
||||
NoticeText_t notice;
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szNoticeText, notice.m_szNotice, sizeof( notice.m_szNotice ) );
|
||||
|
||||
PushNotice( notice, isVictim, isKiller );
|
||||
}
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::PushNotice( const wchar_t* wszNoticeText, bool isVictim, bool isKiller )
|
||||
{
|
||||
NoticeText_t notice;
|
||||
|
||||
V_wcsncpy( notice.m_szNotice, wszNoticeText, sizeof( notice.m_szNotice ) );
|
||||
|
||||
PushNotice( notice, isVictim, isKiller );
|
||||
}
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::PushNotice( NoticeText_t& notice, bool isVictim, bool isKiller )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
SFVALUE result = NULL;
|
||||
if ( m_vecNoticeHandleCache.Count() )
|
||||
{
|
||||
result = m_vecNoticeHandleCache.Tail();
|
||||
m_vecNoticeHandleCache.FastRemove( m_vecNoticeHandleCache.Count()-1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = m_pScaleformUI->Value_Invoke( m_FlashAPI, "AddPanel", NULL, 0 );
|
||||
}
|
||||
|
||||
IScaleformUI::_ValueType resultType = m_pScaleformUI->Value_GetType( result );
|
||||
|
||||
if ( resultType == IScaleformUI::VT_DisplayObject )
|
||||
{
|
||||
notice.m_pPanel = result;
|
||||
|
||||
WITH_SFVALUEARRAY( args, 4 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, notice.m_pPanel);
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, ¬ice.m_szNotice[0]);
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, isVictim );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 3, isKiller );
|
||||
|
||||
SFVALUE boxheight = m_pScaleformUI->Value_Invoke( m_FlashAPI, "SetPanelText", args, 4);
|
||||
|
||||
notice.m_fTextHeight = (float)m_pScaleformUI->Value_GetNumber( boxheight ) + EXTRA_NOTICE_PADDING;
|
||||
|
||||
SafeReleaseSFVALUE( boxheight );
|
||||
|
||||
}
|
||||
|
||||
notice.m_fLifetimeMod = isVictim || isKiller ? m_fLocalPlayerLifetimeMod : 1.0f;
|
||||
notice.m_fSpawnTime = gpGlobals->curtime;
|
||||
|
||||
m_vecPendingNoticeText.AddToHead( notice );
|
||||
|
||||
// if we have too many pending notices, then remove the oldest one
|
||||
// this happens when we are skipping in demos
|
||||
int numPending = m_vecPendingNoticeText.Count();
|
||||
if ( numPending > 15 )
|
||||
{
|
||||
// pull the oldest one
|
||||
numPending -= 1;
|
||||
NoticeText_t noticeToRemove = m_vecPendingNoticeText[numPending];
|
||||
m_vecPendingNoticeText.Remove( numPending );
|
||||
|
||||
m_vecNoticeHandleCache.AddToTail( noticeToRemove.m_pPanel );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SafeReleaseSFVALUE( result );
|
||||
Assert( false && "AddPanel failed. Probably referencing a bad name." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::SetConfig( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_nNotificationDisplayMax = m_pScaleformUI->Params_GetArgAsNumber( obj, 0 );
|
||||
m_fNotificationScrollLength = m_pScaleformUI->Params_GetArgAsNumber( obj, 1 );
|
||||
m_fNotificationFadeLength = m_pScaleformUI->Params_GetArgAsNumber( obj, 2 );
|
||||
m_fNotificationLifetime = m_pScaleformUI->Params_GetArgAsNumber( obj, 3 );
|
||||
|
||||
V_UTF8ToUnicode( pui->Params_GetArgAsString( obj, 4 ), m_wCTColor, sizeof( m_wCTColor ) );
|
||||
V_UTF8ToUnicode( pui->Params_GetArgAsString( obj, 5 ), m_wTColor, sizeof( m_wTColor ) );
|
||||
|
||||
m_fLocalPlayerLifetimeMod = m_pScaleformUI->Params_GetArgAsNumber( obj, 6 );
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::ProcessInput( void )
|
||||
{
|
||||
// limit how often we update this stuff because it doesn't have to be too
|
||||
// smooth
|
||||
if ( gpGlobals->curtime > m_fNextUpdateTime )
|
||||
{
|
||||
m_fNextUpdateTime = gpGlobals->curtime + NOTICE_UPDATE_INTERVAL;
|
||||
|
||||
// go through the visible list, moving and setting positions as appropriate
|
||||
// we're going to to move the first one. And we're going to make sure that each item after that
|
||||
// is above the item below it. so if we go in order from head to tail, we should end up
|
||||
// moving the whole list just by calculating where the first entry should be.
|
||||
|
||||
ScaleformDisplayInfo dinfo;
|
||||
float previousY = 0.f;
|
||||
float currentY = 0.f;
|
||||
float alpha = 0.f;
|
||||
bool bANoticeIsSpawning = false;
|
||||
|
||||
for ( int i = m_vecNoticeText.Count() - 1; i >= 0; i-- )
|
||||
{
|
||||
// keep track of these through the function and set them at the bottom.
|
||||
// if the alpha is zero at the end of the function ( and it's not spawning )
|
||||
// we'll mark this notice for removal
|
||||
// doing it this way lets us add in the alpha from the lifetime being over
|
||||
alpha =0.0f;
|
||||
currentY = m_vecNoticeText[i].m_fY;
|
||||
|
||||
if ( m_vecNoticeText[i].m_iState == NS_SPAWNING )
|
||||
{
|
||||
// this notice is fading in at the bottom of the panel
|
||||
// we want to scroll its position up the screen from 0, and bring the alpha up too
|
||||
// we do both of these over m_fNotificationScrollLength seconds
|
||||
float t = ( gpGlobals->curtime - m_vecNoticeText[i].m_fStateTime ) / m_fNotificationScrollLength;
|
||||
|
||||
if ( t >= 1 )
|
||||
{
|
||||
// done spawning, now move to normal mode ( text just sits, and scrolls up )
|
||||
t = 1;
|
||||
m_vecNoticeText[i].m_iState = NS_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// keep track of whether a notice is currently spawning
|
||||
// we can only add one notice at a time, so we need to know
|
||||
// if this one is still fading in. We'll wait until this stays false
|
||||
// to move a notice over from the pending list.
|
||||
bANoticeIsSpawning = true;
|
||||
|
||||
if ( t < 0 )
|
||||
t = 0;
|
||||
}
|
||||
|
||||
// these will be set on the panel at the bottom of the loop
|
||||
currentY = ( -m_vecNoticeText[i].m_fTextHeight * t ) + ( previousY + ( m_vecNoticeText[i].m_fTextHeight * 2 ) );
|
||||
alpha = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make this notice's position be just below the previous notice's
|
||||
// position
|
||||
currentY = previousY + m_vecNoticeText[i].m_fTextHeight;
|
||||
|
||||
alpha = 1.0f;
|
||||
}
|
||||
|
||||
// now figure out if we need to fade this notice out because it's so old
|
||||
float dt = gpGlobals->curtime - m_vecNoticeText[i].m_fSpawnTime;
|
||||
|
||||
if ( dt > ( m_fNotificationLifetime * m_vecNoticeText[i].m_fLifetimeMod ) )
|
||||
{
|
||||
float t = ( dt - ( m_fNotificationLifetime * m_vecNoticeText[i].m_fLifetimeMod ) ) / m_fNotificationFadeLength;
|
||||
|
||||
// this is just Max( Min( t,1 ) , 0 );
|
||||
t = ( t < 0 ) ? 0 : ( ( t > 1 ) ? 1 : t );
|
||||
|
||||
alpha *= 1.0f - t;
|
||||
}
|
||||
|
||||
// if our alpha is zero ( and we're not spawning ) it means this notice
|
||||
// is now dead and can be removed
|
||||
if ( m_vecNoticeText[i].m_iState != NS_SPAWNING && alpha <= 0.0f )
|
||||
{
|
||||
m_vecNoticeText[i].m_bRemove = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set the actual position / alpha on the notice
|
||||
dinfo.SetAlpha( alpha*100 );
|
||||
dinfo.SetY( currentY );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( m_vecNoticeText[i].m_pPanel, &dinfo );
|
||||
}
|
||||
|
||||
// remember this notice's position so that the next notice can be
|
||||
// placed below it
|
||||
previousY = currentY;
|
||||
}
|
||||
|
||||
// now remove all the guys that are marked for removal ( they had 0 alpha )
|
||||
|
||||
for ( int i = m_vecNoticeText.Count() - 1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_vecNoticeText[i].m_bRemove )
|
||||
{
|
||||
dinfo.Clear();
|
||||
dinfo.SetVisibility( false );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( m_vecNoticeText[i].m_pPanel, &dinfo );
|
||||
|
||||
m_vecNoticeHandleCache.AddToTail( m_vecNoticeText[i].m_pPanel );
|
||||
m_vecNoticeText.Remove( i );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we aren't currently bringing in a message, then
|
||||
// see if there are any pending ones to add
|
||||
if ( !bANoticeIsSpawning )
|
||||
{
|
||||
int numPending = m_vecPendingNoticeText.Count();
|
||||
if ( numPending )
|
||||
{
|
||||
// pull the next pending notice and put it on the bottom of the notice stack
|
||||
numPending -= 1;
|
||||
NoticeText_t notice = m_vecPendingNoticeText[numPending];
|
||||
m_vecPendingNoticeText.Remove( numPending );
|
||||
|
||||
// only add notices that are not too old (stop spew when coming back from pause menu or when skipping in demos)
|
||||
if ( ( gpGlobals->curtime - notice.m_fSpawnTime ) < ( ( m_fNotificationLifetime * notice.m_fLifetimeMod ) + m_fNotificationFadeLength ) )
|
||||
{
|
||||
notice.m_iState = NS_SPAWNING;
|
||||
notice.m_fSpawnTime = gpGlobals->curtime;
|
||||
notice.m_fStateTime = gpGlobals->curtime;
|
||||
|
||||
dinfo.Clear();
|
||||
dinfo.SetAlpha( 0.f );
|
||||
dinfo.SetY( 0.f );
|
||||
dinfo.SetVisibility( true );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( notice.m_pPanel, &dinfo );
|
||||
|
||||
m_vecNoticeText.AddToHead( notice );
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, notice.m_pPanel );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "UpdateWidth", data, 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vecNoticeHandleCache.AddToTail( notice.m_pPanel );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_fNextUpdateTime > gpGlobals->curtime + NOTICE_UPDATE_INTERVAL )
|
||||
{
|
||||
m_fNextUpdateTime = gpGlobals->curtime + NOTICE_UPDATE_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::Show( void )
|
||||
{
|
||||
if ( m_bVisible == false )
|
||||
{
|
||||
for ( int nPos = 0; nPos < m_vecNoticeText.Count(); nPos++ )
|
||||
{
|
||||
if ( m_vecNoticeText[nPos].m_pPanel )
|
||||
{
|
||||
ScaleformDisplayInfo dinfo;
|
||||
m_pScaleformUI->Value_GetDisplayInfo( m_vecNoticeText[nPos].m_pPanel, &dinfo );
|
||||
dinfo.SetVisibility( true );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( m_vecNoticeText[nPos].m_pPanel, &dinfo );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::Hide( void )
|
||||
{
|
||||
if ( m_bVisible == true )
|
||||
{
|
||||
for ( int nPos = 0; nPos < m_vecNoticeText.Count(); nPos++ )
|
||||
{
|
||||
if ( m_vecNoticeText[nPos].m_pPanel )
|
||||
{
|
||||
ScaleformDisplayInfo dinfo;
|
||||
m_pScaleformUI->Value_GetDisplayInfo( m_vecNoticeText[nPos].m_pPanel, &dinfo );
|
||||
dinfo.SetVisibility( false );
|
||||
m_pScaleformUI->Value_SetDisplayInfo( m_vecNoticeText[nPos].m_pPanel, &dinfo );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SFHudDeathNoticeAndBotStatus::GetIconHTML( const wchar_t * szIcon, wchar_t * szBuffer, int nArraySize )
|
||||
{
|
||||
V_snwprintf( szBuffer, nArraySize, DEATH_NOTICE_IMG_STRING, szIcon );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,139 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef SFHUD_DEATHNOTICE_H_
|
||||
#define SFHUD_DEATHNOTICE_H_
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "strtools.h"
|
||||
|
||||
#define DEATH_NOTICE_TEXT_MAX 512 // max number of characters in a notice text
|
||||
#if defined( _GAMECONSOLE )
|
||||
#define DEATH_NOTICE_NAME_TRUNCATE_AT 16 // number of name character displayed before truncation
|
||||
#define DEATH_NOTICE_ASSIST_NAME_TRUNCATE_AT 11 // number of name character displayed before truncation
|
||||
#define DEATH_NOTICE_ASSIST_SHORT_NAME_TRUNCATE_AT 8 // number of name character displayed before truncation
|
||||
#else
|
||||
#define DEATH_NOTICE_NAME_TRUNCATE_AT 22 // number of name character displayed before truncation
|
||||
#define DEATH_NOTICE_ASSIST_NAME_TRUNCATE_AT 18 // number of name character displayed before truncation
|
||||
#define DEATH_NOTICE_ASSIST_SHORT_NAME_TRUNCATE_AT 12 // number of name character displayed before truncation
|
||||
#endif
|
||||
|
||||
//c9c9c9
|
||||
|
||||
#if defined(_PS3) || defined(POSIX)
|
||||
#define DEATH_NOTICE_IMG_STRING L" <img src='icon-%ls.png' height='16'/>"
|
||||
#define DEATH_NOTICE_FONT_STRING L"<font color=\"%ls\">%ls</font>"
|
||||
#define DEATH_NOTICE_ATTACKER_PLUS_ASSISTER L"%ls <font color='#bababa'>+</font> %ls"
|
||||
#define DEATH_NOTICE_ATTACKER_NO_ASSIST L"%ls%ls"
|
||||
#else
|
||||
#define DEATH_NOTICE_IMG_STRING L" <img src='icon-%s.png' height='16'/>"
|
||||
#define DEATH_NOTICE_FONT_STRING L"<font color=\"%s\">%s</font>"
|
||||
#define DEATH_NOTICE_ATTACKER_PLUS_ASSISTER L"%s <font color='#bababa'>+</font> %s"
|
||||
#define DEATH_NOTICE_ATTACKER_NO_ASSIST L"%s%s"
|
||||
#endif
|
||||
|
||||
class SFHudDeathNoticeAndBotStatus : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudDeathNoticeAndBotStatus( const char *value );
|
||||
virtual ~SFHudDeathNoticeAndBotStatus();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// CGameEventListener methods
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void OnPlayerDeath( IGameEvent * event );
|
||||
|
||||
void ClearNotices( void );
|
||||
|
||||
// Scaleform callbacks
|
||||
void SetConfig( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
protected:
|
||||
|
||||
|
||||
void ShowPanel( const bool bShow );
|
||||
|
||||
// Add the text notice to our internal queue and trigger add
|
||||
// animation in scaleform.
|
||||
void PushNotice( const char * szNoticeText, bool isVictim, bool isKiller );
|
||||
void PushNotice( const wchar_t* wszNoticeText, bool isVictim, bool isKiller );
|
||||
|
||||
struct NoticeText_t;
|
||||
void PushNotice( NoticeText_t& notice, bool isVictim, bool isKiller );
|
||||
|
||||
void GetIconHTML( const wchar_t * szIcon, wchar_t * szBuffer, int nArraySize );
|
||||
|
||||
// Show the death notices
|
||||
void Show( void );
|
||||
// Hide the death notices
|
||||
void Hide( void );
|
||||
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
NS_PENDING,
|
||||
NS_SPAWNING,
|
||||
NS_IDLE,
|
||||
NS_FORCED_OUT,
|
||||
} NOTICE_STATE;
|
||||
|
||||
struct NoticeText_t
|
||||
{
|
||||
NoticeText_t() :
|
||||
m_pPanel( NULL ),
|
||||
m_bRemove( false ),
|
||||
m_fTextHeight( 0.0f ),
|
||||
m_fSpawnTime( 0.0f ),
|
||||
m_fStateTime( 0.0f ),
|
||||
m_fLifetimeMod( 1.0f ),
|
||||
m_fY( 0.0f ),
|
||||
m_iState( NS_PENDING )
|
||||
{
|
||||
V_memset( m_szNotice, 0, sizeof( m_szNotice ) );
|
||||
};
|
||||
|
||||
wchar_t m_szNotice[DEATH_NOTICE_TEXT_MAX]; // Notice text
|
||||
bool m_bRemove; // Removal flag
|
||||
SFVALUE m_pPanel; // Handle to instantiated scaleform display object
|
||||
float m_fTextHeight;
|
||||
int m_iState;
|
||||
float m_fSpawnTime;
|
||||
float m_fStateTime;
|
||||
float m_fLifetimeMod;
|
||||
float m_fY;
|
||||
// its proper state after a show or hide
|
||||
};
|
||||
|
||||
int m_nNotificationDisplayMax; // Number of notices to display at one time
|
||||
float m_fNotificationLifetime; // Notification display time before fading out
|
||||
float m_fNotificationFadeLength;
|
||||
float m_fNotificationScrollLength;
|
||||
float m_fNextUpdateTime;
|
||||
float m_fLocalPlayerLifetimeMod;
|
||||
|
||||
CUtlVector<NoticeText_t> m_vecNoticeText; // Oldest notices at the end
|
||||
CUtlVector<NoticeText_t> m_vecPendingNoticeText; // Notices that are queued up to be displayed.
|
||||
CUtlVector<SFVALUE> m_vecNoticeHandleCache; // Cache of notice panel handles to reuse
|
||||
// (to avoid creating a new notice from scratch)
|
||||
|
||||
bool m_bVisible; // Element visibility flag
|
||||
wchar_t m_wCTColor[8]; // Highlight color for CT
|
||||
wchar_t m_wTColor[8]; // Highlight color for T
|
||||
};
|
||||
|
||||
#endif /* SFHUD_DEATHNOTICE_H_ */
|
||||
@@ -0,0 +1,144 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD element to show we are having connectivity trouble
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhud_radio.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudRadio );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( InvokeCommand ),
|
||||
SFUI_END_GAME_API_DEF( SFHudRadio, RadioPanel );
|
||||
|
||||
SFHudRadio::SFHudRadio( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_bVisible( false )
|
||||
{
|
||||
SetHiddenBits( HIDEHUD_MISCSTATUS );
|
||||
}
|
||||
|
||||
SFHudRadio::~SFHudRadio()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudRadio::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( bShow != m_bVisible )
|
||||
{
|
||||
m_bVisible = bShow;
|
||||
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRadio::ProcessInput( void )
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudRadio::FlashReady( void )
|
||||
{
|
||||
ShowPanel( false );
|
||||
}
|
||||
|
||||
bool SFHudRadio::PreUnloadFlash( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudRadio::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudRadio, this, RadioPanel );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRadio::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRadio::Reset( void )
|
||||
{
|
||||
}
|
||||
|
||||
bool SFHudRadio::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
return cl_drawhud.GetBool() && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
void SFHudRadio::SetActive( bool bActive )
|
||||
{
|
||||
if ( !bActive && m_bVisible )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
void SFHudRadio::ShowRadioGroup( int nSetID )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, nSetID );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowRadioGroup", args, 1 );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRadio::InvokeCommand( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( pui->Params_GetNumArgs( obj ) != 1 )
|
||||
{
|
||||
Warning("Bad command invoked by radio panel");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( pui->Params_ArgIs( obj, 0, IScaleformUI::VT_String ) )
|
||||
{
|
||||
engine->ClientCmd( pui->Params_GetArgAsString( obj, 0 ) );
|
||||
}
|
||||
|
||||
ShowPanel( false );
|
||||
}
|
||||
|
||||
bool SFHudRadio::PanelRaised( void )
|
||||
{
|
||||
return m_bVisible;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD element to show we are having connectivity trouble
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SFHUDRADIO_H_
|
||||
#define SFHUDRADIO_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
class SFHudRadio : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudRadio( const char *value );
|
||||
virtual ~SFHudRadio();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
virtual void Reset( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
bool PanelRaised( void );
|
||||
void ShowRadioGroup( int nSetID );
|
||||
void InvokeCommand( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
private:
|
||||
void ShowPanel( bool bShow );
|
||||
|
||||
private:
|
||||
bool m_bVisible;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDRADIO_H_ */
|
||||
@@ -0,0 +1,221 @@
|
||||
//========= Copyright © Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Use mouse control to select among displayed options
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhud_rosettaselector.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "clientmode_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static const char* g_pszSprayErrorSound = "ui/menu_back.wav";
|
||||
|
||||
bool Helper_CanUseSprays( void )
|
||||
{
|
||||
if ( g_bEngineIsHLTV )
|
||||
return false;
|
||||
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pLocalPlayer )
|
||||
return false;
|
||||
|
||||
return pLocalPlayer->IsAlive() && ( pLocalPlayer->GetTeamNumber() == TEAM_TERRORIST || pLocalPlayer->GetTeamNumber() == TEAM_CT );
|
||||
}
|
||||
|
||||
void ShowSprayMenu( const CCommand &args )
|
||||
{
|
||||
if ( Helper_CanUseSprays() )
|
||||
{
|
||||
SFHudRosettaSelector * pRosetta = GET_HUDELEMENT( SFHudRosettaSelector );
|
||||
pRosetta->SetShowRosetta( true, "spray" );
|
||||
}
|
||||
}
|
||||
ConCommand showSprayMenu( "+spray_menu", ShowSprayMenu );
|
||||
|
||||
void HideSprayMenu( const CCommand &args )
|
||||
{
|
||||
extern ConVar cl_playerspray_auto_apply;
|
||||
|
||||
SFHudRosettaSelector * pRosetta = GET_HUDELEMENT( SFHudRosettaSelector );
|
||||
pRosetta->SetShowRosetta( false, "spray" );
|
||||
}
|
||||
ConCommand hideSprayMenu( "-spray_menu", HideSprayMenu);
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudRosettaSelector );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( FlashHide ),
|
||||
SFUI_DECL_METHOD( GetMouseEnableBindingName ),
|
||||
SFUI_END_GAME_API_DEF( SFHudRosettaSelector, RosettaSelector );
|
||||
|
||||
SFHudRosettaSelector::SFHudRosettaSelector( const char *value )
|
||||
: SFHudFlashInterface( value )
|
||||
, m_bVisible( false )
|
||||
|
||||
{
|
||||
SetHiddenBits( HIDEHUD_MISCSTATUS );
|
||||
}
|
||||
|
||||
SFHudRosettaSelector::~SFHudRosettaSelector()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::SetShowRosetta( bool bShow, const char* szType )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
return;
|
||||
|
||||
uint32 unNumArgs = 1;
|
||||
uint32 unArgCount = 0;
|
||||
WITH_SFVALUEARRAY( args, unNumArgs )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, unArgCount++, szType );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
Assert( unNumArgs == unArgCount );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, CFmtStr( "%sRosetta", bShow?"Show":"Hide" ).Access() , args, unArgCount );
|
||||
}
|
||||
}
|
||||
|
||||
Visible( bShow );
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( bShow != Visible() )
|
||||
{
|
||||
Visible(bShow);
|
||||
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::ProcessInput( void )
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::FlashReady( void )
|
||||
{
|
||||
ShowPanel( false );
|
||||
}
|
||||
|
||||
bool SFHudRosettaSelector::PreUnloadFlash( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::FlashHide( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
SetShowRosetta( false, "spray" );
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::GetMouseEnableBindingName( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
/* Removed for partner depot */
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudRosettaSelector, this, RosettaSelector );
|
||||
Visible( false );
|
||||
enginesound->PrecacheSound( g_pszSprayErrorSound, true, true );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
Visible( false );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::Reset( void )
|
||||
{
|
||||
}
|
||||
|
||||
bool SFHudRosettaSelector::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
return cl_drawhud.GetBool() && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::SetActive( bool bActive )
|
||||
{
|
||||
if ( !bActive && Visible() )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
void SFHudRosettaSelector::HACK_OnShowCursorBindingDown( const char* szKeyName )
|
||||
{
|
||||
if ( !Visible() )
|
||||
return;
|
||||
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, szKeyName );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "OnShowCursorBindingPressed", args, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern void PlayerDecalDataSendActionSprayToServer( int nSlot );
|
||||
extern bool Helper_CanShowPreviewDecal( CEconItemView **ppOutEconItemView = NULL, trace_t* pOutSprayTrace = NULL, Vector *pOutVecPlayerRight = NULL, uint32* pOutUnStickerKitID = NULL );
|
||||
|
||||
// Return nonzero to swallow this key
|
||||
int SFHudRosettaSelector::KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding )
|
||||
{
|
||||
if ( down && pszCurrentBinding && ContainsBinding( pszCurrentBinding, "+attack", true ) )
|
||||
{
|
||||
if ( Helper_CanShowPreviewDecal() )
|
||||
{
|
||||
// If we're pretty sure this will result in a successful spray application, tell the server we want to spray
|
||||
// the currently equipped item and close the menu
|
||||
PlayerDecalDataSendActionSprayToServer( 0 );
|
||||
SetShowRosetta( false, "spray" );
|
||||
}
|
||||
else // keep menu up and play error sound
|
||||
{
|
||||
enginesound->EmitAmbientSound( g_pszSprayErrorSound, 1.0f );
|
||||
}
|
||||
// always swallow the input if this menu is up
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//========= Copyright © Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Use mouse control to select among displayed options
|
||||
//
|
||||
//=====================================================================================//
|
||||
#pragma once
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
class SFHudRosettaSelector : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudRosettaSelector( const char *value );
|
||||
virtual ~SFHudRosettaSelector();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void ) OVERRIDE;
|
||||
virtual void LevelInit( void ) OVERRIDE;
|
||||
virtual void LevelShutdown( void ) OVERRIDE;
|
||||
virtual bool ShouldDraw( void ) OVERRIDE;
|
||||
virtual void SetActive( bool bActive ) OVERRIDE;
|
||||
|
||||
virtual void Reset( void ) OVERRIDE;
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void ) OVERRIDE;
|
||||
virtual bool PreUnloadFlash( void ) OVERRIDE;
|
||||
|
||||
void FlashHide( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetMouseEnableBindingName( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void SetShowRosetta( bool bShow, const char* szType );
|
||||
|
||||
bool Visible() const { return m_bVisible; }
|
||||
|
||||
void HACK_OnShowCursorBindingDown( const char* szKeyName );
|
||||
int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
|
||||
private:
|
||||
void ShowPanel( bool bShow );
|
||||
|
||||
void Visible( bool val ) { m_bVisible = val; }
|
||||
private:
|
||||
bool m_bVisible;
|
||||
};
|
||||
|
||||
bool Helper_CanUseSprays();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef SFHUD_TEAMCOUNTER_H_
|
||||
#define SFHUD_TEAMCOUNTER_H_
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
#if !defined( _X360 )
|
||||
#include "xbox/xboxstubs.h"
|
||||
#endif
|
||||
|
||||
#if defined(_PS3) || defined(POSIX)
|
||||
#define TEAM_COUNT_IMG_STRING L"<img src='icon-%ls.png' height='16'/>"
|
||||
#define TEAM_COUNT_FONT_STRING L"<font color=\"%ls\">%ls</font>"
|
||||
#define TEAM_COUNT_FINAL_STRING L"%ls %ls"
|
||||
#else
|
||||
#define TEAM_COUNT_IMG_STRING L"<img src='icon-%s.png' height='16'/>"
|
||||
#define TEAM_COUNT_FONT_STRING L"<font color=\"%s\">%s</font>"
|
||||
#define TEAM_COUNT_FINAL_STRING L"%s %s"
|
||||
#endif
|
||||
|
||||
struct MiniStatus
|
||||
{
|
||||
XUID nXUID;
|
||||
int nEntIdx;
|
||||
int nPlayerIdx;
|
||||
int nGunGameLevel;
|
||||
int nHealth;
|
||||
int nArmor;
|
||||
int nTeammateColor;
|
||||
bool bIsCT;
|
||||
bool bLocalPlayer;
|
||||
bool bDead;
|
||||
bool bDominated;
|
||||
bool bDominating;
|
||||
bool bSpeaking;
|
||||
bool bPlayerBot; // indicates that the player took over this bot
|
||||
bool bSpectated;
|
||||
bool bTeamLeader;
|
||||
float flLastRefresh;
|
||||
|
||||
int nGGProgressiveRank; // save this character's rank
|
||||
int nPoints;
|
||||
int nTeam;
|
||||
|
||||
MiniStatus() :
|
||||
nXUID( INVALID_XUID ), nPlayerIdx(-1), nGunGameLevel(-1), bIsCT(false), bLocalPlayer(false), bDead(false), bDominated(false),
|
||||
bDominating( false ), bTeamLeader( false ), bSpeaking( false ), bPlayerBot( false ), bSpectated( false ), nGGProgressiveRank( -1 ), nPoints( 0 ), nTeam( 0 ), nTeammateColor( -1 ), flLastRefresh( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
MiniStatus( const MiniStatus © )
|
||||
{
|
||||
memcpy( this, ©, sizeof(MiniStatus) );
|
||||
}
|
||||
|
||||
MiniStatus& operator=( const MiniStatus &rhs )
|
||||
{
|
||||
memcpy( this, &rhs, sizeof(MiniStatus) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
memset( this, 0, sizeof(MiniStatus) );
|
||||
nXUID = INVALID_XUID;
|
||||
nPlayerIdx = -1;
|
||||
nEntIdx = 0;
|
||||
nGGProgressiveRank = -1;
|
||||
flLastRefresh = -1;
|
||||
}
|
||||
|
||||
// Returns true if any of these fields has changed since last update
|
||||
bool Update( XUID _Xuid, int _EntIdx, int _PlayerIdx, int _GunGameLevel, int _nHealth, int _nArmor, bool _IsCT, bool _LocalPlayer, bool _Dead, bool _Dominated, bool _Dominating, bool _bTeamLeader, bool _Speaking, bool _PlayerBot, bool _Spectated, int _Points, int _Team, int _TeammateColor, float _CurtimeRefresh )
|
||||
{
|
||||
bool bDiff = ( _Xuid != nXUID ) ||
|
||||
( _EntIdx != nEntIdx ) ||
|
||||
( _PlayerIdx != nPlayerIdx ) ||
|
||||
( _GunGameLevel != nGunGameLevel ) ||
|
||||
( _nHealth != nHealth ) ||
|
||||
( _nArmor != nArmor ) ||
|
||||
( _GunGameLevel != nGunGameLevel ) ||
|
||||
( _IsCT ^ bIsCT ) ||
|
||||
( _LocalPlayer ^ bLocalPlayer ) ||
|
||||
( _Dead ^ bDead ) ||
|
||||
( _Dominated ^ bDominated ) ||
|
||||
( _Dominating ^ bDominating ) ||
|
||||
( _bTeamLeader ^ bTeamLeader ) ||
|
||||
( _Speaking ^ bSpeaking ) ||
|
||||
( _PlayerBot ^ bPlayerBot ) ||
|
||||
( _Spectated ^ bSpectated ) ||
|
||||
( _Points != nPoints ) ||
|
||||
( _Team != nTeam ) ||
|
||||
( _TeammateColor != nTeammateColor ) ||
|
||||
( _CurtimeRefresh > flLastRefresh + 3.0f );
|
||||
|
||||
nXUID = _Xuid;
|
||||
nEntIdx = _EntIdx;
|
||||
nPlayerIdx = _PlayerIdx;
|
||||
nGunGameLevel = _GunGameLevel;
|
||||
nHealth = _nHealth;
|
||||
nArmor = _nArmor;
|
||||
bIsCT = _IsCT;
|
||||
bLocalPlayer = _LocalPlayer;
|
||||
bDead = _Dead;
|
||||
bDominated = _Dominated;
|
||||
bDominating = _Dominating;
|
||||
bTeamLeader = _bTeamLeader;
|
||||
bSpeaking = _Speaking;
|
||||
bPlayerBot = _PlayerBot;
|
||||
bSpectated = _Spectated;
|
||||
nPoints = _Points;
|
||||
nTeam = _Team;
|
||||
nTeammateColor = _TeammateColor;
|
||||
if ( bDiff )
|
||||
flLastRefresh = _CurtimeRefresh;
|
||||
|
||||
return bDiff;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class SFHudTeamCounter : public SFHudFlashInterface, public IShaderDeviceDependentObject
|
||||
{
|
||||
public:
|
||||
explicit SFHudTeamCounter( const char *value );
|
||||
virtual ~SFHudTeamCounter();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
// CGameEventListener methods
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
int FindNextObserverTargetIndex( bool reverse );
|
||||
int GetSpectatorTargetFromSlot( int idx );
|
||||
|
||||
virtual void DeviceLost( void ) { }
|
||||
virtual void DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd ) { m_bForceAvatarRefresh = true; }
|
||||
virtual void ScreenSizeChanged( int width, int height ) { }
|
||||
|
||||
void OnFlashResize( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
int GetPlayerEntIndexInSlot( int nIndex );
|
||||
int GetPlayerSlotIndex( int playerEntIndex );
|
||||
int GetPlayerSlotIndex( int playerEntIndex ) const; // version with no side effects
|
||||
int GetPlayerSlotIndexForDisplay( int playerEntIndex ) const; // When displayed to users, slot is one higher and slot 10 is displayed as 0 for legacy reasons.
|
||||
|
||||
protected:
|
||||
void LockSlot( bool wantItLocked, bool& currentlyLocked );
|
||||
|
||||
// update game clock
|
||||
void UpdateTimer( void );
|
||||
|
||||
// update team scores and balance of power indicator
|
||||
void UpdateScore( void );
|
||||
|
||||
// update current player's team selection graphic
|
||||
void UpdateTeamSelection( void );
|
||||
|
||||
// update mini-scoreboard (team list + status bar)
|
||||
void UpdateMiniScoreboard( void );
|
||||
|
||||
void ShowPanel( const bool bShow );
|
||||
void GetIconHTML( const char * szIcon, wchar_t * szBuffer, int nBufferSize );
|
||||
|
||||
// resets the progressive leader HUD with the local player and weapon
|
||||
// and resets m_nLeaderWeaponRank
|
||||
void ResetLeader();
|
||||
|
||||
void InvokeAvatarSlotUpdate( SFVALUEARRAY &avatarData, const MiniStatus* msInfo, int slotNumber );
|
||||
|
||||
static int GGProgSortFunction( MiniStatus* const* entry1, MiniStatus* const* entry2 );
|
||||
static int DMSortFunction( MiniStatus* const* entry1, MiniStatus* const* entry2 );
|
||||
|
||||
protected:
|
||||
enum BALANCE_OF_POWER
|
||||
{
|
||||
BOP_EVEN = 0, // teams even
|
||||
BOP_CT = TEAM_CT, // CT winning
|
||||
BOP_T = TEAM_TERRORIST // T winning
|
||||
};
|
||||
|
||||
enum VIEW_MODE
|
||||
{
|
||||
VIEW_MODE_NORMAL = 0,
|
||||
VIEW_MODE_GUN_GAME_PROGRESSIVE, // Gun game progressive view mode
|
||||
VIEW_MODE_GUN_GAME_BOMB, // Gun game bomb view mode
|
||||
VIEW_MODE_NUM,
|
||||
};
|
||||
|
||||
ISFTextObject * m_pTimeRedText;
|
||||
ISFTextObject * m_pTimeGreenText;
|
||||
ISFTextObject * m_pTime;
|
||||
ISFTextObject * m_pCTScore;
|
||||
ISFTextObject * m_pTScore;
|
||||
ISFTextObject * m_pCTGunGameBombScore;
|
||||
ISFTextObject * m_pTGunGameBombScore;
|
||||
|
||||
SFVALUE m_ProgressiveLeaderHandle;
|
||||
|
||||
bool m_bTimerAlertTriggered; // True if the timer's alert state has been triggered
|
||||
bool m_bRoundStarted; // True if a round is currently in progress
|
||||
bool m_bTimerHidden; // True if the timer is hidden from view
|
||||
int m_nTScoreLastUpdate; // Terrorist score posted to Scaleform
|
||||
int m_nCTScoreLastUpdate; // Counter-Terrorist score posted to Scaleform
|
||||
int m_nTeamSelectionLastUpdate; // Team selection posted to Scaleform
|
||||
int m_nLeaderWeaponRank; // The weapon rank of the current leader
|
||||
VIEW_MODE m_Mode; // Tracks the current view mode
|
||||
|
||||
bool m_bRoundIsEnding; // True if the round ended event was received
|
||||
bool m_bIsBombDefused;
|
||||
|
||||
bool m_bColorTabsInitialized;
|
||||
|
||||
enum PLAYER_TEAM_COUNT
|
||||
{
|
||||
MAX_TEAM_SIZE = 16
|
||||
};
|
||||
enum GG_PROG_PLAYER_COUNT
|
||||
{
|
||||
MAX_GGPROG_PLAYERS = 32
|
||||
};
|
||||
|
||||
// track the team info we've already pushed to the mini-scoreboard
|
||||
int m_nTerroristTeamCount;
|
||||
int m_nCTTeamCount;
|
||||
MiniStatus m_TerroristTeam[MAX_TEAM_SIZE];
|
||||
MiniStatus m_CTTeam[MAX_TEAM_SIZE];
|
||||
|
||||
// for GG Prog only: Track the status of the players, regardless of team
|
||||
int m_nPreviousGGProgressiveTotalPlayers;
|
||||
MiniStatus m_GGProgressivePlayers[MAX_GGPROG_PLAYERS];
|
||||
CUtlVector<MiniStatus*> m_ggSortedList;
|
||||
|
||||
CountdownTimer m_GGProgRankingTimer;
|
||||
|
||||
// Signals that avatar images should be reloaded (needed after a render device reset)
|
||||
bool m_bForceAvatarRefresh;
|
||||
|
||||
protected:
|
||||
// Sets the view mode, hiding or showing elements and changing
|
||||
// update behavior
|
||||
void SetViewMode( VIEW_MODE mode );
|
||||
|
||||
const MiniStatus* GetPlayerStatus( int index );
|
||||
const MiniStatus* GetPlayerStatus( int index ) const; // version with no side effects
|
||||
|
||||
private:
|
||||
float m_flPlayingTeamFadeoutTime;
|
||||
float m_flLastSpecListUpdate;
|
||||
|
||||
};
|
||||
|
||||
#endif /* SFHUD_TEAMCOUNTER_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,159 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFUNIQUEALERTS_H
|
||||
#define SFUNIQUEALERTS_H
|
||||
#pragma once
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "ehandle.h"
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
#define MAX_PLAYER_GIFT_DROP_DISPLAY 4
|
||||
|
||||
// Experimental feature, not ready to enable. Turn this on to visualize quest progress
|
||||
// messages in the Flash GUI
|
||||
#define MISSIONPANEL_ENABLE_QUEST_PROGRESSION 1
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Used to draw the history of weapon / item pickups and purchases by the player
|
||||
//-----------------------------------------------------------------------------
|
||||
class SFUniqueAlerts : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFUniqueAlerts( const char *value );
|
||||
|
||||
virtual void ProcessInput( void );
|
||||
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
virtual void Reset( void );
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
// CGameEventListener methods
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
virtual void OnTimeJump() OVERRIDE;
|
||||
|
||||
// This should probably be a message listen, but I'm new and not sure the right layering. Will update on review.
|
||||
void ShowQuestProgress(uint32 numPointsEarned, uint32 numPointsTotal, uint32 numPointsMax, const char* weaponName, const char* questDesc);
|
||||
|
||||
// Scaleform callbacks
|
||||
void OnAlertPanelHideAnimEnd( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
protected:
|
||||
void ShowDMBonusWeapon( CEconItemView* pItem, int nPos, int nSecondsLeft );
|
||||
|
||||
// Helper functions for setting active/non-active
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
void UpdateGGWeaponIconList( void );
|
||||
void ShowWarmupAlertPanel( void );
|
||||
void ShowHltvReplayAlertPanel( int nHltvReplayLeft );
|
||||
|
||||
// Display an alert in the 'alert text' area. If 'oneShot' is true, will automatically hide.
|
||||
// One-shot messages always flash on set, otherwise will only flash if the panel is coming from
|
||||
// hidden to showing.
|
||||
void ShowAlertText( const wchar_t* szMessage, bool oneShot = false );
|
||||
|
||||
// Hide a non-one-shot alert text
|
||||
void HideAlertText();
|
||||
|
||||
// Update for each sub-panel
|
||||
// These can assume that all the following are non-null:
|
||||
// CSGameRules()
|
||||
// C_CSPlayer::GetLocalCSPlayer()
|
||||
// m_pScaleformUI
|
||||
void ProcessMissionPanelGuardian();
|
||||
void ProcessDMBonusPanel();
|
||||
void ProcessAlertBar();
|
||||
#if defined ( ENABLE_GIFT_PANEL )
|
||||
void ProcessGiftPanel();
|
||||
#endif
|
||||
#if MISSIONPANEL_ENABLE_QUEST_PROGRESSION
|
||||
void ProcessMissionPanelQuest();
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum AlertState {
|
||||
ALERTSTATE_HIDDEN,
|
||||
ALERTSTATE_SHOWING,
|
||||
ALERTSTATE_HIDING, // Automatically will transition to ALERTSTATE_HIDDEN at some unknown point in the future
|
||||
};
|
||||
|
||||
// Whether any of this UI is active
|
||||
// (it could all be hidden due to hud settings)
|
||||
bool m_bVisible;
|
||||
|
||||
// Alert line (e.g. "Round Start", "Warmup ends in xx:xx")
|
||||
AlertState m_AlertState;
|
||||
float m_flNextAlertTick;
|
||||
|
||||
// Demolition mode panel
|
||||
bool m_bShowDemolitionProgressionPanel;
|
||||
|
||||
// Deathmatch extra points for using a certain weapon panel
|
||||
bool m_bDMBonusIsActive;
|
||||
float m_flNextDMBonusTick;
|
||||
|
||||
int m_nDMCurrentWeaponPoints;
|
||||
int m_nDMCurrentWeaponBonusPoints;
|
||||
int m_nDMBonusWeaponSlot;
|
||||
|
||||
// Mission/quest panel:
|
||||
bool m_bMissionVisible;
|
||||
|
||||
// Mission panel for guardian co-op missions
|
||||
bool m_guardianPanelInitialized;
|
||||
float m_guardianPanelHideTick;
|
||||
int m_nGuardianKills;
|
||||
int m_nGuardianWeapon;
|
||||
int m_nPlayerMoney;
|
||||
bool m_bGuardianHasWeapon;
|
||||
bool m_bGuardianHasWeaponEquipped;
|
||||
|
||||
// Mission panel for quest missions
|
||||
// (Only used if MISSIONPANEL_ENABLE_QUEST_PROGRESSION is enabled)
|
||||
bool m_bQuestMissionActive;
|
||||
|
||||
// Gift panel
|
||||
#if defined ( ENABLE_GIFT_PANEL )
|
||||
bool m_bIsGiftPanelActive;
|
||||
int m_nGlobalGiftsGivenInPeriod;
|
||||
int m_nGlobalNumGiftersInPeriod;
|
||||
int m_nGlobalGiftingPeriodSeconds;
|
||||
float m_flLastGiftPanelUpdate;
|
||||
|
||||
struct GiftTempList_t
|
||||
{
|
||||
int nDefindex;
|
||||
AccountID_t uiAccountID;
|
||||
int nNumGifts;
|
||||
bool bIsLocalPlayer;
|
||||
|
||||
GiftTempList_t() :
|
||||
nDefindex( 0 ), uiAccountID( 0 ), nNumGifts( 0 ), bIsLocalPlayer( false )
|
||||
{
|
||||
}
|
||||
};
|
||||
CUtlVector<GiftTempList_t> m_PlayerSpotlightTempList;
|
||||
#endif // ENABLE_GIFT_PANEL
|
||||
|
||||
};
|
||||
|
||||
#endif // SFUNIQUEALERTS_H
|
||||
@@ -0,0 +1,388 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "sfhudcallvotepanel.h"
|
||||
#include "hud_macros.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "c_cs_player.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "basepanel.h"
|
||||
#include "gametypes.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_user_message_register.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
ConVar cl_test_vote_scroll( "cl_test_vote_scroll", "0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY );
|
||||
|
||||
SFHudCallVotePanel* SFHudCallVotePanel::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( PopulatePlayerTargets ),
|
||||
SFUI_DECL_METHOD( PopulateMapTargets ),
|
||||
SFUI_DECL_METHOD( PopulateBackupFilenames ),
|
||||
SFUI_DECL_METHOD( GetNumberOfValidMapsInGroup ),
|
||||
SFUI_DECL_METHOD( GetNumberOfValidKickTargets ),
|
||||
SFUI_DECL_METHOD( IsQueuedMatchmaking ),
|
||||
SFUI_DECL_METHOD( IsEndMatchMapVoteEnabled ),
|
||||
SFUI_DECL_METHOD( IsPlayingClassicCompetitive ),
|
||||
SFUI_END_GAME_API_DEF( SFHudCallVotePanel, CallVotePanel );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
SFHudCallVotePanel::SFHudCallVotePanel() : ScaleformFlashInterface()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SFHudCallVotePanel::LoadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInstance = new SFHudCallVotePanel();
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, SFHudCallVotePanel, m_pInstance, CallVotePanel );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->RemoveFlashElement();
|
||||
m_pInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::PostUnloadFlash( void )
|
||||
{
|
||||
BasePanel()->DismissPauseMenu();
|
||||
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void SFHudCallVotePanel::LevelShutdown( void )
|
||||
{
|
||||
UnloadDialog();
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::FlashReady( void )
|
||||
{
|
||||
if ( !m_FlashAPI )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Show();
|
||||
|
||||
}
|
||||
|
||||
bool SFHudCallVotePanel::PreUnloadFlash( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::Show()
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_pScaleformUI )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::Hide( void )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_pScaleformUI )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::PopulatePlayerTargets( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( g_PR )
|
||||
{
|
||||
int slot = 0;
|
||||
SFVALUE result = CreateFlashObject();
|
||||
SFVALUE names = CreateFlashArray( MAX_PLAYERS );
|
||||
SFVALUE ids = CreateFlashArray( MAX_PLAYERS );
|
||||
|
||||
for ( int player = 1 ; player < MAX_PLAYERS; ++player )
|
||||
{
|
||||
if ( g_PR->IsConnected( player ) &&
|
||||
( cl_test_vote_scroll.GetBool() || !g_PR->IsFakePlayer( player ) ) &&
|
||||
GetLocalPlayerIndex() != player &&
|
||||
g_PR->GetTeam( player ) == g_PR->GetTeam( GetLocalPlayerIndex() ) )
|
||||
{
|
||||
player_info_t playerInfo;
|
||||
if ( engine->GetPlayerInfo( player, &playerInfo ) )
|
||||
{
|
||||
wchar_t szName[MAX_DECORATED_PLAYER_NAME_LENGTH];
|
||||
wchar_t szSafeName[MAX_DECORATED_PLAYER_NAME_LENGTH];
|
||||
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( g_PR->GetPlayerName( player ), szName, sizeof(szName) );
|
||||
g_pScaleformUI->MakeStringSafe( szName, szSafeName, sizeof( szSafeName ) );
|
||||
TruncatePlayerName( szSafeName, ARRAYSIZE( szSafeName ), CALLVOTE_NAME_TRUNCATE_AT );
|
||||
m_pScaleformUI->Value_SetArrayElement( names, slot, szSafeName );
|
||||
m_pScaleformUI->Value_SetArrayElement( ids, slot, playerInfo.userID );
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_SetMember( result, "names", names );
|
||||
m_pScaleformUI->Value_SetMember( result, "ids", ids );
|
||||
m_pScaleformUI->Value_SetMember( result, "count", slot );
|
||||
m_pScaleformUI->Params_SetResult( obj, result );
|
||||
|
||||
SafeReleaseSFVALUE( names );
|
||||
SafeReleaseSFVALUE( ids );
|
||||
SafeReleaseSFVALUE( result );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::GetNumberOfValidKickTargets( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( g_PR )
|
||||
{
|
||||
int slot = 0;
|
||||
SFVALUE result = CreateFlashObject();
|
||||
|
||||
for ( int player = 1; player < MAX_PLAYERS; ++player )
|
||||
{
|
||||
if ( g_PR->IsConnected( player ) &&
|
||||
( cl_test_vote_scroll.GetBool() || !g_PR->IsFakePlayer( player ) ) &&
|
||||
GetLocalPlayerIndex() != player &&
|
||||
g_PR->GetTeam( player ) == g_PR->GetTeam( GetLocalPlayerIndex() ) )
|
||||
{
|
||||
player_info_t playerInfo;
|
||||
if ( engine->GetPlayerInfo( player, &playerInfo ) )
|
||||
{
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_SetMember( result, "count", slot );
|
||||
m_pScaleformUI->Params_SetResult( obj, result );
|
||||
|
||||
SafeReleaseSFVALUE( result );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::PopulateMapTargets( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
bool bIncludeCurrentMap = false;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) >= 1 )
|
||||
{
|
||||
bIncludeCurrentMap = pui->Params_GetArgAsBool( obj, 0 );
|
||||
}
|
||||
|
||||
SFVALUE result = CreateFlashObject();
|
||||
SFVALUE names = CreateFlashArray( MAX_TARGET_COUNT );
|
||||
SFVALUE ids = CreateFlashArray( MAX_TARGET_COUNT );
|
||||
|
||||
int numMaps = 0; //The number of maps in this cycle group
|
||||
int actualNumMaps = 0; //The number of maps we display (in case we have any errors)
|
||||
|
||||
if ( g_pGameTypes )
|
||||
{
|
||||
const char* mapGroupName = engine->GetMapGroupName();
|
||||
const CUtlStringList* mapsInGroup = g_pGameTypes->GetMapGroupMapList( mapGroupName );
|
||||
|
||||
if ( mapsInGroup )
|
||||
{
|
||||
numMaps = mapsInGroup->Count();
|
||||
char szCurLevel[MAX_PATH];
|
||||
V_strcpy_safe( szCurLevel, engine->GetLevelName() );
|
||||
V_FixSlashes(szCurLevel, '/' ); // use consistent slashes.
|
||||
V_StripExtension( szCurLevel, szCurLevel, sizeof( szCurLevel ) );
|
||||
for( int i = 0 ; i < numMaps ; ++i )
|
||||
{
|
||||
const char* internalMapName = (*mapsInGroup)[i];
|
||||
if ( !bIncludeCurrentMap && V_strstr( szCurLevel, V_GetFileName( internalMapName ) ) )
|
||||
{
|
||||
// don't populate the list with the same map that we're on
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( internalMapName && V_strcmp( "undefined", internalMapName ) != 0 && V_strlen( internalMapName ) > 0 )
|
||||
{
|
||||
const wchar_t* friendlyMapName = CSGameRules()->GetFriendlyMapName(internalMapName);
|
||||
|
||||
if ( friendlyMapName )
|
||||
{
|
||||
m_pScaleformUI->Value_SetArrayElement( names, actualNumMaps, friendlyMapName );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_SetArrayElement( names, actualNumMaps, internalMapName );
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_SetArrayElement( ids, actualNumMaps, internalMapName );
|
||||
|
||||
actualNumMaps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_SetMember( result, "friendlyNames", names );
|
||||
m_pScaleformUI->Value_SetMember( result, "names", ids );
|
||||
m_pScaleformUI->Value_SetMember( result, "count", actualNumMaps );
|
||||
m_pScaleformUI->Params_SetResult( obj, result );
|
||||
|
||||
SafeReleaseSFVALUE( names );
|
||||
SafeReleaseSFVALUE( ids );
|
||||
SafeReleaseSFVALUE( result );
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::PopulateBackupFilenames( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
engine->ServerCmd( "send_round_backup_file_list" );
|
||||
}
|
||||
|
||||
bool __MsgFunc_RoundBackupFilenames( const CCSUsrMsg_RoundBackupFilenames &msg )
|
||||
{
|
||||
|
||||
if ( SFHudCallVotePanel::m_pInstance )
|
||||
{
|
||||
SFHudCallVotePanel::m_pInstance->PopulateBackupFilenames_Callback( msg );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
USER_MESSAGE_REGISTER( RoundBackupFilenames );
|
||||
|
||||
void SFHudCallVotePanel::PopulateBackupFilenames_Callback( const CCSUsrMsg_RoundBackupFilenames &msg )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
return;
|
||||
|
||||
static CCSUsrMsg_RoundBackupFilenames files[ 10 ];
|
||||
|
||||
files[ clamp( msg.index(), 0, 9 ) ] = msg;
|
||||
|
||||
// don't do anything until we get the last file msg.
|
||||
if ( msg.index() < ( msg.count() - 1 ) )
|
||||
return;
|
||||
|
||||
char szCommaDelimitedFilenames[1024] = { 0 };
|
||||
char szCommaDelimitedNicenames[1024] = { 0 };
|
||||
|
||||
for ( int i = 0; i < min ( msg.count(), 10 ); i++ )
|
||||
{
|
||||
if ( *szCommaDelimitedFilenames )
|
||||
V_strcat_safe( szCommaDelimitedFilenames, "," );
|
||||
|
||||
V_strcat_safe( szCommaDelimitedFilenames, files[ i ].filename().c_str() );
|
||||
|
||||
if ( *szCommaDelimitedNicenames )
|
||||
V_strcat_safe( szCommaDelimitedNicenames, "," );
|
||||
|
||||
V_strcat_safe( szCommaDelimitedNicenames, files[ i ].nicename().c_str() );
|
||||
}
|
||||
|
||||
WITH_SFVALUEARRAY( data, 2 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, szCommaDelimitedFilenames );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, szCommaDelimitedNicenames );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "PopulateBackupFilenames_Callback", data, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::GetNumberOfValidMapsInGroup( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
bool bIncludeCurrentMap = false;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) >= 1 )
|
||||
{
|
||||
bIncludeCurrentMap = pui->Params_GetArgAsBool( obj, 0 );
|
||||
}
|
||||
|
||||
SFVALUE result = CreateFlashObject();
|
||||
|
||||
int numMaps = 0; //The number of maps in this cycle group
|
||||
int actualNumMaps = 0; //The number of maps we display (in case we have any errors)
|
||||
static ConVarRef sv_vote_to_changelevel_before_match_point( "sv_vote_to_changelevel_before_match_point" );
|
||||
|
||||
if ( g_pGameTypes && CSGameRules()
|
||||
&& !( sv_vote_to_changelevel_before_match_point.GetInt() > 0 && ( CSGameRules()->IsMatchPoint() || CSGameRules()->IsIntermission() ) ) )
|
||||
{
|
||||
const char* mapGroupName = engine->GetMapGroupName();
|
||||
const CUtlStringList* mapsInGroup = g_pGameTypes->GetMapGroupMapList( mapGroupName );
|
||||
|
||||
if ( mapsInGroup )
|
||||
{
|
||||
numMaps = mapsInGroup->Count();
|
||||
|
||||
for( int i = 0 ; i < numMaps ; ++i )
|
||||
{
|
||||
const char* internalMapName = ( *mapsInGroup )[i];
|
||||
if ( !bIncludeCurrentMap && 0 == V_strcmp( engine->GetLevelNameShort(), internalMapName ) )
|
||||
{
|
||||
// don't populate the list with the same map that we're on
|
||||
continue;
|
||||
}
|
||||
else if ( internalMapName && V_strlen( internalMapName ) > 0 )
|
||||
{
|
||||
actualNumMaps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_SetMember( result, "count", actualNumMaps );
|
||||
m_pScaleformUI->Params_SetResult( obj, result );
|
||||
SafeReleaseSFVALUE( result );
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::IsQueuedMatchmaking( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
bool bQ = CSGameRules() && CSGameRules()->IsQueuedMatchmaking();
|
||||
|
||||
m_pScaleformUI->Params_SetResult( obj, bQ );
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::IsEndMatchMapVoteEnabled( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
bool bY = false;
|
||||
|
||||
C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
|
||||
if ( cs_PR && CSGameRules()->IsEndMatchVotingForNextMapEnabled() )
|
||||
bY = true;
|
||||
|
||||
m_pScaleformUI->Params_SetResult( obj, bY );
|
||||
}
|
||||
|
||||
void SFHudCallVotePanel::IsPlayingClassicCompetitive( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_pScaleformUI->Params_SetResult( obj, ( CSGameRules() && CSGameRules()->IsPlayingAnyCompetitiveStrictRuleset() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,50 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDCALLVOTEPANEL_H
|
||||
#define SFHUDCALLVOTEPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif //_WIN32
|
||||
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
#define MAX_TARGET_COUNT 10
|
||||
#define CALLVOTE_NAME_TRUNCATE_AT 16 // number of name character displayed before truncation
|
||||
|
||||
class SFHudCallVotePanel: public ScaleformFlashInterface
|
||||
{
|
||||
public:
|
||||
static SFHudCallVotePanel *m_pInstance;
|
||||
|
||||
SFHudCallVotePanel();
|
||||
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void PopulatePlayerTargets( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void PopulateMapTargets( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void PopulateBackupFilenames( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void PopulateBackupFilenames_Callback( const CCSUsrMsg_RoundBackupFilenames &msg );
|
||||
void GetNumberOfValidMapsInGroup( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetNumberOfValidKickTargets( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void IsQueuedMatchmaking( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void IsEndMatchMapVoteEnabled( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void IsPlayingClassicCompetitive( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SFHUDCALLVOTEPANEL_H
|
||||
@@ -0,0 +1,332 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements to indicate damage taken
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhuddamageindicator.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "text_message.h"
|
||||
#include "hud_macros.h"
|
||||
#include "view.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
#include "sfhudreticle.h"
|
||||
#include "hltvcamera.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudDamageIndicator );
|
||||
DECLARE_HUD_MESSAGE( SFHudDamageIndicator, Damage );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudDamageIndicator, DamageIndicatorModule );
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
// [jason] Globals, extracted from the vgui version of the damage indicators. Comments are my own:
|
||||
|
||||
static float g_FadeScale = 2.f; // scale applied to delta-seconds to control the fade of the direction dmg indicators
|
||||
static float g_StartFadeThreshold = 0.4f; // scale at which the directional dmg indicator begins to auto-fade out (controlled entirely in Flash); used to be the point where it became invisible in VGui
|
||||
static float g_DetectDamageTakenInterval = 1.0f; // (in seconds) - if you haven't received new damage at least this recently, all direction indicators fade out at this point
|
||||
static float g_CloseDamageDistance = 50.f; // (in world units) - if damage received is closer than this to player, all directions light up
|
||||
static float g_DirectionDotTolerance = 0.3f; // incoming dmg direction dot product must be > this value in order for damage to be "from" this direction
|
||||
|
||||
|
||||
SFHudDamageIndicator::SFHudDamageIndicator( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_flAttackFront(0.f),
|
||||
m_flAttackRear(0.f),
|
||||
m_flAttackLeft(0.f),
|
||||
m_flAttackRight(0.f),
|
||||
m_flFadeCompleteTime(0.f),
|
||||
m_lastFrameTime(0.f)
|
||||
{
|
||||
SetHiddenBits( HIDEHUD_HEALTH );
|
||||
HOOK_HUD_MESSAGE( SFHudDamageIndicator, Damage );
|
||||
}
|
||||
|
||||
SFHudDamageIndicator::~SFHudDamageIndicator()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::IndicateDamage( DamageDirection dmgDir, float newPercentage )
|
||||
{
|
||||
if ( m_bActive && m_FlashAPI )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, dmgDir );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, newPercentage );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showDamageDirection", data, 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::HideAll( void )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hideAll", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define UPDATE_DIR_DAMAGE( dirValue, dirEnum ) \
|
||||
if ( dirValue > 0.f ) \
|
||||
{ \
|
||||
dirValue = MAX( 0.f, dirValue - flFade ); \
|
||||
if ( dirValue > g_StartFadeThreshold ) \
|
||||
{ \
|
||||
IndicateDamage( dirEnum, dirValue ); \
|
||||
} \
|
||||
else \
|
||||
{ /* start auto-fade at this level */ \
|
||||
dirValue = 0.f; \
|
||||
IndicateDamage( dirEnum, -1.f ); \
|
||||
} \
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::ProcessInput( void )
|
||||
{
|
||||
if ( m_flFadeCompleteTime > gpGlobals->curtime )
|
||||
{
|
||||
// We have recent damage information, propagate it to all damage directions:
|
||||
float flFade = ( gpGlobals->curtime - m_lastFrameTime ) * g_FadeScale;
|
||||
|
||||
UPDATE_DIR_DAMAGE( m_flAttackFront, SFDD_DamageUp );
|
||||
UPDATE_DIR_DAMAGE( m_flAttackRear, SFDD_DamageDown );
|
||||
UPDATE_DIR_DAMAGE( m_flAttackLeft, SFDD_DamageLeft );
|
||||
UPDATE_DIR_DAMAGE( m_flAttackRight, SFDD_DamageRight );
|
||||
}
|
||||
else
|
||||
{
|
||||
// We haven't received recent damage info, so begin to fade out all dmg directions
|
||||
if ( m_flAttackFront > 0.f ||
|
||||
m_flAttackRear > 0.f ||
|
||||
m_flAttackLeft > 0.f ||
|
||||
m_flAttackRight > 0.f )
|
||||
{
|
||||
m_flAttackFront = 0.0f;
|
||||
m_flAttackRear = 0.0f;
|
||||
m_flAttackRight = 0.0f;
|
||||
m_flAttackLeft = 0.0f;
|
||||
|
||||
// -1 causes all damage directions to fade down to zero from their current levels
|
||||
IndicateDamage( SFDD_DamageTotal, -1.f );
|
||||
}
|
||||
}
|
||||
|
||||
m_lastFrameTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::FlashReady( void )
|
||||
{
|
||||
// hide everything initially
|
||||
HideAll();
|
||||
}
|
||||
|
||||
bool SFHudDamageIndicator::PreUnloadFlash( void )
|
||||
{
|
||||
// $TODO: Anything to release?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudDamageIndicator, this, DamageIndicatorModule );
|
||||
}
|
||||
else
|
||||
{
|
||||
// When initially loaded, hide all indicators
|
||||
HideAll();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudDamageIndicator::Reset( void )
|
||||
{
|
||||
m_flAttackFront = 0.0f;
|
||||
m_flAttackRear = 0.0f;
|
||||
m_flAttackRight = 0.0f;
|
||||
m_flAttackLeft = 0.0f;
|
||||
m_flFadeCompleteTime = 0.0f;
|
||||
|
||||
HideAll();
|
||||
}
|
||||
|
||||
bool SFHudDamageIndicator::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
return cl_drawhud.GetBool() && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudDamageIndicator::SetActive( bool bActive )
|
||||
{
|
||||
if ( m_bActive && !bActive )
|
||||
{
|
||||
HideAll();
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Message handler for Damage message
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SFHudDamageIndicator::MsgFunc_Damage( const CCSUsrMsg_Damage &msg )
|
||||
{
|
||||
|
||||
C_BasePlayer *pVictimPlayer = NULL;
|
||||
if ( g_bEngineIsHLTV )
|
||||
{
|
||||
// Only show damage indicator for the player we are currently observing.
|
||||
if ( HLTVCamera()->GetMode() != OBS_MODE_IN_EYE )
|
||||
return true;
|
||||
|
||||
C_BaseEntity* pTarget = HLTVCamera()->GetPrimaryTarget();
|
||||
if ( !pTarget || !pTarget->IsPlayer() || pTarget->entindex() != msg.victim_entindex() )
|
||||
return true;
|
||||
|
||||
// This cast is safe because pTarget->IsPlayer() returned true above
|
||||
pVictimPlayer = static_cast< C_BasePlayer* >( pTarget );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( C_BasePlayer::GetLocalPlayer()->entindex() == msg.victim_entindex() );
|
||||
pVictimPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
}
|
||||
|
||||
|
||||
int damageTaken = msg.amount();
|
||||
|
||||
if ( damageTaken > 0 )
|
||||
{
|
||||
Vector vecFrom;
|
||||
vecFrom.x = msg.inflictor_world_pos().x();
|
||||
vecFrom.y = msg.inflictor_world_pos().y();
|
||||
vecFrom.z = msg.inflictor_world_pos().z();
|
||||
|
||||
m_flFadeCompleteTime = gpGlobals->curtime + g_DetectDamageTakenInterval;
|
||||
CalcDamageDirection( vecFrom, pVictimPlayer );
|
||||
|
||||
// If we are using a Steam Controller, do haptics on the Steam Controller
|
||||
// to indicate getting hit.
|
||||
if ( g_pInputSystem->IsSteamControllerActive() && steamapicontext->SteamController() )
|
||||
{
|
||||
static ConVarRef steam_controller_haptics( "steam_controller_haptics" );
|
||||
if ( steam_controller_haptics.GetBool() )
|
||||
{
|
||||
ControllerHandle_t handles[MAX_STEAM_CONTROLLERS];
|
||||
int nControllers = steamapicontext->SteamController()->GetConnectedControllers( handles );
|
||||
|
||||
for ( int i = 0; i < nControllers; ++i )
|
||||
{
|
||||
float flLeft = m_flAttackLeft + m_flAttackFront*0.5 + m_flAttackRear*0.5;
|
||||
float flRight = m_flAttackRight + m_flAttackFront*0.5 + m_flAttackRear*0.5;
|
||||
float flTotal = flLeft + flRight;
|
||||
if ( flTotal > 0.0 )
|
||||
{
|
||||
flLeft /= flTotal;
|
||||
flRight /= flTotal;
|
||||
if ( flRight > 0 )
|
||||
{
|
||||
steamapicontext->SteamController()->TriggerHapticPulse( handles[ i ], k_ESteamControllerPad_Right, 2000*flRight );
|
||||
}
|
||||
|
||||
if ( flLeft > 0 )
|
||||
{
|
||||
steamapicontext->SteamController()->TriggerHapticPulse( handles[ i ], k_ESteamControllerPad_Left, 2000*flLeft );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// [jason] This code is duplicated from cs_hud_damageindicator.cpp:
|
||||
void SFHudDamageIndicator::CalcDamageDirection( const Vector &vecFrom, C_BasePlayer *pVictimPlayer )
|
||||
{
|
||||
// I assume this is done to detect damage from world (falling) and not display
|
||||
// an indicator for this. Old code was zeroing all indicator values here which caused
|
||||
// a bug if we were currently in mid-fade for a previous damage source.
|
||||
if ( vecFrom == vec3_origin )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !pVictimPlayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vecDelta = ( vecFrom - pVictimPlayer->GetRenderOrigin() );
|
||||
|
||||
if ( vecDelta.Length() <= g_CloseDamageDistance )
|
||||
{
|
||||
m_flAttackFront = 1.0f;
|
||||
m_flAttackRear = 1.0f;
|
||||
m_flAttackRight = 1.0f;
|
||||
m_flAttackLeft = 1.0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VectorNormalize( vecDelta );
|
||||
|
||||
Vector forward;
|
||||
Vector right;
|
||||
AngleVectors( MainViewAngles( GET_ACTIVE_SPLITSCREEN_SLOT() ), &forward, &right, NULL );
|
||||
|
||||
float flFront = DotProduct( vecDelta, forward );
|
||||
float flSide = DotProduct( vecDelta, right );
|
||||
|
||||
if ( flFront > 0 )
|
||||
{
|
||||
if ( flFront > g_DirectionDotTolerance )
|
||||
m_flAttackFront = MAX( m_flAttackFront, flFront );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( flFront );
|
||||
if ( f > g_DirectionDotTolerance )
|
||||
m_flAttackRear = MAX( m_flAttackRear, f );
|
||||
}
|
||||
|
||||
if ( flSide > 0 )
|
||||
{
|
||||
if ( flSide > g_DirectionDotTolerance )
|
||||
m_flAttackRight = MAX( m_flAttackRight, flSide );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( flSide );
|
||||
if ( f > g_DirectionDotTolerance )
|
||||
m_flAttackLeft = MAX( m_flAttackLeft, f );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements to indicate damage taken
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SFHUDDAMAGEINDICATOR_H_
|
||||
#define SFHUDDAMAGEINDICATOR_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
class SFHudDamageIndicator : public SFHudFlashInterface
|
||||
{
|
||||
enum DamageDirection
|
||||
{
|
||||
SFDD_DamageUp = 0,
|
||||
SFDD_DamageDown,
|
||||
SFDD_DamageLeft,
|
||||
SFDD_DamageRight,
|
||||
|
||||
SFDD_DamageTotal, // also means turn on damage from all directions
|
||||
SFDD_DamageFirst = SFDD_DamageUp
|
||||
};
|
||||
|
||||
public:
|
||||
explicit SFHudDamageIndicator( const char *value );
|
||||
virtual ~SFHudDamageIndicator();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
virtual void Reset( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
// Handler for our message
|
||||
bool MsgFunc_Damage( const CCSUsrMsg_Damage &msg );
|
||||
|
||||
CUserMessageBinder m_UMCMsgDamage;
|
||||
|
||||
protected:
|
||||
void IndicateDamage( DamageDirection dmgDir, float newPercentage );
|
||||
void HideAll( void );
|
||||
|
||||
private:
|
||||
void CalcDamageDirection( const Vector &vecFrom, C_BasePlayer *pVictimPlayer );
|
||||
|
||||
protected:
|
||||
|
||||
float m_lastFrameTime;
|
||||
|
||||
// Parameters copied from cs_hud_damageindicator:
|
||||
float m_flAttackFront;
|
||||
float m_flAttackRear;
|
||||
float m_flAttackLeft;
|
||||
float m_flAttackRight;
|
||||
float m_flFadeCompleteTime; //don't draw past this time
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDINFOPANEL_H_ */
|
||||
@@ -0,0 +1,26 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#if !defined( SFHUDFLASHINTERFACE_H_ )
|
||||
#define SFHUDFLASHINTERFACE_H_
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
class SFHudFlashInterface : public ScaleformFlashInterfaceMixin<CHudElement>
|
||||
{
|
||||
public:
|
||||
explicit SFHudFlashInterface( const char* name ) : ScaleformFlashInterfaceMixin<CHudElement>()
|
||||
{
|
||||
InitCHudElementAfterConstruction( name );
|
||||
}
|
||||
|
||||
virtual bool ShouldProcessInputBeforeFlashApiReady() { return false; }
|
||||
};
|
||||
|
||||
extern ConVar cl_drawhud;
|
||||
|
||||
#endif // SHHUDFLASHINTERFACE_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,102 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDFREEZEPANEL_H
|
||||
#define SFHUDFREEZEPANEL_H
|
||||
#pragma once
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "ehandle.h"
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "ammodef.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
bool IsTakingAFreezecamScreenshot( void );
|
||||
|
||||
#define FREEZE_PANEL_NAME_TRUNCATE_AT_SHORT 10 // number of name character displayed before truncation
|
||||
#define FREEZE_PANEL_NAME_TRUNCATE_AT_LONG 16 // number of name character displayed before truncation
|
||||
|
||||
class SFHudFreezePanel: public SFHudFlashInterface, public IShaderDeviceDependentObject
|
||||
{
|
||||
public:
|
||||
explicit SFHudFreezePanel( const char *value );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual void ShowPanel( bool bShow );
|
||||
virtual void ShowCancelPanel( bool bShow );
|
||||
virtual bool IsVisible( void ) { return m_bIsVisible; }
|
||||
virtual void OnTimeJump( void ) OVERRIDE;
|
||||
void ResetDamageText( int iPlayerIndexKiller, int iPlayerIndexVictim );
|
||||
void OnHltvReplayButtonStateChanged( void );
|
||||
|
||||
virtual void DeviceLost( void ) { }
|
||||
virtual void DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd );
|
||||
virtual void ScreenSizeChanged( int width, int height ) { }
|
||||
|
||||
bool IsHoldingAfterScreenShot( void ) { return m_bHoldingAfterScreenshot; }
|
||||
void TakeFreezeShot( void );
|
||||
|
||||
enum DominationIconType
|
||||
{
|
||||
None,
|
||||
Nemesis,
|
||||
Revenge,
|
||||
DominationIconMax
|
||||
};
|
||||
|
||||
private:
|
||||
void PopulateDominationInfo( DominationIconType iconType, const char* localizationToken1, const char* localizationToken2, wchar_t *szWeaponHTML );
|
||||
void PopulateWeaponInfo( wchar_t *szWeaponName );
|
||||
void PopulateNavigationText( void );
|
||||
void SetIcon( DominationIconType iconType );
|
||||
void ProcessInput( void );
|
||||
void PositionPanel( void );
|
||||
|
||||
ISFTextObject* m_dominationIcons[DominationIconMax];
|
||||
ISFTextObject* m_dominationText1;
|
||||
ISFTextObject* m_dominationText2;
|
||||
ISFTextObject* m_killerName;
|
||||
ISFTextObject* m_navigationText;
|
||||
|
||||
ISFTextObject* m_weaponInfoText1;
|
||||
ISFTextObject* m_weaponInfoText2;
|
||||
|
||||
ISFTextObject* m_ssDescText;
|
||||
ISFTextObject* m_ssNameText;
|
||||
|
||||
SFVALUE m_freezePanel;
|
||||
SFVALUE m_ssFreezePanel;
|
||||
|
||||
int m_PosX;
|
||||
int m_PosY;
|
||||
CHandle< CBaseEntity > m_FollowEntity;
|
||||
int m_iKillerIndex;
|
||||
|
||||
const char *GetFilesafePlayerName( const char *pszOldName );
|
||||
bool m_bHoldingAfterScreenshot;
|
||||
|
||||
bool m_bDominationIconVisible;
|
||||
bool m_bIsVisible;
|
||||
bool m_bIsCancelPanelVisible;
|
||||
bool m_bFreezePanelStateRelevant; // flag showing if the information in the freeze panel is relevant and it makes sense to show, tracks show_freezepanel and hide_freezepanel events from the game; the panel may still be hidden sometimes (like before autoreplay) to avoid confusing the player (e.g. right before autoplay kicks in and there's not enough time to virually process it for a human being), even if the information in there is relevant
|
||||
|
||||
};
|
||||
|
||||
#endif // SFHUDFREEZEPANEL_H
|
||||
@@ -0,0 +1,367 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. =============================//
|
||||
//
|
||||
// Purpose: Purpose: Displays HUD elements about armor, current weapon, ammo, and TR weapon progress
|
||||
//
|
||||
//======================================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "iclientmode.h"
|
||||
#include "view.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "ivrenderview.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudhealtharmorpanel.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 SAFECALL( handle, func ) \
|
||||
if ( handle ) \
|
||||
{ \
|
||||
func \
|
||||
}
|
||||
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudHealthArmorPanel );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudHealthArmorPanel, HealthArmorModule ); // Asset named WeaponModule to maintain consistency with Flash file naming
|
||||
|
||||
// global tunables
|
||||
const float g_LowHealthPercent = 0.20f;
|
||||
const float g_HealthFlashSeconds = 1.0f;
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
SFHudHealthArmorPanel::SFHudHealthArmorPanel( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_PanelHandle( NULL ),
|
||||
m_HealthTextHandle( NULL ),
|
||||
m_HealthTextHandleRed( NULL ),
|
||||
m_ArmorTextHandle( NULL ),
|
||||
m_HealthBarHandle( NULL ),
|
||||
m_HealthRedBarHandle( NULL ),
|
||||
m_HealthPanel( NULL ),
|
||||
m_HealthPanelRed( NULL ),
|
||||
m_HealthPanelRedSmall( NULL ),
|
||||
m_PrevHealth( -1 ),
|
||||
m_PrevArmor( -1 ),
|
||||
m_PrevHasHelmet( false ),
|
||||
m_PrevHasHeavyArmor( false )
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD );
|
||||
|
||||
m_HealthFlashTimer.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
SFHudHealthArmorPanel::~SFHudHealthArmorPanel()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::ShowPanel( bool value )
|
||||
{
|
||||
if ( !m_pScaleformUI )
|
||||
return;
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
if ( value )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showNow", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hideNow", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// This forces the health and armor bars to reset
|
||||
m_PrevHealth = -1;
|
||||
m_PrevArmor = -1;
|
||||
m_PrevHasHelmet = false;
|
||||
m_PrevHasHeavyArmor = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::SetVisible( bool bVisible )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, bVisible );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setVisible", data, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::LockSlot( bool wantItLocked, bool& currentlyLocked )
|
||||
{
|
||||
if ( currentlyLocked != wantItLocked )
|
||||
{
|
||||
if ( wantItLocked )
|
||||
{
|
||||
LockScaleformSlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnlockScaleformSlot();
|
||||
}
|
||||
|
||||
currentlyLocked = wantItLocked;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::ProcessInput( void )
|
||||
{
|
||||
// Update stats
|
||||
int realHealth = 0;
|
||||
int realArmor = 0;
|
||||
float healthPercent = 0.0f;
|
||||
float armorPercent = 0.0f;
|
||||
bool bHasHelmet = false;
|
||||
bool bHasHeavyArmor = false;
|
||||
|
||||
// Collect all player, weapon and game state data first:
|
||||
|
||||
C_CSPlayer *pPlayer = GetHudPlayer();
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
realHealth = MAX( pPlayer->GetHealth(), 0 );
|
||||
|
||||
realArmor = MAX( pPlayer->ArmorValue(), 0 );
|
||||
|
||||
healthPercent = ( ( float )realHealth / ( float )pPlayer->GetMaxHealth() );
|
||||
|
||||
// HACK (for now)
|
||||
float flMaxArmor = pPlayer->HasHeavyArmor() ? 200 : 100;
|
||||
|
||||
armorPercent = ( ( float )realArmor / ( float )flMaxArmor );
|
||||
|
||||
bHasHelmet = pPlayer->HasHelmet();
|
||||
bHasHeavyArmor = pPlayer->HasHeavyArmor();
|
||||
}
|
||||
|
||||
// Updating flash, slot locking begins...
|
||||
bool bSlotIsLocked = false;
|
||||
char cNewStr[ 128 ];
|
||||
|
||||
// Update health and which color health bar to draw
|
||||
if ( m_PrevHealth != realHealth )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
V_snprintf( cNewStr, sizeof( cNewStr ), "%d", realHealth );
|
||||
SAFECALL( m_HealthTextHandle, m_pScaleformUI->Value_SetText( m_HealthTextHandle, cNewStr ); );
|
||||
SAFECALL( m_HealthTextHandleRed, m_pScaleformUI->Value_SetText( m_HealthTextHandleRed, cNewStr ); );
|
||||
|
||||
bool bTurnHealthRed = false;
|
||||
|
||||
// if our health has decreased...
|
||||
if ( realHealth < m_PrevHealth )
|
||||
{
|
||||
bTurnHealthRed = true;
|
||||
|
||||
if ( healthPercent <= g_LowHealthPercent )
|
||||
{
|
||||
// Turn a steady red, turn off the color restoring timer
|
||||
m_HealthFlashTimer.Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Flash red briefly, set a timer to restore color later
|
||||
m_HealthFlashTimer.Start( g_HealthFlashSeconds );
|
||||
}
|
||||
}
|
||||
|
||||
SAFECALL( m_HealthPanel, m_pScaleformUI->Value_SetVisible( m_HealthPanel, !( healthPercent <= g_LowHealthPercent ) ); );
|
||||
|
||||
ConVarRef cl_hud_healthammo_style( "cl_hud_healthammo_style" );
|
||||
SAFECALL( m_HealthPanelRed, m_pScaleformUI->Value_SetVisible( m_HealthPanelRed, cl_hud_healthammo_style.GetInt() == 0 ? ( healthPercent <= g_LowHealthPercent ) : false ); );
|
||||
SAFECALL( m_HealthPanelRedSmall, m_pScaleformUI->Value_SetVisible( m_HealthPanelRedSmall, cl_hud_healthammo_style.GetInt( ) == 1 ? ( healthPercent <= g_LowHealthPercent ) : false ); );
|
||||
|
||||
SAFECALL( m_HealthBarHandle, m_pScaleformUI->Value_SetVisible( m_HealthBarHandle, !bTurnHealthRed ); );
|
||||
SAFECALL( m_HealthRedBarHandle, m_pScaleformUI->Value_SetVisible( m_HealthRedBarHandle, bTurnHealthRed ); );
|
||||
|
||||
SAFECALL( m_HealthTextHandle, m_pScaleformUI->Value_SetVisible( m_HealthTextHandle, !bTurnHealthRed ); );
|
||||
SAFECALL( m_HealthTextHandleRed, m_pScaleformUI->Value_SetVisible( m_HealthTextHandleRed, bTurnHealthRed ); );
|
||||
}
|
||||
|
||||
|
||||
// When timer elapses, restore the standard health bar color
|
||||
if ( m_HealthFlashTimer.HasStarted() && m_HealthFlashTimer.IsElapsed() )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
m_HealthFlashTimer.Invalidate();
|
||||
|
||||
SAFECALL( m_HealthBarHandle, m_pScaleformUI->Value_SetVisible( m_HealthBarHandle, true ); );
|
||||
SAFECALL( m_HealthRedBarHandle, m_pScaleformUI->Value_SetVisible( m_HealthRedBarHandle, false ); );
|
||||
|
||||
SAFECALL( m_HealthTextHandle, m_pScaleformUI->Value_SetVisible( m_HealthTextHandle, true ); );
|
||||
SAFECALL( m_HealthTextHandleRed, m_pScaleformUI->Value_SetVisible( m_HealthTextHandleRed, false ); );
|
||||
}
|
||||
|
||||
|
||||
// Update armor display
|
||||
// $TODO: update the icon to reflect the type of armor, per design?
|
||||
if ( m_PrevArmor != realArmor )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
V_snprintf( cNewStr, sizeof( cNewStr ), "%d", realArmor);
|
||||
SAFECALL( m_ArmorTextHandle, m_pScaleformUI->Value_SetText( m_ArmorTextHandle, cNewStr ); );
|
||||
}
|
||||
|
||||
|
||||
// Update the health/armor bar lengths
|
||||
if ( ( m_PrevHealth != realHealth ) ||
|
||||
( m_PrevArmor != realArmor ) ||
|
||||
( m_PrevHasHelmet != bHasHelmet ) ||
|
||||
( m_PrevHasHeavyArmor != bHasHeavyArmor ) )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
WITH_SFVALUEARRAY( data, 6 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, realHealth );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, clamp( int(healthPercent*100), 1, 100 ) );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 2, clamp( realArmor, 1, 100 ) );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 3, clamp( int(armorPercent*100), 1, 100 ) );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 4, bHasHelmet );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 5, bHasHeavyArmor );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "updateValues", data, 6 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_PrevHealth = realHealth;
|
||||
m_PrevArmor = realArmor;
|
||||
m_PrevHasHelmet = bHasHelmet;
|
||||
m_PrevHasHeavyArmor = bHasHeavyArmor;
|
||||
|
||||
LockSlot( false, bSlotIsLocked );
|
||||
}
|
||||
|
||||
static void GetTextBoxForElement( IScaleformUI *pScaleformUI, SFVALUE root, const char *elementName, const char *textElementName, SFVALUE &sfv )
|
||||
{
|
||||
SFVALUE TempHandle = pScaleformUI->Value_GetMember( root, elementName );
|
||||
|
||||
if ( TempHandle )
|
||||
{
|
||||
sfv = pScaleformUI->Value_GetMember( TempHandle, textElementName );
|
||||
pScaleformUI->ReleaseValue( TempHandle );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::FlashReady( void )
|
||||
{
|
||||
m_PanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanel" );
|
||||
|
||||
if ( m_PanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_PanelHandle, "HealthArmorPanel" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "Armor", "TextBox", m_ArmorTextHandle );
|
||||
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "Health", "TextBox", m_HealthTextHandle );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "HealthRed", "TextBox", m_HealthTextHandleRed );
|
||||
|
||||
m_HealthPanel = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "HealthPanel" );
|
||||
m_HealthPanelRed = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "HealthPanelRed" );
|
||||
m_HealthPanelRedSmall = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "HealthPanelRed_small" );
|
||||
|
||||
SAFECALL( m_HealthPanelRed, m_pScaleformUI->Value_SetVisible( m_HealthPanelRed, false ); );
|
||||
SAFECALL( m_HealthPanelRedSmall, m_pScaleformUI->Value_SetVisible( m_HealthPanelRedSmall, false ); );
|
||||
|
||||
SFVALUE HealthPanelHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "HealthBar" );
|
||||
|
||||
if ( HealthPanelHandle )
|
||||
{
|
||||
m_HealthBarHandle = m_pScaleformUI->Value_GetMember( HealthPanelHandle, "HealthBar" );
|
||||
m_HealthRedBarHandle = m_pScaleformUI->Value_GetMember( HealthPanelHandle, "HealthBarRed" );
|
||||
|
||||
SafeReleaseSFVALUE( HealthPanelHandle );
|
||||
}
|
||||
|
||||
SafeReleaseSFVALUE( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
// hide everything initially
|
||||
SetVisible( false );
|
||||
}
|
||||
|
||||
bool SFHudHealthArmorPanel::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_PanelHandle );
|
||||
SafeReleaseSFVALUE( m_HealthTextHandle );
|
||||
SafeReleaseSFVALUE( m_HealthTextHandleRed );
|
||||
SafeReleaseSFVALUE( m_ArmorTextHandle );
|
||||
SafeReleaseSFVALUE( m_HealthBarHandle );
|
||||
SafeReleaseSFVALUE( m_HealthRedBarHandle );
|
||||
SafeReleaseSFVALUE( m_HealthPanel );
|
||||
SafeReleaseSFVALUE( m_HealthPanelRed );
|
||||
SafeReleaseSFVALUE( m_HealthPanelRedSmall );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudHealthArmorPanel, this, HealthArmorModule );
|
||||
}
|
||||
else
|
||||
{
|
||||
// When initially loaded, hide this panel
|
||||
SetVisible( false );
|
||||
}
|
||||
|
||||
// Reset all transient data
|
||||
m_PrevHealth = -1;
|
||||
m_PrevArmor = -1;
|
||||
m_PrevHasHelmet = false;
|
||||
m_HealthFlashTimer.Invalidate();
|
||||
}
|
||||
|
||||
void SFHudHealthArmorPanel::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudHealthArmorPanel::ShouldDraw( void )
|
||||
{
|
||||
return cl_drawhud.GetBool() && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudHealthArmorPanel::SetActive( bool bActive )
|
||||
{
|
||||
if ( bActive != m_bActive )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ==================//
|
||||
//
|
||||
// Purpose: Displays HUD elements about armor, current weapon, ammo, and TR weapon progress
|
||||
//
|
||||
//===========================================================================================//
|
||||
#ifndef SFHUDHEALTHARMORPANEL_H_
|
||||
#define SFHUDHEALTHARMORPANEL_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
|
||||
class SFHudHealthArmorPanel : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudHealthArmorPanel( const char *value );
|
||||
virtual ~SFHudHealthArmorPanel();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
virtual void Init( void ) { SetVisible( true ); }
|
||||
virtual void Reset( void ) { SetVisible( true ); }
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
protected:
|
||||
void ShowPanel( bool value );
|
||||
void SetVisible( bool bVisible );
|
||||
void LockSlot( bool wantItLocked, bool& currentlyLocked );
|
||||
|
||||
protected:
|
||||
SFVALUE m_PanelHandle;
|
||||
SFVALUE m_HealthPanel;
|
||||
SFVALUE m_HealthPanelRed;
|
||||
SFVALUE m_HealthPanelRedSmall;
|
||||
SFVALUE m_HealthTextHandle;
|
||||
SFVALUE m_HealthTextHandleRed;
|
||||
SFVALUE m_ArmorTextHandle;
|
||||
SFVALUE m_HealthBarHandle;
|
||||
SFVALUE m_HealthRedBarHandle;
|
||||
|
||||
int m_PrevHealth;
|
||||
int m_PrevArmor;
|
||||
bool m_PrevHasHelmet;
|
||||
bool m_PrevHasHeavyArmor;
|
||||
|
||||
CountdownTimer m_HealthFlashTimer;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDHEALTHARMORPANEL_H_ */
|
||||
@@ -0,0 +1,873 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements for medals/achievements, and hint text
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "iclientmode.h"
|
||||
#include "view.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "ivrenderview.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudinfopanel.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "text_message.h"
|
||||
#include "hud_macros.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "fmtstr.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
|
||||
#include "bannedwords.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudInfoPanel );
|
||||
|
||||
DECLARE_HUD_MESSAGE( SFHudInfoPanel, HintText );
|
||||
DECLARE_HUD_MESSAGE( SFHudInfoPanel, KeyHintText );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudInfoPanel, HelpAchievementModule ); // Asset named HelpAchievementModule to maintain consistency with Flash file naming
|
||||
|
||||
// global tunables for this panel
|
||||
static float g_HintDisplayTime = 6.f;
|
||||
static float g_MedalDisplayTime = 5.f;
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
SFHudInfoPanel::SFHudInfoPanel( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_HelpPanelHandle(NULL),
|
||||
m_HelpBodyTextHandle(NULL),
|
||||
m_MedalPanelHandle(NULL),
|
||||
m_MedalTitleTextHandle(NULL),
|
||||
m_MedalBodyTextHandle(NULL),
|
||||
m_DefusePanelHandle(NULL),
|
||||
m_DefuseTitleTextHandle(NULL),
|
||||
m_DefuseBodyTextHandle(NULL),
|
||||
m_DefuseIconKit( NULL ),
|
||||
m_DefuseIconNoKit( NULL ),
|
||||
m_DefuseTimerTextHandle(NULL),
|
||||
m_PriorityMessagePanelHandle(NULL),
|
||||
m_PriorityMessageTitleTextHandle(NULL),
|
||||
m_PriorityMessageBodyTextHandle(NULL),
|
||||
m_activeAchievement(CSInvalidAchievement),
|
||||
m_PreviousDefusePercent(-1.0f),
|
||||
m_bDeferRaiseHelpPanel(false),
|
||||
m_bHintPanelHidden( false ),
|
||||
m_bDeferRaisePriorityMessagePanel(false),
|
||||
m_bIsVisible(false)
|
||||
{
|
||||
HOOK_HUD_MESSAGE( SFHudInfoPanel, HintText );
|
||||
HOOK_HUD_MESSAGE( SFHudInfoPanel, KeyHintText );
|
||||
SetHiddenBits( HIDEHUD_MISCSTATUS );
|
||||
|
||||
m_HintDisplayTimer.Invalidate();
|
||||
m_AchievementDisplayTimer.Invalidate();
|
||||
m_PriorityMsgDisplayTimer.Invalidate();
|
||||
}
|
||||
|
||||
SFHudInfoPanel::~SFHudInfoPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::ShowPanel( HUDINFO_TYPE panelType, bool value )
|
||||
{
|
||||
if ( m_bActive && m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ShowPanelNoLock( panelType, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Caution! If you call this from code that isn't wrapped with Slot Locks, you will run into run-time multi-threading issues!
|
||||
void SFHudInfoPanel::ShowPanelNoLock( HUDINFO_TYPE panelType, bool value )
|
||||
{
|
||||
if ( m_bActive && FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, panelType );
|
||||
|
||||
if ( value )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", data, 1 );
|
||||
m_bIsVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( panelType == SFHUDINFO_PriorityMessage ||
|
||||
panelType == SFHUDINFO_Help )
|
||||
{
|
||||
STEAMWORKS_TESTSECRET_AMORTIZE( 149 );
|
||||
}
|
||||
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", data, 1 );
|
||||
m_bIsVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the flags so that panels will be raised once this HUD element is visible and loaded
|
||||
if ( value )
|
||||
{
|
||||
if ( panelType == SFHUDINFO_Help )
|
||||
{
|
||||
m_bDeferRaiseHelpPanel = true;
|
||||
}
|
||||
else if ( panelType == SFHUDINFO_PriorityMessage )
|
||||
{
|
||||
m_bDeferRaisePriorityMessagePanel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::HideAll( void )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hideAll", NULL, 0 );
|
||||
}
|
||||
m_bIsVisible = false;
|
||||
|
||||
// Reset the defuse percent so that we detect the defuse panel needs to be shown again when we un-hide this HUD element
|
||||
m_PreviousDefusePercent = -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::LockSlot( bool wantItLocked, bool& currentlyLocked )
|
||||
{
|
||||
if ( currentlyLocked != wantItLocked )
|
||||
{
|
||||
if ( wantItLocked )
|
||||
{
|
||||
LockScaleformSlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnlockScaleformSlot();
|
||||
}
|
||||
|
||||
currentlyLocked = wantItLocked;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::ProcessInput( void )
|
||||
{
|
||||
// Collect information about defuse progress
|
||||
float DefusePercent = -1.0f;
|
||||
int DefuseTimeRemaining = -1;
|
||||
bool bDefuseCanceled = false;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
bool bSpectating = ( pPlayer && ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE || pPlayer->GetObserverMode() == OBS_MODE_CHASE ) );
|
||||
|
||||
if ( pPlayer && bSpectating )
|
||||
{
|
||||
C_BaseEntity *pTarget = pPlayer->GetObserverTarget();
|
||||
|
||||
if ( pTarget && pTarget->IsPlayer() )
|
||||
{
|
||||
pPlayer = ToCSPlayer( pTarget );
|
||||
|
||||
if ( pPlayer && !pPlayer->IsAlive() )
|
||||
{
|
||||
pPlayer = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
bDefuseCanceled = (pPlayer->m_iProgressBarDuration == 0);
|
||||
|
||||
if ( pPlayer->m_iProgressBarDuration > 0 )
|
||||
{
|
||||
// ProgressBarStartTime is now with respect to m_flSimulationTime rather than local time
|
||||
DefusePercent = (pPlayer->m_flSimulationTime - pPlayer->m_flProgressBarStartTime) / (float)pPlayer->m_iProgressBarDuration;
|
||||
DefusePercent = clamp( DefusePercent, 0.f, 1.f );
|
||||
|
||||
DefuseTimeRemaining = static_cast<int>( ceil( (float)pPlayer->m_iProgressBarDuration - (pPlayer->m_flSimulationTime - pPlayer->m_flProgressBarStartTime) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the player goes away (drops from server, dies, etc) remember to clear any defuse panel for them
|
||||
if ( m_PreviousDefusePercent >= 0.f )
|
||||
bDefuseCanceled = true;
|
||||
}
|
||||
|
||||
|
||||
// Updating flash, slot locking begins
|
||||
bool bSlotIsLocked = false;
|
||||
|
||||
if ( m_HintDisplayTimer.HasStarted() )
|
||||
{
|
||||
// Check if the current hint text should go away
|
||||
if ( m_HintDisplayTimer.IsElapsed() )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// clear the hint, which also clears our timer
|
||||
SetHintText(NULL);
|
||||
m_bHintPanelHidden = false;
|
||||
}
|
||||
else if ( m_bHintPanelHidden && m_PriorityMsgDisplayTimer.IsElapsed() )
|
||||
{
|
||||
// Hint message was defered while a priority message was shown. Bring it back.
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
m_bHintPanelHidden = false;
|
||||
ShowPanelNoLock( SFHUDINFO_Help, true );
|
||||
}
|
||||
else if ( m_bActive && m_bDeferRaiseHelpPanel )
|
||||
{
|
||||
// The help panel was triggered before the HUD was visible: raise it now
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_Help, true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_PriorityMsgDisplayTimer.HasStarted() )
|
||||
{
|
||||
// Check if the priority message text should go away
|
||||
if ( m_PriorityMsgDisplayTimer.IsElapsed() )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// clear the hint, which also clears our timer
|
||||
SetPriorityText( static_cast<wchar_t*>(NULL) );
|
||||
}
|
||||
else if ( m_bActive && m_bDeferRaisePriorityMessagePanel )
|
||||
{
|
||||
// The priority message panel was triggered before the HUD was visible: raise it now
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_PriorityMessage, true );
|
||||
}
|
||||
}
|
||||
|
||||
// Update the defuse UI
|
||||
if ( DefusePercent >= 0.0f )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// Update the timer text and progress bar
|
||||
if ( DefuseTimeRemaining >= 0 && m_DefuseTimerTextHandle )
|
||||
{
|
||||
char cTimerStr[ 128 ];
|
||||
int clampedTime = MAX( DefuseTimeRemaining, 0 );
|
||||
|
||||
Q_snprintf( cTimerStr, sizeof(cTimerStr), "%02d:%02d", ( clampedTime / 60 ), ( clampedTime % 60 ) );
|
||||
m_pScaleformUI->Value_SetText( m_DefuseTimerTextHandle, cTimerStr );
|
||||
}
|
||||
|
||||
if ( DefusePercent >= 0.f )
|
||||
{
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, DefusePercent);
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setDefuseProgress", data, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_PreviousDefusePercent < 0.f && DefusePercent >= 0.f )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// activated the defuse process: set our static text once, and then show the panel
|
||||
if ( m_DefuseTitleTextHandle )
|
||||
{
|
||||
if ( pPlayer->m_bIsGrabbingHostage )
|
||||
m_pScaleformUI->Value_SetText( m_DefuseTitleTextHandle, "#SFUIHUD_InfoPanel_HostageTitle" );
|
||||
else
|
||||
m_pScaleformUI->Value_SetText( m_DefuseTitleTextHandle, "#SFUIHUD_InfoPanel_DefuseTitle" );
|
||||
}
|
||||
|
||||
if ( m_DefuseBodyTextHandle )
|
||||
{
|
||||
if ( bSpectating )
|
||||
{
|
||||
C_CSPlayer *pTargetPlayer = ToCSPlayer( pPlayer->GetObserverTarget() );
|
||||
|
||||
if ( pTargetPlayer )
|
||||
{
|
||||
wchar_t wszLocalized[100];
|
||||
wchar_t wszPlayerName[MAX_PLAYER_NAME_LENGTH];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pTargetPlayer->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
|
||||
|
||||
if ( pTargetPlayer->HasDefuser() )
|
||||
g_pVGuiLocalize->ConstructString( wszLocalized, sizeof( wszLocalized ), g_pVGuiLocalize->Find( "#SFUIHUD_InfoPanel_Spec_DefuseText" ), 1, wszPlayerName );
|
||||
else
|
||||
g_pVGuiLocalize->ConstructString( wszLocalized, sizeof( wszLocalized ), g_pVGuiLocalize->Find( "#SFUIHUD_InfoPanel_Spec_DefuseText_NoKit" ), 1, wszPlayerName );
|
||||
|
||||
m_pScaleformUI->Value_SetText( m_DefuseBodyTextHandle, wszLocalized );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_SetText( m_DefuseBodyTextHandle, "" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pPlayer->m_bIsGrabbingHostage )
|
||||
m_pScaleformUI->Value_SetText( m_DefuseBodyTextHandle, "#SFUIHUD_InfoPanel_HostageText" );
|
||||
else if ( pPlayer->HasDefuser() )
|
||||
m_pScaleformUI->Value_SetText( m_DefuseBodyTextHandle, "#SFUIHUD_InfoPanel_DefuseText" );
|
||||
else
|
||||
m_pScaleformUI->Value_SetText( m_DefuseBodyTextHandle, "#SFUIHUD_InfoPanel_DefuseText_NoKit" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_DefuseIconKit && m_DefuseIconNoKit )
|
||||
{
|
||||
bool bHasDefuser = pPlayer->HasDefuser();
|
||||
|
||||
m_pScaleformUI->Value_SetVisible( m_DefuseIconKit, bHasDefuser );
|
||||
m_pScaleformUI->Value_SetVisible( m_DefuseIconNoKit, !bHasDefuser );
|
||||
}
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_Defuse, true );
|
||||
}
|
||||
|
||||
if ( m_PreviousDefusePercent >= 0.f && bDefuseCanceled )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// stopped defusing: hide the panel
|
||||
ShowPanelNoLock( SFHUDINFO_Defuse, false );
|
||||
}
|
||||
|
||||
m_PreviousDefusePercent = DefusePercent;
|
||||
|
||||
|
||||
// Update current achievement UI
|
||||
if ( m_activeAchievement != CSInvalidAchievement )
|
||||
{
|
||||
if ( m_AchievementDisplayTimer.HasStarted() && m_AchievementDisplayTimer.IsElapsed() )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
m_AchievementDisplayTimer.Invalidate();
|
||||
|
||||
// start the hide process on the panel
|
||||
ShowPanelNoLock( SFHUDINFO_Medal, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Once the panel is fully gone, clear the active achievement so we can display the next one
|
||||
if ( m_MedalPanelHandle )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
ScaleformDisplayInfo dinfo;
|
||||
m_pScaleformUI->Value_GetDisplayInfo( m_MedalPanelHandle, &dinfo );
|
||||
|
||||
if ( !dinfo.GetVisibility() )
|
||||
{
|
||||
m_activeAchievement = CSInvalidAchievement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_achievementQueue.Count() > 0 )
|
||||
{
|
||||
// Grab the next queued achievement and pop it up
|
||||
AchivementQueueInfo queueInfo = m_achievementQueue.RemoveAtHead();
|
||||
|
||||
m_AchievementDisplayTimer.Start( g_MedalDisplayTime );
|
||||
|
||||
m_activeAchievement = queueInfo.type;
|
||||
|
||||
// [dwenger] Play the achievement earned sound effect
|
||||
vgui::surface()->PlaySound( "UI/achievement_earned.wav" );
|
||||
|
||||
// Here we get the achievement to be displayed and set that in the popup windows
|
||||
IAchievementMgr *pAchievementMgr = engine->GetAchievementMgr();
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByID( m_activeAchievement, queueInfo.playerSlot );
|
||||
if ( pAchievement )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
if ( m_MedalTitleTextHandle )
|
||||
{
|
||||
m_pScaleformUI->Value_SetText( m_MedalTitleTextHandle, ACHIEVEMENT_LOCALIZED_NAME( pAchievement ) );
|
||||
}
|
||||
|
||||
if ( m_MedalBodyTextHandle )
|
||||
{
|
||||
// not showing the text for right now because the body field isn't incorperated into the design, will address later
|
||||
m_pScaleformUI->Value_SetText( m_MedalBodyTextHandle, "" );
|
||||
//m_pScaleformUI->Value_SetText( m_MedalBodyTextHandle, ACHIEVEMENT_LOCALIZED_DESC( pAchievement ) );
|
||||
}
|
||||
|
||||
// Notify the panel of the achievement name, so we can display the appropriate icon (icon name MUST match the achievement short name, eg. "ENEMY_KILL_HIGH", "SAME_UNIFORM")
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, pAchievement->GetName());
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setMedalAnnouncement", data, 1 );
|
||||
}
|
||||
|
||||
// Achievements and medals always take precedent over hints / priority messages.
|
||||
if ( m_PriorityMsgDisplayTimer.HasStarted() )
|
||||
{
|
||||
if ( m_bHintPanelHidden )
|
||||
{
|
||||
m_bHintPanelHidden = false;
|
||||
m_HintDisplayTimer.Invalidate();
|
||||
}
|
||||
|
||||
SetPriorityText( static_cast<wchar_t*>(NULL) );
|
||||
}
|
||||
|
||||
if ( m_HintDisplayTimer.HasStarted() )
|
||||
{
|
||||
SetHintText( NULL );
|
||||
}
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_Medal, true );
|
||||
}
|
||||
}
|
||||
|
||||
LockSlot( false, bSlotIsLocked );
|
||||
|
||||
// Clear any transient data now
|
||||
if ( m_bActive )
|
||||
{
|
||||
m_bDeferRaiseHelpPanel = false;
|
||||
m_bDeferRaisePriorityMessagePanel = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void GetTextBoxForElement( IScaleformUI *pScaleformUI, SFVALUE root, const char *elementName, const char *textElementName, SFVALUE &sfv )
|
||||
{
|
||||
SFVALUE TempHandle = pScaleformUI->Value_GetMember( root, elementName );
|
||||
|
||||
if ( TempHandle )
|
||||
{
|
||||
sfv = pScaleformUI->Value_GetMember( TempHandle, textElementName );
|
||||
pScaleformUI->ReleaseValue( TempHandle );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::FlashReady( void )
|
||||
{
|
||||
ListenForGameEvent( "achievement_earned_local" );
|
||||
|
||||
m_HelpPanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanelHelp" );
|
||||
|
||||
if ( m_HelpPanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_HelpPanelHandle, "Panel" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "HelpText", "TextBox", m_HelpBodyTextHandle );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
m_PriorityMessagePanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanelCenter" );
|
||||
|
||||
if ( m_PriorityMessagePanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_PriorityMessagePanelHandle, "Panel" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "CenterTextTitle", "TextBox", m_PriorityMessageTitleTextHandle );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "CenterText", "TextBox", m_PriorityMessageBodyTextHandle );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
m_MedalPanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanelMedal" );
|
||||
|
||||
if ( m_MedalPanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_MedalPanelHandle, "Panel" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "MedalTitleText", "TextBox", m_MedalTitleTextHandle );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "MedalText", "TextBox", m_MedalBodyTextHandle );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
m_DefusePanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanelDefuse" );
|
||||
|
||||
if ( m_DefusePanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_DefusePanelHandle, "Panel" );
|
||||
|
||||
m_DefuseIconKit = m_pScaleformUI->Value_GetMember( m_DefusePanelHandle, "icon_defuse" );
|
||||
m_DefuseIconNoKit = m_pScaleformUI->Value_GetMember( m_DefusePanelHandle, "icon_no_defusekit" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "DefuseText", "TextBox", m_DefuseBodyTextHandle );
|
||||
|
||||
SFVALUE TitleBarHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "DefuseTextTitle" );
|
||||
|
||||
if ( TitleBarHandle )
|
||||
{
|
||||
SFVALUE TitleTextHandle = m_pScaleformUI->Value_GetMember( TitleBarHandle, "DefuseTitle" );
|
||||
|
||||
if ( TitleTextHandle )
|
||||
{
|
||||
GetTextBoxForElement( m_pScaleformUI, TitleTextHandle, "DefuseTitle", "TextBox1", m_DefuseTitleTextHandle );
|
||||
|
||||
GetTextBoxForElement( m_pScaleformUI, TitleTextHandle, "DefuseTitle", "TextBox2", m_DefuseTimerTextHandle );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( TitleTextHandle );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( TitleBarHandle );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
// hide everything initially
|
||||
HideAll();
|
||||
}
|
||||
|
||||
bool SFHudInfoPanel::PreUnloadFlash( void )
|
||||
{
|
||||
StopListeningForAllEvents();
|
||||
|
||||
SafeReleaseSFVALUE( m_HelpPanelHandle );
|
||||
SafeReleaseSFVALUE( m_HelpBodyTextHandle );
|
||||
|
||||
SafeReleaseSFVALUE( m_MedalPanelHandle );
|
||||
SafeReleaseSFVALUE( m_MedalTitleTextHandle );
|
||||
SafeReleaseSFVALUE( m_MedalBodyTextHandle );
|
||||
|
||||
SafeReleaseSFVALUE( m_DefusePanelHandle );
|
||||
SafeReleaseSFVALUE( m_DefuseTitleTextHandle );
|
||||
SafeReleaseSFVALUE( m_DefuseTimerTextHandle );
|
||||
SafeReleaseSFVALUE( m_DefuseBodyTextHandle );
|
||||
|
||||
SafeReleaseSFVALUE( m_DefuseIconKit );
|
||||
SafeReleaseSFVALUE( m_DefuseIconNoKit );
|
||||
|
||||
SafeReleaseSFVALUE( m_PriorityMessagePanelHandle );
|
||||
SafeReleaseSFVALUE( m_PriorityMessageTitleTextHandle );
|
||||
SafeReleaseSFVALUE( m_PriorityMessageBodyTextHandle );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudInfoPanel, this, HelpAchievementModule );
|
||||
}
|
||||
else
|
||||
{
|
||||
// When initially loaded, hide this panel
|
||||
HideAll();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::Reset( void )
|
||||
{
|
||||
HideAll();
|
||||
}
|
||||
|
||||
bool SFHudInfoPanel::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
return cl_drawhud.GetBool() && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudInfoPanel::SetActive( bool bActive )
|
||||
{
|
||||
if ( m_bActive && !bActive )
|
||||
{
|
||||
HideAll();
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
bool SFHudInfoPanel::MsgFunc_HintText( const CCSUsrMsg_HintText &msg )
|
||||
{
|
||||
const char *tmpStr = hudtextmessage->LookupString( msg.text().c_str(), NULL );
|
||||
LocalizeAndDisplay( tmpStr, tmpStr );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SFHudInfoPanel::MsgFunc_KeyHintText( const CCSUsrMsg_KeyHintText &msg )
|
||||
{
|
||||
const char *tmpStr = hudtextmessage->LookupString( msg.hints(0).c_str(), NULL );
|
||||
LocalizeAndDisplay( tmpStr, tmpStr );
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::LocalizeAndDisplay( const char *pszHudTxtMsg, const char *szRawString )
|
||||
{
|
||||
wchar_t szBuf[255];
|
||||
wchar_t *pszBuf;
|
||||
|
||||
// init buffers & pointers
|
||||
szBuf[0] = 0;
|
||||
pszBuf = szBuf;
|
||||
|
||||
// try to localize
|
||||
if ( pszHudTxtMsg )
|
||||
{
|
||||
pszBuf = g_pVGuiLocalize->Find( pszHudTxtMsg );
|
||||
}
|
||||
else
|
||||
{
|
||||
pszBuf = g_pVGuiLocalize->Find( szRawString );
|
||||
}
|
||||
|
||||
if ( !pszBuf )
|
||||
{
|
||||
// use plain ASCII string
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szRawString, szBuf, sizeof(szBuf) );
|
||||
pszBuf = szBuf;
|
||||
}
|
||||
|
||||
// replace key binding text
|
||||
wchar_t keyBindingBuf[512];
|
||||
UTIL_ReplaceKeyBindings( pszBuf, sizeof( szBuf ), keyBindingBuf, sizeof( keyBindingBuf ) );
|
||||
|
||||
// make it visible
|
||||
SetHintText( pszBuf );
|
||||
}
|
||||
|
||||
bool SFHudInfoPanel::SetHintText( wchar_t *text )
|
||||
{
|
||||
if ( FlashAPIIsValid() && !m_AchievementDisplayTimer.HasStarted() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( text )
|
||||
{
|
||||
if ( m_HelpBodyTextHandle )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_SetTextHTML( m_HelpBodyTextHandle, m_pScaleformUI->ReplaceGlyphKeywordsWithHTML( text ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_PriorityMsgDisplayTimer.HasStarted() )
|
||||
{
|
||||
// Defer display of the hint message until the priority message has finished displaying
|
||||
m_bHintPanelHidden = true;
|
||||
m_HintDisplayTimer.Start( g_HintDisplayTime + m_PriorityMsgDisplayTimer.GetRemainingTime() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// start (or reset) the timer for auto-hiding this latest hint
|
||||
m_HintDisplayTimer.Start( g_HintDisplayTime );
|
||||
ShowPanelNoLock( SFHUDINFO_Help, true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_HintDisplayTimer.Invalidate();
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_Help, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef _GAMECONSOLE
|
||||
ConVar cl_display_scaleform_achievement_popups( "cl_display_scaleform_achievement_popups", "0", FCVAR_CLIENTDLL );
|
||||
#else
|
||||
ConVar cl_display_scaleform_achievement_popups( "cl_display_scaleform_achievement_popups", "1", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );
|
||||
#endif
|
||||
|
||||
void SFHudInfoPanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *pEventName = event->GetName();
|
||||
|
||||
if ( cl_display_scaleform_achievement_popups.GetBool() )
|
||||
{
|
||||
if ( Q_strcmp( "achievement_earned_local", pEventName ) == 0 )
|
||||
{
|
||||
AchivementQueueInfo queueInfo;
|
||||
queueInfo.type = (eCSAchievementType)event->GetInt( "achievement" );
|
||||
queueInfo.playerSlot = event->GetInt( "splitscreenplayer" );
|
||||
|
||||
// If this achievement is for this player, enqueue it to display on the next tick
|
||||
if ( queueInfo.playerSlot == engine->GetActiveSplitScreenPlayerSlot() )
|
||||
{
|
||||
m_achievementQueue.Insert(queueInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Common code to setup the priority text window for a new message, or tear it down if the message is cleared
|
||||
void SFHudInfoPanel::ModifyPriorityTextWindow( bool bMsgSet )
|
||||
{
|
||||
if ( bMsgSet )
|
||||
{
|
||||
bool bAlreadyActive = m_PriorityMsgDisplayTimer.HasStarted() && !m_PriorityMsgDisplayTimer.IsElapsed();
|
||||
|
||||
// start (or reset) the timer for auto-hiding this latest text
|
||||
static ConVarRef scr_centertime( "scr_centertime" );
|
||||
m_PriorityMsgDisplayTimer.Start( scr_centertime.GetFloat() );
|
||||
|
||||
if ( m_PriorityMessageTitleTextHandle )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_SetText( m_PriorityMessageTitleTextHandle, "#SFUIHUD_InfoPanel_PriorityMsgTitle" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bAlreadyActive )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
// don't re-animate the window into position, just flash it and swap the text
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "flashCenterText", NULL, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_HintDisplayTimer.HasStarted() )
|
||||
{
|
||||
// Priority messages take precedent. Temporarily hide the hint panel.
|
||||
m_bHintPanelHidden = true;
|
||||
m_HintDisplayTimer.Start( m_HintDisplayTimer.GetElapsedTime() + scr_centertime.GetFloat() );
|
||||
ShowPanelNoLock( SFHUDINFO_Help, false );
|
||||
}
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_PriorityMessage, true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PriorityMsgDisplayTimer.Invalidate();
|
||||
|
||||
ShowPanelNoLock( SFHUDINFO_PriorityMessage, false );
|
||||
}
|
||||
}
|
||||
|
||||
// ANSI C-string version
|
||||
void SFHudInfoPanel::SetPriorityText( char *pMsg )
|
||||
{
|
||||
if ( FlashAPIIsValid() && !m_AchievementDisplayTimer.HasStarted() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ModifyPriorityTextWindow( (pMsg != NULL) );
|
||||
|
||||
if ( pMsg && m_PriorityMessageBodyTextHandle )
|
||||
{
|
||||
if ( g_BannedWords.BInitialized() )
|
||||
{
|
||||
int nLen = V_strlen( pMsg );
|
||||
int cubDestSizeInBytes = ( 1 + nLen ) * sizeof( wchar_t );
|
||||
wchar_t * pwchBuffer = ( wchar_t * ) stackalloc( cubDestSizeInBytes );
|
||||
V_UTF8ToUnicode( pMsg, pwchBuffer, cubDestSizeInBytes );
|
||||
if ( g_BannedWords.CensorBannedWordsInplace( pwchBuffer ) )
|
||||
{
|
||||
m_pScaleformUI->Value_SetText( m_PriorityMessageBodyTextHandle, pwchBuffer );
|
||||
pMsg = NULL;
|
||||
}
|
||||
}
|
||||
if ( pMsg )
|
||||
{
|
||||
m_pScaleformUI->Value_SetText( m_PriorityMessageBodyTextHandle, pMsg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TCHAR (multi-byte) string version
|
||||
void SFHudInfoPanel::SetPriorityText( wchar_t *pMsg )
|
||||
{
|
||||
if ( FlashAPIIsValid() && !m_AchievementDisplayTimer.HasStarted() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ModifyPriorityTextWindow( (pMsg != NULL) );
|
||||
|
||||
if ( pMsg && m_PriorityMessageBodyTextHandle )
|
||||
{
|
||||
g_BannedWords.CensorBannedWordsInplace( pMsg );
|
||||
m_pScaleformUI->Value_SetTextHTML( m_PriorityMessageBodyTextHandle, m_pScaleformUI->ReplaceGlyphKeywordsWithHTML( pMsg ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::SetPriorityHintText( wchar_t *pMsg )
|
||||
{
|
||||
if ( FlashAPIIsValid() && !m_AchievementDisplayTimer.HasStarted() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
//m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "flashCenterText", NULL, 0 );
|
||||
|
||||
if ( pMsg )
|
||||
{
|
||||
// make it visible
|
||||
g_BannedWords.CensorBannedWordsInplace( pMsg );
|
||||
SetHintText( pMsg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudInfoPanel::ApplyYOffset( int nOffset )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nOffset );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setYOffset", data, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements for medals/achievements, and hint text
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SFHUDINFOPANEL_H_
|
||||
#define SFHUDINFOPANEL_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "tier1/utlqueue.h"
|
||||
|
||||
class SFHudInfoPanel : public SFHudFlashInterface
|
||||
{
|
||||
enum HUDINFO_TYPE
|
||||
{
|
||||
SFHUDINFO_All,
|
||||
SFHUDINFO_Help,
|
||||
SFHUDINFO_Defuse,
|
||||
SFHUDINFO_Medal,
|
||||
SFHUDINFO_PriorityMessage
|
||||
};
|
||||
|
||||
public:
|
||||
explicit SFHudInfoPanel( const char *value );
|
||||
virtual ~SFHudInfoPanel();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
virtual void Reset( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
// receivers for hint messages
|
||||
bool MsgFunc_HintText( const CCSUsrMsg_HintText &msg );
|
||||
bool MsgFunc_KeyHintText( const CCSUsrMsg_KeyHintText &msg );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
|
||||
// Priority text replaces what used to be called CenterPrint text in VGui
|
||||
void SetPriorityText( char *pMsg );
|
||||
void SetPriorityText( wchar_t *pMsg );
|
||||
void SetPriorityHintText( wchar_t *pMsg );
|
||||
|
||||
// Offsets the Y location of the notification panels
|
||||
void ApplyYOffset( int nOffset );
|
||||
bool IsVisible( void ) { return m_bIsVisible; }
|
||||
|
||||
CUserMessageBinder m_UMCMsgHintText;
|
||||
CUserMessageBinder m_UMCMsgKeyHintText;
|
||||
CUserMessageBinder m_UMCMsgQuestProgress;
|
||||
|
||||
protected:
|
||||
void ModifyPriorityTextWindow( bool bMsgSet );
|
||||
|
||||
void ShowPanel( HUDINFO_TYPE panelType, bool value );
|
||||
|
||||
// Only call this function if you're already inside of a slot-lock block!
|
||||
void ShowPanelNoLock( HUDINFO_TYPE panelType, bool value );
|
||||
|
||||
void HideAll( void );
|
||||
void LockSlot( bool wantItLocked, bool& currentlyLocked );
|
||||
|
||||
bool SetHintText( wchar_t *text );
|
||||
|
||||
void LocalizeAndDisplay( const char *pszHudTxtMsg, const char *szRawString );
|
||||
|
||||
protected:
|
||||
SFVALUE m_HelpPanelHandle;
|
||||
SFVALUE m_HelpBodyTextHandle;
|
||||
|
||||
CountdownTimer m_HintDisplayTimer;
|
||||
|
||||
SFVALUE m_DefusePanelHandle;
|
||||
SFVALUE m_DefuseTitleTextHandle;
|
||||
SFVALUE m_DefuseBodyTextHandle;
|
||||
SFVALUE m_DefuseTimerTextHandle;
|
||||
|
||||
SFVALUE m_DefuseIconKit;
|
||||
SFVALUE m_DefuseIconNoKit;
|
||||
|
||||
float m_PreviousDefusePercent;
|
||||
|
||||
SFVALUE m_MedalPanelHandle;
|
||||
SFVALUE m_MedalTitleTextHandle;
|
||||
SFVALUE m_MedalBodyTextHandle;
|
||||
|
||||
struct AchivementQueueInfo
|
||||
{
|
||||
eCSAchievementType type;
|
||||
int playerSlot;
|
||||
};
|
||||
|
||||
CUtlQueue<AchivementQueueInfo> m_achievementQueue;
|
||||
eCSAchievementType m_activeAchievement;
|
||||
|
||||
CountdownTimer m_AchievementDisplayTimer;
|
||||
|
||||
CountdownTimer m_PriorityMsgDisplayTimer;
|
||||
|
||||
SFVALUE m_PriorityMessagePanelHandle;
|
||||
SFVALUE m_PriorityMessageTitleTextHandle;
|
||||
SFVALUE m_PriorityMessageBodyTextHandle;
|
||||
|
||||
bool m_bDeferRaiseHelpPanel;
|
||||
bool m_bDeferRaisePriorityMessagePanel;
|
||||
bool m_bHintPanelHidden; // True when we have hidden a help panel in order to show a priority message
|
||||
bool m_bIsVisible;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDINFOPANEL_H_ */
|
||||
@@ -0,0 +1,313 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "hudelement.h"
|
||||
#include "sfhudmoney.h"
|
||||
#include "hud_macros.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "sfhudfreezepanel.h"
|
||||
#include "c_plantedc4.h"
|
||||
#include "sfhudradar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudMoney);
|
||||
DECLARE_HUD_MESSAGE( SFHudMoney, AdjustMoney );
|
||||
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( DoneAnimatingAdd ),
|
||||
SFUI_DECL_METHOD( DoneAnimatingSub ),
|
||||
SFUI_END_GAME_API_DEF( SFHudMoney, Money );
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
SFHudMoney::SFHudMoney( const char *value ) : SFHudFlashInterface( value )
|
||||
{
|
||||
m_bAnimatingAdd = false;
|
||||
m_bAnimatingSub = false;
|
||||
m_nLastMoney = 0;
|
||||
m_lastEntityIndex = 0;
|
||||
|
||||
m_hCash = NULL;
|
||||
m_hAddCash = NULL;
|
||||
m_hRemoveCash = NULL;
|
||||
m_hBuyZoneIcon = NULL;
|
||||
|
||||
m_bShowBuyZoneIcon = false;
|
||||
m_nShiftState = -1;
|
||||
|
||||
SetIgnoreGlobalHudDisable( true );
|
||||
}
|
||||
|
||||
|
||||
SFHudMoney::~SFHudMoney()
|
||||
{
|
||||
}
|
||||
|
||||
void SFHudMoney::Init( void )
|
||||
{
|
||||
HOOK_HUD_MESSAGE( SFHudMoney, AdjustMoney );
|
||||
}
|
||||
|
||||
void SFHudMoney::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudMoney, this, Money );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudMoney::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudMoney::ShouldDraw( void )
|
||||
{
|
||||
if ( IsTakingAFreezecamScreenshot() )
|
||||
return false;
|
||||
|
||||
if ( !CSGameRules() )
|
||||
return false;
|
||||
|
||||
if ( CSGameRules()->IsPlayingTraining() || !CSGameRules()->CanSpendMoneyInMap() )
|
||||
return false;
|
||||
|
||||
IViewPortPanel* buyPanel = NULL;
|
||||
IViewPortPanel *scoreboard = NULL;
|
||||
if ( GetViewPortInterface() )
|
||||
{
|
||||
buyPanel = GetViewPortInterface()->FindPanelByName( PANEL_BUY );
|
||||
scoreboard = GetViewPortInterface()->FindPanelByName( PANEL_SCOREBOARD );
|
||||
}
|
||||
|
||||
if ( CSGameRules()->GetGamePhase() == GAMEPHASE_MATCH_ENDED && scoreboard && scoreboard->IsVisible() )
|
||||
return false;
|
||||
|
||||
bool bGloballyHidden = GetHud().HudDisabled() && ( !buyPanel || !buyPanel->IsVisible() );
|
||||
|
||||
return cl_drawhud.GetBool() && !bGloballyHidden && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudMoney::SetActive( bool bActive )
|
||||
{
|
||||
Show( bActive );
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
void SFHudMoney::Show( bool show )
|
||||
{
|
||||
if ( m_FlashAPI && show != m_bActive )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( show )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
UpdateCurrentMoneyText();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudMoney::FlashReady( void )
|
||||
{
|
||||
m_bAnimatingAdd = false;
|
||||
m_bAnimatingSub = false;
|
||||
|
||||
m_cashAdjustmentQueue.SetCount( 0 );
|
||||
|
||||
SFVALUE root = m_pScaleformUI->Value_GetMember( m_FlashAPI, "MoneyPanel" );
|
||||
if ( root )
|
||||
{
|
||||
SFVALUE innerPanel = m_pScaleformUI->Value_GetMember( root, "InnerMoneyPanel" );
|
||||
if ( innerPanel )
|
||||
{
|
||||
m_hBuyZoneIcon = m_pScaleformUI->TextObject_MakeTextObjectFromMember( innerPanel, "BuyZoneIcon" );
|
||||
SFVALUE container = m_pScaleformUI->Value_GetMember( innerPanel, "CashContainer" );
|
||||
if ( container )
|
||||
{
|
||||
m_hCash = m_pScaleformUI->TextObject_MakeTextObjectFromMember( container, "Cash" );
|
||||
SFVALUE AddCash = m_pScaleformUI->Value_GetMember( container, "AddCash" );
|
||||
if ( AddCash )
|
||||
{
|
||||
m_hAddCash = m_pScaleformUI->TextObject_MakeTextObjectFromMember( AddCash, "AddText" );
|
||||
g_pScaleformUI->ReleaseValue( AddCash );
|
||||
}
|
||||
SFVALUE RemoveCash = m_pScaleformUI->Value_GetMember( container, "RemoveCash" );
|
||||
if ( RemoveCash )
|
||||
{
|
||||
m_hRemoveCash = m_pScaleformUI->TextObject_MakeTextObjectFromMember( RemoveCash, "RemoveText" );
|
||||
g_pScaleformUI->ReleaseValue( RemoveCash );
|
||||
}
|
||||
g_pScaleformUI->ReleaseValue( container );
|
||||
}
|
||||
g_pScaleformUI->ReleaseValue( innerPanel );
|
||||
}
|
||||
g_pScaleformUI->ReleaseValue( root );
|
||||
}
|
||||
|
||||
if ( m_bActive )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
|
||||
if ( m_hBuyZoneIcon )
|
||||
{
|
||||
m_hBuyZoneIcon->SetVisible( false );
|
||||
m_bShowBuyZoneIcon = false;
|
||||
}
|
||||
m_nShiftState = -1;
|
||||
|
||||
UpdateCurrentMoneyText();
|
||||
}
|
||||
|
||||
|
||||
bool SFHudMoney::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFTextObject( m_hCash );
|
||||
SafeReleaseSFTextObject( m_hAddCash );
|
||||
SafeReleaseSFTextObject( m_hRemoveCash );
|
||||
SafeReleaseSFTextObject( m_hBuyZoneIcon );
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudMoney::ProcessInput( void )
|
||||
{
|
||||
C_CSPlayer* pPlayer = pPlayer = GetHudPlayer();
|
||||
CCSGameRules* pGameRules = CSGameRules();
|
||||
if ( pGameRules && pPlayer )
|
||||
{
|
||||
int entityIndex = pPlayer->entindex();
|
||||
if ( pPlayer->IsControllingBot() )
|
||||
entityIndex = pPlayer->GetControlledBotIndex();
|
||||
|
||||
// let's always draw attention to when the player's money has changed
|
||||
if ( entityIndex == m_lastEntityIndex )
|
||||
{
|
||||
if ( m_nLastMoney != pPlayer->GetAccount() )
|
||||
{
|
||||
// if this is the start of the very first round, don't show the change that can happen from the warmup round to the start round
|
||||
if ( pGameRules->GetTotalRoundsPlayed() == 0 && pGameRules->GetRoundElapsedTime() < 1 )
|
||||
{
|
||||
UpdateCurrentMoneyText();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateMoneyChange( pPlayer->GetAccount() - m_nLastMoney );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we changed who we're observing, so just update it directly
|
||||
m_lastEntityIndex = entityIndex;
|
||||
UpdateCurrentMoneyText();
|
||||
}
|
||||
|
||||
m_nLastMoney = pPlayer->GetAccount();
|
||||
|
||||
bool bShowBuyZoneIcon = CSGameRules()->CanSpendMoneyInMap() &&
|
||||
!pGameRules->IsBuyTimeElapsed() &&
|
||||
pPlayer->IsInBuyZone();
|
||||
|
||||
if ( m_hBuyZoneIcon && ( m_bShowBuyZoneIcon != bShowBuyZoneIcon ) )
|
||||
{
|
||||
m_bShowBuyZoneIcon = bShowBuyZoneIcon;
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_hBuyZoneIcon->SetVisible( m_bShowBuyZoneIcon );
|
||||
}
|
||||
}
|
||||
|
||||
int nShiftState = 0;
|
||||
|
||||
bool bRoundRadar = ( GET_HUDELEMENT( SFHudRadar ) )->m_bRound;
|
||||
|
||||
nShiftState = ( pGameRules->IsHostageRescueMap() || !bRoundRadar ) ? 1: nShiftState;
|
||||
|
||||
nShiftState = pPlayer->IsBuyMenuOpen() ? 2: nShiftState;
|
||||
|
||||
if ( FlashAPIIsValid() && ( m_nShiftState != nShiftState ) )
|
||||
{
|
||||
m_nShiftState = nShiftState;
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nShiftState );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetShift", data, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudMoney::MsgFunc_AdjustMoney( const CCSUsrMsg_AdjustMoney &msg )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudMoney::UpdateMoneyChange( int nDelta )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nDelta );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "DisplayMoneyAdjustment", data, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( nDelta < 0 )
|
||||
{
|
||||
UpdateCurrentMoneyText();
|
||||
m_bAnimatingSub = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bAnimatingAdd = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudMoney::DoneAnimatingAdd( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_bAnimatingAdd = false;
|
||||
UpdateCurrentMoneyText();
|
||||
}
|
||||
|
||||
void SFHudMoney::DoneAnimatingSub( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_bAnimatingSub = false;
|
||||
}
|
||||
|
||||
void SFHudMoney::UpdateCurrentMoneyText( void )
|
||||
{
|
||||
C_CSPlayer *pPlayer = GetHudPlayer();
|
||||
if ( pPlayer && m_hCash )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_hCash->SetText( CFmtStr( "$%d", pPlayer->GetAccount() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDMONEY_H_
|
||||
#define SFHUDMONEY_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "c_cs_hostage.h"
|
||||
|
||||
|
||||
class SFHudMoney : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudMoney( const char *value );
|
||||
virtual ~SFHudMoney();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual void Init( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
void Show( bool show );
|
||||
|
||||
bool MsgFunc_AdjustMoney( const CCSUsrMsg_AdjustMoney &msg );
|
||||
|
||||
void UpdateMoneyChange( int nDelta = 0 );
|
||||
|
||||
void DoneAnimatingAdd( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void DoneAnimatingSub( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
CUserMessageBinder m_UMCMsgAdjustMoney;
|
||||
|
||||
private:
|
||||
void UpdateCurrentMoneyText();
|
||||
|
||||
int m_nMoneyChange;
|
||||
|
||||
int m_nLastMoney;
|
||||
int m_lastEntityIndex;
|
||||
|
||||
int m_nShiftState;
|
||||
bool m_bShowBuyZoneIcon;
|
||||
|
||||
ISFTextObject * m_hCash;
|
||||
ISFTextObject * m_hAddCash;
|
||||
ISFTextObject * m_hRemoveCash;
|
||||
ISFTextObject * m_hBuyZoneIcon;
|
||||
|
||||
CUtlVector<int> m_cashAdjustmentQueue;
|
||||
|
||||
bool m_bAnimatingAdd;
|
||||
bool m_bAnimatingSub;
|
||||
|
||||
};
|
||||
|
||||
#endif /* SFHUDMONEY_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,603 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDRADAR_H_
|
||||
#define SFHUDRADAR_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "c_cs_hostage.h"
|
||||
|
||||
#define MAX_LOCATION_TEXT_LENGTH 100
|
||||
|
||||
#define MAX_DECOYS 30
|
||||
|
||||
class SFHudRadar : public SFHudFlashInterface
|
||||
{
|
||||
|
||||
// this manages the display of the players and hostages
|
||||
// in the radar
|
||||
|
||||
protected:
|
||||
enum ICON_PACK_TYPE
|
||||
{
|
||||
ICON_PACK_PLAYER,
|
||||
ICON_PACK_HOSTAGE,
|
||||
ICON_PACK_DECOY,
|
||||
ICON_PACK_DEFUSER,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
R_BELOW = 0,
|
||||
R_SAMELEVEL = 1,
|
||||
R_ABOVE = 2,
|
||||
};
|
||||
|
||||
// each enum represents an icon that this class is managing
|
||||
enum PLAYER_ICON_INDICES
|
||||
{
|
||||
PI_PLAYER_NUMBER,
|
||||
PI_PLAYER_LETTER,
|
||||
PI_FIRST_ROTATED,
|
||||
PI_PLAYER_INDICATOR = PI_FIRST_ROTATED,
|
||||
PI_SPEAKING,
|
||||
PI_SPEAKING_OFFMAP,
|
||||
PI_ABOVE,
|
||||
PI_BELOW,
|
||||
PI_HOSTAGE_MOVING,
|
||||
PI_HOSTAGE_MOVING_OFFMAP,
|
||||
|
||||
PI_CT,
|
||||
PI_CT_OFFMAP,
|
||||
PI_CT_DEAD,
|
||||
PI_CT_GHOST,
|
||||
|
||||
PI_T,
|
||||
PI_T_OFFMAP,
|
||||
PI_T_DEAD,
|
||||
PI_T_GHOST,
|
||||
|
||||
PI_ENEMY,
|
||||
PI_ENEMY_OFFMAP,
|
||||
PI_ENEMY_DEAD,
|
||||
PI_ENEMY_GHOST,
|
||||
|
||||
PI_HOSTAGE,
|
||||
PI_HOSTAGE_OFFMAP,
|
||||
PI_HOSTAGE_DEAD,
|
||||
PI_HOSTAGE_GHOST,
|
||||
|
||||
PI_DIRECTION_INDICATOR,
|
||||
|
||||
PI_DEFUSER,
|
||||
|
||||
PI_SELECTED,
|
||||
PI_VIEWFRUSTRUM,
|
||||
PI_ENEMY_SEELOCAL,
|
||||
|
||||
PI_NUM_ICONS
|
||||
};
|
||||
|
||||
class SFHudRadarIconPackage
|
||||
{
|
||||
|
||||
public:
|
||||
SFHudRadarIconPackage();
|
||||
~SFHudRadarIconPackage();
|
||||
|
||||
// zero all the internal variables
|
||||
void ClearAll( void );
|
||||
|
||||
// get handles to the icons which will all be children
|
||||
// of the iconPackage handle
|
||||
void Init( IScaleformUI* pui, SFVALUE iconPackage );
|
||||
|
||||
// release all the handles, and clear all the variables
|
||||
// used when removing players or changing maps
|
||||
void NukeFromOrbit( SFHudRadar* pSFUI );
|
||||
|
||||
// reset all variables to their start of round values
|
||||
void StartRound( void );
|
||||
|
||||
// set the states for this player
|
||||
void SetIsPlayer( bool value );
|
||||
void SetIsSelected( bool value );
|
||||
void SetIsSpeaking ( bool value );
|
||||
void SetIsOffMap( bool value );
|
||||
void SetIsAboveOrBelow( int value );
|
||||
void SetIsMovingHostage( bool value );
|
||||
void SetIsDead( bool value );
|
||||
void SetIsRescued( bool value );
|
||||
void SetPlayerTeam( int team );
|
||||
void SetGrenadeExpireTime( float value );
|
||||
void SetIsSpotted( bool value );
|
||||
void SetIsSpottedByFriendsOnly( bool value );
|
||||
void SetAlpha( float newAlpha );
|
||||
void SetIsOnLocalTeam( bool value );
|
||||
void SetIsBot( bool value );
|
||||
void SetIsControlledBot( void );
|
||||
void SetIsDefuse( bool bValue );
|
||||
|
||||
// given the current set of states, decide which
|
||||
// icons should be shown and which should be hidden
|
||||
void SetupIconsFromStates( void );
|
||||
|
||||
// each bit in newFlags represents the visibility of one of the
|
||||
// icons in the PLAYER_ICON_INDICES. If the bit is on, the icon
|
||||
// is shown.
|
||||
void SetVisibilityFlags( int newFlags );
|
||||
|
||||
void UpdateIconsPostion( void );
|
||||
|
||||
bool IsHostageType( void ) { return m_IconPackType == ICON_PACK_HOSTAGE;}
|
||||
bool IsDecoyType( void ) { return m_IconPackType == ICON_PACK_DECOY;}
|
||||
bool IsPlayerType( void ) { return m_IconPackType == ICON_PACK_PLAYER;}
|
||||
bool IsDefuserType( void ) { return m_IconPackType == ICON_PACK_DEFUSER;}
|
||||
|
||||
bool IsVisible( void );
|
||||
|
||||
|
||||
public:
|
||||
// pointer to scaleform
|
||||
IScaleformUI* m_pScaleformUI;
|
||||
|
||||
// the parent for all the icons
|
||||
SFVALUE m_IconPackage;
|
||||
SFVALUE m_IconPackageRotate;
|
||||
|
||||
// the handles for all the icons listed in PLAYER_ICON_INDICES
|
||||
SFVALUE m_Icons[PI_NUM_ICONS];
|
||||
|
||||
// the location and position of this player/hostage
|
||||
// only updated when the player is spotted
|
||||
Vector m_Position; // current x,y pos
|
||||
QAngle m_Angle; // view origin 0..360
|
||||
|
||||
// HUD Position, rotation and scale - used to update the position of the visible icons
|
||||
Vector m_HudPosition;
|
||||
float m_HudRotation;
|
||||
float m_HudScale;
|
||||
|
||||
// ignore visibility updates until a little time has passed
|
||||
// this keeps track of when the round started
|
||||
float m_fRoundStartTime;
|
||||
|
||||
// the time at which this player/hostage died ( or was rescued )
|
||||
// used to calculate the alpha of the X icon.
|
||||
float m_fDeadTime;
|
||||
|
||||
// the time at which the player / hostage was last spotted
|
||||
// used to fade out the ? icon
|
||||
float m_fGhostTime;
|
||||
|
||||
// the alpha currently used to display all icons
|
||||
// used to lazy update the actual scaleform value
|
||||
float m_fCurrentAlpha;
|
||||
|
||||
// last time we applied this color to the movie
|
||||
float m_fLastColorUpdate;
|
||||
|
||||
// each bit represents one of the PLAYER_ICON_INDICES
|
||||
// used to lazy update the visibility of the icons in scaleform
|
||||
int m_iCurrentVisibilityFlags;
|
||||
|
||||
// the index of this player/hostage in the radar.
|
||||
// used to create the instance name of the icon package in flash
|
||||
int m_iIndex;
|
||||
|
||||
// set from the player objects UserID or EntityID ( for the hostages ). Lets us find the radar
|
||||
// object that represents a player / hostage
|
||||
int m_iEntityID;
|
||||
|
||||
// state variables used to keep track of the player / hostage state
|
||||
// so we know which icon( s ) to show
|
||||
|
||||
int m_Health; // 0..100, 7 bit
|
||||
|
||||
wchar_t m_wcName[MAX_PLAYER_NAME_LENGTH+1];
|
||||
|
||||
|
||||
// the base icon for the player
|
||||
int m_iPlayerType; // will be PI_CT, PI_T, or PI_HOSTAGE
|
||||
|
||||
int m_nAboveOrBelow;// R_BELOW = 0,R_SAMELEVEL = 1,R_ABOVE = 2,
|
||||
|
||||
float m_fGrenExpireTime;
|
||||
|
||||
ICON_PACK_TYPE m_IconPackType;
|
||||
|
||||
bool m_bIsActive : 1;
|
||||
bool m_bOffMap : 1;
|
||||
bool m_bIsPlayer : 1;
|
||||
bool m_bIsSelected : 1;
|
||||
bool m_bIsSpeaking : 1;
|
||||
bool m_bIsDead : 1;
|
||||
bool m_bIsBot : 1;
|
||||
bool m_bIsMovingHostage : 1;
|
||||
bool m_bIsSpotted : 1;
|
||||
bool m_bIsSpottedByFriendsOnly : 1;
|
||||
bool m_bIsRescued : 1;
|
||||
bool m_bIsOnLocalTeam : 1;
|
||||
bool m_bIsDefuser : 1;
|
||||
bool m_bHostageIsUsed : 1;
|
||||
|
||||
// don't put anything new after the bitfields or suffer the Wrath of the Compiler!
|
||||
|
||||
};
|
||||
|
||||
|
||||
// this little class manages the display of the hostage
|
||||
// indicators in the panel
|
||||
|
||||
class SFHudRadarHostageIcons
|
||||
{
|
||||
public:
|
||||
enum HOSTAGE_ICON_INDICES
|
||||
{
|
||||
HI_DEAD,
|
||||
HI_RESCUED,
|
||||
HI_ALIVE,
|
||||
HI_TRANSIT,
|
||||
HI_NUM_ICONS,
|
||||
|
||||
HI_UNUSED = HI_NUM_ICONS,
|
||||
};
|
||||
public:
|
||||
|
||||
SFHudRadarHostageIcons();
|
||||
~SFHudRadarHostageIcons();
|
||||
|
||||
void Init( IScaleformUI* scaleformui, SFVALUE iconPackage );
|
||||
void ReleaseHandles( SFHudRadar* pradar );
|
||||
|
||||
void SetStatus( int status );
|
||||
|
||||
public:
|
||||
IScaleformUI* m_pScaleformUI;
|
||||
|
||||
// the parent object of all the icons
|
||||
SFVALUE m_IconPackage;
|
||||
|
||||
// the icons which represent each of the HOSTAGE_ICON_INDICES
|
||||
SFVALUE m_Icons[HI_NUM_ICONS];
|
||||
|
||||
// the index of the icon that is currently shown
|
||||
int m_iCurrentIcon;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// this just keeps track of the bombzone and hostagezone
|
||||
// icons that are shown on the radar
|
||||
|
||||
struct SFHudRadarGoalIcon
|
||||
{
|
||||
Vector m_Position;
|
||||
SFVALUE m_Icon;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
explicit SFHudRadar( const char *value );
|
||||
virtual ~SFHudRadar();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual void Init( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void Reset( void )
|
||||
{
|
||||
SetActive( true );
|
||||
}
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashLoaded( void );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
void MapLoaded( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// overloads for the CGameEventListener class
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
bool MsgFunc_ProcessSpottedEntityUpdate( const CCSUsrMsg_ProcessSpottedEntityUpdate &msg );
|
||||
|
||||
void ShowRadar( bool value ) {m_bShowRadar = value;}
|
||||
bool IsRadarShown( void ) {return m_bShowRadar;}
|
||||
|
||||
void ResizeHud( void );
|
||||
void SwitchRadarToRound( bool toRound );
|
||||
|
||||
CUserMessageBinder m_UMCMsgProcessSpottedEntityUpdate;
|
||||
|
||||
bool m_bRound; // Is the radar round ( otherwise square )
|
||||
|
||||
protected:
|
||||
|
||||
void ResetRadar( bool bResetGlobalStates = true );
|
||||
|
||||
void ResetForNewMap( void );
|
||||
void ResetRound( void );
|
||||
void SetMap( const char* pMapName );
|
||||
void WorldToRadar( const Vector& ptin, Vector& ptout );
|
||||
void RadarToHud( const Vector& ptin, Vector& ptout );
|
||||
void LazyCreateGoalIcons( void );
|
||||
void FlashLoadMap( const char* pMapName );
|
||||
void FlashUpdateMapLayer( int layerIdx );
|
||||
|
||||
void InitIconPackage( SFHudRadarIconPackage* pPlayer, int iAbsoluteIndex, ICON_PACK_TYPE packType );
|
||||
void RemoveIconPackage( SFHudRadarIconPackage* pPlayer );
|
||||
|
||||
SFHudRadarIconPackage* CreatePlayer( int index );
|
||||
void ResetPlayer( int index );
|
||||
void RemovePlayer( int index );
|
||||
|
||||
SFHudRadarIconPackage* CreateHostage( int index );
|
||||
void ResetHostage( int index );
|
||||
void RemoveHostage( int index );
|
||||
void RemoveStaleHostages( void );
|
||||
void RemoveAllHostages( void );
|
||||
|
||||
SFHudRadarIconPackage* CreateDecoy( int index );
|
||||
void RemoveAllDecoys( void );
|
||||
void RemoveDecoy( int index );
|
||||
|
||||
SFHudRadarIconPackage * CreateDefuser( int nEntityID );
|
||||
SFHudRadarIconPackage * GetDefuser( int nEntityID, bool bCreateIfNotFound = false );
|
||||
void SetDefuserPos( int nEntityID, int x, int y, int z, int a );
|
||||
void UpdateAllDefusers( void );
|
||||
void RemoveAllDefusers( void );
|
||||
void RemoveDefuser( int index );
|
||||
|
||||
bool LazyUpdateIconArray( SFHudRadarIconPackage* pArray, int lastIndex );
|
||||
virtual bool LazyCreateIconPackage( SFHudRadarIconPackage* pPackage );
|
||||
|
||||
void LazyCreatePlayerIcons( void );
|
||||
|
||||
void SetPlayerTeam( int index, int team );
|
||||
|
||||
int GetPlayerIndexFromUserID( int userID );
|
||||
int GetHostageIndexFromHostageEntityID( int entityID );
|
||||
int GetDecoyIndexFromEntityID( int entityID );
|
||||
int GetDefuseIndexFromEntityID( int nEntityID );
|
||||
|
||||
void ApplySpectatorModes( void );
|
||||
|
||||
void PositionRadarViewpoint( void );
|
||||
void PlaceGoalIcons( void );
|
||||
void Show( bool show );
|
||||
void PlacePlayers();
|
||||
void PlaceHostages();
|
||||
void SetIconPackagePosition( SFHudRadarIconPackage* pPackage );
|
||||
void UpdateMiscIcons( void );
|
||||
void SetVisibilityFlags( int newFlags );
|
||||
void SetupIconsFromStates( void );
|
||||
|
||||
void SetLocationText( wchar_t *newText );
|
||||
|
||||
void ResetRoundVariables( bool bResetGlobalStates = true );
|
||||
|
||||
void UpdateDecoys( void );
|
||||
|
||||
void UpdateAllPlayerNumbers( void );
|
||||
void UpdatePlayerNumber( SFHudRadarIconPackage* pPackage );
|
||||
|
||||
SFHudRadarIconPackage* GetRadarPlayer( int index );
|
||||
SFHudRadarIconPackage* GetRadarHostage( int index );
|
||||
SFHudRadarIconPackage* GetRadarDecoy( int index );
|
||||
SFHudRadarIconPackage* GetRadarDefuser( int index );
|
||||
SFHudRadarIconPackage* GetRadarHeight( int index );
|
||||
|
||||
protected:
|
||||
|
||||
// these are the icons used individually by the radar and panel
|
||||
enum RADAR_ICON_INDICES
|
||||
{
|
||||
RI_BOMB_IS_PLANTED,
|
||||
RI_BOMB_IS_PLANTED_MEDIUM,
|
||||
RI_BOMB_IS_PLANTED_FAST,
|
||||
RI_IN_HOSTAGE_ZONE,
|
||||
RI_DASHBOARD,
|
||||
RI_BOMB_ICON_PLANTED,
|
||||
RI_BOMB_ICON_DROPPED,
|
||||
RI_BOMB_ICON_BOMB_CT,
|
||||
RI_BOMB_ICON_BOMB_T,
|
||||
RI_BOMB_ICON_BOMB_ABOVE,
|
||||
RI_BOMB_ICON_BOMB_BELOW,
|
||||
RI_BOMB_ICON_PACKAGE,
|
||||
RI_DEFUSER_ICON_DROPPED,
|
||||
RI_DEFUSER_ICON_PACKAGE,
|
||||
|
||||
RI_NUM_ICONS,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_BOMB_ZONES = 2,
|
||||
};
|
||||
|
||||
int m_nCurrentRadarVerticalSection;
|
||||
|
||||
struct HudRadarLevelVerticalSection_t
|
||||
{
|
||||
int m_nSectionIndex;
|
||||
char m_szSectionName[MAX_MAP_NAME];
|
||||
float m_flSectionAltitudeFloor;
|
||||
float m_flSectionAltitudeCeiling;
|
||||
|
||||
HudRadarLevelVerticalSection_t()
|
||||
{
|
||||
m_nSectionIndex = 0;
|
||||
m_szSectionName[0] = 0;
|
||||
m_flSectionAltitudeFloor = 0;
|
||||
m_flSectionAltitudeCeiling = 0;
|
||||
}
|
||||
};
|
||||
|
||||
CUtlVector< HudRadarLevelVerticalSection_t > m_vecRadarVerticalSections;
|
||||
|
||||
// this holds the names and indexes of the messages we receive so that
|
||||
// we don't have to do a whole bunch of string compares to find them
|
||||
static CUtlMap<const char*, int> m_messageMap;
|
||||
|
||||
// these are used to scale world coordinates to radar coordinates
|
||||
Vector m_MapOrigin;
|
||||
float m_fMapSize;
|
||||
float m_fRadarSize;
|
||||
float m_fPixelToRadarScale;
|
||||
float m_fWorldToPixelScale;
|
||||
float m_fWorldToRadarScale;
|
||||
|
||||
|
||||
// this is center of the radar in world and map coordinates
|
||||
Vector m_RadarViewpointWorld;
|
||||
Vector m_RadarViewpointMap;
|
||||
float m_RadarRotation;
|
||||
|
||||
// the current position of the bomb
|
||||
Vector m_BombPosition;
|
||||
|
||||
// the last time the bomb was seen. Used to fade
|
||||
// out the bomb icon after it has dropped out of sight
|
||||
float m_fBombSeenTime;
|
||||
float m_fBombAlpha;
|
||||
|
||||
|
||||
// the current position of the defuser
|
||||
Vector m_DefuserPosition;
|
||||
|
||||
// the last time the defuser was seen. Used to fade
|
||||
// out the defuser icon after it has dropped out of sight
|
||||
float m_fDefuserSeenTime;
|
||||
float m_fDefuserAlpha;
|
||||
|
||||
// a bitmap of the icons that are currently beeing shown.
|
||||
// each bit corresponds to one the RADAR_ICON_INDICES
|
||||
int m_iCurrentVisibilityFlags;
|
||||
|
||||
// the handles to the RADAR_ICON_INDICES icons
|
||||
SFVALUE m_Icons[RI_NUM_ICONS];
|
||||
|
||||
// Background panel
|
||||
SFVALUE m_BackgroundPanel;
|
||||
|
||||
// handles to the radar movie clips in flash.
|
||||
// there is a rotation and a translation layer each for the icons and for the background map.
|
||||
// The map and the icons have separate layers because the map is behind a mask layer, and the
|
||||
// icons are not.
|
||||
|
||||
// the root of the entire radar and dashboard
|
||||
SFVALUE m_RadarModule;
|
||||
|
||||
// the root of the radar part of the module
|
||||
SFVALUE m_Radar;
|
||||
|
||||
// the layers that handle the icons
|
||||
SFVALUE m_IconTranslation;
|
||||
SFVALUE m_IconRotation;
|
||||
|
||||
// the layers that handle the map
|
||||
SFVALUE m_MapRotation;
|
||||
SFVALUE m_MapTranslation;
|
||||
|
||||
// handles to the actual bomb zone and hostage icons that are defined
|
||||
// in the flash file
|
||||
SFVALUE m_HostageZoneIcons[MAX_HOSTAGE_RESCUES];
|
||||
SFVALUE m_BombZoneIcons[MAX_BOMB_ZONES];
|
||||
|
||||
// "handle" to the text that holds the current location
|
||||
ISFTextObject* m_LocationText;
|
||||
|
||||
// the last index of an active player in the m_Players array
|
||||
int m_iLastPlayerIndex;
|
||||
|
||||
// the last index of an active hostage in the m_Hostages array
|
||||
int m_iLastHostageIndex;
|
||||
|
||||
// the last index of an active decoy in the m_Decoys array
|
||||
int m_iLastDecoyIndex;
|
||||
|
||||
// the last index of an active defuser in the m_Defuser array
|
||||
int m_iLastDefuserIndex;
|
||||
|
||||
// keeps the state information and icon handles for the players
|
||||
SFHudRadarIconPackage m_Players[MAX_PLAYERS];
|
||||
|
||||
// keeps the state information and icon handles for the hostages
|
||||
SFHudRadarIconPackage m_Hostages[MAX_HOSTAGES];
|
||||
|
||||
// keeps the state information and icon handles for the decoys
|
||||
SFHudRadarIconPackage m_Decoys[MAX_DECOYS];
|
||||
|
||||
// keeps the state information and icon handles for the decoys
|
||||
SFHudRadarIconPackage m_Defusers[MAX_PLAYERS];
|
||||
|
||||
// the handles to the hostage status icons that appear beneath the dashboard
|
||||
SFHudRadarHostageIcons m_HostageStatusIcons[MAX_HOSTAGES];
|
||||
|
||||
// a goal icon is either a bomb-area or a hostage-area icon
|
||||
// This array holds the positions / handles of the ones that are active for the current map
|
||||
int m_iNumGoalIcons;
|
||||
SFHudRadarGoalIcon m_GoalIcons[MAX_HOSTAGE_RESCUES + MAX_BOMB_ZONES];
|
||||
|
||||
// the current observer mode. Figures into the placement of the center of the radar
|
||||
// and a few other things
|
||||
int m_iObserverMode;
|
||||
|
||||
// there is a loaded and a desired so that we don't load the same map twice, and so that we
|
||||
// can request that a map be loaded before the flash stuff is able to actually load it.
|
||||
char m_cLoadedMapName[MAX_MAP_NAME+1];
|
||||
char m_cDesiredMapName[MAX_MAP_NAME+1];
|
||||
|
||||
// the name of our current location
|
||||
wchar_t m_wcLocationString[MAX_LOCATION_TEXT_LENGTH+1];
|
||||
|
||||
// keeps track of weather flash is ready or not and if it's currently being loaded
|
||||
bool m_bFlashLoading : 1;
|
||||
bool m_bFlashReady : 1;
|
||||
|
||||
// this is set by a con command to hide the whole radar
|
||||
bool m_bShowRadar : 1;
|
||||
|
||||
bool m_bVisible;
|
||||
|
||||
bool m_bShowViewFrustrum;
|
||||
|
||||
// set to true in spectator mode if we're not in pro mode
|
||||
bool m_bShowAll : 1;
|
||||
|
||||
// keep track of whether we've already gotten all the goal icons and player icons from the
|
||||
// flash file. This is necessary because some of the level information is loaded before
|
||||
// flash is ready
|
||||
bool m_bGotGoalIcons : 1;
|
||||
bool m_bGotPlayerIcons : 1;
|
||||
|
||||
// state information about which icons should be displayed
|
||||
bool m_bShowingHostageZone : 1;
|
||||
bool m_bBombPlanted : 1;
|
||||
bool m_bBombDropped : 1;
|
||||
bool m_bBombDefused : 1;
|
||||
bool m_bBombExploded : 1;
|
||||
bool m_bShowBombHighlight : 1;
|
||||
bool m_bShowingDashboard : 1;
|
||||
|
||||
bool m_bBombIsSpotted : 1;
|
||||
int m_nBombEntIndex;
|
||||
int m_nBombHolderUserId;
|
||||
|
||||
bool m_bTrackDefusers;
|
||||
|
||||
// entities spotted last ProcessSpottedEntityUpdate
|
||||
CBitVec<MAX_EDICTS> m_EntitySpotted;
|
||||
};
|
||||
|
||||
#endif /* SFHUDRADAR_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef SFHUDRETICLE_H_
|
||||
#define SFHUDRETICLE_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
#if defined(_PS3) || defined(POSIX)
|
||||
#define HUDRET_WEPICON_SELECTED_IMG_STRING L"<img src='icon-%ls.png' height='22'/>"
|
||||
#define HUDRET_WEPICON_IMG_STRING L"<img src='icon-%ls_grey.png' height='22'/>"
|
||||
#else
|
||||
#define HUDRET_WEPICON_SELECTED_IMG_STRING L"<img src='icon-%s.png' height='22'/>"
|
||||
#define HUDRET_WEPICON_IMG_STRING L"<img src='icon-%s_grey.png' height='22'/>"
|
||||
#endif
|
||||
|
||||
#define VIEWPUNCH_COMPENSATE_MAGIC_SCALAR 0.65 // cl_flinch_scale.GetFloat()
|
||||
#define VIEWPUNCH_COMPENSATE_MAGIC_ANGLE 1
|
||||
|
||||
struct PlayerIDPanel
|
||||
{
|
||||
EHANDLE hPlayer;
|
||||
SFVALUE panel;
|
||||
SFVALUE arrowA;
|
||||
SFVALUE arrowB;
|
||||
SFVALUE arrowF;
|
||||
SFVALUE voiceIcon;
|
||||
SFVALUE defuseIcon;
|
||||
int iconsFlag;
|
||||
bool bActive;
|
||||
bool bShowName;
|
||||
bool bFriend;
|
||||
int nTeam;
|
||||
int nHealth;
|
||||
float flUpdateAt;
|
||||
float bFlashedAmt;
|
||||
|
||||
float flLastHighlightTime;
|
||||
float flNameAlpha;
|
||||
};
|
||||
|
||||
class SFHudReticle : public SFHudFlashInterface
|
||||
{
|
||||
enum
|
||||
{
|
||||
TEXTFIELD_LENGTH = 256
|
||||
};
|
||||
|
||||
public:
|
||||
enum RETICLE_MODE
|
||||
{
|
||||
RETICLE_MODE_NONE,
|
||||
RETICLE_MODE_WEAPON,
|
||||
RETICLE_MODE_OBSERVER
|
||||
};
|
||||
|
||||
explicit SFHudReticle( const char *value );
|
||||
virtual ~SFHudReticle();
|
||||
|
||||
void OnSwapReticle( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void ToggleTeamEquipmentVisibility( bool bShow );
|
||||
|
||||
protected:
|
||||
void ShowReticle( RETICLE_MODE mode, bool value );
|
||||
bool SetReticlePosition( int distance, int crosshairGap , int offsetX, int offsetY, int nDesiredFishtail );
|
||||
void LockSlot(bool wantItLocked, bool& currentlyLocked);
|
||||
|
||||
void ResetDisplay( void );
|
||||
int TeamToTextIndex( int iTeamNumber );
|
||||
|
||||
// Swaps the current reticle assets
|
||||
void PerformSwapReticle( const char * szReticleName );
|
||||
|
||||
void AddNewPlayerID( CBaseEntity *player, bool bShowName, bool bFriend = false );
|
||||
void UpdatePlayerID( CBaseEntity *player, int slot, bool bHealthAndNameOnly = false );
|
||||
void RemoveID( int index );
|
||||
void RemoveAllIDs( void );
|
||||
|
||||
void GetIconHTML( const wchar_t * szIcon, wchar_t * szBuffer, int nBufferSize, bool bSelected );
|
||||
|
||||
bool ShouldShowAllFriendlyTargetIDs( void );
|
||||
bool ShouldShowAllFriendlyEquipment( void );
|
||||
|
||||
protected:
|
||||
|
||||
wchar_t m_wcIDString[ TEXTFIELD_LENGTH ];
|
||||
|
||||
bool m_bCrosshairPositionsInitialized;
|
||||
|
||||
double m_TopPipY;
|
||||
double m_BottomPipY;
|
||||
double m_LeftPipX;
|
||||
double m_RightPipX;
|
||||
|
||||
float m_dotX;
|
||||
float m_dotY;
|
||||
float m_blackRingX;
|
||||
float m_blackRingY;
|
||||
float m_friendIndicatorX;
|
||||
float m_friendIndicatorY;
|
||||
|
||||
float m_IDMovieX;
|
||||
float m_IDMovieY;
|
||||
|
||||
SFVALUE m_WeaponCrosshairHandle;
|
||||
SFVALUE m_ObserverCrosshairHandle;
|
||||
SFVALUE m_TopPip;
|
||||
SFVALUE m_BottomPip;
|
||||
SFVALUE m_LeftPip;
|
||||
SFVALUE m_RightPip;
|
||||
|
||||
SFVALUE m_topCrosshairArc;
|
||||
SFVALUE m_rightCrosshairArc;
|
||||
SFVALUE m_leftCrosshairArc;
|
||||
SFVALUE m_bottomCrosshairArc;
|
||||
|
||||
SFVALUE m_FriendCrosshair;
|
||||
SFVALUE m_crosshairDot;
|
||||
SFVALUE m_blackRing;
|
||||
|
||||
SFVALUE m_IDMovie;
|
||||
SFVALUE m_IDText;
|
||||
|
||||
SFVALUE m_FlashedIcon;
|
||||
|
||||
RETICLE_MODE m_iReticleMode;
|
||||
|
||||
float m_fIDTimer;
|
||||
|
||||
int m_iLastGap;
|
||||
int m_iLastSpread;
|
||||
|
||||
bool m_bTextIDVisible;
|
||||
bool m_bFriendlyCrosshairVisible;
|
||||
bool m_bEnemyCrosshairVisible;
|
||||
|
||||
bool m_bFlashedIconFadingOut;
|
||||
|
||||
bool m_bForceShowAllTeammateTargetIDs;
|
||||
|
||||
CUtlVector<PlayerIDPanel> m_playerIDs;
|
||||
|
||||
};
|
||||
|
||||
extern ConVar crosshair;
|
||||
//extern ConVar sfcrosshair;
|
||||
|
||||
|
||||
#endif /* SFHUDRETICLE_H_ */
|
||||
@@ -0,0 +1,202 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jpaquin] The "Player Two press start" widget
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "iclientmode.h"
|
||||
#include "clientmode_csnormal.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
|
||||
#if defined( _X360 )
|
||||
#include "xbox/xbox_launch.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static const float UPDATE_INTERVAL = 60.0f;
|
||||
|
||||
class SFHudTrialTimer : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudTrialTimer( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_fNextUpdate( 0.0f ),
|
||||
m_bVisible( false )
|
||||
{
|
||||
SetHiddenBits( /* HIDEHUD_MISCSTATUS */ 0 );
|
||||
}
|
||||
|
||||
|
||||
virtual ~SFHudTrialTimer()
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessInput( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
if ( m_fNextUpdate < gpGlobals->curtime )
|
||||
{
|
||||
m_fNextUpdate = gpGlobals->curtime + UPDATE_INTERVAL;
|
||||
|
||||
bool bUnlocked = false;
|
||||
float timeLeft = 0;
|
||||
|
||||
|
||||
#if defined( _X360 )
|
||||
if ( xboxsystem )
|
||||
{
|
||||
bUnlocked = xboxsystem->IsArcadeTitleUnlocked();
|
||||
|
||||
if ( !bUnlocked )
|
||||
{
|
||||
timeLeft = xboxsystem->GetArcadeRemainingTrialTime( m_iFlashSlot - SF_FIRST_SS_SLOT );
|
||||
}
|
||||
}
|
||||
#else
|
||||
ConVarRef xbox_arcade_title_unlocked( "xbox_arcade_title_unlocked" );
|
||||
ConVarRef xbox_arcade_remaining_trial_time( "xbox_arcade_remaining_trial_time" );
|
||||
|
||||
bUnlocked = xbox_arcade_title_unlocked.GetBool();
|
||||
timeLeft = xbox_arcade_remaining_trial_time.GetFloat();
|
||||
#endif
|
||||
if ( !bUnlocked )
|
||||
{
|
||||
int minutesLeft = floorf( timeLeft / 60.0f );
|
||||
|
||||
minutesLeft = MAX( minutesLeft, 0 );
|
||||
|
||||
if ( minutesLeft == 1 )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pTimerMessage->SetTextHTML( "#SFUI_TrialHudTextMinute" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char strTrialTime[16];
|
||||
Q_snprintf( strTrialTime, sizeof( strTrialTime ), "%d", minutesLeft );
|
||||
|
||||
wchar_t buffer[128];
|
||||
wchar_t wTrialTime[16];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strTrialTime, wTrialTime, sizeof( wTrialTime ) );
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof( buffer ), g_pVGuiLocalize->Find( "#SFUI_TrialHudTextMinutes" ), 1, wTrialTime );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pTimerMessage->SetTextHTML( buffer );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudTrialTimer, this, TrialTimer );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetActive( bool bActive )
|
||||
{
|
||||
ShowPanel( bActive, false );
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
virtual bool ShouldDraw( void )
|
||||
{
|
||||
bool result = cl_drawhud.GetBool();
|
||||
|
||||
#if defined( _X360 )
|
||||
if ( result && xboxsystem )
|
||||
{
|
||||
result = !( xboxsystem->IsArcadeTitleUnlocked() );
|
||||
}
|
||||
#else
|
||||
ConVarRef xbox_arcade_title_unlocked( "xbox_arcade_title_unlocked" );
|
||||
result = result && !xbox_arcade_title_unlocked.GetBool();
|
||||
#endif
|
||||
|
||||
return result && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void )
|
||||
{
|
||||
SFVALUE panel = m_pScaleformUI->Value_GetMember( m_FlashAPI, "Panel" );
|
||||
|
||||
if ( panel != NULL )
|
||||
{
|
||||
m_pTimerMessage = m_pScaleformUI->TextObject_MakeTextObjectFromMember( panel, "AnimatedText" );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( panel );
|
||||
}
|
||||
|
||||
ShowPanel( m_bVisible, true );
|
||||
}
|
||||
|
||||
|
||||
virtual bool PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFTextObject( m_pTimerMessage );
|
||||
return SFHudFlashInterface::PreUnloadFlash();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void ShowPanel( bool bShow, bool force )
|
||||
{
|
||||
if ( ( bShow != m_bVisible ) || force )
|
||||
{
|
||||
m_bVisible = bShow;
|
||||
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
if ( m_bVisible )
|
||||
{
|
||||
m_fNextUpdate = 0.0f;
|
||||
ProcessInput();
|
||||
WITH_SLOT_LOCKED
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowPanel", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
ISFTextObject* m_pTimerMessage;
|
||||
float m_fNextUpdate;
|
||||
bool m_bVisible;
|
||||
|
||||
};
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudTrialTimer );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudTrialTimer, TrialTimer );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDVOTEPANEL_H
|
||||
#define SFHUDVOTEPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif //_WIN32
|
||||
|
||||
#include "sfhudflashinterface.h"
|
||||
|
||||
#define VOTE_PANEL_NAME_TRUNCATE_AT 16 // number of name character displayed before truncation
|
||||
|
||||
class SFHudVotePanel: public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudVotePanel( const char *value );
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual void SetActive( bool bActive );
|
||||
|
||||
//void TimerCallback( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void VoteYes( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void VoteNo( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void UpdateYesNoButtonText( bool bShowOtherTeam = false );
|
||||
|
||||
void Hide( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
bool MsgFunc_CallVoteFailed( const CCSUsrMsg_CallVoteFailed &msg );
|
||||
bool MsgFunc_VoteStart( const CCSUsrMsg_VoteStart &msg );
|
||||
bool MsgFunc_VotePass( const CCSUsrMsg_VotePass &msg );
|
||||
bool MsgFunc_VoteFailed( const CCSUsrMsg_VoteFailed &msg );
|
||||
bool MsgFunc_VoteSetup( const CCSUsrMsg_VoteSetup &msg );
|
||||
|
||||
void ShowVoteUI( wchar_t* headerText, wchar_t* voteText, bool bShowingOtherTeam = false );
|
||||
|
||||
void OnThink( void );
|
||||
|
||||
CUserMessageBinder m_UMCMsgCallVoteFailed;
|
||||
CUserMessageBinder m_UMCMsgVoteStart;
|
||||
CUserMessageBinder m_UMCMsgVotePass;
|
||||
CUserMessageBinder m_UMCMsgVoteFailed;
|
||||
CUserMessageBinder m_UMCMsgVoteSetup;
|
||||
|
||||
private:
|
||||
void SetVoteActive( bool bActive );
|
||||
|
||||
SFVALUE m_hVoteButtonBG;
|
||||
ISFTextObject* m_hVoteLocalCast;
|
||||
ISFTextObject* m_option1Text;
|
||||
ISFTextObject* m_option2Text;
|
||||
ISFTextObject* m_option1CountText;
|
||||
ISFTextObject* m_option2CountText;
|
||||
|
||||
CUtlStringList m_VoteSetupIssues;
|
||||
CUtlStringList m_VoteSetupMapCycle;
|
||||
CUtlStringList m_VoteSetupChoices;
|
||||
|
||||
bool m_bVoteActive;
|
||||
float m_flVoteResultCycleTime; // what time will we cycle to the result
|
||||
float m_flHideTime; // what time will we hide
|
||||
bool m_bVotePassed; // what mode are we going to cycle to
|
||||
int m_nVoteOptionCount[MAX_VOTE_OPTIONS]; // Vote options counter
|
||||
int m_nPotentialVotes; // If set, draw a line at this point to show the required bar length
|
||||
bool m_bIsYesNoVote;
|
||||
int m_nVoteChoicesCount;
|
||||
bool m_bPlayerVoted;
|
||||
int m_bPlayerLocalVote;
|
||||
float m_flPostVotedHideTime;
|
||||
bool m_bVisible;
|
||||
bool m_bHasFocus;
|
||||
|
||||
int m_nVoteYes;
|
||||
int m_nVoteNo;
|
||||
};
|
||||
|
||||
#endif // SFHUDVOTEPANEL_H
|
||||
@@ -0,0 +1,692 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements about health and armor
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hudelement.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "iclientmode.h"
|
||||
#include "view.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "ivrenderview.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudweaponpanel.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "c_cs_hostage.h"
|
||||
#include "HUD/sfweaponselection.h"
|
||||
#include "clientsteamcontext.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define SAFECALL( handle, func ) \
|
||||
if ( handle ) \
|
||||
{ \
|
||||
func \
|
||||
}
|
||||
|
||||
DECLARE_HUDELEMENT( SFHudWeaponPanel );
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SFHudWeaponPanel, WeaponModule ); // Asset named WeaponModule to maintain consistency with Flash file naming
|
||||
|
||||
extern ConVar cl_draw_only_deathnotices;
|
||||
|
||||
SFHudWeaponPanel::SFHudWeaponPanel( const char *value ) : SFHudFlashInterface( value ),
|
||||
m_PanelHandle( NULL ),
|
||||
m_CurrentWeaponImageHandle( NULL ),
|
||||
m_CurrentWeaponTextHandle( NULL ),
|
||||
m_AmmoTextClipHandle( NULL ),
|
||||
m_AmmoTextTotalHandle( NULL ),
|
||||
m_AmmoAnimationHandle( NULL ),
|
||||
m_BurstIcons_Burst( NULL ),
|
||||
m_BurstIcons_Single( NULL ),
|
||||
m_WeaponPenetration1( NULL ),
|
||||
m_WeaponPenetration2( NULL ),
|
||||
m_WeaponPenetration3( NULL ),
|
||||
m_UpgradeKill1( NULL ),
|
||||
m_UpgradeKill2( NULL ),
|
||||
m_UpgradeKillText( NULL ),
|
||||
m_BombHandle( NULL ),
|
||||
m_DefuseHandle( NULL ),
|
||||
m_BombZoneHandle( NULL ),
|
||||
m_WeaponItemName( NULL ),
|
||||
m_PrevAmmoClipCount( -1 ),
|
||||
m_PrevAmmoTotalCount( -1 ),
|
||||
m_PrevAmmoType( -1 ),
|
||||
m_PrevWeaponID( -1 ),
|
||||
m_PrevTRGunGameUpgradePoints( 0 ),
|
||||
m_bHiddenNoAmmo( false ),
|
||||
m_bCarryingC4( false ),
|
||||
m_bCarryingDefuse( false ),
|
||||
m_bInBombZone( false ),
|
||||
m_lastEntityIndex( 0 ),
|
||||
m_LastNumRoundKills( 0 ),
|
||||
m_lastKillEaterCount( 0 )
|
||||
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
SetHiddenBits( HIDEHUD_WEAPONSELECTION );
|
||||
}
|
||||
|
||||
|
||||
SFHudWeaponPanel::~SFHudWeaponPanel()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::ShowPanel( bool value )
|
||||
{
|
||||
if ( !m_pScaleformUI )
|
||||
return;
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
if ( value )
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showNow", NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hideNow", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::SetVisible( bool bVisible )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, bVisible );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setVisible", data, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::LockSlot( bool wantItLocked, bool& currentlyLocked )
|
||||
{
|
||||
if ( currentlyLocked != wantItLocked )
|
||||
{
|
||||
if ( wantItLocked )
|
||||
{
|
||||
LockScaleformSlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnlockScaleformSlot();
|
||||
}
|
||||
|
||||
currentlyLocked = wantItLocked;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::ProcessInput( void )
|
||||
{
|
||||
// Update stats
|
||||
int currentClip = 0;
|
||||
// we need the map clip to calculate the percentage of ammo left
|
||||
// in the clip so the hud knows when to warn you
|
||||
int maxClip = 0;
|
||||
int totalAmmo = 0;
|
||||
int ammoType = -1;
|
||||
int weaponID = -1;
|
||||
const char *weaponName = NULL;
|
||||
const char *shortWeaponName = NULL;
|
||||
bool bInTRBombMode = false;
|
||||
bool bHideNoAmmo = false;
|
||||
int CurrTRPoints = -1;
|
||||
|
||||
// Collect all player, weapon and game state data first:
|
||||
|
||||
if ( CSGameRules()->IsPlayingGunGame() )
|
||||
{
|
||||
if ( CSGameRules()->IsPlayingGunGameTRBomb() )
|
||||
{
|
||||
bInTRBombMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
C_CSPlayer *pPlayer = GetHudPlayer();
|
||||
CWeaponCSBase *pWeapon = NULL;
|
||||
int entityIndex = pPlayer->entindex();
|
||||
|
||||
if ( pPlayer)
|
||||
{
|
||||
if ( CSGameRules()->IsBombDefuseMap() || CSGameRules()->IsHostageRescueMap() )
|
||||
{
|
||||
if ( m_bCarryingC4 != pPlayer->HasC4() )
|
||||
{
|
||||
m_bCarryingC4 = pPlayer->HasC4();
|
||||
}
|
||||
|
||||
SFWeaponSelection *pHudWS = GET_HUDELEMENT( SFWeaponSelection );
|
||||
if ( pHudWS )
|
||||
{
|
||||
static ConVarRef cl_hud_bomb_under_radar( "cl_hud_bomb_under_radar" );
|
||||
bool bShowBomb = ( cl_hud_bomb_under_radar.GetInt( ) == 0 && m_bCarryingC4 );
|
||||
//SAFECALL( m_BombHandle, m_pScaleformUI->Value_SetVisible( m_BombHandle, bShowBomb ); );
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, bShowBomb );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowBomb", args, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_bCarryingDefuse != pPlayer->HasDefuser() )
|
||||
{
|
||||
m_bCarryingDefuse = pPlayer->HasDefuser();
|
||||
SAFECALL( m_DefuseHandle, m_pScaleformUI->Value_SetVisible( m_DefuseHandle, m_bCarryingDefuse ); );
|
||||
}
|
||||
|
||||
if ( m_bInBombZone != pPlayer->m_bInBombZone )
|
||||
{
|
||||
m_bInBombZone = pPlayer->m_bInBombZone;
|
||||
SAFECALL( m_BombZoneHandle, m_pScaleformUI->Value_SetVisible( m_BombZoneHandle, m_bInBombZone ); );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int nRoundKills = pPlayer->GetNumRoundKills();
|
||||
int nRoundKillsHeadshots = pPlayer->GetNumRoundKillsHeadshots();
|
||||
if( pPlayer->IsControllingBot() )
|
||||
{
|
||||
C_CSPlayer *controlledPlayerScorer = ToCSPlayer( UTIL_PlayerByIndex( pPlayer->GetControlledBotIndex() ) );
|
||||
if( controlledPlayerScorer )
|
||||
{
|
||||
nRoundKills = controlledPlayerScorer->GetNumRoundKills();
|
||||
nRoundKillsHeadshots = controlledPlayerScorer->GetNumRoundKillsHeadshots();
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_LastNumRoundKills != nRoundKills )
|
||||
{
|
||||
int nCurIndex = pPlayer->GetPlayerGunGameWeaponIndex();
|
||||
int nRequiredKills = 0;
|
||||
if ( CSGameRules()->IsPlayingGunGameProgressive() )
|
||||
nRequiredKills = CSGameRules()->GetGunGameNumKillsRequiredForWeapon( nCurIndex, pPlayer->GetTeamNumber() );
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 3 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, nRoundKills );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, nRoundKillsHeadshots );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, nRequiredKills );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setNumberKills", args, 3 );
|
||||
}
|
||||
|
||||
m_LastNumRoundKills = nRoundKills;
|
||||
}
|
||||
|
||||
if ( bInTRBombMode == true )
|
||||
{
|
||||
CurrTRPoints = pPlayer->GetNumGunGameTRKillPoints();
|
||||
|
||||
const int nUpgradedFlag = 99;
|
||||
|
||||
// We track "upgrade achieved" by saving the upgrade points as 99 - which means it will
|
||||
// always differ from the actual kill points once we've already upgraded. So, we don't
|
||||
// want to push another change to the panel until our points get reset at the next round
|
||||
bool bAlreadyUpgraded = ( m_PrevTRGunGameUpgradePoints == nUpgradedFlag );
|
||||
bool bZeroed = ( CurrTRPoints == 0 );
|
||||
|
||||
if ( ( m_PrevTRGunGameUpgradePoints != CurrTRPoints ) && ( !bAlreadyUpgraded || bZeroed ) )
|
||||
{
|
||||
// disable the little kill flags now because with the NEXT WEAPON panel serves this purpose and the flags cause confusion
|
||||
// TODO: find a way to bring the kill flags back some way because they add a lot of value
|
||||
/*
|
||||
switch( CurrTRPoints )
|
||||
{
|
||||
case 0:
|
||||
SAFECALL( m_UpgradeKill1, m_pScaleformUI->Value_SetVisible( m_UpgradeKill1, false); );
|
||||
SAFECALL( m_UpgradeKill2, m_pScaleformUI->Value_SetVisible( m_UpgradeKill2, false); );
|
||||
SAFECALL( m_UpgradeKillText, m_pScaleformUI->Value_SetVisible( m_UpgradeKillText, false ); );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
SAFECALL( m_UpgradeKill1, m_pScaleformUI->Value_SetVisible( m_UpgradeKill1, true); );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SAFECALL( m_UpgradeKill2, m_pScaleformUI->Value_SetVisible( m_UpgradeKill2, true); );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
static ConVarRef mp_ggtr_bomb_pts_for_upgrade( "mp_ggtr_bomb_pts_for_upgrade" );
|
||||
|
||||
if ( CurrTRPoints >= mp_ggtr_bomb_pts_for_upgrade.GetInt() )
|
||||
{
|
||||
// disable the little kill flags now because with the NEXT WEAPON panel serves this purpose and the flags cause confusion
|
||||
// TODO: find a way to bring the kill flags back some way because they add a lot of value
|
||||
/*
|
||||
SAFECALL( m_UpgradeKillText, m_pScaleformUI->Value_SetVisible( m_UpgradeKillText, true); );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "playUpgradeAnim", NULL, 0 );
|
||||
}
|
||||
*/
|
||||
|
||||
m_PrevTRGunGameUpgradePoints = nUpgradedFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PrevTRGunGameUpgradePoints = CurrTRPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pWeapon = pPlayer ? (CWeaponCSBase*)pPlayer->GetActiveWeapon() : NULL;
|
||||
|
||||
if ( pWeapon )
|
||||
{
|
||||
weaponName = pWeapon->GetPrintName();
|
||||
shortWeaponName = pWeapon->GetName();
|
||||
|
||||
// remap weaponID to our ammo numbering (defined in the action script for this hud element) - currently, just bullets vs grenades
|
||||
// $TODO: are we going to reflect any other ammo types, like XBLA did?
|
||||
|
||||
weaponID = pWeapon->GetCSWeaponID();
|
||||
switch ( weaponID )
|
||||
{
|
||||
case WEAPON_DECOY: // $FIXME: prototype grenades just display with the flashbang ammo
|
||||
case WEAPON_MOLOTOV:
|
||||
case WEAPON_INCGRENADE:
|
||||
case WEAPON_FLASHBANG:
|
||||
case WEAPON_TAGRENADE:
|
||||
ammoType = 1;
|
||||
break;
|
||||
case WEAPON_HEGRENADE:
|
||||
ammoType = 2;
|
||||
break;
|
||||
case WEAPON_SMOKEGRENADE:
|
||||
ammoType = 3;
|
||||
break;
|
||||
case WEAPON_HEALTHSHOT:
|
||||
ammoType = 10;
|
||||
break;
|
||||
default:
|
||||
ammoType = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// determine what to display for ammo: "clip/total", "total" or nothing (for knife, c4, etc)
|
||||
if ( !pWeapon->UsesPrimaryAmmo() )
|
||||
{
|
||||
currentClip = -1;
|
||||
maxClip = -1;
|
||||
totalAmmo = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentClip = pWeapon->Clip1();
|
||||
maxClip = pWeapon->GetMaxClip1();
|
||||
if ( currentClip < 0 )
|
||||
{
|
||||
// we don't use clip ammo, just use the total ammo count
|
||||
currentClip = pWeapon->GetReserveAmmoCount( AMMO_POSITION_PRIMARY );
|
||||
totalAmmo = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we use clip ammo, so the second ammo is the total ammo
|
||||
totalAmmo = pWeapon->GetReserveAmmoCount( AMMO_POSITION_PRIMARY );
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updating flash, slot locking begins...
|
||||
bool bSlotIsLocked = false;
|
||||
char cNewStr[ 128 ];
|
||||
|
||||
// Update weapon image and text
|
||||
if ( m_PrevWeaponID != weaponID )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
if ( weaponName )
|
||||
{
|
||||
SAFECALL( m_CurrentWeaponTextHandle, m_pScaleformUI->Value_SetText( m_CurrentWeaponTextHandle, weaponName ); );
|
||||
}
|
||||
|
||||
// Update the selected weapon image as well
|
||||
if ( FlashAPIIsValid() && shortWeaponName )
|
||||
{
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, shortWeaponName );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "switchWeaponName", data, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
// CCSWeaponInfo const * pWeaponInfo = GetWeaponInfo( static_cast<CSWeaponID>( weaponID ) );
|
||||
|
||||
CEconItemView *pItem = pWeapon ? pWeapon->GetEconItemView() : NULL;
|
||||
// if ( pWeaponInfo )
|
||||
// {
|
||||
// SAFECALL( m_WeaponPenetration1, m_pScaleformUI->Value_SetVisible( m_WeaponPenetration1, pWeaponInfo->GetAttributeFloat( "penetration", pItem ) == 1 ? true : false ); );
|
||||
// SAFECALL( m_WeaponPenetration2, m_pScaleformUI->Value_SetVisible( m_WeaponPenetration2, pWeaponInfo->GetAttributeFloat( "penetration", pItem ) == 2 ? true : false ); );
|
||||
// SAFECALL( m_WeaponPenetration3, m_pScaleformUI->Value_SetVisible( m_WeaponPenetration3, pWeaponInfo->GetAttributeFloat( "penetration", pItem ) == 3 ? true : false ); );
|
||||
// }
|
||||
|
||||
// update the weapon name
|
||||
if ( pWeapon )
|
||||
{
|
||||
if ( !pItem || !pItem->IsValid() || pItem->GetItemID() <= 0 || !GetItemSchema() || !GetItemSchema()->GetRarityDefinition( pItem->GetRarity() ) )
|
||||
{
|
||||
SAFECALL( m_WeaponItemName, m_pScaleformUI->Value_SetVisible( m_WeaponItemName, false ); );
|
||||
}
|
||||
else
|
||||
{
|
||||
const CEconItemRarityDefinition* pRarity = GetItemSchema()->GetRarityDefinition( pItem->GetRarity() );
|
||||
SAFECALL( m_WeaponItemName, m_pScaleformUI->Value_SetVisible( m_WeaponItemName, true ); );
|
||||
const int kColorBufSize = 128;
|
||||
wchar_t rwchColor[kColorBufSize];
|
||||
Q_UTF8ToUnicode( GetHexColorForAttribColor( pRarity->GetAttribColor() ), rwchColor, kColorBufSize );
|
||||
|
||||
// Update target name
|
||||
wchar_t wcTargetWeaponFormatted[128];
|
||||
V_snwprintf( wcTargetWeaponFormatted, ARRAYSIZE( wcTargetWeaponFormatted ), L"<font color=\"" PRI_WS_FOR_WS L"\">" PRI_WS_FOR_WS L"</font>", rwchColor, pItem->GetItemName() );
|
||||
SAFECALL( m_WeaponItemName, m_pScaleformUI->Value_SetTextHTML( m_WeaponItemName, wcTargetWeaponFormatted ); );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if this weapon has no ammo at all, so the panel should be hidden
|
||||
bHideNoAmmo = (( totalAmmo < 0 ) && ( currentClip < 0 )) || !pWeapon;
|
||||
|
||||
if ( ( bInTRBombMode && CurrTRPoints > 0 ) ||
|
||||
m_bCarryingC4 || m_bCarryingDefuse || m_bInBombZone || weaponID == WEAPON_KNIFE )
|
||||
{
|
||||
// Ensure we still show this when in TR Bomb AND we have kill points to display
|
||||
// or if we have bomb/defuse kit or are in the bomb zone
|
||||
bHideNoAmmo = false;
|
||||
}
|
||||
|
||||
// Update ammo type/count/animating bullets elements
|
||||
|
||||
if (
|
||||
( totalAmmo != m_PrevAmmoTotalCount ) ||
|
||||
( currentClip != m_PrevAmmoClipCount ) ||
|
||||
( weaponID != m_PrevWeaponID ) )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
// Display current weapon ammunition (or lack thereof)
|
||||
bool bAmmoShown = true;
|
||||
if ( totalAmmo < 0 )
|
||||
{
|
||||
// doesn't use ammo at all (knife, c4, etc)
|
||||
cNewStr[0] = 0;
|
||||
bAmmoShown = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
V_snprintf( cNewStr, sizeof( cNewStr ), "%d", currentClip );
|
||||
}
|
||||
|
||||
if ( bAmmoShown )
|
||||
{
|
||||
SAFECALL( m_AmmoTextClipHandle, m_pScaleformUI->Value_SetText( m_AmmoTextClipHandle, cNewStr ); );
|
||||
V_snprintf( cNewStr, sizeof( cNewStr ), "/ %d", totalAmmo );
|
||||
SAFECALL( m_AmmoTextTotalHandle, m_pScaleformUI->Value_SetText( m_AmmoTextTotalHandle, cNewStr ); );
|
||||
}
|
||||
|
||||
SAFECALL( m_AmmoTextClipHandle, m_pScaleformUI->Value_SetVisible( m_AmmoTextClipHandle, bAmmoShown ); );
|
||||
SAFECALL( m_AmmoTextTotalHandle, m_pScaleformUI->Value_SetVisible( m_AmmoTextTotalHandle, bAmmoShown ); );
|
||||
}
|
||||
|
||||
bool bShowBurstBurst = (pWeapon && pWeapon->WeaponHasBurst() && pWeapon->IsInBurstMode());
|
||||
bool bShowBurstSingle = (pWeapon && pWeapon->WeaponHasBurst() && !pWeapon->IsInBurstMode());
|
||||
SAFECALL( m_BurstIcons_Burst, m_pScaleformUI->Value_SetVisible( m_BurstIcons_Burst, bShowBurstBurst ); );
|
||||
SAFECALL( m_BurstIcons_Single, m_pScaleformUI->Value_SetVisible( m_BurstIcons_Single, bShowBurstSingle ); );
|
||||
|
||||
// Show the appropriate ammo for our weapon type
|
||||
if ( ( m_PrevAmmoType != ammoType ) ||
|
||||
( m_PrevAmmoClipCount != currentClip ) || (ammoType != 0 && weaponID != m_PrevWeaponID) )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
WITH_SFVALUEARRAY( data, 4 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, ammoType );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, currentClip );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 2, maxClip );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 3, shortWeaponName );
|
||||
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "updateAmmo", data, 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notify the HUD when we fire - detected by not changing weapon/observed player, and our ammo count decreases
|
||||
if ( entityIndex == m_lastEntityIndex && m_PrevWeaponID == weaponID && (ammoType == 0) && m_PrevAmmoClipCount > 0 && currentClip < m_PrevAmmoClipCount )
|
||||
{
|
||||
if ( m_FlashAPI )
|
||||
{
|
||||
LockSlot( true, bSlotIsLocked );
|
||||
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "weaponFired", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Update previous state so we know which elements need to be refreshed next time
|
||||
m_PrevAmmoClipCount = currentClip;
|
||||
m_PrevAmmoTotalCount = totalAmmo;
|
||||
m_PrevAmmoType = ammoType;
|
||||
m_PrevWeaponID = weaponID;
|
||||
m_lastEntityIndex = entityIndex;
|
||||
|
||||
LockSlot( false, bSlotIsLocked );
|
||||
|
||||
// Now determine if the panel should be entirely hidden, because our current weapon uses no ammo
|
||||
if ( bHideNoAmmo != m_bHiddenNoAmmo )
|
||||
{
|
||||
if ( m_bActive )
|
||||
{
|
||||
ShowPanel( !bHideNoAmmo );
|
||||
}
|
||||
|
||||
m_bHiddenNoAmmo = bHideNoAmmo;
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pLocalPlayer )
|
||||
return;
|
||||
|
||||
int nPlayerUserID = pLocalPlayer->GetUserID();
|
||||
int nEventUserID = event->GetInt( "userid" );
|
||||
|
||||
if ( StringHasPrefix( type, "round_start" ) ||
|
||||
( StringHasPrefix( type, "player_death" ) && nPlayerUserID == nEventUserID ) ||
|
||||
( StringHasPrefix( type, "bot_takeover" ) && nEventUserID == nPlayerUserID ) )
|
||||
{
|
||||
// reset these when the reound restarts of if the player dies
|
||||
m_bCarryingC4 = false;
|
||||
m_bCarryingDefuse = false;
|
||||
SAFECALL( m_BombHandle, m_pScaleformUI->Value_SetVisible( m_BombHandle, false ); );
|
||||
SAFECALL( m_DefuseHandle, m_pScaleformUI->Value_SetVisible( m_DefuseHandle, false ); );
|
||||
|
||||
if ( ( StringHasPrefix( type, "player_death" ) && !CSGameRules()->IsWarmupPeriod() ) )
|
||||
{
|
||||
int nCurIndex = pLocalPlayer->GetPlayerGunGameWeaponIndex();
|
||||
|
||||
int nRequiredKills = 0;
|
||||
if ( CSGameRules()->IsPlayingGunGameProgressive() )
|
||||
nRequiredKills = CSGameRules()->GetGunGameNumKillsRequiredForWeapon( nCurIndex, pLocalPlayer->GetTeamNumber() );
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 3 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, 0 );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, 0 );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, nRequiredKills );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setNumberKills", args, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( CSGameRules()->IsPlayingGunGameProgressive() )
|
||||
{
|
||||
m_LastNumRoundKills = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void GetTextBoxForElement( IScaleformUI *pScaleformUI, SFVALUE root, const char *elementName, const char *textElementName, SFVALUE &sfv )
|
||||
{
|
||||
SFVALUE TempHandle = pScaleformUI->Value_GetMember( root, elementName );
|
||||
|
||||
if ( TempHandle )
|
||||
{
|
||||
sfv = pScaleformUI->Value_GetMember( TempHandle, textElementName );
|
||||
pScaleformUI->ReleaseValue( TempHandle );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::FlashReady( void )
|
||||
{
|
||||
m_PanelHandle = m_pScaleformUI->Value_GetMember( m_FlashAPI, "HudPanel" );
|
||||
|
||||
if ( m_PanelHandle )
|
||||
{
|
||||
SFVALUE AnimatedPanelHandle = m_pScaleformUI->Value_GetMember( m_PanelHandle, "WeaponPanel" );
|
||||
|
||||
if ( AnimatedPanelHandle )
|
||||
{
|
||||
m_CurrentWeaponImageHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "CurrentWeapon" );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "WeaponText", "TextBox", m_CurrentWeaponTextHandle );
|
||||
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "AmmoCountClip", "TextBox", m_AmmoTextClipHandle );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "AmmoCountTotal", "TextBox", m_AmmoTextTotalHandle );
|
||||
GetTextBoxForElement( m_pScaleformUI, AnimatedPanelHandle, "WeaponName", "TextBox", m_WeaponItemName );
|
||||
m_AmmoAnimationHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "AmmoAnim" );
|
||||
|
||||
m_BurstIcons_Burst = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "BurstTypeBurst" );
|
||||
m_BurstIcons_Single = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "BurstTypeSingle" );
|
||||
|
||||
m_WeaponPenetration1 = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "Penetration1" );
|
||||
m_WeaponPenetration2 = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "Penetration2" );
|
||||
m_WeaponPenetration3 = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "Penetration3" );
|
||||
m_UpgradeKill1 = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "Kill1" );
|
||||
m_UpgradeKill2 = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "Kill2" );
|
||||
m_UpgradeKillText = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "UpgradeText" );
|
||||
|
||||
m_BombHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "BombCarrierIcon" );
|
||||
m_DefuseHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "DefuseKitIcon" );
|
||||
m_BombZoneHandle = m_pScaleformUI->Value_GetMember( AnimatedPanelHandle, "InBombZoneIcon" );
|
||||
|
||||
SAFECALL( m_UpgradeKill1, m_pScaleformUI->Value_SetVisible( m_UpgradeKill1, false); );
|
||||
SAFECALL( m_UpgradeKill2, m_pScaleformUI->Value_SetVisible( m_UpgradeKill2, false); );
|
||||
SAFECALL( m_UpgradeKillText, m_pScaleformUI->Value_SetVisible( m_UpgradeKillText, false); );
|
||||
|
||||
SAFECALL( m_BombHandle, m_pScaleformUI->Value_SetVisible( m_BombHandle, false ); );
|
||||
SAFECALL( m_DefuseHandle, m_pScaleformUI->Value_SetVisible( m_DefuseHandle, false ); );
|
||||
SAFECALL( m_BombZoneHandle, m_pScaleformUI->Value_SetVisible( m_BombZoneHandle, false ); );
|
||||
|
||||
SAFECALL( m_WeaponItemName, m_pScaleformUI->Value_SetVisible( m_WeaponItemName, false ); );
|
||||
|
||||
m_pScaleformUI->ReleaseValue( AnimatedPanelHandle );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
ListenForGameEvent( "round_start" );
|
||||
ListenForGameEvent( "player_death" );
|
||||
ListenForGameEvent( "bot_takeover" );
|
||||
}
|
||||
|
||||
// hide everything initially
|
||||
SetVisible( false );
|
||||
}
|
||||
|
||||
bool SFHudWeaponPanel::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFVALUE( m_PanelHandle );
|
||||
SafeReleaseSFVALUE( m_CurrentWeaponImageHandle );
|
||||
SafeReleaseSFVALUE( m_CurrentWeaponTextHandle );
|
||||
SafeReleaseSFVALUE( m_AmmoTextClipHandle );
|
||||
SafeReleaseSFVALUE( m_AmmoTextTotalHandle );
|
||||
SafeReleaseSFVALUE( m_AmmoAnimationHandle );
|
||||
SafeReleaseSFVALUE( m_BurstIcons_Burst );
|
||||
SafeReleaseSFVALUE( m_BurstIcons_Single );
|
||||
SafeReleaseSFVALUE( m_WeaponPenetration1 );
|
||||
SafeReleaseSFVALUE( m_WeaponPenetration2 );
|
||||
SafeReleaseSFVALUE( m_WeaponPenetration3 );
|
||||
SafeReleaseSFVALUE( m_UpgradeKill1 );
|
||||
SafeReleaseSFVALUE( m_UpgradeKill2 );
|
||||
SafeReleaseSFVALUE( m_UpgradeKillText );
|
||||
SafeReleaseSFVALUE( m_BombHandle );
|
||||
SafeReleaseSFVALUE( m_DefuseHandle );
|
||||
SafeReleaseSFVALUE( m_BombZoneHandle );
|
||||
SafeReleaseSFVALUE( m_WeaponItemName );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::LevelInit( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudWeaponPanel, this, WeaponModule );
|
||||
}
|
||||
else
|
||||
{
|
||||
// When initially loaded, hide this panel
|
||||
SetVisible( false );
|
||||
}
|
||||
|
||||
// Reset all transient data
|
||||
m_PrevAmmoClipCount = -1;
|
||||
m_PrevAmmoTotalCount = -1;
|
||||
m_PrevAmmoType = -1;
|
||||
m_PrevWeaponID = -1;
|
||||
m_PrevTRGunGameUpgradePoints = 0;
|
||||
m_bHiddenNoAmmo = false;
|
||||
}
|
||||
|
||||
void SFHudWeaponPanel::LevelShutdown( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool SFHudWeaponPanel::ShouldDraw( void )
|
||||
{
|
||||
return cl_drawhud.GetBool() && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
|
||||
}
|
||||
|
||||
|
||||
void SFHudWeaponPanel::SetActive( bool bActive )
|
||||
{
|
||||
// Do not show the panel if we have hidden it because of an ammo-less weapon
|
||||
if ( bActive != m_bActive && !m_bHiddenNoAmmo )
|
||||
{
|
||||
ShowPanel( bActive );
|
||||
}
|
||||
|
||||
CHudElement::SetActive( bActive );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Displays HUD elements about health and armor
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SFHUDWEAPONPANEL_H_
|
||||
#define SFHUDWEAPONPANEL_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
|
||||
|
||||
class SFHudWeaponPanel : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFHudWeaponPanel( const char *value );
|
||||
virtual ~SFHudWeaponPanel();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
virtual void Init( void ) { SetVisible( true ); }
|
||||
virtual void Reset( void ) { SetVisible( true ); }
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
protected:
|
||||
void ShowPanel( bool value );
|
||||
void SetVisible( bool bVisible );
|
||||
void LockSlot( bool wantItLocked, bool& currentlyLocked );
|
||||
|
||||
protected:
|
||||
SFVALUE m_PanelHandle;
|
||||
SFVALUE m_CurrentWeaponImageHandle;
|
||||
SFVALUE m_CurrentWeaponTextHandle;
|
||||
SFVALUE m_AmmoTextClipHandle;
|
||||
SFVALUE m_AmmoTextTotalHandle;
|
||||
SFVALUE m_AmmoAnimationHandle;
|
||||
SFVALUE m_BurstIcons_Burst;
|
||||
SFVALUE m_BurstIcons_Single;
|
||||
SFVALUE m_WeaponPenetration1;
|
||||
SFVALUE m_WeaponPenetration2;
|
||||
SFVALUE m_WeaponPenetration3;
|
||||
SFVALUE m_UpgradeKill1;
|
||||
SFVALUE m_UpgradeKill2;
|
||||
SFVALUE m_UpgradeKillText;
|
||||
SFVALUE m_BombHandle;
|
||||
SFVALUE m_DefuseHandle;
|
||||
SFVALUE m_BombZoneHandle;
|
||||
SFVALUE m_WeaponItemName;
|
||||
|
||||
int m_PrevAmmoClipCount;
|
||||
int m_PrevAmmoTotalCount;
|
||||
int m_PrevAmmoType;
|
||||
int m_PrevWeaponID;
|
||||
int m_PrevTRGunGameUpgradePoints;
|
||||
bool m_bHiddenNoAmmo; // we hid the panel because our current weapon has no ammo at all
|
||||
bool m_bCarryingC4; // player is carrying the bomb
|
||||
bool m_bCarryingDefuse; // player is carrying a defuse kit
|
||||
bool m_bInBombZone ; // player is in the bomb zone
|
||||
int m_lastEntityIndex;
|
||||
int m_LastNumRoundKills;
|
||||
int m_lastKillEaterCount;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SFHUDWEAPONPANEL_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,111 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDWINPANEL_H
|
||||
#define SFHUDWINPANEL_H
|
||||
#pragma once
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "ehandle.h"
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "ammodef.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
enum
|
||||
{
|
||||
WIN_EXTRATYPE_NONE = 0,
|
||||
WIN_EXTRATYPE_AWARD,
|
||||
WIN_EXTRATYPE_RANK,
|
||||
WIN_EXTRATYPE_ELO,
|
||||
WIN_EXTRATYPE_GGNEXT,
|
||||
WIN_EXTRATYPE_SEASONRANK,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Used to draw the history of weapon / item pickups and purchases by the player
|
||||
//-----------------------------------------------------------------------------
|
||||
class SFHudWinPanel: public SFHudFlashInterface, public IShaderDeviceDependentObject
|
||||
{
|
||||
public:
|
||||
explicit SFHudWinPanel( const char *value );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void ProcessInput( void );
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
// Offsets the Y location of the win panel
|
||||
void ApplyYOffset( int nOffset );
|
||||
|
||||
bool IsVisible( void );
|
||||
|
||||
// IShaderDeviceDependentObject methods
|
||||
virtual void DeviceLost( void ) { }
|
||||
virtual void DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd );
|
||||
virtual void ScreenSizeChanged( int width, int height ) { }
|
||||
|
||||
int m_iMVP;
|
||||
|
||||
|
||||
protected:
|
||||
void SetMVP( C_CSPlayer* pPlayer, CSMvpReason_t reason, int32 nMusicKitMVPs = 0 );
|
||||
void SetFunFactLabel( const wchar *szFunFact );
|
||||
void SetProgressBarText( int nAmount, const wchar *wszDescText );
|
||||
|
||||
//void MovieClipSetVisibility( SFVALUE panel, bool bShow );
|
||||
//void TextPanelSetVisibility( ISFTextObject* panel, bool bShow );
|
||||
|
||||
private:
|
||||
|
||||
void ShowTeamWinPanel( int result, const char* winnerText );
|
||||
void ShowGunGameWinPanel( void /*int nWinner, int nSecond, int nThird*/ );
|
||||
void ShowWinExtraDataPanel( int nExtraPanelType );
|
||||
void SetWinPanelExtraData( void );
|
||||
void Hide( void );
|
||||
|
||||
SFVALUE m_hWinPanelParent;
|
||||
ISFTextObject* m_hWinner;
|
||||
ISFTextObject* m_hReason;
|
||||
ISFTextObject* m_hMVP;
|
||||
ISFTextObject* m_hSurrender;
|
||||
|
||||
ISFTextObject* m_hFunFact;
|
||||
|
||||
SFVALUE m_hEloPanel;
|
||||
SFVALUE m_hRankPanel;
|
||||
SFVALUE m_hItemPanel;
|
||||
SFVALUE m_hMedalPanel;
|
||||
SFVALUE m_hProgressText;
|
||||
SFVALUE m_hNextWeaponPanel;
|
||||
|
||||
bool m_bVisible;
|
||||
|
||||
int m_nFunFactPlayer;
|
||||
string_t m_nFunfactToken;
|
||||
int m_nFunFactParam1;
|
||||
int m_nFunFactParam2;
|
||||
int m_nFunFactParam3;
|
||||
|
||||
|
||||
int m_nRoundStartELO;
|
||||
|
||||
bool m_bShouldSetWinPanelExtraData;
|
||||
float m_fSetWinPanelExtraDataTime;
|
||||
};
|
||||
|
||||
#endif // SFHUDWINPANEL_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,136 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFWEAPONSELECTION_H
|
||||
#define SFWEAPONSELECTION_H
|
||||
#pragma once
|
||||
|
||||
#include "hudelement.h"
|
||||
#include "ehandle.h"
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "sfhudflashinterface.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "weapon_csbase.h"
|
||||
#include "ammodef.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "cs_hud_weaponselection.h"
|
||||
|
||||
#define MAX_WEP_SELECT_PANELS 5
|
||||
#define MAX_WEP_SELECT_POSITIONS 6 // if we limit the grenades to three, this will go down
|
||||
#define WEAPON_SELECTION_FADE_TIME_SEC 1.25
|
||||
#define WEAPON_SELECTION_FADE_SPEED 100.0 / WEAPON_SELECTION_FADE_TIME_SEC
|
||||
#define WEAPON_SELECTION_FADE_DELAY 1.5
|
||||
#define WEAPON_SELECT_PANEL_HEIGHT 65
|
||||
|
||||
struct WeaponSelectPanel
|
||||
{
|
||||
SFVALUE handle;
|
||||
double alpha;
|
||||
EHANDLE hWeapon;
|
||||
bool bSelected;
|
||||
bool bJustPickedUp;
|
||||
float fEndBlinkTime;
|
||||
float fLastBlinkTime;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Used to draw the history of weapon / item pickups and purchases by the player
|
||||
//-----------------------------------------------------------------------------
|
||||
class SFWeaponSelection : public SFHudFlashInterface
|
||||
{
|
||||
public:
|
||||
explicit SFWeaponSelection( const char *value );
|
||||
|
||||
C_CSPlayer* GetLocalOrHudPlayer( void );
|
||||
|
||||
void AddWeapon( C_BaseCombatWeapon *pWeapon, bool bSelected );
|
||||
void UpdateGGNextPanel( bool bForceShowForTRBomb = false, bool bKnifeReached = false );
|
||||
void HideWeapon( int nSlot, int nPos );
|
||||
void RemoveWeapon( int nSlot, int nPos );
|
||||
|
||||
WeaponSelectPanel CreateNewPanel( C_BaseCombatWeapon *pWeapon = NULL, bool bSelected = false );
|
||||
void CreateGGNextPanel( void );
|
||||
void ShowAndUpdateSelection( int nType = WEPSELECT_SWITCH, C_BaseCombatWeapon *pWeapon = NULL, bool bGiveInitial = false );
|
||||
void UpdatePanelPositions( void );
|
||||
|
||||
void DisplayLevelUpNextWeapon( void );
|
||||
|
||||
void RemoveItem( int nSlot, int nPos );
|
||||
void RemoveAllItems( void );
|
||||
|
||||
virtual void ProcessInput( void );
|
||||
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual bool ShouldDraw( void );
|
||||
|
||||
void SetAlwaysShow( bool bAlwaysShow );
|
||||
|
||||
bool IsC4Visible( void ) { return m_bC4IsVisible; }
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
|
||||
// CGameEventListener methods
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
protected:
|
||||
// Calls either Show or Hide
|
||||
void ShowPanel( const bool bShow );
|
||||
|
||||
// Show the item history
|
||||
void Show( void );
|
||||
// Hide the item history
|
||||
void Hide( void );
|
||||
|
||||
virtual C_WeaponCSBase *GetSelectedWeapon( void )
|
||||
{
|
||||
return dynamic_cast<C_WeaponCSBase*>(m_hSelectedWeapon.Get());
|
||||
}
|
||||
|
||||
private:
|
||||
SFVALUE m_anchorPanel;
|
||||
float m_lastUpdate;
|
||||
float m_flFadeStartTime;
|
||||
//CUtlVector<WeaponSelectPanel> m_weaponPanels;
|
||||
WeaponSelectPanel m_weaponPanels[MAX_WEP_SELECT_PANELS][MAX_WEP_SELECT_POSITIONS];
|
||||
bool m_bVisible; // Element visibility flag
|
||||
CHandle< C_BaseCombatWeapon > m_hSelectedWeapon;
|
||||
WeaponSelectPanel m_selectedPanel;
|
||||
|
||||
bool m_bCreatedNextPanel;
|
||||
WeaponSelectPanel m_ggNextPanel;
|
||||
|
||||
int m_nPrevWepAlignSlot;
|
||||
int m_nPrevOccupiedWepSlot;
|
||||
|
||||
int m_nOrigXPos;
|
||||
int m_nOrigYPos;
|
||||
bool m_bInitPos;
|
||||
|
||||
bool m_bInitialized;
|
||||
|
||||
bool m_bAlwaysShow; // When true, will not fade out
|
||||
|
||||
bool m_bC4IsVisible;
|
||||
|
||||
int m_nLastTRKills;
|
||||
int m_nLastGGWepIndex;
|
||||
bool m_bUpdateGGNextPanel;
|
||||
float m_flUpdateInventoryAt;
|
||||
bool m_bUpdateInventoryReset;
|
||||
|
||||
int m_bSpectatorTargetIndex;
|
||||
};
|
||||
|
||||
#endif // SFWEAPONSELECTION_H
|
||||
@@ -0,0 +1,47 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "blog_scaleform.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
CBlogScaleform* CBlogScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
IMPLEMENT_HTML_SFUI_METHODS,
|
||||
SFUI_END_GAME_API_DEF( CBlogScaleform, MainMenuBlogPanel );
|
||||
|
||||
void CBlogScaleform::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CBlogScaleform();
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CBlogScaleform, m_pInstance, MainMenuBlogPanel );
|
||||
}
|
||||
}
|
||||
|
||||
void CBlogScaleform::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
void CBlogScaleform::FlashReady( void )
|
||||
{
|
||||
SFDevMsg("CBlogScaleform::FlashReady\n");
|
||||
|
||||
//InitChromeHTML( "img://chrome_1", "ChromeHTML_UpdateBlog", "http://www.google.com", "" );
|
||||
InitChromeHTML( "http://store.steampowered.com/news/?appids=730", "" );
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,39 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [thomask] Displays blog in Scaleform.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef BLOG_SCALEFORM_H
|
||||
#define BLOG_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "html_base_scaleform.h"
|
||||
|
||||
class CBlogScaleform : public CHtmlBaseScaleform
|
||||
{
|
||||
private:
|
||||
static CBlogScaleform* m_pInstance;
|
||||
|
||||
public:
|
||||
|
||||
/************************************
|
||||
* Construction and Destruction
|
||||
*/
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
virtual void FlashReady( void );
|
||||
};
|
||||
|
||||
#endif // BLOG_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,395 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include <game/client/iviewport.h>
|
||||
#include "chooseclass_scaleform.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_team.h"
|
||||
#include "iclientmode.h"
|
||||
#include "ienginevgui.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "gameui_util.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( OnOk ),
|
||||
SFUI_DECL_METHOD( OnCancel ),
|
||||
SFUI_DECL_METHOD( OnLeft ),
|
||||
SFUI_DECL_METHOD( OnRight ),
|
||||
SFUI_DECL_METHOD( OnAutoSelect ),
|
||||
SFUI_DECL_METHOD( OnShowScoreboard ),
|
||||
SFUI_END_GAME_API_DEF( CChooseClassScaleform, ChooseClass );
|
||||
|
||||
//static ConVar player_classplayedlast_CT( "player_classplayedlast_CT", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_GAMECONSOLE | FCVAR_SS );
|
||||
//static ConVar player_classplayedlast_T( "player_classplayedlast_T", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_GAMECONSOLE | FCVAR_SS );
|
||||
|
||||
CChooseClassScaleform::CChooseClassScaleform( CounterStrikeViewport* pViewPort ) :
|
||||
m_bVisible ( false ),
|
||||
m_bLoading ( false ),
|
||||
m_pViewPort ( pViewPort ),
|
||||
m_pDescriptionText ( NULL ),
|
||||
m_pModelText ( NULL ),
|
||||
m_pTeamText ( NULL ),
|
||||
m_nNumClasses ( 0 ),
|
||||
m_nClassSelection ( 0 ),
|
||||
m_nTeamSelection ( 0 ),
|
||||
m_bCanceled ( false )
|
||||
{
|
||||
m_iSplitScreenSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
ListenForGameEvent( "class_selected" );
|
||||
ListenForGameEvent( "cs_game_disconnected" );
|
||||
}
|
||||
|
||||
CChooseClassScaleform::~CChooseClassScaleform()
|
||||
{
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::FlashLoaded( void )
|
||||
{
|
||||
// determine team
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
if ( pPlayer->GetTeamNumber() == TEAM_TERRORIST )
|
||||
{
|
||||
m_nTeamSelection = TEAM_TERRORIST;
|
||||
m_nNumClasses = PlayerModelInfo::GetPtr()->GetNumTModels();
|
||||
}
|
||||
else if ( pPlayer->GetTeamNumber() == TEAM_CT )
|
||||
{
|
||||
m_nTeamSelection = TEAM_CT;
|
||||
m_nNumClasses = PlayerModelInfo::GetPtr()->GetNumCTModels();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no team selected
|
||||
Assert( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
SFVALUE panelValue = m_pScaleformUI->Value_GetMember( m_FlashAPI, "ChooseClass" );
|
||||
|
||||
if ( panelValue )
|
||||
{
|
||||
SFVALUE navCharPanel = m_pScaleformUI->Value_GetMember( panelValue, "NavPanel" );
|
||||
|
||||
if ( navCharPanel )
|
||||
{
|
||||
m_pDescriptionText = m_pScaleformUI->TextObject_MakeTextObjectFromMember( navCharPanel, "Desc_Text" );
|
||||
m_pModelText = m_pScaleformUI->TextObject_MakeTextObjectFromMember( navCharPanel, "Model_Text" );
|
||||
m_pTeamText = m_pScaleformUI->TextObject_MakeTextObjectFromMember( navCharPanel, "Team_Text" );
|
||||
|
||||
// change the team label depending on previous player team selection
|
||||
if ( m_pTeamText )
|
||||
{
|
||||
if ( m_nTeamSelection == TEAM_TERRORIST )
|
||||
{
|
||||
m_pTeamText->SetText( "#SFUI_T_Label" );
|
||||
}
|
||||
else if ( m_nTeamSelection == TEAM_CT )
|
||||
{
|
||||
m_pTeamText->SetText( "#SFUI_CT_Label" );
|
||||
}
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( navCharPanel );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( panelValue );
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::FlashReady( void )
|
||||
{
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
m_bLoading = false;
|
||||
|
||||
if ( m_bVisible )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::Show( void )
|
||||
{
|
||||
if ( !m_bLoading )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
engine->ClientCmd( "overview_mode 0" );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
//int nLastPlayed = 0;
|
||||
//if ( m_nTeamSelection == TEAM_CT )
|
||||
//{
|
||||
// nLastPlayed = player_classplayedlast_CT.GetInt();
|
||||
//}
|
||||
//else if ( m_nTeamSelection == TEAM_TERRORIST )
|
||||
//{
|
||||
// nLastPlayed = player_classplayedlast_T.GetInt();
|
||||
//}
|
||||
|
||||
m_nClassSelection = 0;
|
||||
SetSelectedClass( m_nClassSelection );
|
||||
UpdateClassText();
|
||||
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", 0, NULL );
|
||||
}
|
||||
|
||||
m_pViewPort->ShowBackGround( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLoading = true;
|
||||
SFUI_REQUEST_ELEMENT( SF_SS_SLOT( m_iSplitScreenSlot ), g_pScaleformUI, CChooseClassScaleform, this, ChooseClass );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::Hide( bool bRemove )
|
||||
{
|
||||
if ( !m_bLoading && FlashAPIIsValid() && m_bVisible )
|
||||
{
|
||||
if ( bRemove )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanelAndRemove", 0, NULL );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
m_pViewPort->ShowBackGround( false );
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
|
||||
bool CChooseClassScaleform::PreUnloadFlash( void )
|
||||
{
|
||||
StopListeningForAllEvents();
|
||||
|
||||
SafeReleaseSFTextObject( m_pDescriptionText );
|
||||
SafeReleaseSFTextObject( m_pModelText );
|
||||
SafeReleaseSFTextObject( m_pTeamText );
|
||||
|
||||
return ScaleformFlashInterface::PreUnloadFlash();
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
m_bLoading = false;
|
||||
|
||||
if ( m_bCanceled )
|
||||
{
|
||||
m_bCanceled = false;
|
||||
|
||||
IViewPortPanel *pTeamScreen = m_pViewPort->FindPanelByName( "team" );
|
||||
|
||||
if ( pTeamScreen )
|
||||
{
|
||||
// Go back to spectating and reset the team info
|
||||
engine->ClientCmd( "resetteam" );
|
||||
m_pViewPort->ShowPanel( pTeamScreen, true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pViewPort->SetChoseTeamAndClass( true );
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( bShow != m_bVisible )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
Show();
|
||||
engine->CheckPoint( "ClassMenu" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::OnAutoSelect( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
SaveAndJoin();
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::OnOk( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
SaveAndJoin();
|
||||
}
|
||||
|
||||
|
||||
void CChooseClassScaleform::SaveAndJoin( void )
|
||||
{
|
||||
// [jason] For updating the last played class in the main menu; written out for each player
|
||||
static CGameUIConVarRef s_player_classplayedlast( "player_classplayedlast" );
|
||||
|
||||
//player_classplayedlast_CT.SetValue( m_nTeamSelection );
|
||||
//s_player_classplayedlast.SetValue( m_nTeamSelection );
|
||||
|
||||
char szCommand[ 64 ];
|
||||
V_strcpy( szCommand, "joinclass" );
|
||||
engine->ClientCmd( szCommand );
|
||||
Hide( true );
|
||||
}
|
||||
|
||||
|
||||
void CChooseClassScaleform::OnCancel( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// reset selection
|
||||
m_nClassSelection = 0;
|
||||
UpdateClassText();
|
||||
|
||||
m_bCanceled = true;
|
||||
Hide( true );
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::UpdateClassText()
|
||||
{
|
||||
char szClassModel[255];
|
||||
szClassModel[0] = '\0';
|
||||
char szClassDesc[1024];
|
||||
szClassDesc[0] = '\0';
|
||||
|
||||
V_snprintf( szClassModel, sizeof(szClassModel), "#SFUI_Obsolete_Name" );
|
||||
V_snprintf( szClassDesc, sizeof(szClassDesc), "#SFUI_Obsolete_Label" );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_pModelText )
|
||||
{
|
||||
m_pModelText->SetText( szClassModel );
|
||||
}
|
||||
|
||||
if ( m_pDescriptionText )
|
||||
{
|
||||
m_pDescriptionText->SetText( szClassDesc );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::OnLeft( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
--m_nClassSelection;
|
||||
|
||||
if ( m_nClassSelection < 0 )
|
||||
{
|
||||
m_nClassSelection = m_nNumClasses - 1;
|
||||
}
|
||||
|
||||
SFVALUEARRAY data = m_pScaleformUI->CreateValueArray( 1 );
|
||||
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, m_nClassSelection );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "onLeft", data, 1 );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValueArray( data, 1 );
|
||||
|
||||
UpdateClassText();
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::OnRight( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
++m_nClassSelection;
|
||||
|
||||
if ( m_nClassSelection > m_nNumClasses - 1 )
|
||||
{
|
||||
m_nClassSelection = 0;
|
||||
}
|
||||
|
||||
SFVALUEARRAY data = m_pScaleformUI->CreateValueArray( 1 );
|
||||
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, m_nClassSelection );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "onRight", data, 1 );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValueArray( data, 1 );
|
||||
|
||||
UpdateClassText();
|
||||
}
|
||||
|
||||
const char * CChooseClassScaleform::GetName( void )
|
||||
{
|
||||
return PANEL_CHOOSE_CLASS;
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::SetSelectedClass( int nClassID )
|
||||
{
|
||||
SFVALUEARRAY data = m_pScaleformUI->CreateValueArray( 2 );
|
||||
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nClassID );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, m_nTeamSelection );
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "onSetSelectedClass", data, 2 );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValueArray( data, 2 );
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::OnShowScoreboard( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( GetViewPortInterface() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, true );
|
||||
}
|
||||
}
|
||||
|
||||
void CChooseClassScaleform::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
const char *type = event->GetName();
|
||||
|
||||
if( !Q_strcmp( type, "class_selected" ) || !Q_strcmp( type, "cs_game_disconnected" ))
|
||||
{
|
||||
if ( m_bVisible )
|
||||
{
|
||||
Hide( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,109 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __CHOOSECLASS_SCALEFORM_H__ )
|
||||
#define __CHOOSECLASS_SCALEFORM_H__
|
||||
|
||||
#include "../VGUI/counterstrikeviewport.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
|
||||
class CChooseClassScaleform : public ScaleformFlashInterface, public IViewPortPanel, public CGameEventListener
|
||||
{
|
||||
public:
|
||||
explicit CChooseClassScaleform( CounterStrikeViewport* pViewPort );
|
||||
virtual ~CChooseClassScaleform( );
|
||||
|
||||
/********************************************
|
||||
* CGameEventListener methods
|
||||
*/
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
/************************************
|
||||
* callbacks from scaleform
|
||||
*/
|
||||
|
||||
void OnOk( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnCancel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnLeft( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnRight( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnAutoSelect( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnShowScoreboard( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
void Show( void );
|
||||
|
||||
// if bRemove, then remove all elements after hide animation completes
|
||||
void Hide( bool bRemove = false );
|
||||
|
||||
bool PreUnloadFlash( void );
|
||||
void PostUnloadFlash( void );
|
||||
|
||||
/*************************************************************
|
||||
* IViewPortPanel interface
|
||||
*/
|
||||
|
||||
virtual const char *GetName( void );
|
||||
virtual void SetData( KeyValues *data ) {}
|
||||
|
||||
virtual void Reset( void ) {} // hibernate
|
||||
virtual void Update( void ) {} // updates all ( size, position, content, etc )
|
||||
virtual bool NeedsUpdate( void ) { return false; } // query panel if content needs to be updated
|
||||
virtual bool HasInputElements( void ) { return true; }
|
||||
virtual void ReloadScheme( void ) {}
|
||||
virtual bool CanReplace( const char *panelName ) const { return true; } // returns true if this panel can appear on top of the given panel
|
||||
virtual bool CanBeReopened( void ) const { return true; } // returns true if this panel can be re-opened after being hidden by another panel
|
||||
|
||||
virtual void ShowPanel( bool state );
|
||||
|
||||
// VGUI functions:
|
||||
virtual vgui::VPANEL GetVPanel( void ) { return 0; } // returns VGUI panel handle
|
||||
virtual bool IsVisible( void ) { return m_bVisible; } // true if panel is visible
|
||||
virtual void SetParent( vgui::VPANEL parent ) {}
|
||||
|
||||
virtual bool WantsBackgroundBlurred( void ) { return false; }
|
||||
|
||||
protected:
|
||||
CounterStrikeViewport * m_pViewPort;
|
||||
|
||||
// text elements
|
||||
ISFTextObject * m_pDescriptionText;
|
||||
ISFTextObject * m_pModelText;
|
||||
ISFTextObject * m_pTeamText;
|
||||
|
||||
bool m_bVisible;
|
||||
bool m_bLoading;
|
||||
int m_iSplitScreenSlot;
|
||||
bool m_bCanceled;
|
||||
int m_nNumClasses;
|
||||
int m_nClassSelection;
|
||||
int m_nTeamSelection;
|
||||
|
||||
// Updates the model name and class description fields based on the currently
|
||||
// selected class
|
||||
void UpdateClassText( void );
|
||||
|
||||
// Sets the currently selected class. The change occurs instantly in flash, no call back for animation.
|
||||
void SetSelectedClass( int classID );
|
||||
|
||||
// Saves the selected class to the player profile and performs the joinclass command
|
||||
void SaveAndJoin( void );
|
||||
};
|
||||
|
||||
#endif // __CHOOSECLASS_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,215 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jpaquin] Plays the intro movie before the start screen / main menu
|
||||
//
|
||||
// This also plays the credits movie.
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "createlegalanim_scaleform.h"
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "cdll_client_int.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
const int MAX_SOUND_NAME_CHARS = 1024;
|
||||
|
||||
CCreateLegalAnimScaleform* CCreateLegalAnimScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( AnimationCompleted ),
|
||||
SFUI_DECL_METHOD( PlayAudio ),
|
||||
SFUI_DECL_METHOD( GetRatingsBoardForLegals ),
|
||||
SFUI_END_GAME_API_DEF( CCreateLegalAnimScaleform, LegalAnimation )
|
||||
;
|
||||
|
||||
|
||||
void CCreateLegalAnimScaleform::CreateIntroMovie( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CCreateLegalAnimScaleform( "FinishedIntroMovie" );
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CCreateLegalAnimScaleform, m_pInstance, LegalAnimation );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::CreateCreditsMovie( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CCreateLegalAnimScaleform( "RestoreTopLevelMenu" );
|
||||
|
||||
// this is the expansion of the SFUI_REQUEST_ELEMENT macro but modified so we can use the LegalAnimation GAME_API table defined above
|
||||
g_pScaleformUI->RequestElement( SF_FULL_SCREEN_SLOT, "CreditsAnimation", reinterpret_cast<ScaleformUIFunctionHandlerObject*>( m_pInstance ), SFUI_OBJ_PTR_NAME( CCreateLegalAnimScaleform, LegalAnimation) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCreateLegalAnimScaleform::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::DismissAnimation( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->InnerDismissAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
CCreateLegalAnimScaleform::CCreateLegalAnimScaleform( const char* commandNameOrNULL ) :
|
||||
m_bAnimationCompleted( false ),
|
||||
m_iCurrentSoundPlaying( 0 )
|
||||
{
|
||||
if ( commandNameOrNULL && *commandNameOrNULL )
|
||||
{
|
||||
V_strncpy( &m_MenuCommandToRunOnCompletion[0], commandNameOrNULL, ARRAYSIZE( m_MenuCommandToRunOnCompletion ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MenuCommandToRunOnCompletion[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::FinishAnimation( void )
|
||||
{
|
||||
// releases the game to show the start screen or main menu
|
||||
m_bAnimationCompleted = true;
|
||||
if ( m_MenuCommandToRunOnCompletion[0] )
|
||||
{
|
||||
BasePanel()->PostMessage( BasePanel(), new KeyValues( "RunMenuCommand", "command", m_MenuCommandToRunOnCompletion ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::FlashLoadError( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
FinishAnimation();
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void CCreateLegalAnimScaleform::AnimationCompleted( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
FinishAnimation();
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::StopAudio( void )
|
||||
{
|
||||
if ( m_iCurrentSoundPlaying )
|
||||
{
|
||||
enginesound->StopSoundByGuid( m_iCurrentSoundPlaying, true );
|
||||
m_iCurrentSoundPlaying = 0;
|
||||
// stop sounds
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::PlayAudio( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( g_pScaleformUI->Params_GetNumArgs( obj ) == 0 )
|
||||
{
|
||||
StopAudio();
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pSoundName = g_pScaleformUI->Params_GetArgAsString( obj, 0 );
|
||||
|
||||
if ( pSoundName && *pSoundName )
|
||||
{
|
||||
StopAudio();
|
||||
|
||||
bool addMixDry = true;
|
||||
bool addStream = true;
|
||||
int len = V_strlen( pSoundName );
|
||||
|
||||
char decoratedSoundName[MAX_SOUND_NAME_CHARS];
|
||||
|
||||
if ( len > 2 )
|
||||
{
|
||||
if ( pSoundName[0] == '*' || pSoundName[1] == '*' )
|
||||
{
|
||||
addMixDry = false;
|
||||
}
|
||||
|
||||
if ( pSoundName[0] == '#' || pSoundName[1] == '#' )
|
||||
{
|
||||
addStream = false;
|
||||
}
|
||||
}
|
||||
|
||||
int firstChar = 0;
|
||||
if ( addMixDry )
|
||||
decoratedSoundName[firstChar++] = '*';
|
||||
|
||||
if ( addStream )
|
||||
decoratedSoundName[firstChar++] = '#';
|
||||
|
||||
V_strncpy( decoratedSoundName, pSoundName, MAX_SOUND_NAME_CHARS - firstChar );
|
||||
decoratedSoundName[ MAX_SOUND_NAME_CHARS - 1 ] = 0;
|
||||
|
||||
m_iCurrentSoundPlaying = enginesound->EmitAmbientSound( decoratedSoundName, 1.0f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::InnerDismissAnimation( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() ) // safety check if overlay triggers some actions that need to dismiss this screen before SWF finished loading
|
||||
return;
|
||||
|
||||
WITH_SFVALUEARRAY( args, 1 )
|
||||
{
|
||||
#if defined( _CERT )
|
||||
g_pScaleformUI->ValueArray_SetElement( args, 0, true );
|
||||
#else
|
||||
g_pScaleformUI->ValueArray_SetElement( args, 0, false );
|
||||
#endif
|
||||
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "dismissAnimation", args, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateLegalAnimScaleform::GetRatingsBoardForLegals( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
const char* szRatingBoard = NULL;
|
||||
#ifdef _X360
|
||||
if ( xboxsystem->IsArcadeTitleUnlocked() )
|
||||
szRatingBoard = "";
|
||||
else
|
||||
szRatingBoard = GetConsoleLocaleRatingsBoard();
|
||||
#else
|
||||
szRatingBoard = "";
|
||||
#endif
|
||||
|
||||
if ( szRatingBoard )
|
||||
{
|
||||
SFVALUE result = CreateFlashString( szRatingBoard );
|
||||
m_pScaleformUI->Params_SetResult( obj, result );
|
||||
SafeReleaseSFVALUE( result );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,53 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jason] Creates the Start Screen in Scaleform.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef CREATELEGALANIM_SCALEFORM_H
|
||||
#define CREATELEGALANIM_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
class CCreateLegalAnimScaleform : public ScaleformFlashInterface
|
||||
{
|
||||
protected:
|
||||
static CCreateLegalAnimScaleform* m_pInstance;
|
||||
|
||||
explicit CCreateLegalAnimScaleform( const char* commandNameOrNULL );
|
||||
|
||||
public:
|
||||
static void CreateIntroMovie( void );
|
||||
static void CreateCreditsMovie( void );
|
||||
static void UnloadDialog( void );
|
||||
static bool IsActive( void ) { return m_pInstance != NULL && !m_pInstance->m_bAnimationCompleted; }
|
||||
static void DismissAnimation( void );
|
||||
|
||||
void AnimationCompleted( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void PlayAudio( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void GetRatingsBoardForLegals( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
protected:
|
||||
virtual void PostUnloadFlash( void );
|
||||
virtual void FlashLoadError( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void InnerDismissAnimation( void );
|
||||
void FinishAnimation( void );
|
||||
|
||||
void StopAudio( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
bool m_bAnimationCompleted;
|
||||
int m_iCurrentSoundPlaying;
|
||||
|
||||
char m_MenuCommandToRunOnCompletion[256];
|
||||
};
|
||||
|
||||
#endif // CREATESTARTSCREEN_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,620 @@
|
||||
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jason] The "Press Start" Screen in Scaleform.
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef IS_WINDOWS_PC
|
||||
#include <winlite.h>
|
||||
#endif
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "createmainmenuscreen_scaleform.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "../engine/filesystem_engine.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "vgui/ISystem.h"
|
||||
|
||||
#if defined( _X360 )
|
||||
#include "xbox/xbox_launch.h"
|
||||
#else
|
||||
#include "xbox/xboxstubs.h"
|
||||
#endif
|
||||
|
||||
#include "engineinterface.h"
|
||||
#include "modinfo.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "cs_shareddefs.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
#include "cs_player_rank_mgr.h"
|
||||
#include "achievements_cs.h"
|
||||
#include "cs_player_rank_shared.h"
|
||||
#include "gametypes.h"
|
||||
#include "econ_item_inventory.h"
|
||||
#include "econ_gcmessages.h"
|
||||
|
||||
#include "cstrike15_gcmessages.pb.h"
|
||||
#include "cstrike15_gcconstants.h"
|
||||
#include "engine/inetsupport.h"
|
||||
|
||||
#include "itempickup_scaleform.h"
|
||||
|
||||
// SF ChromeHTML Test
|
||||
// #include "blog_scaleform.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// for SRC
|
||||
#include "vstdlib/random.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
CCreateMainMenuScreenScaleform* CCreateMainMenuScreenScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( BasePanelRunCommand ),
|
||||
SFUI_DECL_METHOD( IsMultiplayerPrivilegeEnabled ),
|
||||
SFUI_DECL_METHOD( LaunchTraining ),
|
||||
SFUI_DECL_METHOD( ViewMapInWorkshop ),
|
||||
SFUI_DECL_METHOD( GetPreviousLevel ),
|
||||
SFUI_END_GAME_API_DEF( CCreateMainMenuScreenScaleform, MainMenu )
|
||||
;
|
||||
|
||||
// Cache for tracking the presence of pending game invites so that the blocking ps3 system code does not need
|
||||
// to be called unnecessarily
|
||||
ConVar cl_invitation_pending( "cl_invitation_pending", "0", FCVAR_CLIENTDLL | FCVAR_HIDDEN );
|
||||
|
||||
//
|
||||
// expose some build state constants to the UI as convars
|
||||
//
|
||||
|
||||
ConVar play_with_friends_enabled( "play_with_friends_enabled", "1", FCVAR_CLIENTDLL | FCVAR_RELEASE );
|
||||
ConVar key_bind_version( "key_bind_version", "0", FCVAR_CLIENTDLL | FCVAR_RELEASE | FCVAR_HIDDEN | FCVAR_ARCHIVE );
|
||||
|
||||
#ifdef OSX
|
||||
ConVar osx_force_raw_input_once( "osx_force_raw_input_once", "0", FCVAR_CLIENTDLL | FCVAR_RELEASE | FCVAR_HIDDEN | FCVAR_ARCHIVE );
|
||||
#endif
|
||||
|
||||
static const float TIMER_RETURN_GAME_IS_UNLOCKED = -1.0f;
|
||||
static const float TIMER_RETURN_TRIAL_MODE_EXPIRED = 0.0f;
|
||||
|
||||
void CCreateMainMenuScreenScaleform::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
static bool g_bEnteredMainMenuOnce = false;
|
||||
|
||||
// [jason] Release the full-screen movie slot every time we return to the main menu from in-game,
|
||||
// to prevent memory leaks caused by fragmentation in the Scaleform heap
|
||||
// Do NOT dump the heap if we have a priority message open, or the user will miss this dialog box
|
||||
if ( g_bEnteredMainMenuOnce && !CMessageBoxScaleform::IsPriorityMessageOpen() )
|
||||
{
|
||||
ScaleformReleaseFullScreenAndCursor( g_pScaleformUI );
|
||||
|
||||
// Force the UI tint convar to reset now, so the main menu picks it up
|
||||
static ConVarRef sf_ui_tint( "sf_ui_tint" );
|
||||
int actualValue = sf_ui_tint.GetInt();
|
||||
sf_ui_tint.SetValue( 0 );
|
||||
sf_ui_tint.SetValue( actualValue );
|
||||
}
|
||||
|
||||
g_bEnteredMainMenuOnce = true;
|
||||
|
||||
m_pInstance = new CCreateMainMenuScreenScaleform( );
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CCreateMainMenuScreenScaleform, m_pInstance, MainMenu );
|
||||
|
||||
m_pInstance->m_bVisible = true;
|
||||
}
|
||||
|
||||
g_pInputSystem->SetSteamControllerMode( "MenuControls", m_pInstance );
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance && m_pInstance->FlashAPIIsValid() )
|
||||
{
|
||||
g_pInputSystem->SetSteamControllerMode( NULL, m_pInstance );
|
||||
|
||||
m_pInstance->HideImmediate();
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::UpdateDialog()
|
||||
{
|
||||
if ( m_pInstance )
|
||||
m_pInstance->Tick();
|
||||
}
|
||||
|
||||
CCreateMainMenuScreenScaleform::CCreateMainMenuScreenScaleform( void ) :
|
||||
m_pConfirmDialog( NULL ),
|
||||
m_bVisible( false ),
|
||||
m_bHideOnLoad( false ),
|
||||
m_bTrainingRequested( false ),
|
||||
m_uiClientHelloRequestedTimestampMS( 0 ),
|
||||
m_iPreviousPlayerLevel( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::FlashLoaded( void )
|
||||
{
|
||||
// $TODO: Call into any necessary Initializers on the action script side
|
||||
}
|
||||
|
||||
#ifdef IS_WINDOWS_PC
|
||||
ConVar cl_error_message_check_xboxdvr( "cl_error_message_check_xboxdvr", "0", FCVAR_ARCHIVE | FCVAR_HIDDEN );
|
||||
#endif
|
||||
|
||||
void CCreateMainMenuScreenScaleform::FlashReady( void )
|
||||
{
|
||||
// Make sure we check for invites after the main menu is fully ready
|
||||
extern float g_flReadyToCheckForPCBootInvite;
|
||||
g_flReadyToCheckForPCBootInvite = Plat_FloatTime();
|
||||
|
||||
g_pScaleformUI->AddDeviceDependentObject( m_pInstance );
|
||||
|
||||
g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
|
||||
Show();
|
||||
|
||||
// If we requested to hide the screen before it finished loading, process that hide request now
|
||||
// NOTE: because of design decisions made in the layout of this screen, we must always call Show
|
||||
// when flash loads BEFORE we can call hide. If you don't do this, the screen will not
|
||||
// be initialized correctly and when you show it later it will not function properly
|
||||
if ( m_bHideOnLoad )
|
||||
{
|
||||
HideImmediate();
|
||||
m_bHideOnLoad = false;
|
||||
}
|
||||
|
||||
// Do Windows Xbox DVR check and warn the user
|
||||
#ifdef IS_WINDOWS_PC
|
||||
static bool s_bOneTimeWarning = false;
|
||||
if ( !s_bOneTimeWarning )
|
||||
{
|
||||
s_bOneTimeWarning = true;
|
||||
|
||||
struct tm tmNow;
|
||||
Plat_GetLocalTime( &tmNow );
|
||||
time_t tgm = Plat_timegm( &tmNow );
|
||||
int nTimeDelta = tgm - cl_error_message_check_xboxdvr.GetInt();
|
||||
if ( ( ( nTimeDelta >= 31 * 24 * 3600 ) || ( nTimeDelta <= -31 * 24 * 3600 ) )
|
||||
&& ( Plat_GetOSVersion() >= PLAT_OS_VERSION_WIN7 ) )
|
||||
{
|
||||
LONG lRegResult = 0;
|
||||
DWORD dwRegAllowGameDVR = 1, cbRegAllowGameDVR = sizeof( dwRegAllowGameDVR );
|
||||
DWORD dwRegAppCaptureEnabled = 0, cbRegAppCaptureEnabled = sizeof( dwRegAppCaptureEnabled );
|
||||
DWORD dwRegGameDVR_Enabled = 0, cbRegGameDVR_Enabled = sizeof( dwRegGameDVR_Enabled );
|
||||
HKEY hKey;
|
||||
|
||||
RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR\\AllowGameDVR", NULL, KEY_READ, &hKey );
|
||||
lRegResult = ::RegQueryValueEx( hKey, "AllowGameDVR", NULL, NULL, ( BYTE * ) &dwRegAllowGameDVR, &cbRegAllowGameDVR );
|
||||
if ( lRegResult != ERROR_SUCCESS )
|
||||
dwRegAllowGameDVR = 1;
|
||||
DevMsg( "XboxDVRCheck: AllowGameDVR = 0x%08X (e0x%08X)\n", dwRegAllowGameDVR, lRegResult );
|
||||
RegCloseKey( hKey );
|
||||
|
||||
RegOpenKeyEx( HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameDVR", NULL, KEY_READ, &hKey );
|
||||
lRegResult = ::RegQueryValueEx( hKey, "AppCaptureEnabled", NULL, NULL, ( BYTE * ) &dwRegAppCaptureEnabled, &cbRegAppCaptureEnabled );
|
||||
if ( lRegResult != ERROR_SUCCESS )
|
||||
dwRegAppCaptureEnabled = 0;
|
||||
DevMsg( "XboxDVRCheck: AppCaptureEnabled = 0x%08X (e0x%08X)\n", dwRegAppCaptureEnabled, lRegResult );
|
||||
RegCloseKey( hKey );
|
||||
|
||||
RegOpenKeyEx( HKEY_CURRENT_USER, "System\\GameConfigStore", NULL, KEY_READ, &hKey );
|
||||
lRegResult = ::RegQueryValueEx( hKey, "GameDVR_Enabled", NULL, NULL, ( BYTE * ) &dwRegGameDVR_Enabled, &cbRegGameDVR_Enabled );
|
||||
if ( lRegResult != ERROR_SUCCESS )
|
||||
dwRegGameDVR_Enabled = 0;
|
||||
DevMsg( "XboxDVRCheck: GameDVR_Enabled = 0x%08X (e0x%08X)\n", dwRegGameDVR_Enabled, lRegResult );
|
||||
RegCloseKey( hKey );
|
||||
|
||||
if ( dwRegAllowGameDVR && ( dwRegAppCaptureEnabled || dwRegGameDVR_Enabled ) )
|
||||
{ // Our user may have a framerate problem, tell them!
|
||||
CCommandMsgBox::CreateAndShow( "#SFUI_XboxDVR_Title", "#SFUI_XboxDVR_Explain", true, true, "error_message_explain_xboxdvr", "error_message_silence_xboxdvr" );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check if we should do Perfect World notification for the user
|
||||
OnEvent( KeyValues::AutoDeleteInline( new KeyValues( "GcLogonNotificationReceived" ) ) );
|
||||
|
||||
// SF ChromeHTML Test
|
||||
// if ( !CBlogScaleform::IsActive() )
|
||||
// {
|
||||
// CBlogScaleform::LoadDialog( );
|
||||
// }
|
||||
}
|
||||
|
||||
#ifdef IS_WINDOWS_PC
|
||||
CON_COMMAND_F( error_message_explain_xboxdvr, "Take user to Steam support article", FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_HIDDEN )
|
||||
{
|
||||
vgui::system()->ShellExecute( "open", "https://support.steampowered.com/kb_article.php?ref=6239-DZCB-8600" );
|
||||
}
|
||||
CON_COMMAND_F( error_message_silence_xboxdvr, "Take user to Steam support article", FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_HIDDEN )
|
||||
{
|
||||
struct tm tmNow;
|
||||
Plat_GetLocalTime( &tmNow );
|
||||
time_t tgm = Plat_timegm( &tmNow );
|
||||
cl_error_message_check_xboxdvr.SetValue( ( int ) tgm );
|
||||
engine->ClientCmd_Unrestricted( "host_writeconfig\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void CCreateMainMenuScreenScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
// this is called when the dialog has finished animating, and
|
||||
// is ready for use to execute the server command.
|
||||
|
||||
// it gets called no matter how the dialog was dismissed.
|
||||
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
|
||||
g_pScaleformUI->RemoveDeviceDependentObject( this );
|
||||
|
||||
g_pInputSystem->SetSteamControllerMode( NULL, m_pInstance );
|
||||
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::Show( void )
|
||||
{
|
||||
GameUI().SetBackgroundMusicDesired( true );
|
||||
|
||||
// [dkorus] reset our input device
|
||||
g_pInputSystem->ResetCurrentInputDevice();
|
||||
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
|
||||
static bool bFirstShow = true;
|
||||
// if ( bFirstShow && ( GCClientSystem()->GetGCClient()->GetConnectionStatus() != GCConnectionStatus_HAVE_SESSION || !g_GC2ClientHello.has_account_id() ) )
|
||||
// {
|
||||
// m_uiClientHelloRequestedTimestampMS = Plat_MSTime();
|
||||
// }
|
||||
|
||||
bFirstShow = false;
|
||||
|
||||
// if ( CStorePanel::IsPricesheetLoaded() )
|
||||
// {
|
||||
// SCALEFORM_COMPONENT_BROADCAST_EVENT( Store, PriceSheetChanged );
|
||||
// }
|
||||
}
|
||||
|
||||
PerformKeyRebindings();
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
/* Removed for partner depot */
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::Hide( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", 0, NULL );
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the deferred hide flag so we immediately hide the window once loaded
|
||||
m_bHideOnLoad = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::HideImmediate( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanelImmediate", 0, NULL );
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the deferred hide flag so we immediately hide the window once loaded
|
||||
m_bHideOnLoad = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::ShowPanel( bool bShow, bool immediate /*= false*/ )
|
||||
{
|
||||
if ( bShow && !m_pInstance )
|
||||
{
|
||||
// On the first show request, ensure we create the dialog if it doesn't exist
|
||||
LoadDialog();
|
||||
}
|
||||
|
||||
if ( m_pInstance && !m_pInstance->FlashAPIIsValid() && immediate && !bShow )
|
||||
{
|
||||
m_pInstance->m_bHideOnLoad = true;
|
||||
}
|
||||
else if ( m_pInstance && bShow != m_pInstance->m_bVisible )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
m_pInstance->Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( immediate )
|
||||
{
|
||||
m_pInstance->HideImmediate();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInstance->Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::BasePanelRunCommand( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
char RunCommandStr[1024];
|
||||
V_strncpy( &RunCommandStr[0], pui->Params_GetArgAsString( obj, 0 ), sizeof( RunCommandStr ) );
|
||||
|
||||
// Is this dialog being brought up over top of the main menu panel, requiring us to hide it?
|
||||
bool bHideMainPanel = ( ( pui->Params_GetNumArgs( obj ) > 1 ) &&
|
||||
( Q_stricmp( pui->Params_GetArgAsString( obj, 1 ), "bHidePanel" ) == 0 ) );
|
||||
|
||||
if ( bHideMainPanel )
|
||||
{
|
||||
ShowPanel( false );
|
||||
}
|
||||
|
||||
// Run slotted command
|
||||
{
|
||||
char slotnumber[2];
|
||||
slotnumber[0] = '0'+GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
slotnumber[1] = 0;
|
||||
BasePanel()->PostMessage( BasePanel(), new KeyValues( "RunSlottedMenuCommand", "slot", slotnumber, "command", RunCommandStr ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::IsMultiplayerPrivilegeEnabled( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
bool bEnabled = true;
|
||||
|
||||
bool bDisplayWarningBox = ( ( pui->Params_GetNumArgs( obj ) > 0 ) &&
|
||||
( Q_stricmp( pui->Params_GetArgAsString( obj, 0 ), "bShowWarning" ) == 0 ) );
|
||||
|
||||
#if defined( _X360 )
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
|
||||
int userID = XBX_GetActiveUserId();
|
||||
BOOL EnabledFlag;
|
||||
XUserCheckPrivilege( userID, XPRIVILEGE_MULTIPLAYER_SESSIONS, &EnabledFlag );
|
||||
|
||||
bEnabled = ( EnabledFlag == TRUE );
|
||||
#endif
|
||||
#if defined( _PS3 )
|
||||
bEnabled = !engine->PS3_IsUserRestrictedFromOnline();
|
||||
#endif
|
||||
|
||||
if ( !bEnabled && bDisplayWarningBox )
|
||||
{
|
||||
// ShowPanel( false );
|
||||
#if defined( _PS3 )
|
||||
( ( CCStrike15BasePanel* )BasePanel() )->OnOpenMessageBox( "#SFUI_GameUI_OnlineErrorMessageTitle_PS3", "#SFUI_GameUI_NotOnlineEnabled_PS3", "#SFUI_GameUI_ErrorDismiss", MESSAGEBOX_FLAG_OK, this, &m_pConfirmDialog );
|
||||
#else
|
||||
( ( CCStrike15BasePanel* )BasePanel() )->OnOpenMessageBox( "#SFUI_GameUI_OnlineErrorMessageTitle", "#SFUI_GameUI_NotOnlineEnabled", "#SFUI_GameUI_ErrorDismiss", MESSAGEBOX_FLAG_OK, this, &m_pConfirmDialog );
|
||||
#endif
|
||||
}
|
||||
|
||||
m_pScaleformUI->Params_SetResult( obj, bEnabled );
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::ViewMapInWorkshop( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
int idx = (int)pui->Params_GetArgAsNumber( obj, 0 );
|
||||
if ( idx >= 0 )
|
||||
{
|
||||
g_CSGOWorkshopMaps.ViewCommunityMapInWorkshop( idx );
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::GetPreviousLevel( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_pScaleformUI->Params_SetResult( obj, m_iPreviousPlayerLevel );
|
||||
}
|
||||
|
||||
void *g_pvPassedEngineArray = NULL; // this array gets passed from engine and should be reported to GC
|
||||
void CCreateMainMenuScreenScaleform::Tick()
|
||||
{
|
||||
// Check if we need to use saved reconnect data because we cannot talk to GC
|
||||
if ( m_uiClientHelloRequestedTimestampMS &&
|
||||
( int( Plat_MSTime() - m_uiClientHelloRequestedTimestampMS ) > 6000 ) )
|
||||
{
|
||||
m_uiClientHelloRequestedTimestampMS = 0;
|
||||
}
|
||||
|
||||
// Tick every half-second
|
||||
static double s_dblTickTime = 0;
|
||||
double dblTimeNow = Plat_FloatTime();
|
||||
if ( ( dblTimeNow - s_dblTickTime ) > 0.5 )
|
||||
{
|
||||
s_dblTickTime = dblTimeNow;
|
||||
/* Removed for partner depot */
|
||||
}
|
||||
}
|
||||
|
||||
bool CCreateMainMenuScreenScaleform::OnMessageBoxEvent( MessageBoxFlags_t buttonPressed )
|
||||
{
|
||||
if ( !m_pConfirmDialog )
|
||||
return false;
|
||||
|
||||
if ( buttonPressed & MESSAGEBOX_FLAG_OK )
|
||||
{
|
||||
m_pConfirmDialog->Hide();
|
||||
m_pConfirmDialog = NULL;
|
||||
|
||||
ShowPanel( true );
|
||||
}
|
||||
|
||||
// $TODO: Handle other button presses if we have context-sensitive prompts
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::RestorePanel( void )
|
||||
{
|
||||
// [dkorus] reset our input device
|
||||
g_pInputSystem->ResetCurrentInputDevice();
|
||||
|
||||
if ( m_pInstance && !m_pInstance->m_bVisible )
|
||||
{
|
||||
m_pInstance->InnerRestorePanel();
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::InnerRestorePanel( void )
|
||||
{
|
||||
GameUI().SetBackgroundMusicDesired( true );
|
||||
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "restorePanel", NULL, 0 );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::LaunchTraining( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
m_bTrainingRequested = true;
|
||||
if ( !BasePanel()->ShowLockInput() )
|
||||
{
|
||||
DoLaunchTraining();
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::DoLaunchTraining( void )
|
||||
{
|
||||
BasePanel()->SetSinglePlayer( true );
|
||||
KeyValues *pSettings = KeyValues::FromString( "Settings", "System { network offline }Game { type training mode training mapgroupname mg_training1 }Options { action create }Contexts {}Properties {}" );
|
||||
KeyValues::AutoDelete autodelete( pSettings );
|
||||
|
||||
BasePanel()->SetSinglePlayer( true );
|
||||
|
||||
g_pMatchFramework->CreateSession( pSettings );
|
||||
IMatchSession *pMatchSession = g_pMatchFramework->GetMatchSession();
|
||||
if ( pMatchSession )
|
||||
{
|
||||
pMatchSession->Command( KeyValues::AutoDeleteInline( new KeyValues( "Start" ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "CCreateMainMenuScreenScaleform: unable to create single player session.\n" );
|
||||
BasePanel()->RestoreMainMenuScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd )
|
||||
{
|
||||
}
|
||||
|
||||
void CCreateMainMenuScreenScaleform::DeviceLost( void )
|
||||
{
|
||||
}
|
||||
|
||||
// #define REMAP_COMMAND( const char *oldCommand, const char *newCommand ) \
|
||||
// const char *pszKey##oldCommand = engine->Key_LookupBindingExact(#oldCommand); \
|
||||
// const char *pszNewKey##oldCommand = engine->Key_LookupBindingExact(#newCommand); \
|
||||
// if ( pszKey##oldCommand && !pszNewKey##oldCommand ) \
|
||||
// { \
|
||||
// Msg( "Rebinding key %s to new command " #newCommand ".\n", pszKey##oldCommand ); \
|
||||
// engine->ClientCmd_Unrestricted( VarArgs( "bind \"%s\" \"" #newCommand "\"\n", pszKey##oldCommand ) ); \
|
||||
// }
|
||||
|
||||
void RebindKey( const char* szOldBind, const char* szNewBind, ButtonCode_t *buttons, uint32 unButtonCount )
|
||||
{
|
||||
const char *pszKey = engine->Key_LookupBinding( szOldBind );
|
||||
const char *pszNewKey = engine->Key_LookupBinding( szNewBind );
|
||||
if ( pszKey && !pszNewKey )
|
||||
{
|
||||
Msg( "Rebinding key %s to new command %s.\n", pszKey, szNewBind );
|
||||
engine->ClientCmd_Unrestricted( VarArgs( "bind %s \"%s\"\nhost_writeconfig\n", pszKey, szNewBind ) );
|
||||
}
|
||||
else if ( !pszKey && !pszNewKey )
|
||||
{
|
||||
for ( uint32 i = 0; i < unButtonCount; i++ )
|
||||
{
|
||||
if ( !engine->Key_BindingForKey( buttons[ i ] ) )
|
||||
{
|
||||
Msg( "%s was not bound, binding to key %c.\n", szNewBind, buttons[ i ] - KEY_A + 'a' );
|
||||
engine->ClientCmd_Unrestricted( VarArgs( "bind %c \"%s\"\nhost_writeconfig\n", buttons[ i ] - KEY_A + 'a', szNewBind ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Rebinds any binds for old commands to their new commands.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMainMenuScreenScaleform::PerformKeyRebindings( void )
|
||||
{
|
||||
//static ConVarRef key_bind_version( "key_bind_version" );
|
||||
|
||||
// For testing
|
||||
// key_bind_version.SetValue( 0 );
|
||||
|
||||
if ( key_bind_version.GetInt() < 1 )
|
||||
{
|
||||
ButtonCode_t buttons[ 6 ] = { KEY_F, KEY_T, KEY_V, KEY_G, KEY_B, KEY_H };
|
||||
RebindKey( "impulse 100", "+lookatweapon", buttons, ARRAYSIZE( buttons ) );
|
||||
key_bind_version.SetValue( 1 );
|
||||
}
|
||||
|
||||
if ( key_bind_version.GetInt() < 2 )
|
||||
{
|
||||
ButtonCode_t buttons[ 6 ] = { KEY_T, KEY_F, KEY_V, KEY_G, KEY_B, KEY_H };
|
||||
RebindKey( "impulse 201", "+spray_menu", buttons, ARRAYSIZE( buttons) );
|
||||
key_bind_version.SetValue( 2 );
|
||||
}
|
||||
|
||||
#ifdef OSX
|
||||
// On OSX we want to force raw input on once after the 64-bit port since
|
||||
// we think it's the right choice for most users. Users can still revert
|
||||
// this setting if that's what they want, though.
|
||||
static ConVarRef osx_force_raw_input_once( "osx_force_raw_input_once" );
|
||||
|
||||
if ( osx_force_raw_input_once.GetInt() == 0 )
|
||||
{
|
||||
static ConVarRef rawinput( "m_rawinput" );
|
||||
rawinput.SetValue( 1 );
|
||||
osx_force_raw_input_once.SetValue( 1 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,84 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jason] Creates the Main Menu Screen in Scaleform.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef CREATEMAINMENUSCREEN_SCALEFORM_H
|
||||
#define CREATEMAINMENUSCREEN_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
|
||||
class CCreateMainMenuScreenScaleform : public ScaleformFlashInterface, public IMessageBoxEventCallback, public IShaderDeviceDependentObject, public IMatchEventsSink
|
||||
{
|
||||
protected:
|
||||
static CCreateMainMenuScreenScaleform* m_pInstance;
|
||||
|
||||
CCreateMainMenuScreenScaleform( );
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
static void RestorePanel( void );
|
||||
static void ShowPanel( bool bShow, bool immediate = false );
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
static void UpdateDialog( void );
|
||||
static CCreateMainMenuScreenScaleform* GetInstance() { return m_pInstance; }
|
||||
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
|
||||
// Called to trigger commands on the BasePanel, like opening other dialogs, configuring options, etc.
|
||||
// See the CBaseModPanel::RunMenuCommand function for specific available commands.
|
||||
void BasePanelRunCommand( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// Determines whether we can run any multiplayer options on the menu
|
||||
void IsMultiplayerPrivilegeEnabled( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void LaunchTraining( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void ViewMapInWorkshop( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void GetPreviousLevel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// IShaderDeviceDependentObject methods
|
||||
virtual void DeviceLost( void );
|
||||
virtual void DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd );
|
||||
virtual void ScreenSizeChanged( int width, int height ) { }
|
||||
|
||||
void Tick(); // per-frame triggered from basepanel::RunFrame
|
||||
|
||||
void PerformKeyRebindings( void );
|
||||
|
||||
protected:
|
||||
virtual void FlashReady( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
void HideImmediate( void );
|
||||
|
||||
void InnerRestorePanel( void );
|
||||
|
||||
void DoLaunchTraining( void );
|
||||
|
||||
protected:
|
||||
CMessageBoxScaleform* m_pConfirmDialog;
|
||||
bool m_bVisible;
|
||||
bool m_bHideOnLoad;
|
||||
bool m_bTrainingRequested;
|
||||
uint32 m_uiClientHelloRequestedTimestampMS;
|
||||
int m_iPreviousPlayerLevel;
|
||||
};
|
||||
|
||||
#endif // CREATEMAINMENUSCREEN_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,130 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jason] The "Press Start" Screen in Scaleform.
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "createstartscreen_scaleform.h"
|
||||
#include "../engine/filesystem_engine.h"
|
||||
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
|
||||
#ifdef _X360
|
||||
#include "xbox/xbox_launch.h"
|
||||
#endif
|
||||
#include "keyvalues.h"
|
||||
#include "engineinterface.h"
|
||||
#include "modinfo.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// for SRC
|
||||
#include <vstdlib/random.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
CCreateStartScreenScaleform* CCreateStartScreenScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( CCreateStartScreenScaleform, StartScreen )
|
||||
;
|
||||
|
||||
void CCreateStartScreenScaleform::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CCreateStartScreenScaleform( );
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CCreateStartScreenScaleform, m_pInstance, StartScreen );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CCreateStartScreenScaleform::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
CCreateStartScreenScaleform::CCreateStartScreenScaleform( void )
|
||||
{
|
||||
m_bLoadedAndReady = false;
|
||||
// Setup subscription so we are notified when the user signs in
|
||||
g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
g_pScaleformUI->DenyInputToGame( true );
|
||||
}
|
||||
|
||||
void CCreateStartScreenScaleform::FlashLoaded( void )
|
||||
{
|
||||
// $TODO: Call into any necessary Initializers on the action script side
|
||||
}
|
||||
|
||||
void CCreateStartScreenScaleform::FlashReady( void )
|
||||
{
|
||||
GameUI().SetBackgroundMusicDesired( true );
|
||||
m_bLoadedAndReady = true;
|
||||
}
|
||||
|
||||
void CCreateStartScreenScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
// this is called when the dialog has finished animating, and
|
||||
// is ready for use to execute the server command.
|
||||
|
||||
// it gets called no matter how the dialog was dismissed.
|
||||
|
||||
// Remember to unsubscribe so we don't crash later!
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
g_pScaleformUI->DenyInputToGame( false );
|
||||
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
bool CCreateStartScreenScaleform::ShowStartLogo_Internal( void )
|
||||
{
|
||||
if ( m_bLoadedAndReady )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "ShowStartLogo", 0, NULL );
|
||||
}
|
||||
}
|
||||
return m_bLoadedAndReady;
|
||||
}
|
||||
|
||||
void CCreateStartScreenScaleform::OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
char const *szName = pEvent->GetName();
|
||||
|
||||
// Notify that sign-in has completed
|
||||
if ( !Q_stricmp( szName, "OnSysSigninChange" ) &&
|
||||
!Q_stricmp( "signin", pEvent->GetString( "action", "" ) ) )
|
||||
{
|
||||
int userID = pEvent->GetInt( "user0", -1 );
|
||||
|
||||
BasePanel()->NotifySignInCompleted( userID );
|
||||
}
|
||||
else
|
||||
if ( !Q_stricmp( szName, "OnSysXUIEvent" ) &&
|
||||
!Q_stricmp( "closed", pEvent->GetString( "action", "" ) ) )
|
||||
{
|
||||
BasePanel()->NotifySignInCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,52 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jason] Creates the Start Screen in Scaleform.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef CREATESTARTSCREEN_SCALEFORM_H
|
||||
#define CREATESTARTSCREEN_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
class CCreateStartScreenScaleform : public ScaleformFlashInterface, public IMatchEventsSink
|
||||
{
|
||||
protected:
|
||||
static CCreateStartScreenScaleform* m_pInstance;
|
||||
|
||||
CCreateStartScreenScaleform( );
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
static bool ShowStartLogo( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
return m_pInstance->ShowStartLogo_Internal();
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void FlashReady( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
bool ShowStartLogo_Internal( void );
|
||||
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
|
||||
private:
|
||||
bool m_bLoadedAndReady;
|
||||
};
|
||||
|
||||
#endif // CREATESTARTSCREEN_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,87 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include "basepanel.h"
|
||||
#include "howtoplaydialog_scaleform.h"
|
||||
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
CHowToPlayDialogScaleform* CHowToPlayDialogScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( CHowToPlayDialogScaleform, HowToPlay );
|
||||
|
||||
void CHowToPlayDialogScaleform::LoadDialog()
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CHowToPlayDialogScaleform();
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CHowToPlayDialogScaleform, m_pInstance, HowToPlay );
|
||||
}
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::UnloadDialog()
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
CHowToPlayDialogScaleform::CHowToPlayDialogScaleform()
|
||||
{
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::FlashLoaded()
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "InitDialogData", NULL, 0 );
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::FlashReady()
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::PostUnloadFlash()
|
||||
{
|
||||
if ( GameUI().IsInLevel() )
|
||||
{
|
||||
BasePanel()->RestorePauseMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
BasePanel()->RestoreMainMenuScreen();
|
||||
}
|
||||
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::Show()
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CHowToPlayDialogScaleform::Hide()
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,38 @@
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef HOWTOPLAY_SCALEFORM_H
|
||||
#define HOWTOPLAY_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
class CHowToPlayDialogScaleform : public ScaleformFlashInterface
|
||||
{
|
||||
protected:
|
||||
static CHowToPlayDialogScaleform *m_pInstance;
|
||||
|
||||
CHowToPlayDialogScaleform();
|
||||
|
||||
public:
|
||||
static void LoadDialog();
|
||||
static void UnloadDialog();
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
protected:
|
||||
virtual void FlashReady();
|
||||
virtual void PostUnloadFlash();
|
||||
virtual void FlashLoaded();
|
||||
};
|
||||
|
||||
#endif // HOWTOPLAY_SCALEFORM_H
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,352 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "html_base_scaleform.h"
|
||||
|
||||
#include "html_control_scaleform.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "overwatchresolution_scaleform.h"
|
||||
#include "materialsystem/materialsystem_config.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/ISystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
CHtmlBaseScaleform::CHtmlBaseScaleform()
|
||||
:
|
||||
m_pChromeHTML( NULL ),
|
||||
m_bLastCanGoBack( true ),
|
||||
m_bLastCanGoForward( true ),
|
||||
m_bLastIsLoadingState( true )
|
||||
{
|
||||
}
|
||||
|
||||
CHtmlBaseScaleform::~CHtmlBaseScaleform()
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
delete m_pChromeHTML;
|
||||
m_pChromeHTML = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::InitChromeHTML( const char* pszBaseURL, const char *pszPostData )
|
||||
{
|
||||
if ( !m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML = new CHtmlControlScaleform();
|
||||
m_pChromeHTML->Init( this );
|
||||
m_pChromeHTML->OpenURL( pszBaseURL, pszPostData );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::Update()
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->Update();
|
||||
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
if ( m_bLastIsLoadingState != m_pChromeHTML->IsLoadingPage() )
|
||||
{
|
||||
m_bLastIsLoadingState = m_pChromeHTML->IsLoadingPage();
|
||||
|
||||
SFVALUEARRAY args = m_pScaleformUI->CreateValueArray( 1 );
|
||||
g_pScaleformUI->ValueArray_SetElement( args, 0, m_bLastIsLoadingState );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setPageLoadState", args, 1 );
|
||||
g_pScaleformUI->ReleaseValueArray( args, 1 );
|
||||
}
|
||||
|
||||
if ( m_bLastCanGoBack != m_pChromeHTML->BCanGoBack() )
|
||||
{
|
||||
m_bLastCanGoBack = m_pChromeHTML->BCanGoBack();
|
||||
|
||||
SFVALUEARRAY args = m_pScaleformUI->CreateValueArray( 1 );
|
||||
g_pScaleformUI->ValueArray_SetElement( args, 0, m_bLastCanGoBack );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setBackButtonEnabled", args, 1 );
|
||||
g_pScaleformUI->ReleaseValueArray( args, 1 );
|
||||
}
|
||||
|
||||
if ( m_bLastCanGoForward != m_pChromeHTML->BCanGoFoward() )
|
||||
{
|
||||
m_bLastCanGoForward = m_pChromeHTML->BCanGoFoward();
|
||||
|
||||
SFVALUEARRAY args = m_pScaleformUI->CreateValueArray( 1 );
|
||||
g_pScaleformUI->ValueArray_SetElement( args, 0, m_bLastCanGoForward );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setForwardButtonEnabled", args, 1 );
|
||||
g_pScaleformUI->ReleaseValueArray( args, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::PostUnloadFlash()
|
||||
{
|
||||
// remove chrome browser
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
delete m_pChromeHTML;
|
||||
m_pChromeHTML = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::InitChromeHTMLRenderTarget( const char* pszTextureName )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
const int nParams = 1;
|
||||
SFVALUEARRAY args = m_pScaleformUI->CreateValueArray( nParams );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, pszTextureName );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "InitChromeHTMLRenderTarget", args, nParams );
|
||||
m_pScaleformUI->ReleaseValueArray( args, nParams );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::UpdateHTMLScrollbar( int iScroll, int iTall, int iMax, bool bVisible, bool bVert )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
const int nParams = 5;
|
||||
SFVALUEARRAY args = m_pScaleformUI->CreateValueArray( nParams );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, iScroll );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, iTall );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, iMax );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 3, bVisible );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 4, bVert );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "UpdateHTMLScrollbar", args, nParams );
|
||||
m_pScaleformUI->ReleaseValueArray( args, nParams );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CHtmlBaseScaleform::BShouldPreventInputRouting()
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( CMessageBoxScaleform::GetLastMessageBoxCreated() )
|
||||
return true;
|
||||
|
||||
// Disable mouse input if Overwatch verdict is up
|
||||
if ( SFHudOverwatchResolutionPanel::GetInstance() )
|
||||
return true;
|
||||
|
||||
// Otherwise mouse input is OK
|
||||
return false;
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLMouseDown( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 3 )
|
||||
return;
|
||||
|
||||
int x = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
int y = pui->Params_GetArgAsNumber( obj, 1 );
|
||||
int buttonIndex = pui->Params_GetArgAsNumber( obj, 2 );
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
if ( buttonIndex == 0 )
|
||||
{
|
||||
m_pChromeHTML->OnMouseDown( MOUSE_LEFT, x, y );
|
||||
}
|
||||
else if ( buttonIndex == 3 ) // MOUSE_4
|
||||
{
|
||||
m_pChromeHTML->GoBack();
|
||||
}
|
||||
else if ( buttonIndex == 4 ) // MOUSE_5
|
||||
{
|
||||
m_pChromeHTML->GoForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLMouseUp( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 2 )
|
||||
return;
|
||||
|
||||
int x = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
int y = pui->Params_GetArgAsNumber( obj, 1 );
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->OnMouseUp( MOUSE_LEFT, x, y );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLMouseMove( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 2 )
|
||||
return;
|
||||
|
||||
int x = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
int y = pui->Params_GetArgAsNumber( obj, 1 );
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->OnMouseMoved( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLMouseWheel( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 1 )
|
||||
return;
|
||||
|
||||
int delta = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->OnMouseWheeled( delta );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLKeyDown( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 1 )
|
||||
return;
|
||||
|
||||
ButtonCode_t iKey = ( ButtonCode_t )( int )pui->Params_GetArgAsNumber( obj, 0 );
|
||||
|
||||
if ( m_pChromeHTML && IsKeyCode( iKey ) )
|
||||
{
|
||||
m_pChromeHTML->OnKeyDown( iKey );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLKeyUp( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 1 )
|
||||
return;
|
||||
|
||||
ButtonCode_t iKey = ( ButtonCode_t )( int )pui->Params_GetArgAsNumber( obj, 0 );
|
||||
|
||||
if ( m_pChromeHTML && IsKeyCode( iKey ) )
|
||||
{
|
||||
m_pChromeHTML->OnKeyUp( iKey );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLKeyTyped( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
// Disable mouse input if a message box is active
|
||||
if ( BShouldPreventInputRouting() )
|
||||
return;
|
||||
|
||||
if ( pui->Params_GetNumArgs( obj ) != 1 )
|
||||
return;
|
||||
|
||||
wchar_t typed = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->OnKeyTyped( typed );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::SetHTMLBrowserSize( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( pui->Params_GetNumArgs( obj ) != 4 )
|
||||
return;
|
||||
|
||||
int iWidth = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
int iHeight = pui->Params_GetArgAsNumber( obj, 1 );
|
||||
int iWidthStage = pui->Params_GetArgAsNumber( obj, 2 );
|
||||
int iHeightStage = pui->Params_GetArgAsNumber( obj, 3 );
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->SetBrowserBaseSize( iWidth, iHeight, iWidthStage, iHeightStage );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLScrollBarChanged( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( pui->Params_GetNumArgs( obj ) != 2 )
|
||||
return;
|
||||
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
int iPosition = pui->Params_GetArgAsNumber( obj, 0 );
|
||||
bool bVert = pui->Params_GetArgAsBool( obj, 1 );
|
||||
m_pChromeHTML->OnHTMLScrollBarMoved( iPosition, bVert );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLBackButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLForwardButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->GoForward();
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLRefreshButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLStopButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_pChromeHTML )
|
||||
{
|
||||
m_pChromeHTML->StopLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlBaseScaleform::OnHTMLExternalBrowserButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
/* Removed for partner depot */
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,109 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base class for every scaleform screen that need to display html
|
||||
// (using Chrome to display html in a texture)
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef HTML_BASE_SCALEFORM_H
|
||||
#define HTML_BASE_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "html_control_scaleform.h"
|
||||
|
||||
class CHtmlBaseScaleform : public ScaleformFlashInterface, public IHtmlParentScaleform
|
||||
{
|
||||
public:
|
||||
|
||||
CHtmlBaseScaleform();
|
||||
virtual ~CHtmlBaseScaleform();
|
||||
|
||||
void InitChromeHTML( const char* pszBaseURL, const char *pszPostData );
|
||||
|
||||
virtual void Update();
|
||||
|
||||
// Override ScaleformFlashInterface methods
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
// Implements IHtmlParentScaleform interface
|
||||
// (C++ calling ActionScript functions)
|
||||
virtual void InitChromeHTMLRenderTarget( const char* pszTextureName );
|
||||
virtual void BrowserReady() { }
|
||||
virtual void OnFinishRequest( const char *url, const char *pageTitle ) { }
|
||||
virtual void HandleJsAlert( char const *pchAlert ) { Assert( 0 ); }
|
||||
virtual void UpdateHTMLScrollbar( int iScroll, int iTall, int iMax, bool bVisible, bool bVert );
|
||||
|
||||
// HTML Window Input Handlers
|
||||
// (ActionScript calling C++ functions)
|
||||
void OnHTMLMouseDown( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLMouseUp( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLMouseMove( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLMouseWheel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLKeyDown( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLKeyUp( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLKeyTyped( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void SetHTMLBrowserSize( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLScrollBarChanged( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// HTML Window Controls
|
||||
// (ActionScript calling C++ functions)
|
||||
void OnHTMLBackButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLForwardButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLRefreshButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLStopButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHTMLExternalBrowserButtonClicked( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
protected:
|
||||
virtual bool BShouldPreventInputRouting();
|
||||
|
||||
CHtmlControlScaleform* m_pChromeHTML;
|
||||
|
||||
bool m_bLastCanGoBack;
|
||||
bool m_bLastCanGoForward;
|
||||
bool m_bLastIsLoadingState;
|
||||
};
|
||||
|
||||
// ActionScript calling C++ via GameApi
|
||||
#define IMPLEMENT_HTML_SFUI_METHODS \
|
||||
SFUI_DECL_METHOD( OnHTMLMouseDown ), \
|
||||
SFUI_DECL_METHOD( OnHTMLMouseUp ), \
|
||||
SFUI_DECL_METHOD( OnHTMLMouseMove ), \
|
||||
SFUI_DECL_METHOD( OnHTMLMouseWheel ), \
|
||||
SFUI_DECL_METHOD( OnHTMLKeyDown ), \
|
||||
SFUI_DECL_METHOD( OnHTMLKeyUp ), \
|
||||
SFUI_DECL_METHOD( OnHTMLKeyTyped ), \
|
||||
SFUI_DECL_METHOD( SetHTMLBrowserSize ), \
|
||||
SFUI_DECL_METHOD( OnHTMLScrollBarChanged ), \
|
||||
SFUI_DECL_METHOD( OnHTMLBackButtonClicked ), \
|
||||
SFUI_DECL_METHOD( OnHTMLForwardButtonClicked ), \
|
||||
SFUI_DECL_METHOD( OnHTMLRefreshButtonClicked ), \
|
||||
SFUI_DECL_METHOD( OnHTMLStopButtonClicked ), \
|
||||
SFUI_DECL_METHOD( OnHTMLExternalBrowserButtonClicked )
|
||||
|
||||
// ActionScript calling C++ via Component api
|
||||
#define SCALEFORM_COMPONENT_HTML_FUNCTIONS_API_DEF( componentclass ) \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnLoadFinished, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnUnload, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnReady, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLMouseDown, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLMouseUp, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLMouseMove, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLMouseWheel, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLKeyDown, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLKeyUp, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLKeyTyped, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, SetHTMLBrowserSize, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLScrollBarChanged, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLBackButtonClicked, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLForwardButtonClicked, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLRefreshButtonClicked, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLStopButtonClicked, componentclass ), \
|
||||
SCALEFORM_COMPONENT_FUNCTION_API_DEF_NOPREFIX( void, OnHTMLExternalBrowserButtonClicked, componentclass ),
|
||||
|
||||
#endif // HTML_BASE_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,884 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "html_control_scaleform.h"
|
||||
|
||||
#include "vgui/IInput.h"
|
||||
|
||||
#include "input/mousecursors.h"
|
||||
#include "../vgui2/src/vgui_key_translation.h"
|
||||
#include "materialsystem/materialsystem_config.h"
|
||||
|
||||
#include "OfflineMode.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//#define SCALE_MSGS
|
||||
|
||||
// This isn't preferable, would likely work better to have only one system receiving the callbacks and dispatching them properly
|
||||
#define CHECK_BROWSER_HANDLE() do { if ( pCmd->unBrowserHandle != m_unBrowserHandle ) return; } while ( false )
|
||||
|
||||
uint64 CHtmlControlScaleform::m_nextProceduralTextureId = 1;
|
||||
|
||||
const int NO_HTML_ZOOM = 99.0f;
|
||||
|
||||
ConVar csgo_html_zoom( "csgo_html_zoom", "1", FCVAR_NONE, "Scaling method for HTML displays (0=Bilinear Texture Scaling, 1=CEF Pixel Accurate Zoom)" );
|
||||
ConVar csgo_html_zoom_override( "csgo_html_zoom_override", "99.0" );
|
||||
|
||||
extern bool gScaleformBrowserActive;
|
||||
|
||||
|
||||
CHtmlControlScaleform::CHtmlControlScaleform()
|
||||
:
|
||||
m_NeedsPaint( this, &CHtmlControlScaleform::BrowserNeedsPaint ),
|
||||
m_StartRequest( this, &CHtmlControlScaleform::BrowserStartRequest ),
|
||||
m_URLChanged( this, &CHtmlControlScaleform::BrowserURLChanged ),
|
||||
m_FinishedRequest( this, &CHtmlControlScaleform::BrowserFinishedRequest ),
|
||||
m_NewWindow( this, &CHtmlControlScaleform::BrowserPopupHTMLWindow ),
|
||||
m_HorizScroll( this, &CHtmlControlScaleform::BrowserHorizontalScrollBarSizeResponse ),
|
||||
m_VertScroll( this, &CHtmlControlScaleform::BrowserVerticalScrollBarSizeResponse ),
|
||||
m_JSAlert( this, &CHtmlControlScaleform::BrowserJSAlert ),
|
||||
m_JSConfirm( this, &CHtmlControlScaleform::BrowserJSConfirm ),
|
||||
m_CanGoBackForward( this, &CHtmlControlScaleform::BrowserCanGoBackandForward ),
|
||||
m_SetCursor( this, &CHtmlControlScaleform::BrowserSetCursor ),
|
||||
m_StatusText( this, &CHtmlControlScaleform::BrowserStatusText ),
|
||||
m_ShowToolTip( this, &CHtmlControlScaleform::BrowserShowToolTip ),
|
||||
m_UpdateToolTip( this, &CHtmlControlScaleform::BrowserUpdateToolTip ),
|
||||
m_HideToolTip( this, &CHtmlControlScaleform::BrowserHideToolTip ),
|
||||
m_SearchResults( this, &CHtmlControlScaleform::BrowserSearchResults ),
|
||||
m_OpenLinkInNewTab( this, &CHtmlControlScaleform::BrowserOpenNewTab ),
|
||||
m_FileLoadDialog( this, &CHtmlControlScaleform::BrowserFileLoadDialog ),
|
||||
m_Close( this, &CHtmlControlScaleform::BrowserClose ),
|
||||
m_LinkAtPosition( this, &CHtmlControlScaleform::BrowserLinkAtPositionResponse )
|
||||
{
|
||||
m_pParent = NULL;
|
||||
m_proceduralTextureId = 0;
|
||||
m_bCachedResize = false;
|
||||
m_bCachedZoom = false;
|
||||
m_flUIScale = 1.f;
|
||||
m_iMouseX = 0;
|
||||
m_iMouseY = 0;
|
||||
m_iVertScrollStep = 75;
|
||||
m_bLoadingPage = false;
|
||||
m_bStopped = false;
|
||||
m_bFullRepaint = false;
|
||||
m_bNewWindowsOnly = false;
|
||||
m_bCanGoBack = false;
|
||||
m_bCanGoForward = false;
|
||||
m_flZoom = 1.f;
|
||||
m_flDesiredZoom = NO_HTML_ZOOM;
|
||||
m_flLastRequestedZoom = 1.f;
|
||||
|
||||
m_unBrowserHandle = INVALID_HTMLBROWSER;
|
||||
|
||||
gScaleformBrowserActive = true;
|
||||
}
|
||||
|
||||
CHtmlControlScaleform::~CHtmlControlScaleform()
|
||||
{
|
||||
g_pScaleformUI->ChromeHTMLImageRelease( m_proceduralTextureId );
|
||||
|
||||
if ( m_SteamAPIContext.SteamHTMLSurface() )
|
||||
{
|
||||
m_SteamAPIContext.SteamHTMLSurface()->RemoveBrowser( m_unBrowserHandle );
|
||||
}
|
||||
|
||||
gScaleformBrowserActive = false;
|
||||
}
|
||||
|
||||
void CHtmlControlScaleform::Init( IHtmlParentScaleform* pParent )
|
||||
{
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "*** CHtmlControlScaleform::Init() ***\n" );
|
||||
#endif
|
||||
|
||||
m_pParent = pParent;
|
||||
|
||||
// Initialize the HTML surface and create the browser instance
|
||||
m_SteamAPIContext.Init();
|
||||
if ( m_SteamAPIContext.SteamHTMLSurface() )
|
||||
{
|
||||
m_SteamAPIContext.SteamHTMLSurface()->Init();
|
||||
|
||||
int iStageWidth, iStageHeight;
|
||||
engine->GetScreenSize( iStageWidth, iStageHeight );
|
||||
|
||||
SteamAPICall_t hSteamAPICall = m_SteamAPIContext.SteamHTMLSurface()->CreateBrowser( "CSGO Client", "::-webkit-scrollbar { background-color: transparent; }" );
|
||||
m_SteamCallResultBrowserReady.Set( hSteamAPICall, this, &CHtmlControlScaleform::OnBrowserReady );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Unable to access SteamHTMLSurface" );
|
||||
}
|
||||
|
||||
m_proceduralTextureId = m_nextProceduralTextureId++;
|
||||
|
||||
// Turn off bilinear filtering if csgo_html_zoom 1
|
||||
m_strProceduralTextureName.Format( "img%s://chrome_%llu", csgo_html_zoom.GetBool() ? "ps" : "", m_proceduralTextureId );
|
||||
g_pScaleformUI->ChromeHTMLImageAddRef( m_proceduralTextureId );
|
||||
|
||||
if ( m_pParent )
|
||||
{
|
||||
m_pParent->InitChromeHTMLRenderTarget( m_strProceduralTextureName );
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlControlScaleform::Update( void )
|
||||
{
|
||||
if ( csgo_html_zoom_override.GetFloat() != NO_HTML_ZOOM )
|
||||
{
|
||||
m_flDesiredZoom = csgo_html_zoom_override.GetFloat();
|
||||
}
|
||||
|
||||
if ( m_flDesiredZoom != NO_HTML_ZOOM && m_flDesiredZoom != m_flLastRequestedZoom )
|
||||
{
|
||||
SetZoomLevel( m_flDesiredZoom );
|
||||
m_flLastRequestedZoom = m_flDesiredZoom;
|
||||
}
|
||||
}
|
||||
|
||||
void CHtmlControlScaleform::OnHTMLScrollBarMoved( int iPosition, bool bVert )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
if ( bVert )
|
||||
{
|
||||
if ( iPosition != m_scrollVertical.m_nScroll )
|
||||
{
|
||||
m_SteamAPIContext.SteamHTMLSurface()->SetVerticalScroll( m_unBrowserHandle, iPosition );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( iPosition != m_scrollHorizontal.m_nScroll )
|
||||
{
|
||||
m_SteamAPIContext.SteamHTMLSurface()->SetHorizontalScroll( m_unBrowserHandle, iPosition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: helper to convert UI mouse codes to CEF ones
|
||||
//-----------------------------------------------------------------------------
|
||||
ISteamHTMLSurface::EHTMLMouseButton ConvertMouseCodeToCEFCode( vgui::MouseCode code )
|
||||
{
|
||||
switch ( code )
|
||||
{
|
||||
default:
|
||||
case MOUSE_LEFT:
|
||||
return ISteamHTMLSurface::eHTMLMouseButton_Left;
|
||||
|
||||
case MOUSE_RIGHT:
|
||||
return ISteamHTMLSurface::eHTMLMouseButton_Right;
|
||||
|
||||
case MOUSE_MIDDLE:
|
||||
return ISteamHTMLSurface::eHTMLMouseButton_Middle;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: a mouse click on the browser window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnMouseDown( ButtonCode_t button, int x, int y )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->MouseDown( m_unBrowserHandle, ConvertMouseCodeToCEFCode( button ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: a mouse click on the browser window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnMouseUp( ButtonCode_t button, int x, int y )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->MouseUp( m_unBrowserHandle, ConvertMouseCodeToCEFCode( button ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: keeps track of where the cursor is
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnMouseMoved( int x, int y )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
// Only do this when we are over the current panel
|
||||
m_iMouseX = x * m_flUIScale;
|
||||
m_iMouseY = y * m_flUIScale;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->MouseMove( m_unBrowserHandle, m_iMouseX, m_iMouseY );
|
||||
|
||||
/*
|
||||
else if ( !m_sDragURL.IsEmpty() )
|
||||
{
|
||||
if ( input()->GetMouseOver() == NULL )
|
||||
{
|
||||
// we're not over any vgui window, switch to the OS implementation of drag/drop
|
||||
// BR FIXME
|
||||
// surface()->StartDragDropText( m_sDragURL );
|
||||
m_sDragURL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_sDragURL.IsEmpty() && !input()->GetCursorOveride() )
|
||||
{
|
||||
// if we've dragged far enough (in global coordinates), set to use the drag cursor
|
||||
int gx, gy;
|
||||
input()->GetCursorPos( gx, gy );
|
||||
if ( abs(m_iDragStartX-gx) + abs(m_iDragStartY-gy) > 3 )
|
||||
{
|
||||
// input()->SetCursorOveride( dc_alias );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: scrolls the vertical scroll bar on a web page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnMouseWheeled( int delta )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->MouseWheel( m_unBrowserHandle, delta * m_iVertScrollStep );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: return the bitmask of any modifier keys that are currently down
|
||||
//-----------------------------------------------------------------------------
|
||||
int TranslateKeyModifiers()
|
||||
{
|
||||
bool bControl = false;
|
||||
bool bAlt = false;
|
||||
bool bShift = false;
|
||||
|
||||
if ( vgui::input()->IsKeyDown ( KEY_LCONTROL ) || vgui::input()->IsKeyDown( KEY_RCONTROL ) )
|
||||
bControl = true;
|
||||
|
||||
if ( vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT ) )
|
||||
bAlt = true;
|
||||
|
||||
if ( vgui::input()->IsKeyDown( KEY_LSHIFT ) || vgui::input()->IsKeyDown( KEY_RSHIFT ) )
|
||||
bShift = true;
|
||||
|
||||
#ifdef OSX
|
||||
// for now pipe through the cmd-key to be like the control key so we get copy/paste
|
||||
if ( vgui::input()->IsKeyDown( KEY_LWIN ) || vgui::input()->IsKeyDown( KEY_RWIN ) )
|
||||
bControl = true;
|
||||
#endif
|
||||
|
||||
int nModifierCodes = 0;
|
||||
if ( bControl )
|
||||
nModifierCodes |= ISteamHTMLSurface::k_eHTMLKeyModifier_CtrlDown;
|
||||
if ( bAlt )
|
||||
nModifierCodes |= ISteamHTMLSurface::k_eHTMLKeyModifier_AltDown;
|
||||
if ( bShift )
|
||||
nModifierCodes |= ISteamHTMLSurface::k_eHTMLKeyModifier_ShiftDown;
|
||||
|
||||
return nModifierCodes;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Key down detection.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnKeyDown( ButtonCode_t code )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->KeyDown( m_unBrowserHandle, KeyCode_VGUIToVirtualKey( code ), (ISteamHTMLSurface::EHTMLKeyModifiers)TranslateKeyModifiers() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Key up detection.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnKeyUp( ButtonCode_t code )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->KeyUp( m_unBrowserHandle, KeyCode_VGUIToVirtualKey( code ), (ISteamHTMLSurface::EHTMLKeyModifiers)TranslateKeyModifiers() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: passes key presses to the browser
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnKeyTyped( wchar_t unichar )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->KeyChar( m_unBrowserHandle, unichar, (ISteamHTMLSurface::EHTMLKeyModifiers)TranslateKeyModifiers() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Zoom the current page in or out.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::SetZoomLevel( float flZoom )
|
||||
{
|
||||
// Make sure the browser is ready before sending the "Page Scale" message
|
||||
// Cache zoom factor otherwise, it will then get set in the OnBrowserReady callback
|
||||
m_flCachedZoom = flZoom;
|
||||
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
{
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "SetZoomLevel, cache ( %f )\n", flZoom );
|
||||
#endif
|
||||
m_bCachedZoom = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bCachedZoom = false;
|
||||
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "SteamHTMLSurface()->SetPageScaleFactor( %f )\n", flZoom );
|
||||
#endif
|
||||
m_SteamAPIContext.SteamHTMLSurface()->SetPageScaleFactor( m_unBrowserHandle, flZoom, 0, 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Execute Javascript in current page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::ExecuteJavascript( const char *pchScript )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
#ifdef HTML_CONTROL_JAVASCRIPT_DEBUG
|
||||
Msg( "SteamHTMLSurface()->ExecuteJavascript( %s )\n", pchScript );
|
||||
#endif
|
||||
m_SteamAPIContext.SteamHTMLSurface()->ExecuteJavascript( m_unBrowserHandle, pchScript );
|
||||
}
|
||||
|
||||
void CHtmlControlScaleform::CallbackJavascriptDialogResponse( bool bResult )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
#ifdef HTML_CONTROL_JAVASCRIPT_DEBUG
|
||||
Msg( "SteamHTMLSurface()->CallbackJavascriptDialogResponse( %s )\n", bResult ? "ACCEPT" : "Dismiss" );
|
||||
#endif
|
||||
m_SteamAPIContext.SteamHTMLSurface()->JSDialogResponse( m_unBrowserHandle, bResult );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the base size for the browser window.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::SetBrowserBaseSize( int iWidth, int iHeight, int iStageWidth, int iStageHeight )
|
||||
{
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "SetBrowserBaseSize()\n" );
|
||||
#endif
|
||||
|
||||
// Reloading the image in flash so make sure we are creating a new texture !
|
||||
g_pScaleformUI->ChromeHTMLImageRelease( m_proceduralTextureId );
|
||||
g_pScaleformUI->ChromeHTMLImageAddRef( m_proceduralTextureId );
|
||||
|
||||
// default
|
||||
m_flDesiredZoom = 1.0f;
|
||||
|
||||
// iWidth and iHeight are the size of the widget that will contain the browser. This size is unscaled!
|
||||
// iStageWidth and iStageHeight are the size of our screen resolution.
|
||||
// It's possible for the widget's size to be larger than our resolution (it will be scaled).
|
||||
|
||||
if ( csgo_html_zoom.GetBool() )
|
||||
{
|
||||
// scale up the browser size to match actual screen pixels, giving a sharper render
|
||||
// Apply chrome zoom to make it fit the same size proportionally
|
||||
float flScale = ( iStageHeight / 720.0f );
|
||||
|
||||
iWidth = (float)iWidth * flScale;
|
||||
iHeight = (float)iHeight * flScale;
|
||||
|
||||
// these 'hacked' zoom values required updating since the removal of libcef and change in range of zoom values for isteamhtmlsurface (see .h).
|
||||
// they were determined by allowing the blog to sit at the desired vertical resolution (iStageheight) without a horizontal scrollbar.
|
||||
// dota abandoned this notion after the removal of libcef, and doesn't scale the browser page with resolution change.
|
||||
// scaling above 1.0 also problematic (hence the clamp) since no matter where we scale around, the page ends up with a horiz scroll bar.
|
||||
if ( iStageHeight <= 480 ) { m_flDesiredZoom = 0.412f; }
|
||||
else if ( iStageHeight <= 576 ) { m_flDesiredZoom = 0.496f; }
|
||||
else if ( iStageHeight <= 600 ) { m_flDesiredZoom = 0.5195f; }
|
||||
else if ( iStageHeight <= 720 ) { m_flDesiredZoom = 0.625f; }
|
||||
else if ( iStageHeight <= 768 ) { m_flDesiredZoom = 0.66f; }
|
||||
else if ( iStageHeight <= 800 ) { m_flDesiredZoom = 0.695f; }
|
||||
else if ( iStageHeight <= 864 ) { m_flDesiredZoom = 0.75f; }
|
||||
else if ( iStageHeight <= 900 ) { m_flDesiredZoom = 0.7815f; }
|
||||
else if ( iStageHeight <= 960 ) { m_flDesiredZoom = 0.835f; }
|
||||
else if ( iStageHeight <= 1024 ) { m_flDesiredZoom = 0.89f; }
|
||||
else if ( iStageHeight <= 1050 ) { m_flDesiredZoom = 0.91f; }
|
||||
else if ( iStageHeight <= 1080 ) { m_flDesiredZoom = 0.94f; }
|
||||
else if ( iStageHeight <= 1200 ) { m_flDesiredZoom = 1.0f; }
|
||||
else if ( iStageHeight <= 1440 ) { m_flDesiredZoom = 1.0f; }
|
||||
else if ( iStageHeight <= 1600 ) { m_flDesiredZoom = 1.0f; }
|
||||
else { m_flDesiredZoom = 1.0f; }
|
||||
|
||||
m_flUIScale = flScale;
|
||||
BrowserResize( iWidth, iHeight, iWidth, iHeight );
|
||||
|
||||
// force scale to get cached now, attempting to catch case where the page is appearing scaled with a garbage float
|
||||
SetZoomLevel( m_flDesiredZoom );
|
||||
m_flLastRequestedZoom = m_flDesiredZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flUIScale = 1.5f;
|
||||
BrowserResize( iWidth, iHeight, iWidth*m_flUIScale, iHeight*m_flUIScale );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shared code for sizing the HTML surface window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserResize( int iWideRT, int iTallRT, int iWideBrowser, int iTallBrowser )
|
||||
{
|
||||
m_iCachedWideRT = iWideRT;
|
||||
m_iCachedTallRT = iTallRT;
|
||||
m_iCachedWideBrowser = iWideBrowser;
|
||||
m_iCachedTallBrowser = iTallBrowser;
|
||||
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
{
|
||||
m_bCachedResize = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bCachedResize = false;
|
||||
|
||||
// Message the resize to chrome.
|
||||
m_SteamAPIContext.SteamHTMLSurface()->SetSize( m_unBrowserHandle, iWideBrowser, iTallBrowser );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: opens the URL, will accept any URL that IE accepts
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OpenURL(const char *URL, const char *postData )
|
||||
{
|
||||
PostURL( URL, postData );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: opens the URL, will accept any URL that IE accepts
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::PostURL(const char *URL, const char *pchPostData )
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
{
|
||||
m_sPendingURLLoad = URL;
|
||||
m_sPendingPostData = pchPostData;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sLoadingURL = URL;
|
||||
|
||||
if ( pchPostData && Q_strlen( pchPostData ) > 0)
|
||||
m_SteamAPIContext.SteamHTMLSurface()->LoadURL( m_unBrowserHandle, URL, pchPostData );
|
||||
else
|
||||
m_SteamAPIContext.SteamHTMLSurface()->LoadURL( m_unBrowserHandle, URL, NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: opens the URL, will accept any URL that IE accepts
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHtmlControlScaleform::StopLoading()
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return false;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->StopLoad( m_unBrowserHandle );
|
||||
m_bStopped = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: refreshes the current page
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHtmlControlScaleform::Refresh()
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return false;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->Reload( m_unBrowserHandle );
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Tells the browser control to go back
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::GoBack()
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->GoBack( m_unBrowserHandle );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Tells the browser control to go forward
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::GoForward()
|
||||
{
|
||||
if ( m_unBrowserHandle == INVALID_HTMLBROWSER )
|
||||
return;
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->GoForward( m_unBrowserHandle );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if the browser can go back further
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHtmlControlScaleform::BCanGoBack()
|
||||
{
|
||||
return m_bCanGoBack;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if the browser can go forward further
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHtmlControlScaleform::BCanGoFoward()
|
||||
{
|
||||
return m_bCanGoForward;
|
||||
}
|
||||
|
||||
void CHtmlControlScaleform::OnBrowserReady( HTML_BrowserReady_t *pBrowserReady, bool bIOFailure )
|
||||
{
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "OnBrowserReady()\n" );
|
||||
#endif
|
||||
|
||||
m_unBrowserHandle = pBrowserReady->unBrowserHandle;
|
||||
|
||||
if ( m_bCachedZoom )
|
||||
{
|
||||
SetZoomLevel( m_flCachedZoom );
|
||||
}
|
||||
if ( m_bCachedResize )
|
||||
{
|
||||
BrowserResize( m_iCachedWideRT, m_iCachedTallRT, m_iCachedWideBrowser, m_iCachedTallBrowser );
|
||||
}
|
||||
|
||||
// Only post the pending URL if we have set our OAuth token
|
||||
if ( !m_sPendingURLLoad.IsEmpty() )
|
||||
{
|
||||
PostURL( m_sPendingURLLoad, m_sPendingPostData );
|
||||
m_sPendingURLLoad.Clear();
|
||||
}
|
||||
|
||||
// Notify the parent that the browser's been initialized
|
||||
if ( m_pParent )
|
||||
{
|
||||
m_pParent->BrowserReady();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: we have a new texture to update
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserNeedsPaint( HTML_NeedsPaint_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
// If Steam gave us a NULL pointer, something bad happened
|
||||
if ( pCmd->pBGRA == NULL )
|
||||
return;
|
||||
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "BrowserNeedsPaint(), pCmd->flPageScale = %f\n", pCmd->flPageScale );
|
||||
#endif
|
||||
|
||||
// Update texture
|
||||
g_pScaleformUI->ChromeHTMLImageUpdate( m_proceduralTextureId, (const byte *)pCmd->pBGRA, pCmd->unWide, pCmd->unTall, IMAGE_FORMAT_BGRA8888 );
|
||||
|
||||
if ( ( m_scrollVertical.m_bVisible && pCmd->unScrollY > 0 && abs( (int)pCmd->unScrollY - m_scrollVertical.m_nScroll) > 5 ) || ( m_scrollHorizontal.m_bVisible && pCmd->unScrollX > 0 && abs( (int)pCmd->unScrollX - m_scrollHorizontal.m_nScroll ) > 5 ) )
|
||||
{
|
||||
m_scrollVertical.m_nScroll = pCmd->unScrollY;
|
||||
m_scrollHorizontal.m_nScroll = pCmd->unScrollX;
|
||||
|
||||
m_pParent->UpdateHTMLScrollbar( m_scrollHorizontal.m_nScroll, m_scrollHorizontal.m_nWide, m_scrollHorizontal.m_nMax, m_scrollHorizontal.m_bVisible, false );
|
||||
m_pParent->UpdateHTMLScrollbar( m_scrollVertical.m_nScroll, m_scrollVertical.m_nTall, m_scrollVertical.m_nMax, m_scrollVertical.m_bVisible, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser wants to start loading this url, do we let it?
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHtmlControlScaleform::OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect )
|
||||
{
|
||||
if ( !url || !Q_stricmp( url, "about:blank") )
|
||||
return true ; // this is just webkit loading a new frames contents inside an existing page
|
||||
|
||||
HideFindDialog();
|
||||
// see if we have a custom handler for this
|
||||
bool bURLHandled = false;
|
||||
FOR_EACH_VEC( m_URLHandlerDelegates, i )
|
||||
{
|
||||
if ( m_URLHandlerDelegates[i]( url ) )
|
||||
{
|
||||
bURLHandled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bURLHandled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_bNewWindowsOnly && bIsRedirect )
|
||||
{
|
||||
if ( target && ( !Q_stricmp( target, "_blank" ) || !Q_stricmp( target, "_new" ) ) ) // only allow NEW windows (_blank ones)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: callback from cef thread, load a url please
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserStartRequest( HTML_StartRequest_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
bool bRes = OnStartRequest( pCmd->pchURL, pCmd->pchTarget, pCmd->pchPostData, pCmd->bIsRedirect );
|
||||
|
||||
m_SteamAPIContext.SteamHTMLSurface()->AllowStartRequest( m_unBrowserHandle, bRes );
|
||||
|
||||
m_bLoadingPage = bRes;
|
||||
m_bStopped = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser went to a new url
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserURLChanged( HTML_URLChanged_t *pCmd )
|
||||
{
|
||||
#ifdef SCALE_MSGS
|
||||
Msg( "BrowserURLChanged\n" );
|
||||
#endif
|
||||
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
m_sCurrentURL = pCmd->pchURL;
|
||||
|
||||
OnURLChanged( m_sCurrentURL, pCmd->pchPostData, pCmd->bIsRedirect );
|
||||
|
||||
if ( m_flDesiredZoom != NO_HTML_ZOOM )
|
||||
{
|
||||
SetZoomLevel( m_flDesiredZoom );
|
||||
m_flLastRequestedZoom = m_flDesiredZoom;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::OnFinishRequest( const char *url, const char *pageTitle )
|
||||
{
|
||||
//m_bPostRequestPaint = true;
|
||||
m_bLoadingPage = false;
|
||||
|
||||
m_pParent->OnFinishRequest( url, pageTitle );
|
||||
|
||||
// TODO
|
||||
/*if ( m_pParent->FlashAPIIsValid() )
|
||||
{
|
||||
PARENT_WITH_SLOT_LOCKED();
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_pParent->GetFlashAPI(), "tweenChromeBrowser", NULL, 0 );
|
||||
}*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: finished loading this page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserFinishedRequest( HTML_FinishedRequest_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
OnFinishRequest( pCmd->pchURL, pCmd->pchPageTitle );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser telling us the state of back and forward buttons
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserCanGoBackandForward( HTML_CanGoBackAndForward_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
m_bCanGoBack = pCmd->bCanGoBack;
|
||||
m_bCanGoForward = pCmd->bCanGoForward;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: update the value of the cached variables we keep
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::UpdateCachedHTMLValues()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser telling us the size of the horizontal scrollbars
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserHorizontalScrollBarSizeResponse( HTML_HorizontalScroll_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
ScrollData_t scrollHorizontal;
|
||||
// Assumes scrollbar is not visible (by ignoring message) if requested scale and scale from the message do not match
|
||||
if ( pCmd->flPageScale == m_flLastRequestedZoom )
|
||||
{
|
||||
// Same scale - update scrollbar
|
||||
scrollHorizontal.m_nScroll = pCmd->unScrollCurrent;
|
||||
scrollHorizontal.m_nMax = pCmd->unScrollMax;
|
||||
scrollHorizontal.m_bVisible = pCmd->bVisible;
|
||||
scrollHorizontal.m_flZoom = pCmd->flPageScale;
|
||||
}
|
||||
|
||||
if ( scrollHorizontal != m_scrollHorizontal )
|
||||
{
|
||||
m_scrollHorizontal = scrollHorizontal;
|
||||
m_pParent->UpdateHTMLScrollbar( m_scrollHorizontal.m_nScroll, m_scrollHorizontal.m_nWide, m_scrollHorizontal.m_nMax, m_scrollHorizontal.m_bVisible, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scrollHorizontal = scrollHorizontal;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser telling us the size of the vertical scrollbars
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserVerticalScrollBarSizeResponse( HTML_VerticalScroll_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
ScrollData_t scrollVertical;
|
||||
scrollVertical.m_nScroll = pCmd->unScrollCurrent;
|
||||
scrollVertical.m_nMax = pCmd->unScrollMax;
|
||||
scrollVertical.m_bVisible = pCmd->bVisible;
|
||||
scrollVertical.m_flZoom = pCmd->flPageScale;
|
||||
|
||||
if ( scrollVertical != m_scrollVertical )
|
||||
{
|
||||
m_scrollVertical = scrollVertical;
|
||||
m_pParent->UpdateHTMLScrollbar( m_scrollVertical.m_nScroll, m_scrollVertical.m_nTall, m_scrollVertical.m_nMax, m_scrollVertical.m_bVisible, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scrollVertical = scrollVertical;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: browser telling us to change our mouse cursor
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserSetCursor( HTML_SetCursor_t *pCmd )
|
||||
{
|
||||
EMouseCursor cursor = (EMouseCursor)pCmd->eMouseCursor;
|
||||
vgui::input()->SetCursorOveride( cursor );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: status bar details
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserStatusText( HTML_StatusText_t *pCmd )
|
||||
{
|
||||
FOR_EACH_VEC( m_BrowserStatusTextDelegates, i )
|
||||
{
|
||||
m_BrowserStatusTextDelegates[i]( pCmd->pchMsg );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: display a new html window
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::BrowserPopupHTMLWindow( HTML_NewWindow_t *pCmd )
|
||||
{
|
||||
CHECK_BROWSER_HANDLE();
|
||||
|
||||
// Remove intermediate browser created by cef / steam_api
|
||||
if ( m_SteamAPIContext.SteamHTMLSurface() )
|
||||
{
|
||||
Assert( pCmd->unNewWindow_BrowserHandle != m_unBrowserHandle );
|
||||
m_SteamAPIContext.SteamHTMLSurface()->RemoveBrowser( pCmd->unNewWindow_BrowserHandle );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// AS OF YET UNIMPLEMENTED BROWSER FEATURES
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// TODO: Tabs
|
||||
void CHtmlControlScaleform::BrowserOpenNewTab( HTML_OpenLinkInNewTab_t *pCmd ) { Assert(0); }
|
||||
|
||||
// TODO: File Access
|
||||
void CHtmlControlScaleform::BrowserFileLoadDialog( HTML_FileOpenDialog_t *pCmd ) { Assert(0); }
|
||||
|
||||
// TODO: Tool Tips
|
||||
void CHtmlControlScaleform::BrowserShowToolTip( HTML_ShowToolTip_t *pCmd ) { Assert(0); }
|
||||
void CHtmlControlScaleform::BrowserUpdateToolTip( HTML_UpdateToolTip_t *pCmd ) { Assert(0); }
|
||||
void CHtmlControlScaleform::BrowserHideToolTip( HTML_HideToolTip_t *pCmd ) { Assert(0); }
|
||||
|
||||
// TODO: Page Search
|
||||
void CHtmlControlScaleform::BrowserSearchResults( HTML_SearchResults_t *pCmd ) { Assert(0); }
|
||||
|
||||
// TODO: Javascript
|
||||
void CHtmlControlScaleform::BrowserJSAlert( HTML_JSAlert_t *pCmd )
|
||||
{
|
||||
if ( pCmd->unBrowserHandle != m_unBrowserHandle )
|
||||
return;
|
||||
|
||||
m_pParent->HandleJsAlert( pCmd->pchMessage );
|
||||
}
|
||||
void CHtmlControlScaleform::BrowserJSConfirm( HTML_JSConfirm_t *pCmd ) { Assert(0); }
|
||||
|
||||
// TODO: ???
|
||||
void CHtmlControlScaleform::BrowserClose( HTML_CloseBrowser_t *pCmd ) { Assert(0); }
|
||||
void CHtmlControlScaleform::BrowserLinkAtPositionResponse( HTML_LinkAtPosition_t *pCmd ) { Assert(0); }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: install callbacks that listen can respond to URL changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::AddURLHandlerDelegate( CUtlDelegate< bool ( const char * ) > pfnURLHandler )
|
||||
{
|
||||
m_URLHandlerDelegates.AddToTail( pfnURLHandler );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: install callbacks that listen for responses to link at position queries
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHtmlControlScaleform::AddBrowserStatusTextDelegate( CUtlDelegate< void ( const char * ) > pfnStatusHandler )
|
||||
{
|
||||
m_BrowserStatusTextDelegates.AddToTail( pfnStatusHandler );
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,218 @@
|
||||
//========= Copyright © 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Control to display html content (Scaleform version)
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef HTML_CONTROL_SCALEFORM_H
|
||||
#define HTML_CONTROL_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_SAFE_STEAM_API_INTERFACES
|
||||
#define VERSION_SAFE_STEAM_API_INTERFACES
|
||||
#endif
|
||||
#include "steam/steam_api.h"
|
||||
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
class IHtmlParentScaleform
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitChromeHTMLRenderTarget( const char* pszTextureName ) = 0;
|
||||
virtual void BrowserReady() = 0;
|
||||
virtual void HandleJsAlert( char const *pchAlert ) = 0;
|
||||
virtual void OnFinishRequest( const char *url, const char *pageTitle ) = 0;
|
||||
virtual void UpdateHTMLScrollbar( int iScroll, int iTall, int iMax, bool bVisible, bool bVert ) = 0;
|
||||
};
|
||||
|
||||
class CHtmlControlScaleform
|
||||
{
|
||||
public:
|
||||
|
||||
CHtmlControlScaleform();
|
||||
virtual ~CHtmlControlScaleform();
|
||||
|
||||
virtual void Init( IHtmlParentScaleform* pParent );
|
||||
|
||||
// HTML Interface Functions
|
||||
virtual void OpenURL( const char *URL, const char *pchPostData );
|
||||
virtual void BrowserResize( int iWideRT, int iTallRT, int iWideBrowser, int iTallBrowser );
|
||||
virtual bool StopLoading();
|
||||
virtual bool Refresh();
|
||||
virtual void GoBack();
|
||||
virtual void GoForward();
|
||||
virtual bool BCanGoBack();
|
||||
virtual bool BCanGoFoward();
|
||||
|
||||
bool IsLoadingPage() { return m_bLoadingPage && !m_bStopped; }
|
||||
const char* GetCurrentURL() { return m_sCurrentURL.Get(); }
|
||||
|
||||
void SetBrowserBaseSize( int iWidth, int iHeight, int iStageWidth, int iStageHeight );
|
||||
void Update( void );
|
||||
|
||||
// Browser Control
|
||||
void Find( const char *pchSubStr ) {}
|
||||
void StopFind() {}
|
||||
void FindNext() {}
|
||||
void FindPrevious() {}
|
||||
void ShowFindDialog() {}
|
||||
void HideFindDialog() {}
|
||||
bool FindDialogVisible() { return false; }
|
||||
void SetZoomLevel( float flZoom );
|
||||
|
||||
void ExecuteJavascript( const char *pchScript );
|
||||
void CallbackJavascriptDialogResponse( bool bResult );
|
||||
|
||||
// Input Passthrough
|
||||
void OnHTMLScrollBarMoved( int iPosition, bool bVert );
|
||||
virtual void OnMouseMoved( int x, int y );
|
||||
virtual void OnMouseDown( ButtonCode_t button, int x, int y );
|
||||
virtual void OnMouseUp( ButtonCode_t button, int x, int y );
|
||||
virtual void OnMouseWheeled( int delta );
|
||||
virtual void OnKeyDown( ButtonCode_t code );
|
||||
virtual void OnKeyUp( ButtonCode_t code );
|
||||
virtual void OnKeyTyped( wchar_t unichar );
|
||||
|
||||
void AddURLHandlerDelegate( CUtlDelegate< bool ( const char * ) > pfnURLHandler );
|
||||
void AddBrowserStatusTextDelegate( CUtlDelegate< void ( const char * ) > pfnURLHandler );
|
||||
|
||||
protected:
|
||||
|
||||
void PostURL( const char *URL, const char *pchPostData );
|
||||
|
||||
virtual bool OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect );
|
||||
virtual void OnFinishRequest( const char *url, const char *pageTitle );
|
||||
virtual void OnSetHTMLTitle( const char *pchTitle ) {}
|
||||
virtual void OnURLChanged( const char *url, const char *pchPostData, bool bIsRedirect ) {}
|
||||
|
||||
void UpdateCachedHTMLValues();
|
||||
|
||||
private:
|
||||
|
||||
/************************************************************
|
||||
* IHTMLResponses callbacks
|
||||
*/
|
||||
ISteamHTMLSurface *SteamHTMLSurface() { return m_SteamAPIContext.SteamHTMLSurface(); }
|
||||
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserNeedsPaint, HTML_NeedsPaint_t, m_NeedsPaint);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserStartRequest, HTML_StartRequest_t, m_StartRequest);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserURLChanged, HTML_URLChanged_t, m_URLChanged);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserFinishedRequest, HTML_FinishedRequest_t, m_FinishedRequest);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserPopupHTMLWindow, HTML_NewWindow_t, m_NewWindow);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserHorizontalScrollBarSizeResponse, HTML_HorizontalScroll_t, m_HorizScroll);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserVerticalScrollBarSizeResponse, HTML_VerticalScroll_t, m_VertScroll);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserJSAlert, HTML_JSAlert_t, m_JSAlert);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserJSConfirm, HTML_JSConfirm_t, m_JSConfirm);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserCanGoBackandForward, HTML_CanGoBackAndForward_t, m_CanGoBackForward);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserSetCursor, HTML_SetCursor_t, m_SetCursor);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserStatusText, HTML_StatusText_t, m_StatusText );
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserShowToolTip, HTML_ShowToolTip_t, m_ShowToolTip);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserUpdateToolTip, HTML_UpdateToolTip_t, m_UpdateToolTip);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserHideToolTip, HTML_HideToolTip_t, m_HideToolTip);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserSearchResults, HTML_SearchResults_t, m_SearchResults);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserOpenNewTab, HTML_OpenLinkInNewTab_t, m_OpenLinkInNewTab);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserFileLoadDialog, HTML_FileOpenDialog_t, m_FileLoadDialog);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserClose, HTML_CloseBrowser_t, m_Close);
|
||||
STEAM_CALLBACK(CHtmlControlScaleform, BrowserLinkAtPositionResponse, HTML_LinkAtPosition_t, m_LinkAtPosition);
|
||||
|
||||
void OnBrowserReady(HTML_BrowserReady_t *pBrowserReady, bool bIOFailure);
|
||||
|
||||
static uint64 m_nextProceduralTextureId;
|
||||
|
||||
IHtmlParentScaleform* m_pParent;
|
||||
|
||||
CUtlString m_strProceduralTextureName;
|
||||
// id used to identify chrome image when calling ScaleformUI::ChromeHTMLImageAddRef ... functions
|
||||
uint64 m_proceduralTextureId;
|
||||
|
||||
int m_iBrowser; // our browser handle
|
||||
CUtlString m_sCurrentURL; // the url of our current page
|
||||
|
||||
CUtlString m_sLoadingURL;
|
||||
CUtlString m_sPendingURLLoad; // cache of url to load if we get a PostURL before the cef object is mage
|
||||
CUtlString m_sPendingPostData; // cache of the post data for above
|
||||
|
||||
// For resizes sent before the browser is initialized.
|
||||
bool m_bCachedResize;
|
||||
int m_iCachedTallRT;
|
||||
int m_iCachedWideRT;
|
||||
int m_iCachedTallBrowser;
|
||||
int m_iCachedWideBrowser;
|
||||
float m_flUIScale;
|
||||
|
||||
// For zoom messages sent before the browser is initialized.
|
||||
bool m_bCachedZoom;
|
||||
float m_flCachedZoom;
|
||||
|
||||
int m_iMouseX;
|
||||
int m_iMouseY;
|
||||
int m_iVertScrollStep;
|
||||
|
||||
bool m_bLoadingPage;
|
||||
bool m_bStopped;
|
||||
bool m_bFullRepaint;
|
||||
bool m_bNewWindowsOnly;
|
||||
|
||||
// cache of forward and back state
|
||||
bool m_bCanGoBack;
|
||||
bool m_bCanGoForward;
|
||||
|
||||
// Scroll Bars
|
||||
struct ScrollData_t
|
||||
{
|
||||
ScrollData_t()
|
||||
{
|
||||
m_bVisible = false;
|
||||
m_nX = m_nY = m_nWide = m_nTall = m_nMax = 0;
|
||||
m_nScroll = -1;
|
||||
}
|
||||
|
||||
bool operator==( ScrollData_t const &src ) const
|
||||
{
|
||||
return m_bVisible == src.m_bVisible &&
|
||||
m_nX == src.m_nX &&
|
||||
m_nY == src.m_nY &&
|
||||
m_nWide == src.m_nWide &&
|
||||
m_nTall == src.m_nTall &&
|
||||
m_nMax == src.m_nMax &&
|
||||
m_nScroll == src.m_nScroll;
|
||||
}
|
||||
|
||||
bool operator!=( ScrollData_t const &src ) const
|
||||
{
|
||||
return !operator==(src);
|
||||
}
|
||||
|
||||
|
||||
bool m_bVisible; // is the scroll bar visible
|
||||
int m_nX; /// where cef put the scroll bar
|
||||
int m_nY;
|
||||
int m_nWide;
|
||||
int m_nTall; // how many pixels of scroll in the current scroll knob
|
||||
int m_nMax; // most amount of pixels we can scroll
|
||||
int m_nScroll; // currently scrolled amount of pixels
|
||||
float m_flZoom; // zoom level this scroll bar is for
|
||||
};
|
||||
|
||||
ScrollData_t m_scrollHorizontal; // details of horizontal scroll bar
|
||||
ScrollData_t m_scrollVertical; // details of vertical scroll bar
|
||||
|
||||
CUtlVector< CUtlDelegate< bool ( const char * ) > > m_URLHandlerDelegates;
|
||||
CUtlVector< CUtlDelegate< void ( const char * ) > > m_BrowserStatusTextDelegates;
|
||||
|
||||
float m_flZoom; // current page zoom level
|
||||
float m_flDesiredZoom;
|
||||
float m_flLastRequestedZoom;
|
||||
|
||||
CSteamAPIContext m_SteamAPIContext;
|
||||
HHTMLBrowser m_unBrowserHandle;
|
||||
CCallResult< CHtmlControlScaleform, HTML_BrowserReady_t > m_SteamCallResultBrowserReady;
|
||||
};
|
||||
|
||||
#endif // HTML_CONTROL_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
@@ -0,0 +1,579 @@
|
||||
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "itempickup_scaleform.h"
|
||||
#include "item_pickup_panel.h"
|
||||
#include "game/client/iviewport.h"
|
||||
#include "scoreboard_scaleform.h"
|
||||
#include "teammenu_scaleform.h"
|
||||
#include "c_cs_playerresource.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "c_team.h"
|
||||
#include "voice_status.h"
|
||||
#include "basepanel.h"
|
||||
#include "hud_chat.h"
|
||||
#include "iclientmode.h"
|
||||
#include "econ_ui.h"
|
||||
#include "gameui/basemodpanel.h"
|
||||
|
||||
#include "components/scaleformcomponent_common.h"
|
||||
#include "uicomponents/uicomponent_friendslist.h"
|
||||
#include "uicomponents/uicomponent_mypersona.h"
|
||||
|
||||
#include "gc_clientsystem.h"
|
||||
#include "cstrike15_gcmessages.pb.h"
|
||||
#include "cstrike15_gcconstants.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
SFHudItemPickupPanel* SFHudItemPickupPanel::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( HideFromScript ),
|
||||
SFUI_DECL_METHOD( ItemPickupClose ),
|
||||
SFUI_DECL_METHOD( NextItem ),
|
||||
SFUI_DECL_METHOD( PrevItem ),
|
||||
SFUI_DECL_METHOD( DiscardItem ),
|
||||
SFUI_DECL_METHOD( OpenLoadout ),
|
||||
SFUI_DECL_METHOD( OnConfirmDelete ),
|
||||
|
||||
SFUI_END_GAME_API_DEF( SFHudItemPickupPanel, ItemPickup );
|
||||
|
||||
static CSteamID s_steamIdMyself;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
SFHudItemPickupPanel::SFHudItemPickupPanel()
|
||||
{
|
||||
s_steamIdMyself = steamapicontext->SteamUser()->GetSteamID();
|
||||
m_bVisible = false;
|
||||
m_iSplitScreenSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
m_bLoading = false;
|
||||
m_bDestroyAfterLoading = false;
|
||||
m_flLastAddItemSound = 0;
|
||||
|
||||
//g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
|
||||
m_iSelectedItem = 0;
|
||||
}
|
||||
|
||||
SFHudItemPickupPanel::~SFHudItemPickupPanel()
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
m_lastItemAnim = ITEM_ANIM_NONE;
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
char const *szEvent = pEvent->GetName();
|
||||
|
||||
SCALEFORM_COMPONENT_FORWARD_EVENT( szEvent );
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new SFHudItemPickupPanel();
|
||||
m_pInstance->m_bLoading = true;
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, SFHudItemPickupPanel, m_pInstance, ItemPickup );
|
||||
}
|
||||
else if (m_pInstance->m_bLoading)
|
||||
{
|
||||
if ( m_pInstance->m_bDestroyAfterLoading )
|
||||
{
|
||||
m_pInstance->m_bDestroyAfterLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance && !m_pInstance->m_bDestroyAfterLoading)
|
||||
{
|
||||
if (m_pInstance->m_bLoading)
|
||||
{
|
||||
m_pInstance->m_bDestroyAfterLoading = true;
|
||||
m_pInstance->m_bVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInstance->m_bDestroyAfterLoading = true;
|
||||
}
|
||||
|
||||
m_pInstance->Hide();
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::PostUnloadFlash( void )
|
||||
{
|
||||
BasePanel()->DismissPauseMenu();
|
||||
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::FlashReady( void )
|
||||
{
|
||||
if ( !m_FlashAPI )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_bFlashReady = true;
|
||||
m_bLoading = false;
|
||||
|
||||
ListenForGameEvent( "server_spawn" );
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
bool SFHudItemPickupPanel::PreUnloadFlash( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::StaticShowPanel( bool bShow )
|
||||
{
|
||||
if ( bShow && !m_pInstance )
|
||||
{
|
||||
LoadDialog();
|
||||
}
|
||||
|
||||
if ( m_pInstance )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
m_pInstance->m_iSelectedItem = 0;
|
||||
m_pInstance->Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInstance->Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( bShow != m_bVisible )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::Show()
|
||||
{
|
||||
if ( !m_pScaleformUI )
|
||||
return;
|
||||
|
||||
if ( !m_bLoading )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLoading = true;
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, SFHudItemPickupPanel, this, ItemPickup );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
m_aItems.Purge();
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::Hide( void )
|
||||
{
|
||||
if ( !m_pScaleformUI )
|
||||
return;
|
||||
|
||||
if ( m_bVisible )
|
||||
OnCommand( "itempickupclose" );
|
||||
|
||||
if ( FlashAPIIsValid() && !m_bLoading )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", NULL, 0 );
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
|
||||
m_iSelectedItem = 0;
|
||||
m_aItems.Purge();
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::ItemPickupClose( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
OnCommand( "itempickupclose" );
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::NextItem( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
OnCommand( "nextitem" );
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::PrevItem( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
OnCommand( "previtem" );
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::DiscardItem( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
OnCommand( "discarditem" );
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::OpenLoadout( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted("open_econui_backpack\n");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFHudItemPickupPanel::OnConfirmDelete( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_iSelectedItem >= 0 && m_iSelectedItem < m_aItems.Count() )
|
||||
{
|
||||
if ( m_aItems[m_iSelectedItem].pItem.IsValid() )
|
||||
{
|
||||
CPlayerInventory *pInventory = InventoryManager()->GetLocalInventory();
|
||||
if ( pInventory )
|
||||
{
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_DISCARDED, &m_aItems[m_iSelectedItem].pItem );
|
||||
|
||||
InventoryManager()->DeleteItem( m_aItems[m_iSelectedItem].pItem.GetItemID() );
|
||||
|
||||
m_aItems[m_iSelectedItem].bDiscarded = true;
|
||||
|
||||
vgui::surface()->PlaySound( "physics/metal/weapon_impact_hard2.wav" );
|
||||
vgui::surface()->PlaySound( "physics/metal/metal_barrel_impact_hard2.wav" );
|
||||
|
||||
// If we've discarded all our items, we exit immediately
|
||||
bool bFoundUndiscarded = false;
|
||||
for ( int i = 0; i < m_aItems.Count(); i++ )
|
||||
{
|
||||
if ( !m_aItems[i].bDiscarded )
|
||||
{
|
||||
bFoundUndiscarded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bFoundUndiscarded )
|
||||
{
|
||||
OnCommand( "itempickupclose" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateModelPanels();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFHudItemPickupPanel::OnCommand( const char *command )
|
||||
{
|
||||
if ( !Q_stricmp( command, "itempickupclose" ) )
|
||||
{
|
||||
//ShowPanel( false );
|
||||
|
||||
// If we were crafting, and the craft panel is up, we return to that instead.
|
||||
if ( EconUI()->IsUIPanelVisible( ECONUI_CRAFTING ) )
|
||||
return;
|
||||
|
||||
// Check to make sure the player has room for all his items. If not, bring up the discard panel. Otherwise, go away.
|
||||
if ( !InventoryManager()->CheckForRoomAndForceDiscard( ) )
|
||||
{
|
||||
// If we're connected to a game server, we also close the game UI.
|
||||
if ( m_bReturnToGame && engine->IsInGame() )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( "gameui_hide" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !Q_stricmp( command, "changeloadout" ) )
|
||||
{
|
||||
ShowPanel( false );
|
||||
EconUI()->OpenEconUI( ECONUI_LOADOUT, true );
|
||||
}
|
||||
else if ( !Q_stricmp( command, "nextitem" ) )
|
||||
{
|
||||
m_iSelectedItem = clamp( m_iSelectedItem+1, 0, m_aItems.Count()-1 );
|
||||
UpdateModelPanels( ITEM_ANIM_NEXT );
|
||||
}
|
||||
else if ( !Q_stricmp( command, "previtem" ) )
|
||||
{
|
||||
m_iSelectedItem = clamp( m_iSelectedItem-1, 0, m_aItems.Count()-1 );
|
||||
UpdateModelPanels( ITEM_ANIM_PREV );
|
||||
}
|
||||
else if ( !Q_stricmp( command, "discarditem" ) )
|
||||
{
|
||||
CEconItemView *pItem = &m_aItems[m_iSelectedItem].pItem;
|
||||
if ( pItem )
|
||||
{
|
||||
// Bring up confirm dialog
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, pItem->GetItemName() );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showConfirmDeletePanel", args, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
engine->ClientCmd( const_cast<char *>( command ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFHudItemPickupPanel::UpdateModelPanels( ItemDropAnimType_t anim )
|
||||
{
|
||||
if ( anim != ITEM_ANIM_NONE )
|
||||
m_lastItemAnim = anim;
|
||||
|
||||
int nItemsCount = m_aItems.Count();
|
||||
bool bDiscarded = false;
|
||||
|
||||
int iPos = 0;
|
||||
for ( int i = 0; i < ITEMDROP_NUM_SFPANELS; i++ )
|
||||
{
|
||||
bool bHideItemPanel = false;
|
||||
int nItemUsedByTeam = 0;
|
||||
bool bThisItemDiscarded = false;
|
||||
int iFoundMethod = 0;
|
||||
char xuidText[255];
|
||||
xuidText[0] = '\0';
|
||||
char itemIDText[255];
|
||||
itemIDText[0] = '\0';
|
||||
|
||||
if ( m_lastItemAnim == ITEM_ANIM_FIRST || m_lastItemAnim == ITEM_ANIM_NEXT )
|
||||
{
|
||||
iPos = (m_iSelectedItem-2) + i;
|
||||
}
|
||||
else if ( m_lastItemAnim == ITEM_ANIM_PREV )
|
||||
{
|
||||
iPos = (m_iSelectedItem-1) + i;
|
||||
}
|
||||
|
||||
if ( iPos < 0 || iPos >= nItemsCount )
|
||||
{
|
||||
bHideItemPanel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CEconItemView *pItem = &m_aItems[iPos].pItem;
|
||||
if ( pItem )
|
||||
{
|
||||
nItemUsedByTeam = pItem->GetStaticData()->GetUsedByTeam();
|
||||
|
||||
bThisItemDiscarded = m_aItems[iPos].bDiscarded;
|
||||
|
||||
iFoundMethod = GetUnacknowledgedReason( m_aItems[iPos].pItem.GetInventoryPosition() );
|
||||
iFoundMethod--;
|
||||
|
||||
if ( iFoundMethod < 0 || iFoundMethod >= ARRAYSIZE(g_pszItemPickupMethodStrings) )
|
||||
{
|
||||
iFoundMethod = 0;
|
||||
}
|
||||
|
||||
XUID xuidMyself = s_steamIdMyself.ConvertToUint64();
|
||||
V_snprintf( xuidText, ARRAYSIZE(xuidText), "%llu", xuidMyself );
|
||||
|
||||
itemid_t itemID = pItem->GetItemID();
|
||||
V_snprintf( itemIDText, ARRAYSIZE(itemIDText), "%llu", itemID );
|
||||
}
|
||||
else
|
||||
{
|
||||
bHideItemPanel = true;
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t szFoundMethodText[ 256 ];
|
||||
g_pVGuiLocalize->ConstructString( szFoundMethodText, sizeof( szFoundMethodText ), g_pVGuiLocalize->Find( g_pszItemPickupMethodStrings[iFoundMethod] ), 0 );
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 7 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, i );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, bHideItemPanel );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, bThisItemDiscarded );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 3, szFoundMethodText );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 4, nItemUsedByTeam );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 5, xuidText );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 6, itemIDText );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetItemInSlot", args, 7 );
|
||||
}
|
||||
}
|
||||
|
||||
bool bAllowDiscard = true;
|
||||
|
||||
int iFoundMethod = 0;
|
||||
if ( m_iSelectedItem >= 0 && m_iSelectedItem < nItemsCount )
|
||||
{
|
||||
iFoundMethod = GetUnacknowledgedReason( m_aItems[m_iSelectedItem].pItem.GetInventoryPosition() );
|
||||
bAllowDiscard = ( iFoundMethod <= UNACK_ITEM_DROPPED );
|
||||
}
|
||||
|
||||
bDiscarded = m_aItems[m_iSelectedItem].bDiscarded;
|
||||
bool bCanDiscard = ( !bDiscarded && bAllowDiscard );
|
||||
bool bShowOpenLoadoutButton = !bDiscarded;
|
||||
|
||||
wchar_t szNewItemsStr[ 128 ];
|
||||
|
||||
if ( m_aItems.Count() > 1 )
|
||||
{
|
||||
char szBuff[ 64 ];
|
||||
wchar_t szWideBuff2[ 32 ];
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "%i", m_aItems.Count() );
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szBuff, szWideBuff2, sizeof( szWideBuff2 ) );
|
||||
g_pVGuiLocalize->ConstructString( szNewItemsStr, sizeof( szNewItemsStr ), g_pVGuiLocalize->Find( "#NewItemsAcquired" ), 1, szWideBuff2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( szNewItemsStr, sizeof( szNewItemsStr ), g_pVGuiLocalize->Find( "#NewItemAcquired" ), 0 );
|
||||
}
|
||||
|
||||
if ( !m_bVisible )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
bool bReturnToGame = (m_bReturnToGame && engine->IsInGame());
|
||||
|
||||
WITH_SFVALUEARRAY_SLOT_LOCKED( args, 7 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 0, (int)anim );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 1, bCanDiscard );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 2, bShowOpenLoadoutButton );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 3, szNewItemsStr );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 4, bReturnToGame );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 5, m_iSelectedItem );
|
||||
m_pScaleformUI->ValueArray_SetElement( args, 6, nItemsCount );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowSelectedItem", args, 7 );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFHudItemPickupPanel::AddItem( CEconItemView *pItem )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
if ( !m_pInstance->m_bVisible )
|
||||
StaticShowPanel( true );
|
||||
|
||||
m_pInstance->AddItemInternal( pItem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFHudItemPickupPanel::AddItemInternal( CEconItemView *pItem )
|
||||
{
|
||||
int iIdx = m_aItems.AddToTail();
|
||||
m_aItems[iIdx].pItem = *pItem;
|
||||
m_aItems[iIdx].bDiscarded = false;
|
||||
|
||||
if ( (m_flLastAddItemSound + 2.0f) < gpGlobals->curtime )
|
||||
{
|
||||
m_flLastAddItemSound = gpGlobals->curtime;
|
||||
vgui::surface()->PlaySound( "ui/store_item_purchased.wav" );
|
||||
}
|
||||
|
||||
if ( m_bVisible )
|
||||
{
|
||||
ItemDropAnimType_t anim = ITEM_ANIM_NONE;
|
||||
if (iIdx == 0)
|
||||
{
|
||||
anim = ITEM_ANIM_FIRST;
|
||||
}
|
||||
|
||||
UpdateModelPanels( anim );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::ShowItemPickup( XUID xuid, int nIndex )
|
||||
{
|
||||
if ( !m_bVisible )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::HideFromScript( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
void SFHudItemPickupPanel::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
if ( !m_bVisible )
|
||||
return;
|
||||
|
||||
// //if ( !CSGameRules() )
|
||||
// // return;
|
||||
//
|
||||
// ACTIVE_SPLITSCREEN_PLAYER_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
|
||||
//
|
||||
// const char *type = event->GetName();
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// // Game Event Handling
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// if ( !V_strcmp( type, "server_spawn") )
|
||||
// {
|
||||
// const char *hostname = event->GetString( "hostname" );
|
||||
// g_pVGuiLocalize->ConvertANSIToUnicode( hostname, m_szHostName, sizeof(m_szHostName) );
|
||||
// // The truncate player name function is just a generic truncate. Use it to truncate the server name.
|
||||
// TruncatePlayerName( m_szHostName, ARRAYSIZE( m_szHostName ), 80, true );
|
||||
// }
|
||||
|
||||
const char * type = event->GetName();
|
||||
|
||||
if ( Q_strcmp(type, "gameui_hidden") == 0 )
|
||||
{
|
||||
// If they haven't discarded down to <MAX items, bring us right back up again
|
||||
if ( InventoryManager()->CheckForRoomAndForceDiscard() )
|
||||
{
|
||||
//engine->ClientCmd_Unrestricted( "gameui_activate" );
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowPanel( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,108 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFHUDITEMPICKUPPANEL_H
|
||||
#define SFHUDITEMPICKUPPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif //_WIN32
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "game/client/iviewport.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "ienginevgui.h"
|
||||
#include "gameui_util.h"
|
||||
#include "../VGUI/counterstrikeviewport.h"
|
||||
|
||||
#define ITEMDROP_NUM_SFPANELS 4
|
||||
|
||||
class SFHudItemPickupPanel : public ScaleformFlashInterface, public CGameEventListener, public IMatchEventsSink
|
||||
{
|
||||
protected:
|
||||
static SFHudItemPickupPanel *m_pInstance;
|
||||
|
||||
SFHudItemPickupPanel();
|
||||
~SFHudItemPickupPanel();
|
||||
|
||||
//
|
||||
// IMatchEventsSink
|
||||
//
|
||||
public:
|
||||
virtual void OnEvent( KeyValues *pEvent ) OVERRIDE;
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
static void StaticShowPanel( bool bShow );
|
||||
static void NotifyCommendationResponse( XUID xuid, bool bSuccess );
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void ShowItemPickup( XUID xuid, int nIndex );
|
||||
|
||||
void HideFromScript( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void ItemPickupClose( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void NextItem( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void PrevItem( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void DiscardItem( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OpenLoadout( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnConfirmDelete( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// CGameEventListener methods
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
enum ItemDropAnimType_t
|
||||
{
|
||||
ITEM_ANIM_NONE = 0,
|
||||
ITEM_ANIM_FIRST = 1,
|
||||
ITEM_ANIM_NEXT = 2,
|
||||
ITEM_ANIM_PREV = 3,
|
||||
};
|
||||
|
||||
void OnCommand( const char *command );
|
||||
void UpdateModelPanels( ItemDropAnimType_t anim = ITEM_ANIM_NONE );
|
||||
static void AddItem( CEconItemView *pItem );
|
||||
void AddItemInternal( CEconItemView *pItem );
|
||||
static void SetReturnToGame( bool bReturn ) { m_pInstance ? m_pInstance->m_bReturnToGame = bReturn : NULL; }
|
||||
|
||||
virtual void ShowPanel( bool state );
|
||||
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
static bool IsVisible() { return (m_pInstance != NULL && m_pInstance->m_bVisible); }
|
||||
|
||||
bool m_bVisible;
|
||||
|
||||
// keeps track of whether flash is ready or not and if it's currently being loaded
|
||||
bool m_bFlashReady : 1;
|
||||
|
||||
int m_iSplitScreenSlot;
|
||||
bool m_bLoading;
|
||||
bool m_bDestroyAfterLoading;
|
||||
|
||||
protected:
|
||||
bool m_bReturnToGame;
|
||||
int m_iSelectedItem;
|
||||
|
||||
ItemDropAnimType_t m_lastItemAnim;
|
||||
|
||||
struct founditem_t
|
||||
{
|
||||
CEconItemView pItem;
|
||||
bool bDiscarded;
|
||||
};
|
||||
CUtlVector<founditem_t> m_aItems;
|
||||
|
||||
float m_flLastAddItemSound;
|
||||
};
|
||||
|
||||
#endif // SFHUDITEMPICKUPPANEL_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef LEADERBOARDSDIALOG_SCALEFORM_H
|
||||
#define LEADERBOARDSDIALOG_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
#if !defined( NO_STEAM )
|
||||
#include "steam/isteamuserstats.h"
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
|
||||
enum eLeaderboardFiltersType
|
||||
{
|
||||
eLBFilter_Overall = 0,
|
||||
eLBFilter_Me = 1,
|
||||
eLBFilter_Friends = 2
|
||||
};
|
||||
|
||||
class CCreateLeaderboardsDialogScaleform : public ScaleformFlashInterface
|
||||
{
|
||||
protected:
|
||||
static CCreateLeaderboardsDialogScaleform* m_pInstance;
|
||||
|
||||
CCreateLeaderboardsDialogScaleform();
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
static void UpdateDialog( void );
|
||||
|
||||
void OnOk( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void SetQuery( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void Query_NumResults( SCALEFORM_CALLBACK_ARGS_DECL ); // Query the number of results for this query
|
||||
void Query_GetCurrentPlayerRow( SCALEFORM_CALLBACK_ARGS_DECL ); // Query the number of results for this query
|
||||
void QueryRow_GamerTag( SCALEFORM_CALLBACK_ARGS_DECL ); // Retrieve the gamertag of the user at a specified row
|
||||
void QueryRow_ColumnValue( SCALEFORM_CALLBACK_ARGS_DECL ); // Retrieve a single value from the row we retrieved
|
||||
void QueryRow_ColumnRatio( SCALEFORM_CALLBACK_ARGS_DECL ); // Retrieve the ratio between two column values we retrieved
|
||||
|
||||
void DisplayUserInfo( SCALEFORM_CALLBACK_ARGS_DECL ); // Show the gamer card for the row specified
|
||||
|
||||
protected:
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
virtual void Tick( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
void QueryUpdate( void );
|
||||
void CheckForQueryResults( void );
|
||||
|
||||
#if !defined( NO_STEAM )
|
||||
SteamLeaderboard_t GetLeaderboardHandle( const char* szLeaderboardName );
|
||||
void SetLeaderboardHandle( const char* szLeaderboardName, SteamLeaderboard_t hLeaderboard );
|
||||
|
||||
CCallResult<CCreateLeaderboardsDialogScaleform, LeaderboardFindResult_t> m_SteamCallResultFindLeaderboard;
|
||||
void Steam_OnFindLeaderboard( LeaderboardFindResult_t *pFindLeaderboardResult, bool bIOFailure );
|
||||
|
||||
CCallResult< CCreateLeaderboardsDialogScaleform, LeaderboardScoresDownloaded_t > m_SteamCallbackOnLeaderboardScoresDownloaded;
|
||||
void Steam_OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *p, bool bError );
|
||||
|
||||
// Extract data from the given payload on the active leaderboard (m_currentLeaderboardName) and return it as uint64
|
||||
uint64 ExtractPayloadDataByColumnID( int *pData, int columnId );
|
||||
|
||||
void QueryLeaderboard();
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
int m_iPlayerSlot;
|
||||
XUID m_PlayerXUID;
|
||||
|
||||
// Platform-specific stats storage
|
||||
#ifdef _X360
|
||||
XUSER_STATS_SPEC m_statsSpec;
|
||||
XUSER_STATS_READ_RESULTS* m_pResultsBuffer;
|
||||
CUtlVector<XUSER_STATS_ROW*> m_pResults;
|
||||
|
||||
XONLINE_FRIEND* m_pFriends;
|
||||
XUSER_STATS_READ_RESULTS* m_pFriendsResult[MAX_FRIENDS+1];
|
||||
#endif
|
||||
|
||||
#if !defined( NO_STEAM )
|
||||
// Map from name of board to Steam handle
|
||||
CUtlMap< const char*, SteamLeaderboard_t > m_LeaderboardHandles;
|
||||
|
||||
const char* m_currentLeaderboardName;
|
||||
SteamLeaderboard_t m_currentLeaderboardHandle;
|
||||
|
||||
LeaderboardScoresDownloaded_t m_cachedLeaderboardScores;
|
||||
KeyValues *m_pLeaderboardDescription;
|
||||
|
||||
// NOTE: If the number of payload entries ever exceeds this number, you'll have to manually increase it
|
||||
static const int kMaxPayloadEntries = 16;
|
||||
|
||||
int m_payloadSizes[kMaxPayloadEntries]; // Extracted from the payload format data in the KV description
|
||||
#endif
|
||||
|
||||
AsyncHandle_t m_hAsyncQuery;
|
||||
bool m_bCheckForQueryResults;
|
||||
bool m_bResultsValid;
|
||||
int m_iTotalViewRows;
|
||||
|
||||
int m_iNumFriends;
|
||||
int m_iNextFriend; // for querying our friends list for stats
|
||||
bool m_bEnumeratingFriends;
|
||||
|
||||
float m_fQueryDelayTime;
|
||||
|
||||
eLeaderboardFiltersType m_currentFilterType;
|
||||
int m_startingRowIndex;
|
||||
int m_rowsPerPage;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
#endif // LEADERBOARDSDIALOG_SCALEFORM_H
|
||||
#endif // include scaleform
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,134 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __LOADINGSCREEN_SCALEFORM_H__ )
|
||||
#define __LOADINGSCREEN_SCALEFORM_H__
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "uigamedata.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "gameeventlistener.h"
|
||||
|
||||
class CLoadingScreenScaleform : public ScaleformFlashInterface, public IMatchEventsSink, public CGameEventListener
|
||||
{
|
||||
public:
|
||||
static CLoadingScreenScaleform* m_pInstance;
|
||||
|
||||
CLoadingScreenScaleform();
|
||||
virtual ~CLoadingScreenScaleform();
|
||||
|
||||
//These mirror the VGUI LoadingDialog interface
|
||||
static bool SetProgressPoint( float fraction, bool showDialog = true );
|
||||
static bool SetSecondaryProgressPoint( float fraction );
|
||||
static void DisplayVACBannedError( void );
|
||||
static void DisplayNoSteamConnectionError( void );
|
||||
static void DisplayLoggedInElsewhereError( void );
|
||||
static bool LoadingProgressWantsIsolatedRender( bool bContextValid );
|
||||
|
||||
static void FinishLoading( void );
|
||||
static void CloseLoadingScreen( void );
|
||||
|
||||
//These mirror the VGUI LoadingDialog interface and are unused
|
||||
static void Activate( void ){}
|
||||
static void Open( void ){}
|
||||
static void SetStatusText( const char *statusText, bool showDialog = true );
|
||||
static void SetStatusText( const wchar_t *desc );
|
||||
static void SetSecondaryStatusText( const wchar_t *desc );
|
||||
static void SetSecondaryProgress( float progress ){ SetSecondaryProgressPoint( progress ); }
|
||||
static void SetSecondaryProgressText( const wchar_t *desc ){ SetSecondaryStatusText( desc ); }
|
||||
static bool SetShowProgressText( bool show ){ return true; }
|
||||
|
||||
static void LoadDialog( void );
|
||||
static void LoadDialogForCommand( const char* command );
|
||||
static void LoadDialogForKeyValues( KeyValues* keyValues );
|
||||
static void UnloadDialog( void );
|
||||
static bool IsOpen( void );
|
||||
|
||||
void Show( void );
|
||||
void SetPendingCommand( const char* command );
|
||||
void SetProgressInternal( float fraction );
|
||||
void SetStatusTextInternal( const char *statusText );
|
||||
void SetStatusTextInternal( const wchar_t *desc );
|
||||
void SetSecondaryProgressInternal( float fraction );
|
||||
void SetSecondaryStatusTextInternal( const wchar_t *desc );
|
||||
void CloseScreenUpdateScaleform( void );
|
||||
|
||||
void PlayAnimation();
|
||||
void PlayUnblurAnimation();
|
||||
|
||||
|
||||
|
||||
/************************************
|
||||
* callbacks from scaleform
|
||||
*/
|
||||
|
||||
void ReadyForLoading( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void AnimComplete( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void SWFLoadError( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void SWFLoadSuccess( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void ContinueButtonPressed( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void CloseAndUnload( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
|
||||
bool PreUnloadFlash( void );
|
||||
void PostUnloadFlash( void );
|
||||
void SetPendingKeyValues( KeyValues* keyValues );
|
||||
|
||||
/************************************************************
|
||||
* IMatchEventsSink methods
|
||||
*/
|
||||
void OnEvent( KeyValues *pEvent );
|
||||
|
||||
/********************************************
|
||||
* CGameEventListener methods
|
||||
*/
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
|
||||
protected:
|
||||
void SetLoadingScreenElementsData( const char* mapName );
|
||||
void PopulateLevelInfo( const char* mapName, const char* szGameType, const char* szGameMode );
|
||||
void PopulateLevelInfo( const char* mapName, const char* gameTypeNameID, const char* gameModeNameID, int iGameType, int iGameMode );
|
||||
void PopulateHintText( void );
|
||||
|
||||
void ShowContinueButton( void );
|
||||
|
||||
|
||||
bool m_serverInfoReady;
|
||||
char m_pendingCommand[1024];
|
||||
char m_pendingAttributePurchaseActivate[256];
|
||||
int m_nRequiredAttributeValueForPurchaseActivate;
|
||||
KeyValues * m_pPendingKeyValues;
|
||||
|
||||
double m_flLoadStartTime;
|
||||
|
||||
int m_nAnimFrameCurrent;
|
||||
int m_nAnimFrameTarget;
|
||||
bool m_bStartedUnblur;
|
||||
bool m_bAnimPlaying;
|
||||
bool m_bSWFLoadSuccess;
|
||||
float m_flTimeLastHintUpdate;
|
||||
|
||||
bool m_readyForLoading;
|
||||
bool m_bCreatedMapLoadingScreen;
|
||||
|
||||
bool m_bCheckedForSWFAndFailed;
|
||||
};
|
||||
|
||||
extern CLoadingScreenScaleform g_loadingScreen;
|
||||
|
||||
#endif //__LOADINGSCREEN_SCALEFORM_H__
|
||||
|
||||
#endif //INCLUDE_SCALEFORM
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,575 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFOVERVIEWMAP_H_
|
||||
#define SFOVERVIEWMAP_H_
|
||||
|
||||
#include "hud.h"
|
||||
#include "hud_element_helper.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "HUD/sfhudflashinterface.h"
|
||||
#include "HUD/sfhudradar.h"
|
||||
#include "c_cs_hostage.h"
|
||||
#include "usermessages.h"
|
||||
|
||||
#define MAX_GRENADES 30
|
||||
|
||||
class SFMapOverview : public SFHudFlashInterface
|
||||
{
|
||||
// this manages the display of the players and hostages
|
||||
// in the radar
|
||||
|
||||
protected:
|
||||
enum ICON_PACK_TYPE
|
||||
{
|
||||
ICON_PACK_PLAYER,
|
||||
ICON_PACK_HOSTAGE,
|
||||
ICON_PACK_GRENADES,
|
||||
ICON_PACK_DEFUSER,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
R_BELOW = 0,
|
||||
R_SAMELEVEL = 1,
|
||||
R_ABOVE = 2,
|
||||
};
|
||||
|
||||
// each enum represents an icon that this class is managing
|
||||
enum PLAYER_ICON_INDICES
|
||||
{
|
||||
PI_GRENADE_HE,
|
||||
PI_GRENADE_FLASH,
|
||||
PI_GRENADE_SMOKE,
|
||||
PI_GRENADE_MOLOTOV,
|
||||
PI_GRENADE_DECOY,
|
||||
|
||||
PI_DEFUSER,
|
||||
PI_ABOVE,
|
||||
PI_BELOW,
|
||||
PI_FLASHED,
|
||||
PI_PLAYER_NUMBER,
|
||||
PI_PLAYER_NAME_CT,
|
||||
PI_PLAYER_NAME_T,
|
||||
|
||||
PI_FIRST_ROTATED,
|
||||
PI_PLAYER_INDICATOR = PI_FIRST_ROTATED,
|
||||
PI_SPEAKING,
|
||||
PI_HOSTAGE_MOVING,
|
||||
|
||||
PI_CT,
|
||||
PI_CT_DEAD,
|
||||
PI_CT_GHOST,
|
||||
|
||||
PI_T,
|
||||
PI_T_DEAD,
|
||||
PI_T_GHOST,
|
||||
|
||||
PI_ENEMY,
|
||||
PI_ENEMY_DEAD,
|
||||
PI_ENEMY_GHOST,
|
||||
|
||||
PI_HOSTAGE,
|
||||
PI_HOSTAGE_DEAD,
|
||||
PI_HOSTAGE_GHOST,
|
||||
|
||||
PI_DIRECTION_INDICATOR,
|
||||
PI_MUZZLE_FLASH,
|
||||
|
||||
PI_LOWHEALTH,
|
||||
PI_SELECTED,
|
||||
|
||||
PI_NUM_ICONS
|
||||
};
|
||||
|
||||
class SFMapOverviewIconPackage
|
||||
{
|
||||
|
||||
public:
|
||||
SFMapOverviewIconPackage();
|
||||
~SFMapOverviewIconPackage();
|
||||
|
||||
// zero all the internal variables
|
||||
void ClearAll( void );
|
||||
|
||||
// get handles to the icons which will all be children
|
||||
// of the iconPackage handle
|
||||
void Init( IScaleformUI* pui, SFVALUE iconPackage );
|
||||
|
||||
// release all the handles, and clear all the variables
|
||||
// used when removing players or changing maps
|
||||
void NukeFromOrbit( SFMapOverview* pSFUI );
|
||||
|
||||
// reset all variables to their start of round values
|
||||
void StartRound( void );
|
||||
|
||||
// set the states for this player
|
||||
void SetIsPlayer( bool value );
|
||||
void SetIsSpeaking ( bool value );
|
||||
void SetIsOffMap( bool value );
|
||||
void SetIsLowHealth( bool value );
|
||||
void SetIsSelected( bool value );
|
||||
void SetIsFlashed( bool value );
|
||||
void SetIsFiring( bool value );
|
||||
void SetIsAboveOrBelow( int value );
|
||||
void SetIsMovingHostage( bool value );
|
||||
void SetIsDead( bool value );
|
||||
void SetIsRescued( bool value );
|
||||
void SetPlayerTeam( int team );
|
||||
void SetIsSpotted( bool value );
|
||||
void SetAlpha( float newAlpha );
|
||||
void SetIsOnLocalTeam( bool value );
|
||||
void SetIsControlledBot( void );
|
||||
void SetIsDefuse( bool bValue );
|
||||
void SetGrenadeType( int value );
|
||||
void SetGrenadeExpireTime( float value );
|
||||
|
||||
// given the current set of states, decide which
|
||||
// icons should be shown and which should be hidden
|
||||
void SetupIconsFromStates( void );
|
||||
|
||||
// each bit in newFlags represents the visibility of one of the
|
||||
// icons in the PLAYER_ICON_INDICES. If the bit is on, the icon
|
||||
// is shown.
|
||||
void SetVisibilityFlags( uint64 newFlags );
|
||||
|
||||
bool IsHostageType( void ) { return m_IconPackType == ICON_PACK_HOSTAGE;}
|
||||
bool IsGrenadeType( void ) { return m_IconPackType == ICON_PACK_GRENADES;}
|
||||
bool IsPlayerType( void ) { return m_IconPackType == ICON_PACK_PLAYER;}
|
||||
bool IsDefuserType( void ) { return m_IconPackType == ICON_PACK_DEFUSER;}
|
||||
|
||||
bool IsVisible( void );
|
||||
|
||||
|
||||
public:
|
||||
// pointer to scaleform
|
||||
IScaleformUI* m_pScaleformUI;
|
||||
|
||||
// the parent for all the icons
|
||||
SFVALUE m_IconPackage;
|
||||
SFVALUE m_IconPackageRotate;
|
||||
|
||||
// the handles for all the icons listed in PLAYER_ICON_INDICES
|
||||
SFVALUE m_Icons[PI_NUM_ICONS];
|
||||
|
||||
// the location and position of this player/hostage
|
||||
// only updated when the player is spotted
|
||||
Vector m_Position; // current x,y pos
|
||||
QAngle m_Angle; // view origin 0..360
|
||||
|
||||
// ignore visibility updates until a little time has passed
|
||||
// this keeps track of when the round started
|
||||
float m_fRoundStartTime;
|
||||
|
||||
// the time at which this player/hostage died ( or was rescued )
|
||||
// used to calculate the alpha of the X icon.
|
||||
float m_fDeadTime;
|
||||
|
||||
// the time at which the player / hostage was last spotted
|
||||
// used to fade out the ? icon
|
||||
float m_fGhostTime;
|
||||
|
||||
// the alpha currently used to display all icons
|
||||
// used to lazy update the actual scaleform value
|
||||
float m_fCurrentAlpha;
|
||||
|
||||
|
||||
// each bit represents one of the PLAYER_ICON_INDICES
|
||||
// used to lazy update the visibility of the icons in scaleform
|
||||
uint64 m_iCurrentVisibilityFlags;
|
||||
|
||||
// the index of this player/hostage in the radar.
|
||||
// used to create the instance name of the icon package in flash
|
||||
int m_iIndex;
|
||||
|
||||
// set from the player objects UserID or EntityID ( for the hostages ). Lets us find the radar
|
||||
// object that represents a player / hostage
|
||||
int m_iEntityID;
|
||||
|
||||
|
||||
// state variables used to keep track of the player / hostage state
|
||||
// so we know which icon( s ) to show
|
||||
|
||||
int m_Health; // 0..100, 7 bit
|
||||
|
||||
wchar_t m_wcName[MAX_PLAYER_NAME_LENGTH+1];
|
||||
|
||||
|
||||
// the base icon for the player
|
||||
int m_iPlayerType; // will be PI_CT, PI_T, or PI_HOSTAGE
|
||||
|
||||
int m_nAboveOrBelow;// R_BELOW = 0,R_SAMELEVEL = 1,R_ABOVE = 2,
|
||||
|
||||
int m_nGrenadeType;
|
||||
float m_fGrenExpireTime;
|
||||
|
||||
ICON_PACK_TYPE m_IconPackType;
|
||||
|
||||
bool m_bIsActive : 1;
|
||||
bool m_bOffMap : 1;
|
||||
bool m_bIsLowHealth : 1;
|
||||
bool m_bIsSelected : 1;
|
||||
bool m_bIsFlashed : 1;
|
||||
bool m_bIsFiring : 1;
|
||||
bool m_bIsPlayer : 1;
|
||||
bool m_bIsSpeaking : 1;
|
||||
bool m_bIsDead : 1;
|
||||
bool m_bIsMovingHostage : 1;
|
||||
bool m_bIsSpotted : 1;
|
||||
bool m_bIsRescued : 1;
|
||||
bool m_bIsOnLocalTeam : 1;
|
||||
bool m_bIsDefuser : 1;
|
||||
|
||||
// don't put anything new after the bitfields or suffer the Wrath of the Compiler!
|
||||
};
|
||||
|
||||
|
||||
// this little class manages the display of the hostage
|
||||
// indicators in the panel
|
||||
|
||||
class SFMapOverviewHostageIcons
|
||||
{
|
||||
public:
|
||||
enum HOSTAGE_ICON_INDICES
|
||||
{
|
||||
HI_DEAD,
|
||||
HI_RESCUED,
|
||||
HI_ALIVE,
|
||||
HI_TRANSIT,
|
||||
HI_NUM_ICONS,
|
||||
|
||||
HI_UNUSED = HI_NUM_ICONS,
|
||||
};
|
||||
public:
|
||||
|
||||
SFMapOverviewHostageIcons();
|
||||
~SFMapOverviewHostageIcons();
|
||||
|
||||
void Init( IScaleformUI* scaleformui, SFVALUE iconPackage );
|
||||
void ReleaseHandles( SFMapOverview* pradar );
|
||||
|
||||
void SetStatus( int status );
|
||||
|
||||
public:
|
||||
IScaleformUI* m_pScaleformUI;
|
||||
|
||||
// the parent object of all the icons
|
||||
SFVALUE m_IconPackage;
|
||||
|
||||
// the icons which represent each of the HOSTAGE_ICON_INDICES
|
||||
SFVALUE m_Icons[HI_NUM_ICONS];
|
||||
|
||||
// the index of the icon that is currently shown
|
||||
int m_iCurrentIcon;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// this just keeps track of the bombzone and hostagezone
|
||||
// icons that are shown on the radar
|
||||
|
||||
struct SFMapOverviewGoalIcon
|
||||
{
|
||||
Vector m_Position;
|
||||
SFVALUE m_Icon;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
explicit SFMapOverview( const char *value );
|
||||
virtual ~SFMapOverview();
|
||||
|
||||
// These overload the CHudElement class
|
||||
virtual void ProcessInput( void );
|
||||
virtual void LevelInit( void );
|
||||
virtual void LevelShutdown( void );
|
||||
virtual void SetActive( bool bActive );
|
||||
virtual void Init( void );
|
||||
virtual bool ShouldDraw( void );
|
||||
bool CanShowOverview( void );
|
||||
|
||||
// these overload the ScaleformFlashInterfaceMixin class
|
||||
virtual void FlashLoaded( void );
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
void MapLoaded( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void ToggleOverviewMap( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// overloads for the CGameEventListener class
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
bool MsgFunc_ProcessSpottedEntityUpdate( const CCSUsrMsg_ProcessSpottedEntityUpdate &msg );
|
||||
|
||||
void UpdateAllPlayerNamesAndNumbers( void );
|
||||
void UpdatePlayerNameAndNumber( SFMapOverviewIconPackage* pPackage );
|
||||
|
||||
void ShowMapOverview( bool value );
|
||||
bool IsMapOverviewShown( void ) {return (m_bShowMapOverview && m_bVisible);}
|
||||
|
||||
void AllowMapDrawing( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
// void GetNavPath( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetWorldDistance( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void RefreshGraphs( void );
|
||||
|
||||
protected:
|
||||
void ResetRadar( bool bResetGlobalStates = true );
|
||||
|
||||
void ResetForNewMap( void );
|
||||
void ResetRound( void );
|
||||
void SetMap( const char* pMapName );
|
||||
void WorldToRadar( const Vector& ptin, Vector& ptout );
|
||||
void RadarToWorld( const Vector& ptin, Vector& ptout );
|
||||
void LazyCreateGoalIcons( void );
|
||||
void FlashLoadMap( const char* pMapName );
|
||||
|
||||
void InitIconPackage( SFMapOverviewIconPackage* pPlayer, int iAbsoluteIndex, ICON_PACK_TYPE packType );
|
||||
void RemoveIconPackage( SFMapOverviewIconPackage* pPlayer );
|
||||
|
||||
SFMapOverviewIconPackage* CreatePlayer( int index );
|
||||
void ResetPlayer( int index );
|
||||
void RemovePlayer( int index );
|
||||
|
||||
SFMapOverviewIconPackage* CreateHostage( int index );
|
||||
void ResetHostage( int index );
|
||||
void RemoveHostage( int index );
|
||||
void RemoveStaleHostages( void );
|
||||
|
||||
SFMapOverviewIconPackage* CreateGrenade( int entityID, int nGrenadeType );
|
||||
void RemoveAllGrenades( void );
|
||||
void RemoveGrenade( int index );
|
||||
|
||||
SFMapOverviewIconPackage * CreateDefuser( int nEntityID );
|
||||
SFMapOverviewIconPackage * GetDefuser( int nEntityID, bool bCreateIfNotFound = false );
|
||||
void SetDefuserPos( int nEntityID, int x, int y, int z, int a );
|
||||
void UpdateAllDefusers( void );
|
||||
void RemoveAllDefusers( void );
|
||||
void RemoveDefuser( int index );
|
||||
|
||||
bool LazyUpdateIconArray( SFMapOverviewIconPackage* pArray, int lastIndex );
|
||||
virtual bool LazyCreateIconPackage( SFMapOverviewIconPackage* pPackage );
|
||||
|
||||
void LazyCreatePlayerIcons( void );
|
||||
|
||||
void SetPlayerTeam( int index, int team );
|
||||
|
||||
int GetPlayerIndexFromUserID( int userID );
|
||||
int GetHostageIndexFromHostageEntityID( int entityID );
|
||||
int GetGrenadeIndexFromEntityID( int entityID );
|
||||
int GetDefuseIndexFromEntityID( int nEntityID );
|
||||
|
||||
void ApplySpectatorModes( void );
|
||||
|
||||
void PositionRadarViewpoint( void );
|
||||
void PlaceGoalIcons( void );
|
||||
void Show( bool show );
|
||||
void ShowPanel( bool bShow );
|
||||
void PlacePlayers();
|
||||
void PlaceHostages();
|
||||
void SetIconPackagePosition( SFMapOverviewIconPackage* pPackage );
|
||||
void UpdateMiscIcons( void );
|
||||
void SetVisibilityFlags( uint64 newFlags );
|
||||
void SetupIconsFromStates( void );
|
||||
bool IsEnemyCloseEnoughToShow( Vector vecEnemyPos );
|
||||
|
||||
void SetLocationText( wchar_t *newText );
|
||||
|
||||
void ResetRoundVariables( bool bResetGlobalStates = true );
|
||||
|
||||
void UpdateGrenades( void );
|
||||
|
||||
SFMapOverviewIconPackage* GetRadarPlayer( int index );
|
||||
SFMapOverviewIconPackage* GetRadarHostage( int index );
|
||||
SFMapOverviewIconPackage* GetRadarGrenade( int index );
|
||||
SFMapOverviewIconPackage* GetRadarDefuser( int index );
|
||||
SFMapOverviewIconPackage* GetRadarHeight( int index );
|
||||
|
||||
CUserMessageBinder m_UMCMsgProcessSpottedEntityUpdate;
|
||||
|
||||
protected:
|
||||
|
||||
// these are the icons used individually by the radar and panel
|
||||
enum RADAR_ICON_INDICES
|
||||
{
|
||||
RI_BOMB_IS_PLANTED,
|
||||
RI_BOMB_IS_PLANTED_MEDIUM,
|
||||
RI_BOMB_IS_PLANTED_FAST,
|
||||
RI_IN_HOSTAGE_ZONE,
|
||||
RI_DASHBOARD,
|
||||
RI_BOMB_ICON_PLANTED,
|
||||
RI_BOMB_ICON_DROPPED,
|
||||
RI_BOMB_ICON_BOMB_CT,
|
||||
RI_BOMB_ICON_BOMB_T,
|
||||
RI_BOMB_ICON_BOMB_ABOVE,
|
||||
RI_BOMB_ICON_BOMB_BELOW,
|
||||
RI_BOMB_ICON_PACKAGE,
|
||||
RI_DEFUSER_ICON_DROPPED,
|
||||
RI_DEFUSER_ICON_PACKAGE,
|
||||
|
||||
RI_NUM_ICONS,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_BOMB_ZONES = 2,
|
||||
};
|
||||
|
||||
|
||||
// this holds the names and indexes of the messages we receive so that
|
||||
// we don't have to do a whole bunch of string compares to find them
|
||||
static CUtlMap<const char*, int> m_messageMap;
|
||||
|
||||
// these are used to scale world coordinates to radar coordinates
|
||||
Vector m_MapOrigin;
|
||||
float m_fMapSize;
|
||||
float m_fMapScale;
|
||||
float m_fPixelToRadarScale;
|
||||
float m_fWorldToPixelScale;
|
||||
float m_fWorldToRadarScale;
|
||||
|
||||
|
||||
// this is center of the radar in world and map coordinates
|
||||
Vector m_RadarViewpointWorld;
|
||||
Vector m_RadarViewpointMap;
|
||||
float m_RadarRotation;
|
||||
|
||||
|
||||
// the current position of the bomb
|
||||
Vector m_BombPosition;
|
||||
|
||||
// the last time the bomb was seen. Used to fade
|
||||
// out the bomb icon after it has dropped out of sight
|
||||
float m_fBombSeenTime;
|
||||
float m_fBombAlpha;
|
||||
|
||||
|
||||
// the current position of the defuser
|
||||
Vector m_DefuserPosition;
|
||||
|
||||
// the last time the defuser was seen. Used to fade
|
||||
// out the defuser icon after it has dropped out of sight
|
||||
float m_fDefuserSeenTime;
|
||||
float m_fDefuserAlpha;
|
||||
|
||||
// a bitmap of the icons that are currently beeing shown.
|
||||
// each bit corresponds to one the RADAR_ICON_INDICES
|
||||
uint64 m_iCurrentVisibilityFlags;
|
||||
|
||||
// the handles to the RADAR_ICON_INDICES icons
|
||||
SFVALUE m_AllIcons[RI_NUM_ICONS];
|
||||
|
||||
// Background panel
|
||||
SFVALUE m_BackgroundPanel;
|
||||
|
||||
// handles to the radar movie clips in flash.
|
||||
// there is a rotation and a translation layer each for the icons and for the background map.
|
||||
// The map and the icons have separate layers because the map is behind a mask layer, and the
|
||||
// icons are not.
|
||||
|
||||
// the root of the entire radar and dashboard
|
||||
SFVALUE m_RadarModule;
|
||||
|
||||
// the root of the radar part of the module
|
||||
SFVALUE m_Radar;
|
||||
|
||||
// the layers that handle the icons
|
||||
SFVALUE m_IconTranslation;
|
||||
SFVALUE m_IconRotation;
|
||||
|
||||
// the layers that handle the map
|
||||
SFVALUE m_MapRotation;
|
||||
SFVALUE m_MapTranslation;
|
||||
|
||||
// handles to the actual bomb zone and hostage icons that are defined
|
||||
// in the flash file
|
||||
SFVALUE m_HostageZoneIcons[MAX_HOSTAGE_RESCUES];
|
||||
SFVALUE m_BombZoneIcons[MAX_BOMB_ZONES];
|
||||
|
||||
// "handle" to the text that holds the current location
|
||||
ISFTextObject* m_LocationText;
|
||||
|
||||
// the last index of an active player in the m_Players array
|
||||
int m_iLastPlayerIndex;
|
||||
|
||||
// the last index of an active hostage in the m_Hostages array
|
||||
int m_iLastHostageIndex;
|
||||
|
||||
// the last index of an active decoy in the m_Grenades array
|
||||
int m_iLastGrenadeIndex;
|
||||
|
||||
// the last index of an active defuser in the m_Defuser array
|
||||
int m_iLastDefuserIndex;
|
||||
|
||||
// keeps the state information and icon handles for the players
|
||||
SFMapOverviewIconPackage m_Players[MAX_PLAYERS];
|
||||
|
||||
// keeps the state information and icon handles for the hostages
|
||||
SFMapOverviewIconPackage m_Hostages[MAX_HOSTAGES];
|
||||
|
||||
// keeps the state information and icon handles for the decoys
|
||||
SFMapOverviewIconPackage m_Grenades[MAX_GRENADES];
|
||||
|
||||
// keeps the state information and icon handles for the decoys
|
||||
SFMapOverviewIconPackage m_Defusers[MAX_PLAYERS];
|
||||
|
||||
// the handles to the hostage status icons that appear beneath the dashboard
|
||||
SFMapOverviewHostageIcons m_HostageStatusIcons[MAX_HOSTAGES];
|
||||
|
||||
// a goal icon is either a bomb-area or a hostage-area icon
|
||||
// This array holds the positions / handles of the ones that are active for the current map
|
||||
int m_iNumGoalIcons;
|
||||
SFMapOverviewGoalIcon m_GoalIcons[MAX_HOSTAGE_RESCUES + MAX_BOMB_ZONES];
|
||||
|
||||
// the current observer mode. Figures into the placement of the center of the radar
|
||||
// and a few other things
|
||||
int m_iObserverMode;
|
||||
|
||||
// there is a loaded and a desired so that we don't load the same map twice, and so that we
|
||||
// can request that a map be loaded before the flash stuff is able to actually load it.
|
||||
char m_cLoadedMapName[MAX_MAP_NAME+1];
|
||||
char m_cDesiredMapName[MAX_MAP_NAME+1];
|
||||
|
||||
// the name of our current location
|
||||
wchar_t m_wcLocationString[MAX_LOCATION_TEXT_LENGTH+1];
|
||||
|
||||
// // keeps track of weather flash is ready or not and if it's currently being loaded
|
||||
bool m_bFlashLoading : 1;
|
||||
bool m_bFlashReady : 1;
|
||||
|
||||
// this is set by a con command to hide the whole radar
|
||||
bool m_bShowMapOverview : 1;
|
||||
//
|
||||
// // set to true in spectator mode if we're not in pro mode
|
||||
bool m_bShowAll : 1;
|
||||
//
|
||||
// keep track of whether we've already gotten all the goal icons and player icons from the
|
||||
// flash file. This is necessary because some of the level information is loaded before
|
||||
// flash is ready
|
||||
bool m_bGotGoalIcons : 1;
|
||||
bool m_bGotPlayerIcons : 1;
|
||||
|
||||
// state information about which icons should be displayed
|
||||
bool m_bShowingHostageZone : 1;
|
||||
bool m_bBombPlanted : 1;
|
||||
bool m_bBombDropped : 1;
|
||||
bool m_bBombDefused : 1;
|
||||
bool m_bBombExploded : 1;
|
||||
bool m_bShowBombHighlight : 1;
|
||||
bool m_bShowingDashboard : 1;
|
||||
|
||||
bool m_bBombIsSpotted : 1;
|
||||
int m_nBombEntIndex;
|
||||
|
||||
bool m_bTrackDefusers;
|
||||
|
||||
bool m_bVisible;
|
||||
|
||||
// entities spotted last ProcessSpottedEntityUpdate
|
||||
CBitVec<MAX_EDICTS> m_EntitySpotted;
|
||||
};
|
||||
|
||||
#endif /* SFOVERVIEWMAP_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CREATEMEDALSTATSDIALOG_H
|
||||
#define CREATEMEDALSTATSDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
class CCSBaseAchievement;
|
||||
|
||||
enum eAchievementStatus
|
||||
{
|
||||
eAchievement_Locked,
|
||||
eAchievement_Unlocked,
|
||||
eAchievement_Secret,
|
||||
eAchievement_RecentUnlock,
|
||||
};
|
||||
|
||||
class CCreateMedalStatsDialogScaleform: public ScaleformFlashInterface
|
||||
{
|
||||
public:
|
||||
enum eDialogType
|
||||
{
|
||||
eDialogType_Stats_Overall = 0,
|
||||
eDialogType_Stats_Last_Match = 1,
|
||||
eDialogType_Medals = 2,
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
static CCreateMedalStatsDialogScaleform* m_pInstance;
|
||||
|
||||
CCreateMedalStatsDialogScaleform( eDialogType type );
|
||||
|
||||
public:
|
||||
static void LoadDialog( eDialogType type );
|
||||
static void UnloadDialog( void );
|
||||
|
||||
void OnOk( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void UpdateCurrentAchievement( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetAchievementStatus( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetRecentAchievementCount( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetRecentAchievementName( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetRankForCurrentCatagory( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetMaxAwardsForCatagory( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetAchievedInCategory( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetMinAwardNeededForRank( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
|
||||
protected:
|
||||
virtual void FlashReady( void );
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
void UpdateMedalProgress( CCSBaseAchievement* pAchievement );
|
||||
|
||||
void PopulateLastMatchStats();
|
||||
void PopulateOverallStats();
|
||||
|
||||
// Fills out our array of the N most recent achievements
|
||||
void GenerateRecentAchievements();
|
||||
private:
|
||||
SFVALUE m_MedalNameHandle;
|
||||
SFVALUE m_MedalUnlockHandle;
|
||||
SFVALUE m_MedalDescHandle;
|
||||
|
||||
CUtlVector<CCSBaseAchievement*> m_recentAchievements;
|
||||
|
||||
SFVALUE m_LastMatchTeamStats;
|
||||
SFVALUE m_LastMatchFaveWeaponName;
|
||||
SFVALUE m_LastMatchFaveWeaponStats;
|
||||
SFVALUE m_LastMatchPerfStats;
|
||||
SFVALUE m_LastMatchMiscStats;
|
||||
|
||||
SFVALUE m_OverallPlayerName;
|
||||
SFVALUE m_OverallMVPsText;
|
||||
SFVALUE m_OverallPlayerStats;
|
||||
SFVALUE m_OverallFaveWeaponName;
|
||||
SFVALUE m_OverallFaveWeaponStats;
|
||||
SFVALUE m_OverallFaveMapStats;
|
||||
|
||||
int m_iPlayerSlot;
|
||||
uint m_mostRecentAchievementTime; // UTC of most recently earned achievement (used for recent achievement highlight)
|
||||
|
||||
int32 volatile m_nEloBracket; // Which elo bracket emblem to show in the ui.
|
||||
|
||||
eDialogType m_type;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
#endif // CREATEMEDALSTATSDIALOG_H
|
||||
#endif // include scaleform
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,277 @@
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef MESSAGEBOX_SCALEFORM_H
|
||||
#define MESSAGEBOX_SCALEFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "GameUI/IGameUI.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
#define MAX_SCALEFORM_MESSAGE_BOX_LENGTH 1024
|
||||
|
||||
enum MessageBoxFlags_t
|
||||
{
|
||||
MESSAGEBOX_FLAG_INVALID = 0x00,
|
||||
MESSAGEBOX_FLAG_OK = 0x01,
|
||||
MESSAGEBOX_FLAG_CANCEL = 0x02,
|
||||
MESSAGEBOX_FLAG_BOX_CLOSED = 0x04,
|
||||
MESSAGEBOX_FLAG_AUTO_CLOSE_ON_DISCONNECT = 0x08,
|
||||
MESSAGEBOX_FLAG_TERTIARY = 0x10 // for third options, like "Press Y for Default"
|
||||
};
|
||||
|
||||
class CMessageBoxScaleform;
|
||||
void ClearMessageBoxCallback( CMessageBoxScaleform* pMsgBox );
|
||||
|
||||
abstract_class IMessageBoxEventCallback
|
||||
{
|
||||
friend class CMessageBoxScaleform;
|
||||
|
||||
public:
|
||||
IMessageBoxEventCallback()
|
||||
{
|
||||
m_pMessageBoxReference = NULL;
|
||||
}
|
||||
|
||||
virtual ~IMessageBoxEventCallback()
|
||||
{
|
||||
ClearMessageBoxCallback( m_pMessageBoxReference );
|
||||
m_pMessageBoxReference = NULL;
|
||||
}
|
||||
|
||||
// Which button the user selected. Callback should return true in order to dismiss the message box.
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed ) = 0;
|
||||
|
||||
virtual bool OnUpdate( void ) { return false; }
|
||||
virtual void NotifyOnReady( void ) { }
|
||||
|
||||
// Override this as true for any message that you want to persist when you go in/out of levels or the front-end (eg. error codes, game-modal dialogs)
|
||||
virtual bool IsPriorityMessage() { return false; }
|
||||
|
||||
protected:
|
||||
// Allow all callbacks to keep a reference to their owner message box
|
||||
CMessageBoxScaleform *m_pMessageBoxReference;
|
||||
};
|
||||
|
||||
class CMessageBoxScaleform : public ScaleformFlashInterfaceMixin<CGameEventListener>
|
||||
{
|
||||
protected:
|
||||
static CUtlVector<CMessageBoxScaleform*> m_sMessageBoxes;
|
||||
|
||||
CMessageBoxScaleform( char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, wchar_t const *pszWideMessage = NULL );
|
||||
|
||||
virtual ~CMessageBoxScaleform();
|
||||
|
||||
public:
|
||||
static CMessageBoxScaleform * GetLastMessageBoxCreated();
|
||||
static void LoadDialog( char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL, wchar_t const *pszWideMessage = NULL );
|
||||
static void LoadDialogInSlot( int slot, char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL, wchar_t const *pszWideMessage = NULL );
|
||||
|
||||
// Creates the message box with three options: OK, Cancel, and "your button legend"
|
||||
static void LoadDialogThreeway( char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, char const *pszTertiaryButtonLabel, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL );
|
||||
|
||||
// When the bClosePriorityMsgBoxes is set, we will also close every message box that overrides IsPriorityMessageBox=true (CCommandMsgBox for example)
|
||||
static void UnloadAllDialogs( bool bClosePriorityMsgBoxes = true );
|
||||
|
||||
// Are there any important messages open we want to leave active?
|
||||
static bool IsPriorityMessageOpen();
|
||||
|
||||
bool IsReady() { return m_bIsReady; }
|
||||
bool IsPriorityMessage();
|
||||
|
||||
void SetTitle( char const *pszTitle );
|
||||
void SetMessage( char const *pszMessage );
|
||||
void SetTitle( wchar_t const * pwcTitle );
|
||||
void SetMessage( wchar_t const * pszMessage );
|
||||
void SetButtonLegend( char const *pszButtonLegend );
|
||||
void SetFlags( DWORD dwFlags );
|
||||
|
||||
void SetOKButtonLabel( char const *pszOKButtonLabel );
|
||||
|
||||
void SetThirdButtonLabel( char const *pszThirdButtonLabel );
|
||||
|
||||
void OnButtonPress( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnMessageBoxClosed( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnTimerCallback( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
void HideImmediate();
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
void ClearCallback() { m_pEventCallback = NULL; }
|
||||
|
||||
protected:
|
||||
bool m_bIsReady;
|
||||
|
||||
char m_szTitle[MAX_SCALEFORM_MESSAGE_BOX_LENGTH];
|
||||
char m_szMessage[MAX_SCALEFORM_MESSAGE_BOX_LENGTH];
|
||||
char m_szButtonLegend[2048];
|
||||
char m_szThirdButtonLabel[MAX_SCALEFORM_MESSAGE_BOX_LENGTH];
|
||||
char m_szOKButtonLabel[MAX_SCALEFORM_MESSAGE_BOX_LENGTH];
|
||||
|
||||
wchar_t m_szWideMessage[MAX_SCALEFORM_MESSAGE_BOX_LENGTH];
|
||||
|
||||
DWORD m_dwFlags; // See MessageBoxFlags_t
|
||||
|
||||
IMessageBoxEventCallback *m_pEventCallback;
|
||||
|
||||
virtual void FlashReady();
|
||||
virtual void PostUnloadFlash();
|
||||
virtual void FlashLoaded();
|
||||
};
|
||||
|
||||
|
||||
// hosts a message box that can execute con commands based on the user's response
|
||||
// commands are strings that will be passed to engine->ClientCommand_Unrestricted. If the command begins with '!', the code will call engine->ClientCommand instead.
|
||||
// this is a
|
||||
|
||||
class CCommandMsgBox : public IMessageBoxEventCallback
|
||||
{
|
||||
public:
|
||||
static void CreateAndShow( const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
static void CreateAndShowInSlot( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
|
||||
// Command messages are typically game-critical: they are used for trial mode messages, as well as explanation for being kicked from a server or failure to load a map
|
||||
virtual bool IsPriorityMessage() { return true; }
|
||||
|
||||
protected:
|
||||
CCommandMsgBox( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
~CCommandMsgBox();
|
||||
char* m_pCommands[3];
|
||||
int m_iExitCommand;
|
||||
CMessageBoxScaleform* m_pMessageBox;
|
||||
|
||||
void SetCommand( int index, const char* command );
|
||||
void ExecuteCommand( int index );
|
||||
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonProssed );
|
||||
};
|
||||
|
||||
// hosts the matchmaking message box
|
||||
|
||||
class CMatchmakingStatus : public IMatchEventsSink, public IMessageBoxEventCallback
|
||||
{
|
||||
public:
|
||||
CMatchmakingStatus();
|
||||
CMatchmakingStatus( char const *szCustomTitle, char const *szCustomText );
|
||||
~CMatchmakingStatus();
|
||||
|
||||
void SetTimeToAutoCancel( double dblPlatFloatTime );
|
||||
|
||||
protected:
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
|
||||
// IMessageBoxEventsCallback implementation
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
CMessageBoxScaleform *m_pMessageBoxInstance;
|
||||
bool m_bErrorEncountered;
|
||||
|
||||
double m_dblTimeToAutoCancel;
|
||||
};
|
||||
|
||||
// hosts the store message box
|
||||
|
||||
class CStoreStatusScaleform : public IMessageBoxEventCallback
|
||||
{
|
||||
public:
|
||||
static void HideInstance();
|
||||
explicit CStoreStatusScaleform( const char *szText, bool bAllowClose, bool bCancel, const char *szCommandOk = NULL );
|
||||
~CStoreStatusScaleform();
|
||||
|
||||
protected:
|
||||
// IMessageBoxEventsCallback implementation
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
CMessageBoxScaleform *m_pMessageBoxInstance;
|
||||
static CStoreStatusScaleform *s_pStoreStatusBox;
|
||||
|
||||
const char *m_pszCommandOk;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// since first frame key-input has crossover with the button press to open the menu
|
||||
// we have a state machine to force us to skip first frame input
|
||||
enum CMessageBoxLockInputState
|
||||
{
|
||||
MESSAGE_BOX_LOCK_STATE_INIT,
|
||||
MESSAGE_BOX_LOCK_STATE_SCANNING,
|
||||
MESSAGE_BOX_LOCK_STATE_FINISHED,
|
||||
};
|
||||
|
||||
// hosts the lock input message box
|
||||
class CMessageBoxLockInput : public IMatchEventsSink, public IMessageBoxEventCallback
|
||||
{
|
||||
public:
|
||||
CMessageBoxLockInput( void );
|
||||
~CMessageBoxLockInput( void );
|
||||
|
||||
virtual bool IsPriorityMessage() { return true; }
|
||||
|
||||
protected:
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
virtual bool OnUpdate( void );
|
||||
virtual void NotifyOnReady( void );
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
CMessageBoxScaleform *m_pMessageBoxInstance;
|
||||
CMessageBoxLockInputState m_lockState;
|
||||
};
|
||||
|
||||
|
||||
class CMessageBoxCalibrateNotification : public IMatchEventsSink, public IMessageBoxEventCallback
|
||||
{
|
||||
public:
|
||||
CMessageBoxCalibrateNotification( void );
|
||||
~CMessageBoxCalibrateNotification( void );
|
||||
|
||||
virtual bool IsPriorityMessage() { return true; }
|
||||
|
||||
protected:
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
virtual bool OnUpdate( void );
|
||||
virtual void NotifyOnReady( void );
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
CMessageBoxScaleform *m_pMessageBoxInstance;
|
||||
};
|
||||
|
||||
|
||||
// [dkorus] used to differenciate popups, so we can ensure we're enabling and disabling the same popup type
|
||||
// while managing them in a one-at-a-time method
|
||||
enum ManagedPopupType
|
||||
{
|
||||
POPUP_TYPE_NONE = 0,
|
||||
POPUP_TYPE_HIDING,
|
||||
POPUP_TYPE_PSEYE_DISCONNECTED,
|
||||
POPUP_TYPE_PSMOVE_OUT_OF_VIEW,
|
||||
};
|
||||
|
||||
// Used to manage the numerous popups we need for TRC and TCR compliance.
|
||||
class PopupManager
|
||||
{
|
||||
public:
|
||||
static void Update( void );
|
||||
|
||||
static void UpdateTryHideSingleUsePopup( void );
|
||||
static bool ShowSingleUsePopup( ManagedPopupType popupType );
|
||||
static bool HideSingleUsePopup( ManagedPopupType popupType );
|
||||
|
||||
private:
|
||||
|
||||
static ManagedPopupType s_singleUsePopupType;
|
||||
};
|
||||
|
||||
#endif // MESSAGEBOX_SCALEFORM_H
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,580 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include "basepanel.h"
|
||||
#include "gameui_util.h"
|
||||
#include "motion_calibration_scaleform.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
|
||||
#if defined( _PS3 )
|
||||
#include <cell/gem.h> // PS3 move controller lib
|
||||
#endif // defined( _PS3 )
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
ConVar cl_test_calibration( "cl_test_calibration", "0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY );
|
||||
|
||||
|
||||
CMotionCalibrationScaleform* CMotionCalibrationScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( OnCancel ),
|
||||
SFUI_DECL_METHOD( OnAccept ),
|
||||
SFUI_DECL_METHOD( TimerCallback ),
|
||||
SFUI_END_GAME_API_DEF( CMotionCalibrationScaleform, MotionCalibration );
|
||||
|
||||
CMotionCalibrationScaleform::CMotionCalibrationScaleform() :
|
||||
m_bVisible ( false ),
|
||||
m_bLoading ( false ),
|
||||
m_pInfoText( NULL ),
|
||||
m_pNavText( NULL ),
|
||||
m_pTargetTopLeft( NULL ),
|
||||
m_pTargetBottomLeft( NULL ),
|
||||
m_pTargetBottomRight( NULL ),
|
||||
m_pTargetTopRight( NULL ),
|
||||
m_pSensitivity( NULL ),
|
||||
m_nSceneLevel( SCENE_START ),
|
||||
m_bCursorVisible( false )
|
||||
{
|
||||
m_iSplitScreenSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
}
|
||||
|
||||
|
||||
|
||||
CMotionCalibrationScaleform::~CMotionCalibrationScaleform()
|
||||
{
|
||||
#if defined( _PS3 )
|
||||
g_pScaleformUI->PS3ForceCursorEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CMotionCalibrationScaleform();
|
||||
m_pInstance->m_bLoading = true;
|
||||
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CMotionCalibrationScaleform, m_pInstance, MotionCalibration );
|
||||
}
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::UnloadDialog( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::FlashLoaded( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::FlashReady( void )
|
||||
{
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
SF_FORCE_SPLITSCREEN_PLAYER_GUARD( m_iSplitScreenSlot );
|
||||
m_bLoading = false;
|
||||
|
||||
LockInputToSlot( m_iSplitScreenSlot );
|
||||
|
||||
|
||||
SFVALUE panelTop = m_pScaleformUI->Value_GetMember( m_FlashAPI, "PanelTop" );
|
||||
|
||||
if ( panelTop )
|
||||
{
|
||||
SFVALUE panel = m_pScaleformUI->Value_GetMember( panelTop, "Panel" );
|
||||
|
||||
if ( panel )
|
||||
{
|
||||
m_pInfoText = m_pScaleformUI->TextObject_MakeTextObjectFromMember( panel, "InfoText" );
|
||||
|
||||
m_pSensitivity = m_pScaleformUI->Value_GetMember( panel, "Sensitivity" );
|
||||
m_pScaleformUI->Value_SetVisible( m_pSensitivity, false );
|
||||
|
||||
SFVALUE navBar = m_pScaleformUI->Value_GetMember( panel, "NavigationMaster" );
|
||||
if ( navBar )
|
||||
{
|
||||
m_pNavText = m_pScaleformUI->TextObject_MakeTextObjectFromMember( navBar, "ControllerNavl" );
|
||||
m_pScaleformUI->ReleaseValue( navBar );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( panel );
|
||||
}
|
||||
|
||||
|
||||
m_pScaleformUI->ReleaseValue( panelTop );
|
||||
}
|
||||
|
||||
m_pTargetTopLeft = m_pScaleformUI->Value_GetMember( m_FlashAPI, "TargetUpperLeft" );
|
||||
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopLeft, false );
|
||||
|
||||
m_pTargetBottomLeft = m_pScaleformUI->Value_GetMember( m_FlashAPI, "TargetLowerLeft" );
|
||||
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomLeft, false );
|
||||
|
||||
m_pTargetBottomRight = m_pScaleformUI->Value_GetMember( m_FlashAPI, "TargetLowerRight" );
|
||||
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomRight, false );
|
||||
|
||||
m_pTargetTopRight = m_pScaleformUI->Value_GetMember( m_FlashAPI, "TargetUpperRight" );
|
||||
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopRight, false );
|
||||
|
||||
// advance through scenes until we require player input
|
||||
while ( TryAdvance( false, false ) );
|
||||
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::Show( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() && !m_bVisible )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowPanel", 0, NULL );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::Hide( void )
|
||||
{
|
||||
#if defined( _PS3 )
|
||||
g_pScaleformUI->PS3UseStandardCursor();
|
||||
#endif
|
||||
|
||||
if ( FlashAPIIsValid() && m_bVisible )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HidePanel", 0, NULL );
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
|
||||
RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool CMotionCalibrationScaleform::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFTextObject( m_pInfoText );
|
||||
SafeReleaseSFTextObject( m_pNavText );
|
||||
SafeReleaseSFVALUE( m_pTargetTopLeft);
|
||||
SafeReleaseSFVALUE( m_pTargetBottomLeft);
|
||||
SafeReleaseSFVALUE( m_pTargetBottomRight );
|
||||
SafeReleaseSFVALUE( m_pTargetTopRight );
|
||||
SafeReleaseSFVALUE( m_pSensitivity );
|
||||
|
||||
UnlockInput();
|
||||
|
||||
return ScaleformFlashInterface::PreUnloadFlash();
|
||||
}
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::OnCancel( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( m_nSceneLevel == SCENE_ADJUST_SENSITIVITY ||
|
||||
m_nSceneLevel == SCENE_CALIBRATE_CONTROLLER_RESULT )
|
||||
{
|
||||
TryAdvance( false, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
|
||||
if ( !GameUI().IsInLevel() )
|
||||
{
|
||||
g_pInputSystem->ResetCurrentInputDevice();
|
||||
g_pInputSystem->SampleInputToFindCurrentDevice( false );
|
||||
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "mb_input_lock_cancel" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::OnAccept( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
TryAdvance( true, false );
|
||||
}
|
||||
|
||||
|
||||
bool CMotionCalibrationScaleform::TryAdvance( bool bAccept, bool bCancel )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
switch ( m_nSceneLevel )
|
||||
{
|
||||
case SCENE_START:
|
||||
bResult = true;
|
||||
inputsystem->SetMotionControllerCalibrationInvalid();
|
||||
break;
|
||||
|
||||
case SCENE_CONNECT_EYE:
|
||||
{
|
||||
bResult = ( inputsystem->GetMotionControllerDeviceStatus() > INPUT_DEVICE_MC_STATE_CAMERA_NOT_CONNECTED || cl_test_calibration.GetBool() );
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_CONNECT_CONTROLLER:
|
||||
{
|
||||
bool moveConnected = g_pInputSystem->IsInputDeviceConnected( INPUT_DEVICE_PLAYSTATION_MOVE );
|
||||
bool sharpshooterConnected = g_pInputSystem->IsInputDeviceConnected( INPUT_DEVICE_SHARPSHOOTER );
|
||||
|
||||
bResult = ( moveConnected || sharpshooterConnected || cl_test_calibration.GetBool() );
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_CALIBRATE_CONTROLLER:
|
||||
bResult = ( inputsystem->GetMotionControllerDeviceStatus() == INPUT_DEVICE_MC_STATE_OK ||
|
||||
inputsystem->GetMotionControllerDeviceStatus() == INPUT_DEVICE_MC_STATE_CONTROLLER_ERROR ||
|
||||
cl_test_calibration.GetBool() );
|
||||
break;
|
||||
|
||||
case SCENE_CALIBRATE_CONTROLLER_RESULT:
|
||||
if ( inputsystem->GetMotionControllerDeviceStatus() != INPUT_DEVICE_MC_STATE_CONTROLLER_ERROR )
|
||||
{
|
||||
#if defined( _PS3 )
|
||||
// if GetMotionControllerDeviceStatusFlags is exactly = to the CELL_GEM_FLAG_CALIBRATION_OCCURRED and CELL_GEM_FLAG_CALIBRATION_SUCCEEDED bit mask then
|
||||
// it means that no warning or error flags were raised and that we may proceed
|
||||
bool bOkToProceed = ( inputsystem->GetMotionControllerDeviceStatusFlags() == ( CELL_GEM_FLAG_CALIBRATION_OCCURRED | CELL_GEM_FLAG_CALIBRATION_SUCCEEDED ) );
|
||||
|
||||
if ( bOkToProceed == false )
|
||||
{
|
||||
// according to the Sony SDK it is possible for the CELL_GEM_FLAG_CALIBRATION_OCCURRED flag to be ommited on success
|
||||
bOkToProceed = ( inputsystem->GetMotionControllerDeviceStatusFlags() == CELL_GEM_FLAG_CALIBRATION_SUCCEEDED );
|
||||
}
|
||||
#else
|
||||
bool bOkToProceed = true;
|
||||
#endif // defined( _PS3 )
|
||||
|
||||
bResult = bAccept || bOkToProceed ;
|
||||
}
|
||||
|
||||
if ( bCancel )
|
||||
{
|
||||
m_nSceneLevel = SCENE_START;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_TOP_LEFT:
|
||||
if ( bAccept )
|
||||
{
|
||||
inputsystem->StepMotionControllerCalibration();
|
||||
bResult = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_BOTTOM_RIGHT:
|
||||
if ( bAccept )
|
||||
{
|
||||
inputsystem->StepMotionControllerCalibration();
|
||||
bResult = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_BOTTOM_LEFT:
|
||||
if ( bAccept )
|
||||
{
|
||||
inputsystem->StepMotionControllerCalibration();
|
||||
bResult = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_TOP_RIGHT:
|
||||
if ( bAccept )
|
||||
{
|
||||
inputsystem->StepMotionControllerCalibration();
|
||||
bResult = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_ADJUST_SENSITIVITY:
|
||||
if ( bCancel )
|
||||
{
|
||||
inputsystem->ResetMotionControllerScreenCalibration();
|
||||
m_nSceneLevel = SCENE_TARGET_TOP_LEFT;
|
||||
}
|
||||
|
||||
bResult = bAccept;
|
||||
|
||||
break;
|
||||
|
||||
case SCENE_END:
|
||||
Hide();
|
||||
IGameEvent * event = gameeventmanager->CreateEvent( "mb_input_lock_success" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( bResult )
|
||||
{
|
||||
SceneAdvance();
|
||||
}
|
||||
|
||||
SceneDraw( m_nSceneLevel );
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::SceneAdvance( void )
|
||||
{
|
||||
if ( !FlashAPIIsValid() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//WITH_SLOT_LOCKED
|
||||
//{
|
||||
// switch ( m_nSceneLevel )
|
||||
// {
|
||||
// case SCENE_START:
|
||||
// case SCENE_CONNECT_EYE:
|
||||
// case SCENE_CONNECT_CONTROLLER:
|
||||
// case SCENE_CALIBRATE_CONTROLLER:
|
||||
// case SCENE_CALIBRATE_CONTROLLER_RESULT:
|
||||
// case SCENE_TARGET_TOP_LEFT:
|
||||
// case SCENE_TARGET_BOTTOM_RIGHT:
|
||||
// case SCENE_TARGET_BOTTOM_LEFT:
|
||||
// case SCENE_TARGET_TOP_RIGHT:
|
||||
// case SCENE_END:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
m_nSceneLevel++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::SceneDraw( int nSceneLevel )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_SetVisible( m_pSensitivity, false );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopLeft, false );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomLeft, false );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomRight, false );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopRight, false );
|
||||
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Cancel", NULL ) );
|
||||
|
||||
switch ( nSceneLevel )
|
||||
{
|
||||
case SCENE_START:
|
||||
break;
|
||||
|
||||
case SCENE_CONNECT_EYE:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Eye_Disconnected", NULL ) );
|
||||
break;
|
||||
|
||||
case SCENE_CONNECT_CONTROLLER:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Activate_Move", NULL ) );
|
||||
break;
|
||||
|
||||
case SCENE_CALIBRATE_CONTROLLER:
|
||||
if ( inputsystem->GetMotionControllerDeviceStatus() == INPUT_DEVICE_MC_STATE_CONTROLLER_CALIBRATING )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Calibrating", NULL ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Hold_the_Motion", NULL ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCENE_CALIBRATE_CONTROLLER_RESULT:
|
||||
{
|
||||
#if defined( _PS3 )
|
||||
uint64 nCalibrationResult = inputsystem->GetMotionControllerDeviceStatusFlags();
|
||||
|
||||
if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_OCCURRED )
|
||||
{
|
||||
// default nav for warnings
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Accept", NULL ) );
|
||||
|
||||
|
||||
if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_WARNING_BRIGHT_LIGHTING ) // Warning conditions
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Warning_Bright", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_WARNING_MOTION_DETECTED )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Warning_Motion", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_VERY_COLORFUL_ENVIRONMENT )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Warning_Colorful", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_CURRENT_HUE_CONFLICTS_WITH_ENVIRONMENT )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Warning_Hue", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_FAILED_CANT_FIND_SPHERE ) // Error conditions
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Error_Cant_Find", NULL ) );
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Error", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_FAILED_MOTION_DETECTED )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Error_Motion", NULL ) );
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Error", NULL ) );
|
||||
}
|
||||
else if ( nCalibrationResult & CELL_GEM_FLAG_CALIBRATION_FAILED_BRIGHT_LIGHTING )
|
||||
{
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Error_Bright", NULL ) );
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Error", NULL ) );
|
||||
}
|
||||
}
|
||||
#endif // defined( _PS3 )
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_TOP_LEFT:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Aim_at_icon", NULL ) );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopLeft, true );
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_BOTTOM_RIGHT:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Aim_at_icon", NULL ) );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomRight, true );
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_BOTTOM_LEFT:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Aim_at_icon", NULL ) );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetBottomLeft, true );
|
||||
break;
|
||||
|
||||
case SCENE_TARGET_TOP_RIGHT:
|
||||
m_pInfoText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Aim_at_icon", NULL ) );
|
||||
m_pScaleformUI->Value_SetVisible( m_pTargetTopRight, true );
|
||||
break;
|
||||
|
||||
case SCENE_ADJUST_SENSITIVITY:
|
||||
if ( !m_bCursorVisible )
|
||||
{
|
||||
#if defined( _PS3 )
|
||||
g_pScaleformUI->PS3ForceCursorStart();
|
||||
#endif
|
||||
g_pScaleformUI->ShowCursor();
|
||||
#if defined( _PS3 )
|
||||
g_pScaleformUI->PS3UseMoveCursor();
|
||||
#endif
|
||||
m_bCursorVisible = true;
|
||||
}
|
||||
|
||||
m_pInfoText->SetVisible( false );
|
||||
m_pScaleformUI->Value_SetVisible( m_pSensitivity, false );
|
||||
m_pNavText->SetTextHTML( g_pScaleformUI->Translate( "#SFUI_Calibrate_Nav_Accept", NULL ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CMotionCalibrationScaleform::TimerCallback( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
SceneThink();
|
||||
}
|
||||
}
|
||||
|
||||
void CMotionCalibrationScaleform::SceneThink( void )
|
||||
{
|
||||
int nSceneStart = m_nSceneLevel;
|
||||
if ( !cl_test_calibration.GetBool() )
|
||||
{
|
||||
switch( inputsystem->GetMotionControllerDeviceStatus() )
|
||||
{
|
||||
case INPUT_DEVICE_MC_STATE_CAMERA_NOT_CONNECTED:
|
||||
m_nSceneLevel = SCENE_CONNECT_EYE;
|
||||
break;
|
||||
|
||||
case INPUT_DEVICE_MC_STATE_CONTROLLER_NOT_CONNECTED:
|
||||
m_nSceneLevel = SCENE_CONNECT_CONTROLLER;
|
||||
break;
|
||||
|
||||
case INPUT_DEVICE_MC_STATE_CONTROLLER_NOT_CALIBRATED:
|
||||
case INPUT_DEVICE_MC_STATE_CONTROLLER_CALIBRATING:
|
||||
m_nSceneLevel = SCENE_CALIBRATE_CONTROLLER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( nSceneStart != m_nSceneLevel )
|
||||
{
|
||||
SceneDraw( m_nSceneLevel );
|
||||
}
|
||||
|
||||
TryAdvance( false, false );
|
||||
|
||||
if ( m_nSceneLevel != SCENE_ADJUST_SENSITIVITY )
|
||||
{
|
||||
if ( m_bCursorVisible )
|
||||
{
|
||||
g_pScaleformUI->HideCursor();
|
||||
m_bCursorVisible = false;
|
||||
|
||||
#if defined( _PS3 )
|
||||
g_pScaleformUI->PS3ForceCursorEnd();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,103 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __MOTION_CALIBRATION_SCALEFORM_H__ )
|
||||
#define __MOTION_CALIBRATION_SCALEFORM_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
enum InputDisplayAngle_t
|
||||
{
|
||||
INPUT_DISPLAY_TOP_LEFT = 0,
|
||||
INPUT_DISPLAY_BOTTOM_RIGHT,
|
||||
|
||||
INPUT_DISPLAY_COUNT,
|
||||
};
|
||||
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
class CMotionCalibrationScaleform : public ScaleformFlashInterface
|
||||
{
|
||||
private:
|
||||
static CMotionCalibrationScaleform *m_pInstance;
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
static bool IsVisible() { return ( m_pInstance != NULL && m_pInstance->m_bVisible ); }
|
||||
|
||||
void OnCancel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnAccept( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void TimerCallback( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
protected:
|
||||
CMotionCalibrationScaleform( );
|
||||
virtual ~CMotionCalibrationScaleform( );
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
bool TryAdvance( bool bAccept, bool bCancel );
|
||||
void SceneAdvance( void );
|
||||
void SceneDraw( int nSceneLevel );
|
||||
void SceneThink( void );
|
||||
|
||||
protected:
|
||||
enum SceneType_t
|
||||
{
|
||||
SCENE_START = 0,
|
||||
SCENE_CONNECT_EYE,
|
||||
SCENE_CONNECT_CONTROLLER,
|
||||
SCENE_CALIBRATE_CONTROLLER,
|
||||
SCENE_CALIBRATE_CONTROLLER_RESULT,
|
||||
SCENE_TARGET_TOP_LEFT,
|
||||
SCENE_TARGET_BOTTOM_RIGHT,
|
||||
SCENE_TARGET_BOTTOM_LEFT,
|
||||
SCENE_TARGET_TOP_RIGHT,
|
||||
|
||||
SCENE_ADJUST_SENSITIVITY,
|
||||
SCENE_END,
|
||||
};
|
||||
|
||||
int m_iSplitScreenSlot; // the splitscreen slot that launched the dialog
|
||||
bool m_bVisible; // Visibility flag
|
||||
bool m_bLoading; // Loading flag
|
||||
|
||||
ISFTextObject * m_pInfoText;
|
||||
ISFTextObject * m_pNavText;
|
||||
SFVALUE m_pTargetTopLeft;
|
||||
SFVALUE m_pTargetBottomLeft;
|
||||
SFVALUE m_pTargetTopRight;
|
||||
SFVALUE m_pTargetBottomRight;
|
||||
SFVALUE m_pSensitivity;
|
||||
|
||||
int m_nSceneLevel;
|
||||
bool m_bCursorVisible;
|
||||
|
||||
//QAngle m_rgDisplayAngles[INPUT_DISPLAY_COUNT];
|
||||
};
|
||||
|
||||
#endif // __MOTION_CALIBRATION_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,358 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include "basepanel.h"
|
||||
#include "options_audio_scaleform.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
#include "c_playerresource.h"
|
||||
#include <vstdlib/vstrtools.h>
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "gameui_util.h"
|
||||
#include "vgui_int.h"
|
||||
#include "materialsystem/materialsystem_config.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "soundsystem/isoundsystem.h"
|
||||
#ifdef _WIN32
|
||||
#include "dsound.h"
|
||||
#endif
|
||||
|
||||
#ifndef _GAMECONSOLE
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
ConVar sys_sound_quality ( "sys_sound_quality", "-1", FCVAR_CHEAT, "Convar used exclusively by the options screen to set sound quality. Changing this convar manually will have no effect." );
|
||||
ConVar sys_voice ( "sys_voice", "-1", FCVAR_NONE, "Convar used exclusively by the options screen to set voice options. Changing this convar manually will have no effect." );
|
||||
extern ConVar windows_speaker_config;
|
||||
|
||||
|
||||
COptionsAudioScaleform::COptionsAudioScaleform()
|
||||
{
|
||||
}
|
||||
|
||||
COptionsAudioScaleform::~COptionsAudioScaleform()
|
||||
{
|
||||
}
|
||||
|
||||
bool COptionsAudioScaleform::InitUniqueWidget(const char * szWidgetID, OptionChoice_t * pOptionChoice)
|
||||
{
|
||||
if (g_pSoundSystem && !V_strcmp(szWidgetID, "Audio Device"))
|
||||
{
|
||||
CUtlVector<audio_device_description_t> devices;
|
||||
g_pSoundSystem->GetAudioDevices(devices);
|
||||
|
||||
for (int i = 0; i != devices.Count(); ++i)
|
||||
{
|
||||
audio_device_description_t& desc = devices[i];
|
||||
|
||||
int nChoice = pOptionChoice->m_Choices.AddToTail();
|
||||
OptionChoiceData_t * pNewOptionChoice = &(pOptionChoice->m_Choices[nChoice]);
|
||||
|
||||
char buf[sizeof(pNewOptionChoice->m_wszLabel) / sizeof(*pNewOptionChoice->m_wszLabel)];
|
||||
V_strncpy(buf, desc.m_friendlyName, sizeof(buf));
|
||||
|
||||
V_strtowcs(buf, -1, pNewOptionChoice->m_wszLabel, sizeof(pNewOptionChoice->m_wszLabel));
|
||||
V_wcstostr(desc.m_deviceName, -1, pNewOptionChoice->m_szValue, sizeof(pNewOptionChoice->m_szValue));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COptionsAudioScaleform::HandleUpdateChoice( OptionChoice_t * pOptionChoice, int nCurrentChoice )
|
||||
{
|
||||
if ( pOptionChoice &&
|
||||
nCurrentChoice >= 0 &&
|
||||
nCurrentChoice < pOptionChoice->m_Choices.Count() )
|
||||
{
|
||||
pOptionChoice->m_nChoiceIndex = nCurrentChoice;
|
||||
int iConVarSlot = pOptionChoice->m_bSystemValue ? 0 : m_iSplitScreenSlot;
|
||||
|
||||
SplitScreenConVarRef varOption( pOptionChoice->m_szConVar );
|
||||
varOption.SetValue( iConVarSlot, pOptionChoice->m_Choices[nCurrentChoice].m_szValue );
|
||||
|
||||
if ( !V_strcmp( pOptionChoice->m_szConVar, "snd_surround_speakers" ) )
|
||||
{
|
||||
static ConVarRef snd_use_hrtf("snd_use_hrtf");
|
||||
snd_use_hrtf.SetValue(nCurrentChoice == 0 ? 1 : 0);
|
||||
|
||||
UpdateEnhanceStereo();
|
||||
}
|
||||
else if ( !V_strcmp( pOptionChoice->m_szConVar, "sys_sound_quality" ) )
|
||||
{
|
||||
SetSoundQuality( V_atoi( pOptionChoice->m_Choices[nCurrentChoice].m_szValue ) );
|
||||
}
|
||||
else if ( !V_strcmp( pOptionChoice->m_szConVar, "sys_voice" ) )
|
||||
{
|
||||
SetVoiceConfig( V_atoi( pOptionChoice->m_Choices[nCurrentChoice].m_szValue ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void COptionsAudioScaleform::PerformPostLayout()
|
||||
{
|
||||
FindVoiceConfig();
|
||||
}
|
||||
|
||||
|
||||
void COptionsAudioScaleform::SetChoiceWithConVar(OptionChoice_t * pOption, bool bForceDefaultValue)
|
||||
{
|
||||
SF_FORCE_SPLITSCREEN_PLAYER_GUARD(m_iSplitScreenSlot);
|
||||
SplitScreenConVarRef varOption(pOption->m_szConVar);
|
||||
int iConVarSlot = pOption->m_bSystemValue ? 0 : m_iSplitScreenSlot;
|
||||
|
||||
int nResult = -1;
|
||||
|
||||
if (bForceDefaultValue)
|
||||
{
|
||||
varOption.SetValue(iConVarSlot, varOption.GetDefault());
|
||||
}
|
||||
|
||||
if (!V_strcmp(pOption->m_szConVar, "sound_device_override"))
|
||||
{
|
||||
nResult = 2;
|
||||
}
|
||||
else if (!V_strcmp(pOption->m_szConVar, "snd_surround_speakers"))
|
||||
{
|
||||
static ConVarRef snd_use_hrtf("snd_use_hrtf");
|
||||
if (snd_use_hrtf.GetInt() > 0)
|
||||
{
|
||||
nResult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
static ConVarRef windows_speaker_config("windows_speaker_config");
|
||||
|
||||
switch (windows_speaker_config.GetInt())
|
||||
{
|
||||
case DSSPEAKER_HEADPHONE:
|
||||
nResult = 1;
|
||||
break;
|
||||
|
||||
case DSSPEAKER_STEREO:
|
||||
default:
|
||||
nResult = 2;
|
||||
break;
|
||||
|
||||
case DSSPEAKER_QUAD:
|
||||
nResult = 3;
|
||||
break;
|
||||
|
||||
case DSSPEAKER_5POINT1:
|
||||
nResult = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// default to headphones
|
||||
nResult = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if ( !V_strcmp( pOption->m_szConVar, "sys_sound_quality" ) )
|
||||
{
|
||||
nResult = FindSoundQuality();
|
||||
}
|
||||
else if ( !V_strcmp( pOption->m_szConVar, "sys_voice" ) )
|
||||
{
|
||||
nResult = FindVoiceConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
nResult = FindChoiceFromString( pOption, varOption.GetString( iConVarSlot ) );
|
||||
}
|
||||
|
||||
if ( nResult == -1 )
|
||||
{
|
||||
// Unexpected ConVar value, try matching with the default
|
||||
Warning( "ConVar did not match any of the options found in data file: %s\n", pOption->m_szConVar );
|
||||
|
||||
nResult = FindChoiceFromString( pOption, varOption.GetDefault() );
|
||||
|
||||
if ( nResult == -1 )
|
||||
{
|
||||
// Completely unexpected ConVar value. Display whatever choice is at the zero index so that
|
||||
// the client does not draw undefined characters
|
||||
Assert( false );
|
||||
Warning( "ConVar default not match any of the options found in data file: %s\n", pOption->m_szConVar );
|
||||
|
||||
nResult = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pOption->m_nChoiceIndex = nResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int COptionsAudioScaleform::FindVoiceConfig( void )
|
||||
{
|
||||
SF_FORCE_SPLITSCREEN_PLAYER_GUARD( m_iSplitScreenSlot );
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
SplitScreenConVarRef voice_modenable( "voice_modenable" );
|
||||
SplitScreenConVarRef voice_enable( "voice_enable" );
|
||||
// TODO: we're cutting open mic for now
|
||||
SplitScreenConVarRef voice_vox( "voice_vox" );
|
||||
|
||||
bool bVoiceEnabled = voice_enable.GetBool( m_iSplitScreenSlot ) && voice_modenable.GetBool( m_iSplitScreenSlot );
|
||||
|
||||
if ( !bVoiceEnabled )
|
||||
{
|
||||
//disabled
|
||||
nResult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// push to talk
|
||||
nResult = 1;
|
||||
}
|
||||
|
||||
// Update navigation
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "RefreshAudioNav", 0, NULL );
|
||||
}
|
||||
|
||||
return nResult;
|
||||
}
|
||||
|
||||
void COptionsAudioScaleform::SetVoiceConfig( int nIndex )
|
||||
{
|
||||
SF_FORCE_SPLITSCREEN_PLAYER_GUARD( m_iSplitScreenSlot );
|
||||
|
||||
SplitScreenConVarRef voice_modenable( "voice_modenable" );
|
||||
SplitScreenConVarRef voice_enable( "voice_enable" );
|
||||
//TODO: Open mic doesn't work. We're chosing to disable it instead of fix.
|
||||
SplitScreenConVarRef voice_vox( "voice_vox" );
|
||||
|
||||
switch ( nIndex )
|
||||
{
|
||||
case 0: // disabled
|
||||
voice_modenable.SetValue( m_iSplitScreenSlot, 0 );
|
||||
voice_enable.SetValue( m_iSplitScreenSlot, 0 );
|
||||
voice_vox.SetValue( m_iSplitScreenSlot, 0 );
|
||||
break;
|
||||
|
||||
case 1: // push to talk
|
||||
voice_modenable.SetValue( m_iSplitScreenSlot, 1 );
|
||||
voice_enable.SetValue( m_iSplitScreenSlot, 1 );
|
||||
voice_vox.SetValue( m_iSplitScreenSlot, 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
AssertMsg( false, "SetVoiceConfig index out of range." );
|
||||
break;
|
||||
}
|
||||
|
||||
// Update navigation
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "RefreshAudioNav", 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int COptionsAudioScaleform::FindSoundQuality( void )
|
||||
{
|
||||
SplitScreenConVarRef Snd_PitchQuality( "Snd_PitchQuality" );
|
||||
SplitScreenConVarRef dsp_slow_cpu( "dsp_slow_cpu" );
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
if ( !dsp_slow_cpu.GetBool( 0 ) )
|
||||
{
|
||||
nResult = 1;
|
||||
}
|
||||
if ( Snd_PitchQuality.GetBool( 0 ) )
|
||||
{
|
||||
nResult = 2;
|
||||
|
||||
}
|
||||
return nResult;
|
||||
}
|
||||
|
||||
|
||||
void COptionsAudioScaleform::SetSoundQuality( int nIndex )
|
||||
{
|
||||
SplitScreenConVarRef Snd_PitchQuality( "Snd_PitchQuality" );
|
||||
SplitScreenConVarRef dsp_slow_cpu( "dsp_slow_cpu" );
|
||||
|
||||
switch( nIndex )
|
||||
{
|
||||
case 0: // low quality
|
||||
dsp_slow_cpu.SetValue( 0, true );
|
||||
Snd_PitchQuality.SetValue( 0, false );
|
||||
break;
|
||||
|
||||
case 1: // medium quality
|
||||
dsp_slow_cpu.SetValue( 0, false );
|
||||
Snd_PitchQuality.SetValue( 0, false );
|
||||
break;
|
||||
|
||||
case 2: // high quality
|
||||
dsp_slow_cpu.SetValue( 0, false );
|
||||
Snd_PitchQuality.SetValue( 0, true );
|
||||
break;
|
||||
|
||||
default:
|
||||
AssertMsg( false, "SetSoundQuality index out of range" );
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateEnhanceStereo();
|
||||
}
|
||||
|
||||
|
||||
void COptionsAudioScaleform::UpdateEnhanceStereo()
|
||||
{
|
||||
// headphones at high quality get enhanced stereo turned on
|
||||
SplitScreenConVarRef Snd_PitchQuality( "Snd_PitchQuality" );
|
||||
SplitScreenConVarRef dsp_slow_cpu( "dsp_slow_cpu" );
|
||||
SplitScreenConVarRef snd_surround_speakers("Snd_Surround_Speakers");
|
||||
SplitScreenConVarRef dsp_enhance_stereo( "dsp_enhance_stereo" );
|
||||
|
||||
if ( !dsp_slow_cpu.GetBool( 0 ) && Snd_PitchQuality.GetBool( 0 ) && snd_surround_speakers.GetInt( 0 ) == 0 )
|
||||
{
|
||||
#ifdef CSTRIKE15
|
||||
dsp_enhance_stereo.SetValue( 0, 0 );
|
||||
#else
|
||||
dsp_enhance_stereo.SetValue( 0, 1 );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
dsp_enhance_stereo.SetValue( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,57 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __OPTIONS_AUDIO_SCALEFORM_H__ )
|
||||
#define __OPTIONS_AUDIO_SCALEFORM_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "options_scaleform.h"
|
||||
|
||||
class COptionsAudioScaleform : public COptionsScaleform
|
||||
{
|
||||
public:
|
||||
COptionsAudioScaleform( );
|
||||
virtual ~COptionsAudioScaleform( );
|
||||
|
||||
// CGameEventListener callback
|
||||
virtual void FireGameEvent( IGameEvent *event ) { }
|
||||
|
||||
protected:
|
||||
// For Dialog specific updates to choice widgets
|
||||
virtual bool HandleUpdateChoice( OptionChoice_t * pOptionChoice, int nCurrentChoice );
|
||||
|
||||
// Sets the option to whatever the current ConVar value
|
||||
// bForceDefaultValue signals that unique algorithms should be used to select the value
|
||||
virtual void SetChoiceWithConVar( OptionChoice_t * pOption, bool bForceDefaultValue = false );
|
||||
|
||||
// Determine whether enhanced stereo should be turned on (for headphones at high sound quality)
|
||||
void UpdateEnhanceStereo( void );
|
||||
|
||||
// Returns sys_sound_quality dsp_slow_cpu and Snd_PitchQuality
|
||||
int FindSoundQuality( void );
|
||||
|
||||
// Sets dsp_slow_cpu and Snd_PitchQuality
|
||||
void SetSoundQuality( int nIndex );
|
||||
|
||||
void SetVoiceConfig( int nIndex );
|
||||
|
||||
int FindVoiceConfig( void );
|
||||
|
||||
virtual void PerformPostLayout( void );
|
||||
|
||||
bool InitUniqueWidget(const char * szWidgetID, OptionChoice_t * pOptionChoice);
|
||||
};
|
||||
|
||||
#endif // __OPTIONS_AUDIO_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,342 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __OPTIONS_SCALEFORM_H__ )
|
||||
#define __OPTIONS_SCALEFORM_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
#define SF_OPTIONS_MAX 64
|
||||
#define SF_OPTIONS_TOOLTIP_MAX 1024
|
||||
#define SF_OPTIONS_SLOTS_COUNT 20
|
||||
#define SF_OPTIONS_SLOTS_COUNT_MAX 60
|
||||
|
||||
typedef ScaleformFlashInterfaceMixin<CGameEventListener> CControlsFlashBaseClass;
|
||||
|
||||
class COptionsScaleform : public CControlsFlashBaseClass, public IMessageBoxEventCallback, public IMatchEventsSink
|
||||
{
|
||||
private:
|
||||
static COptionsScaleform *m_pInstanceOptions;
|
||||
|
||||
public:
|
||||
enum DialogType_e
|
||||
{
|
||||
// must match action script MainUI.OptionsDialog.Options DIALOG_MODE_X
|
||||
DIALOG_TYPE_NONE = -1,
|
||||
DIALOG_TYPE_MOUSE,
|
||||
DIALOG_TYPE_KEYBOARD = DIALOG_TYPE_MOUSE,
|
||||
DIALOG_TYPE_CONTROLLER,
|
||||
DIALOG_TYPE_SETTINGS,
|
||||
DIALOG_TYPE_MOTION_CONTROLLER,
|
||||
DIALOG_TYPE_MOTION_CONTROLLER_MOVE,
|
||||
DIALOG_TYPE_MOTION_CONTROLLER_SHARPSHOOTER,
|
||||
DIALOG_TYPE_VIDEO,
|
||||
DIALOG_TYPE_VIDEO_ADVANCED,
|
||||
DIALOG_TYPE_AUDIO,
|
||||
DIALOG_TYPE_SCREENSIZE,
|
||||
|
||||
DIALOG_TYPE_COUNT
|
||||
};
|
||||
|
||||
struct DialogQueue_t
|
||||
{
|
||||
DialogQueue_t()
|
||||
{
|
||||
m_Type = DIALOG_TYPE_NONE;
|
||||
m_strMessage.Clear();
|
||||
}
|
||||
|
||||
DialogType_e m_Type;
|
||||
CUtlString m_strMessage; // Any special message that should be passed to the queued dialog
|
||||
};
|
||||
|
||||
enum NoticeType_e
|
||||
{
|
||||
NOTICE_TYPE_NONE = -1,
|
||||
NOTICE_TYPE_RESET_TO_DEFAULT,
|
||||
NOTICE_TYPE_DISCARD_CHANGES,
|
||||
NOTICE_TYPE_INFO
|
||||
};
|
||||
|
||||
enum OptionType_e
|
||||
{
|
||||
OPTION_TYPE_SLIDER = 0,
|
||||
OPTION_TYPE_CHOICE,
|
||||
OPTION_TYPE_DROPDOWN,
|
||||
OPTION_TYPE_BIND,
|
||||
OPTION_TYPE_BIND_KEYBOARD,
|
||||
OPTION_TYPE_CATEGORY,
|
||||
|
||||
OPTION_TYPE_TOTAL
|
||||
};
|
||||
|
||||
struct Option_t
|
||||
{
|
||||
Option_t()
|
||||
{
|
||||
m_Type = OPTION_TYPE_TOTAL;
|
||||
m_nPriority = 0;
|
||||
m_nWidgetSlotID = 0;
|
||||
|
||||
V_memset( m_wcLabel, 0, sizeof( m_wcLabel ) );
|
||||
V_memset( m_wcTooltip, 0, sizeof( m_wcTooltip ) );
|
||||
V_memset( m_szConVar, 0, sizeof( m_szConVar ) );
|
||||
}
|
||||
|
||||
virtual ~Option_t() {}
|
||||
|
||||
OptionType_e m_Type; // The type of option
|
||||
int m_nWidgetSlotID; // Widget slot this option occupies
|
||||
int m_nPriority; // Display order
|
||||
bool m_bSystemValue; // Ignore split screen # when setting this
|
||||
bool m_bRefreshInventoryIconsWhenIncreased; // Only works with advanced video options right now!
|
||||
wchar_t m_wcLabel[ SF_OPTIONS_MAX ]; // Display label
|
||||
wchar_t m_wcTooltip[SF_OPTIONS_TOOLTIP_MAX]; // Tooltip label
|
||||
|
||||
char m_szConVar[ SF_OPTIONS_MAX ]; // ConVar (if any) the option is bound to
|
||||
};
|
||||
|
||||
struct OptionChoiceData_t
|
||||
{
|
||||
wchar_t m_wszLabel[ SF_OPTIONS_MAX ];
|
||||
char m_szValue[ SF_OPTIONS_MAX ];
|
||||
};
|
||||
|
||||
enum BindCommands_e
|
||||
{
|
||||
BIND_CMD_BIND = 0, // binds the last pressed key to the command
|
||||
BIND_CMD_CLEAR, // unbinds the command
|
||||
|
||||
BIND_CMD_TOTAL
|
||||
};
|
||||
|
||||
struct OptionBind_t : public Option_t
|
||||
{
|
||||
OptionBind_t()
|
||||
{
|
||||
V_memset( m_szCommand, 0, sizeof( m_szCommand ) );
|
||||
}
|
||||
|
||||
char m_szCommand[ SF_OPTIONS_MAX ]; // Command the option is bound to
|
||||
};
|
||||
|
||||
struct OptionChoice_t : public Option_t
|
||||
{
|
||||
OptionChoice_t()
|
||||
{
|
||||
m_nChoiceIndex = -1;
|
||||
}
|
||||
|
||||
int m_nChoiceIndex; // Index of currently selected choice
|
||||
CUtlVector<OptionChoiceData_t> m_Choices; // Available choices for choice widgets
|
||||
};
|
||||
|
||||
struct OptionDropdown_t : public Option_t
|
||||
{
|
||||
OptionDropdown_t( )
|
||||
{
|
||||
m_nChoiceIndex = -1;
|
||||
}
|
||||
|
||||
int m_nChoiceIndex; // Index of currently selected choice
|
||||
CUtlVector<OptionChoiceData_t> m_Choices; // Available choices for choice widgets
|
||||
};
|
||||
|
||||
struct OptionSlider_t : public Option_t
|
||||
{
|
||||
OptionSlider_t()
|
||||
{
|
||||
m_fMinValue = 0.0f;
|
||||
m_fMaxValue = 0.0f;
|
||||
m_fSlideValue = 0.0f;
|
||||
m_bLeftMin = true;
|
||||
}
|
||||
|
||||
float m_fMinValue; // Lower bound
|
||||
float m_fMaxValue; // Upper bound
|
||||
float m_fSlideValue; // Current slide value
|
||||
bool m_bLeftMin; // Configures the slider so the far left = m_fMinValue and the far right = m_fMaxValue
|
||||
};
|
||||
|
||||
// Destruction
|
||||
static void UnloadDialog( void );
|
||||
|
||||
/********************************************
|
||||
* IMessageBoxEventCallback implementation
|
||||
*/
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
// IMatchEventSink
|
||||
virtual void OnEvent( KeyValues *kvEvent ) OVERRIDE;
|
||||
|
||||
/************************************
|
||||
* callbacks from scaleform
|
||||
*/
|
||||
void OnCancel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnUpdateValue( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnHighlightWidget( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnLayoutComplete( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnPopulateGlyphRequest( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnClearBind( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
virtual void OnResetToDefaults( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnRequestScroll( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnResizeVertical( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnResizeHorizontal( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSetSizeVertical( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSetSizeHorizontal( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSetNextMenu( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnApplyChanges( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSetupMic( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSaveProfile( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnMCCalibrate( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnRefreshValues( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetTotalOptionsSlots( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetCurrentScrollOffset( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void GetSafeZoneXMin( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
static void ShowMenu( bool bShow, DialogType_e type );
|
||||
static bool IsActive() { return m_pInstanceOptions != NULL; }
|
||||
static bool IsVisible() { return ( m_pInstanceOptions != NULL && m_pInstanceOptions->m_bVisible ); }
|
||||
|
||||
// Notify the current dialog that the Start or Escape key has been pressed
|
||||
static void NotifyStartEvent();
|
||||
|
||||
// CGameEventListener callback
|
||||
virtual void FireGameEvent( IGameEvent *event ) {}
|
||||
|
||||
static bool IsBindMenuRaised( void );
|
||||
|
||||
|
||||
protected:
|
||||
COptionsScaleform( );
|
||||
virtual ~COptionsScaleform( );
|
||||
|
||||
// Construction
|
||||
static void LoadDialog( DialogType_e type );
|
||||
|
||||
static int GetDeviceFromDialogType( DialogType_e eDialogType );
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
|
||||
// fills a choice vector with clan tag labels
|
||||
void BuildClanTagsLabels( CUtlVector<OptionChoiceData_t> &choices );
|
||||
|
||||
// Reads in data that drives the dialog layout and functionality
|
||||
void ReadOptionsFromFile( const char * szFileName );
|
||||
|
||||
// Reads options from m_vecOptions and attaches relevant label and widget to the dialog
|
||||
// beginning at nVecOptionsOffset.
|
||||
void LayoutDialog( const int nVecOptionsOffset, const bool bInit = true );
|
||||
|
||||
// Updates the widget at nWidgetIndex with the data from option
|
||||
void UpdateWidget( const int nWidgetIndex, Option_t const * const option );
|
||||
|
||||
// Sets the option to whatever the current ConVar value
|
||||
// bForceDefaultValue signals that unique algorithms should be used to select the value
|
||||
virtual void SetChoiceWithConVar( OptionChoice_t * pOption, bool bForceDefaultValue = false );
|
||||
|
||||
// Sets the option to whatever the current ConVar value
|
||||
void SetSliderWithConVar( OptionSlider_t * pOption );
|
||||
|
||||
// Returns true if the two passed in actions are identical
|
||||
bool ActionsAreTheSame( const char *szAction1, const char *szAction2 );
|
||||
|
||||
// Resets all options and binds to their default values
|
||||
virtual void ResetToDefaults( void );
|
||||
|
||||
// Unbind the action associated with the option from its key
|
||||
void UnbindOption( OptionBind_t const * const pOptionBind );
|
||||
|
||||
// Notify the current dialog that the Start or Escape key has been pressed
|
||||
void OnNotifyStartEvent( void );
|
||||
|
||||
// Returns the choice ID that matches szMatch
|
||||
int FindChoiceFromString( OptionChoice_t * pOption, const char * szMatch );
|
||||
|
||||
// Applues change to a system convar (SplitScreenConVarRef slot 0)
|
||||
void ApplyChangesToSystemConVar( const char *pConVarName, int value );
|
||||
|
||||
// saves out profile, restarts renderer etc
|
||||
void SaveChanges( void );
|
||||
|
||||
// Invoked before changes are saved
|
||||
virtual void PreSaveChanges( void ) {}
|
||||
|
||||
// returns true if supplied convar contains "_restart", outputs split ConVar
|
||||
bool SplitRestartConvar( const char * szConVarRestartIn, char * szConVarOut, int nOutLength );
|
||||
|
||||
// Initializes widgets that require unique config steps (filling the resolution widget etc.)
|
||||
virtual bool InitUniqueWidget( const char * szWidgetID, OptionChoice_t * pOptionChoice );
|
||||
|
||||
|
||||
void DisableConditionalWidgets();
|
||||
|
||||
// Disable widgets based on current state (brightness not available in windowed mode, etc)
|
||||
virtual void HandleDisableConditionalWidgets( Option_t * pOption, int & nWidgetIDOut, bool & bDisableOut );
|
||||
|
||||
bool UpdateValue( int nWidgetIndex, int nValue );
|
||||
|
||||
// For Dialog specific updates to choice widgets
|
||||
virtual bool HandleUpdateChoice( OptionChoice_t * pOptionChoice, int nCurrentChoice );
|
||||
|
||||
// Called after the dialog has successfully refreshed its widgets
|
||||
virtual void PerformPostLayout( void );
|
||||
|
||||
// Refreshes all widgets, then redraws dialog
|
||||
void RefreshValues( bool bForceDefault );
|
||||
|
||||
// Save the values to the user's profile
|
||||
void WriteUserSettings( int iSplitScreenSlot );
|
||||
|
||||
static bool IsMotionControllerDialog( void );
|
||||
|
||||
protected:
|
||||
static DialogType_e m_DialogType; // The current dialog
|
||||
|
||||
static CUtlString m_strMessage; // Special behavior message
|
||||
|
||||
CMessageBoxScaleform* m_pConfirmDialog; // Reset to default dialog
|
||||
int m_iSplitScreenSlot; // the splitscreen slot that launched the dialog
|
||||
|
||||
bool m_bVisible; // Visibility flag
|
||||
bool m_bLoading; // Loading flag
|
||||
bool m_bNavButtonsEnabled; // true when both nav buttons are enabled
|
||||
bool m_bOptionsChanged; // Flag set when options are changed and need to be saved
|
||||
bool m_bResetRequired; // Flag set when options are changed that require the renderer to be reset
|
||||
NoticeType_e m_NoticeType; // The active message box notice
|
||||
|
||||
int m_nScrollPos; // Index of topmost visible element
|
||||
CUtlVector<Option_t *> m_vecOptions; // Vector of the options, sorted by order of display
|
||||
|
||||
Option_t * m_rgOptionsBySlot[ SF_OPTIONS_SLOTS_COUNT_MAX ]; // Pointer to the option assigned to a specified slot
|
||||
ISFTextObject * m_rgTextBySlot[ SF_OPTIONS_SLOTS_COUNT_MAX ]; // Pointer to the text label for each slot
|
||||
|
||||
static CUtlQueue<DialogQueue_t> m_DialogQueue; // Dialogs to be popped and displayed after the current dialog has been destroyed
|
||||
|
||||
SFVALUE m_pDeadZonePanel;
|
||||
};
|
||||
|
||||
#endif // __OPTIONS_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __OPTIONS_VIDEO_SCALEFORM_H__ )
|
||||
#define __OPTIONS_VIDEO_SCALEFORM_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "options_scaleform.h"
|
||||
|
||||
|
||||
class COptionsVideoScaleform : public COptionsScaleform
|
||||
{
|
||||
public:
|
||||
struct AAMode_t
|
||||
{
|
||||
int m_nNumSamples;
|
||||
int m_nQualityLevel;
|
||||
|
||||
AAMode_t()
|
||||
{
|
||||
m_nNumSamples = 0;
|
||||
m_nQualityLevel = 0;
|
||||
}
|
||||
|
||||
inline bool operator==( const AAMode_t& in ) const
|
||||
{
|
||||
return ( m_nNumSamples == in.m_nNumSamples ) && ( m_nQualityLevel == in.m_nQualityLevel );
|
||||
}
|
||||
};
|
||||
|
||||
struct ResolutionModes_t
|
||||
{
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
|
||||
ResolutionModes_t()
|
||||
{
|
||||
m_nWidth = 0;
|
||||
m_nHeight = 0;
|
||||
}
|
||||
|
||||
inline bool operator==( const ResolutionModes_t& in ) const
|
||||
{
|
||||
return ( m_nWidth == in.m_nWidth ) && ( m_nHeight == in.m_nHeight );
|
||||
}
|
||||
};
|
||||
|
||||
struct AspectModes_t
|
||||
{
|
||||
CUtlVector<ResolutionModes_t> m_vecResolutionModes; // The resolution modes compatible with this aspect ratio
|
||||
};
|
||||
|
||||
COptionsVideoScaleform( );
|
||||
virtual ~COptionsVideoScaleform( );
|
||||
|
||||
|
||||
// IMessageBoxEventCallback implementation
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
protected:
|
||||
virtual bool HandleUpdateChoice( OptionChoice_t * pChoice, int nCurrentChoice );
|
||||
|
||||
// Sets the option to whatever the current ConVar value
|
||||
// bForceDefaultValue signals that unique algorithms should be used to select the value
|
||||
virtual void SetChoiceWithConVar( OptionChoice_t * pOption, bool bForceDefaultValue = false );
|
||||
|
||||
// Resets all options and binds to their default values
|
||||
virtual void ResetToDefaults( void );
|
||||
|
||||
// Fills m_vecAAModes with supported AA modes
|
||||
void BuildAAModes( CUtlVector<OptionChoiceData_t> &choices );
|
||||
|
||||
// Returns sys_antialiasing matching provided values
|
||||
int FindAAMode( int nAASamples, int nAAQuality );
|
||||
|
||||
// Sets mat_antialias and mat_aaquality
|
||||
void SetAAMode( int nIndex );
|
||||
|
||||
// Returns sys_refldetail r_waterforceexpensive and r_waterforcereflectentities
|
||||
int FindReflection( void );
|
||||
|
||||
// Sets r_waterforceexpensive and r_waterforcereflectentities
|
||||
void SetReflection( int nIndex );
|
||||
|
||||
// Returns sys_vsync assigned to provided values
|
||||
int FindVSync( bool bVsync, bool bTrippleBuffered );
|
||||
|
||||
// Sets mat_vsync and mat_triplebuffered
|
||||
void SetVSync( int nIndex );
|
||||
|
||||
// fills m_vecAspectModes with compatible resolutions for each aspect mode
|
||||
void GenerateCompatibleResolutions( void );
|
||||
|
||||
// fills m_vecAspectModes with compatible windowed resolutions for each aspect mode
|
||||
void GenerateWindowedModes( CUtlVector< vmode_t > &windowedModes, int nCount, vmode_t *pFullscreenModes );
|
||||
|
||||
// fills a choice vector with resolution options for the currently selected aspect mode (m_nSelectedAspect)
|
||||
void BuildResolutionModes( CUtlVector<OptionChoiceData_t> &choices );
|
||||
|
||||
// converts the resolution value to a string
|
||||
void GetResolutionName( int nWidth, int nHeight, char *pOutBuffer, int nOutBufferLength );
|
||||
|
||||
// returns appropriate aspect code for supplied resolution
|
||||
int GetScreenAspectRatio( int width, int height );
|
||||
|
||||
// returns an aspect code for the current resolution
|
||||
int FindCurrentAspectRatio();
|
||||
|
||||
// returns the current resolution
|
||||
const ResolutionModes_t FindCurrentResolution( void );
|
||||
|
||||
// returns true if currently in full screen windowed mode
|
||||
bool FullScreenWindowMode( void );
|
||||
|
||||
// changes the aspect ratio widget selection and fills m_pResolutionWidget with resolutions
|
||||
// appropriate for the selected aspect ratio
|
||||
void SelectAspectRatio( int nSelection );
|
||||
|
||||
void SelectResolution( void );
|
||||
|
||||
// if true then a warning dialog should be displayed before allowing this option to be changed
|
||||
bool ShowWarning( const char * szConVar );
|
||||
|
||||
virtual void PreSaveChanges( void );
|
||||
|
||||
// Disable widgets based on current state (brightness not available in windowed mode, etc)
|
||||
virtual void HandleDisableConditionalWidgets( Option_t * pOption, int & nWidgetIDOut, bool & bDisableOut );
|
||||
|
||||
virtual bool InitUniqueWidget( const char * szWidgetID, OptionChoice_t * pOptionChoice );
|
||||
|
||||
protected:
|
||||
CUtlVector<AAMode_t> m_vecAAModes; // List of AA modes supported by device
|
||||
CUtlVector<AspectModes_t> m_vecAspectModes; // List of aspect modes and their compatible resolutions
|
||||
|
||||
OptionChoice_t * m_pResolutionWidget; // Pointer to the resolution widget
|
||||
int m_nSelectedAspect; // ID of currently selected aspect ratio
|
||||
};
|
||||
|
||||
#endif // __OPTIONS_VIDEO_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,98 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "overwatchresolution_scaleform.h"
|
||||
#include "game/client/iviewport.h"
|
||||
#include "basepanel.h"
|
||||
#include "iclientmode.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
SFHudOverwatchResolutionPanel* SFHudOverwatchResolutionPanel::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD( HideFromScript ),
|
||||
SFUI_END_GAME_API_DEF( SFHudOverwatchResolutionPanel, OverwatchResolution );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
SFHudOverwatchResolutionPanel::SFHudOverwatchResolutionPanel()
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
}
|
||||
|
||||
SFHudOverwatchResolutionPanel::~SFHudOverwatchResolutionPanel()
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
/* Removed for partner depot */
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new SFHudOverwatchResolutionPanel();
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, SFHudOverwatchResolutionPanel, m_pInstance, OverwatchResolution );
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::UnloadDialog( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
m_pInstance->RemoveFlashElement();
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::PostUnloadFlash( void )
|
||||
{
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::FlashReady( void )
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::Show()
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", NULL, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::Hide( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", 0, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFHudOverwatchResolutionPanel::HideFromScript( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
UnloadDialog();
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,47 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SFOVERWATCHRESOLUTIONPANEL_H
|
||||
#define SFOVERWATCHRESOLUTIONPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif //_WIN32
|
||||
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "game/client/iviewport.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
|
||||
class SFHudOverwatchResolutionPanel : public ScaleformFlashInterface, public IMatchEventsSink
|
||||
{
|
||||
protected:
|
||||
static SFHudOverwatchResolutionPanel *m_pInstance;
|
||||
|
||||
SFHudOverwatchResolutionPanel();
|
||||
~SFHudOverwatchResolutionPanel();
|
||||
|
||||
//
|
||||
// IMatchEventsSink
|
||||
//
|
||||
public:
|
||||
virtual void OnEvent( KeyValues *pEvent ) OVERRIDE;
|
||||
|
||||
public:
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
static SFHudOverwatchResolutionPanel * GetInstance() { return m_pInstance; }
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void HideFromScript( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
void Show( void );
|
||||
void Hide( void );
|
||||
};
|
||||
|
||||
#endif // SFOVERWATCHRESOLUTIONPANEL_H
|
||||
@@ -0,0 +1,446 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: [jpaquin] The "Player Two press start" widget
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "splitscreensignon.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "../engine/filesystem_engine.h"
|
||||
|
||||
#if defined( _X360 )
|
||||
#include "xbox/xbox_launch.h"
|
||||
#else
|
||||
#include "xbox/xboxstubs.h"
|
||||
#endif
|
||||
|
||||
#if defined ( _PS3 )
|
||||
#include <sysutil/sysutil_userinfo.h>
|
||||
#endif
|
||||
|
||||
#include "engineinterface.h"
|
||||
#include "modinfo.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "filesystem.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// for SRC
|
||||
#include <vstdlib/random.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_END_GAME_API_DEF( SplitScreenSignonWidget, SplitScreenSignon );
|
||||
|
||||
#if defined ( _PS3 )
|
||||
static CellUserInfoTypeSet s_CellTypeSet;
|
||||
static bool s_bUserSelectFinished = true;
|
||||
static CellUserInfoUserStat s_CellUserSelected;
|
||||
static int s_iUserSelectResult;
|
||||
static void UserSelectFinishCallback(int result, CellUserInfoUserStat* pSelectUser, void* userdata)
|
||||
{
|
||||
s_iUserSelectResult = result;
|
||||
if(result == CELL_USERINFO_RET_OK)
|
||||
{
|
||||
memcpy(&s_CellUserSelected, pSelectUser, sizeof(s_CellUserSelected));
|
||||
}
|
||||
s_bUserSelectFinished = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SplitScreenSignonWidget::SplitScreenSignonWidget() :
|
||||
m_bVisible( false ),
|
||||
m_bConditionsAreValid( false ),
|
||||
m_bLoading( false ),
|
||||
m_bWantShown( false ),
|
||||
m_pPlayer2Name( NULL ),
|
||||
m_bWaitingForSignon( false ),
|
||||
m_iSecondPlayerId( -1 ),
|
||||
m_iControllerThatPressedStart( -1 ),
|
||||
m_bCurrentlyProcessingSignin( false ),
|
||||
m_bDropSecondPlayer( false )
|
||||
{
|
||||
ListenForGameEvent( "sfuievent" );
|
||||
#ifdef _PS3
|
||||
s_CellTypeSet.title = "Select Player 2 user";
|
||||
s_CellTypeSet.focus = CELL_USERINFO_FOCUS_LISTHEAD;
|
||||
s_CellTypeSet.type = CELL_USERINFO_LISTTYPE_NOCURRENT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::FlashReady( void )
|
||||
{
|
||||
m_bLoading = false;
|
||||
// Setup subscription so we are notified when the user signs in
|
||||
g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
|
||||
( m_bVisible ) ? OnShow() : OnHide();
|
||||
}
|
||||
|
||||
bool SplitScreenSignonWidget::PreUnloadFlash( void )
|
||||
{
|
||||
// Remember to unsubscribe so we don't crash later!
|
||||
StopListeningForAllEvents();
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SplitScreenSignonWidget::OnShow( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "showPanel", 0, NULL );
|
||||
}
|
||||
}
|
||||
else if ( !m_bLoading )
|
||||
{
|
||||
m_bLoading = true;
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, SplitScreenSignonWidget, this, SplitScreenSignon );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::OnHide( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
ScaleformUI()->Value_InvokeWithoutReturn( m_FlashAPI, "hidePanel", 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::UpdateState( void )
|
||||
{
|
||||
bool showit = ( m_bConditionsAreValid && m_bWantShown );
|
||||
|
||||
if ( showit != m_bVisible )
|
||||
showit ? OnShow() : OnHide();
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::Show( bool showit )
|
||||
{
|
||||
if ( showit != m_bWantShown )
|
||||
{
|
||||
m_bWantShown = showit;
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::SplitScreenConditionsAreValid( bool value )
|
||||
{
|
||||
if ( value != m_bConditionsAreValid )
|
||||
{
|
||||
m_bConditionsAreValid = value;
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::Update( void )
|
||||
{
|
||||
#if defined( _GAMECONSOLE )
|
||||
SplitScreenConditionsAreValid( g_pInputSystem->GetJoystickCount() > 1 );
|
||||
|
||||
if ( m_bVisible )
|
||||
{
|
||||
|
||||
#ifdef _PS3
|
||||
g_pInputSystem->SetPS3StartButtonIdentificationMode();
|
||||
#endif
|
||||
|
||||
int iUserPressingStart = -1;
|
||||
int iPrimary = XBX_GetUserId( 0 );
|
||||
|
||||
if ( XBX_GetNumGameUsers() == 1 )
|
||||
{
|
||||
if ( m_iControllerThatPressedStart == -1 )
|
||||
{
|
||||
for ( int i = 0; i < XUSER_MAX_COUNT && ( iUserPressingStart == -1 ) ; i++ )
|
||||
{
|
||||
if ( i != iPrimary )
|
||||
{
|
||||
if ( g_pInputSystem->IsButtonDown( ButtonCodeToJoystickButtonCode( KEY_XBUTTON_INACTIVE_START, i ) ) )
|
||||
{
|
||||
iUserPressingStart = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( iUserPressingStart != -1 )
|
||||
{
|
||||
m_iControllerThatPressedStart = iUserPressingStart;
|
||||
m_bWaitingForSignon = true;
|
||||
#if defined( _X360 )
|
||||
xboxsystem->ShowSigninUI( 2, XSSUI_FLAGS_LOCALSIGNINONLY ); // Two user, no special flags
|
||||
#elif defined ( _PS3 )
|
||||
if(s_bUserSelectFinished) // Prevent cellUserInfoSelectUser_ListType being called more than once
|
||||
{
|
||||
s_bUserSelectFinished = false;
|
||||
cellUserInfoEnableOverlay(1); // Dim background while showing user selection dialog
|
||||
cellUserInfoSelectUser_ListType(&s_CellTypeSet, UserSelectFinishCallback, SYS_MEMORY_CONTAINER_ID_INVALID, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef _PS3
|
||||
if(m_bWaitingForSignon && s_bUserSelectFinished)
|
||||
{
|
||||
m_bWaitingForSignon = false;
|
||||
if(s_iUserSelectResult == CELL_USERINFO_RET_OK)
|
||||
{
|
||||
|
||||
int userID = s_CellUserSelected.id;
|
||||
|
||||
if ( userID != -1 )
|
||||
{
|
||||
SetPlayerSignedIn();
|
||||
SetPlayer2Name( s_CellUserSelected.name );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iControllerThatPressedStart = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iControllerThatPressedStart = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if ( ( XBX_GetNumGameUsers() == 2 ) )
|
||||
{
|
||||
if(g_pInputSystem->IsButtonDown( ButtonCodeToJoystickButtonCode( KEY_XBUTTON_START, 1 ) ))
|
||||
{
|
||||
m_bDropSecondPlayer = true;
|
||||
}
|
||||
else if(m_bDropSecondPlayer)
|
||||
{
|
||||
// Wait for start button to be released before dropping
|
||||
// otherwise release event gets converted to KEY_XBUTTON_INACTIVE_START on PS3
|
||||
m_bDropSecondPlayer = false;
|
||||
DropSecondPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::SetPlayerSignedIn( void )
|
||||
{
|
||||
if ( m_iControllerThatPressedStart == -1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined( _GAMECONSOLE )
|
||||
|
||||
XBX_SetUserId( 1, m_iControllerThatPressedStart );
|
||||
XBX_SetUserIsGuest ( 1, 0 );
|
||||
XBX_SetNumGameUsers ( 2 );
|
||||
#endif
|
||||
m_iSecondPlayerId = m_iControllerThatPressedStart;
|
||||
m_iControllerThatPressedStart = -1;
|
||||
|
||||
g_pMatchFramework->GetEventsSubscription()->BroadcastEvent( new KeyValues( "OnProfilesChanged", "numProfiles", ( int ) XBX_GetNumGameUsers() ) );
|
||||
|
||||
BasePanel()->UpdateRichPresenceInfo();
|
||||
|
||||
ConVarRef ss_enable( "ss_enable" );
|
||||
ss_enable.SetValue( 1 );
|
||||
ConVarRef ss_pipsplit( "ss_pipsplit" );
|
||||
ss_pipsplit.SetValue( 0 );
|
||||
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::SetPlayer2Name( const char* name )
|
||||
{
|
||||
#if defined( _GAMECONSOLE )
|
||||
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
SafeReleaseSFVALUE( m_pPlayer2Name );
|
||||
|
||||
if ( name && *name )
|
||||
{
|
||||
m_pPlayer2Name = CreateFlashString( name );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setPlayer2Name", m_pPlayer2Name, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "clearPlayer2Name", NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::DropSecondPlayer( void )
|
||||
{
|
||||
#if defined( _GAMECONSOLE )
|
||||
XBX_ClearSlot( 1 );
|
||||
XBX_SetNumGameUsers ( 1 );
|
||||
|
||||
RevertUIToOnePlayerMode();
|
||||
|
||||
if ( !m_bCurrentlyProcessingSignin )
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->BroadcastEvent( new KeyValues( "OnProfilesChanged", "numProfiles", ( int ) XBX_GetNumGameUsers() ) );
|
||||
BasePanel()->UpdateRichPresenceInfo();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void SplitScreenSignonWidget::RevertUIToOnePlayerMode( void )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
SetPlayer2Name( NULL );
|
||||
m_iSecondPlayerId = -1;
|
||||
m_bWaitingForSignon = false;
|
||||
ConVarRef ss_enable( "ss_enable" );
|
||||
ss_enable.SetValue( 0 );
|
||||
ConVarRef ss_pipsplit( "ss_pipsplit" );
|
||||
ss_pipsplit.SetValue( 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SplitScreenSignonWidget::FireGameEvent( IGameEvent* pEvent )
|
||||
{
|
||||
char const *szName = pEvent->GetName();
|
||||
|
||||
// Notify that sign-in has completed
|
||||
if ( !V_stricmp( szName, "sfuievent" ) )
|
||||
{
|
||||
const char* action = pEvent->GetString( "action" );
|
||||
const char* data = pEvent->GetString( "data" );
|
||||
|
||||
if ( action && *action )
|
||||
{
|
||||
if ( data && *data )
|
||||
{
|
||||
if ( !V_stricmp( data, "mainmenu" ) || !V_stricmp( data, "creategamedialog" ) )
|
||||
{
|
||||
if ( !V_stricmp( action, "show" ) )
|
||||
{
|
||||
Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Show( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SplitScreenSignonWidget::OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
#if defined( _X360 )
|
||||
|
||||
if ( !m_bCurrentlyProcessingSignin )
|
||||
{
|
||||
m_bCurrentlyProcessingSignin = true;
|
||||
|
||||
char const *szName = pEvent->GetName();
|
||||
|
||||
// Notify that sign-in has completed
|
||||
|
||||
if ( m_bWaitingForSignon )
|
||||
{
|
||||
if ( !V_stricmp( szName, "OnSysSigninChange" ) &&
|
||||
!V_stricmp( "signin", pEvent->GetString( "action", "" ) ) )
|
||||
{
|
||||
m_bWaitingForSignon = false;
|
||||
|
||||
int userID = pEvent->GetInt( "user1", -1 );
|
||||
|
||||
if ( userID != -1 )
|
||||
{
|
||||
SetPlayerSignedIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iControllerThatPressedStart = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( !V_stricmp( szName, "OnSysXUIEvent" ) &&
|
||||
!V_stricmp( "closed", pEvent->GetString( "action", "" ) ) )
|
||||
{
|
||||
m_bWaitingForSignon = false;
|
||||
m_iControllerThatPressedStart = -1;
|
||||
}
|
||||
else if ( !V_stricmp( szName, "OnProfilesChanged" ) )
|
||||
{
|
||||
m_bWaitingForSignon = false;
|
||||
m_iControllerThatPressedStart = -1;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( !V_stricmp( szName, "OnProfilesChanged" ) )
|
||||
{
|
||||
if ( m_iSecondPlayerId != -1)
|
||||
{
|
||||
IPlayerLocal *pProfile = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( m_iSecondPlayerId );
|
||||
|
||||
uint state = XUserGetSigninState( m_iSecondPlayerId );
|
||||
if ( state != eXUserSigninState_NotSignedIn )
|
||||
{
|
||||
if ( pProfile )
|
||||
{
|
||||
SetPlayer2Name( pProfile->GetName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPlayer2Name( "Player2" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DropSecondPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_bCurrentlyProcessingSignin = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
//======= Copyright ( c ) 1996-2009, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Purpose: Definitions that are shared by the game DLL and the client DLL.
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#ifndef SPLITSCREENSIGNON_H
|
||||
#define SPLITSCREENSIGNON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "GameEventListener.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "scaleformui/scaleformui.h"
|
||||
|
||||
|
||||
class SplitScreenSignonWidget : public ScaleformFlashInterfaceMixin<CGameEventListener>, public IMatchEventsSink
|
||||
{
|
||||
public:
|
||||
SplitScreenSignonWidget();
|
||||
|
||||
void FlashReady( void );
|
||||
bool PreUnloadFlash( void );
|
||||
|
||||
|
||||
void OnShow( void );
|
||||
void OnHide( void );
|
||||
|
||||
void Show( bool showit );
|
||||
|
||||
void UpdateState( void );
|
||||
void SplitScreenConditionsAreValid( bool value );
|
||||
void Update( void );
|
||||
|
||||
void DropSecondPlayer( void );
|
||||
void RevertUIToOnePlayerMode( void );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
void SetPlayer2Name( const char* name );
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
void SetPlayerSignedIn( void );
|
||||
|
||||
public:
|
||||
SFVALUE m_pPlayer2Name;
|
||||
int m_iSecondPlayerId;
|
||||
int m_iControllerThatPressedStart;
|
||||
bool m_bVisible;
|
||||
bool m_bLoading;
|
||||
|
||||
bool m_bWantShown;
|
||||
bool m_bConditionsAreValid;
|
||||
bool m_bWaitingForSignon;
|
||||
bool m_bDropSecondPlayer;
|
||||
|
||||
bool m_bCurrentlyProcessingSignin;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SPLITSCREENSIGNON_H
|
||||
|
||||
#endif // include scaleform
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,161 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __TEAMMENU_SCALEFORM_H__ )
|
||||
#define __TEAMMENU_SCALEFORM_H__
|
||||
|
||||
#include "../VGUI/counterstrikeviewport.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
#define TEAM_MENU_MAX_PLAYERS 12
|
||||
|
||||
class CCSTeamMenuScaleform : public ScaleformFlashInterface, public IViewPortPanel, public CGameEventListener
|
||||
{
|
||||
public:
|
||||
explicit CCSTeamMenuScaleform( CounterStrikeViewport* pViewPort );
|
||||
virtual ~CCSTeamMenuScaleform( );
|
||||
|
||||
/************************************
|
||||
* callbacks from scaleform
|
||||
*/
|
||||
|
||||
void OnOk( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnCancel( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnSpectate( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnAutoSelect( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnTimer( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnShowScoreboard( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void UpdateNavText( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnTeamHighlight( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void IsInitialTeamMenu( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void IsQueuedMatchmaking( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
/****************************************
|
||||
* functionality
|
||||
*/
|
||||
|
||||
void RefreshCounts( void );
|
||||
void UpdateSpectatorOption( void );
|
||||
void SetTeamNames( void ); // Use clan names or teamname_1 or 2 convars
|
||||
void UpdateHelpText();
|
||||
void HandleForceSelect( void ); // Updates the force select timer and pushes a player to a team when it expires
|
||||
void UpdateTeamAvatars( void ); // Pushes any changes to team-member avatars to Scaleform
|
||||
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
void Show( void );
|
||||
|
||||
// if bRemove, then remove all elements after hide animation completes
|
||||
void Hide( bool bRemove = false );
|
||||
|
||||
bool PreUnloadFlash( void );
|
||||
|
||||
/*************************************************************
|
||||
* IViewPortPanel interface
|
||||
*/
|
||||
|
||||
virtual const char *GetName( void ) { return PANEL_TEAM; }
|
||||
virtual void SetData( KeyValues *data ) {};
|
||||
|
||||
virtual void Reset( void ) {} // hibernate
|
||||
virtual void Update( void ) {} // updates all ( size, position, content, etc )
|
||||
virtual bool NeedsUpdate( void ) { return false; } // query panel if content needs to be updated
|
||||
virtual bool HasInputElements( void ) { return true; }
|
||||
virtual void ReloadScheme( void ) {}
|
||||
virtual bool CanReplace( const char *panelName ) const { return true; } // returns true if this panel can appear on top of the given panel
|
||||
virtual bool CanBeReopened( void ) const { return true; } // returns true if this panel can be re-opened after being hidden by another panel
|
||||
virtual void ViewportThink( void );
|
||||
|
||||
virtual void ShowPanel( bool state );
|
||||
|
||||
// VGUI functions:
|
||||
virtual vgui::VPANEL GetVPanel( void ) { return 0; } // returns VGUI panel handle
|
||||
virtual bool IsVisible( void ) { return m_bVisible; } // true if panel is visible
|
||||
virtual void SetParent( vgui::VPANEL parent ) {}
|
||||
|
||||
virtual bool WantsBackgroundBlurred( void ) { return false; }
|
||||
|
||||
/********************************************
|
||||
* CGameEventListener methods
|
||||
*/
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
protected:
|
||||
void HandlePostTeamSelect( int team ); // Display post select overlay and wait for pre-match restart stutters to pass
|
||||
void ResetForceSelect( void ); // Reset state's associated with forced team selection
|
||||
|
||||
void StartListeningForEvents( void );
|
||||
void StopListeningForEvents( void );
|
||||
void StartAlwaysListenEvents( void );
|
||||
|
||||
void SetPlayerXuid( bool bIsCT, int index, XUID xuid, const char* pPlayerName, bool bIsLocalPlayer );
|
||||
|
||||
protected:
|
||||
enum MessageBoxClosedAction
|
||||
{
|
||||
NOTHING,
|
||||
DISCONNECT,
|
||||
HIDEPANEL,
|
||||
};
|
||||
|
||||
CounterStrikeViewport* m_pViewPort;
|
||||
ISFTextObject* m_pCTCountHuman;
|
||||
ISFTextObject* m_pCTCountBot;
|
||||
ISFTextObject* m_pTCountHuman;
|
||||
ISFTextObject* m_pTCountBot;
|
||||
ISFTextObject* m_pCTHelpText;
|
||||
ISFTextObject* m_pTHelpText;
|
||||
|
||||
ISFTextObject* m_pNavText;
|
||||
ISFTextObject* m_pTName;
|
||||
ISFTextObject* m_pCTName;
|
||||
ISFTextObject* m_pTimerTextLabel;
|
||||
ISFTextObject* m_pTimerTextGreen;
|
||||
ISFTextObject* m_pTimerTextRed;
|
||||
SFVALUE m_pTimerHandle;
|
||||
MessageBoxClosedAction m_OnClosedAction;
|
||||
int m_iSplitScreenSlot;
|
||||
int m_nCTHumanCount;
|
||||
int m_nTHumanCount;
|
||||
int m_nForceSelectTimeLast; // The value of the timer at the last update
|
||||
bool m_bVisible;
|
||||
bool m_bLoading;
|
||||
bool m_bAllowSpectate;
|
||||
bool m_bPostSelectOverlay; // True when we are waiting for pre-match restart stuttuers to pass
|
||||
bool m_bGreenTimerVisible; // Green timer is shown
|
||||
bool m_bRedTimerVisible; // Red timer is shown
|
||||
bool m_bMatchStart;
|
||||
bool m_bSelectingTeam;
|
||||
|
||||
void JoinTeam( int side );
|
||||
|
||||
enum PLAYER_TEAM_COUNT
|
||||
{
|
||||
MAX_TEAM_SIZE = 12
|
||||
};
|
||||
|
||||
// Save off the Xuids we've pushed to Scaleform, so we only update when these have changed
|
||||
XUID m_CT_Xuids[MAX_TEAM_SIZE];
|
||||
XUID m_T_Xuids[MAX_TEAM_SIZE];
|
||||
int m_nCTLocalPlayers[MAX_TEAM_SIZE];
|
||||
int m_nTLocalPlayers[MAX_TEAM_SIZE];
|
||||
char m_chCTNames[MAX_TEAM_SIZE][MAX_PLAYER_NAME_LENGTH];
|
||||
char m_chTNames[MAX_TEAM_SIZE][MAX_PLAYER_NAME_LENGTH];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,298 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include "basepanel.h"
|
||||
#include "upsell_scaleform.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
#include "vstdlib/vstrtools.h"
|
||||
#include "../gameui/cstrike15/cstrike15basepanel.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "cs_achievementdefs.h"
|
||||
#include "achievements_cs.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define UPSELL_ACHIEVEMENT_SLOTS 10
|
||||
|
||||
CUpsellScaleform* CUpsellScaleform::m_pInstance = NULL;
|
||||
|
||||
SFUI_BEGIN_GAME_API_DEF
|
||||
SFUI_DECL_METHOD_AS( OnQuitPressed, "QuitPressed" ),
|
||||
SFUI_DECL_METHOD_AS( OnBackPressed, "BackPressed" ),
|
||||
SFUI_DECL_METHOD_AS( OnUnlockPressed, "UnlockPressed" ),
|
||||
SFUI_DECL_METHOD_AS( OnBasePanelRunCommand, "BasePanelRunCommand" ),
|
||||
SFUI_END_GAME_API_DEF( CUpsellScaleform, UpsellMenu );
|
||||
|
||||
|
||||
CUpsellScaleform::CUpsellScaleform() :
|
||||
m_bVisible ( false ),
|
||||
m_bLoading ( false ),
|
||||
m_pTextMedalsCount( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CUpsellScaleform::~CUpsellScaleform()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::LoadDialog( void )
|
||||
{
|
||||
if ( !m_pInstance )
|
||||
{
|
||||
m_pInstance = new CUpsellScaleform( );
|
||||
SFUI_REQUEST_ELEMENT( SF_FULL_SCREEN_SLOT, g_pScaleformUI, CUpsellScaleform, m_pInstance, UpsellMenu );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::UnloadDialog( void )
|
||||
{
|
||||
// m_pInstance is deleted in PostUnloadFlash. RemoveFlashElement is called at the end of the hide animation.
|
||||
if ( m_pInstance )
|
||||
{
|
||||
// Flash elements are removed after hide animation completes
|
||||
m_pInstance->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::ShowMenu( bool bShow )
|
||||
{
|
||||
if ( bShow && !m_pInstance)
|
||||
{
|
||||
LoadDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bShow != m_pInstance->m_bVisible )
|
||||
{
|
||||
if ( bShow )
|
||||
{
|
||||
m_pInstance->Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInstance->Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::FlashLoaded( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::FlashReady( void )
|
||||
{
|
||||
//m_pCTCount = m_pScaleformUI->TextObject_MakeTextObjectFromMember( navPanelValue, "CT_Count" );
|
||||
if ( m_FlashAPI && m_pScaleformUI )
|
||||
{
|
||||
m_bLoading = false;
|
||||
|
||||
SFVALUE topPanel = m_pScaleformUI->Value_GetMember( m_FlashAPI, "TopPanel" );
|
||||
|
||||
if ( topPanel )
|
||||
{
|
||||
SFVALUE panel = m_pScaleformUI->Value_GetMember( topPanel, "Panel" );
|
||||
|
||||
if ( panel )
|
||||
{
|
||||
|
||||
SFVALUE textPanel = m_pScaleformUI->Value_GetMember( panel, "TextPanel" );
|
||||
|
||||
if ( textPanel )
|
||||
{
|
||||
SFVALUE totalPanel = m_pScaleformUI->Value_GetMember( textPanel, "TotalCountPanel" );
|
||||
|
||||
if ( totalPanel )
|
||||
{
|
||||
m_pTextMedalsCount = m_pScaleformUI->TextObject_MakeTextObjectFromMember( totalPanel, "TotalCount" );
|
||||
m_pScaleformUI->ReleaseValue( totalPanel );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( textPanel );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( panel );
|
||||
}
|
||||
|
||||
m_pScaleformUI->ReleaseValue( topPanel );
|
||||
}
|
||||
|
||||
PopulateAchievements();
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::Show( void )
|
||||
{
|
||||
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowPanel", 0, NULL );
|
||||
}
|
||||
|
||||
m_bVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::Hide( const char * szPostHideCommand )
|
||||
{
|
||||
if ( FlashAPIIsValid() )
|
||||
{
|
||||
WITH_SLOT_LOCKED
|
||||
{
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, szPostHideCommand );
|
||||
g_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HidePanel", data, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
m_bVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CUpsellScaleform::PreUnloadFlash( void )
|
||||
{
|
||||
SafeReleaseSFTextObject( m_pTextMedalsCount );
|
||||
|
||||
return ScaleformFlashInterface::PreUnloadFlash();
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::PostUnloadFlash( void )
|
||||
{
|
||||
if ( m_pInstance )
|
||||
{
|
||||
delete this;
|
||||
m_pInstance = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::OnQuitPressed( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
Hide( "QuitNoConfirm" );
|
||||
}
|
||||
|
||||
|
||||
void CUpsellScaleform::OnBackPressed( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
Hide( "RestoreMainMenu" );
|
||||
}
|
||||
|
||||
void CUpsellScaleform::OnUnlockPressed( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
#if defined ( _X360 )
|
||||
xboxsystem->ShowUnlockFullGameUI();
|
||||
#elif defined( _PS3 )
|
||||
//$TODO: Implement PS3 version of xboxsystem->ShowUnlockFullGameUI()
|
||||
#endif // _X360
|
||||
}
|
||||
|
||||
void CUpsellScaleform::OnBasePanelRunCommand( SCALEFORM_CALLBACK_ARGS_DECL )
|
||||
{
|
||||
char RunCommandStr[1024];
|
||||
V_strncpy( RunCommandStr, pui->Params_GetArgAsString( obj, 0 ), sizeof( RunCommandStr ) );
|
||||
|
||||
BasePanel()->PostMessage( BasePanel(), new KeyValues( "RunMenuCommand", "command", RunCommandStr ) );
|
||||
}
|
||||
|
||||
// Not thread safe. Do not invoke outside of flash callbacks
|
||||
void CUpsellScaleform::PopulateAchievements( void )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
|
||||
int nID = XBX_GetActiveUserId();
|
||||
|
||||
IAchievementMgr * pAchievementMgr = engine->GetAchievementMgr();
|
||||
|
||||
if ( !pAchievementMgr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int nAchievementMax = pAchievementMgr->GetAchievementCount();
|
||||
int nAchievmentCount = 0;
|
||||
int nSlot = 0;
|
||||
|
||||
for ( int i = 0; i < nAchievementMax; i++ )
|
||||
{
|
||||
CCSBaseAchievement* pAchievement = static_cast<CCSBaseAchievement *>( pAchievementMgr->GetAchievementByIndex( i, nID ) );
|
||||
|
||||
if ( pAchievement && pAchievement->IsAchieved() )
|
||||
{
|
||||
++nAchievmentCount;
|
||||
|
||||
if ( nSlot < UPSELL_ACHIEVEMENT_SLOTS )
|
||||
{
|
||||
// populate icon slots
|
||||
WITH_SFVALUEARRAY( data, 2 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nSlot );
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 1, pAchievement->GetName() );
|
||||
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetMedal", data, 2 );
|
||||
}
|
||||
|
||||
nSlot++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set progress bar and numerical count
|
||||
int nPercent = 0;
|
||||
|
||||
if ( nAchievmentCount > 0 )
|
||||
{
|
||||
if ( nAchievementMax != 0)
|
||||
{
|
||||
nPercent = static_cast<int>( ( ( static_cast<float>( nAchievmentCount ) / static_cast<float>( nAchievementMax ) ) * 100.0f ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false );
|
||||
}
|
||||
}
|
||||
|
||||
WITH_SFVALUEARRAY( data, 1 )
|
||||
{
|
||||
m_pScaleformUI->ValueArray_SetElement( data, 0, nPercent );
|
||||
m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetProgressBar", data, 1 );
|
||||
}
|
||||
|
||||
wchar_t wcCount[32];
|
||||
V_snwprintf( wcCount, ARRAYSIZE( wcCount ), L"%d / %d", nAchievmentCount, nAchievementMax );
|
||||
|
||||
if ( m_pTextMedalsCount )
|
||||
{
|
||||
m_pTextMedalsCount->SetText( wcCount );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,73 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
|
||||
#if !defined( __UPSELL_SCALEFORM_H__ )
|
||||
#define __UPSELL_SCALEFORM_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
class CUpsellScaleform : public ScaleformFlashInterface
|
||||
{
|
||||
private:
|
||||
static CUpsellScaleform *m_pInstance;
|
||||
|
||||
protected:
|
||||
CUpsellScaleform( );
|
||||
virtual ~CUpsellScaleform( );
|
||||
|
||||
public:
|
||||
/************************************
|
||||
* callbacks from scaleform
|
||||
*/
|
||||
void OnQuitPressed( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnBackPressed( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
void OnUnlockPressed( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
// Called to trigger commands on the BasePanel, like opening other dialogs, configuring options, etc.
|
||||
// See the CBaseModPanel::RunMenuCommand function for specific available commands.
|
||||
void OnBasePanelRunCommand( SCALEFORM_CALLBACK_ARGS_DECL );
|
||||
|
||||
// Construction and Destruction
|
||||
static void LoadDialog( void );
|
||||
static void UnloadDialog( void );
|
||||
|
||||
static void ShowMenu( bool bShow );
|
||||
static bool IsActive() { return m_pInstance != NULL; }
|
||||
static bool IsVisible() { return ( m_pInstance != NULL && m_pInstance->m_bVisible ); }
|
||||
|
||||
protected:
|
||||
/************************************************************
|
||||
* Flash Interface methods
|
||||
*/
|
||||
|
||||
virtual void FlashReady( void );
|
||||
virtual void FlashLoaded( void );
|
||||
|
||||
virtual bool PreUnloadFlash( void );
|
||||
virtual void PostUnloadFlash( void );
|
||||
|
||||
void Show( void );
|
||||
|
||||
// Hides the panel and passes szPostHideCommand to OnBasePanelRunCommand after hide is complete
|
||||
void Hide( const char * szPostHideCommand = "None" );
|
||||
|
||||
// Populates the dialog with achievement icons and sets the progress bar ** Not thread safe. Do not invoke outside of flash callbacks **
|
||||
void PopulateAchievements( void );
|
||||
|
||||
protected:
|
||||
|
||||
bool m_bVisible; // Visibility flag
|
||||
bool m_bLoading; // Loading flag
|
||||
ISFTextObject * m_pTextMedalsCount; // Numerical tally of earned medals
|
||||
};
|
||||
|
||||
#endif // __UPSELL_SCALEFORM_H__
|
||||
|
||||
#endif // INCLUDE_SCALEFORM
|
||||
@@ -0,0 +1,405 @@
|
||||
//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client DLL VGUI2 Viewport
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
// 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 "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"
|
||||
|
||||
#include "teammenu_scaleform.h"
|
||||
#include "chooseclass_scaleform.h"
|
||||
#include "Scaleform/HUD/sfhudinfopanel.h"
|
||||
#include "Scaleform/HUD/sfhudwinpanel.h"
|
||||
#include "Scaleform/loadingscreen_scaleform.h"
|
||||
|
||||
#if defined( CSTRIKE15 )
|
||||
#include "basepanel.h"
|
||||
#endif
|
||||
|
||||
static void OpenPanelWithCheck( const char *panelToOpen, const char *panelToCheck )
|
||||
{
|
||||
IViewPortPanel *checkPanel = GetViewPortInterface()->FindPanelByName( panelToCheck );
|
||||
if ( !checkPanel || !checkPanel->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( panelToOpen, true );
|
||||
}
|
||||
}
|
||||
|
||||
void PrintBuyTimeOverMessage( void )
|
||||
{
|
||||
CHudElement *pElement = GetHud().FindElement( "SFHudInfoPanel" );
|
||||
if ( pElement )
|
||||
{
|
||||
|
||||
char strBuyTime[16];
|
||||
int nBuyTime = ( int )CSGameRules()->GetBuyTimeLength();
|
||||
Q_snprintf( strBuyTime, sizeof( strBuyTime ), "%d", nBuyTime );
|
||||
|
||||
wchar_t buffer[128];
|
||||
wchar_t buytime[16];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strBuyTime, buytime, sizeof( buytime ) );
|
||||
|
||||
if ( nBuyTime == 0 )
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof( buffer ), g_pVGuiLocalize->Find( "#SFUI_BuyMenu_YoureOutOfTime" ), 0 );
|
||||
else
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof( buffer ), g_pVGuiLocalize->Find( "#SFUI_BuyMenu_OutOfTime" ), 1, buytime );
|
||||
|
||||
((SFHudInfoPanel *)pElement)->SetPriorityText( buffer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CON_COMMAND_F( teammenu, "Show team selection window", FCVAR_SERVER_CAN_EXECUTE )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if( pPlayer && pPlayer->CanShowTeamMenu() )
|
||||
{
|
||||
( ( CounterStrikeViewport * )GetViewPortInterface() )->SetChoseTeamAndClass( true );
|
||||
GetViewPortInterface()->ShowPanel( PANEL_TEAM, true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CON_COMMAND_F( buymenu, "Show or hide main buy menu", FCVAR_SERVER_CAN_EXECUTE )
|
||||
{
|
||||
bool bShowIt = true;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( args.ArgC() == 2 )
|
||||
{
|
||||
bShowIt = atoi( args[ 1 ] ) == 1;
|
||||
}
|
||||
|
||||
if( pPlayer && bShowIt )
|
||||
{
|
||||
if ( pPlayer->m_lifeState != LIFE_ALIVE && pPlayer->State_Get() != STATE_ACTIVE )
|
||||
return;
|
||||
|
||||
extern ConVar mp_buy_anywhere;
|
||||
extern ConVar mp_buy_during_immunity;
|
||||
static ConVarRef sv_buy_status_override_ref( "sv_buy_status_override" );
|
||||
// UNUSED: int nGuardianTeam = CSGameRules()->IsHostageRescueMap() ? TEAM_TERRORIST : TEAM_CT;
|
||||
|
||||
if ( CSGameRules()->IsPlayingCooperativeGametype() )
|
||||
{
|
||||
if ( CSGameRules()->IsWarmupPeriod() == false &&
|
||||
CSGameRules()->m_flGuardianBuyUntilTime < gpGlobals->curtime )
|
||||
{
|
||||
int nTeam = CSGameRules()->IsHostageRescueMap() ? TEAM_TERRORIST : TEAM_CT;
|
||||
int iBuyStatus = sv_buy_status_override_ref.GetInt();
|
||||
if ( iBuyStatus > 0 && (( nTeam == TEAM_CT && iBuyStatus != 1 ) || ( nTeam == TEAM_TERRORIST && iBuyStatus != 2 )) )
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuy" );
|
||||
else
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuyTilNextWave" );
|
||||
}
|
||||
else
|
||||
{
|
||||
CSGameRules()->OpenBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
}
|
||||
else if ( CSGameRules()->IsPlayingCoopMission() && sv_buy_status_override_ref.GetInt() == 3 )
|
||||
{
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuy" );
|
||||
}
|
||||
else if ( !pPlayer->IsInBuyPeriod() )
|
||||
{
|
||||
PrintBuyTimeOverMessage();
|
||||
}
|
||||
else if ( !pPlayer->IsInBuyZone() )
|
||||
{
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_NotInBuyZone" );
|
||||
}
|
||||
else
|
||||
{
|
||||
CSGameRules()->OpenBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
}
|
||||
else if( pPlayer && !bShowIt )
|
||||
{
|
||||
// Hide the menu
|
||||
CSGameRules()->CloseBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CON_COMMAND_F( spec_help, "Show spectator help screen", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
//{
|
||||
// if ( GetViewPortInterface() )
|
||||
// GetViewPortInterface()->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 ( GetViewPortInterface() )
|
||||
GetViewPortInterface()->ShowPanel( PANEL_SPECMENU, bShowIt );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( spec_gui, "Shows or hides the spectator bar", 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 ( bShowIt && GetViewPortInterface() && GetViewPortInterface()->GetActivePanel() )
|
||||
{
|
||||
// if the team screen is up, it takes precedence - don't show the spectator GUI
|
||||
if ( !V_strcmp( GetViewPortInterface()->GetActivePanel()->GetName(), PANEL_TEAM ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( GetViewPortInterface() )
|
||||
GetViewPortInterface()->ShowPanel( PANEL_SPECGUI, bShowIt );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( togglescores, "Toggles score panel", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !GetViewPortInterface() )
|
||||
return;
|
||||
|
||||
IViewPortPanel *scoreboard = GetViewPortInterface()->FindPanelByName( PANEL_SCOREBOARD );
|
||||
|
||||
if ( !scoreboard )
|
||||
return;
|
||||
|
||||
if ( scoreboard->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, false );
|
||||
GetClientVoiceMgr()->StopSquelchMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disallow bringing the Scoreboard up while we are paused
|
||||
if ( BasePanel() && BasePanel()->IsScaleformPauseMenuActive() )
|
||||
return;
|
||||
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, true );
|
||||
}
|
||||
}
|
||||
|
||||
CON_COMMAND_F( hidescores, "Forcibly hide score panel", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !GetViewPortInterface() )
|
||||
return;
|
||||
|
||||
IViewPortPanel *scoreboard = GetViewPortInterface()->FindPanelByName( PANEL_SCOREBOARD );
|
||||
|
||||
if ( !scoreboard )
|
||||
return;
|
||||
|
||||
if ( scoreboard->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, false );
|
||||
GetClientVoiceMgr()->StopSquelchMode();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 );
|
||||
SetChoseTeamAndClass( false );
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
ListenForGameEvent( "cs_win_panel_match" );
|
||||
|
||||
GetHud().InitColors( pScheme );
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
}
|
||||
|
||||
|
||||
IViewPortPanel* CounterStrikeViewport::CreatePanelByName( const char *szPanelName )
|
||||
{
|
||||
IViewPortPanel* newpanel = NULL;
|
||||
|
||||
// overwrite MOD specific panel creation
|
||||
|
||||
if ( Q_strcmp( PANEL_TEAM, szPanelName ) == 0 )
|
||||
{
|
||||
newpanel = new CCSTeamMenuScaleform( 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_BUY ), "PANEL_BUY" );
|
||||
|
||||
BaseClass::CreateDefaultPanels();
|
||||
}
|
||||
|
||||
int CounterStrikeViewport::GetDeathMessageStartHeight( void )
|
||||
{
|
||||
int x = YRES( 2 );
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char * type = event->GetName();
|
||||
|
||||
if ( Q_strcmp( type, "game_newmap" ) == 0 || Q_strcmp( type, "cs_win_panel_match" ) == 0 )
|
||||
{
|
||||
SetChoseTeamAndClass( false );
|
||||
}
|
||||
|
||||
BaseClass::FireGameEvent( event );
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::UpdateAllPanels( void )
|
||||
{
|
||||
bool bSomethingIsVisible = false;
|
||||
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( vgui::ipanel()->GetMessageContextId( GetVPanel() ) );
|
||||
|
||||
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
|
||||
{
|
||||
IViewPortPanel *p = m_UnorderedPanels[i];
|
||||
|
||||
if ( p->IsVisible() )
|
||||
{
|
||||
bSomethingIsVisible = true;
|
||||
p->Update();
|
||||
if ( m_pActivePanel == NULL )
|
||||
{
|
||||
// if a visible panel exists, then there should be an activePanel.
|
||||
m_pActivePanel = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// see if we need to show a special ui instead of the hud
|
||||
// [jason] Do not rearrange viewport panels while the Pause menu is opened - it takes precedence over all viewports
|
||||
if ( !bSomethingIsVisible && !BasePanel()->IsScaleformPauseMenuActive() )
|
||||
{
|
||||
C_CSPlayer *pCSPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
const char* UIToShow = NULL;
|
||||
|
||||
if ( !pCSPlayer )
|
||||
{
|
||||
UIToShow = PANEL_SPECGUI;
|
||||
}
|
||||
else if ( pCSPlayer->GetObserverMode() != OBS_MODE_NONE )
|
||||
{
|
||||
if ( pCSPlayer->State_Get() != STATE_PICKINGTEAM && ( pCSPlayer->GetTeamNumber() == TEAM_UNASSIGNED ) && !pCSPlayer->IsHLTV() )
|
||||
{
|
||||
// not a member of a team and not a spectator. show the team select screen.
|
||||
if ( !CLoadingScreenScaleform::IsOpen() &&
|
||||
( (GetActivePanel() && !V_strcmp( GetActivePanel()->GetName(), PANEL_TEAM )) || !GetActivePanel() ) )
|
||||
{
|
||||
// don't show the team panel if the team panel is already up
|
||||
UIToShow = PANEL_TEAM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SFHudWinPanel * pWinPanel = GET_HUDELEMENT( SFHudWinPanel );
|
||||
if ( pWinPanel && !pWinPanel->IsVisible() )
|
||||
{
|
||||
UIToShow = PANEL_SPECGUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( UIToShow )
|
||||
{
|
||||
ShowPanel( UIToShow, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
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 ( GetViewPortInterface() )
|
||||
{
|
||||
GetViewPortInterface()->ChatInputPosition( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE( CounterStrikeViewport, IClientVGUI, CLIENTVGUI_INTERFACE_VERSION );
|
||||
*/
|
||||
@@ -0,0 +1,86 @@
|
||||
//========= Copyright � 1996-2005, 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;
|
||||
|
||||
void PrintBuyTimeOverMessage( void );
|
||||
|
||||
//==============================================================================
|
||||
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...
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [mhansen] We want to let the team screen know if this is the first time
|
||||
// we chose a team so we can decide what the "back" action is
|
||||
//=============================================================================
|
||||
bool GetChoseTeamAndClass() { return m_bChoseTeamAndClass; }
|
||||
void SetChoseTeamAndClass( bool chose ) { m_bChoseTeamAndClass = chose; }
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
|
||||
virtual void UpdateAllPanels( void );
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void CenterWindow( vgui::Frame *win );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [mhansen] We want to let the team screen know if this is the first time
|
||||
// we chose a team so we can decide what the "back" action is
|
||||
//=============================================================================
|
||||
bool m_bChoseTeamAndClass;
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
};
|
||||
|
||||
|
||||
#endif // COUNTERSTRIKEVIEWPORT_H
|
||||
@@ -0,0 +1,398 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSLOADOUT_H
|
||||
#define CSLOADOUT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
const int cMaxEquipment = 6; // if this # changes, bump version # cl_titledataversionblock3 and loadoutData in TitleData1 block for title data storageCCSSteamStats::SyncCSLoadoutsToTitleData
|
||||
const int cMaxLoadouts = 4; // if this # changes, bump version # cl_titledataversionblock3 and loadoutData in TitleData1 block for title data storageCCSSteamStats::SyncCSLoadoutsToTitleData
|
||||
|
||||
class CCSEquipmentLoadout
|
||||
{
|
||||
public:
|
||||
CCSEquipmentLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
SetEquipmentID( WEAPON_NONE );
|
||||
}
|
||||
|
||||
CCSEquipmentLoadout& operator=( const CCSEquipmentLoadout& in_rhs )
|
||||
{
|
||||
m_EquipmentID = in_rhs.m_EquipmentID;
|
||||
m_EquipmentPos = in_rhs.m_EquipmentPos;
|
||||
m_Quantity = in_rhs.m_Quantity;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return ( ( GetEquipmentID() == WEAPON_NONE ) || ( GetQuantity() == 0 ) );
|
||||
}
|
||||
|
||||
CSWeaponID GetEquipmentID() const
|
||||
{
|
||||
return m_EquipmentID;
|
||||
}
|
||||
|
||||
void SetEquipmentID( CSWeaponID newid )
|
||||
{
|
||||
m_EquipmentID = newid;
|
||||
|
||||
if ( newid == WEAPON_NONE )
|
||||
{
|
||||
m_Quantity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int GetEquipmentPos() const
|
||||
{
|
||||
return m_EquipmentPos;
|
||||
}
|
||||
|
||||
void SetEquipmentPos( int pos )
|
||||
{
|
||||
m_EquipmentPos = pos;
|
||||
}
|
||||
|
||||
int GetQuantity() const
|
||||
{
|
||||
return m_Quantity;
|
||||
}
|
||||
|
||||
void SetQuantity( int value )
|
||||
{
|
||||
m_Quantity = value;
|
||||
|
||||
if ( !m_Quantity )
|
||||
{
|
||||
m_EquipmentID = WEAPON_NONE;
|
||||
m_EquipmentPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSWeaponID m_EquipmentID;
|
||||
int m_EquipmentPos;
|
||||
int m_Quantity;
|
||||
|
||||
};
|
||||
|
||||
inline const bool operator==( const CCSEquipmentLoadout& me, const CCSEquipmentLoadout& them )
|
||||
{
|
||||
return ( ( me.GetEquipmentID() == them.GetEquipmentID() ) && ( me.GetQuantity() == them.GetQuantity() ) );
|
||||
}
|
||||
|
||||
inline const bool operator!=( const CCSEquipmentLoadout& me, const CCSEquipmentLoadout& them )
|
||||
{
|
||||
return !( me == them );
|
||||
}
|
||||
|
||||
class CCSLoadout
|
||||
{
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
HAS_TASER = 0x1,
|
||||
HAS_BOMB = 0x2,
|
||||
HAS_DEFUSE = 0x4,
|
||||
};
|
||||
|
||||
bool GetFlag( uint8 flag ) const
|
||||
{
|
||||
return ( m_flags & flag ) != 0;
|
||||
}
|
||||
|
||||
void SetFlag( uint8 flag, bool setIt )
|
||||
{
|
||||
m_flags &= ~flag;
|
||||
if ( setIt )
|
||||
m_flags |= flag;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
CCSLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
m_primaryWeaponID = WEAPON_NONE;
|
||||
m_secondaryWeaponID = WEAPON_NONE;
|
||||
m_primaryWeaponItemPos = 0;
|
||||
m_secondaryWeaponItemPos = 0;
|
||||
m_flags = 0;
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
m_EquipmentArray[i].ClearLoadout();
|
||||
}
|
||||
}
|
||||
|
||||
CCSLoadout& operator=( const CCSLoadout& in_rhs )
|
||||
{
|
||||
m_primaryWeaponID = in_rhs.m_primaryWeaponID;
|
||||
m_secondaryWeaponID = in_rhs.m_secondaryWeaponID;
|
||||
m_primaryWeaponItemPos = in_rhs.m_primaryWeaponItemPos;
|
||||
m_secondaryWeaponItemPos = in_rhs.m_secondaryWeaponItemPos;
|
||||
m_flags = in_rhs.m_flags;
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
m_EquipmentArray[i] = in_rhs.m_EquipmentArray[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const CCSLoadout& in_rhs ) const
|
||||
{
|
||||
if ( m_primaryWeaponID != in_rhs.m_primaryWeaponID )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_secondaryWeaponID != in_rhs.m_secondaryWeaponID )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_flags != in_rhs.m_flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( m_EquipmentArray[i].GetEquipmentID() != WEAPON_NONE )
|
||||
{
|
||||
bool bMatch = false;
|
||||
for ( int j = 0; j < cMaxEquipment; j++ )
|
||||
{
|
||||
if ( in_rhs.m_EquipmentArray[j] == m_EquipmentArray[i] )
|
||||
bMatch = true;
|
||||
}
|
||||
|
||||
if ( bMatch == false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( in_rhs.m_EquipmentArray[i].GetEquipmentID() != WEAPON_NONE )
|
||||
{
|
||||
bool bMatch = false;
|
||||
for ( int j = 0; j < cMaxEquipment; j++ )
|
||||
{
|
||||
if ( m_EquipmentArray[j] == in_rhs.m_EquipmentArray[i] )
|
||||
bMatch = true;
|
||||
}
|
||||
|
||||
if ( bMatch == false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=( const CCSLoadout& in_rhs ) const
|
||||
{
|
||||
return !( *this == in_rhs );
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
if ( m_primaryWeaponID != WEAPON_NONE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_secondaryWeaponID != WEAPON_NONE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( !m_EquipmentArray[i].isEmpty() )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CountUniqueEquipment( void ) const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for ( result = 0; result < cMaxEquipment; result++ )
|
||||
{
|
||||
if ( m_EquipmentArray[result].isEmpty() )
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool GetHasTaser( void ) const
|
||||
{
|
||||
return GetFlag( HAS_TASER );
|
||||
}
|
||||
|
||||
void SetHasTaser( bool value )
|
||||
{
|
||||
SetFlag( HAS_TASER, value );
|
||||
}
|
||||
|
||||
bool GetHasBomb( void ) const
|
||||
{
|
||||
return GetFlag( HAS_BOMB );
|
||||
}
|
||||
|
||||
void SetHasBomb( bool value )
|
||||
{
|
||||
SetFlag( HAS_BOMB, value );
|
||||
}
|
||||
|
||||
bool GetHasDefuser( void ) const
|
||||
{
|
||||
return GetFlag( HAS_DEFUSE );
|
||||
}
|
||||
|
||||
void SetHasDefuser( bool value )
|
||||
{
|
||||
SetFlag( HAS_DEFUSE, value );
|
||||
}
|
||||
|
||||
CSWeaponID ReportFirstWeapon( void )
|
||||
{
|
||||
if ( m_primaryWeaponID )
|
||||
return m_primaryWeaponID;
|
||||
else if ( m_secondaryWeaponID )
|
||||
return m_secondaryWeaponID;
|
||||
else if ( GetHasTaser() )
|
||||
return WEAPON_TASER;
|
||||
else
|
||||
return m_EquipmentArray[0].GetEquipmentID();
|
||||
}
|
||||
|
||||
// Data fields
|
||||
CSWeaponID m_primaryWeaponID;
|
||||
CSWeaponID m_secondaryWeaponID;
|
||||
int m_primaryWeaponItemPos;
|
||||
int m_secondaryWeaponItemPos;
|
||||
CCSEquipmentLoadout m_EquipmentArray[cMaxEquipment];
|
||||
uint8 m_flags;
|
||||
};
|
||||
|
||||
class CCSBuyMenuLoadout
|
||||
{
|
||||
|
||||
public:
|
||||
CCSBuyMenuLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
m_WeaponID[ i ] = WEAPON_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
CCSBuyMenuLoadout& operator=( const CCSBuyMenuLoadout& in_rhs )
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
m_WeaponID[ i ] = in_rhs.m_WeaponID[ i ];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const CCSBuyMenuLoadout& in_rhs ) const
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
if ( m_WeaponID[ i ] != in_rhs.m_WeaponID[ i ] )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=( const CCSBuyMenuLoadout& in_rhs ) const
|
||||
{
|
||||
return !( *this == in_rhs );
|
||||
}
|
||||
|
||||
CEconItemView * GetWeaponView( loadout_positions_t pos, int nTeamNumber ) const;
|
||||
|
||||
// Data fields
|
||||
itemid_t m_WeaponID[ LOADOUT_POSITION_COUNT ];
|
||||
};
|
||||
|
||||
inline CEconItemView * CCSBuyMenuLoadout::GetWeaponView( loadout_positions_t pos, int nTeamNumber ) const
|
||||
{
|
||||
int nPos = pos;
|
||||
|
||||
|
||||
if ( ( nPos < 0 ) || ( nPos >= LOADOUT_POSITION_COUNT ) )
|
||||
return NULL;
|
||||
|
||||
if ( !CSInventoryManager() || !CSInventoryManager()->GetLocalCSInventory() )
|
||||
return NULL;
|
||||
|
||||
if ( m_WeaponID[ nPos ] == INVALID_ITEM_ID )
|
||||
return NULL;
|
||||
|
||||
CEconItemView * pItemView = CSInventoryManager()->GetLocalCSInventory()->GetInventoryItemByItemID( m_WeaponID[ nPos ] );
|
||||
|
||||
if ( pItemView && pItemView->IsValid() )
|
||||
{
|
||||
return pItemView;
|
||||
}
|
||||
else if ( CombinedItemIdIsDefIndexAndPaint( m_WeaponID[ nPos ] ) )
|
||||
{
|
||||
return CSInventoryManager()->FindOrCreateReferenceEconItem( m_WeaponID[ nPos ] );
|
||||
}
|
||||
else if ( CEconItemView * pItemView = CSInventoryManager()->GetItemInLoadoutForTeam( nTeamNumber, nPos ) )
|
||||
{
|
||||
return pItemView;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern CCSLoadout* GetBuyMenuLoadoutData( int in_teamID );
|
||||
|
||||
#endif //CSLOADOUT_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
||||
//====== Copyright © 1996-2005, 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
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,25 @@
|
||||
//====== Copyright © 1996-2005, 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
|
||||
@@ -0,0 +1,368 @@
|
||||
//====== Copyright © 1996-2005, 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 "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_DEAGLE, "#Cstrike_TitlesTXT_DesertEagle" },
|
||||
{ WEAPON_ELITE, "#Cstrike_TitlesTXT_Beretta96G" },
|
||||
{ WEAPON_FIVESEVEN, "#Cstrike_TitlesTXT_ESFiveSeven" },
|
||||
{ WEAPON_GLOCK, "#Cstrike_TitlesTXT_Glock18" },
|
||||
{ WEAPON_P228, "#Cstrike_TitlesTXT_P228" },
|
||||
{ WEAPON_USP, "#Cstrike_TitlesTXT_USP45" },
|
||||
|
||||
{ WEAPON_AK47, "#Cstrike_TitlesTXT_AK47" },
|
||||
{ WEAPON_AUG, "#Cstrike_TitlesTXT_Aug" },
|
||||
{ WEAPON_AWP, "#Cstrike_TitlesTXT_ArcticWarfareMagnum" },
|
||||
{ WEAPON_FAMAS, "#Cstrike_TitlesTXT_Famas" },
|
||||
{ WEAPON_G3SG1, "#Cstrike_TitlesTXT_G3SG1" },
|
||||
{ WEAPON_GALIL, "#Cstrike_TitlesTXT_Galil" },
|
||||
{ WEAPON_GALILAR, "#Cstrike_TitlesTXT_GalilAR" },
|
||||
{ WEAPON_M249, "#Cstrike_TitlesTXT_ESM249" },
|
||||
{ WEAPON_M3, "#Cstrike_TitlesTXT_Leone12" },
|
||||
{ WEAPON_M4A1, "#Cstrike_TitlesTXT_M4A1_Short" },
|
||||
{ WEAPON_MAC10, "#Cstrike_TitlesTXT_Mac10_Short" },
|
||||
{ WEAPON_MP5NAVY, "#Cstrike_TitlesTXT_mp5navy" },
|
||||
{ WEAPON_P90, "#Cstrike_TitlesTXT_ESC90" },
|
||||
{ WEAPON_SCOUT, "#Cstrike_TitlesTXT_Scout" },
|
||||
{ WEAPON_SG550, "#Cstrike_TitlesTXT_SG550" },
|
||||
{ WEAPON_SG552, "#Cstrike_TitlesTXT_SG552" },
|
||||
{ WEAPON_TMP, "#Cstrike_TitlesTXT_tmp" },
|
||||
{ WEAPON_UMP45, "#Cstrike_TitlesTXT_KMUMP45" },
|
||||
{ WEAPON_XM1014, "#Cstrike_TitlesTXT_AutoShotgun" },
|
||||
|
||||
{ WEAPON_BIZON, "#Cstrike_TitlesTXT_Bizon" },
|
||||
{ WEAPON_MAG7, "#Cstrike_TitlesTXT_Mag7" },
|
||||
{ WEAPON_NEGEV, "#Cstrike_TitlesTXT_Negev" },
|
||||
{ WEAPON_SAWEDOFF, "#Cstrike_TitlesTXT_Sawedoff" },
|
||||
{ WEAPON_TEC9, "#Cstrike_TitlesTXT_Tec9" },
|
||||
{ WEAPON_TASER, "#Cstrike_TitlesTXT_Taser" },
|
||||
|
||||
{ WEAPON_HKP2000, "#Cstrike_TitlesTXT_HKP2000" },
|
||||
{ WEAPON_MP7, "#Cstrike_TitlesTXT_MP7" },
|
||||
{ WEAPON_MP9, "#Cstrike_TitlesTXT_MP9" },
|
||||
{ WEAPON_NOVA, "#Cstrike_TitlesTXT_Nova" },
|
||||
{ WEAPON_P250, "#Cstrike_TitlesTXT_P250" },
|
||||
{ WEAPON_SCAR17, "#Cstrike_TitlesTXT_Scar17" },
|
||||
{ WEAPON_SCAR20, "#Cstrike_TitlesTXT_Scar20" },
|
||||
{ WEAPON_SG556, "#Cstrike_TitlesTXT_SG556" },
|
||||
{ WEAPON_SSG08, "#Cstrike_TitlesTXT_SSG08" },
|
||||
|
||||
{ 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->GetPrimaryAmmoType(), C_CSPlayer::GetLocalCSPlayer() );
|
||||
int buySize = GetCSAmmoDef()->GetBuySize( pInfo->GetPrimaryAmmoType() );
|
||||
|
||||
int numClips = 0;
|
||||
if ( buySize && pInfo->GetPrimaryAmmoType() >= 0 )
|
||||
{
|
||||
switch ( pWeapon->GetAmmoType() )
|
||||
{
|
||||
case AMMO_CLIPS:
|
||||
numClips = pWeapon->GetAmmoAmount();
|
||||
if ( pWeapon->GetCSWeaponID() == WEAPON_NONE && numClips >= 4 )
|
||||
{
|
||||
numClips = ceil(maxRounds/(float)buySize);
|
||||
}
|
||||
numClips = MIN( ceil(maxRounds/(float)buySize), numClips );
|
||||
|
||||
numClips -= ammo[pInfo->GetPrimaryAmmoType() ]/buySize;
|
||||
if ( numClips < 0 || ammo[pInfo->GetPrimaryAmmoType() ] == maxRounds )
|
||||
{
|
||||
numClips = 0;
|
||||
}
|
||||
break;
|
||||
case AMMO_ROUNDS:
|
||||
{
|
||||
int roundsNeeded = pWeapon->GetAmmoAmount() - ammo[pInfo->GetPrimaryAmmoType() ];
|
||||
if ( roundsNeeded > 0 )
|
||||
{
|
||||
numClips = ceil(roundsNeeded/(float)buySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
numClips = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AMMO_PERCENT:
|
||||
{
|
||||
int roundsNeeded = maxRounds*pWeapon->GetAmmoAmount() - ammo[pInfo->GetPrimaryAmmoType() ];
|
||||
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 )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
if ( !pPlayer )
|
||||
return false;
|
||||
|
||||
const 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->GetUsedByTeam() != TEAM_UNASSIGNED && pPlayer->GetTeamNumber() != info->GetUsedByTeam() )
|
||||
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 )
|
||||
{
|
||||
const CCSWeaponInfo *info = GetWeaponInfo( id );
|
||||
if ( !info )
|
||||
return false;
|
||||
|
||||
return IsPrimaryWeaponClassID( info->GetWeaponType() );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 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 )
|
||||
{
|
||||
const CCSWeaponInfo *info = GetWeaponInfo( id );
|
||||
if ( !info )
|
||||
return false;
|
||||
|
||||
return IsSecondaryWeaponClassID( info->GetWeaponType() );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 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 >= EQUIPMENT_FIRST )
|
||||
continue;
|
||||
|
||||
const CCSWeaponInfo *info = GetWeaponInfo( gameWeaponID );
|
||||
if ( !info )
|
||||
continue;
|
||||
|
||||
int clientAmmoType = info->GetPrimaryAmmoType();
|
||||
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 = assert_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->GetCSWeaponID();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,454 @@
|
||||
//====== Copyright © 1996-2005, 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 );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,269 @@
|
||||
//====== Copyright © 1996-2005, 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();
|
||||
explicit BuyPresetWeapon( CSWeaponID weaponID );
|
||||
//BuyPresetWeapon& operator= (const BuyPresetWeapon& other); // default implementation should work
|
||||
|
||||
const wchar_t* GetName() const { return m_name; } ///< Returns the display name corresponding to the weapon ID
|
||||
CSWeaponID GetCSWeaponID() 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
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 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
|
||||
@@ -0,0 +1,813 @@
|
||||
//========= Copyright © 1996-2005, 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"
|
||||
#include "c_breakableprop.h"
|
||||
#include "cs_shareddefs.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< CHandle<C_BaseAnimating> > g_HostageRagdolls;
|
||||
|
||||
extern ConVar g_ragdoll_fadespeed;
|
||||
ConVar cl_use_hostage_ik("cl_use_hostage_ik", "1");
|
||||
//-----------------------------------------------------------------------------
|
||||
const int NumInterestingPoseParameters = 6;
|
||||
static const char* InterestingPoseParameters[NumInterestingPoseParameters] =
|
||||
{
|
||||
"body_yaw",
|
||||
"spine_yaw",
|
||||
"neck_trans",
|
||||
"head_pitch",
|
||||
"head_yaw",
|
||||
"head_roll"
|
||||
};
|
||||
|
||||
// Op Bloodhound hostage characters
|
||||
// cbble: Lord William
|
||||
// lake: journalist
|
||||
// bank: Hostage
|
||||
// office:
|
||||
struct CustomHostageNames
|
||||
{
|
||||
const char* mapname;
|
||||
const char* hostageName;
|
||||
};
|
||||
static const CustomHostageNames s_HostageCharactersNames[] =
|
||||
{
|
||||
{ "default", "#Cstrike_TitlesTXT_Hostage" },
|
||||
{ "cs_office", "#CSGO_StoryHostageName_cs_office" },
|
||||
{ "gd_lake", "#CSGO_StoryHostageName_gd_lake" },
|
||||
{ "gd_cbble", "#CSGO_StoryHostageName_gd_cbble" },
|
||||
{ "gd_bank", "#CSGO_StoryHostageName_gd_bank" },
|
||||
{ "coop_cementplant", "#CSGO_StoryHostageName_gd_lake" },
|
||||
{ "", "" } // this needs to be last
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_HostageCarriableProp::C_HostageCarriableProp()
|
||||
{
|
||||
m_bCreatedViewmodel = false;
|
||||
m_flFadeInStartTime = 0.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_HostageCarriableProp::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
|
||||
m_flFadeInStartTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
// if we don't have an owner for some reason, remove ourselves
|
||||
C_BaseEntity *pOwner = GetFollowedEntity();
|
||||
if ( !pOwner )
|
||||
UTIL_Remove( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Should this object cast shadows?
|
||||
//-----------------------------------------------------------------------------
|
||||
ShadowType_t C_HostageCarriableProp::ShadowCastType()
|
||||
{
|
||||
if ( IsEffectActive( /*EF_NODRAW |*/ EF_NOSHADOW ) )
|
||||
return SHADOWS_NONE;
|
||||
|
||||
if ( ShouldDraw() )
|
||||
return SHADOWS_RENDER_TO_TEXTURE;
|
||||
|
||||
return SHADOWS_NONE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns whether object should render.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_HostageCarriableProp::ShouldDraw( void )
|
||||
{
|
||||
C_BaseEntity *pOwner = GetFollowedEntity();
|
||||
|
||||
// weapon has no owner, don't draw it - will get removed soon
|
||||
if ( !pOwner )
|
||||
return false;
|
||||
|
||||
C_BasePlayer *pViewedPlayer = GetLocalOrInEyeCSPlayer();
|
||||
C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
// carried by local player?
|
||||
if ( pOwner == pViewedPlayer )
|
||||
{
|
||||
if ( pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE )
|
||||
return false;
|
||||
|
||||
// 3rd person mode
|
||||
return pViewedPlayer->ShouldDrawLocalPlayer();
|
||||
}
|
||||
|
||||
return BaseClass::ShouldDraw();
|
||||
}
|
||||
|
||||
void C_HostageCarriableProp::ClientThink()
|
||||
{
|
||||
BaseClass::ClientThink();
|
||||
|
||||
int a = GetRenderAlpha();
|
||||
|
||||
if ( m_flFadeInStartTime + 1.0 > gpGlobals->curtime )
|
||||
{
|
||||
SetRenderMode( kRenderGlow );
|
||||
a = ((gpGlobals->curtime - m_flFadeInStartTime) / 1.0f) * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetRenderMode( kRenderNormal );
|
||||
a = 255;
|
||||
}
|
||||
|
||||
a = MAX( 0, a );
|
||||
SetRenderAlpha( a );
|
||||
}
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_HostageCarriableProp, DT_HostageCarriableProp, CHostageCarriableProp)
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
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, false ) == 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 = GetRenderAlpha();
|
||||
|
||||
iAlpha = MAX( iAlpha - ( g_ragdoll_fadespeed.GetInt() * gpGlobals->frametime ), 0 );
|
||||
|
||||
SetRenderMode( kRenderTransAlpha );
|
||||
SetRenderAlpha( 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::RecvProxy_Jumped( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
C_CHostage *pHostage= (C_CHostage *) pStruct;
|
||||
|
||||
bool jumped = pData->m_Value.m_Int != 0;
|
||||
|
||||
if ( jumped )
|
||||
{
|
||||
// hostage jumped
|
||||
pHostage->m_PlayerAnimState->DoAnimationEvent( PLAYERANIMEVENT_JUMP );
|
||||
pHostage->SetNextClientThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
pHostage->m_jumpedThisFrame = jumped;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_CHostage, DT_CHostage, CHostage)
|
||||
|
||||
RecvPropInt( RECVINFO( m_isRescued ), 0, C_CHostage::RecvProxy_Rescued ),
|
||||
RecvPropInt( RECVINFO( m_jumpedThisFrame ), 0, C_CHostage::RecvProxy_Jumped ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_iHealth ) ),
|
||||
RecvPropInt( RECVINFO( m_iMaxHealth ) ),
|
||||
RecvPropInt( RECVINFO( m_lifeState ) ),
|
||||
RecvPropInt( RECVINFO( m_fFlags ) ),// Needed for on ground detection for hostage jumping.
|
||||
|
||||
RecvPropInt( RECVINFO( m_nHostageState ) ),
|
||||
|
||||
RecvPropFloat( RECVINFO( m_flRescueStartTime ) ),
|
||||
RecvPropFloat( RECVINFO( m_flGrabSuccessTime ) ),
|
||||
RecvPropFloat( RECVINFO( m_flDropStartTime ) ),
|
||||
|
||||
RecvPropVector( RECVINFO( m_vel ) ),
|
||||
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.
|
||||
// [msmith] We're starting to use IK on hostages so that we can optionally have their hands bound.
|
||||
if ( !cl_use_hostage_ik.GetBool() )
|
||||
{
|
||||
m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK;
|
||||
}
|
||||
|
||||
// set the model so the PlayerAnimState uses the Hostage activities/sequences
|
||||
SetModelName( HOSTAGE_ANIM_MODEL );
|
||||
|
||||
m_PlayerAnimState = CreateHostageAnimState( this, this, LEGANIM_9WAY, false );
|
||||
|
||||
m_leader = INVALID_EHANDLE;
|
||||
m_blinkTimer.Invalidate();
|
||||
|
||||
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();
|
||||
|
||||
SetClientSideHolidayHatAddon( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::Spawn( void )
|
||||
{
|
||||
m_leader = INVALID_EHANDLE;
|
||||
m_blinkTimer.Invalidate();
|
||||
|
||||
SetClientSideHolidayHatAddon( false );
|
||||
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
const char * C_CHostage::GetCustomHostageNameForMap( const char *szMapName )
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( s_HostageCharactersNames ); ++i )
|
||||
{
|
||||
if ( Q_stricmp( s_HostageCharactersNames[i].mapname, szMapName ) == 0 )
|
||||
{
|
||||
return s_HostageCharactersNames[i].hostageName;
|
||||
}
|
||||
}
|
||||
|
||||
return s_HostageCharactersNames[0].hostageName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_CHostage::ShouldDraw( void )
|
||||
{
|
||||
if ( m_createdLowViolenceRagdoll )
|
||||
return false;
|
||||
|
||||
switch ( m_nHostageState )
|
||||
{
|
||||
case k_EHostageStates_BeingCarried:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case k_EHostageStates_GettingPickedUp:
|
||||
case k_EHostageStates_GettingDropped:
|
||||
case k_EHostageStates_Rescued:
|
||||
case k_EHostageStates_Idle:
|
||||
case k_EHostageStates_BeingUntied:
|
||||
case k_EHostageStates_FollowingPlayer:
|
||||
case k_EHostageStates_Dead:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
m_hRagdollOnClient.Set( pLowViolenceModel );
|
||||
|
||||
g_HostageRagdolls.AddToTail( m_hHolidayHatAddon );
|
||||
if ( m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
m_hHolidayHatAddon->FollowEntity( pLowViolenceModel );
|
||||
m_hHolidayHatAddon.Term();
|
||||
}
|
||||
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 );
|
||||
g_HostageRagdolls.AddToTail( m_hHolidayHatAddon );
|
||||
if ( m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
m_hHolidayHatAddon->FollowEntity( pRagdoll );
|
||||
m_hHolidayHatAddon.Term();
|
||||
}
|
||||
}
|
||||
m_hRagdollOnClient.Set( 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;
|
||||
}
|
||||
|
||||
void C_CHostage::EstimateAbsVelocity( Vector& vel )
|
||||
{
|
||||
vel = m_vel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
* 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;
|
||||
|
||||
STEAMWORKS_TESTSECRET_AMORTIZE(79);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
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 a = 255;
|
||||
|
||||
// if ( GetRenderAlpha() > 0 )
|
||||
// {
|
||||
// SetNextClientThink( gpGlobals->curtime + 0.001 );
|
||||
// }
|
||||
|
||||
switch ( m_nHostageState )
|
||||
{
|
||||
case k_EHostageStates_GettingPickedUp:
|
||||
{
|
||||
a = (1.0f - ((gpGlobals->curtime - m_flGrabSuccessTime) / CS_HOSTAGE_TRANSTIME_PICKUP)) * 255;
|
||||
break;
|
||||
}
|
||||
case k_EHostageStates_GettingDropped:
|
||||
{
|
||||
a = ((gpGlobals->curtime - m_flDropStartTime) / CS_HOSTAGE_TRANSTIME_DROP) * 255;
|
||||
break;
|
||||
}
|
||||
case k_EHostageStates_Rescued:
|
||||
{
|
||||
a = (1.0f - ((gpGlobals->curtime - m_flRescueStartTime) / CS_HOSTAGE_TRANSTIME_RESCUE)) * 255;
|
||||
break;
|
||||
}
|
||||
case k_EHostageStates_BeingCarried:
|
||||
{
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( a < 255 )
|
||||
SetRenderMode( kRenderTransAlpha );
|
||||
else
|
||||
SetRenderMode( kRenderNormal, true );
|
||||
|
||||
a = MAX( 0, a );
|
||||
|
||||
RemoveEffects( EF_NODRAW );
|
||||
SetRenderAlpha( a );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::SetClientSideHolidayHatAddon( bool bEnable )
|
||||
{
|
||||
if ( m_hRagdollOnClient.Get() )
|
||||
bEnable = false; // no hat if we have a ragdoll
|
||||
|
||||
if ( bEnable && !m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
// Create the hat
|
||||
C_BreakableProp *pEnt = new C_BreakableProp;
|
||||
pEnt->InitializeAsClientEntity( "models/player/holiday/santahat.mdl", false );
|
||||
pEnt->FollowEntity( this );
|
||||
pEnt->SetLocalOrigin( Vector( 0, 0, 0 ) );
|
||||
pEnt->SetLocalAngles( QAngle( 0, 0, 0 ) );
|
||||
pEnt->SetUseParentLightingOrigin( true );// This will make it so the weapons get lit with the same ambient cube that the player gets lit with.
|
||||
m_hHolidayHatAddon.Set( pEnt );
|
||||
}
|
||||
if ( !bEnable && m_hHolidayHatAddon.Get() )
|
||||
{
|
||||
// Remove the hat
|
||||
m_hHolidayHatAddon->Release();
|
||||
m_hHolidayHatAddon.Term();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_CHostage::SetClientSideHoldayHatAddonForAllHostagesAndTheirRagdolls( bool bEnable )
|
||||
{
|
||||
FOR_EACH_VEC( g_Hostages, iHostage )
|
||||
{
|
||||
g_Hostages[iHostage]->SetClientSideHolidayHatAddon( bEnable );
|
||||
}
|
||||
|
||||
for ( int k = 0; k < g_HostageRagdolls.Count(); k+=2 )
|
||||
{
|
||||
if ( !g_HostageRagdolls[k].Get() )
|
||||
{
|
||||
if ( g_HostageRagdolls[k+1].Get() )
|
||||
{
|
||||
( ( C_BreakableProp * ) g_HostageRagdolls[k+1].Get() )->Release();
|
||||
g_HostageRagdolls[k+1].Term();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bEnable && !g_HostageRagdolls[k+1].Get() )
|
||||
{
|
||||
// Create the hat
|
||||
C_BreakableProp *pEnt = new C_BreakableProp;
|
||||
pEnt->InitializeAsClientEntity( "models/player/holiday/santahat.mdl", false );
|
||||
pEnt->FollowEntity( g_HostageRagdolls[k].Get() );
|
||||
pEnt->SetLocalOrigin( Vector( 0, 0, 0 ) );
|
||||
pEnt->SetLocalAngles( QAngle( 0, 0, 0 ) );
|
||||
pEnt->SetUseParentLightingOrigin( true );// This will make it so the weapons get lit with the same ambient cube that the player gets lit with.
|
||||
g_HostageRagdolls[k+1].Set( pEnt );
|
||||
}
|
||||
if ( !bEnable && g_HostageRagdolls[k+1].Get() )
|
||||
{
|
||||
// Remove the hat
|
||||
( ( C_BreakableProp * ) g_HostageRagdolls[k+1].Get() )->Release();
|
||||
g_HostageRagdolls[k+1].Term();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
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, char *pCustomImpactName )
|
||||
{
|
||||
static ConVar *violence_hblood = cvar->FindVar( "violence_hblood" );
|
||||
if ( violence_hblood && !violence_hblood->GetBool() )
|
||||
return;
|
||||
|
||||
BaseClass::ImpactTrace( pTrace, iDamageType, pCustomImpactName );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//========= Copyright © 1996-2005, 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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_HostageCarriableProp : public C_BaseAnimating
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_HostageCarriableProp, C_BaseAnimating );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_HostageCarriableProp();
|
||||
|
||||
virtual void ClientThink( void );
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual bool ShouldDraw();
|
||||
virtual ShadowType_t ShadowCastType();
|
||||
|
||||
bool m_bCreatedViewmodel;
|
||||
float m_flFadeInStartTime;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 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();
|
||||
virtual void EstimateAbsVelocity( Vector &vel );
|
||||
|
||||
public:
|
||||
virtual void Spawn( void );
|
||||
virtual void UpdateClientSideAnimation();
|
||||
|
||||
const char *GetCustomHostageNameForMap( const char *szMapName );
|
||||
|
||||
void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
int GetHostageState( void ) { return m_nHostageState; }
|
||||
|
||||
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, char *pCustomImpactName );
|
||||
|
||||
void SetClientSideHolidayHatAddon( bool bEnable );
|
||||
static void SetClientSideHoldayHatAddonForAllHostagesAndTheirRagdolls( bool bEnable );
|
||||
|
||||
private:
|
||||
int m_OldLifestate;
|
||||
int m_iMaxHealth;
|
||||
|
||||
IPlayerAnimState *m_PlayerAnimState;
|
||||
|
||||
CNetworkVar( EHANDLE, m_leader ); // who we are following, or NULL
|
||||
|
||||
CNetworkVar( Vector, m_vel );
|
||||
|
||||
CNetworkVar( bool, m_isRescued );
|
||||
CNetworkVar( bool, m_jumpedThisFrame );
|
||||
|
||||
CNetworkVar( int, m_nHostageState );
|
||||
|
||||
|
||||
CNetworkVar( float, m_flRescueStartTime );
|
||||
CNetworkVar( float, m_flGrabSuccessTime ); //What time did the grabbing succeed?
|
||||
CNetworkVar( float, m_flDropStartTime ); //What time did the grabbing succeed?
|
||||
|
||||
float m_flDeadOrRescuedTime;
|
||||
static void RecvProxy_Rescued( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_Jumped( 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;
|
||||
|
||||
bool m_createdLowViolenceRagdoll;
|
||||
|
||||
CHandle<C_BaseAnimating> m_hRagdollOnClient;
|
||||
CHandle<C_BaseAnimating> m_hHolidayHatAddon;
|
||||
|
||||
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< CHandle<C_BaseAnimating> > g_HostageRagdolls;
|
||||
|
||||
|
||||
#endif // C_CHOSTAGE_H
|
||||
@@ -0,0 +1,285 @@
|
||||
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client handler implementations for instruction players how to play
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_gameinstructor.h"
|
||||
#include "c_baselesson.h"
|
||||
#include "c_cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
|
||||
#include "gametypes.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern CUtlDict< int, int > g_LessonActionMap;
|
||||
|
||||
extern ConVar gameinstructor_verbose;
|
||||
|
||||
|
||||
enum Mod_LessonAction
|
||||
{
|
||||
// Enum starts from end of LessonAction
|
||||
LESSON_ACTION_GAME_TYPE_IS = LESSON_ACTION_MOD_START,
|
||||
LESSON_ACTION_GAME_MODE_IS,
|
||||
LESSON_ACTION_CASUAL_OR_TRAINING,
|
||||
LESSON_ACTION_HAS_DEFUSER,
|
||||
LESSON_ACTION_HAS_ANY_ITEMS,
|
||||
LESSON_ACTION_HAS_MULTIPLE_ITEMS,
|
||||
LESSON_ACTION_HAS_MULTIPLE_WEAPONS,
|
||||
LESSON_ACTION_HAS_BUYMENU_OPEN,
|
||||
LESSON_ACTION_ROUND_STATE_IS,
|
||||
|
||||
LESSON_ACTION_TOTAL
|
||||
};
|
||||
|
||||
void CScriptedIconLesson::Mod_PreReadLessonsFromFile( void )
|
||||
{
|
||||
// Add custom actions to the map
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "game type is", LESSON_ACTION_GAME_TYPE_IS );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "game mode is", LESSON_ACTION_GAME_MODE_IS );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "is casual or training", LESSON_ACTION_CASUAL_OR_TRAINING );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "has defuser", LESSON_ACTION_HAS_DEFUSER );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "has any items", LESSON_ACTION_HAS_ANY_ITEMS );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "has multiple items", LESSON_ACTION_HAS_MULTIPLE_ITEMS );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "has multiple weapons", LESSON_ACTION_HAS_MULTIPLE_WEAPONS );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "is buymenu open", LESSON_ACTION_HAS_BUYMENU_OPEN );
|
||||
CScriptedIconLesson::LessonActionMap.Insert( "round state is", LESSON_ACTION_ROUND_STATE_IS ); //0=freezetime; 1=mid-round; 2=round is over;
|
||||
}
|
||||
|
||||
|
||||
bool CScriptedIconLesson::Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled )
|
||||
{
|
||||
// Assume we're going to handle the action
|
||||
bModHandled = true;
|
||||
|
||||
C_BaseEntity *pVar = hVar.Get();
|
||||
|
||||
switch ( iAction )
|
||||
{
|
||||
case LESSON_ACTION_GAME_TYPE_IS:
|
||||
{
|
||||
return ( bNot ) ? ( g_pGameTypes->GetCurrentGameType() != fParam ) : ( g_pGameTypes->GetCurrentGameType() == fParam );
|
||||
break;
|
||||
}
|
||||
case LESSON_ACTION_GAME_MODE_IS:
|
||||
{
|
||||
return ( bNot ) ? ( g_pGameTypes->GetCurrentGameMode() != fParam ) : ( g_pGameTypes->GetCurrentGameMode() == fParam );
|
||||
break;
|
||||
}
|
||||
case LESSON_ACTION_CASUAL_OR_TRAINING:
|
||||
{
|
||||
return ( (g_pGameTypes->GetCurrentGameType() == CS_GameType_Classic && g_pGameTypes->GetCurrentGameMode() == CS_GameMode::Classic_Casual) || g_pGameTypes->GetCurrentGameType() == CS_GameType_Training );
|
||||
break;
|
||||
}
|
||||
case LESSON_ACTION_HAS_DEFUSER:
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast< C_CSPlayer* >( pVar );
|
||||
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasDefuser()", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as CSPlayer returned NULL!\n" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bHasDefuser = pPlayer->HasDefuser();
|
||||
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSpareWeapon()", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasDefuser ? "true" : "false" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( !bHasDefuser ) : ( bHasDefuser );
|
||||
}
|
||||
|
||||
case LESSON_ACTION_HAS_ANY_ITEMS:
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast< C_CSPlayer* >( pVar );
|
||||
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->GetCSWeapon( ITEM )", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as CSPlayer returned NULL!\n" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bHasItem = false;
|
||||
for ( int i = ITEM_FIRST; i <= ITEM_MAX; i = i + 1 )
|
||||
{
|
||||
if ( pPlayer->GetCSWeapon( (CSWeaponID)i ) )
|
||||
{
|
||||
bHasItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->GetCSWeapon( ITEM )", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasItem ? "true" : "false" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( !bHasItem ) : ( bHasItem );
|
||||
}
|
||||
case LESSON_ACTION_HAS_MULTIPLE_ITEMS:
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast< C_CSPlayer* >( pVar );
|
||||
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] item count ", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as CSPlayer returned NULL!\n" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int nItems = 0;
|
||||
for ( int i = ITEM_FIRST; i <= ITEM_MAX; i++ )
|
||||
if ( pPlayer->GetCSWeapon( (CSWeaponID)i ) )
|
||||
nItems++;
|
||||
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] item count ", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%d ", ( nItems ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( nItems < 2 ) : ( nItems >= 2 );
|
||||
}
|
||||
case LESSON_ACTION_HAS_MULTIPLE_WEAPONS:
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast< C_CSPlayer* >( pVar );
|
||||
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] weapon count ", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as CSPlayer returned NULL!\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int nWeapons = 0;
|
||||
for ( int i = WEAPON_FIRST; i <= WEAPON_LAST; i++ )
|
||||
{
|
||||
if ( pPlayer->GetCSWeapon( (CSWeaponID)i ) )
|
||||
nWeapons++;
|
||||
}
|
||||
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] weapon count ", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%d ", ( nWeapons ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( nWeapons < 2 ) : ( nWeapons >= 2 );
|
||||
}
|
||||
case LESSON_ACTION_HAS_BUYMENU_OPEN:
|
||||
{
|
||||
C_CSPlayer *pPlayer = dynamic_cast< C_CSPlayer* >( pVar );
|
||||
if ( !pPlayer )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->IsBuyMenuOpen()", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as CSPlayer returned NULL!\n" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bHasMenuOpen = pPlayer->IsBuyMenuOpen();
|
||||
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->IsBuyMenuOpen()", pchVarName );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasMenuOpen ? "true" : "false" ) );
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( !bHasMenuOpen ) : ( bHasMenuOpen );
|
||||
}
|
||||
case LESSON_ACTION_ROUND_STATE_IS:
|
||||
{
|
||||
int RoundState;
|
||||
if ( CSGameRules()->IsFreezePeriod() )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t Round is in freeze time.\n" );
|
||||
}
|
||||
RoundState = 0;// freeze time
|
||||
}
|
||||
else if ( CSGameRules()->IsRoundOver() )
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t Round is over.\n" );
|
||||
}
|
||||
RoundState = 2;// round is over
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
|
||||
{
|
||||
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t Round is in progress.\n" );
|
||||
}
|
||||
RoundState = 1;// in the round
|
||||
}
|
||||
|
||||
return ( bNot ) ? ( RoundState != fParam ) : ( RoundState == fParam );
|
||||
}
|
||||
|
||||
default:
|
||||
// Didn't handle this action
|
||||
bModHandled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool C_GameInstructor::Mod_HiddenByOtherElements( void )
|
||||
{
|
||||
//C_ASW_Marine *pLocalMarine = C_ASW_Marine::GetLocalMarine();
|
||||
//if ( pLocalMarine && pLocalMarine->IsControllingTurret() )
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user