mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- made TargetHealth and TargetMana extensible so that new unit bars can be made from them easily
- added TargetTargetHealth and TargetTargetMana (idea and some code borrowed from Dark Imakuni at http://www.wowinterface.com/downloads/info10699-IceHUD-TargetofTarget.html )
This commit is contained in:
@ -49,3 +49,5 @@ modules\FocusMana.lua
|
||||
modules\FocusCast.lua
|
||||
modules\LacerateCount.lua
|
||||
modules\Runes.lua
|
||||
modules\TargetOfTargetHealth.lua
|
||||
modules\TargetOfTargetMana.lua
|
||||
|
@ -1,15 +1,20 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local MobHealth = nil
|
||||
local TargetHealth = AceOO.Class(IceUnitBar)
|
||||
|
||||
TargetHealth.prototype.color = nil
|
||||
IceTargetHealth = AceOO.Class(IceUnitBar)
|
||||
|
||||
IceTargetHealth.prototype.color = nil
|
||||
IceTargetHealth.prototype.determineColor = true
|
||||
IceTargetHealth.prototype.registerEvents = true
|
||||
|
||||
-- Constructor --
|
||||
function TargetHealth.prototype:init()
|
||||
TargetHealth.super.prototype.init(self, "TargetHealth", "target")
|
||||
|
||||
function IceTargetHealth.prototype:init(moduleName, unit)
|
||||
if not moduleName or not unit then
|
||||
IceTargetHealth.super.prototype.init(self, "TargetHealth", "target")
|
||||
else
|
||||
IceTargetHealth.super.prototype.init(self, moduleName, unit)
|
||||
end
|
||||
|
||||
self:SetDefaultColor("TargetHealthHostile", 231, 31, 36)
|
||||
self:SetDefaultColor("TargetHealthFriendly", 46, 223, 37)
|
||||
self:SetDefaultColor("TargetHealthNeutral", 210, 219, 87)
|
||||
@ -18,8 +23,8 @@ function TargetHealth.prototype:init()
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:GetDefaultSettings()
|
||||
local settings = TargetHealth.super.prototype.GetDefaultSettings(self)
|
||||
function IceTargetHealth.prototype:GetDefaultSettings()
|
||||
local settings = IceTargetHealth.super.prototype.GetDefaultSettings(self)
|
||||
|
||||
settings["side"] = IceCore.Side.Left
|
||||
settings["offset"] = 2
|
||||
@ -40,8 +45,8 @@ end
|
||||
|
||||
|
||||
-- OVERRIDE
|
||||
function TargetHealth.prototype:GetOptions()
|
||||
local opts = TargetHealth.super.prototype.GetOptions(self)
|
||||
function IceTargetHealth.prototype:GetOptions()
|
||||
local opts = IceTargetHealth.super.prototype.GetOptions(self)
|
||||
|
||||
opts["mobhealth"] = {
|
||||
type = "toggle",
|
||||
@ -228,14 +233,16 @@ function TargetHealth.prototype:GetOptions()
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:Enable(core)
|
||||
TargetHealth.super.prototype.Enable(self, core)
|
||||
function IceTargetHealth.prototype:Enable(core)
|
||||
IceTargetHealth.super.prototype.Enable(self, core)
|
||||
|
||||
self:RegisterEvent("UNIT_HEALTH", "Update")
|
||||
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
||||
self:RegisterEvent("UNIT_FLAGS", "Update")
|
||||
self:RegisterEvent("UNIT_FACTION", "Update")
|
||||
self:RegisterEvent("RAID_TARGET_UPDATE", "UpdateRaidTargetIcon")
|
||||
if self.registerEvents then
|
||||
self:RegisterEvent("UNIT_HEALTH", "Update")
|
||||
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
||||
self:RegisterEvent("UNIT_FLAGS", "Update")
|
||||
self:RegisterEvent("UNIT_FACTION", "Update")
|
||||
self:RegisterEvent("RAID_TARGET_UPDATE", "UpdateRaidTargetIcon")
|
||||
end
|
||||
|
||||
if (self.moduleSettings.hideBlizz) then
|
||||
self:HideBlizz()
|
||||
@ -247,14 +254,15 @@ function TargetHealth.prototype:Enable(core)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:Disable(core)
|
||||
TargetHealth.super.prototype.Disable(self, core)
|
||||
function IceTargetHealth.prototype:Disable(core)
|
||||
IceTargetHealth.super.prototype.Disable(self, core)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TargetHealth.prototype:Update(unit)
|
||||
TargetHealth.super.prototype.Update(self)
|
||||
function IceTargetHealth.prototype:Update(unit)
|
||||
IceTargetHealth.super.prototype.Update(self)
|
||||
|
||||
if (unit and (unit ~= self.unit)) then
|
||||
return
|
||||
end
|
||||
@ -268,25 +276,27 @@ function TargetHealth.prototype:Update(unit)
|
||||
|
||||
self:UpdateRaidTargetIcon()
|
||||
|
||||
self.color = "TargetHealthFriendly" -- friendly > 4
|
||||
if self.determineColor then
|
||||
self.color = "TargetHealthFriendly" -- friendly > 4
|
||||
|
||||
local reaction = UnitReaction("target", "player")
|
||||
if (reaction and (reaction == 4)) then
|
||||
self.color = "TargetHealthNeutral"
|
||||
elseif (reaction and (reaction < 4)) then
|
||||
self.color = "TargetHealthHostile"
|
||||
end
|
||||
local reaction = UnitReaction("target", "player")
|
||||
if (reaction and (reaction == 4)) then
|
||||
self.color = "TargetHealthNeutral"
|
||||
elseif (reaction and (reaction < 4)) then
|
||||
self.color = "TargetHealthHostile"
|
||||
end
|
||||
|
||||
if (self.moduleSettings.classColor) then
|
||||
self.color = self.unitClass
|
||||
end
|
||||
if (self.moduleSettings.classColor) then
|
||||
self.color = self.unitClass
|
||||
end
|
||||
|
||||
if (self.moduleSettings.scaleHealthColor) then
|
||||
self.color = "ScaledHealthColor"
|
||||
end
|
||||
if (self.moduleSettings.scaleHealthColor) then
|
||||
self.color = "ScaledHealthColor"
|
||||
end
|
||||
|
||||
if (self.tapped) then
|
||||
self.color = "Tapped"
|
||||
if (self.tapped) then
|
||||
self.color = "Tapped"
|
||||
end
|
||||
end
|
||||
|
||||
self:UpdateBar(self.health/self.maxHealth, self.color)
|
||||
@ -316,14 +326,10 @@ function TargetHealth.prototype:Update(unit)
|
||||
self:SetBottomText2()
|
||||
end
|
||||
end
|
||||
|
||||
if self.frame.raidIcon then
|
||||
self.frame.raidIcon:SetAlpha(self.moduleSettings.lockIconAlpha and 1 or self.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:CreateRaidIconFrame()
|
||||
function IceTargetHealth.prototype:CreateRaidIconFrame()
|
||||
if (not self.frame.raidIcon) then
|
||||
self.frame.raidIcon = CreateFrame("Frame", nil, self.frame)
|
||||
end
|
||||
@ -342,13 +348,13 @@ function TargetHealth.prototype:CreateRaidIconFrame()
|
||||
self.frame.raidIcon:Hide()
|
||||
end
|
||||
|
||||
function TargetHealth.prototype:SetRaidIconPlacement()
|
||||
function IceTargetHealth.prototype:SetRaidIconPlacement()
|
||||
self.frame.raidIcon:ClearAllPoints()
|
||||
self.frame.raidIcon:SetPoint("BOTTOM", self.frame, "TOPLEFT", self.moduleSettings.raidIconXOffset, self.moduleSettings.raidIconYOffset)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:UpdateRaidTargetIcon()
|
||||
function IceTargetHealth.prototype:UpdateRaidTargetIcon()
|
||||
if self.moduleSettings.raidIconOnTop then
|
||||
self.frame.raidIcon:SetFrameStrata("MEDIUM")
|
||||
else
|
||||
@ -368,10 +374,14 @@ function TargetHealth.prototype:UpdateRaidTargetIcon()
|
||||
else
|
||||
self.frame.raidIcon:Hide()
|
||||
end
|
||||
|
||||
if self.frame.raidIcon then
|
||||
self.frame.raidIcon:SetAlpha(self.moduleSettings.lockIconAlpha and 1 or self.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:Round(health)
|
||||
function IceTargetHealth.prototype:Round(health)
|
||||
if (health > 1000000) then
|
||||
return self:MathRound(health/1000000, 1) .. "M"
|
||||
end
|
||||
@ -382,7 +392,7 @@ function TargetHealth.prototype:Round(health)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:MathRound(num, idp)
|
||||
function IceTargetHealth.prototype:MathRound(num, idp)
|
||||
local mult = 10^(idp or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
@ -391,7 +401,7 @@ end
|
||||
|
||||
|
||||
|
||||
function TargetHealth.prototype:ShowBlizz()
|
||||
function IceTargetHealth.prototype:ShowBlizz()
|
||||
TargetFrame:Show()
|
||||
TargetFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
TargetFrame:RegisterEvent("UNIT_HEALTH")
|
||||
@ -409,7 +419,7 @@ function TargetHealth.prototype:ShowBlizz()
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:HideBlizz()
|
||||
function IceTargetHealth.prototype:HideBlizz()
|
||||
TargetFrame:Hide()
|
||||
TargetFrame:UnregisterAllEvents()
|
||||
|
||||
@ -420,4 +430,4 @@ end
|
||||
|
||||
|
||||
-- Load us up
|
||||
IceHUD.TargetHealth = TargetHealth:new()
|
||||
IceHUD.TargetHealth = IceTargetHealth:new()
|
||||
|
@ -1,11 +1,16 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local TargetMana = AceOO.Class(IceUnitBar)
|
||||
IceTargetMana = AceOO.Class(IceUnitBar)
|
||||
IceTargetMana.prototype.registerEvents = true
|
||||
|
||||
|
||||
-- Constructor --
|
||||
function TargetMana.prototype:init()
|
||||
TargetMana.super.prototype.init(self, "TargetMana", "target")
|
||||
function IceTargetMana.prototype:init(moduleName, unit)
|
||||
if not moduleName or not unit then
|
||||
IceTargetMana.super.prototype.init(self, "TargetMana", "target")
|
||||
else
|
||||
IceTargetMana.super.prototype.init(self, moduleName, unit)
|
||||
end
|
||||
|
||||
self:SetDefaultColor("TargetMana", 52, 64, 221)
|
||||
self:SetDefaultColor("TargetRage", 235, 44, 26)
|
||||
@ -14,8 +19,8 @@ function TargetMana.prototype:init()
|
||||
end
|
||||
|
||||
|
||||
function TargetMana.prototype:GetDefaultSettings()
|
||||
local settings = TargetMana.super.prototype.GetDefaultSettings(self)
|
||||
function IceTargetMana.prototype:GetDefaultSettings()
|
||||
local settings = IceTargetMana.super.prototype.GetDefaultSettings(self)
|
||||
|
||||
settings["side"] = IceCore.Side.Right
|
||||
settings["offset"] = 2
|
||||
@ -26,42 +31,44 @@ function TargetMana.prototype:GetDefaultSettings()
|
||||
end
|
||||
|
||||
|
||||
function TargetMana.prototype:Enable(core)
|
||||
TargetMana.super.prototype.Enable(self, core)
|
||||
function IceTargetMana.prototype:Enable(core)
|
||||
IceTargetMana.super.prototype.Enable(self, core)
|
||||
|
||||
self:RegisterEvent("UNIT_MAXMANA", "Update")
|
||||
self:RegisterEvent("UNIT_MAXRAGE", "Update")
|
||||
self:RegisterEvent("UNIT_MAXENERGY", "Update")
|
||||
self:RegisterEvent("UNIT_MAXFOCUS", "Update")
|
||||
self:RegisterEvent("UNIT_AURA", "Update")
|
||||
self:RegisterEvent("UNIT_FLAGS", "Update")
|
||||
-- DK rune stuff
|
||||
if IceHUD.WowVer >= 30000 then
|
||||
if GetCVarBool("predictedPower") and self.frame then
|
||||
self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
|
||||
if self.registerEvents then
|
||||
self:RegisterEvent("UNIT_MAXMANA", "Update")
|
||||
self:RegisterEvent("UNIT_MAXRAGE", "Update")
|
||||
self:RegisterEvent("UNIT_MAXENERGY", "Update")
|
||||
self:RegisterEvent("UNIT_MAXFOCUS", "Update")
|
||||
self:RegisterEvent("UNIT_AURA", "Update")
|
||||
self:RegisterEvent("UNIT_FLAGS", "Update")
|
||||
-- DK rune stuff
|
||||
if IceHUD.WowVer >= 30000 then
|
||||
if GetCVarBool("predictedPower") and self.frame then
|
||||
self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
|
||||
else
|
||||
self:RegisterEvent("UNIT_MANA", "Update")
|
||||
self:RegisterEvent("UNIT_RAGE", "Update")
|
||||
self:RegisterEvent("UNIT_ENERGY", "Update")
|
||||
self:RegisterEvent("UNIT_FOCUS", "Update")
|
||||
self:RegisterEvent("UNIT_RUNIC_POWER", "Update")
|
||||
end
|
||||
|
||||
self:RegisterEvent("UNIT_MAXRUNIC_POWER", "Update")
|
||||
else
|
||||
self:RegisterEvent("UNIT_MANA", "Update")
|
||||
self:RegisterEvent("UNIT_RAGE", "Update")
|
||||
self:RegisterEvent("UNIT_ENERGY", "Update")
|
||||
self:RegisterEvent("UNIT_FOCUS", "Update")
|
||||
self:RegisterEvent("UNIT_RUNIC_POWER", "Update")
|
||||
end
|
||||
|
||||
self:RegisterEvent("UNIT_MAXRUNIC_POWER", "Update")
|
||||
else
|
||||
self:RegisterEvent("UNIT_MANA", "Update")
|
||||
self:RegisterEvent("UNIT_RAGE", "Update")
|
||||
self:RegisterEvent("UNIT_ENERGY", "Update")
|
||||
self:RegisterEvent("UNIT_FOCUS", "Update")
|
||||
end
|
||||
|
||||
self:Update("target")
|
||||
self:Update(self.unit)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TargetMana.prototype:Update(unit)
|
||||
TargetMana.super.prototype.Update(self)
|
||||
function IceTargetMana.prototype:Update(unit)
|
||||
IceTargetMana.super.prototype.Update(self)
|
||||
if (unit and (unit ~= self.unit)) then
|
||||
return
|
||||
end
|
||||
@ -102,8 +109,8 @@ end
|
||||
|
||||
|
||||
-- OVERRIDE
|
||||
function TargetMana.prototype:GetOptions()
|
||||
local opts = TargetMana.super.prototype.GetOptions(self)
|
||||
function IceTargetMana.prototype:GetOptions()
|
||||
local opts = IceTargetMana.super.prototype.GetOptions(self)
|
||||
|
||||
opts["scaleManaColor"] = {
|
||||
type = "toggle",
|
||||
@ -127,4 +134,4 @@ end
|
||||
|
||||
|
||||
-- Load us up
|
||||
IceHUD.TargetMana = TargetMana:new()
|
||||
IceHUD.TargetMana = IceTargetMana:new()
|
||||
|
125
modules/TargetOfTargetHealth.lua
Normal file
125
modules/TargetOfTargetHealth.lua
Normal file
@ -0,0 +1,125 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local TargetTargetHealth = AceOO.Class(IceTargetHealth)
|
||||
|
||||
|
||||
-- Constructor --
|
||||
function TargetTargetHealth.prototype:init()
|
||||
TargetTargetHealth.super.prototype.init(self, "TargetTargetHealth", "targettarget")
|
||||
|
||||
self:SetDefaultColor("TargetTargetHealthHostile", 231, 31, 36)
|
||||
self:SetDefaultColor("TargetTargetHealthFriendly", 46, 223, 37)
|
||||
self:SetDefaultColor("TargetTargetHealthNeutral", 210, 219, 87)
|
||||
self:SetDefaultColor("SelfColor", 255, 255, 255)
|
||||
end
|
||||
|
||||
function TargetTargetHealth.prototype:GetDefaultSettings()
|
||||
local settings = TargetTargetHealth.super.prototype.GetDefaultSettings(self)
|
||||
|
||||
settings["side"] = IceCore.Side.Right
|
||||
settings["offset"] = 12
|
||||
settings["mobHealth"] = (MobHealth3 ~= nil)
|
||||
settings["classColor"] = false
|
||||
settings["selfColor"] = { r = 0, g = 0, b = 1 }
|
||||
settings["useSelfColor"] = true
|
||||
settings["upperText"] = "[PercentHP:Round]"
|
||||
settings["lowerText"] = "[(HP:Round \"/\" MaxHP:Round):HPColor:Bracket]"
|
||||
settings["barVerticalOffset"] = 35
|
||||
settings["scale"] = 0.7
|
||||
settings["enabled"] = false
|
||||
settings["hideBlizz"] = false
|
||||
|
||||
return settings
|
||||
end
|
||||
|
||||
|
||||
-- OVERRIDE
|
||||
function TargetTargetHealth.prototype:GetOptions()
|
||||
local opts = TargetTargetHealth.super.prototype.GetOptions(self)
|
||||
|
||||
opts["hideBlizz"] = nil
|
||||
|
||||
opts["useSelfColor"] = {
|
||||
type = "toggle",
|
||||
name = "Use Self Color",
|
||||
desc = "Whether or not to use the self color.",
|
||||
get = function()
|
||||
return self.moduleSettings.useSelfColor
|
||||
end,
|
||||
set = function(value)
|
||||
self.moduleSettings.useSelfColor = value
|
||||
end,
|
||||
disabled = function()
|
||||
return not self.moduleSettings.enabled
|
||||
end,
|
||||
order = 44,
|
||||
}
|
||||
|
||||
opts["selfColor"] = {
|
||||
type = "color",
|
||||
name = "Self Color",
|
||||
desc = "Set the color of the TargetTarget bar if you are your target's target.",
|
||||
get = function()
|
||||
return self.moduleSettings.selfColor.r, self.moduleSettings.selfColor.g, self.moduleSettings.selfColor.b
|
||||
end,
|
||||
set = function(r, g, b)
|
||||
self.moduleSettings.selfColor = { r = r, g = g, b = b }
|
||||
IceHUD.IceCore:SetColor("SelfColor", r, g, b)
|
||||
end,
|
||||
disabled = function()
|
||||
return not self.moduleSettings.enabled or not self.moduleSettings.useSelfColor
|
||||
end,
|
||||
hasAlpha = false,
|
||||
order = 45,
|
||||
}
|
||||
|
||||
return opts
|
||||
end
|
||||
|
||||
|
||||
function TargetTargetHealth.prototype:Enable(core)
|
||||
self.registerEvents = false
|
||||
TargetTargetHealth.super.prototype.Enable(self, core)
|
||||
|
||||
self:ScheduleRepeatingEvent(self.elementName, self.Update, 0.1, self, "targettarget")
|
||||
end
|
||||
|
||||
function TargetTargetHealth.prototype:Disable(core)
|
||||
TargetTargetHealth.super.prototype.Disable(self, core)
|
||||
|
||||
self:CancelScheduledEvent(self.elementName)
|
||||
end
|
||||
|
||||
function TargetTargetHealth.prototype:Update(unit)
|
||||
self.color = "TargetTargetHealthFriendly" -- friendly > 4
|
||||
|
||||
local reaction = UnitReaction("targettarget", "player")
|
||||
|
||||
if (reaction and (reaction == 4)) then
|
||||
self.color = "TargetTargetHealthNeutral"
|
||||
elseif (reaction and (reaction < 4)) then
|
||||
self.color = "TargetTargetHealthHostile"
|
||||
end
|
||||
|
||||
if (self.moduleSettings.classColor) then
|
||||
self.color = self.unitClass
|
||||
end
|
||||
|
||||
if (self.moduleSettings.scaleHealthColor) then
|
||||
self.color = "ScaledHealthColor"
|
||||
end
|
||||
|
||||
if (self.tapped) then
|
||||
self.color = "Tapped"
|
||||
end
|
||||
|
||||
if UnitIsUnit("player", "targettarget") and self.moduleSettings.useSelfColor then
|
||||
self.color = "SelfColor"
|
||||
end
|
||||
|
||||
self.determineColor = false
|
||||
TargetTargetHealth.super.prototype.Update(self, unit)
|
||||
end
|
||||
|
||||
-- Load us up
|
||||
IceHUD.TargetTargetHealth = TargetTargetHealth:new()
|
43
modules/TargetOfTargetMana.lua
Normal file
43
modules/TargetOfTargetMana.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local TargetTargetMana = AceOO.Class(IceTargetMana)
|
||||
|
||||
-- Constructor --
|
||||
function TargetTargetMana.prototype:init()
|
||||
TargetTargetMana.super.prototype.init(self, "TargetTargetMana", "targettarget")
|
||||
|
||||
self:SetDefaultColor("TargetTargetMana", 52, 64, 221)
|
||||
self:SetDefaultColor("TargetTargetRage", 235, 44, 26)
|
||||
self:SetDefaultColor("TargetTargetEnergy", 228, 242, 31)
|
||||
self:SetDefaultColor("TargetTargetFocus", 242, 149, 98)
|
||||
end
|
||||
|
||||
function TargetTargetMana.prototype:GetDefaultSettings()
|
||||
local settings = TargetTargetMana.super.prototype.GetDefaultSettings(self)
|
||||
|
||||
settings["side"] = IceCore.Side.Right
|
||||
settings["offset"] = 11
|
||||
settings["upperText"] = "[PercentMP:Round]"
|
||||
settings["lowerText"] = "[FractionalMP:PowerColor]"
|
||||
settings["barVerticalOffset"] = 35
|
||||
settings["scale"] = 0.7
|
||||
settings["enabled"] = false
|
||||
|
||||
return settings
|
||||
end
|
||||
|
||||
function TargetTargetMana.prototype:Enable(core)
|
||||
self.registerEvents = false
|
||||
TargetTargetMana.super.prototype.Enable(self, core)
|
||||
|
||||
self:ScheduleRepeatingEvent(self.elementName, self.Update, 0.1, self, "targettarget")
|
||||
end
|
||||
|
||||
function TargetTargetMana.prototype:Disable(core)
|
||||
TargetTargetMana.super.prototype.Disable(self, core)
|
||||
|
||||
self:CancelScheduledEvent(self.elementName)
|
||||
end
|
||||
|
||||
-- Load us up
|
||||
IceHUD.TargetTargetMana = TargetTargetMana:new()
|
Reference in New Issue
Block a user