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.

140 lines
4.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_SPECTATORGUI_H
  7. #define TF_SPECTATORGUI_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <spectatorgui.h>
  12. #include "hudelement.h"
  13. #include "tf_hud_playerstatus.h"
  14. #include "item_model_panel.h"
  15. #include "tf_gamerules.h"
  16. #include <vgui_controls/EditablePanel.h>
  17. extern ConVar cl_use_tournament_specgui;
  18. class CAvatarImagePanel;
  19. class CTFPlayerPanel;
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Custom health panel used to show spectator target's health
  22. //-----------------------------------------------------------------------------
  23. class CTFSpectatorGUIHealth : public CTFHudPlayerHealth
  24. {
  25. public:
  26. CTFSpectatorGUIHealth( Panel *parent, const char *name ) : CTFHudPlayerHealth( parent, name )
  27. {
  28. }
  29. virtual const char *GetResFilename( void )
  30. {
  31. return "resource/UI/SpectatorGUIHealth.res";
  32. }
  33. virtual void OnThink()
  34. {
  35. // Do nothing. We're just preventing the base health panel from updating.
  36. }
  37. };
  38. //-----------------------------------------------------------------------------
  39. // Purpose: TF Spectator UI
  40. //-----------------------------------------------------------------------------
  41. class CTFSpectatorGUI : public CSpectatorGUI, public CGameEventListener
  42. {
  43. private:
  44. DECLARE_CLASS_SIMPLE( CTFSpectatorGUI, CSpectatorGUI );
  45. public:
  46. CTFSpectatorGUI( IViewPort *pViewPort );
  47. ~CTFSpectatorGUI( void );
  48. virtual void Reset( void );
  49. virtual void PerformLayout( void );
  50. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  51. virtual void ApplySettings( KeyValues *inResourceData );
  52. virtual void Update( void );
  53. virtual bool NeedsUpdate( void );
  54. virtual bool ShouldShowPlayerLabel( int specmode ) { return false; }
  55. void UpdateReinforcements( void );
  56. virtual void ShowPanel(bool bShow);
  57. virtual Color GetBlackBarColor( void ) { return Color(52,48,45, 255); }
  58. void UpdateKeyLabels( void );
  59. virtual void FireGameEvent( IGameEvent *event );
  60. void UpdateItemPanel( bool bForce = false );
  61. void ForceItemPanelCycle( void );
  62. virtual const char *GetResFile( void );
  63. // Tournament mode handling
  64. bool InTournamentGUI( void );
  65. void RecalculatePlayerPanels( void );
  66. void UpdatePlayerPanels( void );
  67. void SelectSpec( int iSlot );
  68. virtual int GetTopBarHeight();
  69. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_SPECTATOR; }
  70. protected:
  71. int m_nLastSpecMode;
  72. float m_flNextTipChangeTime; // time at which to next change the tip
  73. int m_iTipClass; // class that current tip is for
  74. // used to store the x and y position of the Engy and Spy build panels so we can reset them when the spec panel goes away
  75. int m_nEngBuilds_xpos;
  76. int m_nEngBuilds_ypos;
  77. int m_nSpyBuilds_xpos;
  78. int m_nSpyBuilds_ypos;
  79. int m_nMannVsMachineStatus_xpos;
  80. int m_nMannVsMachineStatus_ypos;
  81. vgui::Label *m_pReinforcementsLabel;
  82. CExLabel *m_pBuyBackLabel;
  83. vgui::Label *m_pClassOrTeamLabel;
  84. CExLabel *m_pClassOrTeamKeyLabel;
  85. vgui::Label *m_pSwitchCamModeKeyLabel;
  86. vgui::Label *m_pCycleTargetFwdKeyLabel;
  87. vgui::Label *m_pCycleTargetRevKeyLabel;
  88. vgui::Label *m_pMapLabel;
  89. CItemModelPanel *m_pItemPanel;
  90. float m_flNextItemPanelUpdate;
  91. EHANDLE m_hPrevItemPlayer;
  92. int m_iPrevItemShown;
  93. int m_iFirstItemShown;
  94. bool m_bShownItems;
  95. // Tournament mode player panel handling
  96. CUtlVector<CTFPlayerPanel*> m_PlayerPanels;
  97. KeyValues *m_pPlayerPanelKVs;
  98. bool m_bReapplyPlayerPanelKVs;
  99. bool m_bPrevTournamentMode;
  100. float m_flNextPlayerPanelUpdate;
  101. // Coaching
  102. bool m_bCoaching;
  103. CAvatarImagePanel *m_pAvatar;
  104. CTFSpectatorGUIHealth *m_pStudentHealth;
  105. CPanelAnimationVarAliasType( int, m_iTeam1PlayerBaseOffsetX, "team1_player_base_offset_x", "0", "proportional_int" );
  106. CPanelAnimationVarAliasType( int, m_iTeam1PlayerBaseX, "team1_player_base_x", "0", "proportional_int" );
  107. CPanelAnimationVarAliasType( int, m_iTeam1PlayerBaseY, "team1_player_base_y", "0", "proportional_int" );
  108. CPanelAnimationVarAliasType( int, m_iTeam2PlayerBaseX, "team2_player_base_x", "0", "proportional_int" );
  109. CPanelAnimationVarAliasType( int, m_iTeam2PlayerBaseOffsetX, "team2_player_base_offset_x", "0", "proportional_int" );
  110. CPanelAnimationVarAliasType( int, m_iTeam2PlayerBaseY, "team2_player_base_y", "0", "proportional_int" );
  111. CPanelAnimationVarAliasType( int, m_iTeam1PlayerDeltaX, "team1_player_delta_x", "0", "proportional_int" );
  112. CPanelAnimationVarAliasType( int, m_iTeam1PlayerDeltaY, "team1_player_delta_y", "0", "proportional_int" );
  113. CPanelAnimationVarAliasType( int, m_iTeam2PlayerDeltaX, "team2_player_delta_x", "0", "proportional_int" );
  114. CPanelAnimationVarAliasType( int, m_iTeam2PlayerDeltaY, "team2_player_delta_y", "0", "proportional_int" );
  115. };
  116. #endif // TF_SPECTATORGUI_H