diff --git a/IceBarElement.lua b/IceBarElement.lua
index 2883bb2..b71a5ee 100644
--- a/IceBarElement.lua
+++ b/IceBarElement.lua
@@ -58,7 +58,7 @@ end
function IceBarElement.prototype:RegisterFontStrings()
- if DogTag ~= nil and self.moduleSettings.usesDogTagStrings then
+ if DogTag ~= nil and self.moduleSettings ~= nil and self.moduleSettings.usesDogTagStrings then
if self.frame.bottomUpperText and self.moduleSettings.upperText then
DogTag:AddFontString(self.frame.bottomUpperText, self.frame, self.moduleSettings.upperText, "Unit", { unit = self.unit })
end
diff --git a/IceCore.lua b/IceCore.lua
index 96b0e9b..ea47e41 100644
--- a/IceCore.lua
+++ b/IceCore.lua
@@ -120,21 +120,31 @@ function IceCore.prototype:Enable()
end
for k,v in pairs(self.settings.modules) do
- if self.settings.modules[k].customBarType == "Bar" then
+ if self.settings.modules[k].customBarType == "Bar" and IceCustomBar ~= nil then
local newBar
newBar = IceCustomBar:new()
newBar.elementName = k
self:AddNewDynamicModule(newBar, true)
- elseif self.settings.modules[k].customBarType == "Counter" then
+ elseif self.settings.modules[k].customBarType == "Counter" and IceCustomCount ~= nil then
local newCounter
newCounter = IceCustomCount:new()
newCounter.elementName = k
self:AddNewDynamicModule(newCounter, true)
- elseif self.settings.modules[k].customBarType == "CD" then
+ elseif self.settings.modules[k].customBarType == "CD" and IceCustomCDBar ~= nil then
local newCD
newCD = IceCustomCDBar:new()
newCD.elementName = k
self:AddNewDynamicModule(newCD, true)
+ elseif self.settings.modules[k].customBarType == "Health" and IceCustomHealth ~= nil then
+ local newHealth
+ newHealth = IceCustomHealth:new()
+ newHealth.elementName = k
+ self:AddNewDynamicModule(newHealth, true)
+ elseif self.settings.modules[k].customBarType == "Mana" and IceCustomMana ~= nil then
+ local newMana
+ newMana = IceCustomMana:new()
+ newMana.elementName = k
+ self:AddNewDynamicModule(newMana, true)
end
end
diff --git a/IceHUD.lua b/IceHUD.lua
index fccc803..1f74fdc 100644
--- a/IceHUD.lua
+++ b/IceHUD.lua
@@ -551,6 +551,34 @@ IceHUD.options =
order = 94.7
},
+ customHealth = {
+ type = 'execute',
+ name = 'Custom health bar',
+ desc = 'Creates a new customized health bar. This bar monitors the health of whatever unit you specify. You can create as many of these as you like.',
+ func = function()
+ IceHUD.IceCore:AddNewDynamicModule(IceCustomHealth:new())
+ StaticPopup_Show("ICEHUD_CUSTOM_HEALTH_CREATED")
+ end,
+ hidden = function()
+ return IceCustomHealth == nil
+ end,
+ order = 94.8
+ },
+
+ customMana = {
+ type = 'execute',
+ name = 'Custom mana bar',
+ desc = 'Creates a new customized mana bar. This bar monitors the mana of whatever unit you specify. You can create as many of these as you like.',
+ func = function()
+ IceHUD.IceCore:AddNewDynamicModule(IceCustomMana:new())
+ StaticPopup_Show("ICEHUD_CUSTOM_MANA_CREATED")
+ end,
+ hidden = function()
+ return IceCustomMana == nil
+ end,
+ order = 94.8
+ },
+
configMode = {
type = 'toggle',
name = '|cffff0000Configuration Mode|r',
@@ -667,6 +695,24 @@ StaticPopupDialogs["ICEHUD_CUSTOM_CD_CREATED"] =
hideOnEscape = 0,
}
+StaticPopupDialogs["ICEHUD_CUSTOM_HEALTH_CREATED"] =
+{
+ text = "A custom health bar has been created and can be configured through Module Settings => MyCustomHealth. It is highly recommended that you change the bar name of this module so that it's easier to identify.",
+ button1 = OKAY,
+ timeout = 0,
+ whileDead = 1,
+ hideOnEscape = 0,
+}
+
+StaticPopupDialogs["ICEHUD_CUSTOM_MANA_CREATED"] =
+{
+ text = "A custom mana bar has been created and can be configured through Module Settings => MyCustomMana. It is highly recommended that you change the bar name of this module so that it's easier to identify.",
+ button1 = OKAY,
+ timeout = 0,
+ whileDead = 1,
+ hideOnEscape = 0,
+}
+
StaticPopupDialogs["ICEHUD_DELETE_CUSTOM_MODULE"] =
{
text = "Are you sure you want to delete this module? This will remove all settings associated with it and cannot be un-done.",
diff --git a/IceHUD.toc b/IceHUD.toc
index 177f702..12dd596 100644
--- a/IceHUD.toc
+++ b/IceHUD.toc
@@ -69,3 +69,5 @@ modules\TargetInvuln.lua
# - PlayerInvuln must be after TargetInvuln
modules\PlayerInvuln.lua
modules\ComboPointsBar.lua
+modules\CustomHealth.lua
+modules\CustomMana.lua
diff --git a/IceUnitBar.lua b/IceUnitBar.lua
index 75cd94f..c277f3c 100644
--- a/IceUnitBar.lua
+++ b/IceUnitBar.lua
@@ -26,8 +26,7 @@ function IceUnitBar.prototype:init(name, unit)
IceUnitBar.super.prototype.init(self, name)
assert(unit, "IceUnitBar 'unit' is nil")
- self.unit = unit
- _, self.unitClass = UnitClass(self.unit)
+ self:SetUnit(unit)
self.noFlash = false
self:SetDefaultColor("Dead", 0.5, 0.5, 0.5)
@@ -47,6 +46,10 @@ function IceUnitBar.prototype:init(name, unit)
self.scaleMPColorInst = { r = 0, g = 0, b = 255 }
end
+function IceUnitBar.prototype:SetUnit(unit)
+ self.unit = unit
+ _, self.unitClass = UnitClass(self.unit)
+end
-- OVERRIDE
function IceUnitBar.prototype:GetDefaultSettings()
diff --git a/modules/CustomHealth.lua b/modules/CustomHealth.lua
new file mode 100644
index 0000000..c2e72ad
--- /dev/null
+++ b/modules/CustomHealth.lua
@@ -0,0 +1,221 @@
+local AceOO = AceLibrary("AceOO-2.0")
+
+IceCustomHealth = AceOO.Class(IceTargetHealth)
+
+-- Constructor --
+function IceCustomHealth.prototype:init()
+ IceCustomHealth.super.prototype.init(self, "IceCustomHealth", "focustarget")
+
+-- these aren't working...don't know why
+--[[ self:SetDefaultColor("CustomHealthHostile", 231, 31, 36)
+ self:SetDefaultColor("CustomHealthFriendly", 46, 223, 37)
+ self:SetDefaultColor("CustomHealthNeutral", 210, 219, 87)
+]]--
+end
+
+function IceCustomHealth.prototype:GetDefaultSettings()
+ local settings = IceCustomHealth.super.prototype.GetDefaultSettings(self)
+
+ settings["side"] = IceCore.Side.Left
+ settings["offset"] = -3
+ settings["classColor"] = false
+ settings["barVerticalOffset"] = 0
+ settings["scale"] = 1
+ settings["allowMouseInteraction"] = false
+ settings["customBarType"] = "Health"
+ settings["unitToTrack"] = "focustarget"
+
+ return settings
+end
+
+
+-- OVERRIDE
+function IceCustomHealth.prototype:GetOptions()
+ local opts = IceCustomHealth.super.prototype.GetOptions(self)
+
+ opts["hideBlizz"] = nil
+
+ opts["customHeader"] = {
+ type = 'header',
+ name = "Custom bar settings",
+ order = 20.1,
+ }
+
+ opts["deleteme"] = {
+ type = 'execute',
+ name = 'Delete me',
+ desc = 'Deletes this custom module and all associated settings. Cannot be undone!',
+ func = function()
+ local dialog = StaticPopup_Show("ICEHUD_DELETE_CUSTOM_MODULE")
+ if dialog then
+ dialog.data = self
+ end
+ end,
+ order = 20.2,
+ }
+
+ opts["name"] = {
+ type = 'text',
+ name = 'Bar name',
+ desc = 'The name of this bar (must be unique!).\n\nRemember to press ENTER after filling out this box with the name you want or it will not save.',
+ get = function()
+ return self.elementName
+ end,
+ set = function(v)
+ if v~= "" then
+ IceHUD.IceCore:RenameDynamicModule(self, v)
+ end
+ end,
+ disabled = function()
+ return not self.moduleSettings.enabled
+ end,
+ usage = "",
+ order = 20.3,
+ }
+
+ opts["unitToTrack"] = {
+ type = 'text',
+ name = 'Unit to track',
+ desc = 'Enter which unit that this bar should be monitoring the health of (e.g.: focustarget, pettarget, etc.)\n\nRemember to press ENTER after filling out this box with the name you want or it will not save.',
+ get = function()
+ return self.moduleSettings.unitToTrack
+ end,
+ set = function(v)
+ v = string.lower(v)
+ self.moduleSettings.unitToTrack = v
+ self:SetUnit(v)
+ self:Redraw()
+ self:CheckCombat()
+ end,
+ disabled = function()
+ return not self.moduleSettings.enabled
+ end,
+ order = 20.4,
+ }
+
+ opts["allowClickTarget"] = {
+ type = 'toggle',
+ name = 'Allow click-targeting',
+ desc = 'Whether or not to allow click targeting/casting for this bar (Note: does not work properly with HiBar, have to click near the base of the bar)',
+ get = function()
+ return self.moduleSettings.allowMouseInteraction
+ end,
+ set = function(v)
+ self.moduleSettings.allowMouseInteraction = v
+ self:Redraw()
+ end,
+ disabled = function()
+ return not self.moduleSettings.enabled
+ end,
+ usage = '',
+ order = 41,
+ }
+
+ return opts
+end
+
+
+function IceCustomHealth.prototype:Enable(core)
+ self.registerEvents = false
+ IceCustomHealth.super.prototype.Enable(self, core)
+
+ self:SetUnit(self.moduleSettings.unitToTrack)
+ self:CreateFrame()
+
+ self:ScheduleRepeatingEvent(self.elementName, self.Update, IceHUD.IceCore:UpdatePeriod(), self)
+end
+
+function IceCustomHealth.prototype:Disable(core)
+ IceCustomHealth.super.prototype.Disable(self, core)
+
+ self:CancelScheduledEvent(self.elementName)
+end
+
+function IceCustomHealth.prototype:Update(unit)
+ self.color = "CustomHealthFriendly" -- friendly > 4
+
+ local reaction = UnitReaction(self.unit, "player")
+
+ if (reaction and (reaction == 4)) then
+ self.color = "CustomHealthNeutral"
+ elseif (reaction and (reaction < 4)) then
+ self.color = "CustomHealthHostile"
+ end
+
+ if (self.moduleSettings.classColor) and (not self.moduleSettings.npcHostilityColor or UnitPlayerControlled("target")) then
+ self.color = self.unitClass
+ end
+
+ if (self.moduleSettings.scaleHealthColor) then
+ self.color = "ScaledHealthColor"
+ end
+
+ if (self.tapped) then
+ self.color = "Tapped"
+ end
+
+ if not self:IsVisible() then
+ RegisterUnitWatch(self.frame)
+ end
+
+ self:Show(true)
+
+ --self.determineColor = false
+ IceCustomHealth.super.prototype.Update(self, unit)
+end
+
+function IceCustomHealth.prototype:CreateBackground()
+ IceCustomHealth.super.prototype.CreateBackground(self)
+
+ if not self.frame.button then
+ self.frame.button = CreateFrame("Button", nil, self.frame, "SecureUnitButtonTemplate")
+ end
+
+ self.frame.button:ClearAllPoints()
+ -- Parnic - kinda hacky, but in order to fit this region to multiple types of bars, we need to do this...
+ -- would be nice to define this somewhere in data, but for now...here we are
+ if self:GetMyBarTexture() == "HiBar" then
+ self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, 0)
+ self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth(), 0)
+ else
+ if self.moduleSettings.side == IceCore.Side.Left then
+ self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -6, 0)
+ self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
+ else
+ self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 6, 0)
+ self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 1.5, 0)
+ end
+ end
+
+ self:EnableClickTargeting(self.moduleSettings.allowMouseInteraction)
+end
+
+function IceCustomHealth.prototype:EnableClickTargeting(bEnable)
+ if bEnable then
+ self.frame.button:EnableMouse(true)
+ self.frame.button:RegisterForClicks("LeftButtonUp")
+ self.frame.button:SetAttribute("type1", "target")
+
+ -- set up click casting
+ ClickCastFrames = ClickCastFrames or {}
+ ClickCastFrames[self.frame.button] = true
+
+-- Parnic - debug code for showing the clickable region on this bar
+-- self.frame.button:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
+-- edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
+-- tile = false,
+-- insets = { left = 0, right = 0, top = 0, bottom = 0 }});
+-- self.frame.button:SetBackdropColor(0,0,0,1);
+ else
+ self.frame.button:EnableMouse(false)
+ self.frame.button:RegisterForClicks()
+ end
+end
+
+function IceCustomHealth.prototype:SetUnit(unit)
+ IceCustomHealth.super.prototype.SetUnit(self, unit)
+ if self.frame ~= nil and self.frame.button ~= nil then
+ self.frame.button:SetAttribute("unit", self.unit)
+ end
+ self:RegisterFontStrings()
+end
diff --git a/modules/CustomMana.lua b/modules/CustomMana.lua
new file mode 100644
index 0000000..32a8b07
--- /dev/null
+++ b/modules/CustomMana.lua
@@ -0,0 +1,150 @@
+local AceOO = AceLibrary("AceOO-2.0")
+
+IceCustomMana = AceOO.Class(IceTargetMana)
+
+-- Constructor --
+function IceCustomMana.prototype:init()
+ IceCustomMana.super.prototype.init(self, "IceCustomMana", "focustarget")
+-- these aren't working...don't know why
+--[[ self:SetDefaultColor("CustomManaMana", 52, 64, 221)
+ self:SetDefaultColor("CustomManaRage", 235, 44, 26)
+ self:SetDefaultColor("CustomManaEnergy", 228, 242, 31)
+ self:SetDefaultColor("CustomManaFocus", 242, 149, 98)
+ self:SetDefaultColor("CustomManaRunicPower", 52, 64, 221)
+]]--
+end
+
+function IceCustomMana.prototype:GetDefaultSettings()
+ local settings = IceCustomMana.super.prototype.GetDefaultSettings(self)
+
+ settings["side"] = IceCore.Side.Left
+ settings["offset"] = -4
+ settings["classColor"] = false
+ settings["barVerticalOffset"] = 0
+ settings["scale"] = 1
+ settings["customBarType"] = "Mana"
+ settings["unitToTrack"] = "focustarget"
+
+ return settings
+end
+
+
+-- OVERRIDE
+function IceCustomMana.prototype:GetOptions()
+ local opts = IceCustomMana.super.prototype.GetOptions(self)
+
+ opts["hideBlizz"] = nil
+
+ opts["customHeader"] = {
+ type = 'header',
+ name = "Custom bar settings",
+ order = 20.1,
+ }
+
+ opts["deleteme"] = {
+ type = 'execute',
+ name = 'Delete me',
+ desc = 'Deletes this custom module and all associated settings. Cannot be undone!',
+ func = function()
+ local dialog = StaticPopup_Show("ICEHUD_DELETE_CUSTOM_MODULE")
+ if dialog then
+ dialog.data = self
+ end
+ end,
+ order = 20.2,
+ }
+
+ opts["name"] = {
+ type = 'text',
+ name = 'Bar name',
+ desc = 'The name of this bar (must be unique!).\n\nRemember to press ENTER after filling out this box with the name you want or it will not save.',
+ get = function()
+ return self.elementName
+ end,
+ set = function(v)
+ if v~= "" then
+ IceHUD.IceCore:RenameDynamicModule(self, v)
+ end
+ end,
+ disabled = function()
+ return not self.moduleSettings.enabled
+ end,
+ usage = "",
+ order = 20.3,
+ }
+
+ opts["unitToTrack"] = {
+ type = 'text',
+ name = 'Unit to track',
+ desc = 'Enter which unit that this bar should be monitoring the mana of (e.g.: focustarget, pettarget, etc.)\n\nRemember to press ENTER after filling out this box with the name you want or it will not save.',
+ get = function()
+ return self.moduleSettings.unitToTrack
+ end,
+ set = function(v)
+ v = string.lower(v)
+ self.moduleSettings.unitToTrack = v
+ self:SetUnit(v)
+ self:Redraw()
+ self:CheckCombat()
+ end,
+ disabled = function()
+ return not self.moduleSettings.enabled
+ end,
+ order = 20.4,
+ }
+
+ return opts
+end
+
+
+function IceCustomMana.prototype:Enable(core)
+ self.registerEvents = false
+ self:SetUnit(self.moduleSettings.unitToTrack)
+ IceCustomMana.super.prototype.Enable(self, core)
+
+ self:CreateFrame()
+
+ self:ScheduleRepeatingEvent(self.elementName, self.Update, IceHUD.IceCore:UpdatePeriod(), self)
+end
+
+function IceCustomMana.prototype:Disable(core)
+ IceCustomMana.super.prototype.Disable(self, core)
+
+ self:CancelScheduledEvent(self.elementName)
+end
+--[[
+function IceCustomMana.prototype:Update(unit)
+ self.color = "CustomManaMana"
+
+ self:Show(true)
+
+ local manaType = UnitPowerType(self.unit)
+
+ if (self.moduleSettings.scaleManaColor) then
+ self.color = "CustomManaColor"
+ end
+
+ if (manaType == 1) then
+ self.color = "CustomManaRage"
+ elseif (manaType == 2) then
+ self.color = "CustomManaFocus"
+ elseif (manaType == 3) then
+ self.color = "CustomManaEnergy"
+ elseif (manaType == 6) then
+ self.color = "CustomManaRunicPower"
+ end
+
+ if (self.tapped) then
+ self.color = "Tapped"
+ end
+
+ IceCustomMana.super.prototype.Update(self, unit)
+end
+]]--
+function IceCustomMana.prototype:SetUnit(unit)
+ IceCustomMana.super.prototype.SetUnit(self, unit)
+ if self.frame ~= nil and self.frame.button ~= nil then
+ self.frame.button:SetAttribute("unit", self.unit)
+ end
+ self:RegisterFontStrings()
+end
diff --git a/modules/TargetMana.lua b/modules/TargetMana.lua
index 98425d4..4447163 100644
--- a/modules/TargetMana.lua
+++ b/modules/TargetMana.lua
@@ -68,8 +68,8 @@ function IceTargetMana.prototype:Update(unit)
if (unit and (unit ~= self.unit)) then
return
end
-
- if ((not UnitExists(unit)) or (self.maxMana == 0)) then
+
+ if ((not UnitExists(self.unit)) or (self.maxMana == 0)) then
self:Show(false)
return
else