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.

122 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "intromenu.h"
  8. #include <networkstringtabledefs.h>
  9. #include <cdll_client_int.h>
  10. #include <vgui/IScheme.h>
  11. #include <vgui/ILocalize.h>
  12. #include <vgui/ISurface.h>
  13. #include <filesystem.h>
  14. #include <KeyValues.h>
  15. #include <convar.h>
  16. #include <game/client/iviewport.h>
  17. #include "spectatorgui.h"
  18. #include "gamerules.h"
  19. // memdbgon must be the last include file in a .cpp file!!!
  20. #include "tier0/memdbgon.h"
  21. using namespace vgui;
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Constructor
  24. //-----------------------------------------------------------------------------
  25. CIntroMenu::CIntroMenu( IViewPort *pViewPort ) : Frame( NULL, PANEL_INTRO )
  26. {
  27. // initialize dialog
  28. m_pViewPort = pViewPort;
  29. m_pTitleLabel = NULL;
  30. // load the new scheme early!!
  31. SetScheme( "ClientScheme" );
  32. SetMoveable( false );
  33. SetSizeable( false );
  34. SetProportional( true );
  35. // hide the system buttons
  36. SetTitleBarVisible( false );
  37. Reset();
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Purpose: Destructor
  41. //-----------------------------------------------------------------------------
  42. CIntroMenu::~CIntroMenu()
  43. {
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose: Sets the color of the top and bottom bars
  47. //-----------------------------------------------------------------------------
  48. void CIntroMenu::ApplySchemeSettings( IScheme *pScheme )
  49. {
  50. BaseClass::ApplySchemeSettings( pScheme );
  51. LoadControlSettings("Resource/UI/IntroMenu.res");
  52. m_pTitleLabel = dynamic_cast<Label *>( FindChildByName( "titlelabel" ) );
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose:
  56. //-----------------------------------------------------------------------------
  57. void CIntroMenu::Reset( void )
  58. {
  59. Update();
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. //-----------------------------------------------------------------------------
  64. void CIntroMenu::Update( void )
  65. {
  66. }
  67. //-----------------------------------------------------------------------------
  68. // Purpose:
  69. //-----------------------------------------------------------------------------
  70. void CIntroMenu::OnCommand( const char *command )
  71. {
  72. if ( !Q_strcmp( command, "skip" ) )
  73. {
  74. engine->ClientCmd( "intro_skip" );
  75. m_pViewPort->ShowPanel( this, false );
  76. }
  77. BaseClass::OnCommand( command );
  78. }
  79. //-----------------------------------------------------------------------------
  80. // Purpose:
  81. //-----------------------------------------------------------------------------
  82. void CIntroMenu::ShowPanel( bool bShow )
  83. {
  84. if ( BaseClass::IsVisible() == bShow )
  85. return;
  86. m_pViewPort->ShowBackGround( bShow );
  87. if ( bShow )
  88. {
  89. Activate();
  90. if ( GameRules() )
  91. {
  92. SetDialogVariable( "gamemode", g_pVGuiLocalize->Find( GameRules()->GetGameTypeName() ) );
  93. }
  94. SetMouseInputEnabled( true );
  95. }
  96. else
  97. {
  98. SetVisible( false );
  99. SetMouseInputEnabled( false );
  100. }
  101. }