local x=0 IconController.iconAdded:Connect(function(k)topbarIcons[k]=true if IconController.gameTheme then k:setTheme(IconController.gameTheme)end k.updated:Connect(function()local x=k:get("\116\111\103\103\108\101\084\114\097\110\115\105\116\105\111\110\073\110\102\111")IconController.updateTopbar(x)end)k.selected:Connect(function()local x=IconController.getIcons()for x,i in pairs(x)do if k.deselectWhenOtherIconSelected and(i~=k and(i.deselectWhenOtherIconSelected and i:getToggleState()=="\115\101\108\101\099\116\101\100"))then i:deselect(k)end end end)x=x+1 if not k._orderWasSet then k:setOrder(x)end if IconController.controllerModeEnabled then IconController._enableControllerModeForIcon(k,true)end IconController:_updateSelectionGroup()end)IconController.iconRemoved:Connect(function(x)topbarIcons[x]=nil x:setEnabled(false)x:deselect()x.updated:Fire()IconController:_updateSelectionGroup()end)
-- CONNECTIONS
local iconCreationCount = 0
IconController.iconAdded:Connect(function(icon)
	topbarIcons[icon] = true
	if IconController.gameTheme then
		icon:setTheme(IconController.gameTheme)
	end
	icon.updated:Connect(function()
		local toggleTransitionInfo = icon:get("toggleTransitionInfo")
		IconController.updateTopbar(toggleTransitionInfo)
	end)
	-- When this icon is selected, deselect other icons if necessary
	icon.selected:Connect(function()
		local allIcons = IconController.getIcons()
		for _, otherIcon in pairs(allIcons) do
			if
				icon.deselectWhenOtherIconSelected
				and otherIcon ~= icon
				and otherIcon.deselectWhenOtherIconSelected
				and otherIcon:getToggleState() == "selected"
			then
				otherIcon:deselect(icon)
			end
		end
	end)
	-- Order by creation if no order specified
	iconCreationCount = iconCreationCount + 1
	if not icon._orderWasSet then
		icon:setOrder(iconCreationCount)
	end
	-- Apply controller view if enabled
	if IconController.controllerModeEnabled then
		IconController._enableControllerModeForIcon(icon, true)
	end
	IconController:_updateSelectionGroup()
end)

IconController.iconRemoved:Connect(function(icon)
	topbarIcons[icon] = nil
	icon:setEnabled(false)
	icon:deselect()
	icon.updated:Fire()
	IconController:_updateSelectionGroup()
end)
