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.

107 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SELECT_PLAYER_DIALOG_H
  8. #define SELECT_PLAYER_DIALOG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/EditablePanel.h"
  13. #include "vgui_controls/ScrollableEditablePanel.h"
  14. #include "tf_controls.h"
  15. #include "vgui_avatarimage.h"
  16. // Select Player Dialog states
  17. enum
  18. {
  19. SPDS_SELECTING_PLAYER,
  20. SPDS_SELECTING_FROM_FRIENDS,
  21. SPDS_SELECTING_FROM_SERVER,
  22. SPDS_NUM_STATES,
  23. };
  24. // Button that displays the name & avatar image of a potential target
  25. class CSelectPlayerTargetPanel : public vgui::EditablePanel
  26. {
  27. DECLARE_CLASS_SIMPLE( CSelectPlayerTargetPanel, vgui::EditablePanel );
  28. public:
  29. CSelectPlayerTargetPanel( vgui::Panel *parent, const char *name ) : vgui::EditablePanel( parent, name )
  30. {
  31. m_pAvatar = new CAvatarImagePanel( this, "avatar" );
  32. m_pButton = new CExButton( this, "button", "", parent );
  33. }
  34. ~CSelectPlayerTargetPanel( void )
  35. {
  36. m_pAvatar->MarkForDeletion();
  37. m_pButton->MarkForDeletion();
  38. }
  39. void SetInfo( const CSteamID &steamID, const char *pszName );
  40. CAvatarImagePanel *GetAvatar( void ) { return m_pAvatar; }
  41. CExButton *GetButton( void ) { return m_pButton; }
  42. private:
  43. // Embedded panels
  44. CAvatarImagePanel *m_pAvatar;
  45. CExButton *m_pButton;
  46. };
  47. //-----------------------------------------------------------------------------
  48. // A dialog that allows users to select who they want to do something with
  49. //-----------------------------------------------------------------------------
  50. class CSelectPlayerDialog : public vgui::EditablePanel
  51. {
  52. DECLARE_CLASS_SIMPLE( CSelectPlayerDialog, vgui::EditablePanel );
  53. public:
  54. CSelectPlayerDialog( vgui::Panel *parent );
  55. ~CSelectPlayerDialog( void );
  56. virtual void ApplySettings( KeyValues *inResourceData );
  57. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  58. virtual void PerformLayout( void );
  59. virtual void OnCommand( const char *command );
  60. void UpdateState( void );
  61. virtual void UpdatePlayerList( void );
  62. virtual void Reset( void );
  63. virtual void SetupSelectFriends( void );
  64. virtual void SetupSelectServer( bool bFriendsOnly );
  65. virtual bool AllowOutOfGameFriends() { return false; }
  66. virtual void OnSelectPlayer( const CSteamID &steamID ) = 0;
  67. protected:
  68. virtual const char *GetResFile() { return "resource/ui/SelectPlayerDialog.res"; }
  69. struct partner_info_t
  70. {
  71. CSteamID m_steamID;
  72. CUtlString m_name;
  73. };
  74. static int SortPartnerInfoFunc( const partner_info_t *pA, const partner_info_t *pB );
  75. vgui::EditablePanel *m_pStatePanels[SPDS_NUM_STATES];
  76. int m_iCurrentState;
  77. CExButton *m_pSelectFromServerButton;
  78. CExButton *m_pCancelButton;
  79. vgui::EditablePanel *m_pPlayerList;
  80. vgui::ScrollableEditablePanel *m_pPlayerListScroller;
  81. CUtlVector<partner_info_t> m_PlayerInfoList;
  82. CUtlVector<CSelectPlayerTargetPanel*> m_pPlayerPanels;
  83. KeyValues *m_pButtonKV;
  84. bool m_bReapplyButtonKVs;
  85. bool m_bAllowSameTeam;
  86. bool m_bAllowOutsideServer;
  87. };
  88. #endif // SELECT_PLAYER_DIALOG_H