local D=Roact.PureComponent:extend(script.Name)function D.init(D)D.Maid=Maid.new()D.CanvasSize,D.SetCanvasSize=Roact.createBinding(UDim2.new())D:setState({CurrentTool=D.props.Core.CurrentTool})D.Maid.CurrentTool=D.props.Core.ToolChanged:Connect(function(R)D:setState({CurrentTool=R})end)end function D.render(D)local R={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(R)if R then D.SetCanvasSize(UDim2.fromOffset(R.AbsoluteContentSize.X,R.AbsoluteContentSize.Y))end end,[Roact.Change.AbsoluteContentSize]=function(R)D.SetCanvasSize(UDim2.fromOffset(R.AbsoluteContentSize.X,R.AbsoluteContentSize.Y))end})}for j,Y in ipairs(D.props.Tools)do R[tostring(j)]=new(ToolButton,{CurrentTool=D.state.CurrentTool;IconAssetId=Y.IconAssetId;HotkeyLabel=Y.HotkeyLabel,Tool=Y.Tool;Core=D.props.Core})end return new("\070\114\097\109\101",{BackgroundTransparency=.8;BackgroundColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0,LayoutOrder=D.props.LayoutOrder,Size=D.CanvasSize:map(function(D)return UDim2.fromOffset(D.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=D.CanvasSize,ScrollBarThickness=1,ScrollingDirection=Enum.ScrollingDirection.Y;ScrollBarImageColor3=Color3.fromRGB(0,0,0);[Roact.Children]=R})})end return D

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
