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.

99 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Draws the normal TF2 or HL2 HUD.
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "clientmode_hlnormal.h"
  8. #include "vgui_int.h"
  9. #include "hud.h"
  10. #include <vgui/IInput.h>
  11. #include <vgui/IPanel.h>
  12. #include <vgui/ISurface.h>
  13. #include <vgui_controls/AnimationController.h>
  14. #include "iinput.h"
  15. #include "ienginevgui.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. extern bool g_bRollingCredits;
  19. ConVar fov_desired( "fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 90.0 );
  20. //-----------------------------------------------------------------------------
  21. // Globals
  22. //-----------------------------------------------------------------------------
  23. vgui::HScheme g_hVGuiCombineScheme = 0;
  24. // Instance the singleton and expose the interface to it.
  25. IClientMode *GetClientModeNormal()
  26. {
  27. static ClientModeHLNormal g_ClientModeNormal;
  28. return &g_ClientModeNormal;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Purpose: this is the viewport that contains all the hud elements
  32. //-----------------------------------------------------------------------------
  33. class CHudViewport : public CBaseViewport
  34. {
  35. private:
  36. DECLARE_CLASS_SIMPLE( CHudViewport, CBaseViewport );
  37. protected:
  38. virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
  39. {
  40. BaseClass::ApplySchemeSettings( pScheme );
  41. gHUD.InitColors( pScheme );
  42. SetPaintBackgroundEnabled( false );
  43. }
  44. virtual void CreateDefaultPanels( void ) { /* don't create any panels yet*/ };
  45. };
  46. //-----------------------------------------------------------------------------
  47. // ClientModeHLNormal implementation
  48. //-----------------------------------------------------------------------------
  49. ClientModeHLNormal::ClientModeHLNormal()
  50. {
  51. m_pViewport = new CHudViewport();
  52. m_pViewport->Start( gameuifuncs, gameeventmanager );
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose:
  56. //-----------------------------------------------------------------------------
  57. ClientModeHLNormal::~ClientModeHLNormal()
  58. {
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. //-----------------------------------------------------------------------------
  63. void ClientModeHLNormal::Init()
  64. {
  65. BaseClass::Init();
  66. // Load up the combine control panel scheme
  67. g_hVGuiCombineScheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), IsXbox() ? "resource/ClientScheme.res" : "resource/CombinePanelScheme.res", "CombineScheme" );
  68. if (!g_hVGuiCombineScheme)
  69. {
  70. Warning( "Couldn't load combine panel scheme!\n" );
  71. }
  72. }
  73. bool ClientModeHLNormal::ShouldDrawCrosshair( void )
  74. {
  75. return ( g_bRollingCredits == false );
  76. }