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.

115 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TRADING_START_DIALOG_H
  8. #define TRADING_START_DIALOG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/EditablePanel.h"
  13. #include "vgui_controls/ScrollableEditablePanel.h"
  14. #include "econ_controls.h"
  15. #include "vgui_avatarimage.h"
  16. // Trading Dialog states
  17. enum
  18. {
  19. TDS_SELECTING_PLAYER,
  20. TDS_SELECTING_FROM_FRIENDS,
  21. TDS_SELECTING_FROM_SERVER,
  22. TDS_SELECTING_FROM_PROFILE,
  23. TDS_NUM_STATES,
  24. };
  25. // Button that displays the name & avatar image of a potential trade target
  26. class CTradeTargetPanel : public vgui::EditablePanel
  27. {
  28. DECLARE_CLASS_SIMPLE( CTradeTargetPanel, vgui::EditablePanel );
  29. public:
  30. CTradeTargetPanel( vgui::Panel *parent, const char *name ) : vgui::EditablePanel( parent, name )
  31. {
  32. m_pAvatar = new CAvatarImagePanel( this, "avatar" );
  33. m_pButton = new CExButton( this, "button", "", parent );
  34. }
  35. ~CTradeTargetPanel( void )
  36. {
  37. m_pAvatar->MarkForDeletion();
  38. m_pButton->MarkForDeletion();
  39. }
  40. void SetInfo( const CSteamID &steamID, const char *pszName );
  41. CAvatarImagePanel *GetAvatar( void ) { return m_pAvatar; }
  42. CExButton *GetButton( void ) { return m_pButton; }
  43. private:
  44. // Embedded panels
  45. CAvatarImagePanel *m_pAvatar;
  46. CExButton *m_pButton;
  47. };
  48. //-----------------------------------------------------------------------------
  49. // A dialog that allows users to select who they want to trade with.
  50. //-----------------------------------------------------------------------------
  51. class CTradingStartDialog : public vgui::EditablePanel, public CGameEventListener
  52. {
  53. DECLARE_CLASS_SIMPLE( CTradingStartDialog, vgui::EditablePanel );
  54. public:
  55. CTradingStartDialog( vgui::Panel *parent );
  56. ~CTradingStartDialog( void );
  57. virtual void ApplySettings( KeyValues *inResourceData );
  58. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  59. virtual void PerformLayout( void );
  60. virtual void OnCommand( const char *command );
  61. virtual void FireGameEvent( IGameEvent *event );
  62. void Close( void );
  63. void Reset( void );
  64. void UpdateState( void );
  65. void SetupSelectFriends( void );
  66. void SetupSelectServer( void );
  67. void SetupSelectProfile( void );
  68. void UpdatePlayerList( void );
  69. void SendGiftTo( CSteamID steamID );
  70. void StartTradeWith( CSteamID steamID );
  71. bool ExtractSteamIDFromURL( char *inputURL );
  72. void OnLookupAccountResponse( uint64 iAccountID );
  73. bool IsInGiftMode( ) const { return m_bGiftMode; }
  74. void SetGift( CEconItemView* pGiftItem );
  75. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
  76. private:
  77. struct trade_partner_info_t
  78. {
  79. CSteamID m_steamID;
  80. CUtlString m_name;
  81. };
  82. vgui::EditablePanel *m_pStatePanels[TDS_NUM_STATES];
  83. int m_iCurrentState;
  84. CExButton *m_pSelectFromServerButton;
  85. CExButton *m_pCancelButton;
  86. vgui::EditablePanel *m_pPlayerList;
  87. vgui::ScrollableEditablePanel *m_pPlayerListScroller;
  88. CUtlVector<trade_partner_info_t> m_PlayerInfoList;
  89. CUtlVector<CTradeTargetPanel*> m_pPlayerPanels;
  90. KeyValues *m_pButtonKV;
  91. bool m_bReapplyButtonKVs;
  92. vgui::Label *m_pURLFailLabel;
  93. vgui::Label *m_pURLSearchingLabel;
  94. CEconItemView m_giftItem;
  95. bool m_bGiftMode;
  96. };
  97. CTradingStartDialog *OpenTradingStartDialog( vgui::Panel *pParent, CEconItemView* pOptGiftItem = NULL );
  98. #endif // TRADING_START_DIALOG_H