Added tooltip support
p3lim-52096 [08-28-08 - 00:14]
Added tooltip support
git-svn-id: svn://svn.wowinterface.com/oUF_Experience-227/trunk@5 f81be506-7a38-4956-9b9f-d707db2888a5
diff --git a/oUF_Experience/oUF_Experience.lua b/oUF_Experience/oUF_Experience.lua
index 50c8b82..01cc1d2 100644
--- a/oUF_Experience/oUF_Experience.lua
+++ b/oUF_Experience/oUF_Experience.lua
@@ -1,3 +1,18 @@
+local function CreateTooltip(self)
+ local min, max = UnitXP('player'), UnitXPMax('player')
+
+ GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT")
+ if(GetXPExhaustion()) then
+ GameTooltip:AddLine(format('Rested XP left: %s', GetXPExhaustion()))
+ GameTooltip:AddLine(' ')
+ end
+ GameTooltip:AddLine(format('Percentage through: %s%%', floor(min / max * 100)))
+ GameTooltip:AddLine(format('Percentage left: %s%%', floor((max - min) / max * 100)))
+ GameTooltip:AddLine(format('Bars through: %s', floor(min / max * 20)))
+ GameTooltip:AddLine(format('Bars left: %s', floor((max - min) / max * 20)))
+ GameTooltip:Show()
+end
+
local function UpdateElement(self, bar)
local min, max = UnitXP('player'), UnitXPMax('player')
bar:SetMinMaxValues(0, max)
@@ -14,6 +29,12 @@ local function UpdateElement(self, bar)
if(bar.text) then
bar.text:SetFormattedText('%s / %s', min, max)
end
+
+ if(bar.tooltip) then
+ bar:EnableMouse()
+ bar:SetScript('OnEnter', CreateTooltip)
+ bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
+ end
end
function oUF:PLAYER_XP_UPDATE()