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.

139 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "cbase.h"
  9. #include "hud.h"
  10. #include "clientmode_tfc.h"
  11. #include "cdll_client_int.h"
  12. #include "iinput.h"
  13. #include "vgui/ISurface.h"
  14. #include "vgui/IPanel.h"
  15. #include <vgui_controls/AnimationController.h>
  16. #include "ivmodemanager.h"
  17. #include "buymenu.h"
  18. #include "filesystem.h"
  19. #include "vgui/IVGui.h"
  20. #include "hud_chat.h"
  21. #include "view_shared.h"
  22. #include "view.h"
  23. #include "ivrenderview.h"
  24. #include "model_types.h"
  25. #include "iefx.h"
  26. #include "dlight.h"
  27. #include <imapoverview.h>
  28. #include "c_playerresource.h"
  29. #include <KeyValues.h>
  30. #include "text_message.h"
  31. #include "panelmetaclassmgr.h"
  32. ConVar default_fov( "default_fov", "90", FCVAR_CHEAT );
  33. IClientMode *g_pClientMode = NULL;
  34. // --------------------------------------------------------------------------------- //
  35. // CTFCModeManager.
  36. // --------------------------------------------------------------------------------- //
  37. class CTFCModeManager : public IVModeManager
  38. {
  39. public:
  40. virtual void Init();
  41. virtual void SwitchMode( bool commander, bool force ) {}
  42. virtual void LevelInit( const char *newmap );
  43. virtual void LevelShutdown( void );
  44. virtual void ActivateMouse( bool isactive ) {}
  45. };
  46. static CTFCModeManager g_ModeManager;
  47. IVModeManager *modemanager = ( IVModeManager * )&g_ModeManager;
  48. // --------------------------------------------------------------------------------- //
  49. // CTFCModeManager implementation.
  50. // --------------------------------------------------------------------------------- //
  51. #define SCREEN_FILE "scripts/vgui_screens.txt"
  52. void CTFCModeManager::Init()
  53. {
  54. g_pClientMode = GetClientModeNormal();
  55. PanelMetaClassMgr()->LoadMetaClassDefinitionFile( SCREEN_FILE );
  56. }
  57. void CTFCModeManager::LevelInit( const char *newmap )
  58. {
  59. g_pClientMode->LevelInit( newmap );
  60. }
  61. void CTFCModeManager::LevelShutdown( void )
  62. {
  63. g_pClientMode->LevelShutdown();
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose:
  67. //-----------------------------------------------------------------------------
  68. ClientModeTFCNormal::ClientModeTFCNormal()
  69. {
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Purpose: If you don't know what a destructor is by now, you are probably going to get fired
  73. //-----------------------------------------------------------------------------
  74. ClientModeTFCNormal::~ClientModeTFCNormal()
  75. {
  76. }
  77. void ClientModeTFCNormal::InitViewport()
  78. {
  79. m_pViewport = new TFCViewport();
  80. m_pViewport->Start( gameuifuncs, gameeventmanager );
  81. }
  82. ClientModeTFCNormal g_ClientModeNormal;
  83. IClientMode *GetClientModeNormal()
  84. {
  85. return &g_ClientModeNormal;
  86. }
  87. ClientModeTFCNormal* GetClientModeTFCNormal()
  88. {
  89. Assert( dynamic_cast< ClientModeTFCNormal* >( GetClientModeNormal() ) );
  90. return static_cast< ClientModeTFCNormal* >( GetClientModeNormal() );
  91. }
  92. float g_flViewModelFOV = 90;
  93. float ClientModeTFCNormal::GetViewModelFOV( void )
  94. {
  95. return g_flViewModelFOV;
  96. }
  97. int ClientModeTFCNormal::GetDeathMessageStartHeight( void )
  98. {
  99. return m_pViewport->GetDeathMessageStartHeight();
  100. }
  101. void ClientModeTFCNormal::FireGameEvent( KeyValues * event)
  102. {
  103. BaseClass::FireGameEvent( event );
  104. }
  105. void ClientModeTFCNormal::PostRenderVGui()
  106. {
  107. }