WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help with an Icon and SetAtlas (https://www.wowinterface.com/forums/showthread.php?t=58509)

bsmorgan 12-31-20 10:25 AM

Help with an Icon and SetAtlas
 
In Skillet, the details frame shows the reagents for a recipe using the following XML template

Code:

        <Frame name="SkilletItemTemplate" hidden="false" virtual="true">
                <Size>
                        <AbsDimension x="190" y="20"/>
                </Size>
                <Layers>
                        <Layer level="OVERLAY">
                                <FontString name="$parentText" inherits="GameFontNormalSmall" justifyH="LEFT" justifyV="MIDDLE">
                                        <Size>
                                                <AbsDimension x="150" y="16"/>
                                        </Size>
                                        <Anchors>
                                                <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
                                                        <Offset>
                                                                <AbsDimension x="54" y="0"/>
                                                        </Offset>
                                                </Anchor>
                                        </Anchors>
                                        <Color r="1" g="1" b="1" a="1"/>
                                </FontString>
                                <FontString name="$parentCount" inherits="GameFontNormalSmall" justifyH="RIGHT" justifyV="MIDDLE">
                                        <Size>
                                                <AbsDimension x="80" y="16"/>
                                        </Size>
                                        <Anchors>
                                                <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT">
                                                        <Offset>
                                                                <AbsDimension x="0" y="0"/>
                                                        </Offset>
                                                </Anchor>
                                        </Anchors>
                                        <Color r="1" g="1" b="1" a="1"/>
                                </FontString>
                                <FontString name="$parentNeeded" inherits="GameFontNormalSmall" justifyH="RIGHT" justifyV="MIDDLE">
                                        <Size>
                                                <AbsDimension x="34" y="16"/>
                                        </Size>
                                        <Anchors>
                                                <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
                                                        <Offset>
                                                                <AbsDimension x="18" y="0"/>
                                                        </Offset>
                                                </Anchor>
                                        </Anchors>
                                <Color r="1" g="1" b="1" a="1"/>
                                </FontString>
                        </Layer>
                </Layers>
                <Frames>
                        <!-- A button for the icon -->
                        <button name="$parentIcon">
                                <Size>
                                        <AbsDimension x="16" y="16"/>
                                </Size>
                                <Anchors>
                                        <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
                                                <Offset>
                                                        <AbsDimension x="0" y="-1"/>
                                                </Offset>
                                        </Anchor>
                                </Anchors>
                        </button>
                </Frames>
        </Frame>

In Skillet for required reagents, the $parentIcon is loaded with:

Code:

                        texture = GetItemIcon(reagent.reagentID)
                        icon:SetNormalTexture(texture)

For optional reagents, Blizzard uses the following:

Code:

                                Icon:SetAtlas(hasRequiredSkillRank and "tradeskills-icon-add" or "tradeskills-icon-locked", TextureKitConstants.UseAtlasSize);
I can't use GetItemIcon for an optional reagent at this point because there's no itemID but changing my code to icon:SetAtlas(...) errors saying SetAtlas is undefined.

What do I need to add to (or change in) my template so that I can use SetAtlas as in the Blizzard code?

Fizzlemizz 12-31-20 02:54 PM

In your code, Icon is a Button (SetNormalTexture). In Blizzards, it's a texture. With your button you could probably:
Code:

local IconTexture = Icon:GetNormalTexture()
IconTexture:SetAtlas(...)


Vrul 12-31-20 03:24 PM

All of the Set...Texture methods have an equivalent Set...Atlas method so SetNormalAtlas should work as a direct substitution.

bsmorgan 01-02-21 02:50 PM

Quote:

Originally Posted by Vrul (Post 338135)
All of the Set...Texture methods have an equivalent Set...Atlas method so SetNormalAtlas should work as a direct substitution.

I finally figured it out, thanks for the hints.

Replace:
Code:

        local texture = GetItemIcon(itemID)
        icon:SetNormalTexture(texture)

with:
Code:

        icon:SetNormalAtlas(categorySkillRank >= oreagent.requiredSkillRank and "tradeskills-icon-add" or "tradeskills-icon-locked")


All times are GMT -6. The time now is 12:50 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI