diff --git a/modules/questitem.lua b/modules/questitem.lua index cd0ffb3f..713387c9 100644 --- a/modules/questitem.lua +++ b/modules/questitem.lua @@ -74,40 +74,36 @@ pfUI:RegisterModule("questitem", function () frame:Show() end - pfUI.questitem = CreateFrame("Frame", "pfQuestItemScanner", UIParent) - pfUI.questitem:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.questitem:RegisterEvent("QUEST_LOG_UPDATE") - pfUI.questitem:RegisterEvent("QUEST_ACCEPTED") - pfUI.questitem:RegisterEvent("QUEST_REMOVED") - pfUI.questitem:SetScript("OnEvent", function() + -- Seed half a second after the last trigger; each trigger pushes it back. + local seeding, timer + local function QueueSeed() if C.tooltip.questitem.showquest ~= "1" then return end - if event == "QUEST_ACCEPTED" then -- arg1 = logIndex, arg2 = questID - if not AddQuest(arg2) then -- cache cold (rare) -> reseed - this.seeding = true - this.run = GetTime() + .5 - end - elseif event == "QUEST_REMOVED" then -- arg1 = questID - RemoveQuest(arg1) - elseif event == "PLAYER_ENTERING_WORLD" then - this.seeding = true -- seed pre-existing quests - this.run = GetTime() + .5 - elseif event == "QUEST_LOG_UPDATE" and this.seeding then - this.run = GetTime() + .5 -- keep retrying while cache warms - end - end) - - pfUI.questitem:SetScript("OnUpdate", function() - if not this.run or GetTime() < this.run then return end - this.run = nil - if Seed() then this.seeding = nil end - end) - - pfUI.questitem.UpdateConfig = function() - if C.tooltip.questitem.showquest ~= "1" then return end - pfUI.questitem.seeding = true - pfUI.questitem.run = GetTime() + .5 + seeding = true + if timer then timer:Cancel() end + timer = C_Timer.NewTimer(.5, function() + if Seed() then seeding = nil end + end) end + -- seed pre-existing quests + pfUI.events:RegisterFrameEventAndCallback("PLAYER_ENTERING_WORLD", QueueSeed) + + -- keep retrying while the quest cache warms + pfUI.events:RegisterFrameEventAndCallback("QUEST_LOG_UPDATE", function() + if seeding then QueueSeed() end + end) + + -- a cold cache (rare) needs a full reseed + pfUI.events:RegisterFrameEventAndCallback("QUEST_ACCEPTED", function(_, _, questID) + if not AddQuest(questID) then QueueSeed() end + end) + + pfUI.events:RegisterFrameEventAndCallback("QUEST_REMOVED", function(_, questID) + RemoveQuest(questID) + end) + + pfUI.questitem = { UpdateConfig = QueueSeed } + pfUI.questitem.tooltip = CreateFrame("Frame", "pfQuestItems", GameTooltip) pfUI.questitem.tooltip:SetScript("OnShow", function() if GameTooltip:HasItem() then diff --git a/modules/raid.lua b/modules/raid.lua index e184233a..c0824970 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -117,7 +117,7 @@ pfUI:RegisterModule("raid", function () self:LayoutPets() - self:Show() + self:QueueUpdate(0) end function pfUI.uf.raid:LayoutPets() @@ -177,6 +177,12 @@ pfUI:RegisterModule("raid", function () end end + -- run UpdateRoster after delay; a newer request replaces a pending one + function pfUI.uf.raid:QueueUpdate(delay) + if self.timer then self.timer:Cancel() end + self.timer = C_Timer.NewTimer(delay, function() self:UpdateRoster() end) + end + pfUI.uf.raid:UpdateConfig() local function SetRaidIndex(frame, id) @@ -205,7 +211,6 @@ pfUI:RegisterModule("raid", function () end end - pfUI.uf.raid:Hide() pfUI.uf.raid:RegisterEvent("RAID_ROSTER_UPDATE") pfUI.uf.raid:RegisterEvent("PARTY_MEMBERS_CHANGED") pfUI.uf.raid:RegisterEvent("PARTY_LEADER_CHANGED") @@ -218,23 +223,15 @@ pfUI:RegisterModule("raid", function () end return end - this:Show() -- Debounce: delay update by 0.5s to batch rapid roster changes (mass swaps) - this.pendingUpdate = GetTime() + 0.5 + this:QueueUpdate(.5) end) - pfUI.uf.raid:SetScript("OnUpdate", function() - -- Wait for debounce: don't update until 0.5s after last event - if this.pendingUpdate and GetTime() < this.pendingUpdate then return end - -- Throttle raid roster updates to 1 FPS max - if (this.tick or 0) > GetTime() then return end - this.tick = GetTime() + 1.0 - this.pendingUpdate = nil + function pfUI.uf.raid:UpdateRoster() -- Without a raid there is nothing to sort, but a party shown as a raid -- grid still needs its pet frames placed and mapped to the party pets. if not IsInRaid() then - this:LayoutPets() - this:Hide() + self:LayoutPets() return end @@ -257,7 +254,7 @@ pfUI:RegisterModule("raid", function () end end - this:LayoutPets() + self:LayoutPets() -- Smart GUID-based updates: only refresh frames where unit changed if pfUI.uf.guidTracker then @@ -284,9 +281,7 @@ pfUI:RegisterModule("raid", function () if pfUI.uf.RebuildUnitmap then pfUI.uf.RebuildUnitmap() end - - this:Hide() - end) + end -- raid popup option to toggle tank role for _, menu in pairs({"RAID", "PARTY"}) do @@ -305,7 +300,7 @@ pfUI:RegisterModule("raid", function () if button and pfUI.uf.raid.tanksfirst[button] and name then pfUI.uf.raid.tankrole[name] = not pfUI.uf.raid.tankrole[name] - pfUI.uf.raid:Show() + pfUI.uf.raid:QueueUpdate(0) end end) end) \ No newline at end of file