View Single Post
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,892
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