Implement tag alerts
This commit is contained in:
@@ -27,6 +27,7 @@ function shared.MinimapTagger.Init()
|
|||||||
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
|
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
frame:Hide()
|
||||||
frame:SetSize(iconSize, iconSize)
|
frame:SetSize(iconSize, iconSize)
|
||||||
frame:SetFrameStrata("HIGH")
|
frame:SetFrameStrata("HIGH")
|
||||||
frame:SetFrameLevel(100)
|
frame:SetFrameLevel(100)
|
||||||
@@ -58,6 +59,7 @@ function shared.MinimapTagger.Init()
|
|||||||
frame:Show()
|
frame:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@type Frame[]
|
||||||
local alertFramePool = {}
|
local alertFramePool = {}
|
||||||
local alertFramePoolMaxSize = 20
|
local alertFramePoolMaxSize = 20
|
||||||
for i = 1, alertFramePoolMaxSize do
|
for i = 1, alertFramePoolMaxSize do
|
||||||
@@ -78,18 +80,51 @@ function shared.MinimapTagger.Init()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not frame and #alertFramePool >= alertFramePoolMaxSize then
|
if not frame then
|
||||||
if Heimdall_Data.config.minimapTagger.debug 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
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
PlantFrame(x, y, frame)
|
PlantFrame(x, y, frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@type Frame[]
|
||||||
|
local tagFramePool = {}
|
||||||
|
local tagFramePoolMaxSize = 20
|
||||||
|
for i = 1, tagFramePoolMaxSize do
|
||||||
|
local frame = CreateFrame("Frame")
|
||||||
|
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")
|
local frame = CreateFrame("Frame")
|
||||||
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
frame:RegisterEvent("WORLD_MAP_UPDATE")
|
||||||
frame:SetScript("OnEvent", function(self, event, addon)
|
frame:SetScript("OnEvent", function(self, event, addon)
|
||||||
|
if pauseUntil > GetTime() then return end
|
||||||
|
pauseUntil = GetTime() + 1
|
||||||
if not BattlefieldMinimap then
|
if not BattlefieldMinimap then
|
||||||
if Heimdall_Data.config.minimapTagger.debug then
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
print(string.format("[%s] BattlefieldMinimap not found", ModuleName))
|
print(string.format("[%s] BattlefieldMinimap not found", ModuleName))
|
||||||
@@ -113,21 +148,12 @@ function shared.MinimapTagger.Init()
|
|||||||
BattlefieldMinimapBackground:Hide()
|
BattlefieldMinimapBackground:Hide()
|
||||||
BattlefieldMinimapCloseButton:Hide()
|
BattlefieldMinimapCloseButton:Hide()
|
||||||
BattlefieldMinimapCorner: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)
|
BattlefieldMinimap:HookScript("OnHide", function(self)
|
||||||
for _, alertFrame in ipairs(alertFramePool) do
|
for _, alertFrame in ipairs(alertFramePool) do
|
||||||
alertFrame:Hide()
|
alertFrame:Hide()
|
||||||
alertFrame.custom.busy = false
|
alertFrame.custom.busy = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
BattlefieldMinimap:Hide()
|
|
||||||
BattlefieldMinimap:Show()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
print("[Heimdall] MinimapTagger loaded")
|
print("[Heimdall] MinimapTagger loaded")
|
||||||
|
|||||||
Reference in New Issue
Block a user