88 lines
3.1 KiB
Lua
88 lines
3.1 KiB
Lua
local addonname, shared = ...
|
|
---@cast shared HeimdallShared
|
|
---@cast addonname string
|
|
local ModuleName = "MinimapTagger"
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
shared.MinimapTagger = {}
|
|
function shared.MinimapTagger.Init()
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] Module initialized", ModuleName))
|
|
end
|
|
|
|
local alertFramePool = {}
|
|
local alertFramePoolMaxSize = 20
|
|
---@param x number
|
|
---@param y number
|
|
local function PlantAlert(x, y)
|
|
local frame = nil
|
|
for _, alertFrame in ipairs(alertFramePool) do
|
|
if not alertFrame.custom.busy then
|
|
frame = alertFrame
|
|
break
|
|
end
|
|
end
|
|
|
|
local w, h = BattlefieldMinimap:GetSize()
|
|
w, h = w * BattlefieldMinimap:GetEffectiveScale(), h * BattlefieldMinimap:GetEffectiveScale()
|
|
local maxSize = w > h and w or h
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] Minimap size: %d", ModuleName, maxSize))
|
|
end
|
|
local iconSize = maxSize * 0.05
|
|
|
|
x, y = x / 100, y / 100
|
|
-- Could do with how... I have no idea, but this seems more accurate than without
|
|
--x, y = x - 0.01, y - 0.01
|
|
local offsetx, offsety = w * x, h * y
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] Alert position: %d, %d", ModuleName, x, y))
|
|
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
|
|
end
|
|
|
|
if not frame then
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] Creating new alert frame", ModuleName))
|
|
end
|
|
frame = CreateFrame("Frame")
|
|
frame:SetSize(iconSize, iconSize)
|
|
frame:SetFrameStrata("HIGH")
|
|
frame:SetFrameLevel(100)
|
|
frame.custom = { busy = true }
|
|
local alertFrameTexture = frame:CreateTexture(nil, "ARTWORK")
|
|
alertFrameTexture:SetAllPoints(frame)
|
|
alertFrameTexture:SetColorTexture(1, 0, 0, 0.5)
|
|
alertFrameTexture:SetTexture("Interface\\AddOns\\WeakAuras\\PowerAurasMedia\\Auras\\Aura27")
|
|
table.insert(alertFramePool, frame)
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] Alert frame created, pool size: %d", ModuleName, #alertFramePool))
|
|
end
|
|
end
|
|
frame:SetPoint("CENTER", BattlefieldMinimap, "TOPLEFT", offsetx, -offsety)
|
|
end
|
|
|
|
local frame = CreateFrame("Frame")
|
|
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
frame:SetScript("OnEvent", function(self, event, addon)
|
|
if not BattlefieldMinimap then
|
|
if Heimdall_Data.config.minimapTagger.debug then
|
|
print(string.format("[%s] BattlefieldMinimap not found", ModuleName))
|
|
end
|
|
return
|
|
end
|
|
--local scale = Heimdall_Data.config.minimapTagger.scale
|
|
local scale = 4
|
|
BattlefieldMinimap:SetScale(scale)
|
|
BattlefieldMinimap:SetMovable(true)
|
|
BattlefieldMinimap:EnableMouse(true)
|
|
BattlefieldMinimap:RegisterForDrag("LeftButton")
|
|
BattlefieldMinimap:SetScript("OnDragStart", function(self) self:StartMoving() end)
|
|
BattlefieldMinimap:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
|
|
BattlefieldMinimapBackground:Hide()
|
|
BattlefieldMinimapCloseButton:Hide()
|
|
BattlefieldMinimapCorner:Hide()
|
|
end)
|
|
|
|
print("[Heimdall] MinimapTagger loaded")
|
|
end
|