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.

168 lines
3.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "ivmodemanager.h"
  10. #include "clientmode_hlnormal.h"
  11. #include "hl1_clientmode.h"
  12. #include "hl1_clientscoreboard.h"
  13. // default FOV for HL1
  14. ConVar default_fov( "default_fov", "90", FCVAR_CHEAT );
  15. ConVar fov_desired( "fov_desired", "90", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 90.0 );
  16. // The current client mode. Always ClientModeNormal in HL.
  17. IClientMode *g_pClientMode = NULL;
  18. class CHLModeManager : public IVModeManager
  19. {
  20. public:
  21. CHLModeManager( void );
  22. virtual ~CHLModeManager( void );
  23. virtual void Init( void );
  24. virtual void SwitchMode( bool commander, bool force );
  25. virtual void OverrideView( CViewSetup *pSetup );
  26. virtual void CreateMove( float flInputSampleTime, CUserCmd *cmd );
  27. virtual void LevelInit( const char *newmap );
  28. virtual void LevelShutdown( void );
  29. };
  30. CHLModeManager::CHLModeManager( void )
  31. {
  32. }
  33. CHLModeManager::~CHLModeManager( void )
  34. {
  35. }
  36. void CHLModeManager::Init( void )
  37. {
  38. g_pClientMode = GetClientModeNormal();
  39. }
  40. void CHLModeManager::SwitchMode( bool commander, bool force )
  41. {
  42. }
  43. void CHLModeManager::OverrideView( CViewSetup *pSetup )
  44. {
  45. }
  46. void CHLModeManager::CreateMove( float flInputSampleTime, CUserCmd *cmd )
  47. {
  48. }
  49. void CHLModeManager::LevelInit( const char *newmap )
  50. {
  51. g_pClientMode->LevelInit( newmap );
  52. }
  53. void CHLModeManager::LevelShutdown( void )
  54. {
  55. g_pClientMode->LevelShutdown();
  56. }
  57. static CHLModeManager g_HLModeManager;
  58. IVModeManager *modemanager = &g_HLModeManager;
  59. //-----------------------------------------------------------------------------
  60. // Purpose: this is the viewport that contains all the hud elements
  61. //-----------------------------------------------------------------------------
  62. class CHudViewport : public CBaseViewport
  63. {
  64. private:
  65. DECLARE_CLASS_SIMPLE( CHudViewport, CBaseViewport );
  66. protected:
  67. virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
  68. {
  69. BaseClass::ApplySchemeSettings( pScheme );
  70. gHUD.InitColors( pScheme );
  71. SetPaintBackgroundEnabled( false );
  72. }
  73. virtual void CreateDefaultPanels( void )
  74. {
  75. CBaseViewport::CreateDefaultPanels();
  76. }
  77. virtual IViewPortPanel *CreatePanelByName( const char *szPanelName );
  78. };
  79. //-----------------------------------------------------------------------------
  80. // Purpose:
  81. //-----------------------------------------------------------------------------
  82. ClientModeHL1Normal::ClientModeHL1Normal()
  83. {
  84. }
  85. //-----------------------------------------------------------------------------
  86. // Purpose: If you don't know what a destructor is by now, you are probably going to get fired
  87. //-----------------------------------------------------------------------------
  88. ClientModeHL1Normal::~ClientModeHL1Normal()
  89. {
  90. }
  91. void ClientModeHL1Normal::InitViewport()
  92. {
  93. m_pViewport = new CHudViewport();
  94. m_pViewport->Start( gameuifuncs, gameeventmanager );
  95. }
  96. float ClientModeHL1Normal::GetViewModelFOV( void )
  97. {
  98. return 90.0f;
  99. }
  100. int ClientModeHL1Normal::GetDeathMessageStartHeight( void )
  101. {
  102. return m_pViewport->GetDeathMessageStartHeight();
  103. }
  104. ClientModeHL1Normal g_ClientModeNormal;
  105. IClientMode *GetClientModeNormal()
  106. {
  107. return &g_ClientModeNormal;
  108. }
  109. ClientModeHL1Normal* GetClientModeHL1Normal()
  110. {
  111. Assert( dynamic_cast< ClientModeHL1Normal* >( GetClientModeNormal() ) );
  112. return static_cast< ClientModeHL1Normal* >( GetClientModeNormal() );
  113. }
  114. IViewPortPanel* CHudViewport::CreatePanelByName( const char *szPanelName )
  115. {
  116. #ifdef HL1MP_CLIENT_DLL
  117. IViewPortPanel* newpanel = NULL;
  118. if ( Q_strcmp( PANEL_SCOREBOARD, szPanelName) == 0 )
  119. {
  120. newpanel = new CHL1MPClientScoreBoardDialog( this );
  121. return newpanel;
  122. }
  123. #endif
  124. /* else if ( Q_strcmp(PANEL_INFO, szPanelName) == 0 )
  125. {
  126. newpanel = new CHL2MPTextWindow( this );
  127. return newpanel;
  128. }*/
  129. return BaseClass::CreatePanelByName( szPanelName );
  130. }