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.

51 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "PlayerContextMenu.h"
  8. #include <vgui/IInput.h>
  9. #include <vgui/IPanel.h>
  10. #include <vgui/ISurface.h>
  11. #include <KeyValues.h>
  12. using namespace vgui;
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Constructor
  15. //-----------------------------------------------------------------------------
  16. CPlayerContextMenu::CPlayerContextMenu(Panel *parent) : Menu(parent, "ServerContextMenu")
  17. {
  18. CPlayerContextMenu::parent=parent;
  19. }
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Destructor
  22. //-----------------------------------------------------------------------------
  23. CPlayerContextMenu::~CPlayerContextMenu()
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Activates the menu
  28. //-----------------------------------------------------------------------------
  29. void CPlayerContextMenu::ShowMenu(Panel *target, unsigned int playerID)
  30. {
  31. DeleteAllItems();
  32. AddMenuItem("Kick", "#Player_Menu_Kick", new KeyValues("Kick", "playerID", playerID), CPlayerContextMenu::parent);
  33. AddMenuItem("Ban", "#Player_Menu_Ban", new KeyValues("Ban", "playerID", playerID), CPlayerContextMenu::parent);
  34. //addMenuItem("Status", "&Player Status", new KeyValues("Status", "playerID", playerID), CPlayerContextMenu::parent);
  35. MakePopup();
  36. int x, y, gx, gy;
  37. input()->GetCursorPos(x, y);
  38. ipanel()->GetPos(surface()->GetEmbeddedPanel(), gx, gy);
  39. SetPos(x - gx, y - gy);
  40. MoveToFront();
  41. RequestFocus();
  42. SetVisible(true);
  43. }