Skip to content

Commit 8e931e3

Browse files
committed
Properly ignore in progress quests on quest frames
1 parent ec72dad commit 8e931e3

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

main.lua

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function DialogKey:OnInitialize()
5555
self:InitGlowFrame()
5656

5757
self:RegisterEvent("QUEST_GREETING")
58+
self:RegisterEvent("QUEST_LOG_UPDATE")
5859
self:RegisterEvent("QUEST_COMPLETE")
5960
self:RegisterEvent("PLAYER_REGEN_DISABLED")
6061
self:RegisterEvent("ADDON_LOADED")
@@ -96,6 +97,10 @@ function DialogKey:QUEST_GREETING()
9697
RunNextFrame(function() self:EnumerateGossips() end)
9798
end
9899

100+
function DialogKey:QUEST_LOG_UPDATE()
101+
RunNextFrame(function() self:EnumerateGossips() end)
102+
end
103+
99104
function DialogKey:PLAYER_REGEN_DISABLED()
100105
-- Disable DialogKey fully upon entering combat
101106
self.frame:SetPropagateKeyboardInput(true)
@@ -503,18 +508,34 @@ end
503508
function DialogKey:EnumerateGossips()
504509
if not QuestFrameGreetingPanel:IsVisible() then return end
505510

511+
local checkQuestsToHandle = false
512+
local questsToHandle = {}
513+
514+
if self.db.ignoreInProgressQuests then
515+
checkQuestsToHandle = true
516+
local numActiveQuests = GetNumActiveQuests()
517+
local numAvailableQuests = GetNumAvailableQuests()
518+
for i = 1, numActiveQuests do
519+
local _, isComplete = GetActiveTitle(i)
520+
questsToHandle[i] = isComplete
521+
end
522+
for i = (numActiveQuests + 1), (numActiveQuests + numAvailableQuests) do
523+
questsToHandle[i] = true
524+
end
525+
end
526+
506527
self.frames = {}
507528
if QuestFrameGreetingPanel and QuestFrameGreetingPanel.titleButtonPool then
508529
--- @type FramePool<Button, QuestTitleButtonTemplate>
509-
local pool = QuestFrameGreetingPanel.titleButtonPool;
530+
local pool = QuestFrameGreetingPanel.titleButtonPool
510531
for tab in (pool:EnumerateActive()) do
511532
if tab:GetObjectType() == "Button" then
512533
table.insert(self.frames, tab)
513534
end
514535
end
515536
elseif QuestFrameGreetingPanel and not QuestFrameGreetingPanel.titleButtonPool then
516537
--- @type ScriptRegion[]
517-
local children = { QuestGreetingScrollChildFrame:GetChildren() };
538+
local children = { QuestGreetingScrollChildFrame:GetChildren() }
518539
for _, child in ipairs(children) do
519540
if child:GetObjectType() == "Button" and child:IsVisible() then
520541
table.insert(self.frames, child)
@@ -533,12 +554,16 @@ function DialogKey:EnumerateGossips()
533554
end)
534555

535556
if self.db.numKeysForGossip then
557+
local n = 1
536558
for i, frame in ipairs(self.frames) do
537-
if i > 10 then break end
538-
frame:SetText((i % 10) .. ". " .. frame:GetText())
559+
if not checkQuestsToHandle or questsToHandle[i] then
560+
if n > 10 then break end
561+
frame:SetText((n % 10) .. ". " .. frame:GetText())
539562

540-
-- Make the button taller if the text inside is wrapped to multiple lines
541-
frame:SetHeight(frame:GetFontString():GetHeight() + 2)
563+
-- Make the button taller if the text inside is wrapped to multiple lines
564+
frame:SetHeight(frame:GetFontString():GetHeight() + 2)
565+
n = n + 1
566+
end
542567
end
543568
end
544569
end

0 commit comments

Comments
 (0)