Thread Tools Display Modes
08-14-20, 11:17 PM   #1
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Create ActionBars using LibActionButton-1.0

Im trying to use LibActionButton-1.0 to create action bars.
I get the problems that all actionbars are showing the exact same spells.

Code first:

Lua Code:
  1. LybrialActionBars.customExitButton = {
  2.     func = function()
  3.         if (UNITS:UnitExists("vehicle")) then
  4.             VehicleExit();
  5.         else
  6.             PetDismiss();
  7.         end
  8.     end,
  9.     texture = [[Interface\Icons\Spell_Shadow_SacrificialShield]],
  10.     tooltip = _G.LEAVE_VEHICLE,
  11. }
  12.  
  13. function LybrialActionBars:SetupBars()
  14.     TABLES:ForEach(self.db.profile.bars, function(index, bar)
  15.         local frameName = ADDON_NAME .. "_" .. index .. "_Frame";
  16.  
  17.         if (bar.enabled and (self.bars[frameName] == nil)) then
  18.             local dbPosition = self.db.profile.bars[index].layout.container.position;
  19.             local defaultPosition = defaults.profile.bars[index].layout.container.position;
  20.             local path = "bars," .. index;
  21.  
  22.             self.bars[frameName] = FRAMES:CreateFrame("Frame", frameName, FRAMES.UIParent, "SecureHandlerStateTemplate", true, LOCALE["ACTION_BAR"], self.db, dbPosition, defaultPosition, path);
  23.             self.bars[frameName]:SetFrameStrata("LOW");
  24.             self.bars[frameName]:SetFrameRef("MainMenuBarArtFrame", _G.MainMenuBarArtFrame);
  25.             self.bars[frameName].id = index;
  26.             self.bars[frameName].buttons = {};
  27.             self.bars[frameName].buttonsBind = self.db.profile.bars[index].buttons.bind;
  28.             self.bars[frameName].buttonsConfig = {};
  29.             self.bars[frameName].db = self.db.profile.bars[index];
  30.             self.bars[frameName]:CreateTemplateBackdrop();
  31.         end
  32.     end);
  33. end
  34.  
  35. function LybrialActionBars:UpdateBars()
  36.     TABLES:ForEach(self.bars, function(_, bar)
  37.         LAYOUT:Setup(bar, bar.buttons, bar.db.layout, bar.db.buttons.max);
  38.         VISIBILITY:UnregisterFrame(bar);
  39.         VISIBILITY:RegisterFrame(bar, bar.db.layout.container.visibility);
  40.     end);
  41. end
  42.  
  43. function LybrialActionBars:SetupButtons()
  44.     TABLES:ForEach(self.bars, function(_, bar)
  45.         for i = 1, 12 do
  46.             bar.buttons[i] = ACTION_BUTTON:CreateButton(i, STRINGS:Format(bar:GetName() .. "_Button_%d", i), bar, nil);
  47.             bar.buttons[i]:SetState(0, "action", i);
  48.  
  49.             for k = 1, 14 do
  50.                 bar.buttons[i]:SetState(k, "action", ((k - 1) * 12) + i);
  51.             end
  52.  
  53.             if i == 12 then
  54.                 bar.buttons[i]:SetState(12, "custom", LybrialActionBars.customExitButton);
  55.             end
  56.         end
  57.     end);
  58. end
  59.  
  60. function LybrialActionBars:UpdateButtons()
  61.     TABLES:ForEach(self.bars, function(_, bar)
  62.         TABLES:ForEach(bar.buttons, function(index, button)
  63.             bar.buttonsConfig.keyBoundTarget = STRINGS:Format(bar.buttonsBind .. "%d", index);
  64.  
  65.             button.keyBoundTarget = bar.buttonsConfig.keyBoundTarget;
  66.             button:SetAttribute("checkselfcast", true);
  67.             button:SetAttribute("checkfocuscast", true);
  68.             button:UpdateConfig(bar.buttonsConfig);
  69.         end);
  70.     end);
  71. end

Create the action bars this way results in the following:



The shortcuts are showing the correct values but the macro text and spells are all the same on each bar.
Does anyone has experience with that library and can tell me what im doing wrong?
  Reply With Quote
08-19-20, 09:31 AM   #2
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
I need to handle the state of each bar. Has nothing todo with LibActionButton. Thx.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Create ActionBars using LibActionButton-1.0

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off