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.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "RulesContextMenu.h"
  8. #include <VGUI_Controls.h>
  9. #include <VGUI_IInput.h>
  10. #include <VGUI_IPanel.h>
  11. #include <VGUI_ISurface.h>
  12. #include <VGUI_KeyValues.h>
  13. using namespace vgui;
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Constructor
  16. //-----------------------------------------------------------------------------
  17. CRulesContextMenu::CRulesContextMenu(Panel *parent) : Menu(parent, "RulesContextMenu")
  18. {
  19. CRulesContextMenu::parent=parent;
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Destructor
  23. //-----------------------------------------------------------------------------
  24. CRulesContextMenu::~CRulesContextMenu()
  25. {
  26. }
  27. //-----------------------------------------------------------------------------
  28. // Purpose: Activates the menu
  29. //-----------------------------------------------------------------------------
  30. void CRulesContextMenu::ShowMenu(Panel *target, unsigned int cvarID)
  31. {
  32. ClearMenu();
  33. AddMenuItem("cvar", "&Change Value", new KeyValues("cvar", "cvarID", cvarID), CRulesContextMenu::parent);
  34. MakePopup();
  35. int x, y, gx, gy;
  36. input()->GetCursorPos(x, y);
  37. ipanel()->GetPos(surface()->GetEmbeddedPanel(), gx, gy);
  38. SetPos(x - gx, y - gy);
  39. MoveToFront();
  40. RequestFocus();
  41. SetVisible(true);
  42. }