end |
end |
|
local function Update(self, event, unit) |
if(event == 'UNIT_PET' and unit ~= 'player') then return end |
local function Update(self, event) |
local bar, unit = self.Experience, self.unit |
|
local bar = self.Experience |
if(self.unit == 'player' and UnitLevel('player') == MAX_PLAYER_LEVEL) then return bar:Hide() end |
if(self.unit == 'pet' and class ~= 'HUNTER') then return bar:Hide() end |
if(self.unit == 'pet' and UnitLevel('pet') >= UnitLevel('player')) then bar:Hide() end |
if(UnitLevel(unit) == MAX_PLAYER_LEVEL) then |
self:DisableElement('Experience') |
|
local min, max = GetXP(self.unit) |
bar:SetMinMaxValues(0, max) |
if(bar.Rested) then |
bar.Rested:Hide() |
end |
|
return bar:Hide() |
end |
|
if(UnitLevel('pet') == 0 and unit == 'pet') then |
bar:Hide() |
else |
bar:Show() |
end |
|
local min, max = getXP(unit) |
bar:SetMinMaxValues(math.min(0, min), max) |
bar:SetValue(min) |
bar:Show() |
|
if(bar.Text) then |
if(bar.OverrideText) then |
bar:OverrideText(min, max) |
bar:OverrideText(unit, min, max) |
else |
bar.Text:SetFormattedText('%d / %d', min, max) |
end |
end |
|
if(bar.Rested and unit == 'player') then |
if(GetXPExhaustion() > 0) then |
bar.Rested:SetMinMaxValues(min, max) |
bar.Rested:SetValue(math.min(min + GetXPExhaustion(), max)) |
else |
bar.Rested:SetMinMaxValues(0, 1) |
bar.Rested:SetValue(0) |
end |
end |
|
if(bar.PostUpdate) then |
bar.PostUpdate(self, event, unit, bar, min, max) |
end |
|
if(bar.Tooltip) then |
bar:SetScript('OnEnter', function() |
Tooltip(bar, self.unit, min, max, self.unit == 'pet' and 6 or 20) |
return (bar.OverrideTooltip or showTooltip) (bar, unit, min, max, unit == 'pet' and 6 or 20) |
end) |
end |
|
if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max) end |
end |
|
local function Enable(self, unit) |
local experience = self.Experience |
if(experience and (unit == 'pet' or unit == 'player')) then |
self:RegisterEvent('PLAYER_XP_UPDATE', Update) |
self:RegisterEvent('UNIT_PET', Update) |
local xp = self.Experience |
if(xp) then |
if(not xp:GetStatusBarTexture()) then |
xp:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) |
end |
|
if(class == 'HUNTER') then |
if(unit == 'player') then |
self:RegisterEvent('PLAYER_XP_UPDATE', Update) |
self:RegisterEvent('PLAYER_LEVEL_UP', Update) |
|
if(xp.Rested) then |
self:RegisterEvent('UPDATE_EXHAUSTION', Update) |
end |
elseif(unit == 'pet' and select(2, UnitClass('player')) == 'HUNTER') then -- only called once so select is "ok" |
self:RegisterEvent('UNIT_PET_EXPERIENCE', Update) |
end |
|
if(experience.MouseOver or experience.Tooltip) then |
experience:EnableMouse() |
if(xp.MouseOver or xp.Tooltip) then |
xp:EnableMouse() |
end |
|
if(experience.Tooltip and experience.MouseOver) then |
experience:SetAlpha(0) |
experience:SetScript('OnLeave', function(self) self:SetAlpha(0); GameTooltip:Hide() end) |
elseif(experience.MouseOver and not experience.Tooltip) then |
experience:SetAlpha(0) |
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() GameTooltip:Hide() end) |
if(xp.MouseOver and xp.Tooltip) then |
xp:SetAlpha(0) |
xp:SetScript('OnLeave', function() xp:SetAlpha(0); GameTooltip:Hide() end) |
elseif(xp.MouseOver and not xp.Tooltip) then |
xp:SetAlpha(0) |
xp:SetScript('OnEnter', function() xp:SetAlpha(1) end) |
xp:SetScript('OnLeave', function() xp:SetAlpha(0) end) |
elseif(not xp.MouseOver and xp.Tooltip) then |
xp:SetScript('OnLeave', function() GameTooltip:Hide() end) |
end |
|
if(not experience:GetStatusBarTexture()) then |
experience:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) |
end |
|
return true |
end |
end |
end |
|
local function Disable(self) |
if(self.Experience) then |
self:UnregisterEvent('PLAYER_XP_UPDATE', Update) |
self:UnregisterEvent('UNIT_PET', Update) |
local function Disable(self, unit) |
local xp = self.Experience |
if(xp) then |
if(unit == 'player') then |
self:UnregisterEvent('PLAYER_XP_UPDATE', Update) |
self:UnregisterEvent('PLAYER_LEVEL_UP', Update) |
|
if(class == 'HUNTER') then |
if(xp.Rested) then |
self:UnregisterEvent('UPDATE_EXHAUSTION', Update) |
end |
elseif(unit == 'pet') then |
self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update) |
end |
end |
end |
end |
|