mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-02 00:46:57 +00:00
Run the raid and questitem delay timers on C_Timer
Both modules waited out their delays in an OnUpdate script. Each now keeps one C_Timer.NewTimer handle and cancels it whenever a new request comes in, so the update runs 0.5 s after the last one. Raid: the roster pass becomes pfUI.uf.raid:UpdateRoster, and pfUI.uf.raid:QueueUpdate schedules it. Roster events queue it with a 0.5 s delay; a config change or a tank toggle queues it for the next frame. The frame no longer shows and hides itself to run the pass, and the extra 1 s throttle is gone because the debounce already merges bursts. Questitem: without the OnUpdate script the scanner frame only handled events, so it moves onto pfUI.events with one callback per event, and pfUI.questitem becomes a plain table. The showquest check now lives in QueueSeed.
This commit is contained in:
+27
-31
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user