Quantcast
Quest:Righteous Retribution special action bar not switching in nUI - WoWInterface
 
Thread Tools Display Modes
08-23-18, 05:33 PM   #1
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Quest:Righteous Retribution special action bar not switching in nUI

I've just come across this on my hunter and it appears it switches out to an action bar that nUI hasn't managed to figure out the combination of paging conditionals to get it to appear without a reload of the UI.

For those that haven't got there yet its the alliance quest from Taelia in Vigil Hill around level 113.

Has any of the action bar creators figured out which setup gets this to work? If I remember rightly I had a similar problem where back when with the Thanksgiving Chair Hopping Quest and could never resolve it so is probably the same bar switch mechanism if that helps.

Thanks in advance for any help that can help me figure it out.
__________________

Last edited by Xrystal : 08-23-18 at 05:49 PM.
  Reply With Quote
08-23-18, 06:26 PM   #2
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
This is what I used based on Blizzard's ActionBarController code (verified it still matches up in BfA):
Code:
[vehicleui] 12; [overridebar] 14; [possessbar] [@vehicle, exists] 12; [shapeshift] 13; [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
I have no way to test myself but you can give it a shot.
  Reply With Quote
08-23-18, 06:30 PM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Originally Posted by Vrul View Post
This is what I used based on Blizzard's ActionBarController code (verified it still matches up in BfA):
Code:
[vehicleui] 12; [overridebar] 14; [possessbar] [@vehicle, exists] 12; [shapeshift] 13; [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
I have no way to test myself but you can give it a shot.
Thanks Vrul, I'll give it a test and let you know.

Looking at the code, it may be the [possessbar] [@vehicle, exists] 12; part as nUI has that down as [vehicleui][possessbar] GetVehicleBarIndex(). I guess there is a difference between [@vehicle, exists] and [vehicleUI] in regards to the posessbar. Thanks again.
__________________

Last edited by Xrystal : 08-23-18 at 06:34 PM.
  Reply With Quote
08-23-18, 06:48 PM   #4
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
Originally Posted by Xrystal View Post
I guess there is a difference between [@vehicle, exists] and [vehicleUI] in regards to the posessbar.
Here is that code section so you can see the logic flow and why vehicle stuff is in there two different ways:
Code:
-- If we have a skinned vehicle bar or skinned override bar, display the OverrideActionBar
if ((HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
or (HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= 0)) then
    -- For now, a vehicle has precedence over override bars (hopefully designers make it so these never conflict)
    if (HasVehicleActionBar()) then
        OverrideActionBar_Setup(UnitVehicleSkin("player"), GetVehicleBarIndex());
    else
        OverrideActionBar_Setup(GetOverrideBarSkin(), GetOverrideBarIndex());
    end
-- If we have a non-skinned override bar of some sort, use the MainMenuBarArtFrame
elseif ( HasBonusActionBar() or HasOverrideActionBar() or HasVehicleActionBar() or HasTempShapeshiftActionBar() or C_PetBattles.IsInBattle() ) then
    if (HasVehicleActionBar()) then
        MainMenuBarArtFrame:SetAttribute("actionpage", GetVehicleBarIndex());
    elseif (HasOverrideActionBar()) then
        MainMenuBarArtFrame:SetAttribute("actionpage", GetOverrideBarIndex());
    elseif (HasTempShapeshiftActionBar()) then
        MainMenuBarArtFrame:SetAttribute("actionpage", GetTempShapeshiftBarIndex());
    elseif (HasBonusActionBar() and GetActionBarPage() == 1) then
        MainMenuBarArtFrame:SetAttribute("actionpage", GetBonusBarIndex());
    else
        MainMenuBarArtFrame:SetAttribute("actionpage", GetActionBarPage());
    end
else
    -- Otherwise, display the normal action bar
    ActionBarController_ResetToDefault(force);
end
  Reply With Quote
08-23-18, 07:09 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Thanks Vrul.

It still confuses me how that normal code segment turns into conditionals. But then it has been years since I last had a look at it and it probably made a bit more sense back then while I was playing with it.

Anyway, thanks again and I'll give it a test run tomorrow when I have time to run through the whole quest which is in sections, in one go.
__________________
  Reply With Quote
08-23-18, 08:53 PM   #6
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
Here is nUI's relevant section changed to follow Blizzard's logic:
Code:
		if nUI_Options.boomkinBar then
			RegisterStateDriver(
				nUI_ActionBar, "page", string.format(
					"[vehicleui] %d; [overridebar] %d; [@vehicle,exists][possessbar] %d; [shapeshift] %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",
					GetVehicleBarIndex(), GetOverrideBarIndex(), GetVehicleBarIndex(), GetTempShapeshiftBarIndex()
				)
			);
		else
			RegisterStateDriver(
				nUI_ActionBar, "page", string.format(
					"[vehicleui] %d; [overridebar] %d; [@vehicle,exists][possessbar] %d; [shapeshift] %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",
					GetVehicleBarIndex(), GetOverrideBarIndex(), GetVehicleBarIndex(), GetTempShapeshiftBarIndex()
				)
			);
		end
  Reply With Quote
08-24-18, 01:05 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Yep, thats what I was going to do

Will test later on today when I'm in wow mode.
__________________
  Reply With Quote
08-24-18, 08:25 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Bummer, that didn't work.

I don't think its the bar thats the problem .. its the buttons not appearing until it is reloaded.

So maybe something to do with when the buttons are created and applied to the bar .. more investigation I guess


Ah, order matters doesn't it .. switched them round like you have and testing again.

Nope, same problem. It must be how nUI builds the buttons and the bars.

Oops, forgot the index change, nope that didn't work either ..

However, I did notice that although the button didn't change the key for the button worked. So must be an assignment of the button to the bar problem with nUI.
__________________

Last edited by Xrystal : 08-24-18 at 08:58 AM.
  Reply With Quote
08-24-18, 06:22 PM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Still no clearer to the problem for this quest .. but ..

Looking back at nUI's updates I found that I had managed to fix the pilgrims bounty bar switching and before that Draktharon Keep.

Just tested Draktharon Keep as we had since removed the separate vehicle bar code file sometime before 7.0 so I was worried it had broken my previous fixes, but nope, it still works .. so a different set up is required for this quest it seems.

Looking at Bartender, SyncUI and lsUI it appears we may have to reinstate a separate vehicle bar as it seems that is the thing they all seem to have in common.

Thanks again Vrul,
__________________
  Reply With Quote
08-26-18, 08:41 PM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Well I managed to get this working. Based on investigation the best way was to set up a bar just for vehicleui use as no amount of changing the code in nUI worked.

With this set up to display when having a vehicleui and the main action bar displayed otherwise seems to work.

The quest shows an empty bar at first and then updates the buttons with the information party way through the flight. This picks up that change and lets the buttons know and sets the appropriate texture via Blizzards Frame template functionality.

Now, in this scenario combat isn't an issue from what I can see, but what if it was, I guess I'll have to find a toon that needs to do the vashjir vision quest chain as I think that was a similar setup .. to 1. see if that now works and 2. whether the combat situation in that quest chain causes an issue... but, bowing to your superior knowledge of the secure section of addons Vrul, would any of this have an issue in combat ? If so, how the hell do actionbar addons deal with this apart from the one or two that gave up and just turned on the blizzard override bar rofl. Thanks in advance again

Lua Code:
  1. ------------------------------------------------------
  2. --[[              Bar Setup                       ]]--
  3. ------------------------------------------------------
  4. local barFrame = CreateFrame("Frame","XBar_Vehicle", UIParent, "SecureHandlerStateTemplate, SecureHandlerAttributeTemplate")
  5. local background = barFrame:CreateTexture("$parent_Background", "BACKGROUND")
  6. background:SetColorTexture(0,0,0,0.5)
  7. background:SetAllPoints()
  8. barFrame:SetWidth(51 * 12)
  9. barFrame:SetHeight(51)
  10. barFrame:SetPoint("CENTER")
  11.  
  12. ------------------------------------------------------
  13. --[[                 Button Setup                 ]]--
  14. ------------------------------------------------------
  15. barFrame.Buttons = {}
  16. for i = 1,NUM_ACTIONBAR_BUTTONS do    
  17.     local btn = CreateFrame("CheckButton", "$parent_Button"..i, barFrame, "SecureActionButtonTemplate,ActionBarButtonTemplate")
  18.     btn:SetWidth(50)
  19.     btn:SetHeight(50)
  20.     if i == 1 then
  21.         btn:SetPoint("LEFT",5,0)
  22.     else
  23.         btn:SetPoint("LEFT", "$parent_Button"..i - 1, "RIGHT", 1,0)
  24.     end
  25.    
  26.     local page = GetVehicleBarIndex()
  27.     local action = i + ((page - 1) * NUM_ACTIONBAR_BUTTONS)
  28.     btn:SetAttribute("type", "action")
  29.     btn:SetAttribute("action", action)
  30.     btn:SetAttribute("useparent-actionpage", true);  
  31.  
  32.     btn.NormalTexture:Hide()    
  33.     btn:Show()
  34.    
  35.     barFrame.Buttons[i] = btn
  36. end
  37.  
  38.  
  39. ------------------------------------------------------
  40. --[[                 Secure Stuff                 ]]--
  41. ------------------------------------------------------
  42.  
  43. barFrame:SetAttribute("_onattributechanged",[[ -- self, name, value    
  44.     if name == "updatebar" then
  45.         local page = GetVehicleBarIndex()
  46.         if HasVehicleActionBar() then        
  47.             local buttons = newtable(self:GetChildren())
  48.             for i,v in ipairs(buttons) do
  49.                 local action = i + ((page - 1) * 12)
  50.                 v:SetAttribute("action",action)                
  51.             end
  52.         end
  53.     end
  54. ]])
  55.  
  56. barFrame:SetAttribute('_onstate-actionpage', [[
  57.         self:SetAttribute('actionpage', GetVehicleBarIndex())
  58.     ]])
  59.  
  60. RegisterStateDriver(barFrame, "visibility", "[vehicleui] show; hide")
  61. RegisterStateDriver(barFrame, "page", "[vehicleui] 12; 1")
  62. barFrame:Execute(barFrame:GetAttribute('_onstate-actionpage'))
  63.  
  64. OverrideActionBarLeaveFrameLeaveButton:SetParent( barFrame );
  65. OverrideActionBarLeaveFrameLeaveButton:SetAllPoints( barFrame.Buttons[12] );
  66. RegisterStateDriver( OverrideActionBarLeaveFrameLeaveButton, "visibility", "[vehicleui][@vehicle, exists] show; hide" );       
  67.  
  68.  
  69. ------------------------------------------------------
  70. --[[         Event Control                        ]]--
  71. ------------------------------------------------------
  72. local function onEvent(self,event,...)
  73.     local args = {...}
  74.     if event == "UPDATE_VEHICLE_ACTIONBAR" then
  75.         barFrame:SetAttribute("updatebar")
  76.     end    
  77. end
  78.  
  79. barFrame:SetScript("OnEvent", onEvent)
  80. barFrame:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR")
__________________
  Reply With Quote
08-27-18, 09:32 PM   #11
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
Can you put this into it's own temp addon and see if it works for that quest:
Code:
local addonName, addon = ...

------------------------------------------------------
--[[                  Bar Setup                   ]]--
------------------------------------------------------
local actionbar = CreateFrame('Frame', addonName .. "ActionBar", UIParent, 'SecureHandlerStateTemplate')
actionbar:SetPoint('CENTER')
actionbar:SetSize(51 * 12, 51)

local background = actionbar:CreateTexture(nil, 'BACKGROUND')
actionbar.background = background
background:SetColorTexture(0, 0, 0, 0.5)
background:SetAllPoints()

actionbar:Execute([[
    ActionButtons = newtable()
]])

------------------------------------------------------
--[[                 Button Setup                 ]]--
------------------------------------------------------
local lastButton
for id = 1, NUM_ACTIONBAR_BUTTONS do    
    local button = CreateFrame('CheckButton', "$parentButton" .. id, actionbar, 'ActionBarButtonTemplate')
    button:SetID(id)
    button:SetSize(50, 50)

    if id ~= 1 then
        button:SetPoint('LEFT', lastButton, 'RIGHT', 1, 0)
    else
        button:SetPoint('LEFT', 5, 0)
    end

    button.NormalTexture:Hide()

    actionbar:SetFrameRef("button", button)
    actionbar:Execute(([[
        ActionButtons[%s] = self:GetFrameRef("button")
    ]]):format(id))

    lastButton = button
end

actionbar:Execute([[
    self:SetAttribute("frameref-button", nil)
]])

------------------------------------------------------
--[[                 Paging Stuff                 ]]--
------------------------------------------------------
actionbar:SetAttribute("_onstate-page", [[
	newstate = tonumber(newstate)
	for id, button in ipairs(ActionButtons) do
		button:SetAttribute('actionpage', newstate)
	end
]])

local paging = {
    ("[vehicleui] %d"):format(GetVehicleBarIndex()),
    ("[overridebar] %s"):format(GetOverrideBarIndex()),
    ("[possessbar] [@vehicle, exists] %s"):format(GetVehicleBarIndex()),
    ("[shapeshift] %d"):format(GetTempShapeshiftBarIndex())
}
for index = 2, NUM_ACTIONBAR_PAGES do
    paging[#paging + 1] = ("[bar:%d] %d"):format(index, index)
end
for index = 1, 5 do
    paging[#paging + 1] = ("[bonusbar:%d] %d"):format(index, index + NUM_ACTIONBAR_PAGES)
end
paging[#paging + 1] = "1"
RegisterStateDriver(actionbar, "page", strjoin("; ", unpack(paging)))

------------------------------------------------------
--[[                 Leave Button                 ]]--
------------------------------------------------------
OverrideActionBarLeaveFrameLeaveButton:SetParent(actionbar)
OverrideActionBarLeaveFrameLeaveButton:SetAllPoints(lastButton)
RegisterStateDriver(OverrideActionBarLeaveFrameLeaveButton, "visibility", "[canexitvehicle] show; hide")
Of course make sure you change it to a better spot/size so you can actually play.
  Reply With Quote
08-28-18, 05:41 AM   #12
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
I'm pretty sure its because for the conditions:
Code:
[vehicleui] 12; [overridebar] 14
only causes the OverrideActionBar buttons to be updated where the other conditions:
Code:
[possessbar] [@vehicle, exists] 12; [shapeshift] 13; [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
update the normal action buttons.

After work I'll dig through Blizzard's code to see if there is work around to get one bar to handle both, otherwise I'll clean up your new vehicle bar code and make it work without the event part.
  Reply With Quote
08-28-18, 07:18 AM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Thanks.

The last time I looked at this type of bar change was back in cataclysm days with the visions of vashjr and I am hoping because it is a similar scenario it will get that working as well.


Hmm. Just realised .. on my code the main action bar disappears as per its visibility conditional supposedly but if I also hide the override bar the main action bar never comes back until a reload. Not a biggie with nUI but annoying otherwise rofl.
__________________

Last edited by Xrystal : 08-28-18 at 09:10 AM.
  Reply With Quote
08-28-18, 07:19 PM   #14
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
Give this a try:
Code:
local BUTTON_SIZE, BUTTON_SPACING = 50, 1

------------------------------------------------------
--[[              Bar Setup                       ]]--
------------------------------------------------------
local barFrame = CreateFrame("Frame", "XBar_Vehicle", UIParent, "SecureHandlerStateTemplate")
barFrame:SetSize((BUTTON_SIZE + BUTTON_SPACING) * NUM_ACTIONBAR_BUTTONS, BUTTON_SIZE)
barFrame:SetPoint("CENTER")

local background = barFrame:CreateTexture(nil, "BACKGROUND")
background:SetColorTexture(0, 0, 0, 0.5)
background:SetAllPoints()

barFrame:Execute([[
    ActionButtons = newtable()
]])

------------------------------------------------------
--[[                 Button Setup                 ]]--
------------------------------------------------------
local buttons = { }
for id = 1, NUM_ACTIONBAR_BUTTONS do
    local button = CreateFrame("CheckButton", "$parent_Button" .. id, barFrame, "ActionBarButtonTemplate")
    button:SetID(id)

    button:SetSize(BUTTON_SIZE, BUTTON_SIZE)
    if id ~= 1 then
        button:SetPoint("LEFT", buttons[id - 1], "RIGHT", BUTTON_SPACING, 0)
    else
        button:SetPoint("LEFT", 5, 0)
    end

    button.NormalTexture:Hide()

    barFrame:SetFrameRef("button", button)
    barFrame:Execute(([[
        ActionButtons[%s] = self:GetFrameRef("button")
    ]]):format(id))

    buttons[id] = button
end
barFrame.Buttons = buttons

------------------------------------------------------
--[[                 Secure Stuff                 ]]--
------------------------------------------------------
barFrame:Execute([[
    self:SetAttribute("frameref-button", nil)
]])

barFrame:SetAttribute('_onstate-page', ([[
    newstate = tonumber(newstate)
    self:SetAttribute("actionpage", newstate)

    local pageOffset, hasAction = (newstate - 1) * NUM_ACTIONBAR_BUTTONS
    for id = 1, #ActionButtons do
        if HasAction(id + pageOffset) then
            ActionButtons[id]:SetAttribute('actionpage', newstate)
            hasAction = true
        else
            ActionButtons[id]:SetAttribute('actionpage', nil)
        end
    end

    if not hasAction then
        self:SetAttribute("state-page", nil)
    end
]]):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS))

RegisterStateDriver(barFrame, "page", ("[vehicleui] %s; [overridebar] %s; 1"):format(GetVehicleBarIndex(), GetOverrideBarIndex()))
RegisterStateDriver(barFrame, "visibility", "[vehicleui] [overridebar] show; hide")

OverrideActionBarLeaveFrameLeaveButton:SetParent(barFrame)
OverrideActionBarLeaveFrameLeaveButton:SetAllPoints(buttons[12])
RegisterStateDriver(OverrideActionBarLeaveFrameLeaveButton, "visibility", "[canexitvehicle] show; hide")
If that works I can modify it so you only need the one bar and not separate main, vehicle, override...
  Reply With Quote
08-28-18, 07:55 PM   #15
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
Thanks, giving it a go now ..

And yes if you can do that it will be great cos then I may have a better idea how to implement it into nUI.

Edit:

Did get a couple of errors to do with newstate being nil ( of course it would as its being set to nil ) so added the test to return if newstate is nil after setting the actionpage to newstate.

With the override bar visible it worked apart from the keybinding. With the overridebar hidden the keybinding worked. So I would say a resounding success.

Trying to see what you did different to me rofl. I tried the setting it to null if HasAction was false but it didn't work for me rofl


Thanks a hell of a lot but yes if you can put it in a single bar, I'll test it again. And when I get my rogue up to the vashjr combat equivalent I'll be able to confirm that combat situation works with it too.
__________________

Last edited by Xrystal : 08-28-18 at 08:11 PM.
  Reply With Quote
08-28-18, 09:05 PM   #16
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
Originally Posted by Xrystal View Post
And when I get my rogue up to the vashjr combat equivalent I'll be able to confirm that combat situation works with it too.
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.
  Reply With Quote
08-28-18, 09:19 PM   #17
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,513
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   #18
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   #19
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
08-28-18, 08:41 PM   #20
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 365
This should let you just use one action bar for everything:
Code:
local BUTTON_SIZE, BUTTON_SPACING = 50, 1

------------------------------------------------------
--[[              Bar Setup                       ]]--
------------------------------------------------------
local actionBar = CreateFrame("Frame", "XActionBar", UIParent, "SecureHandlerStateTemplate")
actionBar:SetSize((BUTTON_SIZE + BUTTON_SPACING) * NUM_ACTIONBAR_BUTTONS, BUTTON_SIZE)
actionBar:SetPoint("CENTER")

local background = actionBar:CreateTexture(nil, "BACKGROUND")
background:SetColorTexture(0, 0, 0, 0.5)
background:SetAllPoints()

actionBar:Execute([[
    buttons = newtable()
]])

------------------------------------------------------
--[[                 Button Setup                 ]]--
------------------------------------------------------
local buttons = { }
for id = 1, NUM_ACTIONBAR_BUTTONS do
    local button = CreateFrame("CheckButton", "$parentButton" .. id, actionBar, "ActionBarButtonTemplate")
    button:SetID(id)

    button:SetSize(BUTTON_SIZE, BUTTON_SIZE)
    if id ~= 1 then
        button:SetPoint("LEFT", buttons[id - 1], "RIGHT", BUTTON_SPACING, 0)
    else
        button:SetPoint("LEFT")
    end

    button.NormalTexture:Hide()

    actionBar:SetFrameRef("button", button)
    actionBar:Execute(([[
        buttons[%s] = self:GetFrameRef("button")
    ]]):format(id))

    buttons[id] = button
end
actionBar.Buttons = buttons

actionBar:Execute([[
    self:SetAttribute("frameref-button", nil)
]])

------------------------------------------------------
--[[                 Paging Stuff                 ]]--
------------------------------------------------------
actionBar:SetAttribute('_onstate-page', ([[
    if not newstate then return end
    newstate = tonumber(newstate)
    self:SetAttribute("actionpage", newstate)

    local pageOffset, hasAction = (newstate - 1) * NUM_ACTIONBAR_BUTTONS
    for id = 1, NUM_ACTIONBAR_BUTTONS do
        if HasAction(id + pageOffset) then
            buttons[id]:SetAttribute('actionpage', newstate)
            hasAction = true
        else
            buttons[id]:SetAttribute('actionpage', nil)
        end
    end

    if not hasAction then
        self:SetAttribute("state-page", nil)
    end
]]):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS))

local paging = {
    ("[vehicleui] %d"):format(GetVehicleBarIndex()),
    ("[overridebar] %s"):format(GetOverrideBarIndex()),
    ("[possessbar] [@vehicle, exists] %s"):format(GetVehicleBarIndex()),
    ("[shapeshift] %d"):format(GetTempShapeshiftBarIndex())
}
for index = 2, NUM_ACTIONBAR_PAGES do
    paging[#paging + 1] = ("[bar:%d] %d"):format(index, index)
end
for index = 1, 5 do
    paging[#paging + 1] = ("[bonusbar:%d] %d"):format(index, index + NUM_ACTIONBAR_PAGES)
end
paging[#paging + 1] = "1"
RegisterStateDriver(actionBar, "page", strjoin("; ", unpack(paging)))

------------------------------------------------------
--[[                 Leave Button                 ]]--
------------------------------------------------------
OverrideActionBarLeaveFrameLeaveButton:SetParent(actionBar)
OverrideActionBarLeaveFrameLeaveButton:SetAllPoints(buttons[12])
RegisterStateDriver(OverrideActionBarLeaveFrameLeaveButton, "visibility", "[canexitvehicle] show; hide")
Can you provide a Wowhead link to the quest you have been testing this against (I may want to try some other ideas out later)?
  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