From 4bf87f89d1335426d63c4abe0efe08b41adc830e Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Thu, 6 Aug 2009 16:47:32 +0200 Subject: [PATCH] Create tooltips once --- oUF_Experience.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/oUF_Experience.lua b/oUF_Experience.lua index 79de5a0..1e8a672 100644 --- a/oUF_Experience.lua +++ b/oUF_Experience.lua @@ -14,7 +14,17 @@ --]] -local function tooltip(self, unit, min, max) +local function xp(unit) + if(unit == 'pet') then + return GetPetExperience() + else + return UnitXP(unit), UnitXPMax(unit) + end +end + +local function tooltip(self) + local unit = self:GetParent().unit + local min, max = xp(unit) local bars = unit == 'pet' and 6 or 20 GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5) @@ -28,14 +38,6 @@ local function tooltip(self, unit, min, max) GameTooltip:Show() end -local function xp(unit) - if(unit == 'pet') then - return GetPetExperience() - else - return UnitXP(unit), UnitXPMax(unit) - end -end - local function update(self) local bar, unit = self.Experience, self.unit local min, max = xp(unit) @@ -64,12 +66,6 @@ local function update(self) end end - if(bar.Tooltip) then - bar:SetScript('OnEnter', function() - tooltip(bar, unit, min, max) - end) - end - if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max) end @@ -125,6 +121,7 @@ local function enable(self, unit) if(bar.Tooltip) then bar:EnableMouse() bar:SetScript('OnLeave', GameTooltip_Hide) + bar:SetScript('OnEnter', tooltip) end end end @@ -146,6 +143,10 @@ local function disable(self, unit) self:UnregisterEvent('UNIT_PET', loadPet) bar:Hide() end + + if(bar.Tooltip) then + bar:SetScript('OnEnter', nil) + end end end -- 1.7.9.5