Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PROSPECT = "Prospecting"
- local PROSPECTABLE = "Prospectable"
- local MILLING = "Milling"
- local MILLABLE = "Millable"
- local sides = {"Left", "Right"}
- local function isDoAble()
- for i = 1, GameTooltip:NumLines() do
- for _, side in pairs(sides) do
- local tt = _G["GameTooltipText" .. side .. i]:GetText()
- if tt == PROSPECTABLE then
- return PROSPECT
- elseif tt == MILLABLE then
- return MILLING
- end
- end
- end
- end
- local function CreateItemButtonOverlay(itemFrame)
- local bag = itemFrame:GetParent():GetID()
- local slot = itemFrame:GetID()
- local button = CreateFrame("Button", nil, itemFrame:GetParent(), "ItemButtonTemplate,SecureActionButtonTemplate")
- button:SetID(slot)
- button:SetAttribute("type2", "macro")
- button:SetAttribute("*type*", "click")
- button:SetAttribute("*clickbutton1", itemFrame)
- button:SetAttribute("clickbutton2", ATTRIBUTE_NOOP)
- button:RegisterForClicks("AnyUp")
- button:RegisterForDrag("LeftButton")
- button:SetWidth(itemFrame:GetWidth())
- button:SetHeight(itemFrame:GetHeight())
- button:SetPoint(itemFrame:GetPoint(1))
- button:SetFrameStrata("DIALOG")
- button:SetScript("OnShow", function(self)
- self:SetAttribute("macrotext2", "/cast "..self.proftype .."\n/use "..bag.." "..slot)
- end)
- button:SetScript("OnLeave", function(self, ...)
- self:Hide()
- itemFrame:GetScript("OnLeave")(itemFrame, ...)
- end)
- button:SetScript("OnReceiveDrag", function(self, ...)
- self:Hide()
- itemFrame:GetScript("OnReceiveDrag")(itemFrame, ...)
- end)
- button:SetScript("OnDragStart", function(self, ...)
- self:Hide()
- itemFrame:GetScript("OnDragStart")(itemFrame, ...)
- end)
- button:SetScript("OnEnter", function(self, ...)
- itemFrame:GetScript("OnEnter")(itemFrame, ...)
- end)
- button.UpdateTooltip = function(self, ...)
- itemFrame:UpdateTooltip(...)
- end
- return button
- end
- hooksecurefunc("ContainerFrameItemButton_OnEnter", function(self)
- if GameTooltip:IsShown() and not InCombatLockdown() then
- local proftype = isDoAble()
- if proftype then
- GameTooltip:AddLine("Right-Click to cast " .. proftype)
- GameTooltip:Show()
- local button = self.ProspectButton
- if not button then
- button = CreateItemButtonOverlay(self)
- self.ProspectButton = button
- end
- button.proftype = proftype
- button:Show()
- end
- end
- end)
Add Comment
Please, Sign In to add comment