Thread Tools Display Modes
02-02-19, 11:33 AM   #1
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 68
8.1.5 ItemButtonTemplate Changes

In 8.1.5 they changed how the item button template works. Instead of being a virtual button that is inherited it is now a new widget type that can be created directly.

Old Way

local button = CreateFrame("Button", "ButtonNameHere"..id, ParentFrame, "ItemButtonTemplate");

New Way

local button = CreateFrame("ItemButton", "ButtonNameHere"..id, ParentFrame, "OptionalTemplateHere");
__________________
Thomas aka Urnn
  Reply With Quote
03-12-19, 03:02 PM   #2
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
Hi, thanks for the Info.
Do you know, how we can set the IconBorder or texture with this new way?
  Reply With Quote
03-12-19, 07:43 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
They should still be the same:

xxx.IconBorder:SetTexture(...)
xxx:SetNormalTexture(...)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-12-19, 08:53 PM   #4
Koviko
A Deviate Faerie Dragon
Join Date: Feb 2010
Posts: 15
Were similar changes made to ContainerFrameItemButtonTemplate?
  Reply With Quote
03-12-19, 09:02 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
It went from inheriting ItemButtonTemplate (because that's now its base widget) to using ContainerFrameItemButtonMixin.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-12-19 at 09:11 PM.
  Reply With Quote
03-12-19, 09:20 PM   #6
Koviko
A Deviate Faerie Dragon
Join Date: Feb 2010
Posts: 15
Pardon me as I'm not very well-versed in making addons, especially the XML templates.


So, in an XML template, instead of:
Code:
<Button inherits="ItemButtonTemplate" />
We'd have:
Code:
<ItemButton />

And, instead of:
Code:
<Button inherits="ContainerFrameItemButtonTemplate" />
We'd have:
Code:
<ItemButton inherits="ContainerFrameItemButtonMixin" />

Is this accurate?

Last edited by Koviko : 03-12-19 at 09:23 PM.
  Reply With Quote
03-12-19, 09:26 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
That's sort of it. ItemButtonTemplate is now the base widget ItemButton. It appears to have all the same elements (textures fontstrings etc.) using the same names and parent keys as the original template.

Instead of
Code:
<Button name="ContainerFrameItemButtonTemplate" inherits="ItemButtonTemplate" virtual="true"/>
you have
Code:
<ItemButton name="ContainerFrameItemButtonTemplate" mixin="ContainerFrameItemButtonMixin" virtual="true"/>
and to create the actual button you will
Code:
<ItemButton inherits="ContainerFrameItemButtonTemplate"/>
The lines with "virtual="true" means these are not real, created in-game widgets, they are just a set of instructions that can be used to make one or more real and identical widgets later on.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-12-19 at 10:14 PM.
  Reply With Quote
03-12-19, 11:20 PM   #8
Koviko
A Deviate Faerie Dragon
Join Date: Feb 2010
Posts: 15
Thank you very much for the help. With this, I was able to get ArkInventory working again!
  Reply With Quote
03-13-19, 09:50 AM   #9
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
Hmm I do not get it to work,

This is the way we creating the template:

Code:
<ItemButton name="GwPaperDollButtonTemplate" registerForDrag="LeftButton" registerForClicks="LeftButtonUp RightButtonUp" mixin="ContainerFrameItemButtonMixin" virtual="true">
        <Size x="49" y="49"></Size>
        <Layers>
            <Layer level="BACKGROUND">
                <Texture parentKey="BACKGROUND" file="Interface\AddOns\GW2_UI\textures\character\slot-bg">
                    <Size x="49" y="49"></Size>
                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="0" y="0"></Anchor>
                        <Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" x="0" y="0"></Anchor>
                    </Anchors>
                    <TexCoords left="0" right="0.25" top="0" bottom="0.25"/>
                </Texture>
            </Layer>
            <Layer level="OVERLAY">
                <Texture name="$parentRepair" hidden="true" parentKey="repairIcon" file="Interface\AddOns\GW2_UI\textures\repair">
                    <Size x="20" y="20"></Size>
                    <Anchors>
                        <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" x="0" y="0"></Anchor>

                    </Anchors>

                    <TexCoords left="0" right="1" top="0.5" bottom="1"/>
                </Texture>
            </Layer>

            <Frames>
                <CheckButton hidden="true" name="$parentCheckButton" checked="false">

                    <Size x="160" y="160"></Size>
                    <Anchors>
                        <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" x="10" y="0"></Anchor>
                    </Anchors>
                    <NormalTexture file="Interface\AddOns\GW2_UI\textures\checkbox"></NormalTexture>
                    <CheckedTexture file="Interface\AddOns\GW2_UI\textures\checkboxchecked"></CheckedTexture>
                </CheckButton>
            </Frames>

        </Layers>

    </ItemButton>

    <ItemButton name="GwPaperDollBagItem" registerForClicks="LeftButtonDown, RightButtonDown" inherits="GwPaperDollButtonTemplate" virtual="true"/>
And this to use it:

Code:
<ItemButton name="GwPaperDollBagItem" registerForClicks="LeftButtonDown, RightButtonDown" inherits="GwPaperDollButtonTemplate" virtual="true"/>
or

Code:
<ItemButton name="GwPaperDollHeadSlot" parentKey="head" inherits="GwPaperDollButtonTemplate,PaperDollAzeriteItemOverlayTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="0" y="0"></Anchor>
                        </Anchors>
                        <Layers>
                            <Layer level="OVERLAY" textureSubLevel="2">
                                <FontString parentKey="itemlevel" inherits="GameFontNormalSmall" justifyH="LEFT">
                                    <Size x="100" y="10"/>
                                    <Color r="1" g="1" b="1"></Color>
                                    <Anchors>
                                        <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="2" y="2"></Anchor>
                                    </Anchors>
                                </FontString>
                            </Layer>
                        </Layers>
                        <Frames>
                            <CheckButton hidden="true" name="$parentCheckButton" parentKey="ignoreSlotCheck" checked="false">
                                <Size x="16" y="16"></Size>
                                <Anchors>
                                    <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" x="0" y="0"></Anchor>
                                </Anchors>
                                <NormalTexture file="Interface\AddOns\GW2_UI\textures\checkbox"></NormalTexture>
                                <CheckedTexture file="Interface\AddOns\GW2_UI\textures\checkboxchecked"></CheckedTexture>
                            </CheckButton>
                        </Frames>
                    </ItemButton>
but we get this error all the time:

Code:
3x ...faceGW2_UI\character/paperdoll_equipment.lua:194: attempt to index field 'IconBorder' (a nil value)
...faceGW2_UI\character/paperdoll_equipment.lua:194: in function <...faceGW2_UI\character/paperdoll_equipment.lua:193>
...faceGW2_UI\character/paperdoll_equipment.lua:504: in function <...faceGW2_UI\character/paperdoll_equipment.lua:487>
...faceGW2_UI\character/paperdoll_equipment.lua:531: in function <...faceGW2_UI\character/paperdoll_equipment.lua:512>
...faceGW2_UI\character/paperdoll_equipment.lua:933: in function `LoadPDBagList'
GW2_UI\character/paperdoll.lua:100: in function `?'
GW2_UI\character/character.lua:423: in function `LoadCharacter'
GW2_UI\GW2_ui.lua:506: in function <GW2_UI\GW2_ui.lua:423>
GW2_UI\GW2_ui.lua:588: in function <GW2_UI\GW2_ui.lua:584>

Locals:
self = gwPaperDollBagSlotButton1 {
 0 = <userdata>
in this Code:

Code:
self.IconBorder:SetSize(self:GetSize(), self:GetSize())
Hope you can help me
  Reply With Quote
03-13-19, 11:50 AM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
It's complaining about gwPaperDollBagSlotButton1 not having a key called IconBorder. I can't see from the code supplied what you used to create gwPaperDollBagSlotButton1 (and presumably others).

My guess is you have something like:
Lua Code:
  1. <Button name="gwPaperDollBag" ....>
  2.         <Button name="$parentSlotButton1" inherits="GwPaperDollBagItem" ...>
  3.                 ....
  4.         </Button>
  5.         <Button name="$parentSlotButton2" inherits="GwPaperDollBagItem" ...>
  6.                 ....
  7.         </Button>
  8.         <Button name="$parentSlotButton3" inherits="GwPaperDollBagItem" ...>
  9.                 ....
  10.         </Button>
  11.     ...
  12. </Button>
Where it should be:
Lua Code:
  1. <Button name="gwPaperDollBag" ....>
  2.         <ItemButton name="$parentSlotButton1" inherits="GwPaperDollBagItem" ...>
  3.                 ....
  4.         </ItemButton>
  5.         <ItemButton name="$parentSlotButton2" inherits="GwPaperDollBagItem" ...>
  6.                 ....
  7.         </ItemButton>
  8.         <ItemButton name="$parentSlotButton3" inherits="GwPaperDollBagItem" ...>
  9.                 ....
  10.         </ItemButton>
  11.     ...
  12. </Button>

The base widget specified for creating the actual widget overwrites the base widget specified in the template it inherits.

Lua Code:
  1. <Frame name="SomeTemplate" virtual="true">
  2.     ...
  3. </Frame>
  4.  
  5. <Button name="B1" inherits="SomeTemplate"> --creates a plain Button
  6. <ItemButton name="B1" inherits="SomeTemplate"> --creates an ItemButton
Even though SomeTemplate is based on a Frame.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-13-19, 12:34 PM   #11
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
Thanks.

Here is the Code to create this:

Code:
if _G["gwPaperDollBagSlotButton" .. i] ~= nil then
        return _G["gwPaperDollBagSlotButton" .. i]
    end

    local f = CreateFrame("Button", "gwPaperDollBagSlotButton" .. i, GwPaperDollBagItemList, "GwPaperDollBagItem")
Code:
 <ItemButton name="GwPaperDollBagItem" registerForClicks="LeftButtonDown, RightButtonDown" inherits="GwPaperDollButtonTemplate" virtual="true"/>
any idea?
  Reply With Quote
03-13-19, 12:39 PM   #12
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Code:
local f = CreateFrame("ItemButton", "gwPaperDollBagSlotButton" .. i, GwPaperDollBagItemList, "GwPaperDollBagItem")
Code:
CreateFrame("Button ..)
CreateFrame("ItemButton ..)
is lua code for
Code:
<Button ..>
<ItemButton ..>
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-13-19 at 12:42 PM.
  Reply With Quote
03-13-19, 12:41 PM   #13
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
That was it Thank you very much


Some other short Question:
Do you have any idea how we can get the warfront ressources?
  Reply With Quote
03-13-19, 12:49 PM   #14
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I don't play the game enough to know if there is a difference between war (mission table) resources and warfront resources.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-13-19, 01:13 PM   #15
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
I think not, and I do not find any api to get the infos. And also tried to get it via the scenario widget.
  Reply With Quote
03-13-19, 02:14 PM   #16
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I thought you were asking how to pick them up in-game

Lua Code:
  1. local name, qty, icon = GetCurrencyInfo(1560)
  2. print("You have", qty, name)
Resources Ids: 824=WoD Garrison, 1220=Legion Order Hall, 1560=BfA War, 1416=Coins of Air, You'll have to find the rest youself .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-13-19, 02:50 PM   #17
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
Thanks, but with this api you do not get the Metal and Wood Ressourcen from the Warfront secenarios

Last edited by Zam89 : 03-13-19 at 02:53 PM.
  Reply With Quote
03-13-19, 05:06 PM   #18
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I don't know if or how that information might be obtained. Possibly someone else might know.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-13-19, 07:20 PM   #19
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Lua Code:
  1. local iname, iqty, iicon = GetCurrencyInfo(1541)  --iron
  2. local wname, wqty, wicon = GetCurrencyInfo(1540)  -- wood
  3. print("You have", iqty, iname, "and", wqty, wname)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-13-19 at 07:27 PM.
  Reply With Quote
03-15-19, 12:39 AM   #20
Zam89
A Deviate Faerie Dragon
Join Date: Mar 2019
Posts: 18
Thanks, that is it exactly
  Reply With Quote

WoWInterface » PTR » PTR API and Graphics Changes » 8.1.5 ItemButtonTemplate Changes

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off