DungeonPreQuest: move log mark after the title
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ddb05c7d52
commit
adc76b9a87
2 changed files with 33 additions and 5 deletions
|
|
@ -6,6 +6,8 @@ local _, ns = ...
|
|||
|
||||
local COLOR = "|cffffd100"
|
||||
local LABEL = "Dungeon pre-quest"
|
||||
local ROW_MARK = "|cffc77dff[D]|r"
|
||||
local ROW_MARK_GAP = 5
|
||||
|
||||
local function HasClass(mask, classID)
|
||||
return mask == 0 or math.floor(mask / 2 ^ (classID - 1)) % 2 == 1
|
||||
|
|
@ -60,10 +62,19 @@ local function MarkRow(button)
|
|||
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")
|
||||
button.dpqMark = button:CreateFontString(nil, "ARTWORK", "GameFontNormalLeft")
|
||||
button.dpqMark:SetText(ROW_MARK)
|
||||
end
|
||||
|
||||
-- Follows the title rather than sitting in the left gutter, which belongs
|
||||
-- to the map icons. A wrapped title reports its unwrapped length.
|
||||
local offset = button.Text:GetStringWidth()
|
||||
local boxWidth = button.Text:GetWidth()
|
||||
if boxWidth > 0 then
|
||||
offset = math.min(offset, boxWidth)
|
||||
end
|
||||
button.dpqMark:ClearAllPoints()
|
||||
button.dpqMark:SetPoint("TOPLEFT", button.Text, "TOPLEFT", offset + ROW_MARK_GAP, 0)
|
||||
button.dpqMark:Show()
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -47,13 +47,18 @@ local function region()
|
|||
local r = { shown = false }
|
||||
function r:Show() self.shown = true end
|
||||
function r:Hide() self.shown = false end
|
||||
function r:SetPoint() end
|
||||
function r:SetPoint(...) self.point = { ... } end
|
||||
function r:ClearAllPoints() self.point = nil end
|
||||
function r:SetText(t) self.text = t end
|
||||
return r
|
||||
end
|
||||
|
||||
local function button(id)
|
||||
local b = { questID = id, creates = 0 }
|
||||
local b = { questID = id, creates = 0, textWidth = 120, boxWidth = 230 }
|
||||
b.Text = {
|
||||
GetStringWidth = function() return b.textWidth end,
|
||||
GetWidth = function() return b.boxWidth end,
|
||||
}
|
||||
function b:CreateFontString() self.creates = self.creates + 1; return region() end
|
||||
return b
|
||||
end
|
||||
|
|
@ -144,6 +149,18 @@ rows = { a, b }
|
|||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark and a.dpqMark.shown and a.dpqMark.text:find("D", 1, true), "pre-quest row is marked")
|
||||
check(b.dpqMark == nil, "other row stays unmarked")
|
||||
check(a.dpqMark.text == "|cffc77dff[D]|r", "row uses the [D] tag: " .. tostring(a.dpqMark.text))
|
||||
check(a.dpqMark.point[2] == a.Text and a.dpqMark.point[4] == 125, "mark sits just after the title: " .. tostring(a.dpqMark.point[4]))
|
||||
|
||||
a.textWidth = 400
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark.point[4] == 235, "long title keeps the mark at the end of the title box")
|
||||
a.boxWidth = 0
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark.point[4] == 405, "unresolved title box falls back to the text width")
|
||||
a.textWidth, a.boxWidth = 80, 230
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark.point[4] == 85, "reused row follows its new title")
|
||||
|
||||
a.questID = 99
|
||||
hooks.QuestLogQuests_Update()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue