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

	local tipMaid = Maid.new()
	self._maid.tipMaid = tipMaid
	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))
	self:displayTip(self.hovering)
	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
