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.

110 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, 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. #include <VGUI_Frame.h>
  13. #include "ServerList.h"
  14. #include "IServerRefreshResponse.h"
  15. class KeyValues;
  16. namespace vgui
  17. {
  18. class Button;
  19. class ToggleButton;
  20. class RadioButton;
  21. class Label;
  22. class TextEntry;
  23. }
  24. //-----------------------------------------------------------------------------
  25. // Purpose: Dialog for displaying information about a game server
  26. //-----------------------------------------------------------------------------
  27. class CDialogGameInfo : public vgui::Frame, public IServerRefreshResponse
  28. {
  29. public:
  30. CDialogGameInfo(class IGameList *gameList, unsigned int serverID, int serverIP = 0, int serverPort = 0);
  31. ~CDialogGameInfo();
  32. void Run(const char *titleName);
  33. void ChangeGame(int serverIP, int serverPort);
  34. // forces the dialog to attempt to connect to the server
  35. void Connect();
  36. // implementation of IServerRefreshResponse interface
  37. // called when the server has successfully responded
  38. virtual void ServerResponded(serveritem_t &server);
  39. // called when a server response has timed out
  40. virtual void ServerFailedToRespond(serveritem_t &server);
  41. // called when the current refresh list is complete
  42. virtual void RefreshComplete();
  43. protected:
  44. // message handlers
  45. void OnConnect();
  46. void OnRefresh();
  47. void OnButtonToggled(vgui::Panel *toggleButton);
  48. // response from the get password dialog
  49. void OnJoinServerWithPassword(const char *password);
  50. DECLARE_PANELMAP();
  51. // vgui overrides
  52. void OnTick();
  53. virtual void OnClose();
  54. virtual void PerformLayout();
  55. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  56. private:
  57. long m_iRequestRetry; // time at which to retry the request
  58. // methods
  59. void RequestInfo();
  60. void ConnectToServer();
  61. void ShowAutoRetryOptions(bool state);
  62. void SetControlText(const char *textEntryName, const char *text);
  63. vgui::Button *m_pConnectButton;
  64. vgui::Button *m_pCloseButton;
  65. vgui::Button *m_pRefreshButton;
  66. vgui::Label *m_pInfoLabel;
  67. vgui::ToggleButton *m_pAutoRetry;
  68. vgui::RadioButton *m_pAutoRetryAlert;
  69. vgui::RadioButton *m_pAutoRetryJoin;
  70. // the ID of the server we're watching
  71. unsigned int m_iServerID;
  72. // server refreshing object
  73. CServerList m_Servers;
  74. // true if we should try connect to the server when it refreshes
  75. bool m_bConnecting;
  76. // password, if entered
  77. char m_szPassword[64];
  78. // state
  79. bool m_bServerNotResponding;
  80. bool m_bServerFull;
  81. bool m_bShowAutoRetryToggle;
  82. bool m_bShowingExtendedOptions;
  83. typedef vgui::Frame BaseClass;
  84. };
  85. #endif // DIALOGGAMEINFO_H