mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-01 03:19:59 +00:00
ClassicAPI redirects the read of pfUI\pfUI.toc to a flavored file whenever
the DLL is installed, so which TOC the client opens already answers whether
ClassicAPI is there. Split the manifest three ways and let that do the work:
pfUI.toc fallback, reached only when ClassicAPI is missing;
loads API_Check.lua and nothing else
pfUI_ClassicAPI.toc full addon, every non-Turtle client
pfUI_Turtle.toc full addon plus init\turtle.xml, on Turtle
The fallback TOC declares no SavedVariables. It used to, while API_Check.lua
reset pfUI_profiles to an empty table on the disabled path -- which truncated
the player's profiles on logout.
With the missing-DLL case handled by TOC selection, API_Check.lua drops the
null object stub that kept the other ~140 files quiet, along with
pfUI_disabled and the now unreachable early return in pfUI.lua. It keeps the
version gate, which still matters: the flavor redirect landed in ClassicAPI
v1.11.0, below the v1.13.1 pfUI needs, so an old DLL still gets served a
flavor TOC. pfUI.lua also loses a verbatim duplicate of the whole check.
Turtle-only files move to init\turtle.xml: modules\turtle-wow.lua (its
TURTLE_WOW_VERSION guard is now redundant) and the lft, turtle_shop,
barbershop, transmog and ebc skins. turtle-wow registers last instead of
75th of 84; the only ordering it relies on is pfUI.chat, registered 8th.
pfSellData moves to env\selldata.lua, listed only in pfUI_ClassicAPI.toc,
since turtle-wow.lua replaces the table wholesale on Turtle. env\tables.lua
keeps an empty declaration so sellvalue.lua has something to index when the
turtle-wow module is disabled.
The release workflow pinned PFUI_CLASSIC_API_LATEST in pfUI.lua, which has
not held that constant since it moved to API_Check.lua, so the pin was
silently doing nothing. It also switches to brues-code/packager@vCAPI, which
recognizes the _ClassicAPI and _Turtle suffixes and applies the TOC build
type filters to them.
79 lines
3.2 KiB
Lua
79 lines
3.2 KiB
Lua
do
|
|
-- ClassicAPI dependency gate.
|
|
--
|
|
-- Which TOC the client opened already answers "is ClassicAPI here?". Whenever
|
|
-- the DLL is loaded it redirects the read of `pfUI\pfUI.toc` to
|
|
-- `pfUI_Turtle.toc` (Turtle clients) or `pfUI_ClassicAPI.toc` (everything
|
|
-- else). Reaching this file from the plain `pfUI.toc` therefore means
|
|
-- ClassicAPI is absent -- and that TOC deliberately loads nothing but this
|
|
-- file, so there is nothing to disable, only a notice to show.
|
|
--
|
|
-- The flavor TOCs still need a version gate of their own: the redirect has
|
|
-- existed since ClassicAPI v1.11.0, well below the API surface pfUI relies
|
|
-- on. There pfUI does load, and will throw wherever it reaches for something
|
|
-- the installed DLL doesn't have yet -- the popup names the cause so those
|
|
-- errors aren't a mystery.
|
|
local PFUI_CLASSIC_API_MIN = 11301 -- (X*10000 + Y*100 + Z)
|
|
local PFUI_CLASSIC_API_LATEST = PFUI_CLASSIC_API_MIN
|
|
local PFUI_CLASSIC_API_WEBSITE = "https://github.com/brues-code/ClassicAPI"
|
|
local PFUI_CLASSIC_API_LATEST_URL = PFUI_CLASSIC_API_WEBSITE .. "/releases/latest"
|
|
local function FormatVersion(packed)
|
|
local x = math.floor(packed / 10000)
|
|
local y = math.floor(math.mod(packed, 10000) / 100)
|
|
local z = math.mod(packed, 100)
|
|
return string.format("v%d.%d.%d", x, y, z)
|
|
end
|
|
|
|
local headline, detail
|
|
if not CLASSIC_API_VERSION then
|
|
headline = "|cff33ffccpf|cffffffffUI|r has been disabled."
|
|
detail = "The ClassicAPI DLL isn't loaded. Download the latest release from:"
|
|
elseif CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then
|
|
headline = "|cff33ffccpf|cffffffffUI|r cannot run on this ClassicAPI."
|
|
detail = "ClassicAPI " .. FormatVersion(PFUI_CLASSIC_API_MIN) .. " or newer is required -- any errors alongside this one are the APIs it is missing. Download the latest release from:"
|
|
end
|
|
|
|
if detail then
|
|
local function ShowRequiredPopup()
|
|
StaticPopupDialogs["PFUI_CLASSICAPI_REQUIRED"] = {
|
|
text = headline .. "\n\n" .. detail,
|
|
button1 = OKAY,
|
|
hasEditBox = 1,
|
|
editBoxWidth = 280,
|
|
timeout = 0,
|
|
whileDead = 1,
|
|
hideOnEscape = 1,
|
|
preferredIndex = 3,
|
|
OnShow = function()
|
|
local editBox = getglobal(this:GetName().."EditBox")
|
|
if editBox then
|
|
editBox:SetText(PFUI_CLASSIC_API_LATEST_URL)
|
|
editBox:HighlightText()
|
|
editBox:SetFocus()
|
|
end
|
|
end,
|
|
}
|
|
StaticPopup_Show("PFUI_CLASSICAPI_REQUIRED")
|
|
DEFAULT_CHAT_FRAME:AddMessage(
|
|
headline .. " " .. detail .. " " .. PFUI_CLASSIC_API_LATEST_URL,
|
|
1, 0.3, 0.3
|
|
)
|
|
end
|
|
local loginFrame = CreateFrame("Frame")
|
|
loginFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
loginFrame:SetScript("OnEvent", function()
|
|
loginFrame:UnregisterEvent("PLAYER_ENTERING_WORLD")
|
|
ShowRequiredPopup()
|
|
end)
|
|
elseif CLASSIC_API_VERSION < PFUI_CLASSIC_API_LATEST then
|
|
EventUtil.ContinueOnPlayerLogin(function()
|
|
C_Timer.After(8, function()
|
|
DEFAULT_CHAT_FRAME:AddMessage(
|
|
"|cff33ffccpf|rUI: ClassicAPI " .. FormatVersion(PFUI_CLASSIC_API_LATEST) .. " is available — " .. PFUI_CLASSIC_API_LATEST_URL,
|
|
1, 0.85, 0.3
|
|
)
|
|
end)
|
|
end)
|
|
end
|
|
end
|