WoWInterface SVN oUF_Pazrael

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /branches
    from Rev 38 to Rev 39
    Reverse comparison

Rev 38 → Rev 39

oUF_Experience/oUF_Experience.lua New file
0,0 → 1,125
local function CreatePlayerTooltip(self)
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
if(GetWatchedFactionInfo()) then
local name, standing, min, max, value = GetWatchedFactionInfo()
local repLevel = _G['FACTION_STANDING_LABEL' .. standing]
GameTooltip:AddLine(format('|cffffffffWatched Reputation: |r %s', name))
GameTooltip:AddLine(format('|cffffffffRemaining Reputation to go:|r %s', floor(max - value)))
GameTooltip:AddLine(format('|cffffffffPercentage to go:|r %s%%', floor((max - value) / (max-min) * 100)))
GameTooltip:AddLine(format('|cffffffffCurrent Standing|r %s', repLevel))
GameTooltip:Show()
elseif(unit=='player') then
local min, max = UnitXP('player'), UnitXPMax('player')
if(GetXPExhaustion()) then
GameTooltip:AddLine(format('|cffffffffRested XP remaining:|r %s', GetXPExhaustion()))
GameTooltip:AddLine(' ')
end
GameTooltip:AddLine(format('|cffffffffRemaining XP to go:|r %s', floor(max - min)))
GameTooltip:AddLine(format('|cffffffffPercentage through:|r %s%%', floor(min / max * 100)))
GameTooltip:AddLine(format('|cffffffffPercentage to go:|r %s%%', floor((max - min) / max * 100)))
GameTooltip:AddLine(format('|cffffffffBars through:|r %s', floor(min / max * 20)))
GameTooltip:AddLine(format('|cffffffffBars to go:|r %s', floor((max - min) / max * 20)))
GameTooltip:Show()
else
local min, max = GetPetExperience();
GameTooltip:AddLine(format('|cffffffffRemaining XP to go:|r %s', floor(max - min)))
GameTooltip:AddLine(format('|cffffffffPercentage through:|r %s%%', floor(min / max * 100)))
GameTooltip:AddLine(format('|cffffffffPercentage to go:|r %s%%', floor((max - min) / max * 100)))
GameTooltip:AddLine(format('|cffffffffBars through:|r %s', floor(min / max * 20)))
GameTooltip:AddLine(format('|cffffffffBars to go:|r %s', floor((max - min) / max * 20)))
GameTooltip:Show()
end
end
 
local function UpdateElement(self, event, unit, bar)
if(unit == 'player' and GetWatchedFactionInfo()) then
local name, standing, min, max, value = GetWatchedFactionInfo()
bar:SetMinMaxValues(min, max)
bar:SetValue(value)
 
if(bar.rested) then
bar.rested:Hide()
end
 
if(bar.text) then
bar.text:SetFormattedText('%s / %s : %d', value, max, name)
end
self.Experience:Show()
else
if(unit == 'player') then
local min, max, petmin, petmax = UnitXP('player'), UnitXPMax('player')
bar:SetMinMaxValues(0, max)
bar:SetValue(min)
 
if(bar.rested) then
local rested = GetXPExhaustion() or 0
bar.rested:SetMinMaxValues(0, max)
bar.rested:SetValue(rested + min)
bar.rested:SetFrameLevel(2)
bar:SetFrameLevel(3)
end
 
if(bar.text) then
bar.text:SetFormattedText('%s / %s', min, max)
end
if(UnitLevel('player') == MAX_PLAYER_LEVEL) then
self.Experience:Hide()
if(self.Experience.rested) then
self.Experience.rested:Hide()
end
end
end
elseif(unit == 'pet') then
local min, max = GetPetExperience();
bar:SetMinMaxValues(0, max)
bar:SetValue(min)
 
if(bar.rested) then
bar.rested:Hide()
end
 
if(bar.text) then
bar.text:SetFormattedText('%s / %s', min, max)
end
if(UnitLevel('pet') == MAX_PLAYER_LEVEL) then
self.Experience:Hide()
if(self.Experience.rested) then
self.Experience.rested:Hide()
end
end
end
end
 
if(bar.tooltip) then
bar:EnableMouse()
bar:SetScript('OnEnter', CreatePlayerTooltip)
bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
end
 
if(self.PostUpdateExperience) then self:PostUpdateExperience(event, unit, bar, min, max) end
end
 
function oUF:PLAYER_XP_UPDATE(event, unit)
if(self.Experience) then
UpdateElement(self, event, unit, self.Experience)
end
end
 
oUF:RegisterSubTypeMapping('PLAYER_XP_UPDATE')
oUF:RegisterInitCallback(function(self)
if(self.Experience) then
self:RegisterEvent('PLAYER_XP_UPDATE')
self:RegisterEvent('UPDATE_FACTION')
self.UPDATE_FACTION = self.PLAYER_XP_UPDATE
if not(UnitLevel('pet') == UnitLevel('player')) then
self:RegisterEvent('UNIT_PET_EXPERIENCE')
self.UNIT_PET_EXPERIENCE = self.PLAYER_XP_UPDATE
end
if not(UnitLevel('player') == MAX_PLAYER_LEVEL) then
self:RegisterEvent('PLAYER_LEVEL_UP')
self:RegisterEvent('UPDATE_EXHAUSTION')
self.PLAYER_LEVEL_UP = self.PLAYER_XP_UPDATE
self.UPDATE_EXHAUSTION = self.PLAYER_XP_UPDATE
end
end
end)
\ No newline at end of file