upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462903 additions and 495158 deletions

View File

@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Client DLL VGUI2 Viewport
//
@@ -26,8 +26,8 @@
#include <vgui/IScheme.h>
#include <vgui/IVGui.h>
#include <vgui/ILocalize.h>
#include <vgui/IPanel.h>
#include <vgui_controls/Button.h>
#include <vgui/ipanel.h>
#include <vgui_controls/button.h>
#include <igameresources.h>
@@ -48,76 +48,74 @@
#include <convar.h>
#include "ienginevgui.h"
#include "iclientmode.h"
#include "vgui_int.h"
#include "tier0/etwprof.h"
#if defined( REPLAY_ENABLED )
#include "replay/ireplaysystem.h"
#include "replay/ienginereplay.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
IViewPort *gViewPortInterface = NULL;
static IViewPort *s_pFullscreenViewportInterface;
static IViewPort *s_pViewportInterfaces[ MAX_SPLITSCREEN_PLAYERS ];
IViewPort *GetViewPortInterface()
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
return s_pViewportInterfaces[ GET_ACTIVE_SPLITSCREEN_SLOT() ];
}
IViewPort *GetFullscreenViewPortInterface()
{
return s_pFullscreenViewportInterface;
}
vgui::Panel *g_lastPanel = NULL; // used for mouseover buttons, keeps track of the last active panel
vgui::Button *g_lastButton = NULL; // used for mouseover buttons, keeps track of the last active button
using namespace vgui;
void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue );
ConVar hud_autoreloadscript("hud_autoreloadscript", "0", FCVAR_NONE, "Automatically reloads the animation script each time one is ran", hud_autoreloadscript_callback);
void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue )
{
if ( g_pClientMode && g_pClientMode->GetViewportAnimationController() )
{
g_pClientMode->GetViewportAnimationController()->SetAutoReloadScript( hud_autoreloadscript.GetBool() );
}
}
ConVar hud_autoreloadscript("hud_autoreloadscript", "0", FCVAR_NONE, "Automatically reloads the animation script each time one is ran");
static ConVar cl_leveloverviewmarker( "cl_leveloverviewmarker", "0", FCVAR_CHEAT );
CON_COMMAND( showpanel, "Shows a viewport panel <name>" )
{
if ( !gViewPortInterface )
if ( !GetViewPortInterface() )
return;
if ( args.ArgC() != 2 )
return;
gViewPortInterface->ShowPanel( args[ 1 ], true );
GetViewPortInterface()->ShowPanel( args[ 1 ], true );
}
CON_COMMAND( hidepanel, "Hides a viewport panel <name>" )
{
if ( !gViewPortInterface )
if ( !GetViewPortInterface() )
return;
if ( args.ArgC() != 2 )
return;
gViewPortInterface->ShowPanel( args[ 1 ], false );
GetViewPortInterface()->ShowPanel( args[ 1 ], false );
}
/* global helper functions
bool Helper_LoadFile( IBaseFileSystem *pFileSystem, const char *pFilename, CUtlVector<char> &buf )
{
FileHandle_t hFile = pFileSystem->Open( pFilename, "rt" );
if ( hFile == FILESYSTEM_INVALID_HANDLE )
{
Warning( "Helper_LoadFile: missing %s\n", pFilename );
return false;
}
FileHandle_t hFile = pFileSystem->Open( pFilename, "rt" );
if ( hFile == FILESYSTEM_INVALID_HANDLE )
{
Warning( "Helper_LoadFile: missing %s\n", pFilename );
return false;
}
unsigned long len = pFileSystem->Size( hFile );
buf.SetSize( len );
pFileSystem->Read( buf.Base(), buf.Count(), hFile );
pFileSystem->Close( hFile );
unsigned long len = pFileSystem->Size( hFile );
buf.SetSize( len );
pFileSystem->Read( buf.Base(), buf.Count(), hFile );
pFileSystem->Close( hFile );
return true;
return true;
} */
//-----------------------------------------------------------------------------
@@ -157,11 +155,10 @@ bool CBaseViewport::LoadHudAnimations( void )
}
//================================================================
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
{
SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
gViewPortInterface = this;
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport" )
{
m_bInitialized = false;
m_bFullscreenViewport = false;
m_GameuiFuncs = NULL;
m_GameEventManager = NULL;
@@ -174,30 +171,18 @@ CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
m_bHasParent = false;
m_pActivePanel = NULL;
m_pLastActivePanel = NULL;
g_lastPanel = NULL;
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ClientScheme.res", "ClientScheme");
SetScheme(scheme);
SetProportional( true );
m_pAnimController = new vgui::AnimationController(this);
// create our animation controller
m_pAnimController->SetScheme(scheme);
m_pAnimController->SetProportional(true);
// Attempt to load all hud animations
if ( LoadHudAnimations() == false )
{
// Fall back to just the main
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
{
Assert(0);
}
}
m_OldSize[ 0 ] = m_OldSize[ 1 ] = -1;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
vgui::VPANEL CBaseViewport::GetSchemeSizingVPanel( void )
{
return VGui_GetFullscreenRootVPANEL();
}
//-----------------------------------------------------------------------------
// Purpose: Updates hud to handle the new screen size
//-----------------------------------------------------------------------------
@@ -205,9 +190,6 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
{
BaseClass::OnScreenSizeChanged(iOldWide, iOldTall);
IViewPortPanel* pSpecGuiPanel = FindPanelByName(PANEL_SPECGUI);
bool bSpecGuiWasVisible = pSpecGuiPanel && pSpecGuiPanel->IsVisible();
// reload the script file, so the screen positions in it are correct for the new resolution
ReloadScheme( NULL );
@@ -218,7 +200,12 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
m_pBackGround->SetZPos( -20 ); // send it to the back
m_pBackGround->SetVisible( false );
#endif
CreateDefaultPanels();
if ( !IsFullscreenViewport() )
{
CreateDefaultPanels();
}
#ifndef _XBOX
vgui::ipanel()->MoveToBack( m_pBackGround->GetVPanel() ); // really send it to the back
#endif
@@ -226,8 +213,7 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
// hide all panels when reconnecting
ShowPanel( PANEL_ALL, false );
// re-enable the spectator gui if it was previously visible
if ( bSpecGuiWasVisible )
if ( g_bEngineIsHLTV || engine->IsReplay() )
{
ShowPanel( PANEL_SPECGUI, true );
}
@@ -235,24 +221,23 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
void CBaseViewport::CreateDefaultPanels( void )
{
#ifndef _XBOX
AddNewPanel( CreatePanelByName( PANEL_SCOREBOARD ), "PANEL_SCOREBOARD" );
AddNewPanel( CreatePanelByName( PANEL_INFO ), "PANEL_INFO" );
AddNewPanel( CreatePanelByName( PANEL_SPECGUI ), "PANEL_SPECGUI" );
#if !defined( TF_CLIENT_DLL )
AddNewPanel( CreatePanelByName( PANEL_SPECMENU ), "PANEL_SPECMENU" );
AddNewPanel( CreatePanelByName( PANEL_NAV_PROGRESS ), "PANEL_NAV_PROGRESS" );
#endif // !TF_CLIENT_DLL
#endif // !_XBOX
}
void CBaseViewport::UpdateAllPanels( void )
{
int count = m_Panels.Count();
int nSlot = vgui::ipanel()->GetMessageContextId( GetVPanel() );
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( nSlot );
for (int i=0; i< count; i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *p = m_Panels[i];
IViewPortPanel *p = m_UnorderedPanels[i];
if ( p->IsVisible() )
{
@@ -261,43 +246,6 @@ void CBaseViewport::UpdateAllPanels( void )
}
}
// Check if we have any visible panel (that's not the MainMenuOverride or the Scoreboard)
bool CBaseViewport::IsAnyPanelVisibleExceptScores()
{
int count = m_Panels.Count();
for ( int i = 0; i < count; i++ )
{
IViewPortPanel *p = m_Panels[i];
if ( p->IsVisible() && Q_strcmp("MainMenuOverride", p->GetName()) && Q_strcmp("scores", p->GetName()) )
{
return true;
}
}
return false;
}
bool CBaseViewport::IsPanelVisible( const char* panel )
{
int count = m_Panels.Count();
for ( int i = 0; i < count; i++ )
{
IViewPortPanel *p = m_Panels[i];
if ( p->IsVisible() )
{
const char* panel_name = p->GetName();
if ( !Q_strcmp( panel, panel_name ) )
{
return true;
}
}
}
return false;
}
IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
IViewPortPanel* newpanel = NULL;
@@ -311,9 +259,9 @@ IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
newpanel = new CTextWindow( this );
}
/* else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
/* else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
{
newpanel = new CMapOverview( this );
newpanel = new CMapOverview( this );
}
*/
else if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
@@ -328,19 +276,19 @@ IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
newpanel = new CSpectatorGUI( this );
}
#if !defined( TF_CLIENT_DLL )
else if ( Q_strcmp(PANEL_NAV_PROGRESS, szPanelName) == 0 )
{
newpanel = new CNavProgress( this );
}
#endif // TF_CLIENT_DLL
#endif
#endif // !XBOX
if ( Q_strcmp(PANEL_COMMENTARY_MODELVIEWER, szPanelName) == 0 )
{
newpanel = new CCommentaryModelViewer( this );
}
return newpanel;
}
@@ -349,7 +297,6 @@ bool CBaseViewport::AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugNam
{
if ( !pPanel )
{
DevMsg("CBaseViewport::AddNewPanel(%s): NULL panel.\n", pchDebugName );
return false;
}
@@ -360,23 +307,20 @@ bool CBaseViewport::AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugNam
return false;
}
m_Panels.AddToTail( pPanel );
m_Panels.Insert( pPanel->GetName(), pPanel );
pPanel->SetParent( GetVPanel() );
m_UnorderedPanels.AddToTail( pPanel );
return true;
}
IViewPortPanel* CBaseViewport::FindPanelByName(const char *szPanelName)
{
int count = m_Panels.Count();
int idx = m_Panels.Find( szPanelName );
if ( idx == m_Panels.InvalidIndex() )
return NULL;
for (int i=0; i< count; i++ )
{
if ( Q_strcmp(m_Panels[i]->GetName(), szPanelName) == 0 )
return m_Panels[i];
}
return NULL;
return m_Panels[ idx ];
}
void CBaseViewport::PostMessageToPanel( IViewPortPanel* pPanel, KeyValues *pKeyValues )
@@ -388,9 +332,10 @@ void CBaseViewport::PostMessageToPanel( const char *pName, KeyValues *pKeyValues
{
if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
{
for (int i=0; i< m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
PostMessageToPanel( m_Panels[i], pKeyValues );
IViewPortPanel *p = m_UnorderedPanels[i];
PostMessageToPanel( p, pKeyValues );
}
return;
@@ -414,13 +359,50 @@ void CBaseViewport::PostMessageToPanel( const char *pName, KeyValues *pKeyValues
}
void CBaseViewport::ShowPanel( const char *pName, bool state, KeyValues *data, bool autoDeleteData )
{
if ( !data )
{
ShowPanel( pName, state );
return;
}
// Also try to show the panel in the full screen viewport
if ( this != s_pFullscreenViewportInterface )
{
GetFullscreenViewPortInterface()->ShowPanel( pName, state, data, false );
}
IViewPortPanel *panel = FindPanelByName( pName );
if ( panel )
{
panel->SetData( data );
GetViewPortInterface()->ShowPanel( panel, state );
}
if ( autoDeleteData )
{
data->deleteThis();
}
}
void CBaseViewport::ShowPanel( const char *pName, bool state )
{
// Also try to show the panel in the full screen viewport
if ( this != s_pFullscreenViewportInterface )
{
GetFullscreenViewPortInterface()->ShowPanel( pName, state );
}
ASSERT_LOCAL_PLAYER_RESOLVABLE();
if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
{
for (int i=0; i< m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
ShowPanel( m_Panels[i], state );
IViewPortPanel *p = m_UnorderedPanels[i];
ShowPanel( p, state );
}
return;
@@ -436,7 +418,7 @@ void CBaseViewport::ShowPanel( const char *pName, bool state )
{
panel = FindPanelByName( pName );
}
if ( !panel )
return;
@@ -445,26 +427,34 @@ void CBaseViewport::ShowPanel( const char *pName, bool state )
void CBaseViewport::ShowPanel( IViewPortPanel* pPanel, bool state )
{
// Extra guard to get layout stuff correct
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( GET_ACTIVE_SPLITSCREEN_SLOT() );
if ( state )
{
// if this is an 'active' panel, deactivate old active panel
if ( pPanel->HasInputElements() )
{
// don't show input panels during normal demo playback
#if defined( REPLAY_ENABLED )
if ( engine->IsPlayingDemo() && !engine->IsHLTV() && !g_pEngineClientReplay->IsPlayingReplayDemo() )
#else
if ( engine->IsPlayingDemo() && !engine->IsHLTV() )
#endif
if ( engine->IsPlayingDemo() && !g_bEngineIsHLTV && !engine->IsReplay() )
return;
if ( (m_pActivePanel != NULL) && (m_pActivePanel != pPanel) && (m_pActivePanel->IsVisible()) )
{
// store a pointer to the currently active panel
// so we can restore it later
m_pLastActivePanel = m_pActivePanel;
m_pActivePanel->ShowPanel( false );
if ( pPanel->CanReplace( m_pActivePanel->GetName() ) )
{
m_pLastActivePanel = m_pActivePanel;
m_pActivePanel->ShowPanel( false );
}
else
{
m_pLastActivePanel = pPanel;
return;
}
}
m_pActivePanel = pPanel;
}
}
@@ -498,12 +488,45 @@ IViewPortPanel* CBaseViewport::GetActivePanel( void )
return m_pActivePanel;
}
void CBaseViewport::RecreatePanel( const char *szPanelName )
{
IViewPortPanel *panel = FindPanelByName( szPanelName );
if ( panel )
{
m_Panels.Remove( szPanelName );
for ( int i = m_UnorderedPanels.Count() - 1; i >= 0; --i )
{
if ( m_UnorderedPanels[ i ] == panel )
{
m_UnorderedPanels.Remove( i );
break;
}
}
vgui::VPANEL vPanel = panel->GetVPanel();
vgui::ipanel()->DeletePanel( vPanel );
if ( m_pActivePanel == panel )
{
m_pActivePanel = NULL;
}
if ( m_pLastActivePanel == panel )
{
m_pLastActivePanel = NULL;
}
AddNewPanel( CreatePanelByName( szPanelName ), szPanelName );
}
}
void CBaseViewport::RemoveAllPanels( void)
{
g_lastPanel = NULL;
for ( int i=0; i < m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
vgui::VPANEL vPanel = m_Panels[i]->GetVPanel();
IViewPortPanel *p = m_UnorderedPanels[i];
vgui::VPANEL vPanel = p->GetVPanel();
vgui::ipanel()->DeletePanel( vPanel );
}
#ifndef _XBOX
@@ -513,7 +536,8 @@ void CBaseViewport::RemoveAllPanels( void)
m_pBackGround = NULL;
}
#endif
m_Panels.Purge();
m_Panels.RemoveAll();
m_UnorderedPanels.RemoveAll();
m_pActivePanel = NULL;
m_pLastActivePanel = NULL;
}
@@ -530,10 +554,13 @@ CBaseViewport::~CBaseViewport()
m_pBackGround = NULL;
#endif
RemoveAllPanels();
gameeventmanager->RemoveListener( this );
}
void CBaseViewport::InitViewportSingletons( void )
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
s_pViewportInterfaces[ GET_ACTIVE_SPLITSCREEN_SLOT() ] = this;
}
//-----------------------------------------------------------------------------
// Purpose: called when the VGUI subsystem starts up
@@ -541,6 +568,8 @@ CBaseViewport::~CBaseViewport()
//-----------------------------------------------------------------------------
void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager )
{
InitViewportSingletons();
m_GameuiFuncs = pGameUIFuncs;
m_GameEventManager = pGameEventManager;
#ifndef _XBOX
@@ -548,10 +577,32 @@ void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGam
m_pBackGround->SetZPos( -20 ); // send it to the back
m_pBackGround->SetVisible( false );
#endif
CreateDefaultPanels();
m_GameEventManager->AddListener( this, "game_newmap", false );
ListenForGameEvent( "game_newmap" );
SetScheme( "ClientScheme" );
SetProportional( true );
if ( !IsFullscreenViewport() )
{
CreateDefaultPanels();
}
m_pAnimController = new vgui::AnimationController(this);
// create our animation controller
m_pAnimController->SetScheme( GetScheme() );
m_pAnimController->SetProportional(true);
// Attempt to load all hud animations
if ( LoadHudAnimations() == false )
{
// Fall back to just the main
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
{
Assert(0);
}
}
m_bInitialized = true;
}
@@ -559,37 +610,37 @@ void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGam
//-----------------------------------------------------------------------------
// Purpose: Updates the spectator panel with new player info
//-----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
void CBaseViewport::UpdateSpectatorPanel()
{
char bottomText[128];
int player = -1;
const char *name;
Q_snprintf(bottomText,sizeof( bottomText ), "#Spec_Mode%d", m_pClientDllInterface->SpectatorMode() );
char bottomText[128];
int player = -1;
const char *name;
Q_snprintf(bottomText,sizeof( bottomText ), "#Spec_Mode%d", m_pClientDllInterface->SpectatorMode() );
m_pClientDllInterface->CheckSettings();
// check if we're locked onto a target, show the player's name
if ( (m_pClientDllInterface->SpectatorTarget() > 0) && (m_pClientDllInterface->SpectatorTarget() <= m_pClientDllInterface->GetMaxPlayers()) && (m_pClientDllInterface->SpectatorMode() != OBS_ROAMING) )
{
player = m_pClientDllInterface->SpectatorTarget();
}
m_pClientDllInterface->CheckSettings();
// check if we're locked onto a target, show the player's name
if ( (m_pClientDllInterface->SpectatorTarget() > 0) && (m_pClientDllInterface->SpectatorTarget() <= m_pClientDllInterface->GetMaxPlayers()) && (m_pClientDllInterface->SpectatorMode() != OBS_ROAMING) )
{
player = m_pClientDllInterface->SpectatorTarget();
}
// special case in free map and inset off, don't show names
if ( ((m_pClientDllInterface->SpectatorMode() == OBS_MAP_FREE) && !m_pClientDllInterface->PipInsetOff()) || player == -1 )
name = NULL;
else
name = m_pClientDllInterface->GetPlayerInfo(player).name;
// special case in free map and inset off, don't show names
if ( ((m_pClientDllInterface->SpectatorMode() == OBS_MAP_FREE) && !m_pClientDllInterface->PipInsetOff()) || player == -1 )
name = NULL;
else
name = m_pClientDllInterface->GetPlayerInfo(player).name;
// create player & health string
if ( player && name )
{
Q_strncpy( bottomText, name, sizeof( bottomText ) );
}
char szMapName[64];
Q_FileBase( const_cast<char *>(m_pClientDllInterface->GetLevelName()), szMapName );
// create player & health string
if ( player && name )
{
Q_strncpy( bottomText, name, sizeof( bottomText ) );
}
char szMapName[64];
Q_FileBase( const_cast<char *>(m_pClientDllInterface->GetLevelName()), szMapName );
m_pSpectatorGUI->Update(bottomText, player, m_pClientDllInterface->SpectatorMode(), m_pClientDllInterface->IsSpectateOnly(), m_pClientDllInterface->SpectatorNumber(), szMapName );
m_pSpectatorGUI->UpdateSpectatorPlayerList();
m_pSpectatorGUI->Update(bottomText, player, m_pClientDllInterface->SpectatorMode(), m_pClientDllInterface->IsSpectateOnly(), m_pClientDllInterface->SpectatorNumber(), szMapName );
m_pSpectatorGUI->UpdateSpectatorPlayerList();
} */
// Return TRUE if the HUD's allowed to print text messages
@@ -598,7 +649,7 @@ bool CBaseViewport::AllowedToPrintText( void )
/* int iId = GetCurrentMenuID();
if ( iId == MENU_TEAM || iId == MENU_CLASS || iId == MENU_INTRO || iId == MENU_CLASSHELP )
return false; */
return false; */
// TODO ask every aktive elemet if it allows to draw text while visible
return ( m_pActivePanel == NULL);
@@ -606,6 +657,8 @@ bool CBaseViewport::AllowedToPrintText( void )
void CBaseViewport::OnThink()
{
ABS_QUERY_GUARD( true );
// Clear our active panel pointer if the panel has made
// itself invisible. Need this so we don't bring up dead panels
// if they are stored as the last active panel
@@ -613,39 +666,48 @@ void CBaseViewport::OnThink()
{
if( m_pLastActivePanel )
{
m_pActivePanel = m_pLastActivePanel;
ShowPanel( m_pActivePanel, true );
if ( m_pLastActivePanel->CanBeReopened() )
{
m_pActivePanel = m_pLastActivePanel;
ShowPanel( m_pActivePanel, true );
}
else
{
m_pActivePanel = NULL;
}
m_pLastActivePanel = NULL;
}
else
m_pActivePanel = NULL;
}
// TF does this in OnTick in TFViewport. This remains to preserve old
// behavior in other games
#if !defined( TF_CLIENT_DLL )
m_pAnimController->UpdateAnimations( gpGlobals->curtime );
#endif
int count = m_Panels.Count();
// check the auto-reload cvar
m_pAnimController->SetAutoReloadScript(hud_autoreloadscript.GetBool());
for (int i=0; i< count; i++ )
int nSlot = vgui::ipanel()->GetMessageContextId( GetVPanel() );
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( nSlot );
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *panel = m_Panels[i];
if ( panel->NeedsUpdate() && panel->IsVisible() )
IViewPortPanel *p = m_UnorderedPanels[i];
if ( p && p->NeedsUpdate() && p->IsVisible() )
{
panel->Update();
p->Update();
}
}
int w, h;
vgui::ipanel()->GetSize( enginevgui->GetPanel( PANEL_CLIENTDLL ), w, h );
vgui::ipanel()->GetSize( VGui_GetClientDLLRootPanel(), w, h );
if ( m_OldSize[ 0 ] != w || m_OldSize[ 1 ] != h )
{
m_OldSize[ 0 ] = w;
m_OldSize[ 1 ] = h;
g_pClientMode->Layout();
ASSERT_LOCAL_PLAYER_RESOLVABLE();
GetClientMode()->Layout();
}
BaseClass::OnThink();
@@ -661,7 +723,7 @@ void CBaseViewport::SetParent(vgui::VPANEL parent)
// parent happened to be non-proportional (such as the vgui root panel), we got
// slammed to be nonproportional
EditablePanel::SetProportional( true );
#ifndef _XBOX
m_pBackGround->SetParent( (vgui::VPANEL)parent );
#endif
@@ -698,7 +760,7 @@ void CBaseViewport::FireGameEvent( IGameEvent * event)
// hide all panels when reconnecting
ShowPanel( PANEL_ALL, false );
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV || engine->IsReplay() )
{
ShowPanel( PANEL_SPECGUI, true );
}
@@ -710,14 +772,13 @@ void CBaseViewport::FireGameEvent( IGameEvent * event)
//-----------------------------------------------------------------------------
void CBaseViewport::ReloadScheme(const char *fromFile)
{
CETWScope timer( "CBaseViewport::ReloadScheme" );
// See if scheme should change
if ( fromFile != NULL )
{
// "resource/ClientScheme.res"
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), fromFile, "HudScheme" );
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( GetSchemeSizingVPanel(), fromFile, "HudScheme" );
SetScheme(scheme);
SetProportional( true );
@@ -735,19 +796,88 @@ void CBaseViewport::ReloadScheme(const char *fromFile)
}
SetProportional( true );
KeyValuesAD pConditions( "conditions" );
g_pClientMode->ComputeVguiResConditions( pConditions );
// reload the .res file from disk
LoadControlSettings( "scripts/HudLayout.res", NULL, NULL, pConditions );
LoadHudLayout();
gHUD.RefreshHudTextures();
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
HudIcons().RefreshHudTextures();
}
InvalidateLayout( true, true );
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *p = m_UnorderedPanels[i];
p->ReloadScheme();
}
// reset the hud
gHUD.ResetHUD();
GetHud().ResetHUD();
}
extern ConVar ss_verticalsplit;
void AddSubKeyNamed( KeyValues *pKeys, const char *pszName )
{
KeyValues *pNewKey = new KeyValues( pszName );
if ( pNewKey )
{
pKeys->AddSubKey( pNewKey );
}
}
void CBaseViewport::LoadHudLayout( void )
{
VGUI_ABSPOS_SPLITSCREEN_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
// reload the .res file from disk
KeyValues *pConditions = NULL;
if ( engine->IsSplitScreenActive() )
{
pConditions = new KeyValues( "conditions" );
if ( pConditions )
{
AddSubKeyNamed( pConditions, "if_split_screen_active" );
ConVarRef ss_verticalsplit( "ss_verticalsplit" );
if ( ss_verticalsplit.IsValid() && ss_verticalsplit.GetBool() )
{
AddSubKeyNamed( pConditions, "if_split_screen_vertical" );
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
AddSubKeyNamed( pConditions, "if_split_screen_left" );
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_right" );
}
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_horizontal" );
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
AddSubKeyNamed( pConditions, "if_split_screen_top" );
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_bottom" );
}
}
}
}
LoadControlSettings( "scripts/HudLayout.res", NULL, NULL, pConditions );
if ( pConditions )
{
pConditions->deleteThis();
}
}
int CBaseViewport::GetDeathMessageStartHeight( void )
@@ -766,3 +896,14 @@ void CBaseViewport::Paint()
vgui::surface()->DrawLine( 0, size, size, size );
}
}
void CBaseViewport::SetAsFullscreenViewportInterface( void )
{
s_pFullscreenViewportInterface = this;
m_bFullscreenViewport = true;
}
bool CBaseViewport::IsFullscreenViewport() const
{
return m_bFullscreenViewport;
}