mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- Added MobHealth2 support
- Added check if ToFu is enabled for TimerBar
This commit is contained in:
@ -3,9 +3,9 @@
|
|||||||
## Name: IceHUD
|
## Name: IceHUD
|
||||||
## Title: IceHUD |cff7fff7f -Ace2-|r
|
## Title: IceHUD |cff7fff7f -Ace2-|r
|
||||||
## Notes: Another HUD mod
|
## Notes: Another HUD mod
|
||||||
## Version: 0.3 ($Revision$)
|
## Version: 0.3.1 ($Revision$)
|
||||||
## SavedVariables: IceCoreDB
|
## SavedVariables: IceCoreDB
|
||||||
## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax
|
## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax, MobHealth
|
||||||
## X-Category: UnitFrame
|
## X-Category: UnitFrame
|
||||||
## X-Date: $Date$
|
## X-Date: $Date$
|
||||||
## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html
|
## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
local AceOO = AceLibrary("AceOO-2.0")
|
local AceOO = AceLibrary("AceOO-2.0")
|
||||||
|
|
||||||
local TargetHealth = AceOO.Class(IceUnitBar)
|
local TargetHealth = AceOO.Class(IceUnitBar, "AceHook-2.0")
|
||||||
|
|
||||||
|
TargetHealth.prototype.mobHealthEnabled = nil
|
||||||
|
TargetHealth.prototype.mobHealth = nil
|
||||||
|
TargetHealth.prototype.mobMaxHealth = nil
|
||||||
|
TargetHealth.prototype.color = nil
|
||||||
|
|
||||||
|
|
||||||
-- Constructor --
|
-- Constructor --
|
||||||
function TargetHealth.prototype:init()
|
function TargetHealth.prototype:init()
|
||||||
@ -9,6 +15,8 @@ function TargetHealth.prototype:init()
|
|||||||
self:SetColor("targetHealthHostile", 231, 31, 36)
|
self:SetColor("targetHealthHostile", 231, 31, 36)
|
||||||
self:SetColor("targetHealthFriendly", 46, 223, 37)
|
self:SetColor("targetHealthFriendly", 46, 223, 37)
|
||||||
self:SetColor("targetHealthNeutral", 210, 219, 87)
|
self:SetColor("targetHealthNeutral", 210, 219, 87)
|
||||||
|
|
||||||
|
self.mobHealthEnabled = IsAddOnLoaded("MobHealth")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -28,10 +36,23 @@ function TargetHealth.prototype:Enable()
|
|||||||
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
||||||
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
|
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
|
||||||
|
|
||||||
|
if (self.mobHealthEnabled) then
|
||||||
|
self:Hook("MobHealth_OnEvent", "MobHealth")
|
||||||
|
end
|
||||||
|
|
||||||
self:Update("target")
|
self:Update("target")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TargetHealth.prototype:Disable()
|
||||||
|
TargetHealth.super.prototype.Disable(self)
|
||||||
|
|
||||||
|
if (self.mobHealthEnabled) then
|
||||||
|
self:Unhook("MobHealth_OnEvent")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function TargetHealth.prototype:TargetChanged()
|
function TargetHealth.prototype:TargetChanged()
|
||||||
self:Update("target")
|
self:Update("target")
|
||||||
end
|
end
|
||||||
@ -50,28 +71,62 @@ function TargetHealth.prototype:Update(unit)
|
|||||||
self.frame:Show()
|
self.frame:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
local color = "targetHealthFriendly" -- friendly > 4
|
self.color = "targetHealthFriendly" -- friendly > 4
|
||||||
|
|
||||||
local reaction = UnitReaction("target", "player")
|
local reaction = UnitReaction("target", "player")
|
||||||
if (reaction and (reaction == 4)) then
|
if (reaction and (reaction == 4)) then
|
||||||
color = "targetHealthNeutral"
|
self.color = "targetHealthNeutral"
|
||||||
elseif (reaction and (reaction < 4)) then
|
elseif (reaction and (reaction < 4)) then
|
||||||
color = "targetHealthHostile"
|
self.color = "targetHealthHostile"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.tapped) then
|
if (self.tapped) then
|
||||||
color = "tapped"
|
self.color = "tapped"
|
||||||
end
|
end
|
||||||
|
|
||||||
self:UpdateBar(self.health/self.maxHealth, color)
|
self:UpdateBar(self.health/self.maxHealth, self.color)
|
||||||
self:SetBottomText1(self.healthPercentage)
|
self:SetBottomText1(self.healthPercentage)
|
||||||
|
|
||||||
-- assumption that if a unit's max health is 100, it's not actual amount
|
self:UpdateHealthText(false)
|
||||||
-- but rather a percentage - this obviously has one caveat though
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TargetHealth.prototype:MobHealth(event)
|
||||||
|
self.hooks.MobHealth_OnEvent.orig(event)
|
||||||
|
|
||||||
if (self.maxHealth ~= 100) then
|
if (self.maxHealth ~= 100) then
|
||||||
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), color)
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.mobHealth = MobHealth_GetTargetCurHP()
|
||||||
|
self.mobMaxHealth = MobHealth_GetTargetMaxHP()
|
||||||
|
|
||||||
|
self:UpdateHealthText(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TargetHealth.prototype:UpdateHealthText(mobHealth)
|
||||||
|
local validData = (self.mobHealth and self.mobMaxHealth and self.health > 0 and self.mobMaxHealth > 0)
|
||||||
|
|
||||||
|
if (mobHealth) then
|
||||||
|
if (validData) then
|
||||||
|
self:SetBottomText2(self:GetFormattedText(self.mobHealth, self.mobMaxHealth), self.color)
|
||||||
|
else
|
||||||
|
self:SetBottomText2()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self:SetBottomText2(nil, color)
|
if (validData) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- assumption that if a unit's max health is 100, it's not actual amount
|
||||||
|
-- but rather a percentage - this obviously has one caveat though
|
||||||
|
|
||||||
|
if (self.maxHealth ~= 100) then
|
||||||
|
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), self.color)
|
||||||
|
else
|
||||||
|
self:SetBottomText2()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ end
|
|||||||
|
|
||||||
-- 'Protected' methods --------------------------------------------------------
|
-- 'Protected' methods --------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
function TimerBar.prototype:OnUpdate(object, timeSinceLast)
|
function TimerBar.prototype:OnUpdate(object, timeSinceLast)
|
||||||
self.hooks[object].OnUpdate.orig(object, timeSinceLast)
|
self.hooks[object].OnUpdate.orig(object, timeSinceLast)
|
||||||
|
|
||||||
@ -67,4 +66,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Load us up
|
-- Load us up
|
||||||
TimerBar:new()
|
if (IsAddOnLoaded("FuBar_ToFu")) then
|
||||||
|
TimerBar:new()
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user