The Big Boom is another quest that has this type of action bar update process.
This will hopefully finalise the changes I ended up making to the action bar in relation to the override bar buttons appearing when they are scheduled rather than immediately.
The following are the changes I ended up making but I just had to add 'elseif value == GetOverrideBarIndex() then' line instead of just else .. as without it .. all other actionbar states were ignoring changes such as dragging new abilities onto the bar etc. And macro based buttons were flashing as well as abilities that weren't valid. These are nUI changes so they are based Terenna's findings adjusted to work with nUI as nUI creates its own action bars.
Lua Code:
nUI_ActionBar = nUI_ButtonBars.Bars["nUI_ActionBar"];
nUI_ActionBar:SetAttribute( "actionpage", 1 );
nUI_ActionBar:Execute(
[[
ChildList = newtable( self:GetChildren() );
ActionButtons = newtable();
actionType = self:GetAttribute( "nUI_ActionType" );
local j = 1;
for i, button in ipairs( ChildList ) do
if not button:GetAttribute( "nUI_ActionButtonOverlay" ) then
ActionButtons[j] = button;
j = j+1;
end
end
]]
);
-- Handle bars where the state page changes
nUI_ActionBar:SetAttribute(
"_onstate-page",
[[
if not newstate then return end
newstate = tonumber(newstate)
self:SetAttribute("actionpage", newstate)
]]
)
nUI_ActionBar:SetAttribute(
"_onshow",
[[
for i, button in ipairs( ActionButtons ) do
if not button:GetAttribute( "nUI_ActionButtonOverlay" ) then
button:SetAttribute( "touch", nil )
end
end
]]
);
-- Handle buttons that appear over time
nUI_ActionBar:SetAttribute(
"_onattributechanged", (
[[
if name == "state-page" then
if value ~= nil then
local pageOffset, hasAction = (value - 1) * NUM_ACTIONBAR_BUTTONS
for id = 1,NUM_ACTIONBAR_BUTTONS do
if HasAction(id + pageOffset) then
ActionButtons[id]:SetAttribute('actionpage', value)
ActionButtons[id]:SetAttribute('statehidden',false)
hasAction = true
self:SetAttribute("showbutton",id)
--- If this is the override bar, do this extra check for those times when the
--- actionbuttons appear one at a time based on a timed sequence
elseif value == 12 then
ActionButtons[id]:SetAttribute('actionpage', nil)
ActionButtons[id]:SetAttribute('statehidden',true)
self:SetAttribute("hidebutton",id)
self:SetAttribute("state-page", nil)
end
end
if not hasAction then
self:SetAttribute("state-page", nil)
end
else
end
elseif name == "showbutton" then
ActionButtons[value]:Show()
elseif name == "hidebutton" then
ActionButtons[value]:Hide()
end
]]
):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS)
)
if nUI_ActionBar.registered then
UnregisterStateDriver( nUI_ActionBar, "page" );
end
if nUI_Options.boomkinBar then
RegisterStateDriver(
nUI_ActionBar, "page", string.format(
"[overridebar] %d; [shapeshift] %d;[vehicleui][possessbar] %d; [vehicleui] %d; " ..
"[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; " ..
"[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 10; [bonusbar:5] 11; 1",
GetOverrideBarIndex(), GetTempShapeshiftBarIndex(), GetVehicleBarIndex(),GetVehicleBarIndex()
)
);
else
RegisterStateDriver(
nUI_ActionBar, "page", string.format(
"[overridebar] %d; [shapeshift] %d;[vehicleui][possessbar] %d; [vehicleui] %d; " ..
"[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; " ..
"[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 1; [bonusbar:5] 11; 1",
GetOverrideBarIndex(), GetTempShapeshiftBarIndex(), GetVehicleBarIndex(),GetVehicleBarIndex()
)
);
end
-- OverrideActionBarLeaveFrameLeaveButton has to be attached to Button12
OverrideActionBarLeaveFrameLeaveButton:SetParent( nUI_ActionBar );
OverrideActionBarLeaveFrameLeaveButton:SetAllPoints( nUI_ActionBar_Button12 );
RegisterStateDriver( OverrideActionBarLeaveFrameLeaveButton, "visibility", "[vehicleui][target=vehicle, exists] show; hide" );
nUI_Movers:lockFrame( OverrideActionBarLeaveFrameLeaveButton, true, nil );
nUI_ActionBar.registered = true;