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
5.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #if !defined( CLIENTMODE_NORMAL_H )
  10. #define CLIENTMODE_NORMAL_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "iclientmode.h"
  15. #include "GameEventListener.h"
  16. #include <baseviewport.h>
  17. class CBaseHudChat;
  18. class CBaseHudWeaponSelection;
  19. class CViewSetup;
  20. class C_BaseEntity;
  21. class C_BasePlayer;
  22. namespace vgui
  23. {
  24. class Panel;
  25. }
  26. //=============================================================================
  27. // HPE_BEGIN:
  28. // [tj] Moved this from the .cpp file so derived classes could access it
  29. //=============================================================================
  30. #define ACHIEVEMENT_ANNOUNCEMENT_MIN_TIME 10
  31. //=============================================================================
  32. // HPE_END
  33. //=============================================================================
  34. class CReplayReminderPanel;
  35. #define USERID2PLAYER(i) ToBasePlayer( ClientEntityList().GetEnt( engine->GetPlayerForUserID( i ) ) )
  36. extern IClientMode *GetClientModeNormal(); // must be implemented
  37. // This class implements client mode functionality common to HL2 and TF2.
  38. class ClientModeShared : public IClientMode, public CGameEventListener
  39. {
  40. // IClientMode overrides.
  41. public:
  42. DECLARE_CLASS_NOBASE( ClientModeShared );
  43. ClientModeShared();
  44. virtual ~ClientModeShared();
  45. virtual void Init();
  46. virtual void InitViewport();
  47. virtual void VGui_Shutdown();
  48. virtual void Shutdown();
  49. virtual void LevelInit( const char *newmap );
  50. virtual void LevelShutdown( void );
  51. virtual void Enable();
  52. virtual void Disable();
  53. virtual void Layout();
  54. virtual void ReloadScheme( bool flushLowLevel );
  55. virtual void OverrideView( CViewSetup *pSetup );
  56. virtual bool ShouldDrawDetailObjects( );
  57. virtual bool ShouldDrawEntity(C_BaseEntity *pEnt);
  58. virtual bool ShouldDrawLocalPlayer( C_BasePlayer *pPlayer );
  59. virtual bool ShouldDrawViewModel();
  60. virtual bool ShouldDrawParticles( );
  61. virtual bool ShouldDrawCrosshair( void );
  62. virtual bool ShouldBlackoutAroundHUD() OVERRIDE;
  63. virtual HeadtrackMovementMode_t ShouldOverrideHeadtrackControl() OVERRIDE;
  64. virtual void AdjustEngineViewport( int& x, int& y, int& width, int& height );
  65. virtual void PreRender(CViewSetup *pSetup);
  66. virtual void PostRender();
  67. virtual void PostRenderVGui();
  68. virtual void ProcessInput(bool bActive);
  69. virtual bool CreateMove( float flInputSampleTime, CUserCmd *cmd );
  70. virtual void Update();
  71. // Input
  72. virtual int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
  73. virtual int HudElementKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
  74. virtual void OverrideMouseInput( float *x, float *y );
  75. virtual void StartMessageMode( int iMessageModeType );
  76. virtual vgui::Panel *GetMessagePanel();
  77. virtual void ActivateInGameVGuiContext( vgui::Panel *pPanel );
  78. virtual void DeactivateInGameVGuiContext();
  79. // The mode can choose to not draw fog
  80. virtual bool ShouldDrawFog( void );
  81. virtual float GetViewModelFOV( void );
  82. virtual vgui::Panel* GetViewport() { return m_pViewport; }
  83. // Gets at the viewports vgui panel animation controller, if there is one...
  84. virtual vgui::AnimationController *GetViewportAnimationController()
  85. { return m_pViewport->GetAnimationController(); }
  86. virtual void FireGameEvent( IGameEvent *event );
  87. virtual bool CanRecordDemo( char *errorMsg, int length ) const { return true; }
  88. virtual int HandleSpectatorKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
  89. virtual void ComputeVguiResConditions( KeyValues *pkvConditions ) OVERRIDE;
  90. //=============================================================================
  91. // HPE_BEGIN:
  92. // [menglish] Save server information shown to the client in a persistent place
  93. //=============================================================================
  94. virtual wchar_t* GetServerName() { return NULL; }
  95. virtual void SetServerName(wchar_t* name) {}
  96. virtual wchar_t* GetMapName() { return NULL; }
  97. virtual void SetMapName(wchar_t* name) {}
  98. //=============================================================================
  99. // HPE_END
  100. //=============================================================================
  101. virtual bool DoPostScreenSpaceEffects( const CViewSetup *pSetup );
  102. virtual void DisplayReplayMessage( const char *pLocalizeName, float flDuration, bool bUrgent,
  103. const char *pSound, bool bDlg );
  104. virtual bool IsInfoPanelAllowed() OVERRIDE { return true; }
  105. virtual void InfoPanelDisplayed() OVERRIDE { }
  106. virtual bool IsHTMLInfoPanelAllowed() OVERRIDE { return true; }
  107. bool IsAnyPanelVisibleExceptScores() { return m_pViewport->IsAnyPanelVisibleExceptScores(); }
  108. bool IsPanelVisible( const char* panel ) { return m_pViewport->IsPanelVisible( panel ); }
  109. virtual void OnDemoRecordStart( char const* pDemoBaseName ) OVERRIDE {}
  110. virtual void OnDemoRecordStop() OVERRIDE {}
  111. protected:
  112. CBaseViewport *m_pViewport;
  113. void DisplayReplayReminder();
  114. private:
  115. virtual void UpdateReplayMessages();
  116. void ClearReplayMessageList();
  117. #if defined( REPLAY_ENABLED )
  118. float m_flReplayStartRecordTime;
  119. float m_flReplayStopRecordTime;
  120. CReplayReminderPanel *m_pReplayReminderPanel;
  121. #endif
  122. // Message mode handling
  123. // All modes share a common chat interface
  124. CBaseHudChat *m_pChatElement;
  125. vgui::HCursor m_CursorNone;
  126. CBaseHudWeaponSelection *m_pWeaponSelection;
  127. int m_nRootSize[2];
  128. };
  129. #endif // CLIENTMODE_NORMAL_H