View Single Post
07-22-20, 11:02 AM   #26
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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:
  1. nUI_ActionBar = nUI_ButtonBars.Bars["nUI_ActionBar"];
  2.  
  3.  
  4.         nUI_ActionBar:SetAttribute( "actionpage", 1 );
  5.        
  6.         nUI_ActionBar:Execute(
  7.             [[
  8.                 ChildList     = newtable( self:GetChildren() );
  9.                 ActionButtons = newtable();
  10.                 actionType    = self:GetAttribute( "nUI_ActionType" );
  11.                
  12.                 local j = 1;
  13.                
  14.                 for i, button in ipairs( ChildList ) do
  15.                     if not button:GetAttribute( "nUI_ActionButtonOverlay" ) then
  16.                         ActionButtons[j] = button;
  17.                         j = j+1;
  18.                     end
  19.                 end
  20.             ]]
  21.         );
  22.        
  23.         -- Handle bars where the state page changes
  24.         nUI_ActionBar:SetAttribute(
  25.             "_onstate-page",
  26.             [[
  27.                 if not newstate then return end
  28.                 newstate = tonumber(newstate)
  29.                 self:SetAttribute("actionpage", newstate)                          
  30.             ]]
  31.         )
  32.        
  33.  
  34.         nUI_ActionBar:SetAttribute(
  35.             "_onshow",
  36.             [[                        
  37.                 for i, button in ipairs( ActionButtons ) do
  38.                     if not button:GetAttribute( "nUI_ActionButtonOverlay" ) then
  39.                         button:SetAttribute( "touch", nil )
  40.                     end            
  41.                 end        
  42.             ]]
  43.         );        
  44.  
  45.        
  46.         -- Handle buttons that appear over time
  47.         nUI_ActionBar:SetAttribute(
  48.             "_onattributechanged", (
  49.                 [[                    
  50.                     if name == "state-page" then
  51.                         if value ~= nil then
  52.                             local pageOffset, hasAction = (value - 1) * NUM_ACTIONBAR_BUTTONS
  53.                             for id = 1,NUM_ACTIONBAR_BUTTONS do
  54.                                 if HasAction(id + pageOffset) then
  55.                                     ActionButtons[id]:SetAttribute('actionpage', value)
  56.                                     ActionButtons[id]:SetAttribute('statehidden',false)
  57.                                     hasAction = true
  58.                                     self:SetAttribute("showbutton",id)
  59.                                 --- If this is the override bar, do this extra check for those times when the
  60.                                 --- actionbuttons appear one at a time based on a timed sequence
  61.                                 elseif value == 12 then  
  62.                                     ActionButtons[id]:SetAttribute('actionpage', nil)
  63.                                     ActionButtons[id]:SetAttribute('statehidden',true)
  64.                                     self:SetAttribute("hidebutton",id)
  65.                                     self:SetAttribute("state-page", nil)
  66.                                 end
  67.                             end
  68.                             if not hasAction then
  69.                                 self:SetAttribute("state-page", nil)
  70.                             end                
  71.                         else
  72.                     end
  73.                     elseif name == "showbutton" then
  74.                         ActionButtons[value]:Show()
  75.                     elseif name == "hidebutton" then
  76.                         ActionButtons[value]:Hide()
  77.                     end
  78.                 ]]
  79.             ):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS)
  80.         )
  81.        
  82.         if nUI_ActionBar.registered then
  83.             UnregisterStateDriver( nUI_ActionBar, "page" );
  84.         end
  85.        
  86.         if nUI_Options.boomkinBar then
  87.             RegisterStateDriver(
  88.                 nUI_ActionBar, "page", string.format(
  89.                     "[overridebar] %d; [shapeshift] %d;[vehicleui][possessbar] %d; [vehicleui] %d; "  ..
  90.                     "[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; " ..
  91.                     "[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9;   [bonusbar:4] 10; [bonusbar:5] 11; 1",
  92.                     GetOverrideBarIndex(), GetTempShapeshiftBarIndex(), GetVehicleBarIndex(),GetVehicleBarIndex()
  93.                 )
  94.             );
  95.         else
  96.             RegisterStateDriver(
  97.                 nUI_ActionBar, "page", string.format(
  98.                     "[overridebar] %d; [shapeshift] %d;[vehicleui][possessbar] %d; [vehicleui] %d; "  ..
  99.                     "[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; " ..
  100.                     "[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 1; [bonusbar:5] 11; 1",
  101.                     GetOverrideBarIndex(), GetTempShapeshiftBarIndex(), GetVehicleBarIndex(),GetVehicleBarIndex()
  102.                 )
  103.             );
  104.         end
  105.  
  106.         -- OverrideActionBarLeaveFrameLeaveButton has to be attached to Button12
  107.         OverrideActionBarLeaveFrameLeaveButton:SetParent( nUI_ActionBar );
  108.         OverrideActionBarLeaveFrameLeaveButton:SetAllPoints( nUI_ActionBar_Button12 );
  109.         RegisterStateDriver( OverrideActionBarLeaveFrameLeaveButton, "visibility", "[vehicleui][target=vehicle, exists] show; hide" );     
  110.         nUI_Movers:lockFrame( OverrideActionBarLeaveFrameLeaveButton, true, nil );
  111.         nUI_ActionBar.registered = true;
__________________

Last edited by Xrystal : 07-22-20 at 11:13 AM.
  Reply With Quote