Thread Tools Display Modes
10-05-05, 03:39 AM   #1
Gorak
A Fallenroot Satyr
Join Date: Oct 2005
Posts: 21
Accessing XML element properties

Hello !

As we all know, the layout of an Add-on is defined by the XML document and the tags placed therein. Now, these tags can have properties of their own, and moreover, child-tags that further specify them.

For example, consider this simplistic frame example:

<Frame name="DummyFrame" parent="UIParent" hidden="true" enableMouse="false">
<Size>
<Offset x="30" y="30"/>
</Size>
</Frame>

This fully-featured code would create an invisible frame of size 30x30. Now, the actual problem I am facing is that nowhere in the documentation or examples is a sample of how you can access these elements in a late-binding mode. For instance, consider that you would like to change the "parent" field of the DummyFrame frame. How would you proceed to accomplish that from the LUA code, in general level ?

This entire question arises from a need to discover the path/file name of TargetFrame's potrait texture. There are no GetTexture() or GetFile() methods to obtain this path by querying either the parent-level frame (TargetFrame) or the actual texture object (TargetPotrait). How would I proceed in obtaining the path or file name of the potrait used by the current target ?

- Gorak
  Reply With Quote
10-05-05, 07:11 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
http://www.wowwiki.com/Widget_API

The widget API page lists what you can do to xml elements from within the mod.

For instance, consider that you would like to change the "parent" field of the DummyFrame frame. How would you proceed to accomplish that from the LUA code, in general level ?
from the wiki: Frame:SetParent(parent or "parentName") - Set the parent for this frame - New in 1700.

How would I proceed in obtaining the path or file name of the potrait used by the current target ?
The portrait is constructed deeper in the UI than we have access to. It does a really thorough job of it so definitely something better left to the game's C code. While it may exists as a path/file someplace, as far as our end of the UI is concerned it doesn't. We can however use it with SetPortraitTexture(texture,"unit"). ie, SetPortraitTexture(MyModsTargetTexture,"target")

Can you "save" the portrait for future use? Probably not. There is no "filename" for a portrait texture and there is no :GetTexture for a generic texture. Total guessing here: It's possible this is drawn in many layers without a final "filename" so a :GetTexture if it existed wouldn't help. Probably icons are the same way. When a texture is applied and some other texture adds with alphaMode="ADD", it doesn't keep two copies of textures so there's nothing meaningful :GetTexture could return. The highlights could be adding and subtracting themselves to whatever is there. Again it's all my speculation so don't take it as gospel or anything.

On portraits, one of my mods is a target history mod that moves targets down like a stack. To keep the portraits around for a long time, instead of redrawing the portrait into the next box, it moves the frame itself.

btw not every aspect of xml can be accessed later (like :GetTexture). Stuff like setting fonts and getting the color of a fontstring are pretty recent. But if you run across something you need that's missing, sometimes a post on the official wow ui forums will get the ball rolling. Perhaps :GetTexture is doable. 1.7 had an enormous amount of stuff added to change xml bits.
  Reply With Quote
10-05-05, 03:57 PM   #3
Gorak
A Fallenroot Satyr
Join Date: Oct 2005
Posts: 21
Thanks for the detailed explanation.

The original attempt was to gain a more unique information of the player's target, as for unique identification. Currently I use name, gender and level. But as we know, that doesn't work in all cases. Even the portrait becomes an issue sometimes.

A bigger problem with the official UI & Macros forums is that I'm playing and have my account on European WoW servers, so I have no possible way of posting at the US forums, which is a real shame. I could've distributed my knowledge of issues or bugs there, and like it seems, slouken reads the forums quite keenly, and these bugs would've been fixed..

Well, back on topic.. Thanks for all the info again, guess that's pretty much it..

- Gorak
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Accessing XML element properties


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