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.

159 lines
4.8 KiB

  1. //========= Copyright Valve Corporation, 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(PRINTF_FORMAT_STRING 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. CDialogGameInfo *JoinGame(IGameList *gameList, unsigned int serverIndex);
  47. // joins a game by a specified IP, not attached to any game list
  48. CDialogGameInfo *JoinGame(int serverIP, int serverPort, const char *pszConnectCode);
  49. // opens a game info dialog from a game list
  50. CDialogGameInfo *OpenGameInfoDialog(IGameList *gameList, unsigned int serverIndex);
  51. // opens a game info dialog by a specified IP, not attached to any game list
  52. CDialogGameInfo *OpenGameInfoDialog( int serverIP, uint16 connPort, uint16 queryPort, const char *pszConnectCode );
  53. // closes all the game info dialogs
  54. void CloseAllGameInfoDialogs();
  55. CDialogGameInfo *GetDialogGameInfoForFriend( uint64 ulSteamIDFriend );
  56. // accessor to the filter save data
  57. KeyValues *GetFilterSaveData(const char *filterSet);
  58. // gets the name of the mod directory we're restricted to accessing, NULL if none
  59. const char *GetActiveModName();
  60. CGameID &GetActiveAppID();
  61. const char *GetActiveGameName();
  62. // load/saves filter & favorites settings from disk
  63. void LoadUserData();
  64. void SaveUserData();
  65. // forces the currently active page to refresh
  66. void RefreshCurrentPage();
  67. virtual gameserveritem_t *GetCurrentConnectedServer()
  68. {
  69. return &m_CurrentConnection;
  70. }
  71. void BlacklistsChanged();
  72. CBlacklistedServers *GetBlacklistPage( void ) { return m_pBlacklist; }
  73. private:
  74. // current game list change
  75. MESSAGE_FUNC( OnGameListChanged, "PageChanged" );
  76. void ReloadFilterSettings();
  77. // receives a specified game is active, so no other game types can be displayed in server list
  78. MESSAGE_FUNC_PARAMS( OnActiveGameName, "ActiveGameName", name );
  79. // notification that we connected / disconnected
  80. MESSAGE_FUNC_PARAMS( OnConnectToGame, "ConnectedToGame", kv );
  81. MESSAGE_FUNC( OnDisconnectFromGame, "DisconnectedFromGame" );
  82. MESSAGE_FUNC( OnLoadingStarted, "LoadingStarted" );
  83. virtual bool GetDefaultScreenPosition(int &x, int &y, int &wide, int &tall);
  84. virtual void ActivateBuildMode();
  85. void OnKeyCodePressed( vgui::KeyCode code );
  86. private:
  87. // list of all open game info dialogs
  88. CUtlVector<vgui::DHANDLE<CDialogGameInfo> > m_GameInfoDialogs;
  89. // pointer to current game list
  90. IGameList *m_pGameList;
  91. // Status text
  92. vgui::Label *m_pStatusLabel;
  93. // property sheet
  94. vgui::PropertySheet *m_pTabPanel;
  95. CFavoriteGames *m_pFavorites;
  96. CBlacklistedServers *m_pBlacklist;
  97. CHistoryGames *m_pHistory;
  98. CInternetGames *m_pInternetGames;
  99. CSpectateGames *m_pSpectateGames;
  100. CLanGames *m_pLanGames;
  101. CFriendsGames *m_pFriendsGames;
  102. KeyValues *m_pSavedData;
  103. KeyValues *m_pFilterData;
  104. // context menu
  105. CServerContextMenu *m_pContextMenu;
  106. // active game
  107. char m_szGameName[128];
  108. char m_szModDir[128];
  109. CGameID m_iLimitAppID;
  110. // currently connected game
  111. bool m_bCurrentlyConnected;
  112. gameserveritem_t m_CurrentConnection;
  113. };
  114. // singleton accessor
  115. extern CServerBrowserDialog &ServerBrowserDialog();
  116. // Used by the LAN tab and the add server dialog when trying to find servers without having
  117. // been given any ports to look for servers on.
  118. void GetMostCommonQueryPorts( CUtlVector<uint16> &ports );
  119. #endif // SERVERBROWSERDIALOG_H