View Single Post
08-04-13, 01:12 PM   #17
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,925
Well, save me messing up my copy of nUI6 beyond recognition I thought I would see if I could create a simple actionbar and get it to do the switches and test things that way ... not working quite like I planned though so Scott, a little help if possible.

The below is the whole of my code and it works in the sense that the main action bar appears and is useable and even has some basic functionality because of the templates I used.

However, despite it shifting when I use it on my warlock and shift into meta mode it doesn't work on my druid in ANY of her forms nor when doing the farming ( OVERRIDEBAR ) and definitely no closer to figuring out DTK last boss problems with it.

Any idea as to why it isn't working Scott ? Or anyone else looking in that understands Secure Handling.

Oh, and I take it that the secure snippet blocks don't allow print output commands for debugging ?

Lua Code:
  1. local addonName,addonData = ...
  2.  
  3. local actionBarFrame = CreateFrame("Frame","XUI_ActionBar_Frame",UIParent,"SecureHandlerStateTemplate,SecureHandlerAttributeTemplate,SecureHandlerShowHideTemplate")
  4. local eventFrame = CreateFrame("Frame","XUI_ActionBar_Events")
  5.  
  6. local function CheckEvents(self,event,...)
  7.     local args = { ... }
  8.     print(event,args[1],args[2],args[3],args[4],args[5])
  9.     print("HasVehicleActionBar() = ", HasVehicleActionBar())
  10.     print("HasOverrideActionBar() = ", HasOverrideActionBar())
  11.     print("HasTempShapeshiftActionBar() = ", HasTempShapeshiftActionBar())
  12.     print("HasBonusActionBar() = ", HasBonusActionBar())
  13.     print("HasPossessBar() = ", IsPossessBarVisible())
  14.     print("HasExtraBar() = ",HasExtraActionBar())
  15.  
  16.    
  17.     if ( event == "ADDON_LOADED" and args[1] == addonName ) then
  18.         actionBarFrame:SetPoint("CENTER",UIParent,"CENTER",0,0)
  19.         actionBarFrame:SetAttribute( "XUI_ActionType","ACTIONBUTTON" )
  20.         actionBarFrame:SetAttribute( "actionpage", 1 );
  21.         actionBarFrame.Buttons = { }
  22.         local lastButton = nil
  23.         for i = 1,12 do
  24.             actionBarFrame.Buttons[i] = CreateFrame("CheckButton","$parent_Button_"..i,actionBarFrame,"SecureActionButtonTemplate,ActionBarButtonTemplate")
  25.             actionBarFrame.Buttons[i]:SetID(i)
  26.             actionBarFrame.Buttons[i]:SetAttribute("action", i );
  27.             actionBarFrame.Buttons[i]:Show()
  28.             if ( lastButton ) then
  29.                 actionBarFrame.Buttons[i]:SetPoint("TOPLEFT",actionBarFrame.Buttons[i-1],"TOPRIGHT",1,0)
  30.             else
  31.                 actionBarFrame.Buttons[i]:SetPoint("TOPLEFT",actionBarFrame,"TOPLEFT",1,0)
  32.             end
  33.             lastButton = actionBarFrame.Buttons[i]
  34.             ActionButton_UpdateAction(lastButton);
  35.         end
  36.         RegisterStateDriver( actionBarFrame, "visibility", "[petbattle] hide; show" );
  37.  
  38.         actionBarFrame:Execute(
  39.             [[
  40.                 ChildList     = newtable( self:GetChildren() );
  41.                 ActionButtons = newtable();
  42.                 actionType    = self:GetAttribute( "XUI_ActionType" );
  43.                
  44.                 local j = 1;
  45.                
  46.                 for i, child in ipairs( ChildList ) do
  47.                     if child:GetAttribute( "XUI_ActionType" ) then
  48.                         ActionButtons[j] = child;
  49.                         j = j+1;
  50.                     end
  51.                 end
  52.             ]]
  53.         );
  54.  
  55.         actionBarFrame:SetAttribute(
  56.             "updatePage",
  57.             [[
  58.  
  59.                 if ( newstate ~= "custombar" ) then return end
  60.  
  61.                 local newIndex = 0
  62.                 local oldIndex = self:GetAttribute( "newstate" )
  63.  
  64.                 if ( ( HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
  65.                 or ( HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= "") ) then
  66.                     if ( HasVehicleActionBar() ) then
  67.                         newIndex = GetVehicleBarIndex()
  68.                     else
  69.                         newIndex = GetOverrideBarIndex()   
  70.                     end
  71.                 else
  72.                     if HasVehicleActionBar() then
  73.                         newIndex = GetVehicleBarIndex()
  74.                     elseif HasOverrideActionBar() then
  75.                         newIndex = GetOverrideBarIndex()
  76.                     elseif HasTempShapeshiftActionBar() then
  77.                         newIndex = GetTempShapeshiftBarIndex()
  78.                     elseif HasBonusActionBar() and GetActionBarPage() ~= 1 then
  79.                         newIndex = GetBonusBarIndex()
  80.                     else
  81.                         newIndex = GetActionBarPage()
  82.                     end
  83.                 else
  84.                     newIndex = GetActionBarPage()
  85.                 end
  86.                 if ( newIndex == 0 ) then
  87.                     newstate = oldIndex
  88.                 else
  89.                     newstate = newIndex
  90.                 end
  91.                 print("newState=",newstate)
  92.             ]]
  93.             )
  94.  
  95.         actionBarFrame:SetAttribute(
  96.             "_onstate-page",
  97.             [[
  98.  
  99.                 print(newstate)
  100.                 self:RunAttribute("updatePage")
  101.                 print(newstate)
  102.                 self:SetAttribute( "actionpage", tonumber( newstate ) );               
  103.                 print(newstate)
  104.                 for i, button in ipairs( ActionButtons ) do
  105.                     button:SetAttribute( "touch", nil )
  106.                 end        
  107.  
  108.             ]]
  109.         );        
  110.  
  111.         actionBarFrame:SetAttribute(
  112.             "_onshow",
  113.             [[
  114.                 for i, button in ipairs( ActionButtons ) do
  115.                     button:SetAttribute( "touch", nil )
  116.                 end        
  117.             ]]
  118.         );             
  119.  
  120.         RegisterStateDriver( actionBarFrame, "page", "custombar; 1" );
  121.         actionBarFrame:Show()
  122.  
  123.     end
  124.    
  125. end
  126.  
  127. eventFrame:RegisterEvent("ACTIONBAR_UPDATE_STATE")
  128. eventFrame:RegisterEvent("ADDON_LOADED")
  129. eventFrame:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
  130. eventFrame:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
  131. eventFrame:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR")
  132. eventFrame:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR")
  133. eventFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
  134. eventFrame:RegisterEvent("UPDATE_POSSESS_BAR")
  135. eventFrame:RegisterEvent("UPDATE_EXTRA_ACTIONBAR")
  136.  
  137. eventFrame:SetScript("OnEvent",CheckEvents)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818