DungeonPreQuest: mark NPC quest lists
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
801608e066
commit
d873b7f6fa
3 changed files with 102 additions and 2 deletions
|
|
@ -9,7 +9,39 @@ local callback
|
|||
EventRegistry = { RegisterCallback = function(_, _, fn) callback = fn end }
|
||||
|
||||
local hooks = {}
|
||||
function hooksecurefunc(name, fn) hooks[name] = fn end
|
||||
function hooksecurefunc(a, b, c)
|
||||
if c then
|
||||
local original = a[b]
|
||||
a[b] = function(...) original(...); c(...) end
|
||||
else
|
||||
hooks[a] = b
|
||||
end
|
||||
end
|
||||
|
||||
GossipAvailableQuestButtonMixin = { Setup = function(self, info) self.text = info.title; self.setups = (self.setups or 0) + 1 end }
|
||||
|
||||
local function listButton(id, isActive)
|
||||
local b = { id = id, isActive = isActive, heightSets = 0, resizes = 0, Icon = { GetHeight = function() return 16 end } }
|
||||
function b:GetID() return self.id end
|
||||
function b:GetText() return self.text end
|
||||
function b:SetText(t) self.text = t end
|
||||
function b:GetTextHeight() return 12 end
|
||||
function b:SetHeight() self.heightSets = self.heightSets + 1 end
|
||||
function b:Resize() self.resizes = self.resizes + 1 end
|
||||
return b
|
||||
end
|
||||
|
||||
local greetingRows = {}
|
||||
local greetingShow
|
||||
QuestFrameGreetingPanel = {
|
||||
titleButtonPool = { EnumerateActive = function()
|
||||
local i = 0
|
||||
return function() i = i + 1; return greetingRows[i] end
|
||||
end },
|
||||
HookScript = function(_, _, fn) greetingShow = fn end,
|
||||
}
|
||||
local availableByIndex = {}
|
||||
function GetAvailableQuestInfo(i) return false, 0, false, false, availableByIndex[i] end
|
||||
|
||||
local function region()
|
||||
local r = { shown = false }
|
||||
|
|
@ -129,6 +161,36 @@ check(registered.QUEST_DETAIL, "listens for a new quest being offered")
|
|||
onEvent()
|
||||
check(banner.shown == false, "next offer clears the banner")
|
||||
|
||||
-- NPC quest lists.
|
||||
local MARK = "|cff8a2be2[D]|r "
|
||||
local gossip = listButton()
|
||||
GossipAvailableQuestButtonMixin.Setup(gossip, { questID = 65, title = "Pre Quest" })
|
||||
check(gossip.text == MARK .. "Pre Quest", "gossip row is marked: " .. tostring(gossip.text))
|
||||
check(gossip.resizes == 1, "gossip row is resized for the longer text")
|
||||
GossipAvailableQuestButtonMixin.Setup(gossip, { questID = 99, title = "Other" })
|
||||
check(gossip.text == "Other", "reused gossip row has no mark")
|
||||
GossipAvailableQuestButtonMixin.Setup(gossip, { questID = 65, title = "Pre Quest" })
|
||||
check(gossip.resizes == 2 and gossip.text == MARK .. "Pre Quest", "setup again marks once")
|
||||
|
||||
local avail, plain, turnin = listButton(1, 0), listButton(2, 0), listButton(1, 1)
|
||||
avail.text, plain.text, turnin.text = "Offer", "Plain", "Turn in"
|
||||
availableByIndex = { 65, 99 }
|
||||
greetingRows = { avail, plain, turnin }
|
||||
greetingShow()
|
||||
check(avail.text == MARK .. "Offer" and avail.heightSets == 1, "greeting offer is marked and resized")
|
||||
check(plain.text == "Plain", "other greeting offer is not")
|
||||
check(turnin.text == "Turn in", "quests already in progress are not marked")
|
||||
hooks.QuestFrameGreetingPanel_OnShow()
|
||||
check(avail.text == MARK .. "Offer" and avail.heightSets == 1, "both greeting hooks mark only once")
|
||||
|
||||
classID = 2
|
||||
availableByIndex = { 72 }
|
||||
avail.text = "Druid only"
|
||||
greetingRows = { avail }
|
||||
greetingShow()
|
||||
check(avail.text == "Druid only", "list respects class")
|
||||
classID = 1
|
||||
|
||||
printed = {}
|
||||
SlashCmdList.DUNGEONPREQUEST("65")
|
||||
check(printed[1]:find("The Deadmines", 1, true), "/dpq describes a quest")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue