From adc76b9a8778868f3e3510b1ab7153ef1593d4d6 Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 10 Nov 2026 13:41:17 +0000 Subject: [PATCH] DungeonPreQuest: move log mark after the title Co-Authored-By: Claude Opus 5.5 --- DungeonPreQuest/DungeonPreQuest.lua | 17 ++++++++++++++--- tests/test_dpq.lua | 21 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/DungeonPreQuest/DungeonPreQuest.lua b/DungeonPreQuest/DungeonPreQuest.lua index 3aaef42..958e43f 100644 --- a/DungeonPreQuest/DungeonPreQuest.lua +++ b/DungeonPreQuest/DungeonPreQuest.lua @@ -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 diff --git a/tests/test_dpq.lua b/tests/test_dpq.lua index c48ef84..dcc548b 100644 --- a/tests/test_dpq.lua +++ b/tests/test_dpq.lua @@ -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()