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

	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: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
