From 496f65b3f4fb9702954ddc638cbe0db114a92326 Mon Sep 17 00:00:00 2001 From: p3lim-52096 Date: Wed, 27 Aug 2008 22:30:07 +0000 Subject: [PATCH] Add rested bar support Bail out early if at max level git-svn-id: svn://svn.wowinterface.com/oUF_Experience-227/trunk@4 f81be506-7a38-4956-9b9f-d707db2888a5 --- oUF_Experience/oUF_Experience.lua | 46 ++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/oUF_Experience/oUF_Experience.lua b/oUF_Experience/oUF_Experience.lua index 0ed1741..50c8b82 100644 --- a/oUF_Experience/oUF_Experience.lua +++ b/oUF_Experience/oUF_Experience.lua @@ -1,18 +1,18 @@ local function UpdateElement(self, bar) - if(UnitLevel('player') < 70) then - local min, max = UnitXP('player'), UnitXPMax('player') + local min, max = UnitXP('player'), UnitXPMax('player') + bar:SetMinMaxValues(0, max) + bar:SetValue(min) + bar:SetFrameLevel(3) - bar:SetMinMaxValues(0, max) - bar:SetValue(min) + if(bar.rested) then + local rested = GetXPExhaustion() or 0 + bar.rested:SetMinMaxValues(0, max) + bar.rested:SetValue(rested) + bar.rested:SetFrameLevel(2) + end - if(bar.text) then - bar.text:SetFormattedText('%s / %s', min, max) - end - else - bar:Hide() - self:UnregisterEvent('PLAYER_XP_UPDATE') - self:UnregisterEvent('PLAYER_LEVEL_UP') - self:UnregisterEvent('UPDATE_EXHAUSTION') + if(bar.text) then + bar.text:SetFormattedText('%s / %s', min, max) end end @@ -22,15 +22,23 @@ function oUF:PLAYER_XP_UPDATE() end end +oUF:RegisterSubTypeMapping('PLAYER_XP_UPDATE') oUF:RegisterInitCallback(function(self) if(self.Experience) then - self:RegisterEvent('PLAYER_XP_UPDATE') - self:RegisterEvent('PLAYER_LEVEL_UP') - self:RegisterEvent('UPDATE_EXHAUSTION') + if(UnitLevel('player') < 70) then + self:RegisterEvent('PLAYER_XP_UPDATE') + self:RegisterEvent('PLAYER_LEVEL_UP') + self:RegisterEvent('UPDATE_EXHAUSTION') - self.PLAYER_LEVEL_UP = self.PLAYER_XP_UPDATE - self.UPDATE_EXHAUSTION = self.PLAYER_XP_UPDATE - -- force update at load - UpdateElement(self, self.Experience) + self.PLAYER_LEVEL_UP = self.PLAYER_XP_UPDATE + self.UPDATE_EXHAUSTION = self.PLAYER_XP_UPDATE + + UpdateElement(self, self.Experience) + else + self.Experience:Hide() + if(self.Experience.rested) then + self.Experience.rested:Hide() + end + end end end) \ No newline at end of file -- 1.7.9.5