WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   PTR API and Graphics Changes (https://www.wowinterface.com/forums/forumdisplay.php?f=175)
-   -   8.1.5 ItemButtonTemplate Changes (https://www.wowinterface.com/forums/showthread.php?t=57008)

thomasjohnshannon 02-02-19 11:33 AM

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");

Zam89 03-12-19 03:02 PM

Hi, thanks for the Info.
Do you know, how we can set the IconBorder or texture with this new way?

Fizzlemizz 03-12-19 07:43 PM

They should still be the same:

xxx.IconBorder:SetTexture(...)
xxx:SetNormalTexture(...)

Koviko 03-12-19 08:53 PM

Were similar changes made to ContainerFrameItemButtonTemplate?

Fizzlemizz 03-12-19 09:02 PM

It went from inheriting ItemButtonTemplate (because that's now its base widget) to using ContainerFrameItemButtonMixin.

Koviko 03-12-19 09:20 PM

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?

Fizzlemizz 03-12-19 09:26 PM

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.

Koviko 03-12-19 11:20 PM

Thank you very much for the help. With this, I was able to get ArkInventory working again!

Zam89 03-13-19 09:50 AM

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 :)

Fizzlemizz 03-13-19 11:50 AM

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.

Zam89 03-13-19 12:34 PM

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?

Fizzlemizz 03-13-19 12:39 PM

Code:

local f = CreateFrame("ItemButton", "gwPaperDollBagSlotButton" .. i, GwPaperDollBagItemList, "GwPaperDollBagItem")
Code:

CreateFrame("Button ..)
CreateFrame("ItemButton ..)

is lua code for
Code:

<Button ..>
<ItemButton ..>


Zam89 03-13-19 12:41 PM

That was it :) Thank you very much :)


Some other short Question:
Do you have any idea how we can get the warfront ressources?

Fizzlemizz 03-13-19 12:49 PM

I don't play the game enough to know if there is a difference between war (mission table) resources and warfront resources.

Zam89 03-13-19 01:13 PM

I think not, and I do not find any api to get the infos. And also tried to get it via the scenario widget.

Fizzlemizz 03-13-19 02:14 PM

I thought you were asking how to pick them up in-game :o

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 ;).

Zam89 03-13-19 02:50 PM

Thanks, but with this api you do not get the Metal and Wood Ressourcen from the Warfront secenarios

Fizzlemizz 03-13-19 05:06 PM

I don't know if or how that information might be obtained. Possibly someone else might know.

Fizzlemizz 03-13-19 07:20 PM

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)

Zam89 03-15-19 12:39 AM

Thanks, that is it exactly :)


All times are GMT -6. The time now is 04:26 PM.

vBulletin © 2019, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI