/branches/preview/Aloft/AloftMana
----------------------------------------------------------------------------- |
local UnitName = UnitName |
local UnitPower = UnitPower |
local UnitPowerMax = UnitPowerMax |
local UnitPowerType = UnitPowerType |
----------------------------------------------------------------------------- |
function AloftManaData:OnInitialize() |
AloftManaBar = Aloft:GetModule("ManaBar", true) |
AloftManaText = Aloft:GetModule("ManaText", true) |
end |
]] |
--[[ obsolete WoW 3.3 events |
self:RegisterEvent("UNIT_MANA", "OnUnitManaChanged") |
self:RegisterEvent("UNIT_RAGE", "OnUnitManaChanged") |
self:RegisterEvent("UNIT_FOCUS", "OnUnitManaChanged") |
self:RegisterEvent("UNIT_ENERGY", "OnUnitManaChanged") |
self:RegisterEvent("UNIT_RUNIC_POWER", "OnUnitManaChanged") |
]] |
-- new WoW 4.0.1+ event |
self:RegisterEvent("UNIT_POWER", "OnUnitManaChanged") |
self:RegisterEvent("UNIT_DISPLAYPOWER", "OnUnitManaChanged") |
self:RegisterMessage("Aloft:OnNameplateShow", "OnNameplateShow") |
function AloftManaData:SetManaData(aloftData, unitid) |
local name, _ = UnitName(unitid) |
if name ~= L["Unknown"] and aloftData.name ~= L["Unknown"] then |
local maxMana = UnitManaMax(unitid) |
local maxMana = UnitPowerMax(unitid) |
-- ChatFrame7:AddMessage("AloftManaData:SetManaData(): update " .. tostring(aloftData.name) .. "/" .. tostring(aloftData.unitid) .. "/".. tostring(maxMana)) |
if ((maxMana ~= nil) and (maxMana > 0)) then |
aloftData.mana = UnitMana(unitid) |
aloftData.mana = UnitPower(unitid) |
aloftData.maxMana = maxMana |
aloftData.powerType, aloftData.powerTypeName = UnitPowerType(unitid) |
-- ChatFrame7:AddMessage("AloftManaData:SetManaData(): " .. tostring(unitid) .. "/" .. tostring(aloftData.name) .. "/" .. tostring(aloftData.mana) .. "/" .. tostring(aloftData.maxMana) .. "/" .. tostring(aloftData.powerType) .. "/" .. tostring(aloftData.powerTypeName)) |
end |
end |
function AloftManaData:OnUnitManaChanged(event, unitid) |
-- the powertype argument is currently not used here, and in any event would arrive with a nil value via the UNIT_DISPLAYPOWER event |
function AloftManaData:OnUnitManaChanged(event, unitid, powertype) |
-- ChatFrame7:AddMessage("AloftManaData:OnUnitManaChanged(): enter " .. unitid) |
if unitid == "target" then |
-- ChatFrame7:AddMessage("AloftManaData:OnUnitManaChanged(): target") |