From fae493b3163468721c4a871bef3f27d0befdd041 Mon Sep 17 00:00:00 2001 From: p3lim-52096 Date: Wed, 14 Jan 2009 20:37:09 +0000 Subject: [PATCH] Added :PostUpdate Added :OverrideText Removed .Colors option Removed UNIT_PET event git-svn-id: svn://svn.wowinterface.com/oUF_Experience-227/trunk@26 f81be506-7a38-4956-9b9f-d707db2888a5 --- oUF_Experience/oUF_Experience.lua | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/oUF_Experience/oUF_Experience.lua b/oUF_Experience/oUF_Experience.lua index a0a8cd3..1d63a81 100644 --- a/oUF_Experience/oUF_Experience.lua +++ b/oUF_Experience/oUF_Experience.lua @@ -5,9 +5,12 @@ .Experience.Text [fontstring] (optional) Shared: - - Colors [table] - will use oUF.colors.health if not set - - Tooltip [boolean] - MouseOver [boolean] + - Tooltip [boolean] + + Functions that can be overridden from within a layout: + - :PostUpdate(event, unit, bar, min, max) + - :OverrideText(min, max) --]] local function Tooltip(self, unit, min, max) @@ -23,33 +26,27 @@ local function Tooltip(self, unit, min, max) end local function Update(self, event, unit) - if(event == 'UNIT_PET' and unit ~= 'player') then return end local bar = self.Experience + local min, max - if(self.unit == 'pet' and UnitLevel('pet') == UnitLevel('player')) then - bar:Hide() - elseif(self.unit == 'player' and UnitLevel('player') == MAX_PLAYER_LEVEL) then - bar:Hide() - else - local min, max + if(self.unit == 'player' and (UnitLevel(self.unit) ~= MAX_PLAYER_LEVEL) or self.unit == 'pet' and (UnitLevel(self.unit) ~= UnitLevel('player'))) then if(self.unit == 'pet') then min, max = GetPetExperience() elseif(self.unit == 'player') then - min, max = UnitXP('player'), UnitXPMax('player') + min, max = UnitXP(self.unit), UnitXPMax(self.unit) end bar:SetMinMaxValues(0, max) bar:SetValue(min) bar:EnableMouse() - bar:SetStatusBarColor(unpack(bar.Colors or self.colors.health)) bar:Show() - if(not bar.MouseOver) then - bar:SetAlpha(1) - end - if(bar.Text) then - bar.Text:SetFormattedText('%d / %d', min, max) + if(bar.OverrideText) then + bar:OverrideText(min, max) + else + bar.Text:SetFormattedText('%d / %d', min, max) + end end if(bar.Tooltip and bar.MouseOver) then @@ -57,6 +54,10 @@ local function Update(self, event, unit) elseif(bar.Tooltip and not bar.MouseOver) then bar:SetScript('OnEnter', function() Tooltip(bar, self.unit, min, max) end) end + + if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max) end + else + bar:Hide() end end @@ -65,7 +66,6 @@ local function Enable(self) if(experience) then self:RegisterEvent('PLAYER_XP_UPDATE', Update) self:RegisterEvent('UNIT_PET_EXPERIENCE', Update) - self:RegisterEvent('UNIT_PET', Update) if(not experience:GetStatusBarTexture()) then experience:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) @@ -79,7 +79,7 @@ local function Enable(self) experience:SetScript('OnEnter', function(self) self:SetAlpha(1) end) experience:SetScript('OnLeave', function(self) self:SetAlpha(0) end) elseif(experience.Tooltip and not experience.MouseOver) then - experience:SetScript('OnLeave', function(self) GameTooltip:Hide() end) + experience:SetScript('OnLeave', function() GameTooltip:Hide() end) end return true @@ -90,7 +90,6 @@ local function Disable(self) if(self.Experience) then self:UnregisterEvent('PLAYER_XP_UPDATE', Update) self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update) - self:UnregisterEvent('UNIT_PET', Update) end end -- 1.7.9.5