Problem setting XML Spell Button Attributes
I thought this might have been due to the BfA changes, but nope, I can't get this to work in Live.
This is the button frame I am trying to set the attributes for so clicking casts the spell, it is contained within a parent frame, although based on recent code changes I may not need to but that's not the problem Code:
<Frame parentKey="ButtonFrame" inherits = "XMP_SpellPageTemplate" setAllPoints = "true" hidden = "true"> Code:
<Frame name = "XMP_SpellPageTemplate" virtual = "true"> Code:
<Button name = "XMP_SpellButtonTemplate" inherits = "XMP_IconTemplate,SecureActionButtonTemplate" virtual = "true"> Code:
<Button name = "XMP_IconTemplate" parentArray = "Buttons" virtual = "true"> Code:
local Button = v.isPortal and XMP_Main.ButtonFrame.Buttons[portalIdx + v.idx] or XMP_Main.ButtonFrame.Buttons[teleportIdx + v.idx] Lua Code:
I even tried setting a button name up via lua in case that was the reason but nada. Any ideas on what I am missing or misunderstood ? Any help appreciated and tanks in advance. |
Identified Problem ..
Finally figured out the problem is due to the data table not being generated properly. I must be creating it at the wrong time in Beta and not doing it at all in Live. Manually setting the spell ID on the XML allowed the button click to cast the spell but no icon appearing ( likely due to the problem identified ). So back to tracing the execution route to make sure the right values are set at the right time rofl. Considering setting a full table at the start rather than smaller tables when requested.
Lua Code:
Based on this latest debugging session it appears the new callback feature to ensure spell data is available also resets the data it sets when you leave, even on an addon wide data table. It is starting to look like I will have to use this function for every spell button that I want to set the spell data to. Hard coding the button attribute setting code to a specific value works ( without icon at the moment ) but trying to access the data value it has a hiccough ... more research, but getting closer. |
Resolved Problem
Whew .. finally .. I suspect I messed up a validation step somewhere as I can't see anything specific being different from before rofl.
This is generated when a map button is clicked Lua Code:
This is called when the selected button frame is being displayed ( it is actually one frame with the button attribute values changing and the unused buttons being hidden as required) Lua Code:
And this is what I did to get the spell data loaded in memory Lua Code:
Definitely looking better than my current version of the addon. A few more additions and it should be ready :) Hopefully some of this will help other's trying to do something similar and hitting problems :) |
As Hannibal Smith used to say “I love it when a plan comes together.” ;)
|
Alternative Spell Cache Option
After some further testing it appears that the SpellMixin way of working isn't exactly the greatest. It's definitely lightweight but it doesn't work for unknown spells until a second call. However, the following seems to work everytime on a fresh login.
Lua Code:
|
I don't think you need to worry about caching or the spell loading stuff. The only spell data you have to wait to load is spell descriptions and spell subtexts. If you're not using either of those, then the data is available immediately and always.
|
Quote:
My Legion version of the addon works fine in that regards (apart from the problem I initially reported here that I realised must have been a programming fault at my end) but the addon needed a rewrite due to the number of portal and teleport spells available. So, with Battle for Azeroth looming I decided to do a full rewrite and that is when I noticed the spell problems. But in either case, the multiple problems I was pointing out are now solved, either by unknowingly correcting faults at my end or by implementing the new functionality. |
All times are GMT -6. The time now is 09:15 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI