local addonName,addonData = ...
local actionBarFrame = CreateFrame("Frame","XUI_ActionBar_Frame",UIParent,"SecureHandlerStateTemplate,SecureHandlerAttributeTemplate,SecureHandlerShowHideTemplate")
local eventFrame = CreateFrame("Frame","XUI_ActionBar_Events")
local function CheckEvents(self,event,...)
local args = { ... }
print(event,args[1],args[2],args[3],args[4],args[5])
print("HasVehicleActionBar() = ", HasVehicleActionBar())
print("HasOverrideActionBar() = ", HasOverrideActionBar())
print("HasTempShapeshiftActionBar() = ", HasTempShapeshiftActionBar())
print("HasBonusActionBar() = ", HasBonusActionBar())
print("HasPossessBar() = ", IsPossessBarVisible())
print("HasExtraBar() = ",HasExtraActionBar())
if ( event == "ADDON_LOADED" and args[1] == addonName ) then
actionBarFrame:SetPoint("CENTER",UIParent,"CENTER",0,0)
actionBarFrame:SetAttribute( "XUI_ActionType","ACTIONBUTTON" )
actionBarFrame:SetAttribute( "actionpage", 1 );
actionBarFrame.Buttons = { }
local lastButton = nil
for i = 1,12 do
actionBarFrame.Buttons[i] = CreateFrame("CheckButton","$parent_Button_"..i,actionBarFrame,"SecureActionButtonTemplate,ActionBarButtonTemplate")
actionBarFrame.Buttons[i]:SetID(i)
actionBarFrame.Buttons[i]:SetAttribute("action", i );
actionBarFrame.Buttons[i]:Show()
if ( lastButton ) then
actionBarFrame.Buttons[i]:SetPoint("TOPLEFT",actionBarFrame.Buttons[i-1],"TOPRIGHT",1,0)
else
actionBarFrame.Buttons[i]:SetPoint("TOPLEFT",actionBarFrame,"TOPLEFT",1,0)
end
lastButton = actionBarFrame.Buttons[i]
ActionButton_UpdateAction(lastButton);
end
RegisterStateDriver( actionBarFrame, "visibility", "[petbattle] hide; show" );
actionBarFrame:Execute(
[[
ChildList = newtable( self:GetChildren() );
ActionButtons = newtable();
actionType = self:GetAttribute( "XUI_ActionType" );
local j = 1;
for i, child in ipairs( ChildList ) do
if child:GetAttribute( "XUI_ActionType" ) then
ActionButtons[j] = child;
j = j+1;
end
end
]]
);
actionBarFrame:SetAttribute(
"updatePage",
[[
if ( newstate ~= "custombar" ) then return end
local newIndex = 0
local oldIndex = self:GetAttribute( "newstate" )
if ( ( HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
or ( HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= "") ) then
if ( HasVehicleActionBar() ) then
newIndex = GetVehicleBarIndex()
else
newIndex = GetOverrideBarIndex()
end
else
if HasVehicleActionBar() then
newIndex = GetVehicleBarIndex()
elseif HasOverrideActionBar() then
newIndex = GetOverrideBarIndex()
elseif HasTempShapeshiftActionBar() then
newIndex = GetTempShapeshiftBarIndex()
elseif HasBonusActionBar() and GetActionBarPage() ~= 1 then
newIndex = GetBonusBarIndex()
else
newIndex = GetActionBarPage()
end
else
newIndex = GetActionBarPage()
end
if ( newIndex == 0 ) then
newstate = oldIndex
else
newstate = newIndex
end
print("newState=",newstate)
]]
)
actionBarFrame:SetAttribute(
"_onstate-page",
[[
print(newstate)
self:RunAttribute("updatePage")
print(newstate)
self:SetAttribute( "actionpage", tonumber( newstate ) );
print(newstate)
for i, button in ipairs( ActionButtons ) do
button:SetAttribute( "touch", nil )
end
]]
);
actionBarFrame:SetAttribute(
"_onshow",
[[
for i, button in ipairs( ActionButtons ) do
button:SetAttribute( "touch", nil )
end
]]
);
RegisterStateDriver( actionBarFrame, "page", "custombar; 1" );
actionBarFrame:Show()
end
end
eventFrame:RegisterEvent("ACTIONBAR_UPDATE_STATE")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
eventFrame:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
eventFrame:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR")
eventFrame:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR")
eventFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
eventFrame:RegisterEvent("UPDATE_POSSESS_BAR")
eventFrame:RegisterEvent("UPDATE_EXTRA_ACTIONBAR")
eventFrame:SetScript("OnEvent",CheckEvents)