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.

57 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "BanContextMenu.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. CBanContextMenu::CBanContextMenu(Panel *parent) : Menu(parent, "BanContextMenu")
  17. {
  18. CBanContextMenu::parent=parent;
  19. }
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Destructor
  22. //-----------------------------------------------------------------------------
  23. CBanContextMenu::~CBanContextMenu()
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Activates the menu
  28. //-----------------------------------------------------------------------------
  29. void CBanContextMenu::ShowMenu(Panel *target, unsigned int banID)
  30. {
  31. DeleteAllItems();
  32. if(banID==-1)
  33. {
  34. AddMenuItem("ban", "#Ban_Menu_Add", new KeyValues("addban", "banID", banID), CBanContextMenu::parent);
  35. }
  36. else
  37. {
  38. AddMenuItem("ban", "#Ban_Menu_Remove", new KeyValues("removeban", "banID", banID), CBanContextMenu::parent);
  39. AddMenuItem("ban", "#Ban_Menu_Change", new KeyValues("changeban", "banID", banID), CBanContextMenu::parent);
  40. }
  41. MakePopup();
  42. int x, y, gx, gy;
  43. input()->GetCursorPos(x, y);
  44. ipanel()->GetPos(surface()->GetEmbeddedPanel(), gx, gy);
  45. SetPos(x - gx, y - gy);
  46. MoveToFront();
  47. RequestFocus();
  48. SetVisible(true);
  49. }