From 8b65cab742d8e7289931e2352cdd005d2b16eaa1 Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 10 Nov 2026 13:31:40 +0000 Subject: [PATCH] DungeonPreQuest: keep markers off the player arrow Co-Authored-By: Claude Opus 5.5 --- DungeonPreQuest/Minimap.lua | 25 +++++++++++++++++++++++++ tests/test_dpq_minimap.lua | 32 +++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/DungeonPreQuest/Minimap.lua b/DungeonPreQuest/Minimap.lua index 5f3eeca..f91c0d2 100644 --- a/DungeonPreQuest/Minimap.lua +++ b/DungeonPreQuest/Minimap.lua @@ -9,6 +9,8 @@ local Pins = LibStub("HereBeDragonsQuestie-Pins-2.0") local ICON = "Interface\\GossipFrame\\AvailableQuestIcon" local PIN_SIZE = 14 local REFRESH_DELAY = 1 +local PLAYER_CLEARANCE = 14 +local OVERLAP_INTERVAL = 0.1 local active, free = {}, {} @@ -122,6 +124,29 @@ local function Refresh() end end +-- The player arrow is drawn by the minimap itself, below anything an addon can +-- add to it, so markers step aside instead. Alpha rather than Hide, because the +-- pin library shows its pins again on every update. +local function UpdateOverlap() + local centerX, centerY = Minimap:GetCenter() + if not centerX then + return + end + for _, pin in ipairs(active) do + if pin:IsShown() then + local x, y = pin:GetCenter() + local overlapping = x ~= nil and (x - centerX) ^ 2 + (y - centerY) ^ 2 < PLAYER_CLEARANCE ^ 2 + if overlapping ~= pin.overlapping then + pin.overlapping = overlapping + pin:SetAlpha(overlapping and 0 or 1) + pin:EnableMouse(not overlapping) + end + end + end +end + +C_Timer.NewTicker(OVERLAP_INTERVAL, UpdateOverlap) + -- Turning a quest in reports several events, and completion lags slightly behind. local queued = false local function QueueRefresh() diff --git a/tests/test_dpq_minimap.lua b/tests/test_dpq_minimap.lua index e7b769d..4b45998 100644 --- a/tests/test_dpq_minimap.lua +++ b/tests/test_dpq_minimap.lua @@ -26,7 +26,11 @@ function LibStub(name) end local timers = {} -C_Timer = { After = function(_, fn) timers[#timers + 1] = fn end } +local overlapTick +C_Timer = { + After = function(_, fn) timers[#timers + 1] = fn end, + NewTicker = function(_, fn) overlapTick = fn end, +} local function flush() local list = timers timers = {} @@ -44,7 +48,7 @@ local function texture() end local onEvent, registered = nil, {} -Minimap = { GetFrameLevel = function() return 1 end } +Minimap = { GetFrameLevel = function() return 1 end, GetCenter = function() return 100, 100 end } CreateFrame = function(kind) if kind == "Frame" and not onEvent and created == 0 and not registered.frame then registered.frame = true @@ -59,7 +63,10 @@ CreateFrame = function(kind) function f:SetSize() end function f:SetFrameLevel() end function f:CreateTexture() self.tex = texture(); return self.tex end - function f:EnableMouse() end + function f:EnableMouse(v) self.mouse = v end + function f:SetAlpha(a) self.alpha = a end + function f:IsShown() return self.visible ~= false end + function f:GetCenter() return self.cx, self.cy end function f:SetScript(name, fn) self.scripts[name] = fn end return f end @@ -163,6 +170,25 @@ check(tip.title == "The Day After" and tip.line == "Dungeon pre-quest: The Deadm pin.scripts.OnLeave(pin) check(tip.hidden, "tooltip hides on leave") +-- The player arrow stays visible. +pin.cx, pin.cy = 105, 103 +overlapTick() +check(pin.alpha == 0 and pin.mouse == false, "marker over the player arrow steps aside") +pin.cx, pin.cy = 150, 150 +overlapTick() +check(pin.alpha == 1 and pin.mouse == true, "marker returns once clear of the arrow") +pin.cx, pin.cy = 115, 100 +overlapTick() +check(pin.alpha == 1, "marker just beyond the arrow stays visible") +pin.cx, pin.cy = 100, 100 +pin.visible = false +overlapTick() +check(pin.alpha == 1, "out-of-range markers are skipped") +pin.visible = nil +pin.cx, pin.cy = nil, nil +overlapTick() +check(pin.alpha == 1, "marker with no position yet is left alone") + -- Pooling and batching. local before = created count()