WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Stuffs to be considered for making actionbar replacement with LibActionButton (https://www.wowinterface.com/forums/showthread.php?t=55992)

Eungavi 01-21-18 08:48 PM

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

zork 01-22-18 05:11 AM

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

Eungavi 01-22-18 06:55 AM

Quote:

Originally Posted by zork (Post 326578)
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.

lightspark 01-22-18 08:47 PM

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.

Eungavi 01-23-18 02:14 AM

Quote:

Originally Posted by lightspark (Post 326589)
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) :rolleyes:

Quote:

Originally Posted by lightspark (Post 326589)
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)?

Quote:

Originally Posted by lightspark (Post 326589)
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?

Quote:

Originally Posted by lightspark (Post 326589)
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

MunkDev 01-23-18 03:19 AM

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. ]])

lightspark 01-23-18 04:25 AM

Quote:

Originally Posted by Engavi (Post 326590)
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) :rolleyes:

It's indeed that simple >_>

Quote:

Originally Posted by Engavi (Post 326590)
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 :D

Quote:

Originally Posted by Engavi (Post 326590)
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.

Quote:

Originally Posted by Engavi (Post 326590)
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 :D

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 :p I replaced LAB's Blizz-like code w/ mine.

zork 01-23-18 04:47 AM

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.

kurapica.igas 01-23-18 06:03 AM

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

MunkDev 01-23-18 06:46 AM

Quote:

Originally Posted by kurapica.igas (Post 326595)
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).

Quote:

Originally Posted by lightspark (Post 326593)
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 :p I replaced LAB's Blizz-like code w/ mine.

Speaking of modifying LAB...

kurapica.igas 01-23-18 07:05 AM

Quote:

Originally Posted by MunkDev (Post 326596)
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

Eungavi 01-24-18 12:15 AM

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

Eungavi 01-25-18 10:49 PM

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 :o...)

lightspark 01-26-18 07:29 AM

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 :D

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.

gempir 01-26-18 12:15 PM

@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

Eungavi 01-26-18 04:16 PM

@lightspark, Thank you for clarification :banana:

@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 :rolleyes:

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 :p


All times are GMT -6. The time now is 06:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI