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.

237 lines
6.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef TF_LOBBYPANEL_H
  7. #define TF_LOBBYPANEL_H
  8. #include "cbase.h"
  9. //#include "tf_pvelobbypanel.h"
  10. #include "game/client/iviewport.h"
  11. #include "vgui_controls/TextEntry.h"
  12. #include "tf_matchmaking_shared.h"
  13. #include "vgui_controls/RichText.h"
  14. #include "vgui_controls/CheckButton.h"
  15. #include "tf_gc_client.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include <tier0/memdbgon.h>
  18. class CBaseLobbyContainerFrame;
  19. class CAvatarImage;
  20. class CTFBadgePanel;
  21. class CMainMenuToolTip;
  22. class CBaseLobbyPanel : public vgui::PropertySheet, public CGameEventListener
  23. {
  24. DECLARE_CLASS_SIMPLE( CBaseLobbyPanel, PropertySheet );
  25. friend class CBaseLobbyContainerFrame;
  26. public:
  27. CBaseLobbyPanel( vgui::Panel *pParent, CBaseLobbyContainerFrame* pLobbyContainer );
  28. virtual ~CBaseLobbyPanel();
  29. //
  30. // Panel overrides
  31. //
  32. virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
  33. virtual void PerformLayout() OVERRIDE;
  34. //
  35. // CGameEventListener overrides
  36. //
  37. virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
  38. virtual void OnCommand( const char *command ) OVERRIDE;
  39. int NumPlayersInParty( void ) { return m_vecPlayers.Count(); }
  40. void ToggleJoinLateCheckButton( void ) { m_pJoinLateCheckButton->SetSelected( !m_pJoinLateCheckButton->IsSelected() );}
  41. bool IsPartyActiveGroupBoxVisible() { return m_pPartyActiveGroupBox != NULL && m_pPartyActiveGroupBox->IsVisible(); }
  42. bool IsAnyoneBanned( RTime32 &rtimeExpire ) const;
  43. bool IsAnyoneLowPriority( RTime32 &rtimeExpire ) const;
  44. void UpdateControls();
  45. virtual EMatchGroup GetMatchGroup( void ) const = 0;
  46. protected:
  47. virtual void WriteGameSettingsControls();
  48. MESSAGE_FUNC_PTR( OnItemLeftClick, "ItemLeftClick", panel );
  49. MESSAGE_FUNC_PTR( OnItemContextMenu, "ItemContextMenu", panel );
  50. MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
  51. MESSAGE_FUNC_PARAMS( OnTradeWithUser, "TradeWithUser", params );
  52. CPanelAnimationVarAliasType( int, m_iNewWidth, "challenge_new_width", "19", "proportional_int" );
  53. CPanelAnimationVarAliasType( int, m_iChallengeCheckBoxWidth, "challenge_check_box_width", "8", "proportional_int" );
  54. CPanelAnimationVarAliasType( int, m_iAvatarWidth, "avatar_width", "16", "proportional_int" );
  55. CPanelAnimationVarAliasType( int, m_iPlayerNameWidth, "player_name_width", "110", "proportional_int" );
  56. CPanelAnimationVarAliasType( int, m_iBannedWidth, "squad_surplus_width", "12", "proportional_int" );
  57. // Sectioned list panels are the worst
  58. struct ChatModelPanel_t
  59. {
  60. CTFBadgePanel* m_pBadgeModel;
  61. CSteamID m_steamIDOwner;
  62. uint32 m_nShownLevel;
  63. };
  64. CUtlVector< ChatModelPanel_t > m_vecChatBadges;
  65. vgui::SectionedListPanel *m_pChatPlayerList;
  66. vgui::ImageList *m_pImageList;
  67. CBaseLobbyContainerFrame *m_pContainer;
  68. int m_iWritingPanel;
  69. int m_iImageIsBanned;
  70. int m_iImageNew;
  71. int m_iImageNo;
  72. int m_iImageRadioButtonYes;
  73. int m_iImageRadioButtonNo;
  74. int m_iImageCheckBoxDisabled;
  75. int m_iImageCheckBoxYes;
  76. int m_iImageCheckBoxNo;
  77. int m_iImageCheckBoxMixed;
  78. struct LobbyPlayerInfo
  79. {
  80. CSteamID m_steamID;
  81. CUtlString m_sName;
  82. bool m_bHasTicket;
  83. bool m_bSquadSurplus;
  84. uint32 m_nBadgeLevel;
  85. CAvatarImage *m_pAvatarImage;
  86. uint32 m_nCompletedChallenges; // bitmask of badge slots (not related to the challenge index in the schema!)
  87. bool m_bIsBanned;
  88. RTime32 m_rtimeBanExpire;
  89. RTime32 m_rtimeLowPriorityExpire;
  90. bool m_bHasCompetitiveAccess;
  91. uint32 m_unLadderRank;
  92. bool m_bIsLowPriority;
  93. uint32 m_unExperienceLevel;
  94. };
  95. const LobbyPlayerInfo* GetLobbyPlayerInfo( CSteamID &steamID ) const;
  96. virtual void OnThink() OVERRIDE
  97. {
  98. BaseClass::OnThink();
  99. WriteStatusControls();
  100. if ( gpGlobals->curtime > m_flRefreshPlayerListTime )
  101. {
  102. UpdatePlayerList();
  103. m_flRefreshPlayerListTime = gpGlobals->curtime + 1.f;
  104. }
  105. }
  106. private:
  107. void SetMatchmakingModeBackground();
  108. virtual const char* GetResFile() const = 0;
  109. virtual void ApplyChatUserSettings( const LobbyPlayerInfo& player, KeyValues* pSettings ) const = 0;
  110. void OnClickedOnPlayer();
  111. class ChatTextEntry : public vgui::TextEntry
  112. {
  113. public:
  114. ChatTextEntry( vgui::Panel *parent, const char *name ) : vgui::TextEntry( parent, name )
  115. {
  116. SetCatchEnterKey( true );
  117. SetAllowNonAsciiCharacters( true );
  118. SetDrawLanguageIDAtLeft( true );
  119. }
  120. virtual void OnKeyCodeTyped(vgui::KeyCode code)
  121. {
  122. if ( code == KEY_ENTER || code == KEY_PAD_ENTER )
  123. {
  124. if ( GetTextLength() > 0 )
  125. {
  126. int nBufSizeBytes = ( GetTextLength() + 4 ) * sizeof( wchar_t );
  127. wchar_t *wText = (wchar_t *)stackalloc( nBufSizeBytes );
  128. GetText( wText, nBufSizeBytes );
  129. TextEntry::SetText("");
  130. // Convert to UTF8, which is really what we should
  131. // use for everything
  132. int nUtf8BufferSizeBytes = nBufSizeBytes * 2;
  133. char *szText = (char *)stackalloc( nUtf8BufferSizeBytes );
  134. V_UnicodeToUTF8( wText, szText, nUtf8BufferSizeBytes );
  135. GTFGCClientSystem()->SendSteamLobbyChat( CTFGCClientSystem::k_eLobbyMsg_UserChat, szText );
  136. }
  137. }
  138. else if ( code == KEY_TAB )
  139. {
  140. // Ignore tab, otherwise vgui will screw up the focus.
  141. return;
  142. }
  143. else
  144. {
  145. vgui::TextEntry::OnKeyCodeTyped( code );
  146. }
  147. }
  148. };
  149. class ChatLog : public vgui::RichText
  150. {
  151. public:
  152. ChatLog( vgui::Panel *parent, const char *name ) : vgui::RichText( parent, name )
  153. {
  154. }
  155. virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
  156. {
  157. vgui::RichText::ApplySchemeSettings(pScheme);
  158. vgui::HFont hFont = pScheme->GetFont( "ChatMiniFont" );
  159. SetFont( hFont );
  160. }
  161. };
  162. CUtlVector<vgui::Label *> m_vecSearchCriteriaLabels;
  163. vgui::EditablePanel *m_pSearchActiveGroupBox;
  164. vgui::Label *m_pSearchActiveTitleLabel;
  165. vgui::Label *m_pSearchActivePenaltyLabel;
  166. vgui::EditablePanel *m_pPartyHasLowPriority;
  167. vgui::CheckButton *m_pJoinLateCheckButton;
  168. vgui::Label *m_pJoinLateValueLabel;
  169. vgui::EditablePanel *m_pPartyActiveGroupBox;
  170. vgui::Button *m_pInviteButton;
  171. ChatLog *m_pChatLog;
  172. ChatTextEntry *m_pChatTextEntry;
  173. int m_iImageAvatars[MAX_PLAYERS+1];
  174. CUtlMap<int,int> m_mapAvatarsToImageList;
  175. vgui::HFont m_fontPlayerListItem;
  176. CSOTFParty_State m_eCurrentPartyState;
  177. float m_flRefreshPlayerListTime;
  178. CMainMenuToolTip* m_pToolTip;
  179. void UpdatePlayerList();
  180. void WriteStatusControls(); // MM status
  181. virtual bool ShouldShowLateJoin() const = 0;
  182. CUtlVector<LobbyPlayerInfo> m_vecPlayers;
  183. CCallback<CBaseLobbyPanel, PersonaStateChange_t, false> m_sPersonaStateChangedCallback;
  184. void OnPersonaStateChanged( PersonaStateChange_t *info )
  185. {
  186. UpdatePlayerList();
  187. }
  188. };
  189. #endif //TF_LOBBYPANEL_H