/trunk
local barwidth = 300 |
local healthtexture = bartexture |
local healthheight = barheight |
local healthheight = 10 |
local healthwidth = barwidth |
local powertexture = bartexture |
local powerheight = 5 |
local powerheight = 10 |
local powerwidth = barwidth |
local textinset = 5 |
local raidcolors = _G.RAID_CLASS_COLORS |
local buffsize = 16 |
local buffsize = 33 |
local innerpadding = 1 |
local outerpadding = 1 |
local pethappiness = {':<',':|',':3'} |
-- functions |
local showMenu |
local updateHealth |
local updateHealthInfo |
local updatePowerInfo |
local createNormalFrame |
local siValue |
function siValue (val) |
if(val >= 1e4) then |
return ("%.1f"):format(val / 1e3):gsub('%.', 'k') |
else |
return val |
end |
end |
function showMenu (self) |
local unit = self.unit:sub(1, -2) |
local cunit = self.unit:gsub("(.)", string.upper, 1) |
end |
end |
function updateHealth (self, event, bar, unit, min, max) |
function updateHealth (self, event, unit, bar, min, max) |
if not unit == self.unit then return end |
local class = select(2, UnitClass(unit)) |
bar:SetValue(0) |
bar.value:SetText('Offline') |
else |
bar.value:SetText(siValue(min)) |
bar.value:SetText(min) |
end |
end |
function updatePower (self, event, bar, unit, min, max) |
function updatePower (self, event, unit, bar, min, max) |
if min == 0 then |
bar.value:SetText(0) |
else |
bar.value:SetText(siValue(min)) |
bar.value:SetText(min) |
end |
end |
local name = UnitName(unit) |
local happiness = ' ' |
if unit == 'pet' then |
if unit == pet then |
happpiness = GetPetHappiness() and happinesstext[GetPetHappiness()]..' ' |
end |
self.Name:SetText(('%s %s %s'):format(level, happiness, name:sub(1,20))) |
self.Name:SetText(('%s %s%s'):format(level, happiness, name:sub(1, 20))) |
end |
function updatePowerInfo () |
self:SetBackdrop(framebackdrop) |
self:SetBackdropColor(0, 0, 0, 1) |
self.UNIT_LEVEL = updateHealthInfo |
self:RegisterEvent('UNIT_LEVEL') |
self:RegisterEvent('UNIT_NAME') |
self:RegisterEvent('UNIT_HAPPINESS') |
self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED') |
self:RegisterEvent('UNIT_COMBAT') |
self:RegisterEvent('UNIT_FACTION') |
self:RegisterEvent('UNIT_FLAGS') |
self:RegisterEvent('UNIT_LEVEL') |
self:RegisterEvent('UNIT_LOYALTY') |
self:RegisterEvent('UNIT_NAME_UPDATE') |
if unit == 'pet' then |
self.UNIT_HAPPINESS = updateHealthInfo |
self:RegisterEvent('UNIT_HAPPINESS') |
end |
self.UNIT_LEVEL = updateHealthInfo |
self.UNIT_NAME = updateHealthInfo |
self.UNIT_HAPPINESS = updateHealthInfo |
self.UNIT_CLASSIFICATION_CHANGED = updateHealthInfo |
self.UNIT_COMBAT = updateHealthInfo |
self.UNIT_FACTION = updateHealthInfo |
self.UNIT_FLAGS = updateHealthInfo |
self.UNIT_LEVEL = updateHealthInfo |
self.UNIT_LOYALTY = updateHealthInfo |
self.UNIT_NAME_UPDATE = updateHealthInfo |
-- buffs |
buffs:SetPoint(TR, self, TL) |