diff --git a/api/api.lua b/api/api.lua index 37bd0fcd..050c43a9 100644 --- a/api/api.lua +++ b/api/api.lua @@ -941,3 +941,57 @@ function pfUI.api.GetColorGradient(perc) gradientcolors[perc].b, gradientcolors[perc].h end + +-- [ GetNoNameObject ] -- +-- 'frame' [string] parent frame +-- 'scantype' [string] scanning Region or Children +-- 'objtype' [string] +-- 'layer' [string] +-- 'arg1' [string] +-- return object + +-- NOTE: special symbols must be escaped by the SAME symbol! +-- e.g. symbol '\': '\\' +-- symbol '-': '--' +function pfUI.api.GetNoNameObject(frame, objtype, layer, arg1, arg2) + local objects + if objtype == "Texture" or objtype == "FontString" then + objects = {frame:GetRegions()} + else + objects = {frame:GetChildren()} + end + + for _, object in ipairs(objects) do + local check = true + if object:GetObjectType() ~= objtype or (layer and object:GetDrawLayer() ~= layer) then check = false end + + if check then + if objtype == "Texture" and object.SetTexture and object:GetTexture() ~= "Interface\\BUTTONS\\WHITE8X8" then + if arg1 then + local texture = object:GetTexture() + if texture and not string.find(texture, arg1) then check = false end + end + + if check then return object end + elseif objtype == "FontString" and object.SetText then + if arg1 then + local text = object:GetText() + if text and not string.find(text, arg1) then check = false end + end + + if check then return object end + elseif objtype == "Button" and object.GetNormalTexture and object:GetNormalTexture() then + if arg1 then + local texture = object:GetNormalTexture():GetTexture() + if texture and not string.find(texture, arg1) then check = false end + end + if arg2 then + local text = object:GetText() + if text and not string.find(text, arg2) then check = false end + end + + if check then return object end + end + end + end +end