added some nil checks for api.lua

This commit is contained in:
Meow
2026-03-31 04:29:39 +02:00
parent 88c8968158
commit df532862b6
+6 -2
View File
@@ -1233,7 +1233,9 @@ end
function pfUI.api.BarLayoutSize(bar,barsize,formfactor,iconsize,bordersize,padding)
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutSize: barsize "..tostring(barsize).." is invalid")
local formfactor = pfUI.api.BarLayoutFormfactor(formfactor)
local cols, rows = unpack(pfGridmath[barsize][formfactor])
local layout = pfGridmath[barsize] and pfGridmath[barsize][formfactor or 1]
if not layout then layout = pfGridmath[barsize] and pfGridmath[barsize][1] or {1,1} end
local cols, rows = unpack(layout)
local width = (iconsize + bordersize*2+padding) * cols + padding
local height = (iconsize + bordersize*2+padding) * rows + padding
bar._size = {width,height}
@@ -1252,7 +1254,9 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarButtonAnchor: barsize "..tostring(barsize).." is invalid")
local formfactor = pfUI.api.BarLayoutFormfactor(formfactor)
local parent = button:GetParent()
local cols, rows = unpack(pfGridmath[barsize][formfactor])
local layout = pfGridmath[barsize] and pfGridmath[barsize][formfactor or 1]
if not layout then layout = pfGridmath[barsize] and pfGridmath[barsize][1] or {1,1} end
local cols, rows = unpack(layout)
if buttonindex == 1 then
button._anchor = {"TOPLEFT", parent, "TOPLEFT", bordersize+padding, -bordersize-padding}
else