Implement icon scale to minimap tagger
This commit is contained in:
@@ -9,7 +9,9 @@ function shared.MinimapTagger.Init()
|
|||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param frame Frame
|
---@param frame Frame
|
||||||
local function PlantFrame(x, y, frame)
|
---@param scale number?
|
||||||
|
local function PlantFrame(x, y, frame, scale)
|
||||||
|
scale = scale or 1
|
||||||
local w, h = BattlefieldMinimap:GetSize()
|
local w, h = BattlefieldMinimap:GetSize()
|
||||||
w, h = w * BattlefieldMinimap:GetEffectiveScale(), h * BattlefieldMinimap:GetEffectiveScale()
|
w, h = w * BattlefieldMinimap:GetEffectiveScale(), h * BattlefieldMinimap:GetEffectiveScale()
|
||||||
local maxSize = w > h and w or h
|
local maxSize = w > h and w or h
|
||||||
@@ -17,6 +19,7 @@ function shared.MinimapTagger.Init()
|
|||||||
print(string.format("[%s] Minimap size: %d", ModuleName, maxSize))
|
print(string.format("[%s] Minimap size: %d", ModuleName, maxSize))
|
||||||
end
|
end
|
||||||
local iconSize = maxSize * 0.05
|
local iconSize = maxSize * 0.05
|
||||||
|
iconSize = iconSize * scale
|
||||||
|
|
||||||
x, y = x / 100, y / 100
|
x, y = x / 100, y / 100
|
||||||
-- Could do with how... I have no idea, but this seems more accurate than without
|
-- Could do with how... I have no idea, but this seems more accurate than without
|
||||||
@@ -73,7 +76,8 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
local function PlantAlert(x, y)
|
---@param scale number?
|
||||||
|
local function PlantAlert(x, y, scale)
|
||||||
local frame = nil
|
local frame = nil
|
||||||
for _, alertFrame in ipairs(alertFramePool) do
|
for _, alertFrame in ipairs(alertFramePool) do
|
||||||
if not alertFrame.custom.busy then
|
if not alertFrame.custom.busy then
|
||||||
@@ -87,7 +91,7 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
PlantFrame(x, y, frame)
|
PlantFrame(x, y, frame, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type Frame[]
|
---@type Frame[]
|
||||||
@@ -104,7 +108,8 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
local function PlantTag(x, y)
|
---@param scale number?
|
||||||
|
local function PlantTag(x, y, scale)
|
||||||
local frame = nil
|
local frame = nil
|
||||||
for _, tagFrame in ipairs(tagFramePool) do
|
for _, tagFrame in ipairs(tagFramePool) do
|
||||||
if not tagFrame.custom.busy then
|
if not tagFrame.custom.busy then
|
||||||
@@ -118,7 +123,7 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
PlantFrame(x, y, frame)
|
PlantFrame(x, y, frame, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type Frame[]
|
---@type Frame[]
|
||||||
@@ -135,7 +140,8 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
local function PlantBattle(x, y)
|
---@param scale number?
|
||||||
|
local function PlantBattle(x, y, scale)
|
||||||
local frame = nil
|
local frame = nil
|
||||||
for _, battleFrame in ipairs(battleFramePool) do
|
for _, battleFrame in ipairs(battleFramePool) do
|
||||||
if not battleFrame.custom.busy then
|
if not battleFrame.custom.busy then
|
||||||
@@ -149,7 +155,7 @@ function shared.MinimapTagger.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
PlantFrame(x, y, frame)
|
PlantFrame(x, y, frame, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pauseUntil = 0
|
local pauseUntil = 0
|
||||||
@@ -197,6 +203,51 @@ function shared.MinimapTagger.Init()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local chatFrame = CreateFrame("Frame")
|
||||||
|
chatFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||||
|
chatFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||||
|
-- if Heimdall_Data.config.echoer.debug then
|
||||||
|
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if not Heimdall_Data.config.minimapTagger.enabled then
|
||||||
|
-- if Heimdall_Data.config.echoer.debug then
|
||||||
|
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
|
||||||
|
-- end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local channelId = select(6, ...)
|
||||||
|
local _, channelname = GetChannelName(channelId)
|
||||||
|
-- if Heimdall_Data.config.echoer.debug then
|
||||||
|
-- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname))
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if channelname ~= Heimdall_Data.config.minimapTagger.masterChannel then
|
||||||
|
-- if Heimdall_Data.config.echoer.debug then
|
||||||
|
-- print(string.format("[%s] Ignoring message from non-master channel", ModuleName))
|
||||||
|
-- end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
|
||||||
|
shared.dumpTable(Heimdall_Data.config.minimapTagger)
|
||||||
|
end
|
||||||
|
|
||||||
|
if string.find(msg, "^I see") then
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Found alert in message: %s", ModuleName, msg))
|
||||||
|
end
|
||||||
|
local x, y = string.match(msg, "%((%d+%.%d+)%s*,%s*(%d+%.%d+)%)")
|
||||||
|
if Heimdall_Data.config.minimapTagger.debug then
|
||||||
|
print(string.format("[%s] Found alert position: %s, %s", ModuleName, tostring(x), tostring(y)))
|
||||||
|
end
|
||||||
|
if x and y then
|
||||||
|
PlantTag(tonumber(x), tonumber(y), 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
print("[Heimdall] MinimapTagger loaded")
|
print("[Heimdall] MinimapTagger loaded")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user