Quantcast
Quest:Righteous Retribution special action bar not switching in nUI - Page 2 - WoWInterface
Thread Tools Display Modes
08-28-18, 09:19 PM   #21
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,492
Originally Posted by Vrul View Post
I already tried it on the Beta server using a druid on a target dummy. I could switch forms in combat with no issues. If it works for that it will work for any other state transition.
Great good to know about the combat. It's more how the quest chain works, I'm hoping that either my other special bar swaps fixed it or this one does.

And for confirmation... just adding that _onstate-page snippet with nUI's actionbuttons variable made it all work and the pet bar came back as I suspected it would ... *happy dance*

And hey, I learnt more about the secure stuff. Thanks alot again.
__________________

Last edited by Xrystal : 08-28-18 at 09:28 PM.
  Reply With Quote
03-15-19, 11:45 PM   #22
Terenna
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 105
I hate to pseudonecro this thread, but I found a solution to this if you still cared.

I did some intense digging, and came up with:
Lua Code:
  1. hooksecurefunc('ActionBarController_UpdateAll', function()  
  2.     for i = 1, 12 do
  3.         local button = _G['ActionButton'..i]
  4.         local overrideButton = _G['OverrideActionBarButton'..i]
  5.         local _, spellID
  6.         if overrideButton then
  7.             _, spellID = GetActionInfo(overrideButton.action)
  8.         end
  9.  
  10.         if ((HasOverrideActionBar() or HasVehicleActionBar()) and (spellID and spellID > 0)) or (not HasOverrideActionBar() and not HasVehicleActionBar()) then
  11.             button:SetAttribute('statehidden', false)
  12.             button:Show()
  13.         else
  14.             button:SetAttribute('statehidden', true)
  15.             button:Hide()
  16.         end
  17.     end
  18. end)

the key thing is the SetAttribute('statehidden') for the buttons. The page changes early on in this quest (as soon as you mount the gryphon) but then the attributes are changed after the page change. I found the function above to hook and it works

HOWEVER, by using SetAttribute outside of a secure environment, this does cause tainting.


I've conversely come up with:
Lua Code:
  1. frame:SetAttribute('_onattributechanged', [[
  2.         for i = 1, 12 do
  3.             local button = _G['ActionButton'..i]
  4.             local overrideButton = _G['OverrideActionBarButton'..i]
  5.             local _, spellID
  6.             if overrideButton then
  7.                 _, spellID = GetActionInfo(overrideButton.action)
  8.             end
  9.  
  10.             if ((HasOverrideActionBar() or HasVehicleActionBar()) and (spellID and spellID > 0)) or (not HasOverrideActionBar() and not HasVehicleActionBar()) then
  11.                 button:SetAttribute('statehidden', false)
  12.                 button:Show()
  13.             else
  14.                 button:SetAttribute('statehidden', true)
  15.                 button:Hide()
  16.             end
  17.         end
  18.     ]])

but IDK if it works and it takes like 2-3 hours of questing to get to that particular quest to test it. If anyone can test that, let me know, if not, I'll post back when I have the time to get another character to that quest.
  Reply With Quote
03-16-19, 10:39 AM   #23
Terenna
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 105
Did some more testing and came up with this:

Lua Code:
  1. local AttributeChangedFrame = CreateFrame('frame', nil, UIParent, 'SecureHandlerAttributeTemplate')
  2. for i = 1, 12 do
  3.     local button = _G['ActionButton'..i]
  4.     AttributeChangedFrame:SetFrameRef('ActionButton'..i, button)
  5. end
  6.  
  7. for i = 1, 6 do
  8.     local overrideButton = _G['OverrideActionBarButton'..i]
  9.     AttributeChangedFrame:SetFrameRef('OverrideActionBarButton'..i, overrideButton)
  10. end
  11. AttributeChangedFrame:Execute([[
  12.     buttons = table.new()
  13.     for i = 1, 12 do
  14.         table.insert(buttons, self:GetFrameRef('ActionButton'..i))
  15.     end
  16.     overridebuttons = table.new()
  17.     for i = 1, 6 do
  18.         table.insert(overridebuttons, self:GetFrameRef('OverrideActionBarButton'..i))
  19.     end
  20. ]])
  21.  
  22. for i = 1, 6 do
  23.     local overrideButton = _G['OverrideActionBarButton'..i]
  24.     overrideButton:HookScript('OnAttributeChanged', function()
  25.         AttributeChangedFrame:Execute[[
  26.             for i = 1, 6 do
  27.                 if not overridebuttons[i]:GetAttribute('statehidden') then
  28.                     buttons[i]:SetAttribute('statehidden', false)
  29.                     buttons[i]:Show()
  30.                 else
  31.                     buttons[i]:SetAttribute('statehidden', true)
  32.                     buttons[i]:Hide()
  33.                 end
  34.             end
  35.         ]]
  36.     end)
  37.    
  38.     local button = _G['ActionButton'..i]
  39.     button:HookScript('OnAttributeChanged', function()
  40.         AttributeChangedFrame:Execute[[
  41.             for i = 1, 12 do
  42.                 if (not HasOverrideActionBar() and not HasVehicleActionBar() and buttons[i]:GetAttribute('statehidden')) then
  43.                     buttons[i]:SetAttribute('statehidden', false)
  44.                     buttons[i]:Show()
  45.                 end
  46.             end
  47.         ]]
  48.     end)
  49. end

This works beautifully and causes 0 taint. HOWEVER, I'm nearly positive this could be way more optimized.
  Reply With Quote
04-10-19, 08:39 PM   #24
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,492
I'm pretty sure I got this working in the end for nUI and a custom bar addon.

I just didn't progress my character until I had it working exactly how I expected it to work .. And then tested the next one in the quest chain that did this before moving on.

As far as I am aware it is working fine.
__________________
  Reply With Quote
05-01-20, 09:30 PM   #25
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,492
To follow on from this initial quest related action bar problems... there was another quest (https://www.wowhead.com/quest=52042/the-big-boom) that needed the bar updated again *sigh* .. so hopefully my change to my previous bar changes haven't killed off the Righteous Retribution quest chain. Or the Tortollan Turtles daily quest (https://www.wowhead.com/quest=55300/the-cycle-of-life) I had to make a change for ( just a re-order of the special bars) since this thread was updated.

Anyway ..

This is what I ended up doing to make things work for big boom which works in a similar way to Righteous Retribution which may have got broken when I made the changes needed for Tortollan Turtles Daily.

Lua Code:
  1. -- Action Bar Creation Code Block includes ...
  2. local bar  = CreateFrame( "Frame", name, anchor, "SecureHandlerStateTemplate,SecureHandlerAttributeTemplate" );
  3. -- Other nUI Specific Bar Creation Code
  4.  
  5. --After creating nUI_ActionBar using above frame creation code
  6.  
  7. -- Paging system changed as follows ( more of an ordering of the special bars ) :
  8. RegisterStateDriver(
  9.     nUI_ActionBar, "page", string.format(
  10.           "[overridebar] %d; [shapeshift] %d;[vehicleui][possessbar] %d; [vehicleui] %d;"  ..
  11.           "[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; " ..
  12.           "[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 1; [bonusbar:5] 11; 1",
  13.           GetOverrideBarIndex(), GetVehicleBarIndex(),GetVehicleBarIndex(), GetTempShapeshiftBarIndex()
  14.    )
  15. );
  16.  
  17. -- Handle the action bar page changes only, buttons changed in new code block
  18.         nUI_ActionBar:SetAttribute('_onstate-page', [[
  19.             if not newstate then return end
  20.             newstate = tonumber(newstate)
  21.             self:SetAttribute("actionpage", newstate)
  22.         ]])
  23.  
  24. -- New attribute setting that allows management of custom attributes
  25. -- Ignore if the state-page value was just reset because the action bar buttons have changed
  26. -- Set state-page to nil if there are no action buttons with actions at all and every time an
  27. -- action button is found with no actions .. this doesn't change anything, but allows the
  28. -- _onstate-page attribute to trigger multiple times
  29.         nUI_ActionBar:SetAttribute('_onattributechanged', ([[
  30.             if name == "state-page" and value ~= nil then
  31.                 local pageOffset, hasAction = (value - 1) * NUM_ACTIONBAR_BUTTONS
  32.                 for id = 1,NUM_ACTIONBAR_BUTTONS do
  33.                     if HasAction(id + pageOffset) then
  34.                         ActionButtons[id]:SetAttribute('actionpage', value)
  35.                         ActionButtons[id]:SetAttribute('statehidden',false) -- use by ActionButton:Update
  36.                         hasAction = true
  37.                         self:SetAttribute("showbutton",id)
  38.                     else
  39.                         ActionButtons[id]:SetAttribute('actionpage', nil)
  40.                         ActionButtons[id]:SetAttribute('statehidden',true)-- used by ActionButton:Update
  41.                         self:SetAttribute("hidebutton",id)
  42.                         self:SetAttribute("state-page", nil)
  43.                     end
  44.                 end
  45.                 if not hasAction then
  46.                     self:SetAttribute("state-page", nil)
  47.                 end                
  48.             elseif name == "showbutton" then
  49.                 ActionButtons[value]:Show()
  50.             elseif name == "hidebutton" then
  51.                 ActionButtons[value]:Hide()
  52.             end
  53.         ]]):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS))

This seems to work fine, after several hours of mixing and matching the code Terenna posted so that it worked with nUI. At least for the big boom quest... I'll hold off handing it in until I have tested at least the tortollan turtle quest. Which after completing just now is working fine.

And it doesn't seem to have overtly affected the normal action bar switching ( druid forms etc switch and update fine with the correct ability icons ).
__________________

Last edited by Xrystal : 05-02-20 at 05:40 PM.
  Reply With Quote
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,492
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
07-28-20, 10:32 PM   #27
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,492
But alas .. my last post was not to be the last .. it appears that these changes affect how stance bars work ( in nUI at least ). So I may have to switch the override bar into a separate bar rather than a switching bar and apply the code to that which should solve the problems all round.
__________________
  Reply With Quote
07-29-20, 07:39 AM   #28
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,492
Wow .. all I had to do was monitor for a couple of events and then do a secure execute snippet to update the buttons again .. I suppose it is all a learning curve

The first time round it doesn't need to do it as the initial state-page change has the same code. Any additional calls to update the bars just asks for the page as last set and updates all the buttons again.

Works flawlessly with Big Boom quest and doesn't affect stance bar changes rofl.

Lua Code:
  1. elseif event == "UPDATE_VEHICLE_ACTIONBAR" or event == "UPDATE_OVERRIDE_ACTIONBAR" then
  2.         nUI_ActionBar:Execute(([[
  3.             local page = self:GetAttribute('state-page')
  4.             if not page then return end
  5.             local pageOffset, hasAction = (page - 1) * NUM_ACTIONBAR_BUTTONS
  6.             for id = 1, #ActionButtons do
  7.                 if HasAction(id + pageOffset) then
  8.                     ActionButtons[id]:SetAttribute('actionpage', page)
  9.                     hasAction = true
  10.                 else
  11.                     ActionButtons[id]:SetAttribute('actionpage', nil)
  12.                 end
  13.             end
  14.  
  15.             if not hasAction then
  16.                 self:SetAttribute('state-page', nil)
  17.             end            
  18.         ]]):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS))        
  19.     end
__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Quest:Righteous Retribution special action bar not switching in nUI

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off