Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. local PROSPECT = "Prospecting"
  2. local PROSPECTABLE = "Prospectable"
  3. local MILLING = "Milling"
  4. local MILLABLE = "Millable"
  5.  
  6. local sides = {"Left", "Right"}
  7.  
  8. local function isDoAble()
  9. for i = 1, GameTooltip:NumLines() do
  10. for _, side in pairs(sides) do
  11. local tt = _G["GameTooltipText" .. side .. i]:GetText()
  12. if tt == PROSPECTABLE then
  13. return PROSPECT
  14. elseif tt == MILLABLE then
  15. return MILLING
  16. end
  17. end
  18. end
  19. end
  20.  
  21. local function CreateItemButtonOverlay(itemFrame)
  22. local bag = itemFrame:GetParent():GetID()
  23. local slot = itemFrame:GetID()
  24. local button = CreateFrame("Button", nil, itemFrame:GetParent(), "ItemButtonTemplate,SecureActionButtonTemplate")
  25. button:SetID(slot)
  26. button:SetAttribute("type2", "macro")
  27. button:SetAttribute("*type*", "click")
  28. button:SetAttribute("*clickbutton1", itemFrame)
  29. button:SetAttribute("clickbutton2", ATTRIBUTE_NOOP)
  30. button:RegisterForClicks("AnyUp")
  31. button:RegisterForDrag("LeftButton")
  32. button:SetWidth(itemFrame:GetWidth())
  33. button:SetHeight(itemFrame:GetHeight())
  34. button:SetPoint(itemFrame:GetPoint(1))
  35. button:SetFrameStrata("DIALOG")
  36. button:SetScript("OnShow", function(self)
  37. self:SetAttribute("macrotext2", "/cast "..self.proftype .."\n/use "..bag.." "..slot)
  38. end)
  39. button:SetScript("OnLeave", function(self, ...)
  40. self:Hide()
  41. itemFrame:GetScript("OnLeave")(itemFrame, ...)
  42. end)
  43. button:SetScript("OnReceiveDrag", function(self, ...)
  44. self:Hide()
  45. itemFrame:GetScript("OnReceiveDrag")(itemFrame, ...)
  46. end)
  47. button:SetScript("OnDragStart", function(self, ...)
  48. self:Hide()
  49. itemFrame:GetScript("OnDragStart")(itemFrame, ...)
  50. end)
  51. button:SetScript("OnEnter", function(self, ...)
  52. itemFrame:GetScript("OnEnter")(itemFrame, ...)
  53. end)
  54. button.UpdateTooltip = function(self, ...)
  55. itemFrame:UpdateTooltip(...)
  56. end
  57. return button
  58. end
  59.  
  60. hooksecurefunc("ContainerFrameItemButton_OnEnter", function(self)
  61. if GameTooltip:IsShown() and not InCombatLockdown() then
  62. local proftype = isDoAble()
  63. if proftype then
  64. GameTooltip:AddLine("Right-Click to cast " .. proftype)
  65. GameTooltip:Show()
  66. local button = self.ProspectButton
  67. if not button then
  68. button = CreateItemButtonOverlay(self)
  69. self.ProspectButton = button
  70. end
  71. button.proftype = proftype
  72. button:Show()
  73. end
  74. end
  75. end)
Add Comment
Please, Sign In to add comment