Quantcast
How can i set Normal/Pushed/Highlight Texture names in Lua? - WoWInterface
Thread Tools Display Modes
09-14-15, 05:35 AM   #1
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 44
How can i set Normal/Pushed/Highlight Texture names in Lua?

I got a button with Textures:

Lua Code:
  1. -- friend = frame
  2. local name = friend:GetName().."FavoritesButton"
  3. local texture = "Interface\\Miscellaneous\\UI-Advanced-Friends-Frame-Favorites-Button"
  4. local button = CreateFrame("Button", name, friend)
  5. button:SetNormalTexture(texture.."-".."Normal")
  6. button:SetPushedTexture(texture.."-".."Pushed")
  7. button:SetHighlightTexture(texture.."-".."Highlight")
  8. button:SetHitRectInsets(4, 4, 2, 2);
  9. button:SetSize(32, 32)

This code makes a button with 3 textures - normal, pushed, and highlight. But when i /framestack and inspect this buttons, they are made without name, so texture names looks like this: FriendsFrameFriendsScrollFrameButton1FavoritesButton.0000000001d8293f80
FriendsFrameFriendsScrollFrameButton1FavoritesButton.0000000001d8293fd0
FriendsFrameFriendsScrollFrameButton1FavoritesButton.0000000001d8293fk0

But i would like to name this texture, to make them readable like this: FriendsFrameFriendsScrollFrameButton1FavoritesButtonNormalTexture
FriendsFrameFriendsScrollFrameButton1FavoritesButtonPushedTexture
FriendsFrameFriendsScrollFrameButton1FavoritesButtonHighlightTexture

I know that it's possible to make with XML:
Code:
<Frame name="FriendsFrameFriendsScrollFrameButton">
	<Button name="$parentFavoritesButton">
		<Size x="32" y="32"/>
		<Anchors>
			<Anchor point="TOPRIGHT">
				<Offset x="0" y="0"/>
			</Anchor>
		</Anchors>
		<NormalTexture name="$parentNormalTexture" file="Interface\FriendsFrame\TravelPass-Invite">
			<Size x="32" y="32"/>
			<TexCoords left="0.01562500" right="0.39062500" top="0.27343750" bottom="0.52343750"/>					
		</NormalTexture>
		<PushedTexture name="$parentPushedTexture" file="Interface\FriendsFrame\TravelPass-Invite">
			<Size x="32" y="32"/>
			<TexCoords left="0.42187500" right="0.79687500" top="0.27343750" bottom="0.52343750"/>
		</PushedTexture>
		<DisabledTexture name="$parentDisabledTexture" file="Interface\FriendsFrame\TravelPass-Invite">
			<Size x="32" y="32"/>
			<TexCoords left="0.01562500" right="0.39062500" top="0.00781250" bottom="0.25781250"/>
		</DisabledTexture>
		<HighlightTexture name="$parentHighlightTexture" file="Interface\FriendsFrame\TravelPass-Invite" alphaMode="ADD">
			<Size x="32" y="32"/>
			<TexCoords left="0.42187500" right="0.79687500" top="0.00781250" bottom="0.25781250"/>
		</HighlightTexture>
		<Scripts>
			-- ...
		</Scripts>
	</Button>
</Frame>
But i can't figure if it's possible to make in Lua. If it's possible, could you please point me, how can i make it. As always, I will very appreciate your help.
  Reply With Quote
09-14-15, 08:02 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
FriendsFrameFriendsScrollFrameButton1FavoritesButtonNormalTexture = button:GetNormalTexture()
  Reply With Quote
09-16-15, 04:01 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That will assign a global, but it won't help you with /framestack, since that global isn't actually the name of the object.

You can give those textures names by creating them manually; "SetNormalTexture" is really just a shortcut.

Code:
local tex = frame:CreateTexture("$parentNormalTexture", "ARTWORK")
tex:SetAllPoints(true)
tex:SetTexture(texture.."-Normal")
button:SetNormalTexture(tex)
Do the same for the pushed/disabled/highlight textures. The highlight texture should be on the "HIGHLIGHT" layer instead of "ARTWORK" but pushed/disabled should be on the same layer as normal. It probably don't need to be "ARTWORK" but it should probably be consistent.

Though I have to say, seeing a name like "FriendsFrameFriendsScrollFrameButton1FavoritesButtonNormalTexture" really makes me want to gouge my eyes out.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote
09-18-15, 01:55 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,961
Originally Posted by Phanx View Post
Though I have to say, seeing a name like "FriendsFrameFriendsScrollFrameButton1FavoritesButtonNormalTexture" really makes me want to gouge my eyes out.
Looks like a Blizzard name to me.

Though it follows naming convention, unless you actually want direct access to said object, I'd leave it unnamed.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-18-15 at 01:57 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How can i set Normal/Pushed/Highlight Texture names in Lua?

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