View Single Post
05-19-18, 09:50 AM   #1
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
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">
                <Scripts>
                    <OnLoad>
                        XMP_ButtonFrame_OnLoad(self)
                    </OnLoad>
                    <OnShow>
                        XMP_ButtonFrame_OnShow(self)
                    </OnShow>
                </Scripts>
            </Frame>
        </Frames>
This is the template for this frame, the buttons will be ultimately hidden by default
Code:
    <Frame name = "XMP_SpellPageTemplate" virtual = "true">
        <Frames> 
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "1" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "2" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "3" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "4" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "5" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "6" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "7" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "8" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "9" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "10" />
        </Frames>            
    </Frame>
This is the template for the spell button itself
Code:
    <Button name = "XMP_SpellButtonTemplate" inherits = "XMP_IconTemplate,SecureActionButtonTemplate" virtual = "true">
        <Attributes>
            <Attribute name="type" value="spell" />
            <Attribute name="spell" value="1" type="number" />
        </Attributes>

        <Frames>
            <Cooldown inherits="CooldownFrameTemplate" parentKey="Cooldown" />
        </Frames>

        <Scripts>
            <OnAttributeChanged>
                DEFAULT_CHAT_FRAME:AddMessage(self:GetAttribute("spell"))
            </OnAttributeChanged>
        </Scripts>        
    </Button>
And this is my simple icon only button template, that I would hope with the Secure template would allow setting of spell and icon etc.
Code:
    <Button name = "XMP_IconTemplate" parentArray = "Buttons" virtual = "true">
        <Size x="40" y="40"/>

        <Layers>
            <Layer level="BACKGROUND">
                <Texture parentKey="Icon" setAllPoints = "true"/>
            </Layer>
        </Layers>

        <NormalTexture parentKey="NormalTexture" file="Interface\Buttons\UI-EmptySlot" setAllPoints = "true"/>
        <PushedTexture parentKey ="PushedTexture" file="Interface\Buttons\CheckButtonHilight" alphaMode = "ADD" setAllPoints = "true"/>
        <HighlightTexture parentKey = "HighlightTexture" file="Interface\Buttons\CheckButtonHilight"  alphaMode = "ADD" setAllPoints = "true"/>  
    </Button>
I then cycle through a list of spells to create icons for ( from my spell ID list ). Setting of the Button will be different depending on the planned placement of the buttons. I noticed 4 different layouts in my situation but again, it's not important. v is the data portion of my spell table and i is the spellID index of the table. portalIdx is set to where this list's portalButton array indexes will start, similarly for teleportIdx. The spell table has the correct information as expected on both live and bfa but on both the spell isn't set ( whether I use spellID or spellName ) nor working.
Code:
local Button = v.isPortal and XMP_Main.ButtonFrame.Buttons[portalIdx + v.idx] or XMP_Main.ButtonFrame.Buttons[teleportIdx + v.idx]

                Button:SetAttribute("type","spell")
                Button:SetAttribute("spell",i)
                Button.Icon:SetTexture(v.icon)
                Button:SetName(v.name)
My initial addon that I am upgrading was written in pure lua so this worked fine. I noticed that the original code also has the button derive from ActionButtonTemplate, but trying that instead of my own didn't make a difference. Here's my old lua button creation code that works fine.

Lua Code:
  1. local Button = CreateFrame("Button",buttonName,UIParent,"ActionButtonTemplate,SecureActionButtonTemplate")
  2.     Button:SetWidth(36)
  3.     Button:SetHeight(36)
  4.    
  5.     Button.spellID = spellID
  6.     Button.spellType = spellType
  7.  
  8.     Button:SetAttribute("type","spell")
  9.     Button:SetAttribute("spell",spellName)
  10.  
  11.        -- Cooldown creation here  ( not relevant to this problem )
  12.        
  13.        -- Events Registered for the button here --
  14.  
  15.        -- OnEvent script set here to execute certain functionality, but no attribute setting so immaterial

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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 05-19-18 at 02:18 PM. Reason: Rewording title
  Reply With Quote