mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Merge branch 'develop' into feature/newer-toolsets
This commit is contained in:
@@ -784,6 +784,10 @@ C_BaseAnimating::C_BaseAnimating() :
|
||||
m_nPrevSequence = -1;
|
||||
m_nRestoreSequence = -1;
|
||||
m_pRagdoll = NULL;
|
||||
m_pClientsideRagdoll = NULL;
|
||||
#ifdef MAPBASE
|
||||
m_pServerRagdoll = NULL;
|
||||
#endif
|
||||
m_builtRagdoll = false;
|
||||
m_hitboxBoneCacheHandle = 0;
|
||||
int i;
|
||||
@@ -1986,6 +1990,10 @@ CollideType_t C_BaseAnimating::GetCollideType( void )
|
||||
return BaseClass::GetCollideType();
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
ConVar ai_death_pose_enabled( "ai_death_pose_enabled", "1", FCVAR_NONE, "Toggles the death pose fix code, which cancels sequence transitions while a NPC is ragdolling." );
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: if the active sequence changes, keep track of the previous ones and decay them based on their decay rate
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2002,6 +2010,14 @@ void C_BaseAnimating::MaintainSequenceTransitions( IBoneSetup &boneSetup, float
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
if ( IsAboutToRagdoll() && ai_death_pose_enabled.GetBool() )
|
||||
{
|
||||
m_nPrevNewSequenceParity = m_nNewSequenceParity;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_SequenceTransitioner.CheckForSequenceChange(
|
||||
boneSetup.GetStudioHdr(),
|
||||
GetSequence(),
|
||||
@@ -2781,14 +2797,29 @@ void C_BaseAnimating::CalculateIKLocks( float currentTime )
|
||||
|
||||
// debugoverlay->AddBoxOverlay( origin, Vector( -1, -1, -1 ), Vector( 1, 1, 1 ), QAngle( 0, 0, 0 ), 255, 0, 0, 0, 0 );
|
||||
|
||||
float d = (pTarget->est.pos - origin).Length();
|
||||
Vector vecDelta = (origin - pTarget->est.pos);
|
||||
float d = vecDelta.Length();
|
||||
|
||||
if ( d >= flDist)
|
||||
continue;
|
||||
|
||||
flDist = d;
|
||||
pTarget->SetPos( origin );
|
||||
pTarget->SetAngles( angles );
|
||||
#ifdef MAPBASE
|
||||
// For blending purposes, IK attachments should obey weight
|
||||
if ( pTarget->est.flWeight < 1.0f )
|
||||
{
|
||||
Quaternion qTarget;
|
||||
AngleQuaternion( angles, qTarget );
|
||||
|
||||
QuaternionSlerp( pTarget->est.q, qTarget, pTarget->est.flWeight, pTarget->est.q );
|
||||
pTarget->SetPos( pTarget->est.pos + (vecDelta * pTarget->est.flWeight) );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pTarget->SetPos( origin );
|
||||
pTarget->SetAngles( angles );
|
||||
}
|
||||
// debugoverlay->AddBoxOverlay( pTarget->est.pos, Vector( -pTarget->est.radius, -pTarget->est.radius, -pTarget->est.radius ), Vector( pTarget->est.radius, pTarget->est.radius, pTarget->est.radius), QAngle( 0, 0, 0 ), 0, 255, 0, 0, 0 );
|
||||
}
|
||||
|
||||
@@ -4948,26 +4979,26 @@ C_BaseAnimating *C_BaseAnimating::BecomeRagdollOnClient()
|
||||
{
|
||||
MoveToLastReceivedPosition( true );
|
||||
GetAbsOrigin();
|
||||
C_BaseAnimating *pRagdoll = CreateRagdollCopy();
|
||||
m_pClientsideRagdoll = CreateRagdollCopy();
|
||||
|
||||
matrix3x4_t boneDelta0[MAXSTUDIOBONES];
|
||||
matrix3x4_t boneDelta1[MAXSTUDIOBONES];
|
||||
matrix3x4_t currentBones[MAXSTUDIOBONES];
|
||||
const float boneDt = 0.1f;
|
||||
GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt );
|
||||
pRagdoll->InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt );
|
||||
m_pClientsideRagdoll->InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt );
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
// Hook for ragdolling
|
||||
if (m_ScriptScope.IsInitialized() && g_Hook_OnClientRagdoll.CanRunInScope( m_ScriptScope ))
|
||||
{
|
||||
// ragdoll
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pRagdoll->GetScriptInstance() ) };
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( m_pClientsideRagdoll->GetScriptInstance() ) };
|
||||
g_Hook_OnClientRagdoll.Call( m_ScriptScope, NULL, args );
|
||||
}
|
||||
#endif
|
||||
|
||||
return pRagdoll;
|
||||
return m_pClientsideRagdoll;
|
||||
}
|
||||
|
||||
bool C_BaseAnimating::InitAsClientRagdoll( const matrix3x4_t *pDeltaBones0, const matrix3x4_t *pDeltaBones1, const matrix3x4_t *pCurrentBonePosition, float boneDt, bool bFixedConstraints )
|
||||
|
||||
@@ -531,6 +531,10 @@ private:
|
||||
|
||||
public:
|
||||
CRagdoll *m_pRagdoll;
|
||||
C_BaseAnimating *m_pClientsideRagdoll; // From Alien Swarm SDK
|
||||
#ifdef MAPBASE
|
||||
C_BaseAnimating *m_pServerRagdoll; // Not from Alien Swarm SDK (note that this can exist without the entity having died)
|
||||
#endif
|
||||
|
||||
// Texture group to use
|
||||
int m_nSkin;
|
||||
|
||||
@@ -429,7 +429,8 @@ BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_AnimTimeMustBeFirst )
|
||||
END_RECV_TABLE()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
ScriptHook_t CBaseEntity::g_Hook_UpdateOnRemove;
|
||||
ScriptHook_t C_BaseEntity::g_Hook_UpdateOnRemove;
|
||||
ScriptHook_t C_BaseEntity::g_Hook_ModifyEmitSoundParams;
|
||||
#endif
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities" )
|
||||
@@ -555,7 +556,11 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetContextThink, "SetContextThink", "Set a think function on this entity." )
|
||||
|
||||
|
||||
DEFINE_SIMPLE_SCRIPTHOOK( CBaseEntity::g_Hook_UpdateOnRemove, "UpdateOnRemove", FIELD_VOID, "Called when the entity is being removed." )
|
||||
DEFINE_SIMPLE_SCRIPTHOOK( C_BaseEntity::g_Hook_UpdateOnRemove, "UpdateOnRemove", FIELD_VOID, "Called when the entity is being removed." )
|
||||
|
||||
BEGIN_SCRIPTHOOK( C_BaseEntity::g_Hook_ModifyEmitSoundParams, "ModifyEmitSoundParams", FIELD_VOID, "Called every time a sound is emitted on this entity, allowing for its parameters to be modified." )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "params", FIELD_HSCRIPT )
|
||||
END_SCRIPTHOOK()
|
||||
|
||||
#endif // MAPBASE_VSCRIPT
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ public:
|
||||
CScriptScope m_ScriptScope;
|
||||
|
||||
static ScriptHook_t g_Hook_UpdateOnRemove;
|
||||
static ScriptHook_t g_Hook_ModifyEmitSoundParams;
|
||||
#endif
|
||||
|
||||
// IClientUnknown overrides.
|
||||
|
||||
@@ -281,6 +281,7 @@ END_RECV_TABLE()
|
||||
RecvPropInt ( RECVINFO( m_spawnflags ), 0, RecvProxy_ShiftPlayerSpawnflags ),
|
||||
|
||||
RecvPropBool ( RECVINFO( m_bDrawPlayerModelExternally ) ),
|
||||
RecvPropBool ( RECVINFO( m_bInTriggerFall ) ),
|
||||
#endif
|
||||
|
||||
END_RECV_TABLE()
|
||||
@@ -331,7 +332,10 @@ END_RECV_TABLE()
|
||||
|
||||
RecvPropString( RECVINFO(m_szLastPlaceName) ),
|
||||
|
||||
RecvPropEHandle(RECVINFO(m_hPostProcessCtrl)), // Send to everybody - for spectating
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
RecvPropEHandle( RECVINFO( m_hPostProcessCtrl ) ), // Send to everybody - for spectating
|
||||
RecvPropEHandle( RECVINFO( m_hColorCorrectionCtrl ) ), // Send to everybody - for spectating
|
||||
#endif
|
||||
|
||||
#if defined USES_ECON_ITEMS
|
||||
RecvPropUtlVector( RECVINFO_UTLVECTOR( m_hMyWearables ), MAX_WEARABLES_SENT_FROM_SERVER, RecvPropEHandle(NULL, 0, 0) ),
|
||||
@@ -2917,6 +2921,7 @@ void C_BasePlayer::UpdateFogBlend( void )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2925,6 +2930,15 @@ C_PostProcessController* C_BasePlayer::GetActivePostProcessController() const
|
||||
return m_hPostProcessCtrl.Get();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
C_ColorCorrection* C_BasePlayer::GetActiveColorCorrection() const
|
||||
{
|
||||
return m_hColorCorrectionCtrl.Get();
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
#include "hintsystem.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "c_env_fog_controller.h"
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
#include "c_postprocesscontroller.h"
|
||||
#include "c_colorcorrection.h"
|
||||
#endif
|
||||
#include "igameevents.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
@@ -381,7 +384,10 @@ public:
|
||||
void UpdateFogController( void );
|
||||
void UpdateFogBlend( void );
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
C_PostProcessController* GetActivePostProcessController() const;
|
||||
C_ColorCorrection* GetActiveColorCorrection() const;
|
||||
#endif
|
||||
|
||||
float GetFOVTime( void ){ return m_flFOVTime; }
|
||||
|
||||
@@ -458,6 +464,8 @@ public:
|
||||
|
||||
// Allows the player's model to draw on non-main views, like monitors or mirrors.
|
||||
bool m_bDrawPlayerModelExternally;
|
||||
|
||||
bool m_bInTriggerFall;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@@ -645,7 +653,10 @@ private:
|
||||
// One for left and one for right side of step
|
||||
StepSoundCache_t m_StepSoundCache[ 2 ];
|
||||
|
||||
CNetworkHandle(C_PostProcessController, m_hPostProcessCtrl); // active postprocessing controller
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
CNetworkHandle( C_PostProcessController, m_hPostProcessCtrl ); // active postprocessing controller
|
||||
CNetworkHandle( C_ColorCorrection, m_hColorCorrectionCtrl ); // active FXVolume color correction
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_colorcorrection.h"
|
||||
#include "filesystem.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "colorcorrectionmgr.h"
|
||||
@@ -17,45 +18,27 @@
|
||||
|
||||
static ConVar mat_colcorrection_disableentities( "mat_colcorrection_disableentities", "0", FCVAR_NONE, "Disable map color-correction entities" );
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Color correction entity with radial falloff
|
||||
//------------------------------------------------------------------------------
|
||||
class C_ColorCorrection : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_ColorCorrection, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_ColorCorrection();
|
||||
virtual ~C_ColorCorrection();
|
||||
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
void ClientThink();
|
||||
|
||||
private:
|
||||
Vector m_vecOrigin;
|
||||
|
||||
float m_minFalloff;
|
||||
float m_maxFalloff;
|
||||
float m_flCurWeight;
|
||||
char m_netLookupFilename[MAX_PATH];
|
||||
|
||||
bool m_bEnabled;
|
||||
|
||||
ClientCCHandle_t m_CCHandle;
|
||||
};
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
static ConVar mat_colcorrection_forceentitiesclientside( "mat_colcorrection_forceentitiesclientside", "0", FCVAR_CHEAT, "Forces color correction entities to be updated on the client" );
|
||||
#endif
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_ColorCorrection, DT_ColorCorrection, CColorCorrection)
|
||||
RecvPropVector( RECVINFO(m_vecOrigin) ),
|
||||
RecvPropFloat( RECVINFO(m_minFalloff) ),
|
||||
RecvPropFloat( RECVINFO(m_maxFalloff) ),
|
||||
RecvPropFloat( RECVINFO(m_flCurWeight) ),
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
RecvPropFloat( RECVINFO(m_flMaxWeight) ),
|
||||
RecvPropFloat( RECVINFO(m_flFadeInDuration) ),
|
||||
RecvPropFloat( RECVINFO(m_flFadeOutDuration) ),
|
||||
#endif
|
||||
RecvPropString( RECVINFO(m_netLookupFilename) ),
|
||||
RecvPropBool( RECVINFO(m_bEnabled) ),
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
RecvPropBool( RECVINFO(m_bMaster) ),
|
||||
RecvPropBool( RECVINFO(m_bClientSide) ),
|
||||
RecvPropBool( RECVINFO(m_bExclusive) )
|
||||
#endif
|
||||
|
||||
END_RECV_TABLE()
|
||||
|
||||
@@ -65,14 +48,43 @@ END_RECV_TABLE()
|
||||
//------------------------------------------------------------------------------
|
||||
C_ColorCorrection::C_ColorCorrection()
|
||||
{
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
m_minFalloff = -1.0f;
|
||||
m_maxFalloff = -1.0f;
|
||||
m_flFadeInDuration = 0.0f;
|
||||
m_flFadeOutDuration = 0.0f;
|
||||
m_flCurWeight = 0.0f;
|
||||
m_flMaxWeight = 1.0f;
|
||||
m_netLookupFilename[0] = '\0';
|
||||
m_bEnabled = false;
|
||||
m_bMaster = false;
|
||||
m_bExclusive = false;
|
||||
#endif
|
||||
m_CCHandle = INVALID_CLIENT_CCHANDLE;
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
m_bFadingIn = false;
|
||||
m_flFadeStartWeight = 0.0f;
|
||||
m_flFadeStartTime = 0.0f;
|
||||
m_flFadeDuration = 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
C_ColorCorrection::~C_ColorCorrection()
|
||||
{
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
g_pColorCorrectionMgr->RemoveColorCorrectionEntity( this, m_CCHandle );
|
||||
#else
|
||||
g_pColorCorrectionMgr->RemoveColorCorrection( m_CCHandle );
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
bool C_ColorCorrection::IsClientSide() const
|
||||
{
|
||||
return m_bClientSide || mat_colcorrection_forceentitiesclientside.GetBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose :
|
||||
@@ -87,11 +99,21 @@ void C_ColorCorrection::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
// forming a unique name without extension
|
||||
char cleanName[MAX_PATH];
|
||||
V_StripExtension( m_netLookupFilename, cleanName, sizeof( cleanName ) );
|
||||
char name[MAX_PATH];
|
||||
Q_snprintf( name, MAX_PATH, "%s_%d", cleanName, entindex() );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrectionEntity( this, name, m_netLookupFilename );
|
||||
#else
|
||||
char filename[MAX_PATH];
|
||||
Q_strncpy( filename, m_netLookupFilename, MAX_PATH );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrection( filename );
|
||||
SetNextClientThink( ( m_CCHandle != INVALID_CLIENT_CCHANDLE ) ? CLIENT_THINK_ALWAYS : CLIENT_THINK_NEVER );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +126,129 @@ bool C_ColorCorrection::ShouldDraw()
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale )
|
||||
{
|
||||
Assert( m_CCHandle != INVALID_CLIENT_CCHANDLE );
|
||||
|
||||
if ( mat_colcorrection_disableentities.GetInt() )
|
||||
{
|
||||
// Allow the colorcorrectionui panel (or user) to turn off color-correction entities
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive );
|
||||
return;
|
||||
}
|
||||
|
||||
// fade weight on client
|
||||
if ( IsClientSide() )
|
||||
{
|
||||
m_flCurWeight = Lerp( GetFadeRatio(), m_flFadeStartWeight, m_bFadingIn ? m_flMaxWeight : 0.0f );
|
||||
}
|
||||
|
||||
if( !m_bEnabled && m_flCurWeight == 0.0f )
|
||||
{
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive );
|
||||
return;
|
||||
}
|
||||
|
||||
Vector playerOrigin = pPlayer->GetAbsOrigin();
|
||||
|
||||
float weight = 0;
|
||||
if ( ( m_minFalloff != -1 ) && ( m_maxFalloff != -1 ) && m_minFalloff != m_maxFalloff )
|
||||
{
|
||||
float dist = (playerOrigin - m_vecOrigin).Length();
|
||||
weight = (dist-m_minFalloff) / (m_maxFalloff-m_minFalloff);
|
||||
if ( weight<0.0f ) weight = 0.0f;
|
||||
if ( weight>1.0f ) weight = 1.0f;
|
||||
}
|
||||
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_flCurWeight * ( 1.0 - weight ) * ccScale, m_bExclusive );
|
||||
}
|
||||
|
||||
void C_ColorCorrection::EnableOnClient( bool bEnable, bool bSkipFade )
|
||||
{
|
||||
if ( !IsClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_bFadingIn = bEnable;
|
||||
|
||||
// initialize countdown timer
|
||||
m_flFadeStartWeight = m_flCurWeight;
|
||||
float flFadeTimeScale = 1.0f;
|
||||
if ( m_flMaxWeight != 0.0f )
|
||||
{
|
||||
flFadeTimeScale = m_flCurWeight / m_flMaxWeight;
|
||||
}
|
||||
|
||||
if ( m_bFadingIn )
|
||||
{
|
||||
flFadeTimeScale = 1.0f - flFadeTimeScale;
|
||||
}
|
||||
|
||||
if ( bSkipFade )
|
||||
{
|
||||
flFadeTimeScale = 0.0f;
|
||||
}
|
||||
|
||||
StartFade( flFadeTimeScale * ( m_bFadingIn ? m_flFadeInDuration : m_flFadeOutDuration ) );
|
||||
|
||||
// update the clientside weight once here, in case the fade duration is 0
|
||||
m_flCurWeight = Lerp( GetFadeRatio(), m_flFadeStartWeight, m_bFadingIn ? m_flMaxWeight : 0.0f );
|
||||
}
|
||||
|
||||
Vector C_ColorCorrection::GetOrigin()
|
||||
{
|
||||
return m_vecOrigin;
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetMinFalloff()
|
||||
{
|
||||
return m_minFalloff;
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetMaxFalloff()
|
||||
{
|
||||
return m_maxFalloff;
|
||||
}
|
||||
|
||||
void C_ColorCorrection::SetWeight( float fWeight )
|
||||
{
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, fWeight, false );
|
||||
}
|
||||
|
||||
void C_ColorCorrection::StartFade( float flDuration )
|
||||
{
|
||||
m_flFadeStartTime = gpGlobals->curtime;
|
||||
m_flFadeDuration = MAX( flDuration, 0.0f );
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetFadeRatio() const
|
||||
{
|
||||
float flRatio = 1.0f;
|
||||
|
||||
if ( m_flFadeDuration != 0.0f )
|
||||
{
|
||||
flRatio = ( gpGlobals->curtime - m_flFadeStartTime ) / m_flFadeDuration;
|
||||
flRatio = clamp( flRatio, 0.0f, 1.0f );
|
||||
}
|
||||
return flRatio;
|
||||
}
|
||||
|
||||
bool C_ColorCorrection::IsFadeTimeElapsed() const
|
||||
{
|
||||
return ( ( gpGlobals->curtime - m_flFadeStartTime ) > m_flFadeDuration ) ||
|
||||
( ( gpGlobals->curtime - m_flFadeStartTime ) < 0.0f );
|
||||
}
|
||||
|
||||
void UpdateColorCorrectionEntities( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrection **pList, int listCount )
|
||||
{
|
||||
for ( int i = 0; i < listCount; i++ )
|
||||
{
|
||||
pList[i]->Update(pPlayer, ccScale);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void C_ColorCorrection::ClientThink()
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
@@ -141,6 +286,7 @@ void C_ColorCorrection::ClientThink()
|
||||
|
||||
BaseClass::ClientThink();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||
//
|
||||
// Note that this header exists in the Alien Swarm SDK, but not in stock Source SDK 2013.
|
||||
// Although technically a new Mapbase file, it only serves to move otherwise identical code,
|
||||
// so most code and repo conventions will pretend it was always there.
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
// Purpose: Color correction entity with simple radial falloff
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_COLORCORRECTION_H
|
||||
#define C_COLORCORRECTION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "colorcorrectionmgr.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Color correction entity with radial falloff
|
||||
//------------------------------------------------------------------------------
|
||||
class C_ColorCorrection : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_ColorCorrection, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_ColorCorrection();
|
||||
virtual ~C_ColorCorrection();
|
||||
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
virtual void Update(C_BasePlayer *pPlayer, float ccScale);
|
||||
|
||||
bool IsMaster() const { return m_bMaster; }
|
||||
bool IsClientSide() const;
|
||||
bool IsExclusive() const { return m_bExclusive; }
|
||||
|
||||
void EnableOnClient( bool bEnable, bool bSkipFade = false );
|
||||
|
||||
Vector GetOrigin();
|
||||
float GetMinFalloff();
|
||||
float GetMaxFalloff();
|
||||
|
||||
void SetWeight( float fWeight );
|
||||
|
||||
protected:
|
||||
void StartFade( float flDuration );
|
||||
float GetFadeRatio() const;
|
||||
bool IsFadeTimeElapsed() const;
|
||||
#else
|
||||
void ClientThink();
|
||||
|
||||
private:
|
||||
#endif
|
||||
Vector m_vecOrigin;
|
||||
|
||||
float m_minFalloff;
|
||||
float m_maxFalloff;
|
||||
float m_flCurWeight;
|
||||
char m_netLookupFilename[MAX_PATH];
|
||||
|
||||
bool m_bEnabled;
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
float m_flFadeInDuration;
|
||||
float m_flFadeOutDuration;
|
||||
float m_flMaxWeight;
|
||||
|
||||
bool m_bMaster;
|
||||
bool m_bClientSide;
|
||||
bool m_bExclusive;
|
||||
|
||||
bool m_bFadingIn;
|
||||
float m_flFadeStartWeight;
|
||||
float m_flFadeStartTime;
|
||||
float m_flFadeDuration;
|
||||
#endif
|
||||
|
||||
ClientCCHandle_t m_CCHandle;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -36,9 +36,26 @@ public:
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void Update( C_BasePlayer *pPlayer, float ccScale );
|
||||
|
||||
void StartTouch( C_BaseEntity *pOther );
|
||||
void EndTouch( C_BaseEntity *pOther );
|
||||
#else
|
||||
void ClientThink();
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
float m_LastEnterWeight;
|
||||
float m_LastEnterTime;
|
||||
|
||||
float m_LastExitWeight;
|
||||
float m_LastExitTime;
|
||||
bool m_bEnabled;
|
||||
float m_MaxWeight;
|
||||
float m_FadeDuration;
|
||||
#endif
|
||||
float m_Weight;
|
||||
char m_lookupFilename[MAX_PATH];
|
||||
|
||||
@@ -46,6 +63,11 @@ private:
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_ColorCorrectionVolume, DT_ColorCorrectionVolume, CColorCorrectionVolume)
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
RecvPropBool( RECVINFO( m_bEnabled ) ),
|
||||
RecvPropFloat( RECVINFO( m_MaxWeight ) ),
|
||||
RecvPropFloat( RECVINFO( m_FadeDuration ) ),
|
||||
#endif
|
||||
RecvPropFloat( RECVINFO(m_Weight) ),
|
||||
RecvPropString( RECVINFO(m_lookupFilename) ),
|
||||
END_RECV_TABLE()
|
||||
@@ -82,11 +104,21 @@ void C_ColorCorrectionVolume::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
// forming a unique name without extension
|
||||
char cleanName[MAX_PATH];
|
||||
V_StripExtension( m_lookupFilename, cleanName, sizeof( cleanName ) );
|
||||
char name[MAX_PATH];
|
||||
Q_snprintf( name, MAX_PATH, "%s_%d", cleanName, entindex() );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrectionVolume( this, name, m_lookupFilename );
|
||||
#else
|
||||
char filename[MAX_PATH];
|
||||
Q_strncpy( filename, m_lookupFilename, MAX_PATH );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrection( filename );
|
||||
SetNextClientThink( ( m_CCHandle != INVALID_CLIENT_CCHANDLE ) ? CLIENT_THINK_ALWAYS : CLIENT_THINK_NEVER );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,11 +131,95 @@ bool C_ColorCorrectionVolume::ShouldDraw()
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_ColorCorrectionVolume::StartTouch( CBaseEntity *pEntity )
|
||||
{
|
||||
m_LastEnterTime = gpGlobals->curtime;
|
||||
m_LastEnterWeight = m_Weight;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_ColorCorrectionVolume::EndTouch( CBaseEntity *pEntity )
|
||||
{
|
||||
m_LastExitTime = gpGlobals->curtime;
|
||||
m_LastExitWeight = m_Weight;
|
||||
}
|
||||
|
||||
|
||||
void C_ColorCorrectionVolume::Update( C_BasePlayer *pPlayer, float ccScale )
|
||||
{
|
||||
if ( pPlayer )
|
||||
{
|
||||
bool isTouching = CollisionProp()->IsPointInBounds( pPlayer->EyePosition() );
|
||||
bool wasTouching = m_LastEnterTime > m_LastExitTime;
|
||||
|
||||
if ( isTouching && !wasTouching )
|
||||
{
|
||||
StartTouch( pPlayer );
|
||||
}
|
||||
else if ( !isTouching && wasTouching )
|
||||
{
|
||||
EndTouch( pPlayer );
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_bEnabled )
|
||||
{
|
||||
m_Weight = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_LastEnterTime > m_LastExitTime )
|
||||
{
|
||||
// we most recently entered the volume
|
||||
|
||||
if( m_Weight < 1.0f )
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_LastEnterTime;
|
||||
float weight = m_LastEnterWeight + dt / ((1.0f-m_LastEnterWeight)*m_FadeDuration);
|
||||
if( weight>1.0f )
|
||||
weight = 1.0f;
|
||||
|
||||
m_Weight = weight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we most recently exitted the volume
|
||||
|
||||
if( m_Weight > 0.0f )
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_LastExitTime;
|
||||
float weight = (1.0f-m_LastExitWeight) + dt / (m_LastExitWeight*m_FadeDuration);
|
||||
if( weight>1.0f )
|
||||
weight = 1.0f;
|
||||
|
||||
m_Weight = 1.0f - weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Vector entityPosition = GetAbsOrigin();
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_Weight * ccScale );
|
||||
}
|
||||
|
||||
|
||||
void UpdateColorCorrectionVolumes( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrectionVolume **pList, int listCount )
|
||||
{
|
||||
for ( int i = 0; i < listCount; i++ )
|
||||
{
|
||||
pList[i]->Update(pPlayer, ccScale);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void C_ColorCorrectionVolume::ClientThink()
|
||||
{
|
||||
Vector entityPosition = GetAbsOrigin();
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_Weight );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,10 @@ ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "20", FCVAR_CHEAT ); //
|
||||
ConVar r_RainParticleDensity( "r_RainParticleDensity", "1", FCVAR_NONE, "Density of Particle Rain 0-1" );
|
||||
|
||||
#ifdef MAPBASE
|
||||
ConVar r_RainParticleClampOffset( "r_RainParticleClampOffset", "112", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems" );
|
||||
ConVar r_RainParticleClampOffset_Rain( "r_RainParticleClampOffset_Rain", "120", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems using the 'Particle Rain' type." );
|
||||
ConVar r_RainParticleClampOffset_Ash( "r_RainParticleClampOffset_Ash", "300", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems using the 'Particle Ash' type." );
|
||||
ConVar r_RainParticleClampOffset_RainStorm( "r_RainParticleClampOffset_RainStorm", "112", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems using the 'Particle Rain Storm' type." );
|
||||
ConVar r_RainParticleClampOffset_Snow( "r_RainParticleClampOffset_Snow", "300", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems using the 'Particle Snow' type." );
|
||||
ConVar r_RainParticleClampDebug( "r_RainParticleClampDebug", "0", FCVAR_NONE, "Enables debug code for precipitation particle system clamping" );
|
||||
#endif
|
||||
|
||||
@@ -951,6 +954,70 @@ void CClient_Precipitation::CreateParticlePrecip( void )
|
||||
UpdateParticlePrecip( pPlayer );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
void CClient_Precipitation::ClampParticlePosition( Vector &vPlayerPos, Vector &vOffsetPos, Vector &vOffsetPosNear, Vector &vOffsetPosFar )
|
||||
{
|
||||
Vector mins, maxs;
|
||||
modelinfo->GetModelBounds( GetModel(), mins, maxs );
|
||||
|
||||
// Account for precipitation height
|
||||
maxs.z += 180;
|
||||
|
||||
Vector vecOrigin; //= WorldSpaceCenter();
|
||||
VectorLerp( mins, maxs, 0.5f, vecOrigin );
|
||||
|
||||
maxs -= vecOrigin;
|
||||
mins -= vecOrigin;
|
||||
|
||||
//float flMax = r_RainParticleClampOffset.GetFloat();
|
||||
float flMax = 0;
|
||||
switch (m_nPrecipType)
|
||||
{
|
||||
case PRECIPITATION_TYPE_PARTICLERAIN:
|
||||
flMax = r_RainParticleClampOffset_Rain.GetFloat();
|
||||
break;
|
||||
|
||||
case PRECIPITATION_TYPE_PARTICLEASH:
|
||||
flMax = r_RainParticleClampOffset_Ash.GetFloat();
|
||||
break;
|
||||
|
||||
case PRECIPITATION_TYPE_PARTICLERAINSTORM:
|
||||
flMax = r_RainParticleClampOffset_RainStorm.GetFloat();
|
||||
break;
|
||||
|
||||
case PRECIPITATION_TYPE_PARTICLESNOW:
|
||||
flMax = r_RainParticleClampOffset_Snow.GetFloat();
|
||||
break;
|
||||
}
|
||||
|
||||
Vector addend( flMax, flMax, 0 );
|
||||
mins += addend;
|
||||
maxs -= addend;
|
||||
|
||||
if (flMax > 0)
|
||||
{
|
||||
// Unless this is extruding outwards, make sure the offset isn't inverting the bounds.
|
||||
// This means precipitation triggers with bounds less than offset*2 will turn into a thin line
|
||||
// and the involved precipitation will pretty much be spatial at all times, which is okay.
|
||||
mins.x = clamp( mins.x, -FLT_MAX, -1 );
|
||||
mins.y = clamp( mins.y, -FLT_MAX, -1 );
|
||||
maxs.x = clamp( maxs.x, 1, FLT_MAX );
|
||||
maxs.y = clamp( maxs.y, 1, FLT_MAX );
|
||||
}
|
||||
|
||||
if (r_RainParticleClampDebug.GetBool())
|
||||
debugoverlay->AddBoxOverlay( vecOrigin, mins, maxs, vec3_angle, 255, 0, 0, 128, 0.15f );
|
||||
|
||||
maxs += vecOrigin;
|
||||
mins += vecOrigin;
|
||||
|
||||
CalcClosestPointOnAABB( mins, maxs, vPlayerPos, vPlayerPos );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPos, vOffsetPos );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPosNear, vOffsetPosNear );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPosFar, vOffsetPosFar );
|
||||
}
|
||||
#endif
|
||||
|
||||
void CClient_Precipitation::UpdateParticlePrecip( C_BasePlayer *pPlayer )
|
||||
{
|
||||
if ( !pPlayer )
|
||||
@@ -980,44 +1047,7 @@ void CClient_Precipitation::UpdateParticlePrecip( C_BasePlayer *pPlayer )
|
||||
#ifdef MAPBASE
|
||||
if (m_spawnflags & SF_PRECIP_PARTICLE_CLAMP)
|
||||
{
|
||||
Vector mins, maxs;
|
||||
modelinfo->GetModelBounds( GetModel(), mins, maxs );
|
||||
|
||||
// Account for precipitation height
|
||||
maxs.z += 180;
|
||||
|
||||
Vector vecOrigin; //= WorldSpaceCenter();
|
||||
VectorLerp( mins, maxs, 0.5f, vecOrigin );
|
||||
|
||||
maxs -= vecOrigin;
|
||||
mins -= vecOrigin;
|
||||
|
||||
float flMax = r_RainParticleClampOffset.GetFloat();
|
||||
Vector addend( flMax, flMax, 0 );
|
||||
mins += addend;
|
||||
maxs -= addend;
|
||||
|
||||
if (flMax > 0)
|
||||
{
|
||||
// Unless this is extruding outwards, make sure the offset isn't inverting the bounds.
|
||||
// This means precipitation triggers with bounds less than offset*2 will turn into a thin line
|
||||
// and the involved precipitation will pretty much be spatial at all times, which is okay.
|
||||
mins.x = clamp( mins.x, -FLT_MAX, -1 );
|
||||
mins.y = clamp( mins.y, -FLT_MAX, -1 );
|
||||
maxs.x = clamp( maxs.x, 1, FLT_MAX );
|
||||
maxs.y = clamp( maxs.y, 1, FLT_MAX );
|
||||
}
|
||||
|
||||
if (r_RainParticleClampDebug.GetBool())
|
||||
debugoverlay->AddBoxOverlay( vecOrigin, mins, maxs, vec3_angle, 255, 0, 0, 128, 0.15f );
|
||||
|
||||
maxs += vecOrigin;
|
||||
mins += vecOrigin;
|
||||
|
||||
CalcClosestPointOnAABB( mins, maxs, vPlayerPos, vPlayerPos );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPos, vOffsetPos );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPosNear, vOffsetPosNear );
|
||||
CalcClosestPointOnAABB( mins, maxs, vOffsetPosFar, vOffsetPosFar );
|
||||
ClampParticlePosition( vPlayerPos, vOffsetPos, vOffsetPosNear, vOffsetPosFar );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1236,6 +1266,13 @@ void CClient_Precipitation::DispatchInnerParticlePrecip( C_BasePlayer *pPlayer,
|
||||
Vector vOffsetPosFar = vPlayerPos + Vector ( 0, 0, 180 ) + ( vForward * m_flParticleInnerDist ); // 100.0
|
||||
Vector vDensity = Vector( r_RainParticleDensity.GetFloat(), 0, 0 ) * m_flDensity;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (m_spawnflags & SF_PRECIP_PARTICLE_CLAMP)
|
||||
{
|
||||
ClampParticlePosition( vPlayerPos, vOffsetPos, vOffsetPosNear, vOffsetPosFar );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (!(m_spawnflags & SF_PRECIP_PARTICLE_NO_OUTER))
|
||||
#endif
|
||||
|
||||
@@ -130,6 +130,10 @@ private:
|
||||
void CreateAshParticle( void );
|
||||
void CreateRainOrSnowParticle( Vector vSpawnPosition, Vector vVelocity );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void ClampParticlePosition( Vector &vPlayerPos, Vector &vOffsetPos, Vector &vOffsetPosNear, Vector &vOffsetPosFar );
|
||||
#endif
|
||||
|
||||
// Information helpful in creating and rendering particles
|
||||
IMaterial *m_MatHandle; // material used
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ protected:
|
||||
int m_iCachedDesiredOverlay;
|
||||
int m_iCurrentOverlay;
|
||||
float m_flCurrentOverlayTime;
|
||||
#ifdef MAPBASE
|
||||
int m_iOverlayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_EnvScreenOverlay, DT_EnvScreenOverlay, CEnvScreenOverlay )
|
||||
@@ -56,6 +59,9 @@ IMPLEMENT_CLIENTCLASS_DT( C_EnvScreenOverlay, DT_EnvScreenOverlay, CEnvScreenOve
|
||||
RecvPropFloat( RECVINFO( m_flStartTime ) ),
|
||||
RecvPropInt( RECVINFO( m_iDesiredOverlay ) ),
|
||||
RecvPropBool( RECVINFO( m_bIsActive ) ),
|
||||
#ifdef MAPBASE
|
||||
RecvPropInt( RECVINFO( m_iOverlayIndex ) ),
|
||||
#endif
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -77,7 +83,11 @@ void C_EnvScreenOverlay::PostDataUpdate( DataUpdateType_t updateType )
|
||||
BaseClass::PostDataUpdate( updateType );
|
||||
|
||||
// If we have a start time now, start the overlays going
|
||||
#ifdef MAPBASE
|
||||
if ( m_bIsActive && m_flStartTime > 0 && (view->GetScreenOverlayMaterial() == NULL || (m_iOverlayIndex != -1 && view->GetIndexedScreenOverlayMaterial(m_iOverlayIndex) == NULL)) )
|
||||
#else
|
||||
if ( m_bIsActive && m_flStartTime > 0 && view->GetScreenOverlayMaterial() == NULL )
|
||||
#endif
|
||||
{
|
||||
StartOverlays();
|
||||
}
|
||||
@@ -111,7 +121,16 @@ void C_EnvScreenOverlay::StopOverlays( void )
|
||||
|
||||
if ( m_bWasActive && !m_bIsActive )
|
||||
{
|
||||
view->SetScreenOverlayMaterial( NULL );
|
||||
#ifdef MAPBASE
|
||||
if (m_iOverlayIndex != -1)
|
||||
{
|
||||
view->SetIndexedScreenOverlayMaterial( m_iOverlayIndex, NULL );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
view->SetScreenOverlayMaterial( NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +182,16 @@ void C_EnvScreenOverlay::StartCurrentOverlay( void )
|
||||
IMaterial *pMaterial = materials->FindMaterial( m_iszOverlayNames[m_iCurrentOverlay], TEXTURE_GROUP_CLIENT_EFFECTS, false );
|
||||
if ( !IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
view->SetScreenOverlayMaterial( pMaterial );
|
||||
#ifdef MAPBASE
|
||||
if (m_iOverlayIndex != -1)
|
||||
{
|
||||
view->SetIndexedScreenOverlayMaterial( m_iOverlayIndex, pMaterial );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
view->SetScreenOverlayMaterial( pMaterial );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -112,6 +112,15 @@ public:
|
||||
C_BasePlayer *GetPlayerOwner( void );
|
||||
bool IsInputOnlyToOwner( void );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void GetSize( float &width, float &height ) const { width = m_flWidth; height = m_flHeight; }
|
||||
void GetPixelSize( int &width, int &height ) const { width = m_nPixelWidth; height = m_nPixelHeight; }
|
||||
void SetWidth( float flWidth ) { m_flWidth = flWidth; }
|
||||
void SetHeight( float flHeight ) { m_flHeight = flHeight; }
|
||||
void SetPixelWidth( int nWidth ) { m_nPixelWidth = nWidth; }
|
||||
void SetPixelHeight( int nHeight ) { m_nPixelHeight = nHeight; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Vgui screen management
|
||||
void CreateVguiScreen( const char *pTypeName );
|
||||
|
||||
@@ -292,8 +292,11 @@ ClientModeShared::ClientModeShared()
|
||||
m_pWeaponSelection = NULL;
|
||||
m_nRootSize[ 0 ] = m_nRootSize[ 1 ] = -1;
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
m_pCurrentPostProcessController = NULL;
|
||||
m_PostProcessLerpTimer.Invalidate();
|
||||
m_pCurrentColorCorrection = NULL;
|
||||
#endif
|
||||
|
||||
#if defined( REPLAY_ENABLED )
|
||||
m_pReplayReminderPanel = NULL;
|
||||
@@ -635,6 +638,43 @@ void ClientModeShared::Update()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ClientModeShared::OnColorCorrectionWeightsReset( void )
|
||||
{
|
||||
C_ColorCorrection *pNewColorCorrection = NULL;
|
||||
C_ColorCorrection *pOldColorCorrection = m_pCurrentColorCorrection;
|
||||
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( pPlayer )
|
||||
{
|
||||
pNewColorCorrection = pPlayer->GetActiveColorCorrection();
|
||||
}
|
||||
|
||||
if ( pNewColorCorrection != pOldColorCorrection )
|
||||
{
|
||||
if ( pOldColorCorrection )
|
||||
{
|
||||
pOldColorCorrection->EnableOnClient( false );
|
||||
}
|
||||
if ( pNewColorCorrection )
|
||||
{
|
||||
pNewColorCorrection->EnableOnClient( true, pOldColorCorrection == NULL );
|
||||
}
|
||||
m_pCurrentColorCorrection = pNewColorCorrection;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
float ClientModeShared::GetColorCorrectionScale( void ) const
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This processes all input before SV Move messages are sent
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -91,6 +91,11 @@ public:
|
||||
virtual void ProcessInput(bool bActive);
|
||||
virtual bool CreateMove( float flInputSampleTime, CUserCmd *cmd );
|
||||
virtual void Update();
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
virtual void OnColorCorrectionWeightsReset( void );
|
||||
virtual float GetColorCorrectionScale( void ) const;
|
||||
virtual void ClearCurrentColorCorrection() { m_pCurrentColorCorrection = NULL; }
|
||||
#endif
|
||||
|
||||
// Input
|
||||
virtual int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
|
||||
@@ -165,12 +170,16 @@ private:
|
||||
CBaseHudWeaponSelection *m_pWeaponSelection;
|
||||
int m_nRootSize[2];
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void UpdatePostProcessingEffects();
|
||||
|
||||
const C_PostProcessController* m_pCurrentPostProcessController;
|
||||
PostProcessParameters_t m_CurrentPostProcessParameters;
|
||||
PostProcessParameters_t m_LerpStartPostProcessParameters, m_LerpEndPostProcessParameters;
|
||||
CountdownTimer m_PostProcessLerpTimer;
|
||||
|
||||
CHandle<C_ColorCorrection> m_pCurrentColorCorrection;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // CLIENTMODE_NORMAL_H
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
#include "cbase.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "colorcorrectionmgr.h"
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
#include "clientmode_shared.h" //"clientmode.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -16,6 +22,13 @@
|
||||
static CColorCorrectionMgr s_ColorCorrectionMgr;
|
||||
CColorCorrectionMgr *g_pColorCorrectionMgr = &s_ColorCorrectionMgr;
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
static ConVar mat_colcorrection_editor( "mat_colcorrection_editor", "0" );
|
||||
|
||||
static CUtlVector<C_ColorCorrection *> g_ColorCorrectionList;
|
||||
static CUtlVector<C_ColorCorrectionVolume *> g_ColorCorrectionVolumeList;
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Constructor
|
||||
@@ -62,10 +75,89 @@ void CColorCorrectionMgr::RemoveColorCorrection( ClientCCHandle_t h )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
ClientCCHandle_t CColorCorrectionMgr::AddColorCorrectionEntity( C_ColorCorrection *pEntity, const char *pName, const char *pFileName )
|
||||
{
|
||||
ClientCCHandle_t h = AddColorCorrection(pName, pFileName);
|
||||
if ( h != INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
Assert(g_ColorCorrectionList.Find(pEntity) == -1);
|
||||
g_ColorCorrectionList.AddToTail(pEntity);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
void CColorCorrectionMgr::RemoveColorCorrectionEntity( C_ColorCorrection *pEntity, ClientCCHandle_t h)
|
||||
{
|
||||
RemoveColorCorrection(h);
|
||||
g_ColorCorrectionList.FindAndFastRemove(pEntity);
|
||||
}
|
||||
|
||||
ClientCCHandle_t CColorCorrectionMgr::AddColorCorrectionVolume( C_ColorCorrectionVolume *pVolume, const char *pName, const char *pFileName )
|
||||
{
|
||||
ClientCCHandle_t h = AddColorCorrection(pName, pFileName);
|
||||
if ( h != INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
Assert(g_ColorCorrectionVolumeList.Find(pVolume) == -1);
|
||||
g_ColorCorrectionVolumeList.AddToTail(pVolume);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
void CColorCorrectionMgr::RemoveColorCorrectionVolume( C_ColorCorrectionVolume *pVolume, ClientCCHandle_t h)
|
||||
{
|
||||
RemoveColorCorrection(h);
|
||||
g_ColorCorrectionVolumeList.FindAndFastRemove(pVolume);
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Modify color correction weights
|
||||
//------------------------------------------------------------------------------
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive )
|
||||
{
|
||||
if ( h != INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
SetWeightParams_t params = { h, flWeight, bExclusive };
|
||||
m_colorCorrectionWeights.AddToTail( params );
|
||||
if( bExclusive && m_bHaveExclusiveWeight && ( flWeight != 0.0f ) )
|
||||
{
|
||||
DevWarning( "Found multiple active color_correction entities with exclusive setting enabled. This is invalid.\n" );
|
||||
}
|
||||
if ( bExclusive )
|
||||
{
|
||||
m_bHaveExclusiveWeight = true;
|
||||
m_flExclusiveWeight = flWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CColorCorrectionMgr::CommitColorCorrectionWeights()
|
||||
{
|
||||
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
|
||||
|
||||
for ( int i = 0; i < m_colorCorrectionWeights.Count(); i++ )
|
||||
{
|
||||
ColorCorrectionHandle_t ccHandle = reinterpret_cast<ColorCorrectionHandle_t>( m_colorCorrectionWeights[i].handle );
|
||||
float flWeight = m_colorCorrectionWeights[i].flWeight;
|
||||
if ( !m_colorCorrectionWeights[i].bExclusive )
|
||||
{
|
||||
flWeight = (1.0f - m_flExclusiveWeight ) * m_colorCorrectionWeights[i].flWeight;
|
||||
}
|
||||
pRenderContext->SetLookupWeight( ccHandle, flWeight );
|
||||
|
||||
// FIXME: NOTE! This doesn't work if the same handle has
|
||||
// its weight set twice with no intervening calls to ResetColorCorrectionWeights
|
||||
// which, at the moment, is true
|
||||
if ( flWeight != 0.0f )
|
||||
{
|
||||
++m_nActiveWeightCount;
|
||||
}
|
||||
}
|
||||
m_colorCorrectionWeights.RemoveAll();
|
||||
}
|
||||
#else
|
||||
void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight )
|
||||
{
|
||||
if ( h != INVALID_CLIENT_CCHANDLE )
|
||||
@@ -83,6 +175,7 @@ void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float fl
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CColorCorrectionMgr::ResetColorCorrectionWeights()
|
||||
{
|
||||
@@ -93,6 +186,11 @@ void CColorCorrectionMgr::ResetColorCorrectionWeights()
|
||||
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
|
||||
pRenderContext->ResetLookupWeights();
|
||||
m_nActiveWeightCount = 0;
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
m_bHaveExclusiveWeight = false;
|
||||
m_flExclusiveWeight = 0.0f;
|
||||
m_colorCorrectionWeights.RemoveAll();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CColorCorrectionMgr::SetResetable( ClientCCHandle_t h, bool bResetable )
|
||||
@@ -113,7 +211,34 @@ void CColorCorrectionMgr::SetResetable( ClientCCHandle_t h, bool bResetable )
|
||||
//------------------------------------------------------------------------------
|
||||
// Is color correction active?
|
||||
//------------------------------------------------------------------------------
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
bool CColorCorrectionMgr::HasNonZeroColorCorrectionWeights() const
|
||||
{
|
||||
return ( m_nActiveWeightCount != 0 ) || mat_colcorrection_editor.GetBool();
|
||||
}
|
||||
|
||||
void CColorCorrectionMgr::UpdateColorCorrection()
|
||||
{
|
||||
ResetColorCorrectionWeights();
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
IClientMode *pClientMode = GetClientModeNormal(); //GetClientMode();
|
||||
|
||||
Assert( pClientMode );
|
||||
if ( !pPlayer || !pClientMode )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pClientMode->OnColorCorrectionWeightsReset();
|
||||
float ccScale = pClientMode->GetColorCorrectionScale();
|
||||
|
||||
UpdateColorCorrectionEntities( pPlayer, ccScale, g_ColorCorrectionList.Base(), g_ColorCorrectionList.Count() );
|
||||
UpdateColorCorrectionVolumes( pPlayer, ccScale, g_ColorCorrectionVolumeList.Base(), g_ColorCorrectionVolumeList.Count() );
|
||||
CommitColorCorrectionWeights();
|
||||
}
|
||||
#else
|
||||
bool CColorCorrectionMgr::HasNonZeroColorCorrectionWeights() const
|
||||
{
|
||||
return ( m_nActiveWeightCount != 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
#include "igamesystem.h"
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
class C_ColorCorrection;
|
||||
class C_ColorCorrectionVolume;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Singleton manager for color correction on the client
|
||||
@@ -35,8 +39,21 @@ public:
|
||||
ClientCCHandle_t AddColorCorrection( const char *pName, const char *pFileName = NULL );
|
||||
void RemoveColorCorrection( ClientCCHandle_t );
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
ClientCCHandle_t AddColorCorrectionEntity( C_ColorCorrection *pEntity, const char *pName, const char *pFileName = NULL );
|
||||
void RemoveColorCorrectionEntity( C_ColorCorrection *pEntity, ClientCCHandle_t );
|
||||
|
||||
ClientCCHandle_t AddColorCorrectionVolume( C_ColorCorrectionVolume *pVolume, const char *pName, const char *pFileName = NULL );
|
||||
void RemoveColorCorrectionVolume( C_ColorCorrectionVolume *pVolume, ClientCCHandle_t );
|
||||
#endif
|
||||
|
||||
// Modify color correction weights
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive = false );
|
||||
void UpdateColorCorrection();
|
||||
#else
|
||||
void SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight );
|
||||
#endif
|
||||
void ResetColorCorrectionWeights();
|
||||
void SetResetable( ClientCCHandle_t h, bool bResetable );
|
||||
|
||||
@@ -45,8 +62,27 @@ public:
|
||||
|
||||
private:
|
||||
int m_nActiveWeightCount;
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
bool m_bHaveExclusiveWeight;
|
||||
float m_flExclusiveWeight;
|
||||
|
||||
struct SetWeightParams_t
|
||||
{
|
||||
ClientCCHandle_t handle;
|
||||
float flWeight;
|
||||
bool bExclusive;
|
||||
};
|
||||
|
||||
CUtlVector< SetWeightParams_t > m_colorCorrectionWeights;
|
||||
|
||||
void CommitColorCorrectionWeights();
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
void UpdateColorCorrectionEntities( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrection **pList, int listCount );
|
||||
void UpdateColorCorrectionVolumes( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrectionVolume **pList, int listCount );
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Singleton access
|
||||
|
||||
@@ -25,6 +25,13 @@ extern ConVar r_drawmodeldecals;
|
||||
|
||||
ImpactSoundRouteFn g_pImpactSoundRouteFn = NULL;
|
||||
|
||||
#ifdef MAPBASE
|
||||
ConVar g_ragdoll_steal_impacts_client( "g_ragdoll_steal_impacts_client", "1", FCVAR_NONE, "Allows clientside death ragdolls to \"steal\" impacts from their source entities. This fixes issues with NPCs dying before decals are applied." );
|
||||
ConVar g_ragdoll_steal_impacts_server( "g_ragdoll_steal_impacts_server", "1", FCVAR_NONE, "Allows serverside death ragdolls to \"steal\" impacts from their source entities. This fixes issues with NPCs dying before decals are applied." );
|
||||
|
||||
ConVar g_ragdoll_client_impact_decals( "g_ragdoll_client_impact_decals", "1", FCVAR_NONE, "Applies decals to clientside ragdolls when they are hit." );
|
||||
#endif
|
||||
|
||||
//==========================================================================================================================
|
||||
// RAGDOLL ENUMERATOR
|
||||
//==========================================================================================================================
|
||||
@@ -32,7 +39,11 @@ CRagdollEnumerator::CRagdollEnumerator( Ray_t& shot, int iDamageType )
|
||||
{
|
||||
m_rayShot = shot;
|
||||
m_iDamageType = iDamageType;
|
||||
#ifdef MAPBASE
|
||||
m_pHitEnt = NULL;
|
||||
#else
|
||||
m_bHit = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
IterationRetval_t CRagdollEnumerator::EnumElement( IHandleEntity *pHandleEntity )
|
||||
@@ -57,7 +68,11 @@ IterationRetval_t CRagdollEnumerator::EnumElement( IHandleEntity *pHandleEntity
|
||||
if ( tr.fraction < 1.0 )
|
||||
{
|
||||
pModel->ImpactTrace( &tr, m_iDamageType, NULL );
|
||||
#ifdef MAPBASE
|
||||
m_pHitEnt = pModel;
|
||||
#else
|
||||
m_bHit = true;
|
||||
#endif
|
||||
|
||||
//FIXME: Yes? No?
|
||||
return ITERATION_STOP;
|
||||
@@ -84,6 +99,22 @@ bool FX_AffectRagdolls( Vector vecOrigin, Vector vecStart, int iDamageType )
|
||||
return ragdollEnum.Hit();
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
C_BaseAnimating *FX_AffectRagdolls_GetHit( Vector vecOrigin, Vector vecStart, int iDamageType )
|
||||
{
|
||||
// don't do this when lots of ragdolls are simulating
|
||||
if ( s_RagdollLRU.CountRagdolls(true) > 1 )
|
||||
return false;
|
||||
Ray_t shotRay;
|
||||
shotRay.Init( vecStart, vecOrigin );
|
||||
|
||||
CRagdollEnumerator ragdollEnum( shotRay, iDamageType );
|
||||
partition->EnumerateElementsAlongRay( PARTITION_CLIENT_RESPONSIVE_EDICTS, shotRay, false, &ragdollEnum );
|
||||
|
||||
return ragdollEnum.GetHit();
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : &data -
|
||||
@@ -104,6 +135,22 @@ bool Impact( Vector &vecOrigin, Vector &vecStart, int iMaterial, int iDamageType
|
||||
|
||||
Assert ( pEntity );
|
||||
|
||||
#ifdef MAPBASE
|
||||
// If the entity already has a ragdoll that was created on the current tick, use that ragdoll instead.
|
||||
// This allows the killing damage's decals to show up on the ragdoll.
|
||||
if (C_BaseAnimating *pAnimating = pEntity->GetBaseAnimating())
|
||||
{
|
||||
if (pAnimating->m_pClientsideRagdoll && WasRagdollCreatedOnCurrentTick( pAnimating->m_pClientsideRagdoll ) && g_ragdoll_steal_impacts_client.GetBool())
|
||||
{
|
||||
pEntity = pAnimating->m_pClientsideRagdoll;
|
||||
}
|
||||
else if (pAnimating->m_pServerRagdoll && WasRagdollCreatedOnCurrentTick( pAnimating->m_pServerRagdoll ) && g_ragdoll_steal_impacts_server.GetBool())
|
||||
{
|
||||
pEntity = pAnimating->m_pServerRagdoll;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Clear out the trace
|
||||
memset( &tr, 0, sizeof(trace_t));
|
||||
tr.fraction = 1.0f;
|
||||
@@ -115,13 +162,52 @@ bool Impact( Vector &vecOrigin, Vector &vecStart, int iMaterial, int iDamageType
|
||||
VectorMA( vecStart, flLength + 8.0f, shotDir, traceExt );
|
||||
|
||||
// Attempt to hit ragdolls
|
||||
|
||||
|
||||
bool bHitRagdoll = false;
|
||||
|
||||
|
||||
#ifdef MAPBASE
|
||||
if ( !pEntity->IsClientCreated() )
|
||||
{
|
||||
C_BaseAnimating *pRagdoll = FX_AffectRagdolls_GetHit( vecOrigin, vecStart, iDamageType );
|
||||
if (pRagdoll)
|
||||
{
|
||||
bHitRagdoll = true;
|
||||
|
||||
if (g_ragdoll_client_impact_decals.GetBool())
|
||||
{
|
||||
pEntity = pRagdoll;
|
||||
|
||||
// HACKHACK: Get the ragdoll's nearest bone for its material
|
||||
int iNearestMaterial = 0;
|
||||
float flNearestDistSqr = FLT_MAX;
|
||||
|
||||
IPhysicsObject *pList[VPHYSICS_MAX_OBJECT_LIST_COUNT];
|
||||
int count = pEntity->VPhysicsGetObjectList( pList, ARRAYSIZE(pList) );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
Vector vecPosition;
|
||||
QAngle angAngles;
|
||||
pList[i]->GetPosition( &vecPosition, &angAngles );
|
||||
float flDistSqr = (vecStart - vecPosition).LengthSqr();
|
||||
if (flDistSqr < flNearestDistSqr)
|
||||
{
|
||||
iNearestMaterial = pList[i]->GetMaterialIndex();
|
||||
flNearestDistSqr = flDistSqr;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the material from the surfaceprop
|
||||
surfacedata_t *psurfaceData = physprops->GetSurfaceData( iNearestMaterial );
|
||||
iMaterial = psurfaceData->game.material;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ( !pEntity->IsClientCreated() )
|
||||
{
|
||||
bHitRagdoll = FX_AffectRagdolls( vecOrigin, vecStart, iDamageType );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( (nFlags & IMPACT_NODECAL) == 0 )
|
||||
{
|
||||
|
||||
@@ -58,12 +58,21 @@ public:
|
||||
// Actual work code
|
||||
virtual IterationRetval_t EnumElement( IHandleEntity *pHandleEntity );
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool Hit( void ) const { return m_pHitEnt != NULL; }
|
||||
C_BaseAnimating *GetHit( void ) { return m_pHitEnt; }
|
||||
#else
|
||||
bool Hit( void ) const { return m_bHit; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
Ray_t m_rayShot;
|
||||
int m_iDamageType;
|
||||
#ifdef MAPBASE
|
||||
C_BaseAnimating *m_pHitEnt;
|
||||
#else
|
||||
bool m_bHit;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // FX_IMPACT_H
|
||||
|
||||
@@ -146,6 +146,32 @@ bool CBaseViewport::LoadHudAnimations( void )
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reloads HUD animations after loading a map-specific HUD animations file.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseViewport::ReloadHudAnimations( void )
|
||||
{
|
||||
// Force a reload
|
||||
if ( LoadHudAnimations() == false )
|
||||
{
|
||||
// Fall back to just the main
|
||||
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
|
||||
{
|
||||
Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads a map-specific HUD animations file.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBaseViewport::LoadCustomHudAnimations( const char *pszFile )
|
||||
{
|
||||
return m_pAnimController->SetScriptFile( GetVPanel(), pszFile, true );
|
||||
}
|
||||
#endif
|
||||
|
||||
//================================================================
|
||||
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
|
||||
{
|
||||
|
||||
@@ -73,6 +73,10 @@ public:
|
||||
public: // IGameEventListener:
|
||||
virtual void FireGameEvent( IGameEvent * event);
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool LoadCustomHudAnimations( const char *pszFile );
|
||||
void ReloadHudAnimations( void );
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -32,6 +32,16 @@ struct creditname_t
|
||||
float flTimeAdd;
|
||||
float flTimeStart;
|
||||
int iSlot;
|
||||
|
||||
#ifdef MAPBASE
|
||||
// New credits stuff
|
||||
|
||||
Color cColorOverride;
|
||||
|
||||
// Images
|
||||
int iImageID = -1;
|
||||
float flImageScale = 1.0f;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define CREDITS_FILE "scripts/credits.txt"
|
||||
@@ -93,6 +103,10 @@ private:
|
||||
void DrawOutroCreditsName( void );
|
||||
void DrawIntroCreditsName( void );
|
||||
void DrawLogo( void );
|
||||
#ifdef MAPBASE
|
||||
void DrawOutroCreditFont( const char *pCreditName, float flYPos, vgui::HFont hTFont, const Color &cColor, int iScreenWidth, int iDivisor = 2 );
|
||||
void DrawOutroCreditTexture( int iImageID, float flYPos, float flImageScale, const Color &cColor, int iScreenWidth, int iDivisor = 2 );
|
||||
#endif
|
||||
|
||||
void PrepareLogo( float flTime );
|
||||
void PrepareOutroCredits( void );
|
||||
@@ -102,6 +116,10 @@ private:
|
||||
|
||||
void PrepareLine( vgui::HFont hFont, char const *pchLine );
|
||||
|
||||
#ifdef MAPBASE
|
||||
int GetOrAllocateImageID( const char *szFileName );
|
||||
#endif
|
||||
|
||||
CPanelAnimationVar( vgui::HFont, m_hTextFont, "TextFont", "Default" );
|
||||
CPanelAnimationVar( Color, m_TextColor, "TextColor", "FgColor" );
|
||||
|
||||
@@ -110,7 +128,10 @@ private:
|
||||
float m_flScrollTime;
|
||||
float m_flSeparation;
|
||||
#ifdef MAPBASE
|
||||
int m_iEndLines;
|
||||
int m_iEndLines;
|
||||
float m_flEndLinesFadeHoldTime;
|
||||
bool m_bAllowColumns;
|
||||
CUtlDict<int, int> m_ImageDict;
|
||||
#endif
|
||||
float m_flFadeTime;
|
||||
bool m_bLastOneInPlace;
|
||||
@@ -202,6 +223,20 @@ void CHudCredits::Clear( void )
|
||||
m_bLastOneInPlace = false;
|
||||
m_Alpha = m_TextColor[3];
|
||||
m_iLogoState = LOGO_FADEOFF;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if ( surface() )
|
||||
{
|
||||
for (int i = m_ImageDict.Count()-1; i >= 0; i--)
|
||||
{
|
||||
if (m_ImageDict[i] != -1)
|
||||
{
|
||||
surface()->DestroyTextureID( m_ImageDict[i] );
|
||||
m_ImageDict.RemoveAt( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -229,7 +264,11 @@ void CHudCredits::ReadNames( KeyValues *pKeyValue )
|
||||
{
|
||||
creditname_t Credits;
|
||||
V_strcpy_safe( Credits.szCreditName, pKVNames->GetName() );
|
||||
#ifdef MAPBASE
|
||||
V_strcpy_safe( Credits.szFontName, pKVNames->GetString( (const char *)NULL, "Default" ) );
|
||||
#else
|
||||
V_strcpy_safe( Credits.szFontName, pKeyValue->GetString( Credits.szCreditName, "Default" ) );
|
||||
#endif
|
||||
|
||||
m_CreditsList.AddToTail( Credits );
|
||||
pKVNames = pKVNames->GetNextKey();
|
||||
@@ -248,6 +287,8 @@ void CHudCredits::ReadParams( KeyValues *pKeyValue )
|
||||
m_flSeparation = pKeyValue->GetFloat( "separation", 5 );
|
||||
#ifdef MAPBASE
|
||||
m_iEndLines = pKeyValue->GetInt( "endlines", 1 );
|
||||
m_flEndLinesFadeHoldTime = pKeyValue->GetFloat( "endlines_fadeholdtime", ( IsConsole() ? 2.0f : 10.0f ) ); // "360 certification requires that we not hold a static image too long."
|
||||
m_bAllowColumns = pKeyValue->GetBool( "allow_columns", false );
|
||||
#endif
|
||||
|
||||
m_flFadeInTime = pKeyValue->GetFloat( "fadeintime", 1 );
|
||||
@@ -300,10 +341,46 @@ void CHudCredits::DrawOutroCreditsName( void )
|
||||
if ( pCredit == NULL )
|
||||
continue;
|
||||
|
||||
#ifdef MAPBASE
|
||||
vgui::HScheme scheme = GetScheme();
|
||||
#else
|
||||
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme(scheme)->GetFont( pCredit->szFontName, true );
|
||||
#endif
|
||||
vgui::HFont m_hTFont = INVALID_FONT;
|
||||
|
||||
int iFontTall = surface()->GetFontTall ( m_hTFont );
|
||||
int iFontTall = 1;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (pCredit->iImageID != -1)
|
||||
{
|
||||
// Get the size of the tallest image if there's multiple
|
||||
int iFontWide;
|
||||
if (m_bAllowColumns && V_strstr( pCredit->szCreditName, "\t" ))
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szCreditName, "\t", outStrings );
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
int iTempTall;
|
||||
surface()->DrawGetTextureSize( GetOrAllocateImageID( outStrings[i] ), iFontWide, iTempTall );
|
||||
if (iTempTall > iFontTall)
|
||||
iFontTall = iTempTall;
|
||||
}
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
else
|
||||
{
|
||||
surface()->DrawGetTextureSize( GetOrAllocateImageID( pCredit->szCreditName ), iFontWide, iFontTall );
|
||||
}
|
||||
|
||||
iFontTall = ((float)iFontTall * pCredit->flImageScale);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
m_hTFont = vgui::scheme()->GetIScheme( scheme )->GetFont( pCredit->szFontName, true );
|
||||
iFontTall = surface()->GetFontTall( m_hTFont );
|
||||
}
|
||||
|
||||
if ( pCredit->flYPos < -iFontTall || pCredit->flYPos > iTall )
|
||||
{
|
||||
@@ -317,6 +394,9 @@ void CHudCredits::DrawOutroCreditsName( void )
|
||||
Color cColor = m_TextColor;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (pCredit->cColorOverride.a() > 0)
|
||||
cColor = pCredit->cColorOverride;
|
||||
|
||||
// Some lines should stick around and fade out
|
||||
if ( i >= m_CreditsList.Count()-m_iEndLines )
|
||||
#else
|
||||
@@ -333,8 +413,12 @@ void CHudCredits::DrawOutroCreditsName( void )
|
||||
{
|
||||
m_bLastOneInPlace = true;
|
||||
|
||||
#ifdef MAPBASE
|
||||
m_flFadeTime = gpGlobals->curtime + m_flEndLinesFadeHoldTime;
|
||||
#else
|
||||
// 360 certification requires that we not hold a static image too long.
|
||||
m_flFadeTime = gpGlobals->curtime + ( IsConsole() ? 2.0f : 10.0f );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -364,6 +448,50 @@ void CHudCredits::DrawOutroCreditsName( void )
|
||||
if ( pCredit->bActive == false )
|
||||
continue;
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Credits separated by tabs should appear divided
|
||||
if (m_bAllowColumns && V_strstr( pCredit->szCreditName, "\t" ))
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szCreditName, "\t", outStrings );
|
||||
int iDivisor = 1 + outStrings.Count();
|
||||
if (pCredit->iImageID != -1)
|
||||
{
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
int iImageID = GetOrAllocateImageID( outStrings[i] );
|
||||
|
||||
// Center the image if needed
|
||||
int iImageWide, iImageTall = 1;
|
||||
surface()->DrawGetTextureSize( iImageID, iImageWide, iImageTall );
|
||||
if (iImageTall < iFontTall)
|
||||
{
|
||||
DrawOutroCreditTexture( iImageID, pCredit->flYPos + ((iFontTall * 0.5f) - (iImageTall * 0.5f)), pCredit->flImageScale, cColor, iWidth*(i + 1), iDivisor );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawOutroCreditTexture( iImageID, pCredit->flYPos, pCredit->flImageScale, cColor, iWidth*(i + 1), iDivisor );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
DrawOutroCreditFont( outStrings[i], pCredit->flYPos, m_hTFont, cColor, iWidth*(i + 1), iDivisor );
|
||||
}
|
||||
}
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
else if (pCredit->iImageID != -1)
|
||||
{
|
||||
DrawOutroCreditTexture( pCredit->iImageID, pCredit->flYPos, pCredit->flImageScale, cColor, iWidth, 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawOutroCreditFont( pCredit->szCreditName, pCredit->flYPos, m_hTFont, cColor, iWidth, 2 );
|
||||
}
|
||||
#else
|
||||
surface()->DrawSetTextFont( m_hTFont );
|
||||
surface()->DrawSetTextColor( cColor[0], cColor[1], cColor[2], cColor[3] );
|
||||
|
||||
@@ -382,9 +510,56 @@ void CHudCredits::DrawOutroCreditsName( void )
|
||||
|
||||
surface()->DrawSetTextPos( ( iWidth / 2 ) - ( iStringWidth / 2 ), pCredit->flYPos );
|
||||
surface()->DrawUnicodeString( unicode );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
void CHudCredits::DrawOutroCreditFont( const char *pCreditName, float flYPos, vgui::HFont hTFont, const Color &cColor, int iScreenWidth, int iDivisor )
|
||||
{
|
||||
surface()->DrawSetTextFont( hTFont );
|
||||
surface()->DrawSetTextColor( cColor[0], cColor[1], cColor[2], cColor[3] );
|
||||
|
||||
wchar_t unicode[256];
|
||||
|
||||
if ( pCreditName[0] == '#' )
|
||||
{
|
||||
g_pVGuiLocalize->ConstructString( unicode, sizeof(unicode), g_pVGuiLocalize->Find(pCreditName), 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pCreditName, unicode, sizeof( unicode ) );
|
||||
}
|
||||
|
||||
int iStringWidth = GetStringPixelWidth( unicode, hTFont );
|
||||
|
||||
// ((iScreenWidth*iMultiplier) / iDivisor)
|
||||
// When needed, just multiply iScreenWidth before sending to the function
|
||||
surface()->DrawSetTextPos( (iScreenWidth / iDivisor) - (iStringWidth / 2), flYPos );
|
||||
surface()->DrawUnicodeString( unicode );
|
||||
}
|
||||
|
||||
void CHudCredits::DrawOutroCreditTexture( int iImageID, float flYPos, float flImageScale, const Color &cColor, int iScreenWidth, int iDivisor )
|
||||
{
|
||||
int iImageWide, iImageTall;
|
||||
surface()->DrawGetTextureSize( iImageID, iImageWide, iImageTall );
|
||||
|
||||
// Scale for resolution
|
||||
flImageScale *= ((float)GetTall() / 900.0f);
|
||||
|
||||
iImageWide = ((float)(iImageWide) * flImageScale);
|
||||
iImageTall = ((float)(iImageTall) * flImageScale);
|
||||
|
||||
iImageWide /= 2;
|
||||
//iImageTall /= 2;
|
||||
iScreenWidth /= iDivisor;
|
||||
|
||||
surface()->DrawSetColor( cColor );
|
||||
surface()->DrawSetTexture( iImageID );
|
||||
surface()->DrawTexturedRect( iScreenWidth - iImageWide, flYPos, iScreenWidth + iImageWide, flYPos + iImageTall );
|
||||
}
|
||||
#endif
|
||||
|
||||
void CHudCredits::DrawLogo( void )
|
||||
{
|
||||
if( m_iLogoState == LOGO_FADEOFF )
|
||||
@@ -464,7 +639,11 @@ void CHudCredits::DrawLogo( void )
|
||||
Q_snprintf( szLogoFont, sizeof( szLogoFont ), "WeaponIcons" );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
vgui::HScheme scheme = GetScheme();
|
||||
#else
|
||||
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||
#endif
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme(scheme)->GetFont( szLogoFont );
|
||||
|
||||
int iFontTall = surface()->GetFontTall ( m_hTFont );
|
||||
@@ -544,14 +723,26 @@ void CHudCredits::DrawIntroCreditsName( void )
|
||||
|
||||
if ( pCredit->bActive == false )
|
||||
continue;
|
||||
|
||||
|
||||
#ifdef MAPBASE
|
||||
vgui::HScheme scheme = GetScheme();
|
||||
#else
|
||||
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||
#endif
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme(scheme)->GetFont( pCredit->szFontName );
|
||||
|
||||
float localTime = gpGlobals->curtime - pCredit->flTimeStart;
|
||||
|
||||
surface()->DrawSetTextFont( m_hTFont );
|
||||
#ifdef MAPBASE
|
||||
Color cColor = m_cColor;
|
||||
if (pCredit->cColorOverride.a() > 0)
|
||||
cColor = pCredit->cColorOverride;
|
||||
|
||||
surface()->DrawSetTextColor( cColor[0], cColor[1], cColor[2], FadeBlend( m_flFadeInTime, m_flFadeOutTime, m_flFadeHoldTime + pCredit->flTimeAdd, localTime ) * cColor[3] );
|
||||
#else
|
||||
surface()->DrawSetTextColor( m_cColor[0], m_cColor[1], m_cColor[2], FadeBlend( m_flFadeInTime, m_flFadeOutTime, m_flFadeHoldTime + pCredit->flTimeAdd, localTime ) * m_cColor[3] );
|
||||
#endif
|
||||
|
||||
wchar_t unicode[256];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pCredit->szCreditName, unicode, sizeof( unicode ) );
|
||||
@@ -692,17 +883,119 @@ void CHudCredits::PrepareOutroCredits( void )
|
||||
if ( pCredit == NULL )
|
||||
continue;
|
||||
|
||||
#ifdef MAPBASE
|
||||
vgui::HScheme scheme = GetScheme();
|
||||
#else
|
||||
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme(scheme)->GetFont( pCredit->szFontName, true );
|
||||
#endif
|
||||
|
||||
pCredit->flYPos = iHeight;
|
||||
pCredit->bActive = false;
|
||||
#ifdef MAPBASE
|
||||
if (pCredit->szFontName[0] == '$')
|
||||
{
|
||||
if (V_strncmp( pCredit->szFontName + 1, "Image", 5 ) == 0)
|
||||
{
|
||||
if (pCredit->szFontName[6] == ';')
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szFontName, ";", outStrings );
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
// Get scale
|
||||
case 1:
|
||||
pCredit->flImageScale = atof( outStrings[i] );
|
||||
break;
|
||||
|
||||
iHeight += surface()->GetFontTall ( m_hTFont ) + m_flSeparation;
|
||||
// Get color
|
||||
case 2:
|
||||
int tmp[4];
|
||||
UTIL_StringToIntArray( tmp, 4, outStrings[i] );
|
||||
pCredit->cColorOverride = Color( tmp[0], tmp[1], tmp[2], tmp[3] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
|
||||
PrepareLine( m_hTFont, pCredit->szCreditName );
|
||||
// Get the size of the tallest image if there's multiple
|
||||
int iFontWide, iFontTall = 1;
|
||||
if (m_bAllowColumns && V_strstr( pCredit->szCreditName, "\t" ))
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szCreditName, "\t", outStrings );
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
pCredit->iImageID = GetOrAllocateImageID( outStrings[i] );
|
||||
|
||||
int iTempTall;
|
||||
surface()->DrawGetTextureSize( pCredit->iImageID, iFontWide, iTempTall );
|
||||
if (iTempTall > iFontTall)
|
||||
iFontTall = iTempTall;
|
||||
}
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
else
|
||||
{
|
||||
pCredit->iImageID = GetOrAllocateImageID( pCredit->szCreditName );
|
||||
surface()->DrawGetTextureSize( pCredit->iImageID, iFontWide, iFontTall );
|
||||
}
|
||||
|
||||
pCredit->flYPos = iHeight;
|
||||
pCredit->bActive = false;
|
||||
|
||||
iHeight += ((float)iFontTall * pCredit->flImageScale * ((float)GetTall() / 900.0f)) + m_flSeparation;
|
||||
|
||||
Msg( "'%s' is image type (image scale is %f)\n", pCredit->szCreditName, pCredit->flImageScale );
|
||||
}
|
||||
else
|
||||
{
|
||||
//Msg( "'%s' is not an image type\n", pCredit->szFontName + 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
if (V_strstr( pCredit->szFontName, ";" ))
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szFontName, ";", outStrings );
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
// Get color
|
||||
case 1:
|
||||
int tmp[4];
|
||||
UTIL_StringToIntArray( tmp, 4, outStrings[i] );
|
||||
pCredit->cColorOverride = Color( tmp[0], tmp[1], tmp[2], tmp[3] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Q_strncpy( pCredit->szFontName, outStrings[0], sizeof( pCredit->szFontName ) );
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
#endif
|
||||
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme( scheme )->GetFont( pCredit->szFontName, true );
|
||||
|
||||
pCredit->flYPos = iHeight;
|
||||
pCredit->bActive = false;
|
||||
|
||||
iHeight += surface()->GetFontTall ( m_hTFont ) + m_flSeparation;
|
||||
|
||||
PrepareLine( m_hTFont, pCredit->szCreditName );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Check if the last line has a color override. If it does, use that as the alpha for the fadeout
|
||||
if (m_CreditsList.Tail().cColorOverride.a() != 0)
|
||||
m_Alpha = m_CreditsList.Tail().cColorOverride.a();
|
||||
#endif
|
||||
|
||||
SetActive( true );
|
||||
|
||||
g_iCreditsPixelHeight = iHeight;
|
||||
@@ -721,7 +1014,34 @@ void CHudCredits::PrepareIntroCredits( void )
|
||||
if ( pCredit == NULL )
|
||||
continue;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (V_strstr( pCredit->szFontName, ";" ))
|
||||
{
|
||||
CUtlStringList outStrings;
|
||||
V_SplitString( pCredit->szFontName, ";", outStrings );
|
||||
FOR_EACH_VEC( outStrings, i )
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
// Get color
|
||||
case 1:
|
||||
int tmp[4];
|
||||
UTIL_StringToIntArray( tmp, 4, outStrings[i] );
|
||||
pCredit->cColorOverride = Color( tmp[0], tmp[1], tmp[2], tmp[3] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Q_strncpy( pCredit->szFontName, outStrings[0], sizeof( pCredit->szFontName ) );
|
||||
outStrings.PurgeAndDeleteElements();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE
|
||||
vgui::HScheme scheme = GetScheme();
|
||||
#else
|
||||
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||
#endif
|
||||
vgui::HFont m_hTFont = vgui::scheme()->GetIScheme(scheme)->GetFont( pCredit->szFontName );
|
||||
|
||||
pCredit->flYPos = m_flY + ( iSlot * surface()->GetFontTall ( m_hTFont ) );
|
||||
@@ -749,6 +1069,21 @@ void CHudCredits::PrepareIntroCredits( void )
|
||||
SetActive( true );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
int CHudCredits::GetOrAllocateImageID( const char *szFileName )
|
||||
{
|
||||
int iIndex = m_ImageDict.Find( szFileName );
|
||||
if (iIndex == m_ImageDict.InvalidIndex())
|
||||
{
|
||||
iIndex = surface()->CreateNewTextureID();
|
||||
m_ImageDict.Insert( szFileName, iIndex );
|
||||
surface()->DrawSetTextureFile( iIndex, szFileName, true, false );
|
||||
return iIndex;
|
||||
}
|
||||
return m_ImageDict[iIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
void CHudCredits::MsgFunc_CreditsMsg( bf_read &msg )
|
||||
{
|
||||
m_iCreditsType = msg.ReadByte();
|
||||
|
||||
@@ -1612,6 +1612,9 @@ struct WorkUnitParams
|
||||
clr = Color( 255, 255, 255, 255 );
|
||||
newline = false;
|
||||
font = 0;
|
||||
#ifdef MAPBASE
|
||||
customFont = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
~WorkUnitParams()
|
||||
@@ -1657,6 +1660,9 @@ struct WorkUnitParams
|
||||
Color clr;
|
||||
bool newline;
|
||||
vgui::HFont font;
|
||||
#ifdef MAPBASE
|
||||
bool customFont;
|
||||
#endif
|
||||
};
|
||||
|
||||
void CHudCloseCaption::AddWorkUnit( CCloseCaptionItem *item,
|
||||
@@ -1771,27 +1777,58 @@ void CHudCloseCaption::ComputeStreamWork( int available_width, CCloseCaptionItem
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
params.italic = !params.italic;
|
||||
#ifdef MAPBASE
|
||||
params.customFont = false;
|
||||
#endif
|
||||
}
|
||||
else if ( !wcscmp( cmd, L"B" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
params.bold = !params.bold;
|
||||
#ifdef MAPBASE
|
||||
params.customFont = false;
|
||||
#endif
|
||||
}
|
||||
#ifdef MAPBASE
|
||||
else if ( !wcscmp( cmd, L"font" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
vgui::IScheme *pScheme = vgui::scheme()->GetIScheme( GetScheme() );
|
||||
|
||||
if ( args[0] != 0 )
|
||||
{
|
||||
char font[64];
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( args, font, sizeof( font ) );
|
||||
params.font = pScheme->GetFont( font );
|
||||
params.customFont = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.customFont = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int font;
|
||||
if ( IsPC() )
|
||||
vgui::HFont useF = params.font;
|
||||
#ifdef MAPBASE
|
||||
if (params.customFont == false)
|
||||
#endif
|
||||
{
|
||||
font = params.GetFontNumber();
|
||||
int font;
|
||||
if ( IsPC() )
|
||||
{
|
||||
font = params.GetFontNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
font = streamlen >= cc_smallfontlength.GetInt() ? CCFONT_SMALL : CCFONT_NORMAL;
|
||||
}
|
||||
useF = m_hFonts[font];
|
||||
params.font = useF;
|
||||
}
|
||||
else
|
||||
{
|
||||
font = streamlen >= cc_smallfontlength.GetInt() ? CCFONT_SMALL : CCFONT_NORMAL;
|
||||
}
|
||||
vgui::HFont useF = m_hFonts[font];
|
||||
params.font = useF;
|
||||
|
||||
int w, h;
|
||||
|
||||
@@ -2630,6 +2667,124 @@ void CHudCloseCaption::InitCaptionDictionary( const char *dbfile )
|
||||
g_AsyncCaptionResourceManager.SetDbInfo( m_AsyncCaptions );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
void CHudCloseCaption::AddAdditionalCaptionDictionary( const char *dbfile, CUtlVector<CUtlSymbol> &outPathSymbols )
|
||||
{
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Adding additional caption dictionary \"%s\"\n", dbfile );
|
||||
|
||||
g_AsyncCaptionResourceManager.Clear();
|
||||
|
||||
char searchPaths[4096];
|
||||
filesystem->GetSearchPath( "MOD", true, searchPaths, sizeof( searchPaths ) );
|
||||
|
||||
for ( char *path = strtok( searchPaths, ";" ); path; path = strtok( NULL, ";" ) )
|
||||
{
|
||||
if ( IsX360() && ( filesystem->GetDVDMode() == DVDMODE_STRICT ) && !V_stristr( path, ".zip" ) )
|
||||
{
|
||||
// only want zip paths
|
||||
continue;
|
||||
}
|
||||
|
||||
char fullpath[MAX_PATH];
|
||||
Q_snprintf( fullpath, sizeof( fullpath ), "%s%s", path, dbfile );
|
||||
Q_FixSlashes( fullpath );
|
||||
|
||||
if ( IsX360() )
|
||||
{
|
||||
char fullpath360[MAX_PATH];
|
||||
UpdateOrCreateCaptionFile( fullpath, fullpath360, sizeof( fullpath360 ) );
|
||||
Q_strncpy( fullpath, fullpath360, sizeof( fullpath ) );
|
||||
}
|
||||
|
||||
// Seach for this dictionary. If it already exists, remove it.
|
||||
for (int i = 0; i < m_AsyncCaptions.Count(); ++i)
|
||||
{
|
||||
if (FStrEq( m_AsyncCaptions[i].m_DataBaseFile.String(), fullpath ))
|
||||
{
|
||||
m_AsyncCaptions.Remove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileHandle_t fh = filesystem->Open( fullpath, "rb" );
|
||||
if ( FILESYSTEM_INVALID_HANDLE != fh )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
CUtlBuffer dirbuffer;
|
||||
|
||||
AsyncCaption_t& entry = m_AsyncCaptions[ m_AsyncCaptions.AddToTail() ];
|
||||
|
||||
// Read the header
|
||||
filesystem->Read( &entry.m_Header, sizeof( entry.m_Header ), fh );
|
||||
if ( entry.m_Header.magic != COMPILED_CAPTION_FILEID )
|
||||
Error( "Invalid file id for %s\n", fullpath );
|
||||
if ( entry.m_Header.version != COMPILED_CAPTION_VERSION )
|
||||
Error( "Invalid file version for %s\n", fullpath );
|
||||
if ( entry.m_Header.directorysize < 0 || entry.m_Header.directorysize > 64 * 1024 )
|
||||
Error( "Invalid directory size %d for %s\n", entry.m_Header.directorysize, fullpath );
|
||||
//if ( entry.m_Header.blocksize != MAX_BLOCK_SIZE )
|
||||
// Error( "Invalid block size %d, expecting %d for %s\n", entry.m_Header.blocksize, MAX_BLOCK_SIZE, fullpath );
|
||||
|
||||
int directoryBytes = entry.m_Header.directorysize * sizeof( CaptionLookup_t );
|
||||
entry.m_CaptionDirectory.EnsureCapacity( entry.m_Header.directorysize );
|
||||
dirbuffer.EnsureCapacity( directoryBytes );
|
||||
|
||||
filesystem->Read( dirbuffer.Base(), directoryBytes, fh );
|
||||
filesystem->Close( fh );
|
||||
|
||||
entry.m_CaptionDirectory.CopyArray( (const CaptionLookup_t *)dirbuffer.PeekGet(), entry.m_Header.directorysize );
|
||||
entry.m_CaptionDirectory.RedoSort( true );
|
||||
|
||||
entry.m_DataBaseFile = fullpath;
|
||||
outPathSymbols.AddToTail( entry.m_DataBaseFile );
|
||||
}
|
||||
}
|
||||
|
||||
g_AsyncCaptionResourceManager.SetDbInfo( m_AsyncCaptions );
|
||||
}
|
||||
|
||||
void CHudCloseCaption::AddCustomCaptionFile( char const *file, CUtlVector<CUtlSymbol> &outPathSymbols )
|
||||
{
|
||||
//
|
||||
// 'file' should be something like "maps/mapbase_demo01_closecaption_%language%"
|
||||
//
|
||||
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Adding custom caption file \"%s\"\n", file );
|
||||
|
||||
if (!IsX360())
|
||||
{
|
||||
g_pVGuiLocalize->AddFile( file, "MOD", true );
|
||||
}
|
||||
|
||||
char uilanguage[64];
|
||||
engine->GetUILanguage( uilanguage, sizeof( uilanguage ) );
|
||||
|
||||
char dbfile[512];
|
||||
V_StrSubst( file, "%language%", uilanguage, dbfile, sizeof( dbfile ) );
|
||||
V_SetExtension( dbfile, ".dat", sizeof( dbfile ) );
|
||||
AddAdditionalCaptionDictionary( dbfile, outPathSymbols );
|
||||
}
|
||||
|
||||
void CHudCloseCaption::RemoveCaptionDictionary( const CUtlSymbol &dbFileSymbol )
|
||||
{
|
||||
//
|
||||
// 'file' should be something like "maps/mapbase_demo01_closecaption_%language%"
|
||||
//
|
||||
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Removing custom caption file \"%s\"\n", dbFileSymbol.String() );
|
||||
|
||||
for (int i = 0; i < m_AsyncCaptions.Count(); ++i)
|
||||
{
|
||||
if ( m_AsyncCaptions[i].m_DataBaseFile == dbFileSymbol )
|
||||
{
|
||||
m_AsyncCaptions.Remove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CHudCloseCaption::OnFinishAsyncLoad( int nFileIndex, int nBlockNum, AsyncCaptionData_t *pData )
|
||||
{
|
||||
// Fill in data for all users of pData->m_nBlockNum
|
||||
|
||||
@@ -111,6 +111,11 @@ public:
|
||||
void PlayRandomCaption();
|
||||
|
||||
void InitCaptionDictionary( char const *dbfile );
|
||||
#ifdef MAPBASE
|
||||
void AddAdditionalCaptionDictionary( char const *dbfile, CUtlVector<CUtlSymbol> &outPathSymbols );
|
||||
void AddCustomCaptionFile( char const *file, CUtlVector<CUtlSymbol> &outPathSymbols );
|
||||
void RemoveCaptionDictionary( const CUtlSymbol &dbFileSymbol );
|
||||
#endif
|
||||
void OnFinishAsyncLoad( int nFileIndex, int nBlockNum, AsyncCaptionData_t *pData );
|
||||
|
||||
void Flush();
|
||||
@@ -133,6 +138,11 @@ public:
|
||||
|
||||
void FindSound( char const *pchANSI );
|
||||
|
||||
#ifdef MAPBASE
|
||||
inline bool IsUsingCommentaryDimensions() const { return m_bUsingCommentaryDimensions; }
|
||||
inline void SetUsingCommentaryDimensions( bool bToggle ) { m_bUsingCommentaryDimensions = bToggle; }
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
struct CaptionRepeat
|
||||
@@ -212,6 +222,10 @@ private:
|
||||
bool m_bVisibleDueToDirect;
|
||||
bool m_bPaintDebugInfo;
|
||||
CUtlSymbol m_CurrentLanguage;
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool m_bUsingCommentaryDimensions;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // HUD_CLOSECAPTION_H
|
||||
|
||||
@@ -112,6 +112,11 @@ public:
|
||||
|
||||
virtual bool CanRecordDemo( char *errorMsg, int length ) const = 0;
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
virtual void OnColorCorrectionWeightsReset( void ) = 0;
|
||||
virtual float GetColorCorrectionScale( void ) const = 0;
|
||||
#endif
|
||||
|
||||
virtual void ComputeVguiResConditions( KeyValues *pkvConditions ) = 0;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
@@ -115,6 +115,13 @@ public:
|
||||
virtual void SetScreenOverlayMaterial( IMaterial *pMaterial ) = 0;
|
||||
virtual IMaterial *GetScreenOverlayMaterial( ) = 0;
|
||||
|
||||
#ifdef MAPBASE
|
||||
virtual void SetIndexedScreenOverlayMaterial( int i, IMaterial *pMaterial ) = 0;
|
||||
virtual IMaterial *GetIndexedScreenOverlayMaterial( int i ) = 0;
|
||||
virtual void ResetIndexedScreenOverlays() = 0;
|
||||
virtual int GetMaxIndexedScreenOverlays() const = 0;
|
||||
#endif
|
||||
|
||||
virtual void WriteSaveGameScreenshot( const char *pFilename ) = 0;
|
||||
virtual void WriteSaveGameScreenshotOfSize( const char *pFilename, int width, int height, bool bCreatePowerOf2Padded = false, bool bWriteVTF = false ) = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||
//
|
||||
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
|
||||
// Purpose: Recreates Portal 2 linked_portal_door visual functionality using SDK code only.
|
||||
// (basically a combination of point_camera and func_reflective_glass)
|
||||
//
|
||||
// $NoKeywords: $
|
||||
@@ -120,8 +120,8 @@ C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t
|
||||
//-----------------------------------------------------------------------------
|
||||
// Iterates through fake world portals instead of just picking one
|
||||
//-----------------------------------------------------------------------------
|
||||
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
|
||||
const Frustum_t &frustum )
|
||||
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
|
||||
cplane_t &plane, Vector &vecPlaneOrigin, const Frustum_t &frustum )
|
||||
{
|
||||
// Early out if no cameras
|
||||
C_FuncFakeWorldPortal *pReflectiveGlass = NULL;
|
||||
@@ -167,6 +167,7 @@ C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const
|
||||
if ( !pReflectiveGlass->m_hTargetPlane )
|
||||
continue;
|
||||
|
||||
vecPlaneOrigin = vecOrigin;
|
||||
return pReflectiveGlass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane );
|
||||
|
||||
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
|
||||
const Frustum_t &frustum );
|
||||
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
|
||||
cplane_t &plane, Vector &vecPlaneOrigin, const Frustum_t &frustum );
|
||||
|
||||
|
||||
#endif // C_FUNC_FAKE_WORLDPORTAL
|
||||
|
||||
@@ -157,11 +157,34 @@ void C_TextDisplayPanel::UpdateText()
|
||||
m_pDisplayTextLabel->SetText( m_hScreenEntity->GetDisplayText() );
|
||||
|
||||
//SetSize( m_hScreenEntity->GetTextSize(), m_hScreenEntity->GetTextSize() );
|
||||
SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
|
||||
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
|
||||
//m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetTextSize(), m_hScreenEntity->GetTextSize() );
|
||||
|
||||
Label::Alignment iAlignment = m_hScreenEntity->GetContentAlignment();
|
||||
|
||||
switch (iAlignment)
|
||||
{
|
||||
// Use a special scaling method when using a south alignment
|
||||
case Label::Alignment::a_southwest:
|
||||
case Label::Alignment::a_south:
|
||||
case Label::Alignment::a_southeast:
|
||||
int lW, lT;
|
||||
m_pDisplayTextLabel->GetContentSize( lW, lT );
|
||||
SetSize( m_hScreenEntity->GetResolution(), lT );
|
||||
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), lT );
|
||||
|
||||
float sW, sT;
|
||||
m_hVGUIScreen->GetSize( sW, sT );
|
||||
//Msg( "Screen width: %f, new height: %f\n", sW, sW * (lT / m_hScreenEntity->GetResolution()) );
|
||||
m_hVGUIScreen->SetHeight( sW * ((float)lT / (float)m_hScreenEntity->GetResolution()) );
|
||||
m_hVGUIScreen->SetPixelHeight( lT );
|
||||
break;
|
||||
|
||||
default:
|
||||
SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
|
||||
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
|
||||
break;
|
||||
}
|
||||
|
||||
m_pDisplayTextLabel->SetContentAlignment( iAlignment );
|
||||
|
||||
bool bWrap = true;
|
||||
|
||||
@@ -487,6 +487,9 @@ int C_ServerRagdoll::InternalDrawModel( int flags )
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
static ConVar g_ragdoll_server_snatch_instance( "g_ragdoll_server_snatch_instance", "1", FCVAR_NONE, "Allows serverside ragdolls to snatch their source entities' model instances in the same way clientside ragdolls do, thereby retaining decals." );
|
||||
#endif
|
||||
|
||||
CStudioHdr *C_ServerRagdoll::OnNewModel( void )
|
||||
{
|
||||
@@ -509,6 +512,26 @@ CStudioHdr *C_ServerRagdoll::OnNewModel( void )
|
||||
m_iv_ragAngles.SetMaxCount( m_elementCount );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
if ( GetOwnerEntity() )
|
||||
{
|
||||
if (GetOwnerEntity()->GetModelName() == GetModelName())
|
||||
{
|
||||
// TODO: Is there a better place for this?
|
||||
if (GetOwnerEntity()->GetBaseAnimating())
|
||||
GetOwnerEntity()->GetBaseAnimating()->m_pServerRagdoll = this;
|
||||
|
||||
if (g_ragdoll_server_snatch_instance.GetBool())
|
||||
{
|
||||
GetOwnerEntity()->SnatchModelInstance( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add server ragdolls to the creation tick list
|
||||
NoteRagdollCreationTick( this );
|
||||
#endif
|
||||
|
||||
return hdr;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ extern ConVar cl_forwardspeed;
|
||||
static ConVar v_centermove( "v_centermove", "0.15");
|
||||
static ConVar v_centerspeed( "v_centerspeed","500" );
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
#if defined(TF_CLIENT_DLL) || defined(MAPBASE)
|
||||
// 54 degrees approximates a 35mm camera - we determined that this makes the viewmodels
|
||||
// and motions look the most natural.
|
||||
ConVar v_viewmodel_fov( "viewmodel_fov", "54", FCVAR_ARCHIVE );
|
||||
|
||||
@@ -29,6 +29,9 @@ static ConVar mat_wateroverlaysize( "mat_wateroverlaysize", "256" );
|
||||
static ConVar mat_showframebuffertexture( "mat_showframebuffertexture", "0", FCVAR_CHEAT );
|
||||
static ConVar mat_framebuffercopyoverlaysize( "mat_framebuffercopyoverlaysize", "256" );
|
||||
static ConVar mat_showcamerarendertarget( "mat_showcamerarendertarget", "0", FCVAR_CHEAT );
|
||||
#ifdef MAPBASE
|
||||
static ConVar mat_showcamerarendertarget_all( "mat_showcamerarendertarget_all", "0", FCVAR_CHEAT );
|
||||
#endif
|
||||
static ConVar mat_camerarendertargetoverlaysize( "mat_camerarendertargetoverlaysize", "256", FCVAR_CHEAT );
|
||||
static ConVar mat_hsv( "mat_hsv", "0", FCVAR_CHEAT );
|
||||
static ConVar mat_yuv( "mat_yuv", "0", FCVAR_CHEAT );
|
||||
@@ -178,6 +181,11 @@ void OverlayCameraRenderTarget( const char *pszMaterialName, float flX, float fl
|
||||
pMaterial = materials->FindMaterial( pszMaterialName, TEXTURE_GROUP_OTHER, true );
|
||||
if( !IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
// HACKHACK
|
||||
pMaterial->IncrementReferenceCount();
|
||||
#endif
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
pRenderContext->Bind( pMaterial );
|
||||
IMesh* pMesh = pRenderContext->GetDynamicMesh( true );
|
||||
@@ -203,6 +211,11 @@ void OverlayCameraRenderTarget( const char *pszMaterialName, float flX, float fl
|
||||
|
||||
meshBuilder.End();
|
||||
pMesh->Draw();
|
||||
|
||||
#ifdef MAPBASE
|
||||
// HACKHACK
|
||||
pMaterial->DecrementReferenceCount();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +227,11 @@ static void OverlayFrameBufferTexture( int nFrameBufferIndex )
|
||||
IMaterial *pMaterial;
|
||||
char buf[MAX_PATH];
|
||||
Q_snprintf( buf, MAX_PATH, "debug/debugfbtexture%d", nFrameBufferIndex );
|
||||
#ifdef MAPBASE
|
||||
pMaterial = materials->FindMaterial( buf, NULL, true );
|
||||
#else
|
||||
pMaterial = materials->FindMaterial( buf, TEXTURE_GROUP_OTHER, true );
|
||||
#endif
|
||||
if( !IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
@@ -586,12 +603,52 @@ void CDebugViewRender::Draw2DDebuggingInfo( const CViewSetup &view )
|
||||
|
||||
if ( mat_showcamerarendertarget.GetBool() )
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
float w = mat_camerarendertargetoverlaysize.GetFloat();
|
||||
float h = mat_camerarendertargetoverlaysize.GetFloat();
|
||||
#else
|
||||
float w = mat_wateroverlaysize.GetFloat();
|
||||
float h = mat_wateroverlaysize.GetFloat();
|
||||
#endif
|
||||
#ifdef PORTAL
|
||||
g_pPortalRender->OverlayPortalRenderTargets( w, h );
|
||||
#else
|
||||
|
||||
#ifdef MAPBASE
|
||||
int iCameraNum = mat_showcamerarendertarget.GetInt();
|
||||
|
||||
if (iCameraNum == 1) // Display the default camera
|
||||
{
|
||||
OverlayCameraRenderTarget( "debug/debugcamerarendertarget", 0, 0, w, h );
|
||||
}
|
||||
else if (mat_showcamerarendertarget_all.GetBool()) // Display all cameras
|
||||
{
|
||||
OverlayCameraRenderTarget( "debug/debugcamerarendertarget", 0, 0, w, h );
|
||||
|
||||
// Already showed one camera
|
||||
iCameraNum--;
|
||||
|
||||
// Show Mapbase's cameras
|
||||
char szTextureName[48];
|
||||
for (int i = 0; i < iCameraNum; i++)
|
||||
{
|
||||
V_snprintf( szTextureName, sizeof( szTextureName ), "debug/debugcamerarendertarget_camera%i", i );
|
||||
|
||||
// Show them vertically if the cvar is set to 2
|
||||
if (mat_showcamerarendertarget_all.GetInt() == 2)
|
||||
OverlayCameraRenderTarget( szTextureName, 0, h * (i + 1), w, h );
|
||||
else
|
||||
OverlayCameraRenderTarget( szTextureName, w * (i + 1), 0, w, h );
|
||||
}
|
||||
}
|
||||
else // Display one of the new cameras
|
||||
{
|
||||
OverlayCameraRenderTarget( VarArgs( "debug/debugcamerarendertarget_camera%i", iCameraNum-2 ), 0, 0, w, h );
|
||||
}
|
||||
#else
|
||||
OverlayCameraRenderTarget( "debug/debugcamerarendertarget", 0, 0, w, h );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -655,6 +712,57 @@ CON_COMMAND_F( r_screenoverlay, "Draw specified material as an overlay", FCVAR_C
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// The same as above, but using the new indexed overlays
|
||||
//-----------------------------------------------------------------------------
|
||||
CON_COMMAND_F( r_screenoverlay_indexed, "Draw specified material as an overlay in the specified index", FCVAR_CHEAT|FCVAR_SERVER_CAN_EXECUTE )
|
||||
{
|
||||
if( args.ArgC() == 3 )
|
||||
{
|
||||
int index = atoi( args[1] );
|
||||
if (index < 0 || index >= MAX_SCREEN_OVERLAYS)
|
||||
{
|
||||
Warning( "r_screenoverlay_indexed: '%i' is out of range (should be 0-9)\n", index );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( "off", args[2] ) )
|
||||
{
|
||||
view->SetIndexedScreenOverlayMaterial( index, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindMaterial( args[2], TEXTURE_GROUP_OTHER, false );
|
||||
if ( !IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
view->SetIndexedScreenOverlayMaterial( index, pMaterial );
|
||||
}
|
||||
else
|
||||
{
|
||||
view->SetIndexedScreenOverlayMaterial( index, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( args.ArgC() == 2 )
|
||||
{
|
||||
int index = atoi( args[1] );
|
||||
if (index < 0 || index >= MAX_SCREEN_OVERLAYS)
|
||||
{
|
||||
Warning( "r_screenoverlay_indexed: '%i' is out of range (should be 0-9)\n", index );
|
||||
return;
|
||||
}
|
||||
|
||||
IMaterial *pMaterial = view->GetIndexedScreenOverlayMaterial( index );
|
||||
Warning( "r_screenoverlay_indexed %i: %s\n", index, pMaterial ? pMaterial->GetName() : "off" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Format: r_screenoverlay_indexed <index> <material> %s\n" );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Used to verify frame syncing.
|
||||
void CDebugViewRender::GenerateOverdrawForTesting()
|
||||
{
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
|
||||
#ifdef MAPBASE
|
||||
#include "mapbase/c_func_fake_worldportal.h"
|
||||
#include "colorcorrectionmgr.h"
|
||||
#endif
|
||||
|
||||
// Projective textures
|
||||
@@ -1218,6 +1219,73 @@ IMaterial *CViewRender::GetScreenOverlayMaterial( )
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the screen space effect material (can't be done during rendering)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CViewRender::SetIndexedScreenOverlayMaterial( int i, IMaterial *pMaterial )
|
||||
{
|
||||
if (i < 0 || i >= MAX_SCREEN_OVERLAYS)
|
||||
return;
|
||||
|
||||
m_IndexedScreenOverlayMaterials[i].Init( pMaterial );
|
||||
|
||||
if (pMaterial == NULL)
|
||||
{
|
||||
// Check if we should set to false
|
||||
int i;
|
||||
for (i = 0; i < MAX_SCREEN_OVERLAYS; i++)
|
||||
{
|
||||
if (m_IndexedScreenOverlayMaterials[i] != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == MAX_SCREEN_OVERLAYS)
|
||||
m_bUsingIndexedScreenOverlays = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bUsingIndexedScreenOverlays = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
IMaterial *CViewRender::GetIndexedScreenOverlayMaterial( int i )
|
||||
{
|
||||
if (i < 0 || i >= MAX_SCREEN_OVERLAYS)
|
||||
return NULL;
|
||||
|
||||
return m_IndexedScreenOverlayMaterials[i];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CViewRender::ResetIndexedScreenOverlays()
|
||||
{
|
||||
for (int i = 0; i < MAX_SCREEN_OVERLAYS; i++)
|
||||
{
|
||||
m_IndexedScreenOverlayMaterials[i].Init( NULL );
|
||||
}
|
||||
|
||||
m_bUsingIndexedScreenOverlays = false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CViewRender::GetMaxIndexedScreenOverlays( ) const
|
||||
{
|
||||
return MAX_SCREEN_OVERLAYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Performs screen space effects, if any
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1254,6 +1322,44 @@ void CViewRender::PerformScreenOverlay( int x, int y, int w, int h )
|
||||
render->ViewDrawFade( color, m_ScreenOverlayMaterial );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
if (m_bUsingIndexedScreenOverlays)
|
||||
{
|
||||
for (int i = 0; i < MAX_SCREEN_OVERLAYS; i++)
|
||||
{
|
||||
if (!m_IndexedScreenOverlayMaterials[i])
|
||||
continue;
|
||||
|
||||
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s", __FUNCTION__ );
|
||||
|
||||
if ( m_IndexedScreenOverlayMaterials[i]->NeedsFullFrameBufferTexture() )
|
||||
{
|
||||
// FIXME: check with multi/sub-rect renders. Should this be 0,0,w,h instead?
|
||||
DrawScreenEffectMaterial( m_IndexedScreenOverlayMaterials[i], x, y, w, h );
|
||||
}
|
||||
else if ( m_IndexedScreenOverlayMaterials[i]->NeedsPowerOfTwoFrameBufferTexture() )
|
||||
{
|
||||
// First copy the FB off to the offscreen texture
|
||||
UpdateRefractTexture( x, y, w, h, true );
|
||||
|
||||
// Now draw the entire screen using the material...
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
ITexture *pTexture = GetPowerOfTwoFrameBufferTexture( );
|
||||
int sw = pTexture->GetActualWidth();
|
||||
int sh = pTexture->GetActualHeight();
|
||||
// Note - don't offset by x,y - already done by the viewport.
|
||||
pRenderContext->DrawScreenSpaceRectangle( m_IndexedScreenOverlayMaterials[i], 0, 0, w, h,
|
||||
0, 0, sw-1, sh-1, sw, sh );
|
||||
}
|
||||
else
|
||||
{
|
||||
byte color[4] = { 255, 255, 255, 255 };
|
||||
render->ViewDrawFade( color, m_IndexedScreenOverlayMaterials[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CViewRender::DrawUnderwaterOverlay( void )
|
||||
@@ -2005,18 +2111,19 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
|
||||
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
|
||||
|
||||
cplane_t portalPlane;
|
||||
Vector vecPlaneOrigin;
|
||||
//C_FuncFakeWorldPortal *pPortalEnt = IsFakeWorldPortalInView( view, portalPlane );
|
||||
//if ( pPortalEnt )
|
||||
C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal( NULL, view, portalPlane, frustum );
|
||||
C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal( NULL, view, portalPlane, vecPlaneOrigin, frustum );
|
||||
while ( pPortalEnt != NULL )
|
||||
{
|
||||
ITexture *pCameraTarget = pPortalEnt->RenderTarget();
|
||||
int width = pCameraTarget->GetActualWidth();
|
||||
int height = pCameraTarget->GetActualHeight();
|
||||
|
||||
DrawFakeWorldPortal( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer(), 0, 0, width, height, view, portalPlane );
|
||||
DrawFakeWorldPortal( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer(), 0, 0, width, height, view, portalPlane, vecPlaneOrigin );
|
||||
|
||||
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, portalPlane, frustum );
|
||||
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, portalPlane, vecPlaneOrigin, frustum );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2027,6 +2134,10 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
|
||||
// Must be first
|
||||
render->SceneBegin();
|
||||
|
||||
#ifdef MAPBASE // From Alien Swarm SDK
|
||||
g_pColorCorrectionMgr->UpdateColorCorrection();
|
||||
#endif
|
||||
|
||||
pRenderContext.GetFrom( materials );
|
||||
pRenderContext->TurnOnToneMapping();
|
||||
pRenderContext.SafeRelease();
|
||||
@@ -3434,8 +3545,7 @@ ConVar r_fakeworldportal_debug("r_fakeworldportal_debug", "0");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets up scene and renders WIP fake world portal view.
|
||||
// Based on code from monitors, mirrors, and 3D skyboxes.
|
||||
// It's also terrible right now.
|
||||
// Based on code from monitors, mirrors, and logic_measure_movement.
|
||||
//
|
||||
// Input : cameraNum -
|
||||
// &cameraView
|
||||
@@ -3449,7 +3559,7 @@ ConVar r_fakeworldportal_debug("r_fakeworldportal_debug", "0");
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
|
||||
int x, int y, int width, int height,
|
||||
const CViewSetup &mainView, cplane_t &ourPlane )
|
||||
const CViewSetup &mainView, cplane_t &ourPlane, const Vector &vecPlaneOrigin )
|
||||
{
|
||||
#ifdef USE_MONITORS
|
||||
VPROF_INCREMENT_COUNTER( "cameras rendered", 1 );
|
||||
@@ -3488,97 +3598,89 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
|
||||
monitorView.origin = mainView.origin;
|
||||
monitorView.angles = mainView.angles;
|
||||
|
||||
// Temporary debug stuff
|
||||
// Debug stuff
|
||||
static float flLastDebugTime = 0.0f;
|
||||
bool bDebug = r_fakeworldportal_debug.GetBool() && gpGlobals->curtime > flLastDebugTime;
|
||||
|
||||
QAngle angTargetAngles = pCameraEnt->m_hTargetPlane->GetAbsAngles() + pCameraEnt->m_PlaneAngles;
|
||||
|
||||
// RED - First origin
|
||||
if (bDebug)
|
||||
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 0, 0, 128, 10.0f );
|
||||
|
||||
// Make sure the origin and angles are relative to the target plane
|
||||
monitorView.origin -= pCameraEnt->GetAbsOrigin();
|
||||
|
||||
// scale origin by sky scale
|
||||
if ( pCameraEnt->m_flScale > 0 )
|
||||
{
|
||||
float scale = 1.0f / pCameraEnt->m_flScale;
|
||||
VectorScale( monitorView.origin, scale, monitorView.origin );
|
||||
}
|
||||
|
||||
// YELLOW - Main origin
|
||||
if (bDebug)
|
||||
debugoverlay->AddBoxOverlay( pCameraEnt->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 224, 0, 128, 10.0f );
|
||||
|
||||
// Make sure our angles are relative to the main plane, just like the origin
|
||||
QAngle angOurAngles;
|
||||
VectorAngles( ourPlane.normal * -1, angOurAngles );
|
||||
//angles -= angOurAngles;
|
||||
|
||||
// First, create a matrix for the sky's angles.
|
||||
matrix3x4_t matSkyAngles;
|
||||
AngleMatrix( angTargetAngles - angOurAngles, matSkyAngles );
|
||||
|
||||
Vector vecSkyForward, vecSkyRight, vecSkyUp;
|
||||
//
|
||||
// Calculate the angles for the fake portal plane
|
||||
//
|
||||
QAngle angTargetAngles = pCameraEnt->m_hTargetPlane->GetAbsAngles() - pCameraEnt->m_PlaneAngles;
|
||||
QAngle angFakePortalAngles;
|
||||
|
||||
// Get vectors from our original angles.
|
||||
Vector vPlayerForward, vPlayerRight, vPlayerUp;
|
||||
AngleVectors( monitorView.angles, &vPlayerForward, &vPlayerRight, &vPlayerUp );
|
||||
|
||||
VectorTransform( vPlayerForward, matSkyAngles, vecSkyForward );
|
||||
VectorTransform( vPlayerRight, matSkyAngles, vecSkyRight );
|
||||
VectorTransform( vPlayerUp, matSkyAngles, vecSkyUp );
|
||||
|
||||
// Normalize them.
|
||||
VectorNormalize( vecSkyForward );
|
||||
VectorNormalize( vecSkyRight );
|
||||
VectorNormalize( vecSkyUp );
|
||||
Vector vOurForward, vOurRight, vOurUp;
|
||||
AngleVectors( pCameraEnt->GetAbsAngles(), &vOurForward, &vOurRight, &vOurUp );
|
||||
|
||||
Quaternion quat;
|
||||
BasisToQuaternion( vecSkyForward, vecSkyRight, vecSkyUp, quat );
|
||||
QuaternionAngles( quat, monitorView.angles );
|
||||
BasisToQuaternion( ourPlane.normal, vOurRight, vOurUp, quat );
|
||||
QuaternionAngles( quat, angFakePortalAngles );
|
||||
|
||||
// End of code mostly lifted from projected texture screenspace stuff
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Now just rotate our origin with that matrix.
|
||||
// We create a copy of the origin since VectorRotate doesn't want in1 to be the same variable as the destination.
|
||||
VectorRotate(Vector(monitorView.origin), matSkyAngles, monitorView.origin);
|
||||
|
||||
// BLUE - Target origin
|
||||
if (bDebug)
|
||||
debugoverlay->AddBoxOverlay( pCameraEnt->m_hTargetPlane->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 0, 0, 255, 128, 10.0f );
|
||||
|
||||
monitorView.origin += pCameraEnt->m_hTargetPlane->GetAbsOrigin();
|
||||
|
||||
// GREEN - Final origin
|
||||
if (bDebug)
|
||||
{
|
||||
// RED - Initial player origin
|
||||
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 0, 0, 128, 10.0f );
|
||||
|
||||
// YELLOW - Portal origin
|
||||
debugoverlay->AddBoxOverlay( pCameraEnt->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), angFakePortalAngles, 255, 224, 0, 128, 10.0f );
|
||||
}
|
||||
|
||||
//
|
||||
// Translate the actual portal view position to be relative to the target
|
||||
//
|
||||
matrix3x4_t matPlayer, matPortal, matPlayerToPortal;
|
||||
AngleIMatrix( monitorView.angles, monitorView.origin, matPlayer );
|
||||
AngleMatrix( angFakePortalAngles, pCameraEnt->GetAbsOrigin(), matPortal );
|
||||
ConcatTransforms( matPlayer, matPortal, matPlayerToPortal );
|
||||
|
||||
// Apply the scale factor
|
||||
if ( pCameraEnt->m_flScale > 0 )
|
||||
{
|
||||
Vector vecTranslation;
|
||||
MatrixGetColumn( matPlayerToPortal, 3, vecTranslation );
|
||||
vecTranslation /= pCameraEnt->m_flScale;
|
||||
MatrixSetColumn( vecTranslation, 3, matPlayerToPortal );
|
||||
}
|
||||
|
||||
matrix3x4_t matTarget;
|
||||
AngleMatrix( angTargetAngles, pCameraEnt->m_hTargetPlane->GetAbsOrigin(), matTarget );
|
||||
|
||||
// Now apply the new matrix to the new reference point
|
||||
matrix3x4_t matPortalToPlayer, matNewPlayerPosition;
|
||||
MatrixInvert( matPlayerToPortal, matPortalToPlayer );
|
||||
|
||||
ConcatTransforms( matTarget, matPortalToPlayer, matNewPlayerPosition );
|
||||
|
||||
MatrixAngles( matNewPlayerPosition, monitorView.angles, monitorView.origin );
|
||||
|
||||
if (bDebug)
|
||||
{
|
||||
// BLUE - Target origin
|
||||
debugoverlay->AddBoxOverlay( pCameraEnt->m_hTargetPlane->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), angTargetAngles, 0, 0, 255, 128, 10.0f );
|
||||
|
||||
// GREEN - Final origin
|
||||
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 0, 255, 0, 128, 10.0f );
|
||||
|
||||
flLastDebugTime = gpGlobals->curtime + 5.0f;
|
||||
}
|
||||
|
||||
|
||||
monitorView.fov = mainView.fov;
|
||||
monitorView.m_bOrtho = false;
|
||||
monitorView.m_flAspectRatio = 0.0f;
|
||||
monitorView.m_bOrtho = mainView.m_bOrtho;
|
||||
monitorView.m_flAspectRatio = mainView.m_flAspectRatio;
|
||||
monitorView.m_bViewToProjectionOverride = false;
|
||||
|
||||
// @MULTICORE (toml 8/11/2006): this should be a renderer....
|
||||
int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR | VIEW_CLEAR_OBEY_STENCIL);
|
||||
bool bDrew3dSkybox = false;
|
||||
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
|
||||
|
||||
Frustum frustum;
|
||||
render->Push3DView( monitorView, nClearFlags, pRenderTarget, (VPlane *)frustum );
|
||||
|
||||
//
|
||||
// Monitor sky handling
|
||||
// Sky handling
|
||||
//
|
||||
if ( pCameraEnt->SkyMode() == SKYBOX_3DSKYBOX_VISIBLE )
|
||||
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
|
||||
if ( nSkyMode == SKYBOX_3DSKYBOX_VISIBLE )
|
||||
{
|
||||
// if the 3d skybox world is drawn, then don't draw the normal skybox
|
||||
CSkyboxView *pSkyView = new CSkyboxView( this );
|
||||
@@ -3589,16 +3691,21 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
|
||||
SafeRelease( pSkyView );
|
||||
}
|
||||
|
||||
//
|
||||
// Make a clipping plane for the target view
|
||||
//
|
||||
Vector4D plane;
|
||||
|
||||
// Combine the target angles and the plane angles
|
||||
Vector vecAnglesNormal( angTargetAngles.x, angTargetAngles.y, angTargetAngles.z );
|
||||
Vector vecAnglesNormal;
|
||||
AngleVectors( angTargetAngles, &vecAnglesNormal );
|
||||
VectorNormalize( vecAnglesNormal );
|
||||
VectorCopy( vecAnglesNormal, plane.AsVector3D() );
|
||||
VectorCopy( -vecAnglesNormal, plane.AsVector3D() );
|
||||
|
||||
// TODO: How do we get a good value for this!?!?
|
||||
//plane.w = m_OurPlane.dist + 0.1f;
|
||||
plane.w = -32.0f + 0.1f;
|
||||
// The portal plane's distance from the actual brush's origin
|
||||
float flPlaneDist = vecPlaneOrigin.Length();
|
||||
|
||||
// The target's distance from world origin
|
||||
plane.w = -((pCameraEnt->m_hTargetPlane->GetAbsOrigin() * vecAnglesNormal).Length() + flPlaneDist) + 0.1f;
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
pRenderContext->PushCustomClipPlane( plane.Base() );
|
||||
|
||||
@@ -454,7 +454,7 @@ private:
|
||||
#ifdef MAPBASE
|
||||
bool DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
|
||||
int x, int y, int width, int height,
|
||||
const CViewSetup &mainView, cplane_t &ourPlane );
|
||||
const CViewSetup &mainView, cplane_t &ourPlane, const Vector &vecPlaneOrigin );
|
||||
#endif
|
||||
|
||||
// Drawing primitives
|
||||
@@ -468,6 +468,13 @@ private:
|
||||
IMaterial *GetScreenOverlayMaterial( );
|
||||
void PerformScreenOverlay( int x, int y, int w, int h );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void SetIndexedScreenOverlayMaterial( int i, IMaterial *pMaterial );
|
||||
IMaterial *GetIndexedScreenOverlayMaterial( int i );
|
||||
void ResetIndexedScreenOverlays();
|
||||
int GetMaxIndexedScreenOverlays() const;
|
||||
#endif
|
||||
|
||||
void DrawUnderwaterOverlay( void );
|
||||
|
||||
// Water-related methods
|
||||
@@ -511,6 +518,10 @@ private:
|
||||
CMaterialReference m_TranslucentSingleColor;
|
||||
CMaterialReference m_ModulateSingleColor;
|
||||
CMaterialReference m_ScreenOverlayMaterial;
|
||||
#ifdef MAPBASE
|
||||
CMaterialReference m_IndexedScreenOverlayMaterials[MAX_SCREEN_OVERLAYS];
|
||||
bool m_bUsingIndexedScreenOverlays;
|
||||
#endif
|
||||
CMaterialReference m_UnderWaterOverlayMaterial;
|
||||
|
||||
Vector m_vecLastFacing;
|
||||
|
||||
@@ -41,10 +41,13 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
||||
#endif // VMPROFILE
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
static ScriptHook_t g_Hook_OnEntityCreated;
|
||||
static ScriptHook_t g_Hook_OnEntityDeleted;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A clientside variant of CScriptEntityIterator.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CScriptClientEntityIterator
|
||||
class CScriptClientEntityIterator : public IClientEntityListener
|
||||
{
|
||||
public:
|
||||
HSCRIPT GetLocalPlayer()
|
||||
@@ -96,6 +99,38 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void EnableEntityListening()
|
||||
{
|
||||
// Start getting entity updates!
|
||||
ClientEntityList().AddListenerEntity( this );
|
||||
}
|
||||
|
||||
void DisableEntityListening()
|
||||
{
|
||||
// Stop getting entity updates!
|
||||
ClientEntityList().RemoveListenerEntity( this );
|
||||
}
|
||||
|
||||
void OnEntityCreated( CBaseEntity *pEntity )
|
||||
{
|
||||
if ( g_pScriptVM )
|
||||
{
|
||||
// entity
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pEntity->GetScriptInstance() ) };
|
||||
g_Hook_OnEntityCreated.Call( NULL, NULL, args );
|
||||
}
|
||||
};
|
||||
|
||||
void OnEntityDeleted( CBaseEntity *pEntity )
|
||||
{
|
||||
if ( g_pScriptVM )
|
||||
{
|
||||
// entity
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pEntity->GetScriptInstance() ) };
|
||||
g_Hook_OnEntityDeleted.Call( NULL, NULL, args );
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
} g_ScriptEntityIterator;
|
||||
|
||||
@@ -106,6 +141,17 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptClientEntityIterator, "CEntities", SCRIPT_SI
|
||||
DEFINE_SCRIPTFUNC( CreateByClassname, "Creates an entity by classname" )
|
||||
DEFINE_SCRIPTFUNC( FindByClassname, "Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search" )
|
||||
DEFINE_SCRIPTFUNC( FindByName, "Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( EnableEntityListening, "Enables the 'OnEntity' hooks. This function must be called before using them." )
|
||||
DEFINE_SCRIPTFUNC( DisableEntityListening, "Disables the 'OnEntity' hooks." )
|
||||
|
||||
BEGIN_SCRIPTHOOK( g_Hook_OnEntityCreated, "OnEntityCreated", FIELD_VOID, "Called when an entity is created. Requires EnableEntityListening() to be fired beforehand." )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "entity", FIELD_HSCRIPT )
|
||||
END_SCRIPTHOOK()
|
||||
|
||||
BEGIN_SCRIPTHOOK( g_Hook_OnEntityDeleted, "OnEntityDeleted", FIELD_VOID, "Called when an entity is deleted. Requires EnableEntityListening() to be fired beforehand." )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "entity", FIELD_HSCRIPT )
|
||||
END_SCRIPTHOOK()
|
||||
END_SCRIPTDESC();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user