Quantcast Stuffs to be considered for making actionbar replacement with LibActionButton - WoWInterface
Thread Tools Display Modes
01-21-18, 08:48 PM   #1
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Stuffs to be considered for making actionbar replacement with LibActionButton

I don't know how many of addon authors, here, have used or are currently using LibActionButton for their addon, but what things should I consider while replacing a default blizzard actionbar with it?

The only thing that I know is you should use SecureHandlerStateTemplate for creating a bar and register state driver on it so that each individual buttons switch on shape shifting, page switching and so on.

What else would be there?

-Engavi

Last edited by Eungavi : 01-21-18 at 08:55 PM.
  Reply With Quote
01-22-18, 05:11 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,726
Check lightspark's UI. He is using Lib-Action-Button. Well...he may have adjusted it a little since the reference is LibActionButton-1.0-ls.

https://github.com/ls-/ls_UI/blob/ma...onbars.lua#L10
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
01-22-18, 06:55 AM   #3
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Originally Posted by zork View Post
Check lightspark's UI. He is using Lib-Action-Button. Well...he may have adjusted it a little since the reference is LibActionButton-1.0-ls.

https://github.com/ls-/ls_UI/blob/ma...onbars.lua#L10
Sweet! Gotta start from comparing the original library and lightspark's adjusted one then

Thanks for reference zork

** EDIT

Okay, just had a look at both files and I could pretty much say that there is no change on performance or its functionality, but the only difference the design.

Last edited by Eungavi : 01-22-18 at 07:13 AM.
  Reply With Quote
01-22-18, 08:47 PM   #4
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 305
Mine might not be a good example of LAB usage because I'm still migrating to it and code needs to be adjusted, I used to re-use Blizz buttons.

But from my experience so far LAB is missing only one thing: a new 735 feature that allows you to right-click an action button to toggle pet action's autocasting if it's placed on your action bar. But that's Blizz forgetting about us, addon devs, once again, it's not a part of secenv, so nothing can be done atm >_>

Other than that, it's fine. It's not that customisable by default, but it's a lib, so you can edit its code w/o any issues. That's what I did.

Benefits of using LAB are quite nice, the most important, at least for me, is that you don't need to dance around default buttons' OnUpdate and OnEvent handlers, like each button has its own o_O LAB uses a better approach, so it may actually be a performance gain. And, once again, because it's a lib, you can alter it w/o breaking anything.
__________________

Last edited by lightspark : 01-22-18 at 08:51 PM.
  Reply With Quote
01-23-18, 02:14 AM   #5
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Originally Posted by lightspark View Post
Mine might not be a good example of LAB usage because I'm still migrating to it and code needs to be adjusted, I used to re-use Blizz buttons.
Don't worry too much about it

The only thing that I need is just a brief reference so that I could get a bare minimum idea on how I should deal with it.
There is an official documentation for LAB on its project page, but I find it too simple (or short)

Originally Posted by lightspark View Post
But from my experience so far LAB is missing only one thing: a new 735 feature that allows you to right-click an action button to toggle pet action's autocasting if it's placed on your action bar. But that's Blizz forgetting about us, addon devs, once again, it's not a part of secenv, so nothing can be done atm >_>
So, is Blizzard aware of this issue(?)? Or are they really unconcerned about addon devs (as you said)?

Originally Posted by lightspark View Post
Other than that, it's fine. It's not that customisable by default, but it's a lib, so you can edit its code w/o any issues. That's what I did.
If I'd customize the appearance of buttons/action bars (border, background, glow, etc), which approach would you recommend?

Should I directly adjust it from lib file? Or should I modify it on button creation?

Originally Posted by lightspark View Post
Benefits of using LAB are quite nice, the most important, at least for me, is that you don't need to dance around default buttons' OnUpdate and OnEvent handlers, like each button has its own o_O LAB uses a better approach, so it may actually be a performance gain. And, once again, because it's a lib, you can alter it w/o breaking anything.
Could I get some further explanation regarding this, please?


Many thanks!

-Engavi

Last edited by Eungavi : 01-24-18 at 12:12 AM.
  Reply With Quote
01-23-18, 03:19 AM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 416
Lua Code:
  1. -- FrameXML\SecureTemplates.lua:351
  2. SECURE_ACTIONS.pet =
  3.     function (self, unit, button)
  4.         local action =
  5.             SecureButton_GetModifiedAttribute(self, "action", button);
  6.         if ( action ) then
  7.             CastPetAction(action, unit);
  8.         end
  9.     end;

Damn, I didn't even know this. They could change it to this...
Lua Code:
  1. SECURE_ACTIONS.pet =
  2.     function (self, unit, button)
  3.         local action =
  4.             SecureButton_GetModifiedAttribute(self, "action", button);
  5.         if ( action ) then
  6.             if ( button == "LeftButton" ) then
  7.                 CastPetAction(action, unit);
  8.             else
  9.                 TogglePetAutocast(action);
  10.             end
  11.         end
  12.     end;
...or give a separate type for it since you might want to use something other than LeftButton as input.

I've also built my own version of LAB because it didn't cover all my needs, but here are my recommendations anyway:
  • I'm just using PetActionButtonTemplate for a separate pet bar. I haven't bothered trying to fit a square peg in a round hole.
  • For posterity I recommend not pre-calculating the actionpage attribute using a state driver, because to me it seems these numbers may change when they make changes to certain specs; Shadowdance used to have its own page, and monks had several pages for stances that no longer exist.

    Lua Code:
    1. local function GetActionpageStateDriver()
    2.     -- Generate a macro condition with generic values to ensure any change pushes an update.
    3.     -- Add any new / extra macro conditions to the list below. (as if there aren't enough already)
    4.     local conditionFormat = '[%s] %d; '
    5.     local count, driver = 0, ''
    6.     local conditions = {
    7.         ----------------------------------
    8.         'vehicleui', 'possessbar', 'overridebar', 'shapeshift',
    9.         'bar:2', 'bar:3', 'bar:4', 'bar:5', 'bar:6',
    10.         'bonusbar:1', 'bonusbar:2', 'bonusbar:3', 'bonusbar:4'
    11.         ----------------------------------
    12.     }
    13.     for i, condition in ipairs(conditions) do
    14.         driver = driver .. format(conditionFormat, condition, i)
    15.     end
    16.     driver = driver .. (#conditions + 1) -- append the list for the default bar (1) when none of the conditions apply.
    17.     -- this ends up looking like this: "[vehicleui] 1; [possessbar] 2; ... [bonusbar:4] 13; 14"
    18.     ----------------------------------
    19.     return driver
    20. end
    21.  
    22. -- Register the generic state driver just so it sends updates on page swaps.
    23. RegisterStateDriver(mainBar, 'page', GetActionpageStateDriver())
    24.  
    25. -- With this approach, newstate is expected to return an incorrect value,
    26. -- because I didn't bother finding out which condition corresponds to which page.
    27. -- Instead I'm using the available API in the environment to calculate the page.
    28. -- This is pretty much an exact copy of ActionBarController_UpdateAll,
    29. -- which you can find in FrameXML\ActionBarController.lua:107
    30. mainBar:SetAttribute('_onstate-page', [[
    31.     if HasVehicleActionBar() then
    32.         newstate = GetVehicleBarIndex()
    33.     elseif HasOverrideActionBar() then
    34.         newstate = GetOverrideBarIndex()
    35.     elseif HasTempShapeshiftActionBar() then
    36.         newstate = GetTempShapeshiftBarIndex()
    37.     elseif GetBonusBarOffset() > 0 then
    38.         newstate = GetBonusBarOffset() + 6
    39.     else
    40.         newstate = GetActionBarPage()
    41.     end
    42.     self:SetAttribute('actionpage', newstate)
    43.     control:ChildUpdate('actionpage', newstate)
    44. ]])
__________________

Last edited by MunkDev : 01-23-18 at 03:35 AM.
  Reply With Quote
01-23-18, 04:25 AM   #7
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 305
Originally Posted by Engavi View Post
Don't worry too much about it

The only thing that I need is just a brief reference so that I could get a bare minimum idea on how I should deal with it.
There is an official documentation for LAB on its project page, but I find it to simple (or short)
It's indeed that simple >_>

Originally Posted by Engavi View Post
So, is Blizzard aware of this issue(?)? Or are they really unconcerned about addon devs (as you said)?
Well, I think so, I didn't report it, but prob someone else did, prob o_O They're a bit out of touch w/ secenv because they don't need to use it for their own UI, all Blizz code is secure by default. So things normally go like this:
- Proper patch #1. Blizz add a new feature, but forget to add it to secenv;
- We report it;
- Proper patch #2. Blizz add said feature to secenv.

They rarely add anything w/ hotfixes though, so I expect this to be fixed in 8.0

Originally Posted by Engavi View Post
If I'd customize the appearance of buttons/action bars (border, background, glow, etc), which approach would you recommend?

Should I directly adjust it from lib file? Or should I modify it on button creation?
Nah, something as simple is done on button creation, so no need to change the lib itself, I was talking about things that aren't implemented/supported by the lib or if you want them to be handled differently, e.g., state/action-specific icon colouration or whatever.

You can even add masque support, if you want.

Originally Posted by Engavi View Post
Could I get some further explanation regarding this, please?
Well, instead of having OnUpdate handlers running on tens of buttons simultaneously, LAB uses only one, same goes for event stuff. It's a performance gain, a marginal one

You can reskin Blizz buttons w/o any issues, but when it comes to dynamic things, like using different colours for icons, reusing default buttons might be a PITA, but if you use LAB, you can do whatever you want w/ it I replaced LAB's Blizz-like code w/ mine.
__________________
  Reply With Quote
01-23-18, 04:47 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,726
I have not digged into LAB yet because the default action bar is fine for my needs.

I always seperated the styling of the buttons from the general layout of the bar.

If you are using an action button template it is quite easy to adjust the button appearance once the button is created because all elements are already there. It might be even possible to just use rButtonTemplate for it if a Blizzard action button template is used.

rButtonTemplate:StyleActionButton()
https://github.com/zorker/rothui/blo.../core.lua#L169
Doc:
https://github.com/zorker/rothui/blo...late/README.me
My config:
https://github.com/zorker/rothui/blo.../theme.lua#L39

Funny enough I was able to give all buttons in the player BuffFrame, BagSlots and for all action buttons the same config.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

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

Last edited by zork : 01-23-18 at 04:52 AM.
  Reply With Quote
01-23-18, 06:03 AM   #9
kurapica.igas
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 97
For the right-click on pet action, you can use macro type for the right-click. Well, no harm to click the original pet action button.
Lua Code:
  1. self:SetAttribute("type2", "macro")
  2. self:SetAttribute("macrotext2", "/click PetActionButton".. target .. " RightButton")

It's a little difficult to figure out the action page, I use three steps to figure it out:

1. Use SetFrameRef to register the MainMenuBarArtFrame and OverrideActionBar to your secure frame, so we can get some action page securely during combat:
ActionHandler.lua#L147-L148

2. Register state for conditions like stanceActionHandler.lua#L151-L188

3. At last, the secure snippet to get the real action page based on the state and the MainMenuBarArtFrame or OverrideActionBar ActionHandler.lua#L94-L117
  Reply With Quote
01-23-18, 06:46 AM   #10
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 416
Originally Posted by kurapica.igas View Post
3. At last, the secure snippet to get the real action page based on the state and the MainMenuBarArtFrame or OverrideActionBar ActionHandler.lua#L94-L117
This isn't really that robust. It's better to use the API provided in the environment (for this exact purpose).

Originally Posted by lightspark View Post
You can reskin Blizz buttons w/o any issues, but when it comes to dynamic things, like using different colours for icons, reusing default buttons might be a PITA, but if you use LAB, you can do whatever you want w/ it I replaced LAB's Blizz-like code w/ mine.
Speaking of modifying LAB...
__________________

Last edited by MunkDev : 01-23-18 at 06:49 AM.
  Reply With Quote
01-23-18, 07:05 AM   #11
kurapica.igas
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 97
Originally Posted by MunkDev View Post
This isn't really that robust. It's better to use the API provided in the environment (for this exact purpose).
I check the RestrictedEnvironment.lua, well, the GetVehicleBarIndex and GetOverrideBarIndex is added in 7.0. finally no need to fetch them by tricky now
  Reply With Quote
01-24-18, 12:15 AM   #12
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Thank you so much to all for giving me such a valuable advice, comments and references.

I'm not sure when I'd start writing my project with LAB, but this post would definitely be the great starting point for myself as well as for those who are willing to write one

-Engavi

Last edited by Eungavi : 01-24-18 at 02:21 AM.
  Reply With Quote
01-25-18, 10:49 PM   #13
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Okay, here's another question.

What's the best way to disable/hide default blizzard action bars?
I currently found two solutions, one from Bartender4 and the other from lightspark's project, but ain't sure of which would be better.
(apologize to lightspark for keep mentioning of his project ...)

Last edited by Eungavi : 01-25-18 at 11:43 PM.
  Reply With Quote
01-26-18, 07:29 AM   #14
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 305
In general, you may want to kill them for good: unregister all events, reparent them to a hidden frame and so on.

But sometimes Blizz make bars (esp MainMenuBarArtFrame) do more things than they're supposed to do, for instance, at some point in the past MainMenuBarArtFrame was used to update either currency or rep tab on your character frame, so if you unregistered all events, you wouldn't see one of those tabs there

I kill them all, but I keep events on MainMenuBarArtFrame, haven't caused any issues in years. Bartender hides most of them w/o touching events.
__________________

Last edited by lightspark : 01-26-18 at 07:32 AM.
  Reply With Quote
01-26-18, 12:15 PM   #15
gempir
A Cliff Giant
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 79
@Engavi what's your decision for writing new Actionbars? Or have you tried reusing Blizzards Actionbars before?

I'm kinda in the same situation as you, needing some sort of customizable Actionbars.
I'm currently using an old version of zorks rActionbar which actually works really nicely.

But I wanted to add and ingame config and starting running into issues (like somehow 2 actionbars have the exact same spells on them, but the macros, position etc. are correct)

So I'm thinking of doing something like you and using LibActionButton.
My current situation looks like this if you wanna read some code. https://github.com/gempir/gempUI/blo...nbars/bars.lua
  Reply With Quote
01-26-18, 04:16 PM   #16
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
@lightspark, Thank you for clarification

@gempir, Unfortunately, I have not yet decided whether I'd directly start from LAB or reuse Blizzard's code to just re-skin buttons, thus it's 50:50 so far.
(I do not have an experience of reusing Blizzard's code either, btw)

Although my "current" goal is just re-skinning, I would like to have more controls on its features and that's why I'm considering LAB at the same time, but you know

Even if I start my project, I'm pretty sure it won't finish in next few months cause I'm super lazy and planning to start my degrees real soon

Last edited by Eungavi : 01-26-18 at 07:37 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Stuffs to be considered for making actionbar replacement with LibActionButton

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