Sleep loot cursor updates between changes
This commit is contained in:
+34
-8
@@ -12,27 +12,53 @@ local module = ShaguTweaks:register({
|
||||
|
||||
module.enable = function(self)
|
||||
local loot = CreateFrame("Frame", "ShaguTweaksLoot", LootFrame)
|
||||
local buttons = {}
|
||||
|
||||
for i = 1, LOOTFRAME_NUMBUTTONS do
|
||||
buttons[i] = getglobal("LootButton"..i)
|
||||
end
|
||||
|
||||
loot:RegisterEvent("LOOT_OPENED")
|
||||
loot:RegisterEvent("LOOT_SLOT_CLEARED")
|
||||
loot:RegisterEvent("LOOT_CLOSED")
|
||||
|
||||
loot:SetScript("OnEvent", function()
|
||||
if event == "LOOT_OPENED" then
|
||||
loot.last_button = nil
|
||||
loot:Show()
|
||||
elseif event == "LOOT_SLOT_CLEARED" then
|
||||
loot:Show()
|
||||
else
|
||||
loot:Hide()
|
||||
end
|
||||
end)
|
||||
|
||||
loot:SetScript("OnUpdate", function()
|
||||
if GetNumLootItems() == 0 then HideUIPanel(LootFrame) return end
|
||||
local x, y = GetCursorPosition()
|
||||
local s = LootFrame:GetEffectiveScale()
|
||||
x, y = x / s, y / s
|
||||
if GetNumLootItems() == 0 then
|
||||
loot:Hide()
|
||||
HideUIPanel(LootFrame)
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, LOOTFRAME_NUMBUTTONS do
|
||||
local button = getglobal("LootButton"..i)
|
||||
local button = buttons[i]
|
||||
if button:IsVisible() then
|
||||
if loot.last_button ~= button then
|
||||
local x, y = GetCursorPosition()
|
||||
local s = LootFrame:GetEffectiveScale()
|
||||
local button_offset = (i-1) * button:GetHeight()
|
||||
x, y = x / s, y / s
|
||||
LootFrame:ClearAllPoints()
|
||||
LootFrame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x - 40, y + 100 + button_offset)
|
||||
loot.last_button = button
|
||||
end
|
||||
loot:Hide()
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
loot:SetScript("OnShow", function()
|
||||
loot.last_button = nil
|
||||
end)
|
||||
-- Stay fully dormant between loot changes. If LootFrame has not populated
|
||||
-- its buttons yet, OnUpdate remains active until the first one appears.
|
||||
loot:Hide()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user