Replace pfUI's clamp/isempty/modf with ClassicAPI's Clamp/TableIsEmpty

The world map's shift/ctrl wheel alpha and scale use Clamp, and the
fresh-install profile check uses TableIsEmpty (pfUI_init and pfUI_config
are always tables by then). modf only wrapped math.modf and had no callers.
This commit is contained in:
Brues
2026-10-31 15:47:52 -05:00
parent 3b64bfa98b
commit 2b7febf617
3 changed files with 3 additions and 33 deletions
-30
View File
@@ -84,14 +84,6 @@ mod = math.mod or mod
-- strsplit calls inside the pfUI environment resolve to this copy.
pfUI.api.strsplit = ClassicAPI.strsplit
-- [ isempty ]
-- Returns true if a table is empty or not existing, otherwise false.
-- 'tbl' [table] the table that shall be checked
-- return: [boolean] result of the check.
function pfUI.api.isempty(tbl)
return next(tbl or {}) == nil
end
-- [ checkversion ]
-- Compares a given version (major,minor,fix) and compares it to the current
-- 'chkmajor' [number] the major number to check
@@ -271,28 +263,6 @@ function pfUI.api.round(input, places)
end
end
-- [ clamp ]
-- Clamps a number between given range.
-- 'x' [number] the number that should be clamped.
-- 'min' [number] minimum value.
-- 'max' [number] maximum value.
-- returns: [number] clamped value: 'x', 'min' or 'max' value itself.
function pfUI.api.clamp(x, min, max)
if type(x) == "number" and type(min) == "number" and type(max) == "number" then
return x < min and min or x > max and max or x
else
return x
end
end
-- [ modf ]
-- Returns integral and fractional part of a number.
-- 'f' [float] the number to breakdown.
-- returns: [int],[float] whole and fractional part.
function pfUI.api.modf(f)
return math.modf(f)
end
-- [ GetServerEpoch ]
-- Returns a Unix epoch (seconds) representing the current server wall
-- clock, packed in the player's local timezone so that date(fmt, epoch)
+2 -2
View File
@@ -67,14 +67,14 @@ pfUI:RegisterModule("map", function ()
WorldMapFrame:HookScript("OnMouseWheel", function()
if IsShiftKeyDown() then
alpha = clamp(WorldMapFrame:GetAlpha() + arg1/10, 0.1, 1.0)
alpha = Clamp(WorldMapFrame:GetAlpha() + arg1/10, 0.1, 1.0)
WorldMapFrame:SetAlpha(alpha)
end
if IsControlKeyDown() then
local oldscale = WorldMapFrame:GetScale()
local point, rel, relpoint, offx, offy = WorldMapFrame:GetPoint()
scale = clamp(oldscale + arg1/10, 0.1, 2.0)
scale = Clamp(oldscale + arg1/10, 0.1, 2.0)
-- recalculate world frame position based on old and new scale
if point == "TOPLEFT" and relpoint == "TOPLEFT" then
+1 -1
View File
@@ -376,7 +376,7 @@ pfUI:SetScript("OnEvent", function()
end
-- use "Modern" as default profile on a fresh install
if pfUI.api.isempty(pfUI_init) and pfUI.api.isempty(pfUI_config) then
if TableIsEmpty(pfUI_init) and TableIsEmpty(pfUI_config) then
pfUI_config = pfUI.api.CopyTable(pfUI_profiles["Modern"]) or {}
end