Initial addons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
de17b0006e
17 changed files with 3257 additions and 0 deletions
123
DungeonPreQuest/DungeonPreQuest.lua
Normal file
123
DungeonPreQuest/DungeonPreQuest.lua
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
-- 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
|
||||
-- Data.lua is generated ahead of time.
|
||||
|
||||
local _, ns = ...
|
||||
|
||||
local COLOR = "|cffffd100"
|
||||
local LABEL = "Dungeon pre-quest"
|
||||
|
||||
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]
|
||||
if not row then
|
||||
return nil
|
||||
end
|
||||
|
||||
local faction = UnitFactionGroup("player")
|
||||
local factionBit = faction == "Alliance" and 1 or faction == "Horde" and 2
|
||||
local classID = select(3, UnitClass("player"))
|
||||
if not factionBit or not classID then
|
||||
return nil
|
||||
end
|
||||
|
||||
local names, seen, matched = {}, {}, false
|
||||
for i = 1, #row, 3 do
|
||||
local dungeon, factions, classes = row[i], row[i + 1], row[i + 2]
|
||||
if (factions == 3 or factions == factionBit) and HasClass(classes, classID) then
|
||||
matched = true
|
||||
local name = ns.dungeons[dungeon]
|
||||
if name and not seen[name] then
|
||||
seen[name] = true
|
||||
names[#names + 1] = name
|
||||
end
|
||||
end
|
||||
end
|
||||
return matched and names or nil
|
||||
end
|
||||
|
||||
local function Describe(names)
|
||||
if #names == 0 then
|
||||
return LABEL
|
||||
end
|
||||
return LABEL .. ": " .. table.concat(names, ", ")
|
||||
end
|
||||
|
||||
local function MarkRow(button)
|
||||
local names = DungeonsFor(button.questID)
|
||||
if not names then
|
||||
if button.dpqMark then
|
||||
button.dpqMark:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if not button.dpqMark then
|
||||
button.dpqMark = button:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
|
||||
button.dpqMark:SetPoint("TOPLEFT", button, "TOPLEFT", 12, -9)
|
||||
button.dpqMark:SetText(COLOR .. "D|r")
|
||||
end
|
||||
button.dpqMark:Show()
|
||||
end
|
||||
|
||||
local function UpdateRows()
|
||||
for button in QuestScrollFrame.titleFramePool:EnumerateActive() do
|
||||
MarkRow(button)
|
||||
end
|
||||
end
|
||||
|
||||
local banner
|
||||
|
||||
local function UpdateBanner()
|
||||
if not banner then
|
||||
return
|
||||
end
|
||||
local names = DungeonsFor(GetQuestID())
|
||||
if names then
|
||||
banner:SetText(COLOR .. Describe(names) .. "|r")
|
||||
banner:Show()
|
||||
else
|
||||
banner:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
GameTooltip:Show()
|
||||
end
|
||||
end, ns)
|
||||
|
||||
-- Sits above the window, where it can't disturb Blizzard's layout. Parented
|
||||
-- to the detail panel so it goes away with that panel.
|
||||
banner = QuestFrameDetailPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
||||
banner:SetPoint("BOTTOM", QuestFrame, "TOP", 0, 6)
|
||||
QuestFrameDetailPanel:HookScript("OnShow", UpdateBanner)
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("PLAYER_LOGIN")
|
||||
frame:RegisterEvent("QUEST_DETAIL")
|
||||
frame:SetScript("OnEvent", function(_, event)
|
||||
if event == "PLAYER_LOGIN" then
|
||||
Setup()
|
||||
else
|
||||
UpdateBanner()
|
||||
end
|
||||
end)
|
||||
|
||||
-- /dpq 123 says what is known about a quest ID.
|
||||
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"))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue