Skip to content

Commit 4e7d3d9

Browse files
committed
Fixed an issue with number keys on gossip frames (fixes #2)
1 parent 59c1c31 commit 4e7d3d9

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

main.lua

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,8 @@ function DialogKey:QUEST_COMPLETE()
9393
self.itemChoice = (GetNumQuestChoices() > 1 and -1 or 1)
9494
end
9595

96-
function DialogKey:GOSSIP_SHOW()
97-
RunNextFrame(function() self:EnumerateGossips(true) end)
98-
end
99-
10096
function DialogKey:QUEST_GREETING()
101-
RunNextFrame(function() self:EnumerateGossips(false) end)
97+
RunNextFrame(function() self:EnumerateGossips() end)
10298
end
10399

104100
function DialogKey:PLAYER_REGEN_DISABLED()
@@ -175,12 +171,11 @@ function DialogKey:OnPlayerChoiceHide()
175171
self.playerChoiceButtons = {}
176172
end
177173

178-
-- Prefix list of GossipFrame options with 1., 2., 3. etc.
179174
--- @param gossipFrame GossipFrame
180175
function DialogKey:OnGossipFrameUpdate(gossipFrame)
181-
if not self.db.numKeysForGossip then return end
182176
local scrollbox = gossipFrame.GreetingPanel.ScrollBox
183177

178+
self.frames = {};
184179
local n = 1
185180
for _, frame in scrollbox:EnumerateFrames() do
186181
local data = frame.GetElementData and frame:GetElementData()
@@ -193,8 +188,11 @@ function DialogKey:OnGossipFrameUpdate(gossipFrame)
193188
tag = "title"
194189
end
195190
if tag then
196-
frame:SetText((n % 10) .. ". " .. data.info[tag])
197-
frame:SetHeight(frame:GetFontString():GetHeight() + 2)
191+
if self.db.numKeysForGossip then
192+
frame:SetText((n % 10) .. ". " .. data.info[tag])
193+
frame:SetHeight(frame:GetFontString():GetHeight() + 2)
194+
end
195+
self.frames[n] = frame
198196
n = n + 1
199197
end
200198
if n > 10 then break end
@@ -501,34 +499,30 @@ function DialogKey:SelectItemReward()
501499
end
502500
end
503501

504-
-- Prefix list of QuestGreetingFrame(!!) options with 1., 2., 3. etc.
502+
-- Prefix list of QuestGreetingFrame options with 1., 2., 3. etc.
505503
-- Also builds DialogKey.frames, used to click said options
506-
function DialogKey:EnumerateGossips(isGossipFrame)
507-
if not ( QuestFrameGreetingPanel:IsVisible() or GossipFrame.GreetingPanel:IsVisible() ) then return end
504+
function DialogKey:EnumerateGossips()
505+
if not QuestFrameGreetingPanel:IsVisible() then return end
508506

509507
self.frames = {}
510-
if isGossipFrame then
511-
for _, child in pairs{ GossipFrame.GreetingPanel.ScrollBox.ScrollTarget:GetChildren() } do
508+
if QuestFrameGreetingPanel and QuestFrameGreetingPanel.titleButtonPool then
509+
--- @type FramePool<Button, QuestTitleButtonTemplate>
510+
local pool = QuestFrameGreetingPanel.titleButtonPool;
511+
for tab in (pool.EnumerateActive()) do
512+
if tab:GetObjectType() == "Button" then
513+
table.insert(self.frames, tab)
514+
end
515+
end
516+
elseif QuestFrameGreetingPanel and not QuestFrameGreetingPanel.titleButtonPool then
517+
--- @type ScriptRegion[]
518+
local children = { QuestGreetingScrollChildFrame:GetChildren() };
519+
for _, child in ipairs(children) do
512520
if child:GetObjectType() == "Button" and child:IsVisible() then
513521
table.insert(self.frames, child)
514522
end
515523
end
516524
else
517-
if QuestFrameGreetingPanel and QuestFrameGreetingPanel.titleButtonPool then
518-
for tab in QuestFrameGreetingPanel.titleButtonPool:EnumerateActive() do
519-
if tab:GetObjectType() == "Button" then
520-
table.insert(self.frames, tab)
521-
end
522-
end
523-
elseif QuestFrameGreetingPanel and not QuestFrameGreetingPanel.titleButtonPool then
524-
for _, child in ipairs({ QuestGreetingScrollChildFrame:GetChildren() }) do
525-
if child:GetObjectType() == "Button" and child:IsVisible() then
526-
table.insert(self.frames, child)
527-
end
528-
end
529-
else
530-
return
531-
end
525+
return
532526
end
533527

534528
table.sort(self.frames, function(a,b)
@@ -539,7 +533,7 @@ function DialogKey:EnumerateGossips(isGossipFrame)
539533
end
540534
end)
541535

542-
if self.db.numKeysForGossip and not isGossipFrame then
536+
if self.db.numKeysForGossip then
543537
for i, frame in ipairs(self.frames) do
544538
if i > 10 then break end
545539
frame:SetText((i % 10) .. ". " .. frame:GetText())

0 commit comments

Comments
 (0)