Quantcast WoWInterface - View Single Post - Amber-Shaper Un'sok
View Single Post
11-15-12, 08:08 AM   #10
A Pyroguard Emberseer
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,530
I checked ElvUi since his and TukUi always have some nice code pieces to look at.

When building the new rABS for MoP I stepped aways from bar paging because I had no clue how to apply the bar state to protected children (buttons). Actually thats the reason why I had to keep the default OverrideActionBar alive.

But there is a solution for this:
Lua Code:
  1. control:ChildUpdate("snippetid", message)
  2.     executes the contents of "_childupdate-snippetid" (or, if that attribute is nil/false, "_childupdate"), on all protected children (and children of children) of the restricted environment owner with (self, scriptid, message) arguments.

The interesting code snippets of Elv UI are
Lua Code:
  1. AB["barDefaults"] = {
  2.     ["bar1"] = {
  3.         ['visibility'] = "[petbattle] hide; show", --[petbattle][overridebar][vehicleui] hide; show
  4.         ['page'] = 1,
  5.         ['conditions'] = string.format("[vehicleui] %d; [possessbar] %d; [overridebar] %d; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;", GetVehicleBarIndex(), GetVehicleBarIndex(), GetOverrideBarIndex()),
  6.     },
  7. }
  9.     RegisterStateDriver(bar, "page", self:GetPage(barName, self['barDefaults'][barName].page, self['barDefaults'][barName].conditions));
  10.     --basically returns this: [vehicleui] GetVehicleBarIndex(); [possessbar] GetVehicleBarIndex(); [overridebar] GetOverrideBarIndex(); [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; 1"
  11.     RegisterStateDriver(bar, "visibility", self['barDefaults'][barName].visibility)
  13.     bar:SetAttribute("_onstate-page", [[
  14.         self:SetAttribute("state", newstate)
  15.         control:ChildUpdate("state", newstate)
  16.     ]])

The problem that we have when building an actionbar on our own is to reproduce this function in the ActionBarController. It handles the actionpage swap on conditions.
Lua Code:
  1. function ActionBarController_UpdateAll()
  2.     PossessBar_Update();
  3.     StanceBar_Update();
  6.     -- If we have a skinned vehicle bar or skinned override bar, display the OverrideActionBar
  7.     if ((HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
  8.     or (HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= "")) then
  9.         -- For now, a vehicle has precedence over override bars (hopefully designers make it so these never conflict)
  10.         if (HasVehicleActionBar()) then
  11.             OverrideActionBar_Setup(UnitVehicleSkin("player"), GetVehicleBarIndex());
  12.         else
  13.             OverrideActionBar_Setup(GetOverrideBarSkin(), GetOverrideBarIndex());
  14.         end
  17.     -- If we have a non-skinned override bar of some sort, use the MainMenuBarArtFrame
  18.     elseif ( HasBonusActionBar() or HasOverrideActionBar() or HasVehicleActionBar() or HasTempShapeshiftActionBar() or C_PetBattles.IsInBattle() ) then
  19.         if (HasVehicleActionBar()) then
  20.             MainMenuBarArtFrame:SetAttribute("actionpage", GetVehicleBarIndex());
  21.         elseif (HasOverrideActionBar()) then
  22.             MainMenuBarArtFrame:SetAttribute("actionpage", GetOverrideBarIndex());
  23.         elseif (HasTempShapeshiftActionBar()) then
  24.             MainMenuBarArtFrame:SetAttribute("actionpage", GetTempShapeshiftBarIndex());
  25.         elseif (HasBonusActionBar() and GetActionBarPage() == 1) then
  26.             MainMenuBarArtFrame:SetAttribute("actionpage", GetBonusBarIndex());
  27.         else
  28.             MainMenuBarArtFrame:SetAttribute("actionpage", GetActionBarPage());
  29.         end
  31.         for i=1, NUM_ACTIONBAR_BUTTONS do
  32.             local button = _G["ActionButton"..i];
  33.             ActionButton_UpdateAction(button);
  34.         end
  35.     else
  36.         -- Otherwise, display the normal action bar
  37.         ActionBarController_ResetToDefault();
  38.     end
  40.     ValidateActionBarTransition();
  41. end

In vehicle and possess state ElvUI uses the ID from GetVehicleBarIndex().
In overridebar state ElvUI uses the ID from GetOverrideBarIndex().

There is no state for temp shapeshift and bonusbar.

So basically what ElvUi does is creating an actionbar on its own using LibActionButton-1.0.
On page-state the bar state swaps and additionally all children swap aswell.

Regarding rABS. I have no clue why the bar should not show up.

The only reason I could think of is the [overridebar] firing without actually loading the OverrideActionbar and instead loading the override actionbuttons into the main actionbar. This would result in me removing the main actionbar and showing an probably empty (?!) overridebar. No clue.
| Simple is beautiful.
| WoWI AddOns | GitHub | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-15-12 at 08:56 AM.
  Reply With Quote