Files
ice-hud/modules/PlayerHealth.lua
2006-08-26 13:50:55 +00:00

54 lines
1.1 KiB
Lua

local AceOO = AceLibrary("AceOO-2.0")
local PlayerHealth = AceOO.Class(IceUnitBar)
-- Constructor --
function PlayerHealth.prototype:init()
PlayerHealth.super.prototype.init(self, "PlayerHealth", "player")
self:SetColor("playerHealth", 37, 164, 30)
end
function PlayerHealth.prototype:GetDefaultSettings()
local settings = PlayerHealth.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Left
settings["offset"] = 1
return settings
end
function PlayerHealth.prototype:Enable(core)
PlayerHealth.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_HEALTH", "Update")
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
self:Update(self.unit)
end
function PlayerHealth.prototype:Update(unit)
PlayerHealth.super.prototype.Update(self)
if (unit and (unit ~= self.unit)) then
return
end
local color = "playerHealth"
if not (self.alive) then
color = "dead"
end
self:UpdateBar(self.health/self.maxHealth, color)
self:SetBottomText1(self.healthPercentage)
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), color)
end
-- Load us up
PlayerHealth:new()