2.x Secure State Headers
I have been beating my head against this brick wall for a week now.
I'm working on trying to get this mod to work and then I'll try to understand the 3.0 changes. I am down to just guessing now and that's getting nowhere very quickly. Yes, I'm told that this will be easier with 3.x. I don't see that as being comforting since I can't find much about it beyond Iriel's documentation. Perhaps I'm just an idiot, but I don't think so. So, what is the obvious thing I've done in the below code? I'll tell you what it does do. I get the button I create. I can right and left click in the parent frame to change the state. That piece of code isn't in the box below. What does not happen is, at no time does a spell ever get cast. The button just presses and animates. No error message. No attempt to cast the spell I thought I associated with any of the virtual buttons. The spell names are spelled right as I can change this up to a normal secure button without states and it casts nicely. I just can't change what the button does in combat. All the examples I've seen only use secureactionbarbutton. That has functionality I don't want. Namely its tied to action buttons. Perhaps changing spells per state is not allowed. Code:
ntraps=trapper:enumeratetraps() |
Code:
trap_b:SetAttribute("type1-S"..t,"spell") Code:
trap_b:SetAttribute("type-S"..t,"spell") On getting to grips with secure state headers There are two main interesting parts that you should look at when things are not working out:
Read the SecureButton_GetModifiedAttribute, SecureState_GetStateAttribute, SecureState_GetStateModifiedAttribute functions - they're important to figure out which attributes are valid in which case. |
For a more complete change-spell-on-state example:
Code:
local sBtn = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate"); -- [1]
|
Thank you for your responses.
There has to be something subtle I'm just missing on this because even when I change things around to your example, the button still never casts a spell. I'm out of time today, I'll look at it again tomorrow. Again, thank you. |
Ok, Its a new day....
Since I couldn't get the spells to actually work on states, I went with a different approach. I also needed to change the icon depending on state and I couldn't find a way to do that in combat. I went with a different approach using "hidestate"/"showstate". In this scheme I create up to 5 buttons and put them all in the same space. All but one is hidden per state. That works. Except then I found out that whenever I click the button it changes the state automatically to the next one in line. I'd rather that didn't happen except by some other method. For testing that is clicking in the bordering frame. Now, I can make the state change up and down. I do the math myself and all. I have stopped the secureheader from moving the state on the button with every click with: SetAttribute("newstate","1-5:=") I read that notation somewhere, it works. I change the state programatically with SetAttribute("state",x) that changes the state BUT introduces a new problem I've not been able to work around. It doesn't seem to actually update all the buttons. In my research I tried ActionButton_Update(). This is no good because my button isn't actually an action bar button. It therefore bashes out when trying to use a function ActionGetTexture(action) internally. Again, I don't want to make it an action button as that defeats the purpose of what I'm doing with this. I seem to be so close with this. In fact, if I can find a way to update the secureheader and its children I'd be good to go. Now I am torturing myself looking through the securexxxxtemplate.lua codes to see how those are updated. |
You can put your own code in the on state changed method on the header, then run whatever you need in there (It obviously can't do secure stuff, but it sounds like you're just trying to update visuals)
|
Unfortunately, I want the buttons to update their own hide/show status which is a secure thing. So basically, I want them to update themselves according to the rules I set up in all the secureheader junk.
I'll keep looking, but its a real mess. The real fun is, I get to do this all again when 3.0 comes out. But I have to stay busy for now rather than just wait around and learn that from scratch. |
I forgot to bring my keyfob thing with me yesterday so I couldn't do any testing. Today, however, I could.
I am now convinced I just cannot do what I want to do. I did manage to get the secureheader frame and all its children to update whenever I forced a state change. Unfortunately, " Interface action failed because of an AddOn " Bla effin bla It seems wrong, though since I see target windows hide and show all the time during combat. Oh well. I guess my only choice is the five-buttons-on-the-screen option. Works great out of combat, right where you don't care. |
I also tried a different approach. Never figured out why the statebutton didn't work before but it does now.
So, with this approach I create 1 button made into a child of the stateheader frame. Each state is tied to a different trap. I do not want the state to change when clicked, instead I want it to change with another event (eventually a mousewheel but for now its a click in the state frame rather than the button) Ok, well. It works out of combat just fine. In combat, apparently, I'm not allowed to update the button state. |
All times are GMT -6. The time now is 09:50 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI