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.

158 lines
4.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SPECTATORGUI_H
  8. #define SPECTATORGUI_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/IScheme.h>
  13. #include <vgui/KeyCode.h>
  14. #include <vgui_controls/Frame.h>
  15. #include <vgui_controls/EditablePanel.h>
  16. #include <vgui_controls/Button.h>
  17. #include <vgui_controls/ComboBox.h>
  18. #include <igameevents.h>
  19. #include "GameEventListener.h"
  20. #include <game/client/iviewport.h>
  21. class KeyValues;
  22. namespace vgui
  23. {
  24. class TextEntry;
  25. class Button;
  26. class Panel;
  27. class ImagePanel;
  28. class ComboBox;
  29. }
  30. #define BLACK_BAR_COLOR Color(0, 0, 0, 196)
  31. class IBaseFileSystem;
  32. //-----------------------------------------------------------------------------
  33. // Purpose: Spectator UI
  34. //-----------------------------------------------------------------------------
  35. class CSpectatorGUI : public vgui::EditablePanel, public IViewPortPanel
  36. {
  37. DECLARE_CLASS_SIMPLE( CSpectatorGUI, vgui::EditablePanel );
  38. public:
  39. CSpectatorGUI( IViewPort *pViewPort );
  40. virtual ~CSpectatorGUI();
  41. virtual const char *GetName( void ) { return PANEL_SPECGUI; }
  42. virtual void SetData(KeyValues *data) {};
  43. virtual void Reset() {};
  44. virtual void Update();
  45. virtual bool NeedsUpdate( void ) { return false; }
  46. virtual bool HasInputElements( void ) { return false; }
  47. virtual void ShowPanel( bool bShow );
  48. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  49. vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
  50. virtual bool IsVisible() { return BaseClass::IsVisible(); }
  51. virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
  52. virtual void OnThink();
  53. virtual int GetTopBarHeight() { return m_pTopBar->GetTall(); }
  54. virtual int GetBottomBarHeight() { return m_pBottomBarBlank->GetTall(); }
  55. virtual bool ShouldShowPlayerLabel( int specmode );
  56. virtual Color GetBlackBarColor( void ) { return BLACK_BAR_COLOR; }
  57. virtual const char *GetResFile( void );
  58. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_SPECTATOR; }
  59. protected:
  60. void SetLabelText(const char *textEntryName, const char *text);
  61. void SetLabelText(const char *textEntryName, wchar_t *text);
  62. void MoveLabelToFront(const char *textEntryName);
  63. void UpdateTimer();
  64. void SetLogoImage(const char *image);
  65. protected:
  66. enum { INSET_OFFSET = 2 } ;
  67. // vgui overrides
  68. virtual void PerformLayout();
  69. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  70. // virtual void OnCommand( const char *command );
  71. vgui::Panel *m_pTopBar;
  72. vgui::Panel *m_pBottomBarBlank;
  73. vgui::ImagePanel *m_pBannerImage;
  74. vgui::Label *m_pPlayerLabel;
  75. IViewPort *m_pViewPort;
  76. // bool m_bHelpShown;
  77. // bool m_bInsetVisible;
  78. bool m_bSpecScoreboard;
  79. };
  80. //-----------------------------------------------------------------------------
  81. // Purpose: the bottom bar panel, this is a separate panel because it
  82. // wants mouse input and the main window doesn't
  83. //----------------------------------------------------------------------------
  84. class CSpectatorMenu : public vgui::Frame, public IViewPortPanel, public CGameEventListener
  85. {
  86. DECLARE_CLASS_SIMPLE( CSpectatorMenu, vgui::Frame );
  87. public:
  88. CSpectatorMenu( IViewPort *pViewPort );
  89. ~CSpectatorMenu() {}
  90. virtual const char *GetName( void ) { return PANEL_SPECMENU; }
  91. virtual void SetData(KeyValues *data) {};
  92. virtual void Reset( void ) { m_pPlayerList->DeleteAllItems(); }
  93. virtual void Update( void );
  94. virtual bool NeedsUpdate( void ) { return false; }
  95. virtual bool HasInputElements( void ) { return true; }
  96. virtual void ShowPanel( bool bShow );
  97. virtual void FireGameEvent( IGameEvent *event );
  98. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  99. virtual bool IsVisible() { return BaseClass::IsVisible(); }
  100. vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
  101. virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
  102. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_SPECTATOR; }
  103. private:
  104. // VGUI2 overrides
  105. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
  106. virtual void OnCommand( const char *command );
  107. virtual void OnKeyCodePressed(vgui::KeyCode code);
  108. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  109. virtual void PerformLayout();
  110. void SetViewModeText( const char *text ) { m_pViewOptions->SetText( text ); }
  111. void SetPlayerFgColor( Color c1 ) { m_pPlayerList->SetFgColor(c1); }
  112. vgui::ComboBox *m_pPlayerList;
  113. vgui::ComboBox *m_pViewOptions;
  114. vgui::ComboBox *m_pConfigSettings;
  115. vgui::Button *m_pLeftButton;
  116. vgui::Button *m_pRightButton;
  117. IViewPort *m_pViewPort;
  118. ButtonCode_t m_iDuckKey;
  119. };
  120. extern CSpectatorGUI * g_pSpectatorGUI;
  121. #endif // SPECTATORGUI_H