/
.Experience.Text [fontstring] (optional) |
Shared: |
- Colors [table] - will use oUF.colors.health if not set |
- Tooltip [boolean] |
- MouseOver [boolean] |
- Tooltip [boolean] |
Functions that can be overridden from within a layout: |
- :PostUpdate(event, unit, bar, min, max) |
- :OverrideText(min, max) |
--]] |
local function Tooltip(self, unit, min, max) |
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5) |
end |
local function Update(self, event, unit) |
if(event == 'UNIT_PET' and unit ~= 'player') then return end |
local bar = self.Experience |
local min, max |
if(self.unit == 'pet' and UnitLevel('pet') == UnitLevel('player')) then |
bar:Hide() |
elseif(self.unit == 'player' and UnitLevel('player') == MAX_PLAYER_LEVEL) then |
bar:Hide() |
else |
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('player'), UnitXPMax('player') |
min, max = UnitXP(self.unit), UnitXPMax(self.unit) |
end |
bar:SetMinMaxValues(0, max) |
bar:SetValue(min) |
bar:EnableMouse() |
bar:SetStatusBarColor(unpack(bar.Colors or self.colors.health)) |
bar:Show() |
if(not bar.MouseOver) then |
bar:SetAlpha(1) |
end |
if(bar.Text) then |
bar.Text:SetFormattedText('%d / %d', min, max) |
if(bar.OverrideText) then |
bar:OverrideText(min, max) |
else |
bar.Text:SetFormattedText('%d / %d', min, max) |
end |
end |
if(bar.Tooltip and bar.MouseOver) then |
elseif(bar.Tooltip and not bar.MouseOver) then |
bar:SetScript('OnEnter', function() Tooltip(bar, self.unit, min, max) end) |
end |
if(bar.PostUpdate) then bar.PostUpdate(self, event, unit, bar, min, max) end |
else |
bar:Hide() |
end |
end |
if(experience) then |
self:RegisterEvent('PLAYER_XP_UPDATE', Update) |
self:RegisterEvent('UNIT_PET_EXPERIENCE', Update) |
self:RegisterEvent('UNIT_PET', Update) |
if(not experience:GetStatusBarTexture()) then |
experience:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=]) |
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(self) GameTooltip:Hide() end) |
experience:SetScript('OnLeave', function() GameTooltip:Hide() end) |
end |
return true |
if(self.Experience) then |
self:UnregisterEvent('PLAYER_XP_UPDATE', Update) |
self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update) |
self:UnregisterEvent('UNIT_PET', Update) |
end |
end |