DEFAULT_FORCED_GROUP_VALUES.tip=1 function Icon.setTip(Y,u)assert(typeof(u)=="\115\116\114\105\110\103"or u==nil,"\069\120\112\101\099\116\101\100 \115\116\114\105\110\103\044 \103\111\116 "..typeof(u))local M=u or""local G=M~=""Y.tipText=u Y.instances.tipLabel.Text=M Y.instances.tipFrame.Parent=G and activeItems or Y.instances.iconContainer Y._maid.tipFrame=Y.instances.tipFrame Y:_updateTipSize()local r=Maid.new()Y._maid.tipMaid=r if G then r:give(Y.hoverStarted:Connect(function()if not Y.isSelected then Y:displayTip(true)end end))r:give(Y.hoverEnded:Connect(function()Y:displayTip(false)end))r:give(Y.selected:Connect(function()if Y.hovering then Y:displayTip(false)end end))end Y:displayTip(Y.hovering and G)return Y end function Icon._updateTipSize(u)local Y=u.tipText or""local M=Y~=""local G=u:_getContentText(Y)local r=textService:GetTextSize(G,12,Enum.Font.GothamSemibold,Vector2.new(1000,14))u.instances.tipFrame.Size=M and UDim2.new(0,r.X+6,0,20)or UDim2.new(0,0,0,0)end function Icon.displayTip(Y,u)if userInputService.TouchEnabled and not Y._draggingFinger then return end local M=Y.tipVisible or false if typeof(u)=="\098\111\111\108\101\097\110"then M=u end Y.tipVisible=M local G=Y.instances.tipFrame if M then local function u(u,Y)local M=u local r=Y local x=workspace.CurrentCamera local j=x and x.ViewportSize if userInputService.TouchEnabled then local u=M-G.Size.X.Offset/2 local Y=0 local x=j.X-G.Size.X.Offset local k=(r+THUMB_OFFSET)+60 local y=((G.AbsoluteSize.Y+THUMB_OFFSET)+64)+3 local o=j.Y-G.Size.Y.Offset M=math.clamp(u,Y,x)r=math.clamp(k,y,o)elseif IconController.controllerModeEnabled then local u=TopbarPlusGui.Indicator local Y=u.AbsolutePosition M=(Y.X-G.Size.X.Offset/2)+u.AbsoluteSize.X/2 r=Y.Y+90 else local u=M local Y=0 local x=(j.X-G.Size.X.Offset)-48 local k=r local y=G.Size.Y.Offset+3 local o=j.Y M=math.clamp(u,Y,x)r=math.clamp(k,y,o)end G.Position=UDim2.new(0,M,0,r-20)end local M=userInputService:GetMouseLocation()if M then u(M.X,M.Y)end Y._hoveringMaid:give(Y.instances.iconButton.MouseMoved:Connect(u))end for u,G in pairs(Y._groupSettings.tip)do local r=Y._settingsDictionary[G]r.useForcedGroupValue=not M Y:_update(G)end end

DEFAULT_FORCED_GROUP_VALUES["tip"] = 1

function Icon:setTip(text)
	assert(typeof(text) == "string" or text == nil, "Expected string, got "..typeof(text))
	local realText = text or ""
	local isVisible = realText ~= ""
	self.tipText = text
	self.instances.tipLabel.Text = realText
	self.instances.tipFrame.Parent = (isVisible and activeItems) or self.instances.iconContainer
	self._maid.tipFrame = self.instances.tipFrame
	self:_updateTipSize()
	
	local tipMaid = Maid.new()
	self._maid.tipMaid = tipMaid
	if isVisible then
		tipMaid:give(self.hoverStarted:Connect(function()
			if not self.isSelected then
				self:displayTip(true)
			end
		end))
		tipMaid:give(self.hoverEnded:Connect(function()
			self:displayTip(false)
		end))
		tipMaid:give(self.selected:Connect(function()
			if self.hovering then
				self:displayTip(false)
			end
		end))
	end
	self:displayTip(self.hovering and isVisible)
	return self
end

function Icon:_updateTipSize()
	local realText = self.tipText or ""
	local isVisible = realText ~= ""
	local iconContentText = self:_getContentText(realText)
	local textSize = textService:GetTextSize(iconContentText, 12, Enum.Font.GothamSemibold, Vector2.new(1000, 20-6))
	self.instances.tipFrame.Size = (isVisible and UDim2.new(0, textSize.X+6, 0, 20)) or UDim2.new(0, 0, 0, 0)
end

function Icon:displayTip(bool)
	if userInputService.TouchEnabled and not self._draggingFinger then return end

	-- Determine caption visibility
	local isVisible = self.tipVisible or false
	if typeof(bool) == "boolean" then
		isVisible = bool
	end
	self.tipVisible = isVisible

	-- Have tip position track mouse or finger
	local tipFrame = self.instances.tipFrame
	if isVisible then
		-- When the user moves their cursor/finger, update tip to match the position
		local function updateTipPositon(x, y)
			local newX = x
			local newY = y
			local camera = workspace.CurrentCamera
			local viewportSize = camera and camera.ViewportSize
			if userInputService.TouchEnabled then
				--tipFrame.AnchorPoint = Vector2.new(0.5, 0.5)
				local desiredX = newX - tipFrame.Size.X.Offset/2
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset
				local desiredY = newY + THUMB_OFFSET + 60
				local minY = tipFrame.AbsoluteSize.Y + THUMB_OFFSET + 64 + 3
				local maxY = viewportSize.Y - tipFrame.Size.Y.Offset
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			elseif IconController.controllerModeEnabled then
				local indicator = TopbarPlusGui.Indicator
				local newPos = indicator.AbsolutePosition
				newX = newPos.X - tipFrame.Size.X.Offset/2 + indicator.AbsoluteSize.X/2
				newY = newPos.Y + 90
			else
				local desiredX = newX
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset - 48
				local desiredY = newY
				local minY = tipFrame.Size.Y.Offset+3
				local maxY = viewportSize.Y
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			end
			--local difX = tipFrame.AbsolutePosition.X - tipFrame.Position.X.Offset
			--local difY = tipFrame.AbsolutePosition.Y - tipFrame.Position.Y.Offset
			--local globalX = newX - difX
			--local globalY = newY - difY
			--tipFrame.Position = UDim2.new(0, globalX, 0, globalY-55)
			tipFrame.Position = UDim2.new(0, newX, 0, newY-20)
		end
		local cursorLocation = userInputService:GetMouseLocation()
		if cursorLocation then
			updateTipPositon(cursorLocation.X, cursorLocation.Y)
		end
		self._hoveringMaid:give(self.instances.iconButton.MouseMoved:Connect(updateTipPositon))
	end

	-- Change transparency of relavent tip instances
	for _, settingName in pairs(self._groupSettings.tip) do
		local settingDetail = self._settingsDictionary[settingName]
		settingDetail.useForcedGroupValue = not isVisible
		self:_update(settingName)
	end
end
