Changed support from MobHealth2 to MobHealth3

This commit is contained in:
iceroth
2006-08-08 14:49:52 +00:00
parent 259ff592a0
commit 5d31c65650
2 changed files with 17 additions and 69 deletions

View File

@ -3,11 +3,12 @@
## Name: IceHUD ## Name: IceHUD
## Title: IceHUD |cff7fff7f -Ace2-|r ## Title: IceHUD |cff7fff7f -Ace2-|r
## Notes: Another HUD mod ## Notes: Another HUD mod
## Version: 0.4 ($Revision$) ## Version: 0.4.1 ($Revision$)
## SavedVariables: IceCoreDB ## SavedVariables: IceCoreDB
## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax, MobHealth ## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax, MobHealth
## X-Category: UnitFrame ## X-Category: UnitFrame
## X-Date: $Date$ ## X-Date: $Date$
## X-eMail: iceroth@iceroth.net
## 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
# Libraries # Libraries

View File

@ -2,8 +2,6 @@ local AceOO = AceLibrary("AceOO-2.0")
local TargetHealth = AceOO.Class(IceUnitBar, "AceHook-2.0") local TargetHealth = AceOO.Class(IceUnitBar, "AceHook-2.0")
TargetHealth.prototype.mobHealth = nil
TargetHealth.prototype.mobMaxHealth = nil
TargetHealth.prototype.color = nil TargetHealth.prototype.color = nil
@ -32,18 +30,17 @@ function TargetHealth.prototype:GetOptions()
opts["mobhealth"] = { opts["mobhealth"] = {
type = "toggle", type = "toggle",
name = "MobHealth2 support", name = "MobHealth3 support",
desc = "Will NOT work with the original MobHealth addon", desc = "Enable/disable MobHealth3 target HP data. If this option is gray, you do not have MobHealth3.",
get = function() get = function()
return self.moduleSettings.mobhealth return self.moduleSettings.mobhealth
end, end,
set = function(value) set = function(value)
self.moduleSettings.mobhealth = value self.moduleSettings.mobhealth = value
if (self.moduleSettings.mobhealth) then self:Update(self.unit)
self:EnableMobHealth() end,
else disabled = function()
self:DisableMobHealth() return (MobHealth3 == nil)
end
end, end,
order = 40 order = 40
} }
@ -59,11 +56,7 @@ 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.moduleSettings.mobhealth) then self:Update(self.unit)
self:EnableMobHealth()
end
self:Update("target")
end end
@ -74,22 +67,8 @@ function TargetHealth.prototype:Disable()
end end
function TargetHealth.prototype:EnableMobHealth()
if (IsAddOnLoaded("MobHealth")) then
self:Hook("MobHealth_OnEvent", "MobHealth")
end
end
function TargetHealth.prototype:DisableMobHealth()
if (self:IsHooked("MobHealth_OnEvent")) then
self:Unhook("MobHealth_OnEvent")
end
end
function TargetHealth.prototype:TargetChanged() function TargetHealth.prototype:TargetChanged()
self:Update("target") self:Update(self.unit)
end end
@ -122,50 +101,18 @@ function TargetHealth.prototype:Update(unit)
self:UpdateBar(self.health/self.maxHealth, self.color) self:UpdateBar(self.health/self.maxHealth, self.color)
self:SetBottomText1(self.healthPercentage) self:SetBottomText1(self.healthPercentage)
self:UpdateHealthText(false)
end
function TargetHealth.prototype:MobHealth(event)
self.hooks.MobHealth_OnEvent.orig(event)
-- we are getting valid values from the server, no need for MobHealth2 if (self.moduleSettings.mobhealth and MobHealth3) then
if (self.maxHealth ~= 100) then self.health, self.maxHealth, _ = MobHealth3:GetUnitHealth(self.unit, self.health, self.maxHealth)
self.mobHealth = nil
self.mobMaxHealth = nil
self:UpdateHealthText(false)
return
end end
self.mobHealth = MobHealth_GetTargetCurHP() -- assumption that if a unit's max health is 100, it's not actual amount
self.mobMaxHealth = MobHealth_GetTargetMaxHP() -- but rather a percentage - this obviously has one caveat though
self:UpdateHealthText(true) if (self.maxHealth ~= 100) then
end self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), self.color)
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
if (validData and self.moduleSettings.mobhealth) then self:SetBottomText2()
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