DungeonPreQuest: mark dungeon quests too, refresh QuestieDB data
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9d30c8fed8
commit
01a351a865
10 changed files with 628 additions and 70 deletions
|
|
@ -1,11 +1,12 @@
|
|||
-- Dungeon Pre-Quest: marks quests whose chain leads to a dungeon quest, in the
|
||||
-- quest log and on the quest offer window. The client has no chain data, so
|
||||
-- Dungeon Pre-Quest: marks dungeon quests and quests whose chain leads to one,
|
||||
-- in the quest log and on the quest offer window. The client has no chain data, so
|
||||
-- Data.lua is generated ahead of time.
|
||||
|
||||
local _, ns = ...
|
||||
|
||||
local COLOR = "|cffffd100"
|
||||
local LABEL = "Dungeon pre-quest"
|
||||
local DUNGEON_LABEL = "Dungeon quest"
|
||||
local ROW_MARK = "|cffc77dff[D]|r"
|
||||
local ROW_MARK_GAP = 5
|
||||
|
||||
|
|
@ -13,10 +14,10 @@ local function HasClass(mask, classID)
|
|||
return mask == 0 or math.floor(mask / 2 ^ (classID - 1)) % 2 == 1
|
||||
end
|
||||
|
||||
-- Dungeon names this quest leads to for this character, or nil if none.
|
||||
-- An empty list means a dungeon quest whose dungeon isn't known.
|
||||
local function DungeonsFor(questID)
|
||||
local row = questID and ns.quests[questID]
|
||||
-- Dungeon names from one of the generated tables that apply to this
|
||||
-- character, or nil if none. An empty list means a dungeon that isn't known.
|
||||
local function Match(tbl, questID)
|
||||
local row = questID and tbl and tbl[questID]
|
||||
if not row then
|
||||
return nil
|
||||
end
|
||||
|
|
@ -43,19 +44,28 @@ local function DungeonsFor(questID)
|
|||
return matched and names or nil
|
||||
end
|
||||
|
||||
local function Describe(names)
|
||||
local function Label(label, names)
|
||||
if #names == 0 then
|
||||
return LABEL
|
||||
return label
|
||||
end
|
||||
return LABEL .. ": " .. table.concat(names, ", ")
|
||||
return label .. ": " .. table.concat(names, ", ")
|
||||
end
|
||||
|
||||
-- What to say about a quest for this character, or nil if it isn't one of
|
||||
-- ours: a quest done inside a dungeon, a step towards one, or both.
|
||||
local function Describe(questID)
|
||||
local own = Match(ns.dungeonQuests, questID)
|
||||
local leads = Match(ns.quests, questID)
|
||||
if own and leads then
|
||||
return Label(DUNGEON_LABEL, own) .. "\n" .. Label(LABEL, leads)
|
||||
end
|
||||
return own and Label(DUNGEON_LABEL, own) or leads and Label(LABEL, leads) or nil
|
||||
end
|
||||
|
||||
ns.DungeonsFor = DungeonsFor
|
||||
ns.Describe = Describe
|
||||
|
||||
local function MarkRow(button)
|
||||
local names = DungeonsFor(button.questID)
|
||||
if not names then
|
||||
if not Describe(button.questID) then
|
||||
if button.dpqMark then
|
||||
button.dpqMark:Hide()
|
||||
end
|
||||
|
|
@ -88,7 +98,7 @@ end
|
|||
local LIST_MARK = "|cff8a2be2[D]|r "
|
||||
|
||||
local function MarkListButton(button, questID)
|
||||
if not DungeonsFor(questID) then
|
||||
if not Describe(questID) then
|
||||
return false
|
||||
end
|
||||
local text = button:GetText()
|
||||
|
|
@ -116,9 +126,9 @@ local function UpdateBanner()
|
|||
if not banner then
|
||||
return
|
||||
end
|
||||
local names = DungeonsFor(GetQuestID())
|
||||
if names then
|
||||
banner:SetText(COLOR .. Describe(names) .. "|r")
|
||||
local text = Describe(GetQuestID())
|
||||
if text then
|
||||
banner:SetText(COLOR .. text .. "|r")
|
||||
banner:Show()
|
||||
else
|
||||
banner:Hide()
|
||||
|
|
@ -129,9 +139,9 @@ local function Setup()
|
|||
hooksecurefunc("QuestLogQuests_Update", UpdateRows)
|
||||
|
||||
EventRegistry:RegisterCallback("QuestMapLogTitleButton.OnEnter", function(_, button, questID)
|
||||
local names = DungeonsFor(questID or (button and button.questID))
|
||||
if names then
|
||||
GameTooltip:AddLine(Describe(names), 1, 0.82, 0, true)
|
||||
local text = Describe(questID or (button and button.questID))
|
||||
if text then
|
||||
GameTooltip:AddLine(text, 1, 0.82, 0, true)
|
||||
GameTooltip:Show()
|
||||
end
|
||||
end, ns)
|
||||
|
|
@ -170,6 +180,6 @@ end)
|
|||
SLASH_DUNGEONPREQUEST1 = "/dpq"
|
||||
SlashCmdList.DUNGEONPREQUEST = function(text)
|
||||
local id = tonumber(text)
|
||||
local names = DungeonsFor(id)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(COLOR .. "DungeonPreQuest:|r " .. (id and (names and Describe(names) or "not a pre-quest for you") or "usage: /dpq questID"))
|
||||
local text = Describe(id)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(COLOR .. "DungeonPreQuest:|r " .. (id and (text or "not a dungeon quest for you") or "usage: /dpq questID"))
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue