I've been playing Remix like many others ( who aren't lucky enough to get into the beta yet ) and I stumbled across several override bar issues.
Now, in light with nUI, I had decided to let Blizzard manage the override bar but just have nUI reposition things it didn't want Blizzard to control. However, the way Scott set up the keybinds for nUI meant that the override bar no long has keybinds, and vice versa if I try to set it up etc.
So, thought I would return back to having nUI manage the override bar and with so many quests in the Remix using it, I had ample tests to highlight the issues that occurred.
1. Buttons don't appear straight away ( Big Boom - BfA quest)
2. Bar jumps in and out during combat ( King Dun - Panda quest)
3. Bar and Buttons appear and disappear when initiated
I have been testing 1 for the last few days ( repeatedly ) in a simple addon to help identify what's needed for it to work and for some reason I can't get the icon to show. It's there but due to item 2 on the list, I need to limit what is done to avoid those functions that can't be used in combat.
My complete code is below and in lights to item 1 on the list the bar shows ( with all buttons but no icons ) when I cause the bar to appear ( do the next step in the quest ). The keybinds work fine, and inside the override bar's setup function I can see that it gets called whenever a button is updated with its action info, but the icon isn't shown.
Now, I can see GetActionInfo(action) as one of the okay functions ( hopefully while in combat too ) to use in the secured environment but, for some reason it returns nil inside the secure environment when it's insecure equivalent.
Also, the button's SetAttribute values never seem to get triggered so can't go that route either.
If anyone can see anything that I've missed for it to work as I expect, it would be a great help.
Thanks in advance.
edit: Just to add that if you reload the UI after the bar appears the active buttons have their icons show up. But when the inactive ones become active you have to do a reload to see the icon. So the icon is set to the button, it's just not being shown.
Lua Code:
local BUTTON_SIZE, BUTTON_SPACING = 50, 1
local NUM_ACTIONBAR_BUTTONS = 12
local BlizUI = CreateFrame( "Frame", "XAB_BlizUI", UIParent, "SecureFrameTemplate" )
OverrideActionBar:SetParent(BlizUI)
BlizUI:Hide()
local barFrame = CreateFrame("Frame", "XBar_OverrideBar", 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()
background:Show()
barFrame:Execute([[
ActionButtons = newtable()
]])
barFrame:SetPoint("CENTER")
local buttons = { }
for i = 1, NUM_ACTIONBAR_BUTTONS do
local button = CreateFrame("CheckButton","XBar_OverrideButton"..i, barFrame,"OverrideActionBarButtonTemplate")
button:SetID(i)
button:SetSize(BUTTON_SIZE, BUTTON_SIZE)
if i ~= 1 then
button:SetPoint("LEFT", buttons[i - 1], "RIGHT", BUTTON_SPACING, 0)
else
button:SetPoint("LEFT", 5, 0)
end
button.icon:Show()
local background = button:CreateTexture(nil, "BACKGROUND")
background:SetColorTexture(1, 1, 1, 0.5)
background:SetAllPoints()
barFrame:SetFrameRef("button", button)
barFrame:Execute(([[
ActionButtons[%s] = self:GetFrameRef("button")
]]):format(i))
button:SetAttribute("_onstate-statehidden",[[
print("statehidden: ",newstate)
if not newstate then return end
if newstate == "true" then
self:Hide()
else
self:Show()
end
]])
button:SetAttribute("_onstate-actionpage",[[
print("_onstate-actionpage: ",newstate)
if not newstate then return end
]])
buttons[i] = button
end
barFrame.Buttons = buttons
barFrame:Execute([[
self:SetAttribute("frameref-button", nil)
]])
barFrame: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, #ActionButtons do
ActionButtons[id]:SetAttribute("actionpage",newstate)
ActionButtons[id]:SetAttribute("action",id + pageOffset)
end
]]):gsub('NUM_ACTIONBAR_BUTTONS', NUM_ACTIONBAR_BUTTONS))
RegisterStateDriver( barFrame, "visibility", "[overridebar][vehicleui][target=vehicle, exists] show; hide" )
RegisterStateDriver(barFrame, "page", ("[vehicleui] %s; [overridebar] %s; 1"):format(GetVehicleBarIndex(), GetOverrideBarIndex()))
MainMenuBarVehicleLeaveButton:SetParent(barFrame)
MainMenuBarVehicleLeaveButton:SetAllPoints(barFrame.Buttons[12])
RegisterStateDriver(MainMenuBarVehicleLeaveButton, "visibility", "[canexitvehicle] show; hide")
hooksecurefunc(OverrideActionBar,"Setup", function(self,skin, barIndex)
print("OverrideActionBar:Setup", self:GetName(),skin,barIndex)
for k=1,6 do
local button = barFrame.Buttons[k]
local isHidden = button:GetAttribute("statehidden")
if button.action then
local actionType, actionID = GetActionInfo(button.action)
local iconVisible = button.icon:IsVisible()
local iconShown = button.icon:IsShown()
print(k,button.action,isHidden,actionType, actionID,iconVisible,iconShown)
button:SetAttribute("statehidden",actionID and false or true)
barFrame:Execute(([[
local button = ActionButtons[%d]
local action = button:GetAttribute("action")
local actionType, actionID = action and GetActionInfo(action) -- actionID is 0 ?
print(button:GetID(),action,actionType,actionID)
]]):format(k))
end
end
end)