LibActionButton-1.0 is a library to create and manage Action Buttons. And when i say action button, i don't necessarily mean buttons that are limited to the 120 actions the game gives you.
LibActionButton-1.0 implements a full replacement button which can either use the 120 actions provided by the game, or alternatively be completely independent of those actions, and directly use spells, items, macros, etc, letting the addon using LAB-1.0 manage the contents of the buttons.
Of course, actions and non-actions can also be mixed.
The whole button handling code, while roughly modeled after how Blizzard manages their buttons, has been cleaned up and optimized quite a lot. Replacing the whole default UIs action buttons with LAB-1.0 based buttons will increase your performance, even if not by much.
Features
- 100% support for Action-based buttons.
- 99%* support for non-action based buttons, containing spells, items, macros**.
- LibKeyBound-1.0 integration
- ButtonFacade support
- Configuration of the buttons through a config table
- Static Buttons (Disable Drag'n'Drop, so the user cannot change the contents of the button - only for non-action)
* 99% because Drag'N'Drop in combat is not 100% the same as for action buttons. You can drag a spell on the button, but only with a real drag (keep mouse button pressed from action pickup to action drop). Having the action on the cursor and clicking on the button to drop the action only works out of combat.
** Macros are not fully supported yet. You can drag them on buttons, and the macros will be cast when you click them, however alot of visual feedback is still missing.
ToDos
- Finish Macro support
- Pet Action support (replacing the pet bar)
- Add support for non-combat pets/mounts on the buttons
- New 4.0 "flyout" action support
- Extensive Testing
Maybes
- "Auto-Assist" option from Bartender
Requirements
- Requires WoW 4.0
- Its currently required to have a secure header driving the buttons.
Primarily aimed at replacing the custom Action Button code in Bartender4.5, i decided to make it a proper library, for everyone to benefit.
If anyone is creating secure buttons with custom actions on them right now, this could be potentially interesting for you. For example, this could be addons that provide bars for Hunter Aspects, Mage Portals, or something generic like AutoBar. Any kind of button that holds items or spells, and needs to behave like a typical Action Button, can make use of this library, and get rid of all the interfacing to the restricted environment and event handling.
- Add the "Border" color as an option in the config table. This will allow authors to optionally add a GUI option to change the color for equipped items. Otherwise, they'll have to hook the update function.
I've found that LAB is sort-of-conflicting with another addon, ThereIsNoCost, which scans for spells with a consumable requirement but that have been glyphed to remove the requirement, and hides the reagent cost text on the action button. Since the 4.0 update of BT4+LAB, the redundant reagent numbers are no longer being hidden.
I did some fprintf-style debugging and found that ThereIsNoCost is still doing all the right things, but then LAB comes along and restores the reagent count. Specifically, the other addon is securehooking ActionButton_UpdateCount. LAB's own UpdateCount() mostly duplicates that function. As a sanity check, adding an early 'return' to bail out of UpdateCount() immediately allows ThereIsNoCost's changes to work.
I'm not sure what the best solution to this would be.
LAB buttons does not use ActionButton_UpdateCount at all. It replaces most Blizzard functionality with its own. (Adding the early return just disables all count numbers, obviously)
Thats the price for the added flexibility i wanted. Addons working with Blizzard Action Bars will not work with Bartender anymore.
LAB buttons does not use ActionButton_UpdateCount at all. It replaces most Blizzard functionality with its own. (Adding the early return just disables all count numbers, obviously)
Well, something's calling it... If I add my own text to the routine in the hooked AB_UC (say, replacing glyphed numbers with "cheese"), then adding the early return shows "cheese" on the action button.
Let me approach it from another direction, then. If a plugin-type addon were written to do the same thing, but specifically for LAB/BT4, where would you recommend the appropriate hook be done? I'd love to hook UpdateCount, but as you said upthread, they're all locals.
I've not looked at what could be hooked in BT4 itself. The downside would be that future non-Bartender addons using LAB wouldn't be adjustable... which should probably not be a concern at present anyhow.
A third option would be to not hook anything, but have the plugin register for the appropriate events (ACTIONBAR_SLOT_CHANGED, etc) and reach into the BT4Button* objects that need to be changed. There's no way of making sure that the plugin's handler would run after BT4's handler, so the plugin would have to do things that subsequent BT4 updates would catch (probably making self.IsConsumableOrStackable return nil for glyphed spells).
I'm riffing off the top of my head without the benefit of coffee, so all this may be ridiculous later.
I don't know what would be calling AB_UC. LAB or BT4 certainly don't, and i don't use any of Blizzards initialization code on the buttons. Something funny must be going on!
I am working on adding a sane possibility to register callbacks for the common functions, so you get notified when they get called, and can do what you need to do.
I won't allow hooking, because that always has a high risk of blocking LAB to function, which happend so often before with BT4, that i would rather not see it happen again.
I'll probably go with a CallbackHandler interface, still trying to decide on the best way to handle this, which also works when the lib gets upgraded.
Ok, i implemented a set of callbacks and some new APIs:
[B]lib:GetAllButtons()[/B]
-- Returns a hash table containing all currently registered buttons as keys.
-- Like: {[button1] = true, [button2] = true, ...}
[b]lib.RegisterCallback(self, event, method, ...)[/b]
-- Register a callback handler. Default CallbackHandler-1.0 syntax
-- Example: LAB.RegisterCallback(MyAddon, "OnButtonCreated")
And all the events that fire callbacks
All callbacks receive the button as the first argument.
[b]"OnButtonCreated"[/b](button)
Fired when a new button was created
[b]"OnButtonContentsChanged"[/b](button, state, type ,value)
Fired when the type of the button changed due to a user action, drag'n'drop, etc.
Currently not being used in Bartender4, and only relevant for the addon controlling
this button, and requiring to save the new contents.
"OnButtonUpdate" will fire in addition to his, as a full button update will
run as well, so addons just needing to update their additional information on the button
do not have to use this at all.
[b]"OnButtonUpdate"[/b](button)
Fired when a full button update occurs.
This is the equivalent to ActionButton_Update.
[b]"OnButtonState"[/b](button)
Fired when the buttons state changes (after a click, for example)
This is the equivalent to ActionButton_UpdateState.
[b]"OnButtonUsable"[/b](button)
Fired when the buttons usability changes.
This is the equivalent to ActionButton_UpdateUsable.
Let me know if you need more information or more callbacks.
One thing, though: I will not fire a callback in OnUpdate for obvious reasons.
Does anyone know why I would be getting 100+ lua errors attributed to LibActionButton-1.0 when my guild levels after killing a dungeon or raid boss? It's happened twice so far - once when we hit level 12 after killing the final boss in Lost City, and tonight when we hit level 15 after killing Maloriak. My screen freezes for 5-7 seconds when it happens, and then I'll see the massive pile of lua errors in BugSack.
How to call OnReceiveDrag for this buttons (is nil)? Or at least is this possible to implement PlaceAction for this buttons?
I'm trying from my addon (FlyoutButton Custom) to put into parent BT4 button another spell on right click while not in combat. It works for Blizzard buttons through
FlyoutButton_SetCursor(self.command, self.value, self.subValue)
local type, action = actBtn:GetAction()
if type == "action" then
PlaceAction(action)
actBtn:UpdateAction(true)
end
ClearCursor()
3rd party interaction isn't really all that well though out yet.
It works perfectly as a self-contained button, but isn't too friendly to anyone trying to hook into it.
elseif actBtnName:match("^BT4Button%d+$") then
local atype, action = actBtn:GetAction()
if atype == "action" then
FlyoutButton_SetCursor(self.command, self.value, self.subValue)
PlaceAction(action)
actBtn:UpdateAction(true)
ClearCursor()
end
I was linking for someone who might benefit on WoWInterface, when I noticed "error 404" for the API link on LAB's main page description. The API can be found by clicking Pages, but for some people, that's a bit too much creative thinking.
Just pointing it out in case you want to update the link, Nev.
PSA: LibActionButton-1.0 now uses LibButtonGlow-1.0 for the spell activation alerts, due to a taint bug when using the Blizzard APIs (or even the Blizzard template).
If you use LibActionButton-1.0 in your project, you should include LibButtonGlow-1.0 as well, otherwise the glow effects will no longer show (it will however not error out).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
LibActionButton-1.0 implements a full replacement button which can either use the 120 actions provided by the game, or alternatively be completely independent of those actions, and directly use spells, items, macros, etc, letting the addon using LAB-1.0 manage the contents of the buttons.
Of course, actions and non-actions can also be mixed.
The whole button handling code, while roughly modeled after how Blizzard manages their buttons, has been cleaned up and optimized quite a lot. Replacing the whole default UIs action buttons with LAB-1.0 based buttons will increase your performance, even if not by much.
Features
- 100% support for Action-based buttons.
- 99%* support for non-action based buttons, containing spells, items, macros**.
- LibKeyBound-1.0 integration
- ButtonFacade support
- Configuration of the buttons through a config table
- Static Buttons (Disable Drag'n'Drop, so the user cannot change the contents of the button - only for non-action)
* 99% because Drag'N'Drop in combat is not 100% the same as for action buttons. You can drag a spell on the button, but only with a real drag (keep mouse button pressed from action pickup to action drop). Having the action on the cursor and clicking on the button to drop the action only works out of combat.
** Macros are not fully supported yet. You can drag them on buttons, and the macros will be cast when you click them, however alot of visual feedback is still missing.
ToDos
- Finish Macro support
- Pet Action support (replacing the pet bar)
- Add support for non-combat pets/mounts on the buttons
- New 4.0 "flyout" action support
- Extensive Testing
Maybes
- "Auto-Assist" option from Bartender
Requirements
- Requires WoW 4.0
- Its currently required to have a secure header driving the buttons.
Primarily aimed at replacing the custom Action Button code in Bartender4.5, i decided to make it a proper library, for everyone to benefit.
If anyone is creating secure buttons with custom actions on them right now, this could be potentially interesting for you. For example, this could be addons that provide bars for Hunter Aspects, Mage Portals, or something generic like AutoBar. Any kind of button that holds items or spells, and needs to behave like a typical Action Button, can make use of this library, and get rid of all the interfacing to the restricted environment and event handling.
Project: http://www.wowace.com/addons/libactionbutton-1-0/
API: http://www.wowace.com/addons/libactionbutton-1-0/pages/api/
If anyone is interested in using it, i would appreciate any feedback and features you might need/want.
I'll expand on the non-action functionality in the coming weeks, mostly as i need it in Bartender. ;)
- Add the "Border" color as an option in the config table. This will allow authors to optionally add a GUI option to change the color for equipped items. Otherwise, they'll have to hook the update function.
Haha. Didn't even think of that. But still. :p
I did some fprintf-style debugging and found that ThereIsNoCost is still doing all the right things, but then LAB comes along and restores the reagent count. Specifically, the other addon is securehooking ActionButton_UpdateCount. LAB's own UpdateCount() mostly duplicates that function. As a sanity check, adding an early 'return' to bail out of UpdateCount() immediately allows ThereIsNoCost's changes to work.
I'm not sure what the best solution to this would be.
Thats the price for the added flexibility i wanted. Addons working with Blizzard Action Bars will not work with Bartender anymore.
Well, something's calling it... If I add my own text to the routine in the hooked AB_UC (say, replacing glyphed numbers with "cheese"), then adding the early return shows "cheese" on the action button.
Let me approach it from another direction, then. If a plugin-type addon were written to do the same thing, but specifically for LAB/BT4, where would you recommend the appropriate hook be done? I'd love to hook UpdateCount, but as you said upthread, they're all locals.
I've not looked at what could be hooked in BT4 itself. The downside would be that future non-Bartender addons using LAB wouldn't be adjustable... which should probably not be a concern at present anyhow.
A third option would be to not hook anything, but have the plugin register for the appropriate events (ACTIONBAR_SLOT_CHANGED, etc) and reach into the BT4Button* objects that need to be changed. There's no way of making sure that the plugin's handler would run after BT4's handler, so the plugin would have to do things that subsequent BT4 updates would catch (probably making self.IsConsumableOrStackable return nil for glyphed spells).
I'm riffing off the top of my head without the benefit of coffee, so all this may be ridiculous later.
I am working on adding a sane possibility to register callbacks for the common functions, so you get notified when they get called, and can do what you need to do.
I won't allow hooking, because that always has a high risk of blocking LAB to function, which happend so often before with BT4, that i would rather not see it happen again.
I'll probably go with a CallbackHandler interface, still trying to decide on the best way to handle this, which also works when the lib gets upgraded.
And all the events that fire callbacks
All callbacks receive the button as the first argument.
Let me know if you need more information or more callbacks.
One thing, though: I will not fire a callback in OnUpdate for obvious reasons.
These changes are implemented in Bartender 4.4.13
I have more detailed info in a ticket here:
http://www.wowace.com/addons/libactionbutton-1-0/tickets/2-lab-lua-errors-using-bt4-in-combat-while-guild-leveled/
I'm trying from my addon (FlyoutButton Custom) to put into parent BT4 button another spell on right click while not in combat. It works for Blizzard buttons through
and for Button Forge through
Thanks.
3rd party interaction isn't really all that well though out yet.
It works perfectly as a self-contained button, but isn't too friendly to anyone trying to hook into it.
Just pointing it out in case you want to update the link, Nev.
If you use LibActionButton-1.0 in your project, you should include LibButtonGlow-1.0 as well, otherwise the glow effects will no longer show (it will however not error out).