local math_abs = _G.math.abs local math_max = _G.math.max local math_min = _G.math.min local math_clamp = _G.math.clamp or (function(value, min, max) return math_max(min, math_min(value, max)) end) local math_round = _G.math.round or (function(number) return (math_floor(number + 0.5)) end) local Parent = setmetatable({}, {}) function Parent:Constructor() if not self.Initialized then self.Initialized = true else return self; end if (type (Require) ~= 'function') then loadstring(exports['nc_libraries']:extend('Extend'), 'Require')() end if (not Responsive) then Responsive = Require('Interface/Responsive') end Require('Math') math_round = math.round self.Responsive = Responsive self.Parents = {} self.Initialized = true return self; end function Parent:Create(Name, X, Y, W, H, CenterX, CenterY) if not self.Parents[Name] then local ParentData = { x = X > 0 and math_round(self.Responsive:RespcX(X)) - self.Responsive.DifferenceX / 2 or 0, y = Y > 0 and math_round(self.Responsive:RespcY(Y)) - self.Responsive.DifferenceY / 2 or 0, w = CenterX and math_round((self.Responsive.Screen.x - self.Responsive:RespcX(W)) / 2) or self.Responsive:RespcX(W or 0, true), h = CenterY and math_round((self.Responsive.Screen.y - self.Responsive:RespcX(H)) / 2) or self.Responsive:RespcX(H or 0, true) } local Parent = setmetatable(ParentData, { __index = function(self, key) return self[key:lower()] end, __newindex = function(self, key, value) self[key:lower()] = value end }) self.Parents[Name] = Parent end return self.Parents[Name] end function Parent:CreatePure(Name, X, Y, W, H) if not self.Parents[Name] then local ParentData = { x = X, y = Y, w = W, h = H } local Parent = setmetatable(ParentData, { __index = function(self, key) return self[key:lower()] end, __newindex = function(self, key, value) self[key:lower()] = value end }) self.Parents[Name] = Parent end return self.Parents[Name] end function Parent:SetPosition(Name, X, Y, W, H, CenterX, CenterY) if not self.Parents[Name] then return false end if (CenterX and CenterY) then X = (self.Responsive.Screen.x - self.Responsive:Respc(W)) / 2 Y = (self.Responsive.Screen.y - self.Responsive:Respc(H)) / 2 end self.Parents[Name].x = X > 0 and math_round((self.Responsive.Screen.x * ((X + W) * 100 / self.Responsive.DevScreen.x) / 100) - self.Responsive:RespcX(W)) or 0 self.Parents[Name].y = Y > 0 and math_round((self.Responsive.Screen.y * ((Y + H) * 100 / self.Responsive.DevScreen.y) / 100) - self.Responsive:RespcY(H)) or 0 self.Parents[Name].w = CenterX and math_round((self.Responsive.Screen.x - self.Responsive:Respc(W)) / 2) or self.Responsive:Respc((W or 0), true) self.Parents[Name].h = CenterY and math_round((self.Responsive.Screen.y - self.Responsive:Respc(H)) / 2) or self.Responsive:Respc((H or 0), true) return true end function Parent:SetPositionPure(Name, X, Y, W, H) if not self.Parents[Name] then return false end if (X) then self.Parents[Name].x = X end if (Y) then self.Parents[Name].y = Y end if (W) then self.Parents[Name].w = W end if (H) then self.Parents[Name].h = H end return true end function Parent:SetActive(Name) self.Active = Name end function Parent:GetActive() return self.Active end function Parent:Get(Name) return self.Parents[Name] or false; end function Parent:Remove(Name) self.Parents[Name] = nil return true end function Parent:Clear() self.Parents = {} return true end _G.Parent = Parent; return Parent;