Thread Tools Display Modes
12-31-20, 10:25 AM   #1
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
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?
  Reply With Quote
12-31-20, 02:54 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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(...)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-31-20, 03:24 PM   #3
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
All of the Set...Texture methods have an equivalent Set...Atlas method so SetNormalAtlas should work as a direct substitution.
  Reply With Quote
01-02-21, 02:50 PM   #4
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Originally Posted by Vrul View Post
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")

Last edited by bsmorgan : 01-02-21 at 02:56 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with an Icon and SetAtlas

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