diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index c0df5b7..7925f45 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -47,18 +47,6 @@ end local changes = "" do -- recent change history changes = changes - ..TitanUtils_GetGoldText("8.0.2 : 2024/01/14\n") - ..TitanUtils_GetGreenText("Location : \n") - ..TitanUtils_GetHighlightText("" - .."- Fix for ticket #1381; error on opening map when Location was hidden.\n" - .."- Refactor to save cycles by stopping coord updates if user did not request.\n" - ) - ..TitanUtils_GetGreenText("Titan Config: \n") - ..TitanUtils_GetHighlightText("" - .."- Update many missing locale / translated strings.\n" - ) - .."\n\n" -changes = changes ..TitanUtils_GetGoldText("8.0.1 : 2024/01/01\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" @@ -350,7 +338,7 @@ local titan_entry = { } }, confinfodesc = { - name = "About", + name = L["TITAN_ABOUT"], order = 7, type = "group", inline = true, args = { @@ -2518,14 +2506,14 @@ end --============= Advanced local conftimerdesc = { - name = "Timers", + name = L["TITAN_PANEL_MENU_ADV_TIMER"], type = "group", inline = true, order = 1, args = { confdesc = { order = 10, type = "description", - name = L["TITAN_PANEL_MENU_ADV_DESC"], + name = L["TITAN_PANEL_MENU_ADV_TIMER_DESC"], cmdHidden = true }, advtimerpew = { @@ -2553,14 +2541,14 @@ local conftimerdesc = { }, } local confbuffdesc = { - name = "Buff Icon Vertical Adjustment", + name = L["TITAN_PANEL_MENU_ADV_BUFF"], type = "group", inline = true, order = 2, args = { confbuffdesc = { order = 110, type = "description", - name = "Adjust Buff icons only as needed. This will override the Titan default adjustment.", --L["TITAN_PANEL_MENU_ADV_DESC"], + name = L["TITAN_PANEL_MENU_ADV_BUFF_DESC"], cmdHidden = true }, advbuffadj = { @@ -2591,14 +2579,14 @@ local optionsAdvanced = { type = "group", args = { confoutputdesc = { - name = "Output", + name = L["TITAN_PANEL_MENU_ADV_OUTPUT"], type = "group", inline = true, order = 3, args = { confdesc = { order = 110, type = "description", - name = L["TITAN_PANEL_MENU_ADV_DESC"], + name = L["TITAN_PANEL_MENU_ADV_OUTPUT_DESC"], cmdHidden = true }, advname = { diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index a4f7c52..875f604 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -848,7 +848,7 @@ local function TitanPanelButton_SetButtonText(id) else buttonText:SetText("<?>") --[[ - local msg = tostring(id).." '"..tostring(label1).."'" + local msg = tostring(id).." '"..label1.."'" TitanPrint(msg, "error") --]] return diff --git a/TitanLocation/TitanLocation.lua b/TitanLocation/TitanLocation.lua index 5df39f8..ae8c156 100755 --- a/TitanLocation/TitanLocation.lua +++ b/TitanLocation/TitanLocation.lua @@ -23,40 +23,10 @@ local L = {} -- For AceLocale local AceTimer = {} local LocationTimer = nil; -local debug_flow = false +-- Difference in the Blizzard frame for the world map +local MapMinMaxFrame = {} -- ******************************** Functions ******************************* ---[[ local --- ************************************************************************** --- NAME : debug_msg(Message) --- DESC : Debug function to print message to chat frame --- VARS : Message = message to print to chat frame --- ************************************************************************** ---]] -local function debug_msg(Message) - local msg = "" - local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S") - local milli = GetTime() -- seconds with millisecond precision (float) - milli = string.format("%0.2F", milli - math.modf(milli)) - msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_LOCATION_ID..": ") - msg = msg..TitanUtils_GetGreenText(Message) - DEFAULT_CHAT_FRAME:AddMessage(msg) --- DEFAULT_CHAT_FRAME:AddMessage(TITAN_LOCATION_ID..": " .. Message, 1.00, 0.49, 0.04) -end - ---[[ local --- ************************************************************************** --- NAME : RegEvent() --- DESC : Check if already registered, register if not --- ************************************************************************** ---]] -local function RegEvent(plugin, event) - if plugin:IsEventRegistered(event) then - -- already registered - else - plugin:RegisterEvent(event) - end -end --[[ -- ************************************************************************** @@ -103,271 +73,34 @@ function TitanPanelLocationButton_OnLoad(self) } }; - RegEvent(self, "PLAYER_ENTERING_WORLD") - - if debug_flow then - local msg = - "_OnLoad" --- .." "..tostring(reason).."" - debug_msg(msg) - else - -- not requested - end + self:RegisterEvent("ZONE_CHANGED"); + self:RegisterEvent("ZONE_CHANGED_INDOORS"); + self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); + self:RegisterEvent("PLAYER_ENTERING_WORLD"); + TitanPanelLocation_CreateMapFrames(); end ---[[ local --- ************************************************************************** --- NAME : Events() --- DESC : Registers / unregisters events the plugin needs --- ************************************************************************** ---]] -local function Events(action, reason) --[[ ---]] - local plugin = _G[TITAN_BUTTON] - - if action == "register" then - RegEvent(plugin, "ZONE_CHANGED") - RegEvent(plugin, "ZONE_CHANGED_INDOORS") - RegEvent(plugin, "ZONE_CHANGED_NEW_AREA") - elseif action == "unregister" then - plugin:UnregisterEvent("ZONE_CHANGED") - plugin:UnregisterEvent("ZONE_CHANGED_INDOORS") - plugin:UnregisterEvent("ZONE_CHANGED_NEW_AREA") - else - -- action unknown ??? - end - - if debug_flow then - local msg = - "Events" - .." "..tostring(action).."" - .." "..tostring(reason).."" - debug_msg(msg) - else - -- not requested - end -end - -local function ZoneUpdate(self) - - local _ = nil - self.zoneText = GetZoneText(); - self.subZoneText = GetSubZoneText(); - self.pvpType, _, self.factionName = GetZonePVPInfo(); - - TitanPanelPluginHandle_OnUpdate(updateTable); - - if TitanPanelLocationButton:IsVisible() and not LocationTimer then - LocationTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelLocation", TitanPanelLocationButton_CheckForUpdate, 0.5) - end -end - ---[[ local -- ************************************************************************** --- NAME : GetPlayerMapPosition() --- DESC : Get the player coordinates --- VARS : x = location on x axis, y = location on y axis +-- NAME : TitanPanelLocationButton_OnShow() +-- DESC : Display button when plugin is visible -- ************************************************************************** --]] -local function GetPlayerMapPosition() - local mapID = C_Map.GetBestMapForUnit("player") - if mapID == nil then - return nil, nil - end - - local position = C_Map.GetPlayerMapPosition(mapID, "player") - if position == nil then - return nil, nil - else - return position:GetXY() - end -end - -local function SetCoordText(player, cursor) - local playerLocationText = player or "" - local cursorLocationText = cursor or "" - - TitanMapPlayerLocation:SetText(cursorLocationText); - TitanMapCursorLocation:SetText(playerLocationText); - --- local mloc = TitanGetVar(TITAN_LOCATION_ID, "MapLocation") or "TOPRIGHT" +function TitanPanelLocationButton_OnShow() + -- Set the version of the map to use if TITAN_ID == "TitanClassic" then - -- TODO - is setting map id needed?? + MapMinMaxFrame = WorldMapFrame.MaximizeMinimizeFrame + local mapID = C_Map.GetBestMapForUnit("player"); if mapID ~= nil and C_Map.MapHasArt(mapID) then WorldMapFrame:SetMapID(mapID); end - - -- Determine where to show the text - TitanMapPlayerLocation:ClearAllPoints() - TitanMapCursorLocation:ClearAllPoints() - - TitanMapPlayerLocation:SetPoint("BOTTOMLEFT", WorldMapFrame, "BOTTOM", 0, 10) - TitanMapCursorLocation:SetPoint("BOTTOMRIGHT", WorldMapFrame, "BOTTOM", -10, 10) - else -- current retail - -- Position the text - local anchor = WorldMapFrame.BorderFrame.MaximizeMinimizeFrame - if WorldMapFrame:IsMaximized() then - -- map should be 'full' screen - TitanMapPlayerLocation:ClearAllPoints(); - TitanMapCursorLocation:ClearAllPoints(); - TitanMapPlayerLocation:SetPoint("RIGHT", anchor, "LEFT", 0, 0) - TitanMapCursorLocation:SetPoint("TOP", TitanMapPlayerLocation, "BOTTOM", 0, -5) - WorldMapFrame.TitanSize = "large" - else - TitanMapPlayerLocation:ClearAllPoints(); - TitanMapCursorLocation:ClearAllPoints(); - TitanMapPlayerLocation:SetPoint("RIGHT", anchor, "LEFT", 0, 0) - TitanMapCursorLocation:SetPoint("LEFT", WorldMapFrame.BorderFrame.Tutorial, "RIGHT", 0, 0) - WorldMapFrame.TitanSize = "small" - end - end -end - ---[[ --- ************************************************************************** --- NAME : LocOnMiniMap() --- DESC : Show / hide the location above the mini map per user settings --- ************************************************************************** ---]] -local function LocOnMiniMap(reason) - if TitanGetVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap") then - MinimapBorderTop:Show() - MinimapZoneTextButton:Show() --- MiniMapWorldMapButton:Show() else - MinimapBorderTop:Hide() - MinimapZoneTextButton:Hide() - MiniMapWorldMapButton:Hide() + MapMinMaxFrame = WorldMapFrame.BorderFrame.MaximizeMinimizeFrame end - - -- adjust MiniMap frame if needed - if reason == "config" then - TitanPanel_AdjustFrames(false); - else - -- 2024 Jan - Do not adjust; allow Titan to handle on PEW - end -end ---[[ --- Set the coordinates text for player and cursor --- 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; - 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 - -- user did not request so save a few cycles - end - - if debug_flow then - local msg = - "CoordFrames" - .." "..tostring(action).."" - .." "..tostring(show_on_map).."" - debug_msg(msg) - else - -- not requested - end -end - ---[[ --- ************************************************************************** --- NAME : CreateMapFrames() --- DESC : Adds player and cursor coords to the WorldMapFrame, unless the player has CT_MapMod --- VARS : none --- ************************************************************************** ---]] -local function CreateMapFrames() - if _G[TitanMapFrame] then - return -- if already created - end - - -- avoid an addon conflict - if (_G["CT_MapMod"]) then - return; - end - - if debug_flow then - local msg = - "CreateMapFrames" --- .." "..tostring(reason).."" - debug_msg(msg) - else - -- not requested - 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) - 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 - local playertext = frame:CreateFontString("TitanMapPlayerLocation", "ARTWORK", "GameFontNormal"); - local cursortext = frame:CreateFontString("TitanMapCursorLocation", "ARTWORK", "GameFontNormal"); - playertext:ClearAllPoints(); - cursortext:ClearAllPoints(); - playertext:SetPoint("TOPRIGHT", WorldMapFrameCloseButton, "BOTTOMRIGHT", 0, 0) - cursortext:SetPoint("TOP", playertext, "BOTTOM", 0, 0) -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelLocationButton_OnShow() --- DESC : Display button when plugin is visible --- ************************************************************************** ---]] -function TitanPanelLocationButton_OnShow(self) - - if debug_flow then - local msg = - "_OnShow" --- .." "..tostring(reason).."" - debug_msg(msg) - else - -- not requested - end - - CreateMapFrames() -- as needed - CoordFrames("start") -- start coords on map, if requested - - Events("register", "_OnShow") - - -- Zone may not be available yet, PEW event should correct - ZoneUpdate(self); - - TitanPanelButton_UpdateButton(TITAN_LOCATION_ID); + TitanPanelLocation_HandleUpdater(); end --[[ @@ -379,9 +112,6 @@ end function TitanPanelLocationButton_OnHide() AceTimer.CancelTimer("TitanPanelLocation", LocationTimer, true) LocationTimer = nil; - - Events("unregister", "_OnHide") - CoordFrames("stop") -- stop coords on map, if requested end --[[ @@ -397,7 +127,7 @@ function TitanPanelLocationButton_GetButtonText(id) -- Coordinates text, if requested if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsText")) then - button.px, button.py = GetPlayerMapPosition(); + button.px, button.py = TitanPanelGetPlayerMapPosition(); -- cache coordinates for update checking later on cachedX = button.px; cachedY = button.py; @@ -478,22 +208,15 @@ function TitanPanelLocationButton_GetTooltipText() pvpInfoRichText = "" end - -- build the tool tip - local zone = TitanUtils_GetHighlightText(TitanPanelLocationButton.zoneText) or "" - local sub_zone = TitanUtils_Ternary( - (TitanPanelLocationButton.subZoneText == ""), - "", - L["TITAN_LOCATION_TOOLTIP_SUBZONE"].."\t"..TitanUtils_GetHighlightText(TitanPanelLocationButton.subZoneText).."\n" - ) - local bind_loc = TitanUtils_GetHighlightText(GetBindLocation()) - return "".. - L["TITAN_LOCATION_TOOLTIP_ZONE"].."\t"..zone.."\n" - ..sub_zone.."\n" - ..TitanUtils_GetHighlightText(L["TITAN_LOCATION_TOOLTIP_HOMELOCATION"]).."\n" - ..L["TITAN_LOCATION_TOOLTIP_INN"].."\t"..bind_loc.."\n" - ..TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_1"]).."\n" - ..TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_2"]) + L["TITAN_LOCATION_TOOLTIP_ZONE"].."\t"..TitanUtils_GetHighlightText(TitanPanelLocationButton.zoneText).."\n".. + TitanUtils_Ternary((TitanPanelLocationButton.subZoneText == ""), "", L["TITAN_LOCATION_TOOLTIP_SUBZONE"].."\t"..TitanUtils_GetHighlightText(TitanPanelLocationButton.subZoneText).."\n").. + TitanUtils_Ternary((pvpInfoRichText == ""), "", L["TITAN_LOCATION_TOOLTIP_PVPINFO"].."\t"..pvpInfoRichText.."\n").. + "\n".. + TitanUtils_GetHighlightText(L["TITAN_LOCATION_TOOLTIP_HOMELOCATION"]).."\n".. + L["TITAN_LOCATION_TOOLTIP_INN"].."\t"..TitanUtils_GetHighlightText(GetBindLocation()).."\n".. + TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_1"]).."\n".. + TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_2"]); end --[[ @@ -506,31 +229,25 @@ function TitanPanelLocationButton_OnEvent(self, event, ...) -- DF TODO See if we can turn off zone on minimap --[=[ --]=] - if debug_flow then - local msg = - "_OnEvent" - .." "..tostring(event).."" - debug_msg(msg) - else - -- not requested - end - if TITAN_ID == "TitanClassic" then if event == "PLAYER_ENTERING_WORLD" then if not TitanGetVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap") and MinimapBorderTop and MinimapBorderTop:IsShown() then - LocOnMiniMap("PEW") + TitanPanelLocationButton_LocOnMiniMap("PEW") end end if TitanGetVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap") and MinimapBorderTop:IsShown() then if not MinimapZoneTextButton:IsShown() then MinimapZoneTextButton:Show() end +-- if not MiniMapWorldMapButton:IsShown() then MiniMapWorldMapButton:Show() end end else -- no work needed end - ZoneUpdate(self); + TitanPanelLocationButton_UpdateZoneInfo(self); + TitanPanelPluginHandle_OnUpdate(updateTable); + TitanPanelLocation_HandleUpdater(); --[[ --]] end @@ -543,7 +260,7 @@ end --]] function TitanPanelLocationButton_CheckForUpdate() local mapID = C_Map.GetBestMapForUnit("player") - local tempx, tempy = GetPlayerMapPosition(); + local tempx, tempy = TitanPanelGetPlayerMapPosition(); if tempx ~= cachedX or tempy ~= cachedY then TitanPanelPluginHandle_OnUpdate(updateTable); end @@ -551,6 +268,18 @@ end --[[ -- ************************************************************************** +-- NAME : TitanPanelLocation_HandleUpdater() +-- DESC : Check to see if you are inside an instance +-- ************************************************************************** +--]] +function TitanPanelLocation_HandleUpdater() + if TitanPanelLocationButton:IsVisible() and not LocationTimer then + LocationTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelLocation", TitanPanelLocationButton_CheckForUpdate, 0.5) + end +end + +--[[ +-- ************************************************************************** -- NAME : TitanPanelLocationButton_OnClick(button) -- DESC : Copies coordinates to chat line for shift-LeftClick -- VARS : button = value of action @@ -571,6 +300,29 @@ function TitanPanelLocationButton_OnClick(self, button) end end +--[[ +-- ************************************************************************** +-- NAME : TitanPanelLocationButton_UpdateZoneInfo() +-- DESC : Update data on button +-- ************************************************************************** +--]] +function TitanPanelLocationButton_UpdateZoneInfo(self) + local _ = nil + self.zoneText = GetZoneText(); + self.subZoneText = GetSubZoneText(); + self.pvpType, _, self.factionName = GetZonePVPInfo(); +end + +--[[ +-- ************************************************************************** +-- NAME : TitanPanelRightClickMenu_PrepareLocationMenu() +-- DESC : Display rightclick menu options +-- ************************************************************************** +--]] +local function CoordLoc(loc) + local res = (TitanGetVar(TITAN_LOCATION_ID, "MapLocation") == loc) + return res +end function TitanPanelRightClickMenu_PrepareLocationMenu() local info @@ -580,10 +332,7 @@ function TitanPanelRightClickMenu_PrepareLocationMenu() TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_OPTIONS"], TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_LOCATION_MENU_SHOW_ZONE_ON_PANEL_TEXT"]; - info.func = function() - TitanToggleVar(TITAN_LOCATION_ID, "ShowZoneText"); - TitanPanelButton_UpdateButton(TITAN_LOCATION_ID); - end + info.func = TitanPanelLocationButton_ToggleDisplay; info.checked = TitanGetVar(TITAN_LOCATION_ID, "ShowZoneText"); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -608,17 +357,9 @@ function TitanPanelRightClickMenu_PrepareLocationMenu() end info.checked = TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsText"); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - info = {}; info.text = L["TITAN_LOCATION_MENU_SHOW_COORDS_ON_MAP_TEXT"]; - info.func = function() - TitanToggleVar(TITAN_LOCATION_ID, "ShowCoordsOnMap"); - if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap")) then - CoordFrames("start") - else - CoordFrames("stop") - end - end + info.func = TitanPanelLocationButton_ToggleLocationOnMap; info.checked = TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap"); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -627,7 +368,7 @@ function TitanPanelRightClickMenu_PrepareLocationMenu() info.text = L["TITAN_LOCATION_MENU_SHOW_LOC_ON_MINIMAP_TEXT"]; info.func = function() TitanToggleVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap"); - LocOnMiniMap("config") + TitanPanelLocationButton_LocOnMiniMap("config") end info.checked = TitanGetVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap"); info.disabled = InCombatLockdown() @@ -644,8 +385,52 @@ function TitanPanelRightClickMenu_PrepareLocationMenu() info.disabled = InCombatLockdown() TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +--[=[ + if TITAN_ID == "TitanClassic" then + info = {}; + TitanPanelRightClickMenu_AddSpacer(TitanPanelRightClickMenu_GetDropdownLevel()); + TitanPanelRightClickMenu_AddTitle(L["TITAN_LOCATION_MENU_MAP_COORDS_TITLE"], TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_LOCATION_MENU_MAP_COORDS_LOC_1"] + info.func = function() + TitanSetVar(TITAN_LOCATION_ID, "MapLocation", "TOPLEFT") + end + info.checked = CoordLoc("TOPLEFT") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + info = {}; + info.text = L["TITAN_LOCATION_MENU_MAP_COORDS_LOC_2"] + info.func = function() + TitanSetVar(TITAN_LOCATION_ID, "MapLocation", "TOPRIGHT") + end + info.checked = CoordLoc("TOPRIGHT") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + info = {}; + info.text = L["TITAN_LOCATION_MENU_MAP_COORDS_LOC_3"] + info.func = function() + TitanSetVar(TITAN_LOCATION_ID, "MapLocation", "BOTTOMLEFT") + end + info.checked = CoordLoc("BOTTOMLEFT") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + info = {}; + info.text = L["TITAN_LOCATION_MENU_MAP_COORDS_LOC_4"] + info.func = function() + TitanSetVar(TITAN_LOCATION_ID, "MapLocation", "BOTTOM") + end + info.checked = CoordLoc("BOTTOM") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + info = {}; + info.text = L["TITAN_LOCATION_MENU_MAP_COORDS_LOC_5"] + info.func = function() + TitanSetVar(TITAN_LOCATION_ID, "MapLocation", "BOTTOMRIGHT") + end + info.checked = CoordLoc("BOTTOMRIGHT") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + else + -- no work needed + end +--]=] end - if TitanPanelRightClickMenu_GetDropdMenuValue() == "CoordFormat" then TitanPanelRightClickMenu_AddTitle(L["TITAN_LOCATION_FORMAT_COORD_LABEL"], TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; @@ -700,6 +485,72 @@ end --[[ -- ************************************************************************** +-- NAME : TitanPanelLocationButton_ToggleDisplay() +-- DESC : Set option to show zone text +-- ************************************************************************** +--]] +function TitanPanelLocationButton_ToggleDisplay() + TitanToggleVar(TITAN_LOCATION_ID, "ShowZoneText"); + TitanPanelButton_UpdateButton(TITAN_LOCATION_ID); +end + +--[[ +-- ************************************************************************** +-- NAME : TitanPanelLocationButton_ToggleLocationOnMap() +-- DESC : Set option to show player coordinates on map +-- ************************************************************************** +--]] +function TitanPanelLocationButton_ToggleLocationOnMap() + TitanToggleVar(TITAN_LOCATION_ID, "ShowCoordsOnMap"); + if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap")) then + TitanMapPlayerLocation:Show(); + else + TitanMapPlayerLocation:Hide(); + end +end + +--[[ +-- ************************************************************************** +-- NAME : TitanPanelLocationButton_ToggleCursorLocationOnMap() +-- DESC : Set option to show cursor coordinates on map +-- ************************************************************************** +--]] +function TitanPanelLocationButton_ToggleCursorLocationOnMap() + TitanToggleVar(TITAN_LOCATION_ID, "ShowCursorOnMap"); + if (TitanGetVar(TITAN_LOCATION_ID, "ShowCursorOnMap")) then + TitanMapCursorLocation:Show(); + else + TitanMapCursorLocation:Hide(); + end +end + +--[[ +-- ************************************************************************** +-- NAME : TitanPanelLocationButton_LocOnMiniMap() +-- DESC : Show / hide the location above the mini map per user settings +-- ************************************************************************** +--]] +function TitanPanelLocationButton_LocOnMiniMap(reason) + if TitanGetVar(TITAN_LOCATION_ID, "ShowLocOnMiniMap") then + MinimapBorderTop:Show() + MinimapZoneTextButton:Show() +-- MiniMapWorldMapButton:Show() + else + MinimapBorderTop:Hide() + MinimapZoneTextButton:Hide() + MiniMapWorldMapButton:Hide() + end + + -- adjust MiniMap frame if needed + if reason == "config" then + TitanPanel_AdjustFrames(false); + else + -- 2024 Jan - Do not adjust; allow Titan to handle on PEW + end +end + +--[[ +-- ************************************************************************** -- NAME : TitanMapFrame_OnUpdate() -- DESC : Update coordinates on map -- ************************************************************************** @@ -710,18 +561,11 @@ function TitanMapFrame_OnUpdate(self, elapsed) -- Determine the text to show for player coords - local cursorLocationText = "" - local playerLocationText = "" - - if debug_flow then - cursorLocationText = "-C-" - playerLocationText = "-P-" - else - -- use default - end + local cursorLocationText = "-C-" + local playerLocationText = "-P-" if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap")) then - self.px, self.py = GetPlayerMapPosition(); + self.px, self.py = TitanPanelGetPlayerMapPosition(); if self.px == nil then self.px = 0 end if self.py == nil then self.py = 0 end if self.px == 0 and self.py == 0 then @@ -756,10 +600,117 @@ print("TLoc" .." p "..tostring(playerLocationText).." " ) --]==] - SetCoordText(playerLocationText, cursorLocationText) + TitanMapPlayerLocation:SetText(cursorLocationText); + TitanMapCursorLocation:SetText(playerLocationText); + +-- local mloc = TitanGetVar(TITAN_LOCATION_ID, "MapLocation") or "TOPRIGHT" + if TITAN_ID == "TitanClassic" then + -- Determine where to show the text + TitanMapPlayerLocation:ClearAllPoints() + TitanMapCursorLocation:ClearAllPoints() + + TitanMapPlayerLocation:SetPoint("BOTTOMLEFT", WorldMapFrame, "BOTTOM", 0, 10) + TitanMapCursorLocation:SetPoint("BOTTOMRIGHT", WorldMapFrame, "BOTTOM", -10, 10) + else -- current retail + -- Position the text + if WorldMapFrame:IsMaximized() then + -- map should be 'full' screen + if WorldMapFrame.TitanSizePrev == "large" then + -- no change + else + TitanMapPlayerLocation:ClearAllPoints(); + TitanMapCursorLocation:ClearAllPoints(); + TitanMapPlayerLocation:SetPoint("RIGHT", MapMinMaxFrame, "LEFT", 0, 0) + TitanMapCursorLocation:SetPoint("TOP", TitanMapPlayerLocation, "BOTTOM", 0, -5) + WorldMapFrame.TitanSize = "large" + end + else + if WorldMapFrame.TitanSizePrev == "small" then + -- no change + else + TitanMapPlayerLocation:ClearAllPoints(); + TitanMapCursorLocation:ClearAllPoints(); + TitanMapPlayerLocation:SetPoint("RIGHT", MapMinMaxFrame, "LEFT", 0, 0) + TitanMapCursorLocation:SetPoint("LEFT", WorldMapFrame.BorderFrame.Tutorial, "RIGHT", 0, 0) + WorldMapFrame.TitanSize = "small" + end + end + end end +--[[ +-- ************************************************************************** +-- NAME : TitanPanelGetPlayerMapPosition() +-- DESC : Get the player coordinates +-- VARS : x = location on x axis, y = location on y axis +-- ************************************************************************** +--]] +function TitanPanelGetPlayerMapPosition() + local mapID = C_Map.GetBestMapForUnit("player") + if mapID == nil then + return nil, nil + end + + local position = C_Map.GetPlayerMapPosition(mapID, "player") + if position == nil then + return nil, nil + else + return position:GetXY() + end +end + +--[[ +-- ************************************************************************** +-- NAME : TitanPanelLocation_CreateMapFrames() +-- DESC : Adds player and cursor coords to the WorldMapFrame, unless the player has CT_MapMod +-- VARS : none +-- ************************************************************************** +--]] +function TitanPanelLocation_CreateMapFrames() + if _G[TitanMapFrame] then + return -- if already created + end + + -- avoid an addon conflict + if (_G["CT_MapMod"]) then + return; + 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.BorderFrame) + local frame = CreateFrame("FRAME", "TitanMapFrame", WorldMapFrame) + frame:SetFrameStrata("DIALOG") -- DF need to raise the strata to be seen + local function updateFunc() + TitanMapFrame_OnUpdate(frame, 0.07); -- simulating an OnUpdate call + end + frame:HookScript("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:HookScript("OnHide", function() + if (frame.updateTicker) then + frame.updateTicker:Cancel(); + frame.updateTicker = nil; + end + end); + + -- create the font strings and update their position based in minimizing/maximizing the main map + local playertext = frame:CreateFontString("TitanMapPlayerLocation", "ARTWORK", "GameFontNormal"); + local cursortext = frame:CreateFontString("TitanMapCursorLocation", "ARTWORK", "GameFontNormal"); + playertext:ClearAllPoints(); + cursortext:ClearAllPoints(); + playertext:SetPoint("TOPRIGHT", WorldMapFrameCloseButton, "BOTTOMRIGHT", 0, 0) + cursortext:SetPoint("TOP", playertext, "BOTTOM", 0, 0) +end + + -- ====== Create needed frames local function Create_Frames() if _G[TITAN_BUTTON] then @@ -794,6 +745,8 @@ local function Create_Frames() end -AceTimer = LibStub("AceTimer-3.0") -L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -Create_Frames() -- do the work +if TITAN_ID then -- it exists + AceTimer = LibStub("AceTimer-3.0") + L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) + Create_Frames() -- do the work +end