local I=Roact.PureComponent:extend(script.Name)function I.init(I)I.Maid=Maid.new()I.CanvasSize,I.SetCanvasSize=Roact.createBinding(UDim2.new())I:setState({CurrentTool=I.props.Core.CurrentTool})I.Maid.CurrentTool=I.props.Core.ToolChanged:Connect(function(q)I:setState({CurrentTool=q})end)end function I.render(I)local q={Layout=new("\085\073\071\114\105\100\076\097\121\111\117\116",{CellPadding=UDim2.new(0,0,0,0),CellSize=UDim2.new(0,35,0,35);FillDirection=Enum.FillDirection.Horizontal;FillDirectionMaxCells=2,HorizontalAlignment=Enum.HorizontalAlignment.Left,VerticalAlignment=Enum.VerticalAlignment.Top,SortOrder=Enum.SortOrder.LayoutOrder;StartCorner=Enum.StartCorner.TopLeft,[Roact.Ref]=function(q)if q then I.SetCanvasSize(UDim2.fromOffset(q.AbsoluteContentSize.X,q.AbsoluteContentSize.Y))end end,[Roact.Change.AbsoluteContentSize]=function(q)I.SetCanvasSize(UDim2.fromOffset(q.AbsoluteContentSize.X,q.AbsoluteContentSize.Y))end})}for H,B in ipairs(I.props.Tools)do q[tostring(H)]=new(ToolButton,{CurrentTool=I.state.CurrentTool;IconAssetId=B.IconAssetId,HotkeyLabel=B.HotkeyLabel;Tool=B.Tool;Core=I.props.Core})end return new("\070\114\097\109\101",{BackgroundTransparency=.8;BackgroundColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0,LayoutOrder=I.props.LayoutOrder;Size=I.CanvasSize:map(function(I)return UDim2.fromOffset(I.X.Offset,245)end)},{Corners=new("\085\073\067\111\114\110\101\114",{CornerRadius=UDim.new(0,3)}),SizeConstraint=new("\085\073\083\105\122\101\067\111\110\115\116\114\097\105\110\116",{MinSize=Vector2.new(70,0)}),List=new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101",{BackgroundTransparency=1,BorderSizePixel=0;Size=UDim2.new(1,0,1,0);CanvasSize=I.CanvasSize,ScrollBarThickness=1;ScrollingDirection=Enum.ScrollingDirection.Y;ScrollBarImageColor3=Color3.fromRGB(0,0,0);[Roact.Children]=q})})end return I
-- Create component
local ToolList = Roact.PureComponent:extend(script.Name)

function ToolList:init()
	self.Maid = Maid.new()
	self.CanvasSize, self.SetCanvasSize = Roact.createBinding(UDim2.new())

	-- Track current tool
	self:setState({
		CurrentTool = self.props.Core.CurrentTool,
	})
	self.Maid.CurrentTool = self.props.Core.ToolChanged:Connect(function(Tool)
		self:setState({
			CurrentTool = Tool,
		})
	end)
end

function ToolList:render()
	local Children = {
		Layout = new("UIGridLayout", {
			CellPadding = UDim2.new(0, 0, 0, 0),
			CellSize = UDim2.new(0, 35, 0, 35),
			FillDirection = Enum.FillDirection.Horizontal,
			FillDirectionMaxCells = 2,
			HorizontalAlignment = Enum.HorizontalAlignment.Left,
			VerticalAlignment = Enum.VerticalAlignment.Top,
			SortOrder = Enum.SortOrder.LayoutOrder,
			StartCorner = Enum.StartCorner.TopLeft,
			[Roact.Ref] = function(rbx)
				if rbx then
					self.SetCanvasSize(UDim2.fromOffset(rbx.AbsoluteContentSize.X, rbx.AbsoluteContentSize.Y))
				end
			end,
			[Roact.Change.AbsoluteContentSize] = function(rbx)
				self.SetCanvasSize(UDim2.fromOffset(rbx.AbsoluteContentSize.X, rbx.AbsoluteContentSize.Y))
			end,
		}),
	}

	-- Build buttons for each tool
	for ToolIndex, ToolInfo in ipairs(self.props.Tools) do
		Children[tostring(ToolIndex)] = new(ToolButton, {
			CurrentTool = self.state.CurrentTool,
			IconAssetId = ToolInfo.IconAssetId,
			HotkeyLabel = ToolInfo.HotkeyLabel,
			Tool = ToolInfo.Tool,
			Core = self.props.Core,
		})
	end

	return new("Frame", {
		BackgroundTransparency = 0.8,
		BackgroundColor3 = Color3.fromRGB(0, 0, 0),
		BorderSizePixel = 0,
		LayoutOrder = self.props.LayoutOrder,
		Size = self.CanvasSize:map(function(CanvasSize)
			return UDim2.fromOffset(CanvasSize.X.Offset, 35 * 7)
		end),
	}, {
		Corners = new("UICorner", {
			CornerRadius = UDim.new(0, 3),
		}),
		SizeConstraint = new("UISizeConstraint", {
			MinSize = Vector2.new(70, 0),
		}),
		List = new("ScrollingFrame", {
			BackgroundTransparency = 1,
			BorderSizePixel = 0,
			Size = UDim2.new(1, 0, 1, 0),
			CanvasSize = self.CanvasSize,
			ScrollBarThickness = 1,
			ScrollingDirection = Enum.ScrollingDirection.Y,
			ScrollBarImageColor3 = Color3.fromRGB(0, 0, 0),
			[Roact.Children] = Children,
		}),
	})
end

return ToolList
