Counter Strike : Global Offensive Source Code
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.

128 lines
3.9 KiB

  1. //========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef DIALOGGAMEINFO_H
  8. #define DIALOGGAMEINFO_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. struct challenge_s
  13. {
  14. netadr_t addr;
  15. int challenge;
  16. };
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Dialog for displaying information about a game server
  19. //-----------------------------------------------------------------------------
  20. class CDialogGameInfo : public vgui::Frame, public ISteamMatchmakingPlayersResponse, public ISteamMatchmakingPingResponse
  21. {
  22. DECLARE_CLASS_SIMPLE( CDialogGameInfo, vgui::Frame );
  23. public:
  24. CDialogGameInfo(vgui::Panel *browser, vgui::Panel *parent, int serverIP, int queryPort, unsigned short connectionPort );
  25. ~CDialogGameInfo();
  26. void Run(const char *titleName);
  27. void ChangeGame(int serverIP, int queryPort, unsigned short connectionPort);
  28. void SetFriend( uint64 ulSteamIDFriend );
  29. uint64 GetAssociatedFriend();
  30. // forces the dialog to attempt to connect to the server
  31. void Connect( const char* szJoinType );
  32. // implementation of IServerRefreshResponse interface
  33. // called when the server has successfully responded
  34. virtual void ServerResponded( gameserveritem_t &server );
  35. // called when a server response has timed out
  36. virtual void ServerFailedToRespond();
  37. // on individual player added
  38. virtual void AddPlayerToList(const char *playerName, int score, float timePlayedSeconds);
  39. virtual void PlayersFailedToRespond() {}
  40. virtual void PlayersRefreshComplete() { m_hPlayersQuery = HSERVERQUERY_INVALID; }
  41. // called when the current refresh list is complete
  42. virtual void RefreshComplete( EMatchMakingServerResponse response );
  43. // player list received
  44. virtual void ClearPlayerList();
  45. //virtual void SendChallengeQuery( const netadr_t & to );
  46. virtual void SendPlayerQuery( uint32 unIP, uint16 usQueryPort );
  47. //virtual void InsertChallengeResponse( const netadr_t & to, int nChallenge );
  48. protected:
  49. // message handlers
  50. MESSAGE_FUNC( OnConnect, "Connect" );
  51. MESSAGE_FUNC( OnRefresh, "Refresh" );
  52. MESSAGE_FUNC_PTR( OnButtonToggled, "ButtonToggled", panel );
  53. MESSAGE_FUNC_PTR( OnRadioButtonChecked, "RadioButtonChecked", panel )
  54. {
  55. OnButtonToggled( panel );
  56. }
  57. // response from the get password dialog
  58. MESSAGE_FUNC_CHARPTR( OnJoinServerWithPassword, "JoinServerWithPassword", password );
  59. MESSAGE_FUNC_INT_INT( OnConnectToGame, "ConnectedToGame", ip, port );
  60. // vgui overrides
  61. virtual void OnTick();
  62. virtual void PerformLayout();
  63. private:
  64. STEAM_CALLBACK( CDialogGameInfo, OnPersonaStateChange, PersonaStateChange_t, m_CallbackPersonaStateChange );
  65. long m_iRequestRetry; // time at which to retry the request
  66. static int PlayerTimeColumnSortFunc(vgui::ListPanel *pPanel, const vgui::ListPanelItem &p1, const vgui::ListPanelItem &p2);
  67. // methods
  68. void RequestInfo();
  69. void ConnectToServer();
  70. void ShowAutoRetryOptions(bool state);
  71. void ConstructConnectArgs( char *pchOptions, int cchOptions, const gameserveritem_t &server );
  72. void ApplyConnectCommand( const gameserveritem_t &server );
  73. vgui::Button *m_pConnectButton;
  74. vgui::Button *m_pCloseButton;
  75. vgui::Button *m_pRefreshButton;
  76. vgui::Label *m_pInfoLabel;
  77. vgui::ToggleButton *m_pAutoRetry;
  78. vgui::RadioButton *m_pAutoRetryAlert;
  79. vgui::RadioButton *m_pAutoRetryJoin;
  80. vgui::ListPanel *m_pPlayerList;
  81. vgui::Panel *m_pBrowser;
  82. enum { PING_TIMES_MAX = 4 };
  83. // true if we should try connect to the server when it refreshes
  84. bool m_bConnecting;
  85. // password, if entered
  86. char m_szPassword[64];
  87. // state
  88. bool m_bServerNotResponding;
  89. bool m_bServerFull;
  90. bool m_bShowAutoRetryToggle;
  91. bool m_bShowingExtendedOptions;
  92. uint64 m_SteamIDFriend;
  93. gameserveritem_t m_Server;
  94. HServerQuery m_hPingQuery;
  95. HServerQuery m_hPlayersQuery;
  96. bool m_bPlayerListUpdatePending;
  97. const char* m_szJoinType;
  98. };
  99. #endif // DIALOGGAMEINFO_H