local l=Roact.PureComponent:extend(script.Name)function l.init(l)l:UpdateHotkeyTextSize(l.props.HotkeyLabel)end function l.willUpdate(G,l)if G.props.HotkeyLabel~=l.HotkeyLabel then G:UpdateHotkeyTextSize(l.HotkeyLabel)end end function l.UpdateHotkeyTextSize(G,l)G.HotkeyTextSize=TextService:GetTextSize(l,9,Enum.Font.Gotham,Vector2.new(math.huge,math.huge))end function l.render(l)return new("\073\109\097\103\101\066\117\116\116\111\110",{BackgroundColor3=l.props.Tool.Color.Color;BackgroundTransparency=l.props.CurrentTool==l.props.Tool and 0 or 1,BorderSizePixel=0;Image=l.props.IconAssetId;AutoButtonColor=false;[Roact.Event.Activated]=function()l.props.Core.EquipTool(l.props.Tool)end},{Corners=new("\085\073\067\111\114\110\101\114",{CornerRadius=UDim.new(0,3)}),Hotkey=new("\084\101\120\116\076\097\098\101\108",{BackgroundTransparency=1;Position=UDim2.new(0,3,0,3),Size=UDim2.fromOffset(l.HotkeyTextSize.X,l.HotkeyTextSize.Y),Font=Enum.Font.Gotham;Text=l.props.HotkeyLabel;TextColor3=Color3.fromRGB(255,255,255),TextSize=9,TextXAlignment=Enum.TextXAlignment.Left;TextYAlignment=Enum.TextYAlignment.Top})})end return l

local ToolButton = Roact.PureComponent:extend(script.Name)

function ToolButton:init()
    self:UpdateHotkeyTextSize(self.props.HotkeyLabel)
end

function ToolButton:willUpdate(nextProps)
    if self.props.HotkeyLabel ~= nextProps.HotkeyLabel then
        self:UpdateHotkeyTextSize(nextProps.HotkeyLabel)
    end
end

function ToolButton:UpdateHotkeyTextSize(Text)
    self.HotkeyTextSize = TextService:GetTextSize(
        Text,
        9,
        Enum.Font.Gotham,
        Vector2.new(math.huge, math.huge)
    )
end

function ToolButton:render()
    return new('ImageButton', {
        BackgroundColor3 = self.props.Tool.Color.Color;
        BackgroundTransparency = (self.props.CurrentTool == self.props.Tool) and 0 or 1;
        BorderSizePixel = 0;
        Image = self.props.IconAssetId;
        AutoButtonColor = false;
        [Roact.Event.Activated] = function ()
            self.props.Core.EquipTool(self.props.Tool)
        end;
    }, {
        Corners = new('UICorner', {
            CornerRadius = UDim.new(0, 3);
        });
        Hotkey = new('TextLabel', {
            BackgroundTransparency = 1;
            Position = UDim2.new(0, 3, 0, 3);
            Size = UDim2.fromOffset(self.HotkeyTextSize.X, self.HotkeyTextSize.Y);
            Font = Enum.Font.Gotham;
            Text = self.props.HotkeyLabel;
            TextColor3 = Color3.fromRGB(255, 255, 255);
            TextSize = 9;
            TextXAlignment = Enum.TextXAlignment.Left;
            TextYAlignment = Enum.TextYAlignment.Top;
        });
    })
end

return ToolButton
