07-23-17, 04:56 PM | #1 |
Any way to change ActionBar Page in combat? [SOLVED]
Hi all,
I know you can't (in principle, or maybe at all?) call ChangeActionBarPage(number) in combat but I was wondering if there is some context (e.g. in Restricted Environment) or maybe some alternative method to switching Blizzard's main action bar page, while in combat. As for the first alternative, the "secure context", I must admit it's likely way way way over my head. but I did try declaring my events-handling frame as inheriting from SecureHandlerBaseTemplate. Like so: Lua Code:
In any case, I think I understand the intention of implementing a Restricted Environment for your addon is so that the frames you create can do things they normaly couldn't, but to themselves only. I'm guessing it doesn't help at all when it comes to using such an environment to control Blizzard frames. Am I right? As for the second alternative, I tried the following: Lua Code:
For further clarification, I was trying to do these calls in response to ACTIONBAR_UPDATE_STATE and after checking GetActionBarPage() ~= 1, to bring it back to 1. I have macros to switch between page 1 and 2 through 4, which work fine in combat. Furthermore, the macro bellow also works fine in combat: Code:
/cast Some Spell /changeactionbar 1 Any thoughts would be greatly appreciated! Last edited by aallkkaa : 07-30-17 at 05:15 AM. Reason: Sollution given. |
|
07-25-17, 09:54 AM | #2 |
07-25-17, 12:35 PM | #3 |
Thanks a lot for that reference, Rainrider!
It's all still very confusing for me at the moment, but that might actually lead me somewhere. Incidentally... do you know this can be done or were you just hinting at it because you know maybe it can?... Anyway, in the little time I've spent reading that page, it got me to another one ( SecureActionButtonTemplate ), where it is apparently said (or maybe I'm misreading) that there is actually an "actionbar" type of attribute exactly for the purpose of changing the actionbar page (not just checking its state). Anyway, I feel like I'll still have to learn a big bit before I get this right, but it does feel like I'm moving in the right direction now. Thanks! And ... more thoughts still welcome! |
|
07-26-17, 02:53 AM | #4 |
If you want to change bar pages based on user input, then use the SecureActionButtonTemplate. Else you use the SecureStateDriver. You could take a look at Dominos code for reference.
|
|
07-27-17, 01:34 AM | #5 |
Yes, I want ro change bar pages based on user input, so yeah, I'm trying to look at SecureActionButtonTemplate now.
Dominos does change action bar pages in reaction to my macros, including during combat lockdown. Or at least so it seems. Maybe it only catches the call to change the page (I can easily do that myself, through the ACTIONBAR_PAGE_CHANGED event). Assuming Dominos changes the actual page on the Blizzard ActionBar (and then reflects that change in its own bars), it's still not very obvious to me how it does it. Looking for "Template" in the Dominos folder, I got four different templates being used: - ActionBarButtonTemplate; - SecureHandlerStateTemplate; - SecureActionButtonTemplate; - SecureHandlerShowHideTemplate. And that's just for the files in the bars and core subfolders. There's more in libs and in plugins ... SecureActionButtonTemplate but I'm unsure that's "the one" and "only" one needed for the task. SecureHandlerStateTemplate appears two or three times. RegisterStateDriver also makes appearances in Dominos. Three "states" (if I'm using the correct term) that I think may be of interest to me would be: - 'page'; - state - yes, it's a variable - I'll have to go chasing it around the code to understand its workings, I guess; - 'combat'. Seems like a lot of time trying to figure out how Dominos does something that might or not be what I want to do. Dominos is of course a much much much more ambitious project than my own (and coded by someone much much much more knowledgeable too) and I don't really have the time to read and understand all the relevant parts at the moment. Maybe I will when I get some more spare time. In the meanwhile, I found another ActionBars addon, called Paging. It serves a purpose similar to what I want to perform but it uses the modifier keys (ctrl, shift, alt) to keep on an alternate page only for as long as yu keep that modifier key pressed. That's not what I want. Currently, I press one of the keys E, R or T and the page swaps; I then have to press said key again to swap back to 1; sometimes, when reaction times are critical, I get lost about which page I'm on). The abilities one pages 2 through 4 are mostly situational ones and though very useful in those situations, it's most often than not a case of use once and not again for a long time... Making them available only while certain modifier key is down is something that I acomplished before with keybindings (to the bars) for a long time, and I wasn't happy. Press one key (no need to be doing hand-contortionism to hold a modifier all along) and I have a new set of buttons at my disposal, press the one I want and (the part currently missing) forget about it. This is what I'm trying to do. TL;DR: Paging is an addon which seems to be much simpler in scope than Dominos and I might get enough information from it. It is BTW ... outdated, from 6.0.3 if I remember correctly. Will have to test whether it still works. Once again, thanks for the thoughts, RainRider! Keep them coming! |
|
07-27-17, 01:44 PM | #6 |
I can show you how to do this using a combination of SecureHandlerBaseTemplate and SecureActionButtonTemplate. Since the default action bar doesn't use these templates (they are only for addons), I'm not sure you can get around the fact that you would need a custom action bar for this. You would at least need to create a hidden action bar that simply hijacks the regular action bar bindings to make this work for the default UI... to my knowledge.
Last edited by MunkDev : 07-28-17 at 09:11 PM. |
|
07-27-17, 04:20 PM | #7 |
I tinkered a bit more with this and you can actually do the same thing with just one button that uses a state driver, a wrapped PreClick and a custom identifier passed as the 'button' argument to the click script.
This solution only uses one secure button, does what you want, and the only drawback is that it won't trigger the first time if you're on a swap page when changing key bindings. This method also works when changing key bindings in combat. Lua Code:
Last edited by MunkDev : 07-28-17 at 09:43 PM. |
|
07-30-17, 12:44 AM | #8 |
Wow, thank you very very very much, MunkDev! This is working perfectly!
And I reckon it would have took me about a couple years to get all that down on my own! That was really awesome and kind of you! Again, thank you! I'm enjoying the fruits of it already. And still looking marvelled at little parts of your code to try and understand it better - I will probably break it every so often while testing stuff with it... I'd read about this stuff, wrapping-scripts in restriced environments, using long strings instead of functions in restricted environments, several other cool "tricks" in there, but it all seemed so blurry to me (still does for a big part). But seeing it all come together for one (seemingly) simple task is really cool! Again, thank you, you rock! Also, for the time being, I'll only be using this in a personal addon, which I don't intend to publish in the near future (or possibly ever). But if I do publish it sometime, will it be alright to include your snippet in it? |
|
07-31-17, 11:32 AM | #9 | |
Feel free to release this as your own, because I certainly won't. I tried to put comments on everything that might be unclear, because I also had these struggles when I first started with addon development. There are only a few cases for beginners to look at and they are often not that clear and concise.
In Iriel’s Field Guide to Secure Handlers the documentation on restricted environments and how it all works is pretty comprehensive, but under "Examples", all that's said is this:
Last edited by MunkDev : 07-31-17 at 11:35 AM. |
||
08-01-17, 05:12 AM | #10 |
Thank you!
Yes, I did do a quick read of Iriel's Field Guide to Secure Handlers and though I found it very well written and easy to follow, I still had many doubts in the end, regarding how to bring it all together to achieve a task. And yes, the Examples section was rather erm shorter than I expected... Your comments on the code are very very very helpful. Matter of fact, they are so helpful I got a little urge to mess about them, just for the sake of experimenting... |
|
WoWInterface » Developer Discussions » Lua/XML Help » Any way to change ActionBar Page in combat? |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|