Quantcast
local _, addon = ...

local MAX_BUBBLES = 20

function addon:GetXPInfo()
	local xp, xpMax = UnitXP("player"), UnitXPMax("player")
	local xpPercent =  xp / xpMax * 100

	local rested = GetXPExhaustion() or 0
	local restedPercent = rested / xpMax * 100

	local tnl = xpMax - xp
	local tnlPercent = tnl / xpMax * 100

	local width = MainMenuExpBar:GetWidth()
	local divWidth = width / MAX_BUBBLES
	local totalProgress = xp / xpMax * width
	local bubbles = totalProgress / divWidth

	return xp, xpMax, xpPercent, rested, restedPercent, tnl, tnlPercent, bubbles, MAX_BUBBLES
end

function addon:Paste()
	local text
	local _, _, xpPercent, rested, restedPercent, _, _, bubbles = self:GetXPInfo()
	local level = UnitLevel("player")

	if rested ~= 0 then
		text = format("[Current Level %s] XP: %.1f%% (%.1f%%)", level, xpPercent, restedPercent)
	else
		text = format("[Current Level %s] XP: %.1f%%", level, xpPercent)
	end

	ChatFrame_OpenChat(text)
end