mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- changed DruidMana module to (optionally) work with LibDruidMana/DogTag for simplicity/compatibility purposes
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -12,6 +12,7 @@
|
||||
<Script file="libs\Gratuity-2.0\Gratuity-2.0.lua"/>
|
||||
<Include file="libs\LibDogTag-3.0\lib.xml"/>
|
||||
<Include file="libs\LibDogTag-Unit-3.0\lib.xml"/>
|
||||
<Include file="libs\LibDruidMana-1.0\lib.xml"/>
|
||||
<Include file="libs\LibMobHealth-4.0\lib.xml"/>
|
||||
<Include file="libs\LibSharedMedia-2.0\lib.xml"/>
|
||||
<Script file="libs\Waterfall-1.0\Waterfall-1.0.lua"/>
|
||||
|
@ -1,31 +1,47 @@
|
||||
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
|
||||
|
||||
@ -33,11 +49,18 @@ end
|
||||
function DruidMana.prototype:Enable(core)
|
||||
DruidMana.super.prototype.Enable(self, core)
|
||||
|
||||
self:FormsChanged(self.unit)
|
||||
if not LibDruidMana then
|
||||
self:FormsChanged(self.unit)
|
||||
|
||||
self:RegisterEvent("UNIT_DISPLAYPOWER", "FormsChanged")
|
||||
self:RegisterEvent("UNIT_MANA", "UpdateMana")
|
||||
self:RegisterEvent("UNIT_MAXMANA", "UpdateManaMax")
|
||||
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
|
||||
|
||||
@ -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
|
||||
@ -149,7 +172,12 @@ function DruidMana.prototype:Update()
|
||||
|
||||
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
|
||||
@ -158,10 +186,13 @@ function DruidMana.prototype:Update()
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user