Implement fading alerts
This commit is contained in:
@@ -170,6 +170,7 @@ local function init()
|
|||||||
---@field masterChannel string
|
---@field masterChannel string
|
||||||
---@field throttle number
|
---@field throttle number
|
||||||
---@field scale number
|
---@field scale number
|
||||||
|
---@field ttl number
|
||||||
|
|
||||||
--- Data ---
|
--- Data ---
|
||||||
---@class HeimdallMessengerData
|
---@class HeimdallMessengerData
|
||||||
@@ -337,6 +338,7 @@ local function init()
|
|||||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "masterChannel" }, "Agent"),
|
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "masterChannel" }, "Agent"),
|
||||||
throttle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "throttle" }, 10),
|
throttle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "throttle" }, 10),
|
||||||
scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3),
|
scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3),
|
||||||
|
ttl = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "ttl" }, 1),
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1390,6 +1390,21 @@ function shared.Config.Init()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
minimapTaggerConfigFrame:Add(masterChannel, 2, 6)
|
minimapTaggerConfigFrame:Add(masterChannel, 2, 6)
|
||||||
|
|
||||||
|
local ttl = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigTTL",
|
||||||
|
minimapTaggerConfigFrame.frame, "TTL",
|
||||||
|
Heimdall_Data.config.minimapTagger.ttl,
|
||||||
|
function(self)
|
||||||
|
local text = self:GetText()
|
||||||
|
if string.match(text, "%d+") then
|
||||||
|
Heimdall_Data.config.minimapTagger.ttl = tonumber(text)
|
||||||
|
print("TTL set to", tostring(text))
|
||||||
|
else
|
||||||
|
print("Invalid ttl", tostring(text))
|
||||||
|
self:SetText(Heimdall_Data.config.minimapTagger.ttl)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
minimapTaggerConfigFrame:Add(ttl, 2, 6)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Whisper Notify
|
-- Whisper Notify
|
||||||
|
@@ -6,10 +6,6 @@ local ModuleName = "MinimapTagger"
|
|||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
shared.MinimapTagger = {}
|
shared.MinimapTagger = {}
|
||||||
function shared.MinimapTagger.Init()
|
function shared.MinimapTagger.Init()
|
||||||
if Heimdall_Data.config.minimapTagger.debug then
|
|
||||||
print(string.format("[%s] Module initialized", ModuleName))
|
|
||||||
end
|
|
||||||
|
|
||||||
local alertFramePool = {}
|
local alertFramePool = {}
|
||||||
local alertFramePoolMaxSize = 20
|
local alertFramePoolMaxSize = 20
|
||||||
---@param x number
|
---@param x number
|
||||||
@@ -39,6 +35,12 @@ function shared.MinimapTagger.Init()
|
|||||||
print(string.format("[%s] Alert position: %d, %d", ModuleName, x, y))
|
print(string.format("[%s] Alert position: %d, %d", ModuleName, x, y))
|
||||||
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
|
print(string.format("[%s] Alert offset: %d, %d", ModuleName, offsetx, offsety))
|
||||||
end
|
end
|
||||||
|
if not frame and #alertFramePool >= alertFramePoolMaxSize then
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Alert frame pool is full, skipping", ModuleName))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not frame then
|
if not frame then
|
||||||
if Heimdall_Data.config.minimapTagger.debug then
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
@@ -58,7 +60,33 @@ function shared.MinimapTagger.Init()
|
|||||||
print(string.format("[%s] Alert frame created, pool size: %d", ModuleName, #alertFramePool))
|
print(string.format("[%s] Alert frame created, pool size: %d", ModuleName, #alertFramePool))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
frame:SetPoint("CENTER", BattlefieldMinimap, "TOPLEFT", offsetx, -offsety)
|
frame:SetPoint("CENTER", BattlefieldMinimap, "TOPLEFT", offsetx, -offsety)
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Alert frame created, OnUpdate hooked", ModuleName))
|
||||||
|
end
|
||||||
|
frame:SetScript("OnShow", function(self)
|
||||||
|
self:SetAlpha(1)
|
||||||
|
self.custom.busy = true
|
||||||
|
self.custom.progress = 0
|
||||||
|
self:SetScript("OnUpdate", function(self, elapsed)
|
||||||
|
self.custom.progress = self.custom.progress + elapsed
|
||||||
|
local progress = self.custom.progress / Heimdall_Data.config.minimapTagger.ttl
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Alert progress%%: %f", ModuleName, progress))
|
||||||
|
print(string.format("[%s] Alert progress: %f", ModuleName, self.custom.progress))
|
||||||
|
print(string.format("[%s] Alert ttl: %f", ModuleName, Heimdall_Data.config.minimapTagger.ttl))
|
||||||
|
end
|
||||||
|
self:SetAlpha(1 - progress)
|
||||||
|
|
||||||
|
if progress >= 1 then
|
||||||
|
self:Hide()
|
||||||
|
self.custom.busy = false
|
||||||
|
self:SetScript("OnUpdate", nil)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
frame:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
local frame = CreateFrame("Frame")
|
local frame = CreateFrame("Frame")
|
||||||
@@ -70,6 +98,12 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if not Heimdall_Data.config.minimapTagger.enabled then
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] MinimapTagger is disabled", ModuleName))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
--local scale = Heimdall_Data.config.minimapTagger.scale
|
--local scale = Heimdall_Data.config.minimapTagger.scale
|
||||||
local scale = 4
|
local scale = 4
|
||||||
BattlefieldMinimap:SetScale(scale)
|
BattlefieldMinimap:SetScale(scale)
|
||||||
@@ -81,7 +115,27 @@ 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)
|
||||||
|
for _, alertFrame in ipairs(alertFramePool) do
|
||||||
|
alertFrame:Hide()
|
||||||
|
alertFrame.custom.busy = false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
BattlefieldMinimap:Hide()
|
||||||
|
BattlefieldMinimap:Show()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
print("[Heimdall] MinimapTagger loaded")
|
print("[Heimdall] MinimapTagger loaded")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SlashCmdList["HEIMDALL_MINIMAPTAGGER"] = function(args)
|
||||||
|
shared.MinimapTagger.Init()
|
||||||
|
end
|
||||||
|
SLASH_HEIMDALL_MINIMAPTAGGER1 = "/mf"
|
||||||
|
Reference in New Issue
Block a user