From 4ccccd4e3414ae5f3dd866ea66b80d3593077663 Mon Sep 17 00:00:00 2001 From: urnati Date: Mon, 15 Jan 2024 08:49:25 -0500 Subject: [PATCH] - Add explict flag to check for addon conflicts (CTMod) --- TitanLocation/TitanLocation.lua | 78 ++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/TitanLocation/TitanLocation.lua b/TitanLocation/TitanLocation.lua index c5201da..536fa3a 100755 --- a/TitanLocation/TitanLocation.lua +++ b/TitanLocation/TitanLocation.lua @@ -13,8 +13,9 @@ local _G = getfenv(0); local TITAN_LOCATION_ID = "Location"; local TITAN_BUTTON = "TitanPanel"..TITAN_LOCATION_ID.."Button" -local OFFSET_X = 0.0022 -- 0.0022; -local OFFSET_Y = -0.0262 -- -0.0262; +local TITAN_MAP_FRAME = "TitanMapFrame" + +local addon_conflict = false -- used for addon conflicts local cachedX = 0; local cachedY = 0; local updateTable = {TITAN_LOCATION_ID, TITAN_PANEL_UPDATE_BUTTON}; @@ -250,40 +251,44 @@ end -- Used on update to refresh and on hide to clear the text --]] local function CoordFrames(action) - local frame = _G["TitanMapFrame"] - local show_on_map = (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap") and true or false) - if show_on_map then - if action == "start" then - local function updateFunc() - TitanMapFrame_OnUpdate(frame, 0.07); -- simulating an OnUpdate call - end - frame:SetScript("OnShow", function() - frame.updateTicker = frame.updateTicker or C_Timer.NewTicker(0.07, updateFunc); - if WorldMapFrame:IsMaximized() then - WorldMapFrame.TitanSize = "large" - WorldMapFrame.TitanSizePrev = "none" - else - WorldMapFrame.TitanSize = "small" - WorldMapFrame.TitanSizePrev = "none" - end - end); - frame:SetScript("OnHide", function() - if (frame.updateTicker) then - frame.updateTicker:Cancel(); - frame.updateTicker = nil; + if addon_conflict then + -- do not attempt coords + else + local frame = _G[TITAN_MAP_FRAME] + local show_on_map = (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap") and true or false) + if show_on_map then + if action == "start" then + local function updateFunc() + TitanMapFrame_OnUpdate(frame, 0.07); -- simulating an OnUpdate call end - end); - elseif action == "stop" then - -- stop timer, hooks are not needed - frame:SetScript("OnShow", nil) - frame:SetScript("OnHide", nil) - SetCoordText("", "") -- cleanup + frame:SetScript("OnShow", function() + frame.updateTicker = frame.updateTicker or C_Timer.NewTicker(0.07, updateFunc); + if WorldMapFrame:IsMaximized() then + WorldMapFrame.TitanSize = "large" + WorldMapFrame.TitanSizePrev = "none" + else + WorldMapFrame.TitanSize = "small" + WorldMapFrame.TitanSizePrev = "none" + end + end); + frame:SetScript("OnHide", function() + if (frame.updateTicker) then + frame.updateTicker:Cancel(); + frame.updateTicker = nil; + end + end); + elseif action == "stop" then + -- stop timer, hooks are not needed + frame:SetScript("OnShow", nil) + frame:SetScript("OnHide", nil) + SetCoordText("", "") -- cleanup + else + -- action unknown ??? + end else - -- action unknown ??? + -- user did not request so save a few cycles end - else - -- user did not request so save a few cycles end if debug_flow then @@ -291,6 +296,7 @@ local function CoordFrames(action) "CoordFrames" .." "..tostring(action).."" .." "..tostring(show_on_map).."" + .." "..tostring(addon_conflict).."" debug_msg(msg) else -- not requested @@ -305,12 +311,13 @@ end -- ************************************************************************** --]] local function CreateMapFrames() - if _G[TitanMapFrame] then + if _G[TITAN_MAP_FRAME] then return -- if already created end -- avoid an addon conflict if (_G["CT_MapMod"]) then + addon_conflict = true return; end @@ -324,7 +331,7 @@ local function CreateMapFrames() end -- create the frame to hold the font strings, and simulate an "OnUpdate" script handler using C_Timer for efficiency - local frame = CreateFrame("FRAME", "TitanMapFrame", WorldMapFrame) + local frame = CreateFrame("FRAME", TITAN_MAP_FRAME, WorldMapFrame) frame:SetFrameStrata("DIALOG") -- DF need to raise the strata to be seen -- create the font strings and update their position based in minimizing/maximizing the main map @@ -699,9 +706,6 @@ end -- ************************************************************************** --]] function TitanMapFrame_OnUpdate(self, elapsed) - -- using :Hide / :Show prevents coords from running - -- TitanMapFrame:Hide() -- hide parent - -- Determine the text to show for player coords local cursorLocationText = "" -- 1.7.9.5