WoWInterface SVN oUF_Pazrael

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 48 to Rev 49
    Reverse comparison

Rev 48 → Rev 49

branches/oUF_Experience/oUF_Experience.lua New file
0,0 → 1,139
local _, class = UnitClass('player')
local function CreatePlayerXPTooltip(self, min, max)
GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
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()
end
 
local function CreatePlayerRepTooltip(self, name, standing, min, max, value)
GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
GameTooltip:AddLine(format('|cffffffffWatched Faction:|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', _G['FACTION_STANDING_LABEL' .. standing]))
GameTooltip:Show()
end
 
local function CreatePetTooltip(self, min, max)
GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
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
 
local function UpdatePlayerElement(self, event, unit, bar)
if(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 - %s', value, max, name)
end
 
if(bar.Tooltip) then
bar:EnableMouse()
bar:SetScript('OnEnter', function() CreatePlayerRepTooltip(bar, name, standing, min, max, value) end)
bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
end
else
if(UnitLevel('PLAYER') == MAX_PLAYER_LEVEL) then
self:UnregisterEvent('PLAYER_LEVEL_UP')
self:UnregisterEvent('UPDATE_EXHAUSTION')
return
end
 
local min, max = UnitXP('player'), UnitXPMax('player')
bar:SetMinMaxValues(0, max)
bar:SetValue(min)
 
if(bar.Rested) then
bar.Rested:SetMinMaxValues(0, max)
bar.Rested:SetValue((GetXPExhaustion() or 0) + min)
bar.Rested:SetFrameLevel(2)
bar.Rested:Show()
bar:SetFrameLevel(3)
end
 
if(bar.Text) then
bar.Text:SetFormattedText('%s / %s', min, max)
end
 
if(bar.Tooltip) then
bar:EnableMouse()
bar:SetScript('OnEnter', function() CreatePlayerXPTooltip(bar, min, max) end)
bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
end
end
end
 
local function UpdatePetElement(self, event, unit, bar)
if(UnitLevel('pet') == MAX_PLAYER_LEVEL or not(class == 'HUNTER')) then
bar:Hide()
return
end
 
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(bar.Tooltip) then
bar:EnableMouse()
bar:SetScript('OnEnter', function() CreatePetTooltip(bar, min, max) end)
bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
end
end
 
function oUF:PLAYER_XP_UPDATE(event, unit)
if((self.Experience == oUF.units.player.Experience)--[[ and unit == 'player']]) then
UpdatePlayerElement(self, event, unit, self.Experience)
elseif((self.Experience == oUF.units.pet.Experience) and unit == 'pet') then
UpdatePetElement(self, event, unit, self.Experience)
end
end
 
--[[function oUF:UNIT_PET_EXPERIENCE(event, unit)
if((self.Experience == oUF.units.pet.Experience) and unit == 'pet') then
UpdatePetElement(self, event, unit, self.Experience)
end
end]]
 
oUF:RegisterSubTypeMapping('PLAYER_XP_UPDATE')
oUF:RegisterInitCallback(function(self)
if(self.Experience) then
self:RegisterEvent('UPDATE_FACTION')
self.UPDATE_FACTION = self.PLAYER_XP_UPDATE
 
if(UnitLevel('player') ~= MAX_PLAYER_LEVEL) then
self:RegisterEvent('PLAYER_XP_UPDATE')
self:RegisterEvent('PLAYER_LEVEL_UP')
self:RegisterEvent('UPDATE_EXHAUSTION')
self.PLAYER_LEVEL_UP = self.PLAYER_XP_UPDATE
self.UPDATE_EXAUSTION = self.PLAYER_XP_UPDATE
end
 
if(UnitLevel('pet') ~= MAX_PLAYER_LEVEL) then
self:RegisterEvent('UNIT_PET_EXPERIENCE')
self.UNIT_PET_EXPERIENCE = self.PLAYER_XP_UPDATE
end
end
end)
\ No newline at end of file