Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

768 lines
20 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Client DLL VGUI2 Viewport
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #pragma warning( disable : 4800 ) // disable forcing int to bool performance warning
  14. #include "cbase.h"
  15. #include <cdll_client_int.h>
  16. #include <cdll_util.h>
  17. #include <globalvars_base.h>
  18. // VGUI panel includes
  19. #include <vgui_controls/Panel.h>
  20. #include <vgui_controls/AnimationController.h>
  21. #include <vgui/ISurface.h>
  22. #include <KeyValues.h>
  23. #include <vgui/IScheme.h>
  24. #include <vgui/IVGui.h>
  25. #include <vgui/ILocalize.h>
  26. #include <vgui/IPanel.h>
  27. #include <vgui_controls/Button.h>
  28. #include <igameresources.h>
  29. // sub dialogs
  30. #include "clientscoreboarddialog.h"
  31. #include "spectatorgui.h"
  32. #include "teammenu.h"
  33. #include "vguitextwindow.h"
  34. #include "IGameUIFuncs.h"
  35. #include "mapoverview.h"
  36. #include "hud.h"
  37. #include "NavProgress.h"
  38. #include "commentary_modelviewer.h"
  39. // our definition
  40. #include "baseviewport.h"
  41. #include <filesystem.h>
  42. #include <convar.h>
  43. #include "ienginevgui.h"
  44. #include "iclientmode.h"
  45. #include "tier0/etwprof.h"
  46. #if defined( REPLAY_ENABLED )
  47. #include "replay/ireplaysystem.h"
  48. #include "replay/ienginereplay.h"
  49. #endif
  50. // memdbgon must be the last include file in a .cpp file!!!
  51. #include "tier0/memdbgon.h"
  52. IViewPort *gViewPortInterface = NULL;
  53. vgui::Panel *g_lastPanel = NULL; // used for mouseover buttons, keeps track of the last active panel
  54. vgui::Button *g_lastButton = NULL; // used for mouseover buttons, keeps track of the last active button
  55. using namespace vgui;
  56. void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue );
  57. ConVar hud_autoreloadscript("hud_autoreloadscript", "0", FCVAR_NONE, "Automatically reloads the animation script each time one is ran", hud_autoreloadscript_callback);
  58. void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue )
  59. {
  60. if ( g_pClientMode && g_pClientMode->GetViewportAnimationController() )
  61. {
  62. g_pClientMode->GetViewportAnimationController()->SetAutoReloadScript( hud_autoreloadscript.GetBool() );
  63. }
  64. }
  65. static ConVar cl_leveloverviewmarker( "cl_leveloverviewmarker", "0", FCVAR_CHEAT );
  66. CON_COMMAND( showpanel, "Shows a viewport panel <name>" )
  67. {
  68. if ( !gViewPortInterface )
  69. return;
  70. if ( args.ArgC() != 2 )
  71. return;
  72. gViewPortInterface->ShowPanel( args[ 1 ], true );
  73. }
  74. CON_COMMAND( hidepanel, "Hides a viewport panel <name>" )
  75. {
  76. if ( !gViewPortInterface )
  77. return;
  78. if ( args.ArgC() != 2 )
  79. return;
  80. gViewPortInterface->ShowPanel( args[ 1 ], false );
  81. }
  82. /* global helper functions
  83. bool Helper_LoadFile( IBaseFileSystem *pFileSystem, const char *pFilename, CUtlVector<char> &buf )
  84. {
  85. FileHandle_t hFile = pFileSystem->Open( pFilename, "rt" );
  86. if ( hFile == FILESYSTEM_INVALID_HANDLE )
  87. {
  88. Warning( "Helper_LoadFile: missing %s\n", pFilename );
  89. return false;
  90. }
  91. unsigned long len = pFileSystem->Size( hFile );
  92. buf.SetSize( len );
  93. pFileSystem->Read( buf.Base(), buf.Count(), hFile );
  94. pFileSystem->Close( hFile );
  95. return true;
  96. } */
  97. //-----------------------------------------------------------------------------
  98. // Purpose:
  99. // Output : Returns true on success, false on failure.
  100. //-----------------------------------------------------------------------------
  101. bool CBaseViewport::LoadHudAnimations( void )
  102. {
  103. const char *HUDANIMATION_MANIFEST_FILE = "scripts/hudanimations_manifest.txt";
  104. KeyValues *manifest = new KeyValues( HUDANIMATION_MANIFEST_FILE );
  105. if ( manifest->LoadFromFile( g_pFullFileSystem, HUDANIMATION_MANIFEST_FILE, "GAME" ) == false )
  106. {
  107. manifest->deleteThis();
  108. return false;
  109. }
  110. bool bClearScript = true;
  111. // Load each file defined in the text
  112. for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
  113. {
  114. if ( !Q_stricmp( sub->GetName(), "file" ) )
  115. {
  116. // Add it
  117. if ( m_pAnimController->SetScriptFile( GetVPanel(), sub->GetString(), bClearScript ) == false )
  118. {
  119. Assert( 0 );
  120. }
  121. bClearScript = false;
  122. continue;
  123. }
  124. }
  125. manifest->deleteThis();
  126. return true;
  127. }
  128. //================================================================
  129. CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
  130. {
  131. SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
  132. gViewPortInterface = this;
  133. m_bInitialized = false;
  134. m_GameuiFuncs = NULL;
  135. m_GameEventManager = NULL;
  136. SetKeyBoardInputEnabled( false );
  137. SetMouseInputEnabled( false );
  138. #ifndef _XBOX
  139. m_pBackGround = NULL;
  140. #endif
  141. m_bHasParent = false;
  142. m_pActivePanel = NULL;
  143. m_pLastActivePanel = NULL;
  144. g_lastPanel = NULL;
  145. vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ClientScheme.res", "ClientScheme");
  146. SetScheme(scheme);
  147. SetProportional( true );
  148. m_pAnimController = new vgui::AnimationController(this);
  149. // create our animation controller
  150. m_pAnimController->SetScheme(scheme);
  151. m_pAnimController->SetProportional(true);
  152. // Attempt to load all hud animations
  153. if ( LoadHudAnimations() == false )
  154. {
  155. // Fall back to just the main
  156. if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
  157. {
  158. Assert(0);
  159. }
  160. }
  161. m_OldSize[ 0 ] = m_OldSize[ 1 ] = -1;
  162. }
  163. //-----------------------------------------------------------------------------
  164. // Purpose: Updates hud to handle the new screen size
  165. //-----------------------------------------------------------------------------
  166. void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
  167. {
  168. BaseClass::OnScreenSizeChanged(iOldWide, iOldTall);
  169. IViewPortPanel* pSpecGuiPanel = FindPanelByName(PANEL_SPECGUI);
  170. bool bSpecGuiWasVisible = pSpecGuiPanel && pSpecGuiPanel->IsVisible();
  171. // reload the script file, so the screen positions in it are correct for the new resolution
  172. ReloadScheme( NULL );
  173. // recreate all the default panels
  174. RemoveAllPanels();
  175. #ifndef _XBOX
  176. m_pBackGround = new CBackGroundPanel( NULL );
  177. m_pBackGround->SetZPos( -20 ); // send it to the back
  178. m_pBackGround->SetVisible( false );
  179. #endif
  180. CreateDefaultPanels();
  181. #ifndef _XBOX
  182. vgui::ipanel()->MoveToBack( m_pBackGround->GetVPanel() ); // really send it to the back
  183. #endif
  184. // hide all panels when reconnecting
  185. ShowPanel( PANEL_ALL, false );
  186. // re-enable the spectator gui if it was previously visible
  187. if ( bSpecGuiWasVisible )
  188. {
  189. ShowPanel( PANEL_SPECGUI, true );
  190. }
  191. }
  192. void CBaseViewport::CreateDefaultPanels( void )
  193. {
  194. #ifndef _XBOX
  195. AddNewPanel( CreatePanelByName( PANEL_SCOREBOARD ), "PANEL_SCOREBOARD" );
  196. AddNewPanel( CreatePanelByName( PANEL_INFO ), "PANEL_INFO" );
  197. AddNewPanel( CreatePanelByName( PANEL_SPECGUI ), "PANEL_SPECGUI" );
  198. #if !defined( TF_CLIENT_DLL )
  199. AddNewPanel( CreatePanelByName( PANEL_SPECMENU ), "PANEL_SPECMENU" );
  200. AddNewPanel( CreatePanelByName( PANEL_NAV_PROGRESS ), "PANEL_NAV_PROGRESS" );
  201. #endif // !TF_CLIENT_DLL
  202. #endif // !_XBOX
  203. }
  204. void CBaseViewport::UpdateAllPanels( void )
  205. {
  206. int count = m_Panels.Count();
  207. for (int i=0; i< count; i++ )
  208. {
  209. IViewPortPanel *p = m_Panels[i];
  210. if ( p->IsVisible() )
  211. {
  212. p->Update();
  213. }
  214. }
  215. }
  216. // Check if we have any visible panel (that's not the MainMenuOverride or the Scoreboard)
  217. bool CBaseViewport::IsAnyPanelVisibleExceptScores()
  218. {
  219. int count = m_Panels.Count();
  220. for ( int i = 0; i < count; i++ )
  221. {
  222. IViewPortPanel *p = m_Panels[i];
  223. if ( p->IsVisible() && Q_strcmp("MainMenuOverride", p->GetName()) && Q_strcmp("scores", p->GetName()) )
  224. {
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. bool CBaseViewport::IsPanelVisible( const char* panel )
  231. {
  232. int count = m_Panels.Count();
  233. for ( int i = 0; i < count; i++ )
  234. {
  235. IViewPortPanel *p = m_Panels[i];
  236. if ( p->IsVisible() )
  237. {
  238. const char* panel_name = p->GetName();
  239. if ( !Q_strcmp( panel, panel_name ) )
  240. {
  241. return true;
  242. }
  243. }
  244. }
  245. return false;
  246. }
  247. IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
  248. {
  249. IViewPortPanel* newpanel = NULL;
  250. #ifndef _XBOX
  251. if ( Q_strcmp(PANEL_SCOREBOARD, szPanelName) == 0 )
  252. {
  253. newpanel = new CClientScoreBoardDialog( this );
  254. }
  255. else if ( Q_strcmp(PANEL_INFO, szPanelName) == 0 )
  256. {
  257. newpanel = new CTextWindow( this );
  258. }
  259. /* else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
  260. {
  261. newpanel = new CMapOverview( this );
  262. }
  263. */
  264. else if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
  265. {
  266. newpanel = new CTeamMenu( this );
  267. }
  268. else if ( Q_strcmp(PANEL_SPECMENU, szPanelName) == 0 )
  269. {
  270. newpanel = new CSpectatorMenu( this );
  271. }
  272. else if ( Q_strcmp(PANEL_SPECGUI, szPanelName) == 0 )
  273. {
  274. newpanel = new CSpectatorGUI( this );
  275. }
  276. #if !defined( TF_CLIENT_DLL )
  277. else if ( Q_strcmp(PANEL_NAV_PROGRESS, szPanelName) == 0 )
  278. {
  279. newpanel = new CNavProgress( this );
  280. }
  281. #endif // TF_CLIENT_DLL
  282. #endif
  283. if ( Q_strcmp(PANEL_COMMENTARY_MODELVIEWER, szPanelName) == 0 )
  284. {
  285. newpanel = new CCommentaryModelViewer( this );
  286. }
  287. return newpanel;
  288. }
  289. bool CBaseViewport::AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugName )
  290. {
  291. if ( !pPanel )
  292. {
  293. DevMsg("CBaseViewport::AddNewPanel(%s): NULL panel.\n", pchDebugName );
  294. return false;
  295. }
  296. // we created a new panel, initialize it
  297. if ( FindPanelByName( pPanel->GetName() ) != NULL )
  298. {
  299. DevMsg("CBaseViewport::AddNewPanel: panel with name '%s' already exists.\n", pPanel->GetName() );
  300. return false;
  301. }
  302. m_Panels.AddToTail( pPanel );
  303. pPanel->SetParent( GetVPanel() );
  304. return true;
  305. }
  306. IViewPortPanel* CBaseViewport::FindPanelByName(const char *szPanelName)
  307. {
  308. int count = m_Panels.Count();
  309. for (int i=0; i< count; i++ )
  310. {
  311. if ( Q_strcmp(m_Panels[i]->GetName(), szPanelName) == 0 )
  312. return m_Panels[i];
  313. }
  314. return NULL;
  315. }
  316. void CBaseViewport::PostMessageToPanel( IViewPortPanel* pPanel, KeyValues *pKeyValues )
  317. {
  318. PostMessage( pPanel->GetVPanel(), pKeyValues );
  319. }
  320. void CBaseViewport::PostMessageToPanel( const char *pName, KeyValues *pKeyValues )
  321. {
  322. if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
  323. {
  324. for (int i=0; i< m_Panels.Count(); i++ )
  325. {
  326. PostMessageToPanel( m_Panels[i], pKeyValues );
  327. }
  328. return;
  329. }
  330. IViewPortPanel * panel = NULL;
  331. if ( Q_strcmp( pName, PANEL_ACTIVE ) == 0 )
  332. {
  333. panel = m_pActivePanel;
  334. }
  335. else
  336. {
  337. panel = FindPanelByName( pName );
  338. }
  339. if ( !panel )
  340. return;
  341. PostMessageToPanel( panel, pKeyValues );
  342. }
  343. void CBaseViewport::ShowPanel( const char *pName, bool state )
  344. {
  345. if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
  346. {
  347. for (int i=0; i< m_Panels.Count(); i++ )
  348. {
  349. ShowPanel( m_Panels[i], state );
  350. }
  351. return;
  352. }
  353. IViewPortPanel * panel = NULL;
  354. if ( Q_strcmp( pName, PANEL_ACTIVE ) == 0 )
  355. {
  356. panel = m_pActivePanel;
  357. }
  358. else
  359. {
  360. panel = FindPanelByName( pName );
  361. }
  362. if ( !panel )
  363. return;
  364. ShowPanel( panel, state );
  365. }
  366. void CBaseViewport::ShowPanel( IViewPortPanel* pPanel, bool state )
  367. {
  368. if ( state )
  369. {
  370. // if this is an 'active' panel, deactivate old active panel
  371. if ( pPanel->HasInputElements() )
  372. {
  373. // don't show input panels during normal demo playback
  374. #if defined( REPLAY_ENABLED )
  375. if ( engine->IsPlayingDemo() && !engine->IsHLTV() && !g_pEngineClientReplay->IsPlayingReplayDemo() )
  376. #else
  377. if ( engine->IsPlayingDemo() && !engine->IsHLTV() )
  378. #endif
  379. return;
  380. if ( (m_pActivePanel != NULL) && (m_pActivePanel != pPanel) && (m_pActivePanel->IsVisible()) )
  381. {
  382. // store a pointer to the currently active panel
  383. // so we can restore it later
  384. m_pLastActivePanel = m_pActivePanel;
  385. m_pActivePanel->ShowPanel( false );
  386. }
  387. m_pActivePanel = pPanel;
  388. }
  389. }
  390. else
  391. {
  392. // if this is our current active panel
  393. // update m_pActivePanel pointer
  394. if ( m_pActivePanel == pPanel )
  395. {
  396. m_pActivePanel = NULL;
  397. }
  398. // restore the previous active panel if it exists
  399. if( m_pLastActivePanel )
  400. {
  401. m_pActivePanel = m_pLastActivePanel;
  402. m_pLastActivePanel = NULL;
  403. m_pActivePanel->ShowPanel( true );
  404. }
  405. }
  406. // just show/hide panel
  407. pPanel->ShowPanel( state );
  408. UpdateAllPanels(); // let other panels rearrange
  409. }
  410. IViewPortPanel* CBaseViewport::GetActivePanel( void )
  411. {
  412. return m_pActivePanel;
  413. }
  414. void CBaseViewport::RemoveAllPanels( void)
  415. {
  416. g_lastPanel = NULL;
  417. for ( int i=0; i < m_Panels.Count(); i++ )
  418. {
  419. vgui::VPANEL vPanel = m_Panels[i]->GetVPanel();
  420. vgui::ipanel()->DeletePanel( vPanel );
  421. }
  422. #ifndef _XBOX
  423. if ( m_pBackGround )
  424. {
  425. m_pBackGround->MarkForDeletion();
  426. m_pBackGround = NULL;
  427. }
  428. #endif
  429. m_Panels.Purge();
  430. m_pActivePanel = NULL;
  431. m_pLastActivePanel = NULL;
  432. }
  433. CBaseViewport::~CBaseViewport()
  434. {
  435. m_bInitialized = false;
  436. #ifndef _XBOX
  437. if ( !m_bHasParent && m_pBackGround )
  438. {
  439. m_pBackGround->MarkForDeletion();
  440. }
  441. m_pBackGround = NULL;
  442. #endif
  443. RemoveAllPanels();
  444. gameeventmanager->RemoveListener( this );
  445. }
  446. //-----------------------------------------------------------------------------
  447. // Purpose: called when the VGUI subsystem starts up
  448. // Creates the sub panels and initialises them
  449. //-----------------------------------------------------------------------------
  450. void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager )
  451. {
  452. m_GameuiFuncs = pGameUIFuncs;
  453. m_GameEventManager = pGameEventManager;
  454. #ifndef _XBOX
  455. m_pBackGround = new CBackGroundPanel( NULL );
  456. m_pBackGround->SetZPos( -20 ); // send it to the back
  457. m_pBackGround->SetVisible( false );
  458. #endif
  459. CreateDefaultPanels();
  460. m_GameEventManager->AddListener( this, "game_newmap", false );
  461. m_bInitialized = true;
  462. }
  463. /*
  464. //-----------------------------------------------------------------------------
  465. // Purpose: Updates the spectator panel with new player info
  466. //-----------------------------------------------------------------------------
  467. void CBaseViewport::UpdateSpectatorPanel()
  468. {
  469. char bottomText[128];
  470. int player = -1;
  471. const char *name;
  472. Q_snprintf(bottomText,sizeof( bottomText ), "#Spec_Mode%d", m_pClientDllInterface->SpectatorMode() );
  473. m_pClientDllInterface->CheckSettings();
  474. // check if we're locked onto a target, show the player's name
  475. if ( (m_pClientDllInterface->SpectatorTarget() > 0) && (m_pClientDllInterface->SpectatorTarget() <= m_pClientDllInterface->GetMaxPlayers()) && (m_pClientDllInterface->SpectatorMode() != OBS_ROAMING) )
  476. {
  477. player = m_pClientDllInterface->SpectatorTarget();
  478. }
  479. // special case in free map and inset off, don't show names
  480. if ( ((m_pClientDllInterface->SpectatorMode() == OBS_MAP_FREE) && !m_pClientDllInterface->PipInsetOff()) || player == -1 )
  481. name = NULL;
  482. else
  483. name = m_pClientDllInterface->GetPlayerInfo(player).name;
  484. // create player & health string
  485. if ( player && name )
  486. {
  487. Q_strncpy( bottomText, name, sizeof( bottomText ) );
  488. }
  489. char szMapName[64];
  490. Q_FileBase( const_cast<char *>(m_pClientDllInterface->GetLevelName()), szMapName );
  491. m_pSpectatorGUI->Update(bottomText, player, m_pClientDllInterface->SpectatorMode(), m_pClientDllInterface->IsSpectateOnly(), m_pClientDllInterface->SpectatorNumber(), szMapName );
  492. m_pSpectatorGUI->UpdateSpectatorPlayerList();
  493. } */
  494. // Return TRUE if the HUD's allowed to print text messages
  495. bool CBaseViewport::AllowedToPrintText( void )
  496. {
  497. /* int iId = GetCurrentMenuID();
  498. if ( iId == MENU_TEAM || iId == MENU_CLASS || iId == MENU_INTRO || iId == MENU_CLASSHELP )
  499. return false; */
  500. // TODO ask every aktive elemet if it allows to draw text while visible
  501. return ( m_pActivePanel == NULL);
  502. }
  503. void CBaseViewport::OnThink()
  504. {
  505. // Clear our active panel pointer if the panel has made
  506. // itself invisible. Need this so we don't bring up dead panels
  507. // if they are stored as the last active panel
  508. if( m_pActivePanel && !m_pActivePanel->IsVisible() )
  509. {
  510. if( m_pLastActivePanel )
  511. {
  512. m_pActivePanel = m_pLastActivePanel;
  513. ShowPanel( m_pActivePanel, true );
  514. m_pLastActivePanel = NULL;
  515. }
  516. else
  517. m_pActivePanel = NULL;
  518. }
  519. // TF does this in OnTick in TFViewport. This remains to preserve old
  520. // behavior in other games
  521. #if !defined( TF_CLIENT_DLL )
  522. m_pAnimController->UpdateAnimations( gpGlobals->curtime );
  523. #endif
  524. int count = m_Panels.Count();
  525. for (int i=0; i< count; i++ )
  526. {
  527. IViewPortPanel *panel = m_Panels[i];
  528. if ( panel->NeedsUpdate() && panel->IsVisible() )
  529. {
  530. panel->Update();
  531. }
  532. }
  533. int w, h;
  534. vgui::ipanel()->GetSize( enginevgui->GetPanel( PANEL_CLIENTDLL ), w, h );
  535. if ( m_OldSize[ 0 ] != w || m_OldSize[ 1 ] != h )
  536. {
  537. m_OldSize[ 0 ] = w;
  538. m_OldSize[ 1 ] = h;
  539. g_pClientMode->Layout();
  540. }
  541. BaseClass::OnThink();
  542. }
  543. //-----------------------------------------------------------------------------
  544. // Purpose: Sets the parent for each panel to use
  545. //-----------------------------------------------------------------------------
  546. void CBaseViewport::SetParent(vgui::VPANEL parent)
  547. {
  548. EditablePanel::SetParent( parent );
  549. // force ourselves to be proportional - when we set our parent above, if our new
  550. // parent happened to be non-proportional (such as the vgui root panel), we got
  551. // slammed to be nonproportional
  552. EditablePanel::SetProportional( true );
  553. #ifndef _XBOX
  554. m_pBackGround->SetParent( (vgui::VPANEL)parent );
  555. #endif
  556. // set proportionality on animation controller
  557. m_pAnimController->SetProportional( true );
  558. m_bHasParent = (parent != 0);
  559. }
  560. //-----------------------------------------------------------------------------
  561. // Purpose: called when the engine shows the base client VGUI panel (i.e when entering a new level or exiting GameUI )
  562. //-----------------------------------------------------------------------------
  563. void CBaseViewport::ActivateClientUI()
  564. {
  565. }
  566. //-----------------------------------------------------------------------------
  567. // Purpose: called when the engine hides the base client VGUI panel (i.e when the GameUI is comming up )
  568. //-----------------------------------------------------------------------------
  569. void CBaseViewport::HideClientUI()
  570. {
  571. }
  572. //-----------------------------------------------------------------------------
  573. // Purpose: passes death msgs to the scoreboard to display specially
  574. //-----------------------------------------------------------------------------
  575. void CBaseViewport::FireGameEvent( IGameEvent * event)
  576. {
  577. const char * type = event->GetName();
  578. if ( Q_strcmp(type, "game_newmap") == 0 )
  579. {
  580. // hide all panels when reconnecting
  581. ShowPanel( PANEL_ALL, false );
  582. if ( engine->IsHLTV() )
  583. {
  584. ShowPanel( PANEL_SPECGUI, true );
  585. }
  586. }
  587. }
  588. //-----------------------------------------------------------------------------
  589. // Purpose:
  590. //-----------------------------------------------------------------------------
  591. void CBaseViewport::ReloadScheme(const char *fromFile)
  592. {
  593. CETWScope timer( "CBaseViewport::ReloadScheme" );
  594. // See if scheme should change
  595. if ( fromFile != NULL )
  596. {
  597. // "resource/ClientScheme.res"
  598. vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), fromFile, "HudScheme" );
  599. SetScheme(scheme);
  600. SetProportional( true );
  601. m_pAnimController->SetScheme(scheme);
  602. }
  603. // Force a reload
  604. if ( LoadHudAnimations() == false )
  605. {
  606. // Fall back to just the main
  607. if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
  608. {
  609. Assert(0);
  610. }
  611. }
  612. SetProportional( true );
  613. KeyValuesAD pConditions( "conditions" );
  614. g_pClientMode->ComputeVguiResConditions( pConditions );
  615. // reload the .res file from disk
  616. LoadControlSettings( "scripts/HudLayout.res", NULL, NULL, pConditions );
  617. gHUD.RefreshHudTextures();
  618. InvalidateLayout( true, true );
  619. // reset the hud
  620. gHUD.ResetHUD();
  621. }
  622. int CBaseViewport::GetDeathMessageStartHeight( void )
  623. {
  624. return YRES(2);
  625. }
  626. void CBaseViewport::Paint()
  627. {
  628. if ( cl_leveloverviewmarker.GetInt() > 0 )
  629. {
  630. int size = cl_leveloverviewmarker.GetInt();
  631. // draw a 1024x1024 pixel box
  632. vgui::surface()->DrawSetColor( 255, 0, 0, 255 );
  633. vgui::surface()->DrawLine( size, 0, size, size );
  634. vgui::surface()->DrawLine( 0, size, size, size );
  635. }
  636. }