end |
end |
|
if(bar.Rested and unit == 'player') then |
if(GetXPExhaustion() and GetXPExhaustion() > 0) then |
if(bar.Rested) then |
local exhaustion = GetXPExhaustion() |
|
if(unit == 'player' and exhaustion and exhaustion > 0) then |
bar.Rested:SetMinMaxValues(0, max) |
bar.Rested:SetValue(math.min(min + GetXPExhaustion(), max)) |
bar.Rested:SetValue(math.min(min + exhaustion, max)) |
bar.exhaustion = exhaustion |
else |
bar.Rested:SetMinMaxValues(0, 1) |
bar.Rested:SetValue(0) |
bar.exhaustion = nil |
end |
elseif(bar.Rested and unit ~= 'player') then |
bar.Rested:SetMinMaxValues(0, 1) |
bar.Rested:SetValue(0) |
end |
|
if(bar.PostUpdate) then |
bar.PostUpdate(self, event, unit, bar, min, max) |
end |
|
if(bar.Tooltip) then |
bar:SetScript('OnEnter', function() |
return (bar.OverrideTooltip or showTooltip) (bar, unit, min, max, unit == 'pet' and 6 or 20) |
tooltip(bar, unit, min, max) |
end) |
end |
end |
|
local function LevelCheck(self) |
if(UnitLevel(self.unit) == MAX_PLAYER_LEVEL) then |
return self:DisableElement('Experience') |
else |
Update(self) |
if(bar.PostUpdate) then |
bar.PostUpdate(self, event, unit, bar, min, max) |
end |
end |
|
if(self.unit == 'pet') then |
if(UnitLevel(self.unit) == UnitLevel('player')) then |
self.Experience:Hide() |
local function argChecks(self, event, unit, ...) |
if(self.unit == 'player') then |
if(IsXPUserDisabled()) then |
self:DisableElement('Experience') |
self:RegisterEvent('ENABLE_XP_GAIN', argChecks) |
elseif(UnitLevel('player') == MAX_PLAYER_LEVEL) then |
self:DisableElement('Experience') |
else |
update(self) |
end |
elseif(self.unit == 'pet') then |
if(UnitLevel('pet') ~= UnitLevel('player')) then |
self.Experience:Show() |
update(self) |
else |
self.Experience:Hide() |
end |
end |
end |
|
local function PetCheck(self, event, unit) |
local function loadPet(self, event, unit) |
if(unit == 'player') then |
LevelCheck(self) |
argChecks(self) |
end |
end |
|
local function Enable(self, unit) |
local function enable(self, unit) |
local bar = self.Experience |
if(bar) then |
if(not bar:GetStatusBarTexture()) then |
bar:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) |
bar:SetStatusBarTexture() |
end |
|
if(unit == 'player') then |
if(UnitLevel(unit) ~= MAX_PLAYER_LEVEL) then |
self:RegisterEvent('PLAYER_XP_UPDATE', Update) |
self:RegisterEvent('PLAYER_LEVEL_UP', LevelCheck) |
self:RegisterEvent('PLAYER_XP_UPDATE', argChecks) |
self:RegisterEvent('PLAYER_LEVEL_UP', argChecks) |
|
if(bar.Rested) then |
self:RegisterEvent('UPDATE_EXHAUSTION', Update) |
end |
else |
bar:Hide() |
|
if(bar.Rested) then |
bar.Rested:Hide() |
end |
if(bar.Rested) then |
self:RegisterEvent('UPDATE_EXHAUSTION', argChecks) |
end |
elseif(unit == 'pet') then |
if(select(2, UnitClass('player')) == 'HUNTER') then |
if(UnitLevel(unit) ~= MAX_PLAYER_LEVEL) then |
self:RegisterEvent('UNIT_PET_EXPERIENCE', LevelCheck) |
self:RegisterEvent('UNIT_PET', PetCheck) |
else |
bar:Hide() |
end |
else |
bar:Hide() |
self:RegisterEvent('UNIT_PET_EXPERIENCE', argChecks) |
self:RegisterEvent('UNIT_PET', loadPet) |
end |
end |
|
if(bar.MouseOver or bar.Tooltip) then |
if(bar.Tooltip) then |
bar:EnableMouse() |
bar:SetScript('OnLeave', GameTooltip_Hide) |
end |
|
if(bar.MouseOver and bar.Tooltip) then |
bar:SetAlpha(0) |
bar:SetScript('OnLeave', function() bar:SetAlpha(0); GameTooltip:Hide() end) |
elseif(bar.MouseOver and not bar.Tooltip) then |
bar:SetAlpha(0) |
bar:SetScript('OnEnter', function() bar:SetAlpha(1) end) |
bar:SetScript('OnLeave', function() bar:SetAlpha(0) end) |
elseif(not bar.MouseOver and bar.Tooltip) then |
bar:SetScript('OnLeave', function() GameTooltip:Hide() end) |
end |
|
return true |
end |
end |
|
local function Disable(self, unit) |
local function disable(self, unit) |
local bar = self.Experience |
if(bar) then |
if(unit == 'player') then |
self:UnregisterEvent('PLAYER_XP_UPDATE', Update) |
if(unit == 'player') |
self:UnregisterEvent('PLAYER_XP_UPDATE', argChecks) |
self:UnregisterEvent('PLAYER_LEVEL_UP', argChecks) |
bar:Hide() |
|
if(bar.Rested) then |
self:UnregisterEvent('UPDATE_EXHAUSTION', Update) |
bar:Hide() |
self:UnregisterEvent('UPDATE_EXHAUSTION', argChecks) |
bar.Rested:Hide() |
end |
elseif(unit == 'pet') then |
self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update) |
self:UnregisterEvent('UNIT_PET_EXPERIENCE', argChecks) |
self:UnregisterEvent('UNIT_PET', loadPet) |
bar:Hide() |
end |
end |
end |
|
oUF:AddElement('Experience', Update, Enable, Disable) |