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.

168 lines
5.1 KiB

  1. //========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef SERVERBROWSERDIALOG_H
  8. #define SERVERBROWSERDIALOG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. extern class IRunGameEngine *g_pRunGameEngine;
  13. //-----------------------------------------------------------------------------
  14. // Purpose:
  15. //-----------------------------------------------------------------------------
  16. class CServerBrowserDialog : public vgui::Frame
  17. {
  18. DECLARE_CLASS_SIMPLE( CServerBrowserDialog, vgui::Frame );
  19. public:
  20. // Construction/destruction
  21. CServerBrowserDialog( vgui::Panel *parent );
  22. ~CServerBrowserDialog( void );
  23. void Initialize( void );
  24. // displays the dialog, moves it into focus, updates if it has to
  25. void Open( void );
  26. // gets server info
  27. gameserveritem_t *GetServer(unsigned int serverID);
  28. // called every frame
  29. virtual void OnTick();
  30. // updates status text at bottom of window
  31. void UpdateStatusText(const char *format, ...);
  32. // updates status text at bottom of window
  33. void UpdateStatusText(wchar_t *unicode);
  34. // context menu access
  35. CServerContextMenu *GetContextMenu(vgui::Panel *pParent);
  36. // returns a pointer to a static instance of this dialog
  37. // valid for use only in sort functions
  38. static CServerBrowserDialog *GetInstance();
  39. // Adds a server to the list of favorites
  40. void AddServerToFavorites(gameserveritem_t &server);
  41. // Adds a server to our list of blacklisted servers
  42. void AddServerToBlacklist(gameserveritem_t &server);
  43. bool IsServerBlacklisted(gameserveritem_t &server);
  44. // begins the process of joining a server from a game list
  45. // the game info dialog it opens will also update the game list
  46. // Join type param indicates the server browser tab used.
  47. CDialogGameInfo *JoinGame(IGameList *gameList, unsigned int serverIndex, const char* szJoinType );
  48. // joins a game by a specified IP, not attached to any game list
  49. CDialogGameInfo *JoinGame(int serverIP, int serverPort);
  50. // opens a game info dialog from a game list
  51. CDialogGameInfo *OpenGameInfoDialog(IGameList *gameList, unsigned int serverIndex);
  52. // opens a game info dialog by a specified IP, not attached to any game list
  53. CDialogGameInfo *OpenGameInfoDialog( int serverIP, uint16 connPort, uint16 queryPort );
  54. // closes all the game info dialogs
  55. void CloseAllGameInfoDialogs();
  56. CDialogGameInfo *GetDialogGameInfoForFriend( uint64 ulSteamIDFriend );
  57. // accessor to the filter save data
  58. KeyValues *GetFilterSaveData(const char *filterSet);
  59. // gets the name of the mod directory we're restricted to accessing, NULL if none
  60. const char *GetActiveModName();
  61. CGameID &GetActiveAppID();
  62. const char *GetActiveGameName();
  63. // load/saves filter & favorites settings from disk
  64. void LoadUserData();
  65. void SaveUserData();
  66. // forces the currently active page to refresh
  67. void RefreshCurrentPage();
  68. virtual gameserveritem_t *GetCurrentConnectedServer()
  69. {
  70. return &m_CurrentConnection;
  71. }
  72. void BlacklistsChanged();
  73. CBlacklistedServers *GetBlacklistPage( void ) { return m_pBlacklist; }
  74. virtual void OnKeyCodePressed( vgui::KeyCode code );
  75. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  76. virtual void OnClose();
  77. private:
  78. // current game list change
  79. MESSAGE_FUNC( OnGameListChanged, "PageChanged" );
  80. void ReloadFilterSettings();
  81. // receives a specified game is active, so no other game types can be displayed in server list
  82. MESSAGE_FUNC_PARAMS( OnActiveGameName, "ActiveGameName", name );
  83. // notification that we connected / disconnected
  84. MESSAGE_FUNC_PARAMS( OnConnectToGame, "ConnectedToGame", kv );
  85. MESSAGE_FUNC( OnDisconnectFromGame, "DisconnectedFromGame" );
  86. MESSAGE_FUNC_PARAMS( ShowServerBrowserPage, "ShowServerBrowserPage", kv );
  87. MESSAGE_FUNC_PARAMS( SetCustomScheme, "SetCustomScheme", kv );
  88. MESSAGE_FUNC_CHARPTR( RunModuleCommand, "RunModuleCommand", command );
  89. virtual bool GetDefaultScreenPosition(int &x, int &y, int &wide, int &tall);
  90. virtual void ActivateBuildMode();
  91. private:
  92. // list of all open game info dialogs
  93. CUtlVector<vgui::DHANDLE<CDialogGameInfo> > m_GameInfoDialogs;
  94. // pointer to current game list
  95. IGameList *m_pGameList;
  96. // Status text
  97. vgui::Label *m_pStatusLabel;
  98. // property sheet
  99. vgui::PropertySheet *m_pTabPanel;
  100. CFavoriteGames *m_pFavorites;
  101. CBlacklistedServers *m_pBlacklist;
  102. CHistoryGames *m_pHistory;
  103. CInternetGames *m_pInternetGames;
  104. CSpectateGames *m_pSpectateGames;
  105. CLanGames *m_pLanGames;
  106. CFriendsGames *m_pFriendsGames;
  107. KeyValues *m_pSavedData;
  108. KeyValues *m_pFilterData;
  109. // context menu
  110. CServerContextMenu *m_pContextMenu;
  111. // active game
  112. char m_szGameName[128];
  113. char m_szModDir[128];
  114. CGameID m_iLimitAppID;
  115. // currently connected game
  116. bool m_bCurrentlyConnected;
  117. gameserveritem_t m_CurrentConnection;
  118. bool m_bActive;
  119. };
  120. // singleton accessor
  121. extern CServerBrowserDialog &ServerBrowserDialog();
  122. // Used by the LAN tab and the add server dialog when trying to find servers without having
  123. // been given any ports to look for servers on.
  124. void GetMostCommonQueryPorts( CUtlVector<uint16> &ports );
  125. #endif // SERVERBROWSERDIALOG_H