diff --git a/Modules/MinimapTagger.lua b/Modules/MinimapTagger.lua index c3c4667..7120d17 100644 --- a/Modules/MinimapTagger.lua +++ b/Modules/MinimapTagger.lua @@ -9,7 +9,9 @@ function shared.MinimapTagger.Init() ---@param x number ---@param y number ---@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() w, h = w * BattlefieldMinimap:GetEffectiveScale(), h * BattlefieldMinimap:GetEffectiveScale() 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)) end local iconSize = maxSize * 0.05 + iconSize = iconSize * scale x, y = x / 100, y / 100 -- Could do with how... I have no idea, but this seems more accurate than without @@ -73,7 +76,8 @@ function shared.MinimapTagger.Init() end ---@param x number ---@param y number - local function PlantAlert(x, y) + ---@param scale number? + local function PlantAlert(x, y, scale) local frame = nil for _, alertFrame in ipairs(alertFramePool) do if not alertFrame.custom.busy then @@ -87,7 +91,7 @@ function shared.MinimapTagger.Init() end return end - PlantFrame(x, y, frame) + PlantFrame(x, y, frame, scale) end ---@type Frame[] @@ -104,7 +108,8 @@ function shared.MinimapTagger.Init() end ---@param x number ---@param y number - local function PlantTag(x, y) + ---@param scale number? + local function PlantTag(x, y, scale) local frame = nil for _, tagFrame in ipairs(tagFramePool) do if not tagFrame.custom.busy then @@ -118,7 +123,7 @@ function shared.MinimapTagger.Init() end return end - PlantFrame(x, y, frame) + PlantFrame(x, y, frame, scale) end ---@type Frame[] @@ -135,7 +140,8 @@ function shared.MinimapTagger.Init() end ---@param x number ---@param y number - local function PlantBattle(x, y) + ---@param scale number? + local function PlantBattle(x, y, scale) local frame = nil for _, battleFrame in ipairs(battleFramePool) do if not battleFrame.custom.busy then @@ -149,7 +155,7 @@ function shared.MinimapTagger.Init() end return end - PlantFrame(x, y, frame) + PlantFrame(x, y, frame, scale) end local pauseUntil = 0 @@ -197,6 +203,51 @@ function shared.MinimapTagger.Init() 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") end