Thread: GUI's
View Single Post
05-26-05, 02:49 PM   #13
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
My apologies, you are right. I was thinking too narrowly of textures used in widgets like buttons, but textures can be used in layers as art and can accept texture coordinates within a file (thereby getting multiple images from a single file)
<Texture name="MainMenuBarTexture0" file="Interface\MainMenuBar\UI-MainMenuBar-Dwarf"><Size><AbsDimension x="256" y="53"/></Size><Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="-384" y="0"/></Offset></Anchor></Anchors><TexCoords left="0" right="1.0" top="0.79296875" bottom="1.0"/></Texture>
Just like in EQ, you have to know the tga dimensions, the actual image topleft point (x,y), the image width, and the image height. You then do simple math to fill in the coordinates.

example:
you have an image file that is 256x256, and you want to use an element in that image that is 256x50 located at point 0, 100.

left = 0/256 = 0.0
right = 256/256 = 1.0
top = 100/256 = 0.390625
bottom = 150/256 = 0.5859375

Your final code would be
<Texture name="MyTexture0" file="Interface\AddOns\MyAddOn\image.tga"><Size><AbsDimension x="256" y="50"/></Size><Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors><TexCoords left="0" right="1.0" top="0.390625" bottom="0.5859375"/></Texture>
Put that within a layer or something similar within a frame, and it should do what you are talking about.

I apologize if you already figured this out. Just trying to share...

As for the Swahili thing - yeah, Lua is a bit weird. The XML Conventions are easy enough to grasp, but lua is very "open" in terms of requirements. I have developed techniques that I use in coding that helps make it a little more "understandable" by wrapping all of my code within variables and accessing them like objects in an OO language. Like mymod.myfunction(); -- doing that seems to help me at least in understanding the structure of how I have things layed out. The next thing to make sure of (at least I do) is that all my coding is consistent in everything I do. That way when you look at one script, and look at another, you can easily pick it up because well, they are structured the same way. I use naming conventions for everything within my little object oriented tables...

Last edited by Beladona : 05-26-05 at 02:52 PM.
  Reply With Quote