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.

128 lines
3.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Draws the normal TF2 or HL2 HUD.
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "cbase.h"
  10. #include "clientmode_hl2mpnormal.h"
  11. #include "vgui_int.h"
  12. #include "hud.h"
  13. #include <vgui/IInput.h>
  14. #include <vgui/IPanel.h>
  15. #include <vgui/ISurface.h>
  16. #include <vgui_controls/AnimationController.h>
  17. #include "iinput.h"
  18. #include "hl2mpclientscoreboard.h"
  19. #include "hl2mptextwindow.h"
  20. #include "ienginevgui.h"
  21. // memdbgon must be the last include file in a .cpp file!!!
  22. #include "tier0/memdbgon.h"
  23. //-----------------------------------------------------------------------------
  24. // Globals
  25. //-----------------------------------------------------------------------------
  26. vgui::HScheme g_hVGuiCombineScheme = 0;
  27. // Instance the singleton and expose the interface to it.
  28. IClientMode *GetClientModeNormal()
  29. {
  30. static ClientModeHL2MPNormal g_ClientModeNormal;
  31. return &g_ClientModeNormal;
  32. }
  33. ClientModeHL2MPNormal* GetClientModeHL2MPNormal()
  34. {
  35. Assert( dynamic_cast< ClientModeHL2MPNormal* >( GetClientModeNormal() ) );
  36. return static_cast< ClientModeHL2MPNormal* >( GetClientModeNormal() );
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose: this is the viewport that contains all the hud elements
  40. //-----------------------------------------------------------------------------
  41. class CHudViewport : public CBaseViewport
  42. {
  43. private:
  44. DECLARE_CLASS_SIMPLE( CHudViewport, CBaseViewport );
  45. protected:
  46. virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
  47. {
  48. BaseClass::ApplySchemeSettings( pScheme );
  49. gHUD.InitColors( pScheme );
  50. SetPaintBackgroundEnabled( false );
  51. }
  52. virtual IViewPortPanel *CreatePanelByName( const char *szPanelName );
  53. };
  54. int ClientModeHL2MPNormal::GetDeathMessageStartHeight( void )
  55. {
  56. return m_pViewport->GetDeathMessageStartHeight();
  57. }
  58. IViewPortPanel* CHudViewport::CreatePanelByName( const char *szPanelName )
  59. {
  60. IViewPortPanel* newpanel = NULL;
  61. if ( Q_strcmp( PANEL_SCOREBOARD, szPanelName) == 0 )
  62. {
  63. newpanel = new CHL2MPClientScoreBoardDialog( this );
  64. return newpanel;
  65. }
  66. else if ( Q_strcmp(PANEL_INFO, szPanelName) == 0 )
  67. {
  68. newpanel = new CHL2MPTextWindow( this );
  69. return newpanel;
  70. }
  71. else if ( Q_strcmp(PANEL_SPECGUI, szPanelName) == 0 )
  72. {
  73. newpanel = new CHL2MPSpectatorGUI( this );
  74. return newpanel;
  75. }
  76. return BaseClass::CreatePanelByName( szPanelName );
  77. }
  78. //-----------------------------------------------------------------------------
  79. // ClientModeHLNormal implementation
  80. //-----------------------------------------------------------------------------
  81. ClientModeHL2MPNormal::ClientModeHL2MPNormal()
  82. {
  83. m_pViewport = new CHudViewport();
  84. m_pViewport->Start( gameuifuncs, gameeventmanager );
  85. }
  86. //-----------------------------------------------------------------------------
  87. // Purpose:
  88. //-----------------------------------------------------------------------------
  89. ClientModeHL2MPNormal::~ClientModeHL2MPNormal()
  90. {
  91. }
  92. //-----------------------------------------------------------------------------
  93. // Purpose:
  94. //-----------------------------------------------------------------------------
  95. void ClientModeHL2MPNormal::Init()
  96. {
  97. BaseClass::Init();
  98. // Load up the combine control panel scheme
  99. g_hVGuiCombineScheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/CombinePanelScheme.res", "CombineScheme" );
  100. if (!g_hVGuiCombineScheme)
  101. {
  102. Warning( "Couldn't load combine panel scheme!\n" );
  103. }
  104. }