From 669e1d1684fa3f71ddfb11a8d1207254310d8f49 Mon Sep 17 00:00:00 2001 From: p3lim-52096 Date: Sat, 7 Feb 2009 21:17:21 +0000 Subject: [PATCH] Added unit check Bail out early if there is nothing to update git-svn-id: svn://svn.wowinterface.com/oUF_Reputation-398/trunk@5 f82d3c14-86d8-4125-bab8-f0c326a23617 --- oUF_Reputation/oUF_Reputation.lua | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/oUF_Reputation/oUF_Reputation.lua b/oUF_Reputation/oUF_Reputation.lua index 7189bcb..c4ed9db 100644 --- a/oUF_Reputation/oUF_Reputation.lua +++ b/oUF_Reputation/oUF_Reputation.lua @@ -14,6 +14,8 @@ --]] local function Tooltip(self, min, max, name, id) + if(self.MouseOver) then self:SetAlpha(1) end + GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5) GameTooltip:AddLine(string.format('%s (%s)', name, _G['FACTION_STANDING_LABEL'..id])) GameTooltip:AddLine(string.format('%d/%d (%.1f%%)', min, max, min/max*100)) @@ -22,42 +24,37 @@ end local function Update(self, event, unit) local bar = self.Reputation - - if(GetWatchedFactionInfo()) then - local name, id, min, max, value = GetWatchedFactionInfo() - - bar:SetMinMaxValues(min, max) - bar:SetValue(value) - bar:EnableMouse() - bar:Show() - - if(bar.Text) then - if(bar.OverrideText) then - bar:OverrideText(min, max, value, name, id) - else - bar.Text:SetFormattedText('%d / %d - %s', value - min, max - min, name) - end - end + if(not GetWatchedFactionInfo()) then return bar:Hide() + + local name, id, min, max, value = GetWatchedFactionInfo() + bar:SetMinMaxValues(min, max) + bar:SetValue(value) + bar:Show() - if(bar.Tooltip and bar.MouseOver) then - bar:SetScript('OnEnter', function() bar:SetAlpha(1); Tooltip(bar, value - min, max - min, name, id) end) - elseif(bar.Tooltip and not bar.MouseOver) then - bar:SetScript('OnEnter', function() Tooltip(bar, value - min, max - min, name, id) end) + if(bar.Text) then + if(bar.OverrideText) then + bar:OverrideText(min, max, value, name, id) + else + bar.Text:SetFormattedText('%d / %d - %s', value - min, max - min, name) end + end - if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max, value, name, id) end - else - bar:Hide() + if(bar.Tooltip) then + bar:SetScript('OnEnter', function() + Tooltip(bar, value - min, max - min, name, id) + end) end + + if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max, value, name, id) end end -local function Enable(self) +local function Enable(self, unit) local reputation = self.Reputation - if(reputation) then + if(reputation and unit == 'player') then self:RegisterEvent('UPDATE_FACTION', Update) - if(not reputation:GetStatusBarTexture()) then - reputation:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) + if(reputation.Tooltip or reputation.MouseOver) then + reputation:EnableMouse() end if(reputation.Tooltip and reputation.MouseOver) then @@ -71,6 +68,11 @@ local function Enable(self) reputation:SetScript('OnLeave', function() GameTooltip:Hide() end) end + if(not reputation:GetStatusBarTexture()) then + reputation:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) + end + + return true end end -- 1.7.9.5