function IconController._updateSelectionGroup(J,C)if IconController._navigationEnabled then guiService:RemoveSelectionGroup("\084\111\112\098\097\114\080\108\117\115\073\099\111\110\115")end if C then guiService.CoreGuiNavigationEnabled=IconController._originalCoreGuiNavigationEnabled guiService.GuiNavigationEnabled=IconController._originalGuiNavigationEnabled IconController._navigationEnabled=nil elseif IconController.controllerModeEnabled then local C=IconController.getIcons()local J={}for C,t in pairs(C)do local O=t.joinedFeatureName if not O or t._parentIcon[t.joinedFeatureName.."\079\112\101\110"]==true then table.insert(J,t.instances.iconButton)end end guiService:AddSelectionTuple("\084\111\112\098\097\114\080\108\117\115\073\099\111\110\115",table.unpack(J))if not IconController._navigationEnabled then IconController._originalCoreGuiNavigationEnabled=guiService.CoreGuiNavigationEnabled IconController._originalGuiNavigationEnabled=guiService.GuiNavigationEnabled guiService.CoreGuiNavigationEnabled=false guiService.GuiNavigationEnabled=true IconController._navigationEnabled=true end end end local function C()if guiService:IsTenFootInterface()then return 3 else return 1.3 end end function IconController._setControllerSelectedObject(C)local J=IconController._controllerSetCount and IconController._controllerSetCount+1 or 0 IconController._controllerSetCount=J guiService.SelectedObject=C delay(.1,function()local t=IconController._controllerSetCount if J==t then guiService.SelectedObject=C end end)end function IconController._enableControllerMode(J)local t=TopbarPlusGui.Indicator local O=IconController.getIcon("\095\084\111\112\098\097\114\067\111\110\116\114\111\108\108\101\114\079\112\116\105\111\110")if IconController.controllerModeEnabled==J then return end IconController.controllerModeEnabled=J if J then TopbarPlusGui.TopbarContainer.Position=UDim2.new(0,0,0,5)TopbarPlusGui.TopbarContainer.Visible=false local J=C()t.Position=UDim2.new(.5,0,0,5)t.Size=UDim2.new(0,18*J,0,18*J)t.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\050\055\056\049\053\049\053\053\054"t.Visible=checkTopbarEnabled()t.Position=UDim2.new(.5,0,0,5)else TopbarPlusGui.TopbarContainer.Position=UDim2.new(0,0,0,0)TopbarPlusGui.TopbarContainer.Visible=checkTopbarEnabled()t.Visible=false IconController._setControllerSelectedObject(nil)end for C,t in pairs(topbarIcons)do IconController._enableControllerModeForIcon(C,J)end end function IconController._enableControllerModeForIcon(J,t)local O=J._parentIcon local m=J.joinedFeatureName if O then J:leave()end if t then local t=C()local O=J:get("\105\099\111\110\083\105\122\101","\100\101\115\101\108\101\099\116\101\100")local m=J:get("\105\099\111\110\083\105\122\101","\115\101\108\101\099\116\101\100")J:set("\105\099\111\110\083\105\122\101",UDim2.new(0,O.X.Offset*t,0,O.Y.Offset*t),"\100\101\115\101\108\101\099\116\101\100","\099\111\110\116\114\111\108\108\101\114\077\111\100\101")J:set("\105\099\111\110\083\105\122\101",UDim2.new(0,m.X.Offset*t,0,m.Y.Offset*t),"\115\101\108\101\099\116\101\100","\099\111\110\116\114\111\108\108\101\114\077\111\100\101")J:set("\097\108\105\103\110\109\101\110\116","\109\105\100","\100\101\115\101\108\101\099\116\101\100","\099\111\110\116\114\111\108\108\101\114\077\111\100\101")J:set("\097\108\105\103\110\109\101\110\116","\109\105\100","\115\101\108\101\099\116\101\100","\099\111\110\116\114\111\108\108\101\114\077\111\100\101")else local C={"\100\101\115\101\108\101\099\116\101\100";"\115\101\108\101\099\116\101\100"}for C,t in pairs(C)do local O,m=J:get("\097\108\105\103\110\109\101\110\116",t,"\099\111\110\116\114\111\108\108\101\114\077\111\100\101")if m then J:set("\097\108\105\103\110\109\101\110\116",m,t)end local h,g=J:get("\105\099\111\110\083\105\122\101",t,"\099\111\110\116\114\111\108\108\101\114\077\111\100\101")if g then J:set("\105\099\111\110\083\105\122\101",g,t)end end end if O then J:join(O,m)end end
-- PRIVATE METHODS
function IconController:_updateSelectionGroup(clearAll)
	if IconController._navigationEnabled then
		guiService:RemoveSelectionGroup("TopbarPlusIcons")
	end
	if clearAll then
		guiService.CoreGuiNavigationEnabled = IconController._originalCoreGuiNavigationEnabled
		guiService.GuiNavigationEnabled = IconController._originalGuiNavigationEnabled
		IconController._navigationEnabled = nil
	elseif IconController.controllerModeEnabled then
		local icons = IconController.getIcons()
		local iconContainers = {}
		for i, otherIcon in pairs(icons) do
			local featureName = otherIcon.joinedFeatureName
			if not featureName or otherIcon._parentIcon[otherIcon.joinedFeatureName .. "Open"] == true then
				table.insert(iconContainers, otherIcon.instances.iconButton)
			end
		end
		guiService:AddSelectionTuple("TopbarPlusIcons", table.unpack(iconContainers))
		if not IconController._navigationEnabled then
			IconController._originalCoreGuiNavigationEnabled = guiService.CoreGuiNavigationEnabled
			IconController._originalGuiNavigationEnabled = guiService.GuiNavigationEnabled
			guiService.CoreGuiNavigationEnabled = false
			guiService.GuiNavigationEnabled = true
			IconController._navigationEnabled = true
		end
	end
end

local function getScaleMultiplier()
	if guiService:IsTenFootInterface() then
		return 3
	else
		return 1.3
	end
end

function IconController._setControllerSelectedObject(object)
	local startId = (IconController._controllerSetCount and IconController._controllerSetCount + 1) or 0
	IconController._controllerSetCount = startId
	guiService.SelectedObject = object
	delay(0.1, function() -- blame the roblox guiservice its a piece of doo doo
		local finalId = IconController._controllerSetCount
		if startId == finalId then
			guiService.SelectedObject = object
		end
	end)
end

function IconController._enableControllerMode(bool)
	local indicator = TopbarPlusGui.Indicator
	local controllerOptionIcon = IconController.getIcon("_TopbarControllerOption")
	if IconController.controllerModeEnabled == bool then
		return
	end
	IconController.controllerModeEnabled = bool
	if bool then
		TopbarPlusGui.TopbarContainer.Position = UDim2.new(0, 0, 0, 5)
		TopbarPlusGui.TopbarContainer.Visible = false
		local scaleMultiplier = getScaleMultiplier()
		indicator.Position = UDim2.new(0.5, 0, 0, 5)
		indicator.Size = UDim2.new(0, 18 * scaleMultiplier, 0, 18 * scaleMultiplier)
		indicator.Image = "rbxassetid://5278151556"
		indicator.Visible = checkTopbarEnabled()
		indicator.Position = UDim2.new(0.5, 0, 0, 5)
	else
		TopbarPlusGui.TopbarContainer.Position = UDim2.new(0, 0, 0, 0)
		TopbarPlusGui.TopbarContainer.Visible = checkTopbarEnabled()
		indicator.Visible = false
		IconController._setControllerSelectedObject(nil)
	end
	for icon, _ in pairs(topbarIcons) do
		IconController._enableControllerModeForIcon(icon, bool)
	end
end

function IconController._enableControllerModeForIcon(icon, bool)
	local parentIcon = icon._parentIcon
	local featureName = icon.joinedFeatureName
	if parentIcon then
		icon:leave()
	end
	if bool then
		local scaleMultiplier = getScaleMultiplier()
		local currentSizeDeselected = icon:get("iconSize", "deselected")
		local currentSizeSelected = icon:get("iconSize", "selected")
		icon:set(
			"iconSize",
			UDim2.new(
				0,
				currentSizeDeselected.X.Offset * scaleMultiplier,
				0,
				currentSizeDeselected.Y.Offset * scaleMultiplier
			),
			"deselected",
			"controllerMode"
		)
		icon:set(
			"iconSize",
			UDim2.new(
				0,
				currentSizeSelected.X.Offset * scaleMultiplier,
				0,
				currentSizeSelected.Y.Offset * scaleMultiplier
			),
			"selected",
			"controllerMode"
		)
		icon:set("alignment", "mid", "deselected", "controllerMode")
		icon:set("alignment", "mid", "selected", "controllerMode")
	else
		local states = { "deselected", "selected" }
		for _, toggleState in pairs(states) do
			local _, previousAlignment = icon:get("alignment", toggleState, "controllerMode")
			if previousAlignment then
				icon:set("alignment", previousAlignment, toggleState)
			end
			local currentSize, previousSize = icon:get("iconSize", toggleState, "controllerMode")
			if previousSize then
				icon:set("iconSize", previousSize, toggleState)
			end
		end
	end
	if parentIcon then
		icon:join(parentIcon, featureName)
	end
end
