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.

63 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "pch_serverbrowser.h"
  8. using namespace vgui;
  9. //-----------------------------------------------------------------------------
  10. // Purpose: Constructor
  11. //-----------------------------------------------------------------------------
  12. CServerContextMenu::CServerContextMenu(Panel *parent) : Menu(parent, "ServerContextMenu")
  13. {
  14. }
  15. //-----------------------------------------------------------------------------
  16. // Purpose: Destructor
  17. //-----------------------------------------------------------------------------
  18. CServerContextMenu::~CServerContextMenu()
  19. {
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Activates the menu
  23. //-----------------------------------------------------------------------------
  24. void CServerContextMenu::ShowMenu(
  25. Panel *target,
  26. unsigned int serverID,
  27. bool showConnect,
  28. bool showViewGameInfo,
  29. bool showRefresh,
  30. bool showAddToFavorites )
  31. {
  32. if (showConnect)
  33. {
  34. AddMenuItem("ConnectToServer", "#ServerBrowser_ConnectToServer", new KeyValues("ConnectToServer", "serverID", serverID), target);
  35. }
  36. if (showViewGameInfo)
  37. {
  38. AddMenuItem("ViewGameInfo", "#ServerBrowser_ViewServerInfo", new KeyValues("ViewGameInfo", "serverID", serverID), target);
  39. }
  40. if (showRefresh)
  41. {
  42. AddMenuItem("RefreshServer", "#ServerBrowser_RefreshServer", new KeyValues("RefreshServer", "serverID", serverID), target);
  43. }
  44. if (showAddToFavorites)
  45. {
  46. AddMenuItem("AddToFavorites", "#ServerBrowser_AddServerToFavorites", new KeyValues("AddToFavorites", "serverID", serverID), target);
  47. AddMenuItem("AddToBlacklist", "#ServerBrowser_AddServerToBlacklist", new KeyValues("AddToBlacklist", "serverID", serverID), target);
  48. }
  49. int x, y, gx, gy;
  50. input()->GetCursorPos(x, y);
  51. ipanel()->GetPos(surface()->GetEmbeddedPanel(), gx, gy);
  52. SetPos(x - gx, y - gy);
  53. SetVisible(true);
  54. }