Harden final ClassicAPI audit interactions

This commit is contained in:
Dusk-92
2026-09-05 16:41:09 +02:00
parent 5bcbab1b74
commit 2f1c4f42cb
4 changed files with 86 additions and 68 deletions
+10
View File
@@ -187,6 +187,13 @@ module.enable = function(self)
MinimapClock:SetScript("OnEnter", function()
local h, m = GetGameTime()
local servertime = string.format("%.2d:%.2d", h, m)
local zonetime
local turtleClock = ShaguTweaks.GetTurtleClockTimes
if turtleClock then
servertime, zonetime = turtleClock()
end
local time = date("%H:%M")
GameTooltip:ClearLines()
@@ -195,6 +202,9 @@ module.enable = function(self)
GameTooltip:AddLine(T["Clock"])
GameTooltip:AddDoubleLine(T["Localtime"], time, 1,1,1,1,1,1)
GameTooltip:AddDoubleLine(T["Servertime"], servertime, 1,1,1,1,1,1)
if zonetime then
GameTooltip:AddDoubleLine(T["Zonetime"], zonetime, 1,1,1,1,1,1)
end
GameTooltip:Show()
end)
+4 -2
View File
@@ -2,6 +2,7 @@ local _G = ShaguTweaks.GetGlobalEnv()
local T = ShaguTweaks.T
local L = ShaguTweaks.L
local gfind = string.gmatch or string.gfind
local strfind = string.find
local GetUnitData = ShaguTweaks.GetUnitData
local GetPlayerCache = ShaguTweaks.GetPlayerCache
local hooksecurefunc = ShaguTweaks.hooksecurefunc
@@ -119,7 +120,7 @@ end
local classHex = {}
local function GetPlayerNameFromLink(payload)
local colon = string.find(payload, ":")
local colon = strfind(payload, ":")
if colon then
return string.sub(payload, 1, colon - 1)
end
@@ -128,6 +129,7 @@ end
local function ColorPlayerLinks(text)
if not text then return text end
if not strfind(text, "|Hplayer:", 1, true) then return text end
for name in gfind(text, "|Hplayer:(.-)|h") do
-- Player hyperlinks may contain Turtle metadata after the real name. Avoid
@@ -384,4 +386,4 @@ module.enable = function(self)
end
end)
end
end
end
+50 -51
View File
@@ -15,63 +15,62 @@ local module = ShaguTweaks:register({
})
module.enable = function(self)
if ShaguTweaks_config[T["MiniMap Clock"]] == 1 then
MinimapClock:SetScript("OnEnter", function()
-- read game time
local zh, zm = GetGameTime()
local sh, sm = zh, zm
-- Minimap Clock owns its tooltip script. Expose only Turtle's time conversion
-- so the clock can consume it dynamically regardless of module enable order.
ShaguTweaks.GetTurtleClockTimes = function()
local zh, zm = GetGameTime()
local sh, sm = zh, zm
-- convert custom zonetime to servertime
SetMapToCurrentZone()
if GetCurrentMapContinent() == 1 then
sh = sh + 12
sh = sh >= 24 and sh - 24 or sh
SetMapToCurrentZone()
if GetCurrentMapContinent() == 1 then
sh = sh + 12
sh = sh >= 24 and sh - 24 or sh
end
local servertime = string.format("%.2d:%.2d", sh, sm)
local zonetime = string.format("%.2d:%.2d", zh, zm)
return servertime, zonetime
end
-- Turtle changes WorldMapFrame_Maximize. Keep our compatibility wrapper
-- completely out of the way when a dedicated map addon owns the world map.
if not Cartographer and not METAMAP_TITLE then
local HookWorldMapFrame_Maximize = WorldMapFrame_Maximize
WorldMapFrame_Maximize = function()
-- run original function
HookWorldMapFrame_Maximize()
-- Re-apply only when WorldMap Window really initialized.
if ShaguTweaks.WorldMapWindowActive then
WorldMapFrame:SetMovable(true)
WorldMapFrame:EnableMouse(true)
WorldMapFrame:SetScale(.85)
WorldMapFrame:ClearAllPoints()
WorldMapFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 30)
WorldMapFrame:SetWidth(WorldMapButton:GetWidth() + 15)
WorldMapFrame:SetHeight(WorldMapButton:GetHeight() + 55)
-- overwrite wrong title position set by turtlewow
WorldMapFrameTitle:SetPoint("TOP", WorldMapFrame, 0, 17)
BlackoutWorld:Hide()
end
end
-- format time to strings
local zonetime = string.format("%.2d:%.2d", zh, zm)
local servertime = string.format("%.2d:%.2d", sh, sm)
local time = date("%H:%M")
-- create the tooltip
GameTooltip:ClearLines()
GameTooltip:SetOwner(this, ANCHOR_BOTTOMLEFT)
GameTooltip:AddLine(T["Clock"])
GameTooltip:AddDoubleLine(T["Localtime"], time, 1,1,1,1,1,1)
GameTooltip:AddDoubleLine(T["Servertime"], servertime, 1,1,1,1,1,1)
GameTooltip:AddDoubleLine(T["Zonetime"], zonetime, 1,1,1,1,1,1)
GameTooltip:Show()
-- Trigger once after every module has handled PLAYER_ENTERING_WORLD. A
-- zero-delay ClassicAPI timer makes the result independent of event order.
local worldmapInit = CreateFrame("Frame")
worldmapInit:RegisterEvent("PLAYER_ENTERING_WORLD")
worldmapInit:SetScript("OnEvent", function()
this:UnregisterAllEvents()
this:Hide()
C_Timer.After(0, function()
WorldMapFrame_Maximize()
end)
end)
end
-- compatibility for turtle-wow's worldmap window
local HookWorldMapFrame_Maximize = WorldMapFrame_Maximize
WorldMapFrame_Maximize = function()
-- run original function
HookWorldMapFrame_Maximize()
-- re-apply worldmap window
if ShaguTweaks_config[T["WorldMap Window"]] == 1 then
WorldMapFrame:SetMovable(true)
WorldMapFrame:EnableMouse(true)
WorldMapFrame:SetScale(.85)
WorldMapFrame:ClearAllPoints()
WorldMapFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 30)
WorldMapFrame:SetWidth(WorldMapButton:GetWidth() + 15)
WorldMapFrame:SetHeight(WorldMapButton:GetHeight() + 55)
-- overwrite wrong title position set by turtlewow
WorldMapFrameTitle:SetPoint("TOP", WorldMapFrame, 0, 17)
BlackoutWorld:Hide()
end
end
-- trigger once to avoid graphical glitches
WorldMapFrame_Maximize()
-- Vendor Values exposes a lazy ClassicAPI-backed SellValueDB compatibility
-- table, so do not allocate a second Turtle-specific static price database.
+22 -15
View File
@@ -19,20 +19,9 @@ local function AddSpecialFrame(name)
end
module.enable = function(self)
AddSpecialFrame("WorldMapFrame")
-- Window mode requires a direct Show/Hide toggle instead of the stock
-- full-screen panel toggle. Install it once when this module is enabled.
if not self.toggleInstalled then
self.toggleInstalled = true
function _G.ToggleWorldMap()
if WorldMapFrame:IsShown() then
WorldMapFrame:Hide()
else
WorldMapFrame:Show()
end
end
end
-- Only advertise the window as active after the delayed compatibility check.
-- Turtle WoW consumes this flag instead of looking at config alone.
ShaguTweaks.WorldMapWindowActive = nil
-- Reuse one initialization frame so repeated enable() calls cannot stack
-- PLAYER_ENTERING_WORLD handlers or duplicate WorldMapFrame hooks.
@@ -43,13 +32,31 @@ module.enable = function(self)
local delay = self.delay
delay:RegisterEvent("PLAYER_ENTERING_WORLD")
delay:SetScript("OnEvent", function()
-- Do not interfere with dedicated map addons.
-- Do not touch the stock world-map controls at all when a dedicated map
-- addon owns them. Run this before replacing ToggleWorldMap or adding hooks.
if Cartographer or METAMAP_TITLE then
ShaguTweaks.WorldMapWindowActive = nil
this:UnregisterAllEvents()
this:Hide()
return
end
ShaguTweaks.WorldMapWindowActive = true
AddSpecialFrame("WorldMapFrame")
-- Window mode requires a direct Show/Hide toggle instead of the stock
-- full-screen panel toggle. Install it only after the compatibility check.
if not self.toggleInstalled then
self.toggleInstalled = true
function _G.ToggleWorldMap()
if WorldMapFrame:IsShown() then
WorldMapFrame:Hide()
else
WorldMapFrame:Show()
end
end
end
UIPanelWindows["WorldMapFrame"] = { area = "center" }
if not self.hooked then