DungeonPreQuest: keep markers off the player arrow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-10 13:31:40 +00:00
parent ef6cb6ab60
commit 8b65cab742
2 changed files with 54 additions and 3 deletions

View file

@ -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()

View file

@ -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()