I gathered some information on the UnitPowerAlt stuff.
Code:
--default Blizzard PlayerPowerBarAlt
PlayerPowerBarAlt:Hide()
--Event handling
frame:RegisterEvent("UNIT_POWER")
frame:RegisterEvent("UNIT_POWER_BAR_SHOW")
frame:RegisterEvent("UNIT_POWER_BAR_HIDE")
--WoW API Functions
UnitAlternatePowerInfo("player")
UnitAlternatePowerTextureInfo(...)
UnitPower("player", ALTERNATE_POWER_INDEX)
UnitPowerMax("player", ALTERNATE_POWER_INDEX)
Currently only two powerbars of that type are known.
PlayerPowerAlt for Atramedes and Cho'gall.
Onyxia Bossframe on Nefarian encounter has a alternative powerbar aswell. No clue about the name though.
Creating an player power alternative statusbar on its own in form of a statusbar should be quite simple.
Just create the statusbar make it 0/100, hook the events and check for UnitAlternatePowerInfo(). If that is true get the percentage value of UnitPower(alt_index) to UnitPowerMax(alt_index) and apply that value to the statusbar.
Does anyone have information on the onyxia bossframe altpowerbar?
I just checked ShadowedUnitFrames. There is already some kind of element for that.
Code:
local AltPower = {}
ShadowUF:RegisterModule(AltPower, "altPowerBar", ShadowUF.L["Alt. Power bar"], true)
local ALTERNATE_POWER_INDEX = ALTERNATE_POWER_INDEX
function AltPower:OnEnable(frame)
frame.altPowerBar = frame.altPowerBar or ShadowUF.Units:CreateBar(frame)
frame:RegisterUnitEvent("UNIT_POWER", self, "Update")
frame:RegisterUnitEvent("UNIT_MAXPOWER", self, "Update")
frame:RegisterUnitEvent("UNIT_POWER_BAR_SHOW", self, "UpdateVisibility")
frame:RegisterUnitEvent("UNIT_POWER_BAR_HIDE", self, "UpdateVisibility")
frame:RegisterUpdateFunc(self, "UpdateVisibility")
end
function AltPower:OnLayoutApplied(frame)
if( frame.visibility.altPowerBar ) then
local color = ShadowUF.db.profile.powerColors.ALTERNATE
frame.altPowerBar:SetStatusBarColor(color.r, color.g, color.b, ShadowUF.db.profile.bars.alpha)
end
end
function AltPower:OnDisable(frame)
frame:UnregisterAll(self)
end
function AltPower:UpdateVisibility(frame)
local barType, minPower, _, _, _, hideFromOthers = UnitAlternatePowerInfo(frame.unit)
local visible = barType and (frame.unit == "player" or not hideFromOthers)
ShadowUF.Layout:SetBarVisibility(frame, "altPowerBar", visible)
AltPower:Update(frame, nil, nil, "ALTERNATE")
end
function AltPower:Update(frame, event, unit, type)
if( type ~= "ALTERNATE" ) then return end
local cur = UnitPower(frame.unit, ALTERNATE_POWER_INDEX)
local max = UnitPowerMax(frame.unit, ALTERNATE_POWER_INDEX)
local barType, min = UnitAlternatePowerInfo(frame.unit)
frame.altPowerBar.currentPower = cur
frame.altPowerBar:SetMinMaxValues(min or 0, max or 0)
frame.altPowerBar:SetValue(cur or 0)
end
Player bar
Code:
if( ShadowUF.db.profile.hidden.playerAltPower ) then
PlayerPowerBarAlt:UnregisterEvent("UNIT_POWER_BAR_SHOW")
PlayerPowerBarAlt:UnregisterEvent("UNIT_POWER_BAR_HIDE")
PlayerPowerBarAlt:UnregisterEvent("PLAYER_ENTERING_WORLD")
PlayerPowerBarAlt:Hide()
end
The Onyxia alternative power bar is bound to the bossframe. It is gone once you spawn bossframes via oUF. Which is good since you only have to spawn the powerbar alt for bossframes without having to deactivate a specific frame like for player.