Implement tag alerts

This commit is contained in:
2025-01-09 12:18:04 +01:00
parent 32543d04a0
commit 176d184d91

View File

@@ -27,6 +27,7 @@ function shared.MinimapTagger.Init()
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
end
frame:Hide()
frame:SetSize(iconSize, iconSize)
frame:SetFrameStrata("HIGH")
frame:SetFrameLevel(100)
@@ -58,6 +59,7 @@ function shared.MinimapTagger.Init()
frame:Show()
end
---@type Frame[]
local alertFramePool = {}
local alertFramePoolMaxSize = 20
for i = 1, alertFramePoolMaxSize do
@@ -78,18 +80,51 @@ function shared.MinimapTagger.Init()
break
end
end
if not frame and #alertFramePool >= alertFramePoolMaxSize then
if not frame then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Alert frame pool is full, skipping", ModuleName))
print(string.format("[%s] Alert frame pool is full and could not get frame", ModuleName))
end
return
end
PlantFrame(x, y, frame)
end
---@type Frame[]
local tagFramePool = {}
local tagFramePoolMaxSize = 20
for i = 1, tagFramePoolMaxSize do
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame.custom = { busy = false }
local texture = frame:CreateTexture(nil, "ARTWORK")
texture:SetAllPoints(frame)
texture:SetTexture("Interface\\AddOns\\WeakAuras\\PowerAurasMedia\\Auras\\Aura11")
table.insert(tagFramePool, frame)
end
---@param x number
---@param y number
local function PlantTag(x, y)
local frame = nil
for _, tagFrame in ipairs(tagFramePool) do
if not tagFrame.custom.busy then
frame = tagFrame
break
end
end
if not frame then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Tag frame pool is full and could not get frame", ModuleName))
end
return
end
PlantFrame(x, y, frame)
end
local pauseUntil = 0
local frame = CreateFrame("Frame")
frame:RegisterEvent("WORLD_MAP_UPDATE")
frame:SetScript("OnEvent", function(self, event, addon)
if pauseUntil > GetTime() then return end
pauseUntil = GetTime() + 1
if not BattlefieldMinimap then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] BattlefieldMinimap not found", ModuleName))
@@ -113,21 +148,12 @@ function shared.MinimapTagger.Init()
BattlefieldMinimapBackground:Hide()
BattlefieldMinimapCloseButton:Hide()
BattlefieldMinimapCorner:Hide()
BattlefieldMinimap:HookScript("OnShow", function(self)
for i = 1, 10 do
local x = math.random()
local y = math.random()
PlantAlert(x * 100, y * 100)
end
end)
BattlefieldMinimap:HookScript("OnHide", function(self)
for _, alertFrame in ipairs(alertFramePool) do
alertFrame:Hide()
alertFrame.custom.busy = false
end
end)
BattlefieldMinimap:Hide()
BattlefieldMinimap:Show()
end)
print("[Heimdall] MinimapTagger loaded")