local A=script.Parent.Parent local m=require(A:WaitForChild("\076\097\122\121\076\111\097\100\101\114"))local Y=A:WaitForChild("\068\101\102\097\117\108\116\115")local x=Y:WaitForChild("\076\105\115\116\066\117\116\116\111\110")local a={SortOrder=Enum.SortOrder.LayoutOrder}local function s(A,m)local Y=x:Clone()Y.Name=m.."\095\098\117\116\116\111\110"Y.Label.Text=m return Y end local t={}function t.Create(A,m,Y,x,a)m=m or math.huge x=x or UDim.new(0,0)Y=Y or Enum.FillDirection.Vertical a=a or s local t=#A local I=1/t local Q=Y==Enum.FillDirection.Vertical local Z=Instance.new("\070\114\097\109\101")Z.Name="\076\105\115\116\070\114\097\109\101"Z.BorderSizePixel=0 local W=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")W.Name="\083\099\114\111\108\108\070\114\097\109\101"W.BackgroundTransparency=1 W.BorderSizePixel=0 W.Size=UDim2.new(1,0,1,0)local D=nil local o=nil local P=nil local q=(t-1)/t local i=x.Scale*q local c=x.Offset*q if Q then D=UDim2.new(0,0,t/m,0)o=UDim2.new(1,0,I-i,-c)else D=UDim2.new(t/m,0,0,0)o=UDim2.new(I-i,-c,1,0)end W.CanvasSize=D local j={}for A,m in ipairs(A)do local Y=a(A,m)Y.LayoutOrder=A Y.Size=o Y.Position=UDim2.new(0,0,(A-1)*I,0)if Q then Y.Position=Y.Position+UDim2.new(0,0,(x.Scale/t)*(A-1),(x.Offset/t)*(A-1))else Y.Position=Y.Position+UDim2.new((x.Scale/t)*(A-1),(x.Offset/t)*(A-1),0,0)end j[A]=Y Y.Parent=W end Z.BackgroundTransparency=j[1].BackgroundTransparency Z.BackgroundColor3=j[1].BackgroundColor3 W.Parent=Z return Z end return t
--[[
Constructors.List

This module provides a set of functions useful for generating lists that can be scrolled through.

This module only has one function:

List.Create(
	string[] list, -- an array of strings used to generate instances for the list
	integer scrollMax, -- the maximum number of elements visible in the scroll frame at any given time. Defaults to math.huge
	enum fillDirection, -- Enum.FillDirection lets you decide if the list is vertical or horizontal. Defaults to verical
	udim padding, -- scale and offset for padding between instances. Defaults to no padding
	function instanceFunc -- must return a UI object such as a frame. Defaults to creating a textbutton with a child textlabel
)

--]]

-- CONSTANTS

local GuiLib = script.Parent.Parent
local Lazy = require(GuiLib:WaitForChild("LazyLoader"))
local Defaults = GuiLib:WaitForChild("Defaults")

local LIST_BUTTON = Defaults:WaitForChild("ListButton")

local DEFAULT_LAYOUT = {
	SortOrder = Enum.SortOrder.LayoutOrder
}

-- Private Functions

local function defaultButton(index, option)
	local button = LIST_BUTTON:Clone()
	button.Name = option .. "_button"
	button.Label.Text = option
	return button
end

-- Library

local List = {}

function List.Create(list, max, fillDirection, padding, instanceFunc)
	max = max or math.huge
	padding = padding or UDim.new(0, 0)
	fillDirection = fillDirection or Enum.FillDirection.Vertical
	instanceFunc = instanceFunc or defaultButton

	local nList = #list
	local dList = 1 / nList
	
	local isVertical = (fillDirection == Enum.FillDirection.Vertical)
	
	local listFrame = Instance.new("Frame")
	listFrame.Name = "ListFrame"
	listFrame.BorderSizePixel = 0 
	
	local scrollFrame = Instance.new("ScrollingFrame")
	scrollFrame.Name = "ScrollFrame"
	scrollFrame.BackgroundTransparency = 1
	scrollFrame.BorderSizePixel = 0
	scrollFrame.Size = UDim2.new(1, 0, 1, 0)
	
	local canvasSize = nil	
	local elementSize = nil
	local extraPosition = nil
	
	local adj = (nList - 1) / nList
	local scale = padding.Scale * adj
	local offset = padding.Offset * adj
	
	if (isVertical) then
		canvasSize = UDim2.new(0, 0, nList / max, 0) 
		elementSize = UDim2.new(1, 0, dList - scale, -offset)
	else
		canvasSize = UDim2.new(nList / max , 0, 0, 0)
		elementSize = UDim2.new(dList - scale, -offset, 1, 0)
	end
	
	scrollFrame.CanvasSize = canvasSize
	
	local items = {}
	for i, option in ipairs(list) do
		local item = instanceFunc(i, option)
		item.LayoutOrder = i
		item.Size = elementSize
		item.Position = UDim2.new(0, 0, (i-1)*dList, 0)
		
		if (isVertical) then
			item.Position = item.Position + UDim2.new(0, 0, padding.Scale/nList*(i-1), padding.Offset/nList*(i-1))
		else
			item.Position = item.Position + UDim2.new(padding.Scale/nList*(i-1), padding.Offset/nList*(i-1), 0, 0)
		end
		
		items[i] = item
		item.Parent = scrollFrame
	end
	
	listFrame.BackgroundTransparency = items[1].BackgroundTransparency
	listFrame.BackgroundColor3 = items[1].BackgroundColor3
	scrollFrame.Parent = listFrame
	
	return listFrame	
end

--

return List