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
|
|
@ -70,6 +70,32 @@ local function UpdateRows()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Purple, because the gold used elsewhere is hard to read on parchment.
|
||||||
|
local LIST_MARK = "|cff8a2be2[D]|r "
|
||||||
|
|
||||||
|
local function MarkListButton(button, questID)
|
||||||
|
if not DungeonsFor(questID) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local text = button:GetText()
|
||||||
|
if not text or text:find(LIST_MARK, 1, true) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
button:SetText(LIST_MARK .. text)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function MarkGreetingList()
|
||||||
|
for button in QuestFrameGreetingPanel.titleButtonPool:EnumerateActive() do
|
||||||
|
if button.isActive == 0 then
|
||||||
|
local questID = select(5, GetAvailableQuestInfo(button:GetID()))
|
||||||
|
if MarkListButton(button, questID) then
|
||||||
|
button:SetHeight(math.max(button:GetTextHeight() + 2, button.Icon:GetHeight()))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local banner
|
local banner
|
||||||
|
|
||||||
local function UpdateBanner()
|
local function UpdateBanner()
|
||||||
|
|
@ -101,6 +127,18 @@ local function Setup()
|
||||||
banner = QuestFrameDetailPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
banner = QuestFrameDetailPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
||||||
banner:SetPoint("BOTTOM", QuestFrame, "TOP", 0, 6)
|
banner:SetPoint("BOTTOM", QuestFrame, "TOP", 0, 6)
|
||||||
QuestFrameDetailPanel:HookScript("OnShow", UpdateBanner)
|
QuestFrameDetailPanel:HookScript("OnShow", UpdateBanner)
|
||||||
|
|
||||||
|
-- Gossip buttons copy this mixin when they are first created, after login.
|
||||||
|
hooksecurefunc(GossipAvailableQuestButtonMixin, "Setup", function(button, questInfo)
|
||||||
|
if MarkListButton(button, questInfo and questInfo.questID) then
|
||||||
|
button:Resize()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Showing the panel runs Blizzard's XML-bound handler, while refreshing an
|
||||||
|
-- open panel calls the global by name, so both need covering.
|
||||||
|
QuestFrameGreetingPanel:HookScript("OnShow", MarkGreetingList)
|
||||||
|
hooksecurefunc("QuestFrameGreetingPanel_OnShow", MarkGreetingList)
|
||||||
end
|
end
|
||||||
|
|
||||||
local frame = CreateFrame("Frame")
|
local frame = CreateFrame("Frame")
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Four small quality-of-life addons for WoW Forever (client 1.60.1, Interface 1600
|
||||||
| Quest Item Tip | Item tooltips show the quest, its level and have / need. Warns when a quest item is no longer needed. | `/qit` |
|
| Quest Item Tip | Item tooltips show the quest, its level and have / need. Warns when a quest item is no longer needed. | `/qit` |
|
||||||
| Quest Craft Highlight | Highlights profession recipes whose crafted item an active quest needs. | `/qch` |
|
| Quest Craft Highlight | Highlights profession recipes whose crafted item an active quest needs. | `/qch` |
|
||||||
| Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` |
|
| Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` |
|
||||||
| Dungeon Pre-Quest | Marks quests whose chain leads to a dungeon quest, in the quest log and on the quest offer window. | `/dpq <questID>` |
|
| Dungeon Pre-Quest | Marks quests whose chain leads to a dungeon quest, in the quest log, NPC quest lists and the quest offer window. | `/dpq <questID>` |
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,39 @@ local callback
|
||||||
EventRegistry = { RegisterCallback = function(_, _, fn) callback = fn end }
|
EventRegistry = { RegisterCallback = function(_, _, fn) callback = fn end }
|
||||||
|
|
||||||
local hooks = {}
|
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 function region()
|
||||||
local r = { shown = false }
|
local r = { shown = false }
|
||||||
|
|
@ -129,6 +161,36 @@ check(registered.QUEST_DETAIL, "listens for a new quest being offered")
|
||||||
onEvent()
|
onEvent()
|
||||||
check(banner.shown == false, "next offer clears the banner")
|
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 = {}
|
printed = {}
|
||||||
SlashCmdList.DUNGEONPREQUEST("65")
|
SlashCmdList.DUNGEONPREQUEST("65")
|
||||||
check(printed[1]:find("The Deadmines", 1, true), "/dpq describes a quest")
|
check(printed[1]:find("The Deadmines", 1, true), "/dpq describes a quest")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue