Thread Tools Display Modes
05-14-10, 06:02 AM   #1
iindigo
An Aku'mai Servant
 
iindigo's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 32
Using SetTexture on a texture with no name?

Is this possible? I'm trying to modify one of the default Blizzard frames, but after looking at the XML for said frames, the textures of the window are not named at all.

Thanks!
  Reply With Quote
05-14-10, 06:06 AM   #2
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
One way would be to retrieve the table with GetRegions()
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
05-14-10, 10:55 AM   #3
iindigo
An Aku'mai Servant
 
iindigo's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 32
Originally Posted by v6o View Post
One way would be to retrieve the table with GetRegions()
Where could one find examples of this? I've never worked with regions before. I did a quick google and wowwiki search, which turned up some things but it's confusing to someone who doesn't know how regions work...
  Reply With Quote
05-14-10, 11:02 AM   #4
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
GetRegions just returns all non-Frame objects (FontStrings and Textures) that are a child of the frame. Just iterate through the returned objects to find yours.

Code:
for _, obj in pairs{frame:GetRegions()} do 
     -- You have to use your own heuristic to find the frame. For example if you know that the
	 -- texture file is the default status bar texture, you could use this to find it:
	 if obj:GetObjectType() == 'Texture' and obj:GetTexture() == 'Interface\\TargetingFrame\\UI-StatusBar' then
		-- This is the frame we want, manipulate it here.
	 end
end
You should also be able to do this instead of using a throw-away table:

Code:
for i = 1, select('#', frame:GetRegions()) do
	local obj = select(i, frame:GetRegions())
	-- Same code as above
end
But if this is only something your doing once then I don't think it matters which way you choose.
  Reply With Quote
05-15-10, 07:28 PM   #5
iindigo
An Aku'mai Servant
 
iindigo's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 32
Thanks for the example! It's been a great help. However, it seems that this method doesn't work on PaperDollFrame, or I'm doing something wrong.

Code:
	for _, obj in pairs{PaperDollFrame:GetRegions()} do 
	 if obj:GetObjectType() == 'Texture' and obj:GetTexture() == 'Interface\\PaperDollInfoFrame\\UI-Character-CharacterTab-L1' then
		obj:SetTexture("Interface\AddOns\xXXXx\charPaneTopLeft.blp");
	 end
	end
Am I doing anything wrong here? The code is definitely being fired, I made sure of this myself. The pane simply shows no change after the code fires, though.
  Reply With Quote
05-15-10, 09:32 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Replace:

obj:SetTexture("Interface\AddOns\xXXXx\charPaneTopLeft.blp)

with:

obj:SetTexture("Interface\\AddOns\\xXXXx\\charPaneTopLeft")
  Reply With Quote
05-15-10, 10:29 PM   #7
iindigo
An Aku'mai Servant
 
iindigo's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 32
Ah! That indeed was it. I thought double slashes weren't necessary since I didn't have to use them when creating textures in XML.

Thanks a ton guys!
  Reply With Quote
05-16-10, 02:30 AM   #8
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by iindigo View Post
Ah! That indeed was it. I thought double slashes weren't necessary since I didn't have to use them when creating textures in XML.

Thanks a ton guys!
Backslash is an escape character for strings in lua, so that's why you need the additional one. You can also use a literal string for file paths, which ignores escape characters:

Code:
[[My\File\Path\Here.blp]]
But this is just me being a little pedantic again, since there isn't any difference between the two options for this particular situation. :>
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Using SetTexture on a texture with no name?


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