- removed LibGratuity-2.0 (or GratuityLib, whichever you wanna call it) since only the DruidMana module used it and even then only if the user didn't have LibDruidMana installed. now LibDruidMana is required instead of falling back to Gratuity...the Gratuity method was broken for powershifting anyway

This commit is contained in:
Parnic
2008-06-25 03:31:40 +00:00
parent fea0edddce
commit 7e42238219
3 changed files with 3 additions and 124 deletions

View File

@ -5,8 +5,8 @@
## Notes: Another HUD addon ## Notes: Another HUD addon
## Version: 1.2 ($Revision$) ## Version: 1.2 ($Revision$)
## SavedVariables: IceCoreDB ## SavedVariables: IceCoreDB
## OptionalDeps: Ace2, GratuityLib, LibSharedMedia-3.0, Waterfall-1.0, Deformat, LibDogTag-3.0, LibDogTag-Unit-3.0, LibDruidMana-1.0 ## OptionalDeps: Ace2, LibSharedMedia-3.0, Waterfall-1.0, Deformat, LibDogTag-3.0, LibDogTag-Unit-3.0, LibDruidMana-1.0
## X-Embeds: Ace2, GratuityLib, LibSharedMedia-3.0, Waterfall-1.0, Deformat, LibDogTag-3.0, LibDogTag-Unit-3.0, LibDruidMana-1.0 ## X-Embeds: Ace2, LibSharedMedia-3.0, Waterfall-1.0, Deformat, LibDogTag-3.0, LibDogTag-Unit-3.0, LibDruidMana-1.0
## X-Category: UnitFrame ## X-Category: UnitFrame
## X-Date: $Date$ ## X-Date: $Date$
## 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

View File

@ -10,7 +10,6 @@
<Script file="libs\AceAddon-2.0\AceAddon-2.0.lua"/> <Script file="libs\AceAddon-2.0\AceAddon-2.0.lua"/>
<Script file="libs\CallbackHandler-1.0\CallbackHandler-1.0.lua"/> <Script file="libs\CallbackHandler-1.0\CallbackHandler-1.0.lua"/>
<Script file="libs\Deformat-2.0\Deformat-2.0.lua"/> <Script file="libs\Deformat-2.0\Deformat-2.0.lua"/>
<Script file="libs\Gratuity-2.0\Gratuity-2.0.lua"/>
<Include file="libs\LibDogTag-3.0\lib.xml"/> <Include file="libs\LibDogTag-3.0\lib.xml"/>
<Include file="libs\LibDogTag-Unit-3.0\lib.xml"/> <Include file="libs\LibDogTag-Unit-3.0\lib.xml"/>
<Include file="libs\LibDruidMana-1.0\lib.xml"/> <Include file="libs\LibDruidMana-1.0\lib.xml"/>

View File

@ -4,14 +4,9 @@ local DruidMana = AceOO.Class(IceUnitBar)
DruidMana.prototype.druidMana = nil DruidMana.prototype.druidMana = nil
DruidMana.prototype.druidManaMax = nil DruidMana.prototype.druidManaMax = nil
DruidMana.prototype.lastCast = nil
DruidMana.prototype.baseMana = nil
local gratuity = nil
local LibDruidMana = nil local LibDruidMana = nil
local intMod = 14
-- Constructor -- -- Constructor --
function DruidMana.prototype:init() function DruidMana.prototype:init()
@ -24,8 +19,6 @@ function DruidMana.prototype:init()
if AceLibrary:HasInstance("LibDogTag-3.0") and AceLibrary:HasInstance("LibDruidMana-1.0") then if AceLibrary:HasInstance("LibDogTag-3.0") and AceLibrary:HasInstance("LibDruidMana-1.0") then
LibDruidMana = AceLibrary("LibDruidMana-1.0") LibDruidMana = AceLibrary("LibDruidMana-1.0")
else
gratuity = AceLibrary("Gratuity-2.0")
end end
end end
@ -49,14 +42,7 @@ end
function DruidMana.prototype:Enable(core) function DruidMana.prototype:Enable(core)
DruidMana.super.prototype.Enable(self, core) DruidMana.super.prototype.Enable(self, core)
if not LibDruidMana then if 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("UPDATE_SHAPESHIFT_FORM", "Update")
self:RegisterEvent("UNIT_MANA", "Update") self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_MAXMANA", "Update") self:RegisterEvent("UNIT_MAXMANA", "Update")
@ -68,104 +54,6 @@ function DruidMana.prototype:Disable(core)
DruidMana.super.prototype.Disable(self, core) DruidMana.super.prototype.Disable(self, core)
end end
-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:FormsChanged(unit)
if (unit ~= self.unit) then
return
end
local forms = (UnitPowerType(self.unit) ~= 0)
if (forms) then
self.lastCast = GetTime()
if (not self.druidMana or not gratuity) then
return
end
-- deduct the shapeshift cost from last known mana value
-- 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
self.druidMana = self.druidMana - (manaCost or 0)
SetCVar("UberTooltips", uberTooltips)
else
-- always update with actual mana values when shifting out
self:UpdateMana(self.unit)
self:UpdateManaMax(self.unit)
local _, intellect, _, _ = UnitStat(self.unit, 4)
self.baseMana = UnitMana(self.unit) - (intellect * intMod)
end
self:Update()
end
-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:UpdateMana(unit)
if (unit ~= self.unit) then
return
end
local forms = (UnitPowerType(self.unit) ~= 0)
if (forms) then
if (not self.druidMana or not self.lastCast) then
return
end
local time = GetTime()
local normal, casting = GetManaRegen()
if (time - self.lastCast > 5) then
self.druidMana = self.druidMana + (normal * 2)
else
self.druidMana = self.druidMana + (casting * 2)
end
-- sanity check, the tick can be off a little sometimes
if (self.druidMana > self.druidManaMax) then
self.druidMana = self.druidManaMax
end
else
self.druidMana = UnitMana(self.unit)
end
self:Update()
end
-- Only called if the user doesn't have LibDruidMana installed
function DruidMana.prototype:UpdateManaMax(unit)
if (unit ~= self.unit) then
return
end
local forms = (UnitPowerType(self.unit) ~= 0)
if (forms) then
if not (self.baseMana) then
return
end
local _, intellect, _, _ = UnitStat(self.unit, 4)
self.druidManaMax = self.baseMana + (intellect * intMod)
if (self.druidMana > self.druidManaMax) then
self.druidMana = self.druidManaMax
end
else
self.druidManaMax = UnitManaMax(self.unit)
end
self:Update()
end
function DruidMana.prototype:Update() function DruidMana.prototype:Update()
DruidMana.super.prototype.Update(self) DruidMana.super.prototype.Update(self)
@ -185,14 +73,6 @@ function DruidMana.prototype:Update()
end end
self:UpdateBar(self.druidMana / self.druidManaMax, "DruidMana") self:UpdateBar(self.druidMana / 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 end