So, I'm trying to re-position Auras element based on Additional Power element's enabled state and came out with the following.
Lua Code:
function AdditionalPowerOverride(self, event, unit, powertype)
if event == "ElementEnable" then
-- re-position Auras element
elseif event == "ElementDisable" then
-- re-position Auras element
end
if(unit ~= 'player' or (powertype and powertype ~= ADDITIONAL_POWER_BAR_NAME)) then return end
local element = self.AdditionalPower
--[[ Callback: AdditionalPower:PreUpdate(unit)
Called before the element has been updated.
* self - the AdditionalPower element
* unit - the unit for which the update has been triggered (string)
--]]
if(element.PreUpdate) then element:PreUpdate(unit) end
local cur = UnitPower('player', ADDITIONAL_POWER_BAR_INDEX)
local max = UnitPowerMax('player', ADDITIONAL_POWER_BAR_INDEX)
element:SetMinMaxValues(0, max)
element:SetValue(cur)
--[[ Override: AdditionalPower:UpdateColor(cur, max)
Used to completely override the internal function for updating the widget's colors.
* self - the AdditionalPower element
* cur - the current value of the player's additional power (number)
* max - the maximum value of the player's additional power (number)
--]]
element:UpdateColor(cur, max)
--[[ Callback: AdditionalPower:PostUpdate(unit, cur, max)
Called after the element has been updated.
* self - the AdditionalPower element
* unit - the unit for which the update has been triggered (string)
* cur - the current value of the player's additional power (number)
* max - the maximum value of the player's additional power (number)
--]]
if(element.PostUpdate) then
return element:PostUpdate(unit, cur, max)
end
end
function CreateAdditionalPower(self, unit)
local additionalPower = CreateFrame("StatusBar", "$parentAdditionalPower", self);
additionalPower:SetSize(self:GetWidth(), 4);
additionalPower:SetPoint("TOP", self, "BOTTOM", 0, -3);
additionalPower.Override = AdditionalPowerOverride;
self.AdditionalPower = additionalPower;
end
If anyone has a better solution to this, please feel free to advise me.
Thank you!