diff --git a/IceBarElement.lua b/IceBarElement.lua
index 7174211..e6c1359 100644
--- a/IceBarElement.lua
+++ b/IceBarElement.lua
@@ -330,7 +330,7 @@ function IceBarElement.prototype:GetOptions()
name = 'Upper Text',
desc = 'The upper text to display under this bar (accepts LibDogTag formatting)\n\nSee http://www.wowace.com/wiki/LibDogTag-2.0/ or type /dogtag for tag info',
hidden = function()
- return DogTag == nil or self.elementName == "DruidMana"
+ return DogTag == nil
end,
get = function()
return self.moduleSettings.upperText
@@ -352,7 +352,7 @@ function IceBarElement.prototype:GetOptions()
name = 'Lower Text',
desc = 'The lower text to display under this bar (accepts LibDogTag formatting)\n\nSee http://www.wowace.com/wiki/LibDogTag-2.0/ or type /dogtag for tag info',
hidden = function()
- return DogTag == nil or self.elementName == "DruidMana"
+ return DogTag == nil
end,
get = function()
return self.moduleSettings.lowerText
diff --git a/IceHUD.toc b/IceHUD.toc
index ad76c0d..27c6844 100644
--- a/IceHUD.toc
+++ b/IceHUD.toc
@@ -5,8 +5,8 @@
## Notes: Another HUD addon
## Version: 1.2 ($Revision$)
## SavedVariables: IceCoreDB
-## OptionalDeps: Ace2, GratuityLib, LibSharedMedia-2.0, WaterfallLib, Deformat-2.0, LibDogTag-3.0
-## X-Embeds: Ace2, GratuityLib, LibSharedMedia-2.0, WaterfallLib, Deformat-2.0, LibDogTag-3.0, LibDogTag-Unit-3.0, LibMobHealth-4.0
+## OptionalDeps: Ace2, GratuityLib, LibSharedMedia-2.0, WaterfallLib, Deformat-2.0, LibDogTag-3.0, LibDruidMana-1.0
+## X-Embeds: Ace2, GratuityLib, LibSharedMedia-2.0, WaterfallLib, Deformat-2.0, LibDogTag-3.0, LibDogTag-Unit-3.0, LibMobHealth-4.0, LibDruidMana-1.0
## X-Category: UnitFrame
## X-Date: $Date$
## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html
diff --git a/embeds.xml b/embeds.xml
index 049af4f..d52885f 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -12,6 +12,7 @@
+
diff --git a/modules/DruidMana.lua b/modules/DruidMana.lua
index 365b3e0..0c5a6f8 100644
--- a/modules/DruidMana.lua
+++ b/modules/DruidMana.lua
@@ -1,43 +1,66 @@
local AceOO = AceLibrary("AceOO-2.0")
local DruidMana = AceOO.Class(IceUnitBar)
-local gratuity = AceLibrary("Gratuity-2.0")
DruidMana.prototype.druidMana = nil
DruidMana.prototype.druidManaMax = nil
DruidMana.prototype.lastCast = nil
DruidMana.prototype.baseMana = nil
+local gratuity = nil
+local LibDruidMana = nil
+
local intMod = 14
-- Constructor --
function DruidMana.prototype:init()
DruidMana.super.prototype.init(self, "DruidMana", "player")
+
self.side = IceCore.Side.Right
self.offset = 0
self:SetDefaultColor("DruidMana", 87, 82, 141)
+
+ if AceLibrary:HasInstance("LibDogTag-3.0") and AceLibrary:HasInstance("LibDruidMana-1.0") then
+ LibDruidMana = AceLibrary("LibDruidMana-1.0")
+ else
+ gratuity = AceLibrary("Gratuity-2.0")
+ end
end
function DruidMana.prototype:GetDefaultSettings()
local settings = DruidMana.super.prototype.GetDefaultSettings(self)
+
settings["side"] = IceCore.Side.Right
settings["offset"] = 0
settings["textVisible"] = {upper = true, lower = false}
+
+ if LibDruidMana then
+ settings["upperText"] = "[PercentDruidMP:Round]"
+ settings["lowerText"] = "[FractionalDruidMP:Color('3071bf'):Bracket]"
+ end
+
return settings
end
function DruidMana.prototype:Enable(core)
DruidMana.super.prototype.Enable(self, core)
-
- self:FormsChanged(self.unit)
-
- self:RegisterEvent("UNIT_DISPLAYPOWER", "FormsChanged")
- self:RegisterEvent("UNIT_MANA", "UpdateMana")
- self:RegisterEvent("UNIT_MAXMANA", "UpdateManaMax")
+
+ if not LibDruidMana then
+ self:FormsChanged(self.unit)
+
+ self:RegisterEvent("UNIT_DISPLAYPOWER", "FormsChanged")
+ self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "FormsChanged")
+ self:RegisterEvent("UNIT_MANA", "UpdateMana")
+ self:RegisterEvent("UNIT_MAXMANA", "UpdateManaMax")
+ else
+ self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "Update")
+ self:RegisterEvent("UNIT_MANA", "Update")
+ self:RegisterEvent("UNIT_MAXMANA", "Update")
+ end
end
@@ -45,7 +68,7 @@ function DruidMana.prototype:Disable(core)
DruidMana.super.prototype.Disable(self, core)
end
-
+-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:FormsChanged(unit)
if (unit ~= self.unit) then
return
@@ -56,7 +79,7 @@ function DruidMana.prototype:FormsChanged(unit)
if (forms) then
self.lastCast = GetTime()
- if (not self.druidMana) then
+ if (not self.druidMana or not gratuity) then
return
end
@@ -64,7 +87,7 @@ function DruidMana.prototype:FormsChanged(unit)
-- when we shift to forms
local uberTooltips = GetCVar("UberTooltips")
SetCVar("UberTooltips", 1)
-
+
gratuity:SetShapeshift(1) -- 1 = bear form, rawr
local _, _, manaCost = gratuity:Find("(%d+)", 2, 2) -- 2 = mana cost line
@@ -83,7 +106,7 @@ function DruidMana.prototype:FormsChanged(unit)
self:Update()
end
-
+-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:UpdateMana(unit)
if (unit ~= self.unit) then
return
@@ -116,7 +139,7 @@ function DruidMana.prototype:UpdateMana(unit)
self:Update()
end
-
+-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:UpdateManaMax(unit)
if (unit ~= self.unit) then
return
@@ -146,22 +169,30 @@ end
function DruidMana.prototype:Update()
DruidMana.super.prototype.Update(self)
-
+
local forms = (UnitPowerType(self.unit) ~= 0)
-
- if (not self.alive or not forms or not self.druidMana or not self.druidManaMax) then
+
+ if LibDruidMana then
+ self.druidMana = LibDruidMana:GetCurrentMana()
+ self.druidManaMax = LibDruidMana:GetMaximumMana()
+ end
+
+ if (not self.alive or not forms or not self.druidMana or not self.druidManaMax or self.druidManaMax == 0) then
self:Show(false)
return
else
self:Show(true)
end
-
+
self:UpdateBar(self.druidMana / self.druidManaMax, "DruidMana")
- local percentage = (self.druidMana / self.druidManaMax) * 100
- self:SetBottomText1(math.floor(percentage))
- self:SetBottomText2(self:GetFormattedText(string.format("%.0f", self.druidMana),
- string.format("%.0f", self.druidManaMax)), "DruidMana")
+ if not LibDruidMana then
+ local percentage = (self.druidMana / self.druidManaMax) * 100
+
+ self:SetBottomText1(math.floor(percentage))
+ self:SetBottomText2(self:GetFormattedText(string.format("%.0f", self.druidMana),
+ string.format("%.0f", self.druidManaMax)), "DruidMana")
+ end
end