WoWInterface SVN oUF_Experience

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 26 to Rev 27
    Reverse comparison

Rev 26 → Rev 27

oUF_Experience/oUF_Experience.lua
13,11 → 13,19
- :OverrideText(min, max)
 
--]]
 
local localized, class = UnitClass('player')
 
local function Tooltip(self, unit, min, max)
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5)
GameTooltip:AddLine(string.format('XP: %d/%d (%.1f%%)', min, max, min/max*100))
GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100,(max-min)/max*20))
 
if(unit == 'pet') then
GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100, 6*(max-min)/max))
else
GameTooltip:AddLine(string.format('%d needed (%.1f%% - %.1f bars)', max-min, (max-min)/max*100, 20*(max-min)/max))
end
 
if(unit == 'player' and GetXPExhaustion()) then
GameTooltip:AddLine(string.format('|cff0090ffRested: +%d (%.1f%%)', GetXPExhaustion(), GetXPExhaustion()/max*100))
end
25,20 → 33,22
GameTooltip:Show()
end
 
local function GetXP(unit)
if(unit == 'pet') then
return GetPetExperience()
else
return UnitXP(unit), UnitXPMax(unit)
end
end
 
local function Update(self, event, unit)
local bar = self.Experience
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(self.unit), UnitXPMax(self.unit)
end
if(self.unit == 'player' and (UnitLevel(self.unit) ~= MAX_PLAYER_LEVEL) or (self.unit == 'pet' and class == 'HUNTER') and (UnitLevel(self.unit) < UnitLevel('player'))) then
local min, max = GetXP(self.unit)
 
bar:SetMinMaxValues(0, max)
bar:SetValue(min)
bar:EnableMouse()
bar:Show()
 
if(bar.Text) then
61,12 → 71,20
end
end
 
local function Enable(self)
local function Enable(self, unit)
local experience = self.Experience
if(experience) then
if(experience and (unit == 'pet' or unit == 'player')) then
self:RegisterEvent('PLAYER_XP_UPDATE', Update)
self:RegisterEvent('UNIT_PET_EXPERIENCE', Update)
self:RegisterEvent('UNIT_PET', Update)
 
if(class == 'HUNTER') then
self:RegisterEvent('UNIT_PET_EXPERIENCE', Update)
end
 
if(experience.MouseOver or experience.Tooltip) then
experience:EnableMouse()
end
 
if(not experience:GetStatusBarTexture()) then
experience:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=])
end
89,7 → 107,11
local function Disable(self)
if(self.Experience) then
self:UnregisterEvent('PLAYER_XP_UPDATE', Update)
self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update)
self:UnregisterEvent('UNIT_PET', Update)
 
if(class == 'HUNTER') then
self:UnregisterEvent('UNIT_PET_EXPERIENCE', Update)
end
end
end