From ca4f280c19919fff0aa944707fabd143bb8a3cf5 Mon Sep 17 00:00:00 2001 From: p3lim-52096 Date: Fri, 6 Feb 2009 16:04:16 +0000 Subject: [PATCH] Fixed pet update Fixed pet "bubbles" git-svn-id: svn://svn.wowinterface.com/oUF_Experience-227/trunk@27 f81be506-7a38-4956-9b9f-d707db2888a5 --- oUF_Experience/oUF_Experience.lua | 48 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/oUF_Experience/oUF_Experience.lua b/oUF_Experience/oUF_Experience.lua index 1d63a81..7d5f606 100644 --- a/oUF_Experience/oUF_Experience.lua +++ b/oUF_Experience/oUF_Experience.lua @@ -13,10 +13,18 @@ - :OverrideText(min, max) --]] + +local localized, class = UnitClass('player') + local function Tooltip(self, unit, min, max) GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5) GameTooltip:AddLine(string.format('XP: %d/%d (%.1f%%)', min, max, min/max*100)) - GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100,(max-min)/max*20)) + + if(unit == 'pet') then + GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100, 6*(max-min)/max)) + else + GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100, 20*(max-min)/max)) + end if(unit == 'player' and GetXPExhaustion()) then GameTooltip:AddLine(string.format('|cff0090ffRested: +%d (%.1f%%)', GetXPExhaustion(), GetXPExhaustion()/max*100)) @@ -25,20 +33,22 @@ local function Tooltip(self, unit, min, max) GameTooltip:Show() end +local function GetXP(unit) + if(unit == 'pet') then + return GetPetExperience() + else + return UnitXP(unit), UnitXPMax(unit) + end +end + local function Update(self, event, unit) local bar = self.Experience - 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(self.unit), UnitXPMax(self.unit) - end + if(self.unit == 'player' and (UnitLevel(self.unit) ~= MAX_PLAYER_LEVEL) or (self.unit == 'pet' and class == 'HUNTER') and (UnitLevel(self.unit) < UnitLevel('player'))) then + local min, max = GetXP(self.unit) bar:SetMinMaxValues(0, max) bar:SetValue(min) - bar:EnableMouse() bar:Show() if(bar.Text) then @@ -61,11 +71,19 @@ local function Update(self, event, unit) end end -local function Enable(self) +local function Enable(self, unit) local experience = self.Experience - if(experience) then + if(experience and (unit == 'pet' or unit == 'player')) then self:RegisterEvent('PLAYER_XP_UPDATE', Update) - self:RegisterEvent('UNIT_PET_EXPERIENCE', Update) + self:RegisterEvent('UNIT_PET', Update) + + if(class == 'HUNTER') then + self:RegisterEvent('UNIT_PET_EXPERIENCE', Update) + end + + if(experience.MouseOver or experience.Tooltip) then + experience:EnableMouse() + end if(not experience:GetStatusBarTexture()) then experience:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) @@ -89,7 +107,11 @@ end 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) + + if(class == 'HUNTER') then + self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update) + end end end -- 1.7.9.5