mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- Added basic pet support - Added configuration (via both console and Dewdrop) - Fixed indexing problem with non-English clients
54 lines
1.1 KiB
Lua
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()
|
|
PlayerHealth.super.prototype.Enable(self)
|
|
|
|
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()
|