From dc38566ae67b2395f96b8a1b34f9114fece347fd Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Wed, 26 Aug 2026 09:31:51 +0200 Subject: [PATCH] Sleep loot cursor updates between changes --- mods/loot-cursor.lua | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/mods/loot-cursor.lua b/mods/loot-cursor.lua index 1d034e6..f4e2bee 100644 --- a/mods/loot-cursor.lua +++ b/mods/loot-cursor.lua @@ -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