WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   useful Macro for checking UI-Items (https://www.wowinterface.com/forums/showthread.php?t=30214)

nehegeb 01-23-10 07:29 PM

useful Macro for checking UI-Items
 
Hi there!

Here is a useful Macro, for getting the name of a UI frame:

/script DEFAULT_CHAT_FRAME:AddMessage( GetMouseFocus():GetName() );

Just create that Macro and put it into the actionbar. Point your mousecursor over a particular frame an press the actionbars number for that Macro. The frames name will be post into the chatframe.

But now I have got a question:

I need a Macro for getting the texturepath from the texture my mouse is over. The following Macro doesn't work but I don't know why:
/script DEFAULT_CHAT_FRAME:AddMessage( GetMouseFocus():GetTexture() );
All I found out so far is that 'GetTexture()' seems to not work with 'GetMouseFocus()'. But why?
The following works:
/script DEFAULT_CHAT_FRAME:AddMessage( ActionButton1Icon:GetTexture() );
This Macro gets the texturepath of the icon in actionbar1.

I hope that Macro helps you and someone can help me! ;)
greetings, nehegeb

Seerah 01-23-10 08:35 PM

GetTexture() only works for texture objects. Frame objects do not use SetTexture(). They have a background image and use SetBackdrop() instead. So, if your GetTexture() doesn't work, use GetBackdrop().

Phanx 01-23-10 08:55 PM

Your first macro actually fails because GetMouseFocus() does not return ActionButton1Icon. It returns ActionButton1.

GetMouseFocus() only returns the top-most mouse-enabled frame. It doesn't return non-frame UI objects (like textures or font strings). It doesn't return frames that aren't mouse-enabled. And it only returns the mouse-enabled frame with the highest frame level/strata.

Since ActionButton1Icon is a texture, not a frame, you won't get a pointer to it from GetMouseFocus().

However, Seerah's solution won't work for your particular case, because ActionButton1Icon is a child of what GetMouseFocus() does return (ActionButton1), not its backdrop. There isn't really a generic solution that will work to get all visible textures. If you're only interested in action button icon textures, the following would work:

/print _G[GetMouseFocus():GetName() .. "Icon"]:GetTexture()

Breaking that down:
  1. GetMouseFocus() returns the frame object.
  2. :GetName() returns the name of the object it's called on; in this case, the frame object.
  3. The string concatenation operator (..) appends "Icon" onto the end of the name.
  4. The table lookup in _G returns the object whose name in the global namespace matches the provided table key; in this case, a string consisting of the button's name with "Icon" on the end, which points to the texture object that serve's the button's icon.
  5. :GetTexture() returns the texture of the object it's called on.

Note that using this macro on objects that don't have a name will cause an error. Using it on objects that do have a name, but don't have a corresponding "nameIcon" object, will also cause an error.

nehegeb 01-24-10 03:50 AM

Thanks for your rapid answers!

@Seerah:
Sadly your tip with 'GetBackdrop()' doesnt work. That would have been great!

@Phanx:
Thanks for your infos. They will help me further!

But I think, I didn't explain correctly what I need...
...in general I need a Macro that tells me, what texturepath a visible texture on the UI has got, so that I can use exactly this texture for my addons. At first it would really help me, if I could get just the path of the texture on the hightest level/strata. So maybe the thing with 'GetMouseFocus()' could work.

I don't only need just the Icons. That was just an example for what worked (in my first post). In many cases it's really just the backdrop of a frame.

Maybe what I want isn't possible for a single Macro, so an Addon also would do it, if it exists. Otherwise I have to break my workings on my almost finished Addon and build another one that gets me my needed textures. :D The perfect solution would be a Tooltip next to the mousecursor, that shows me all the UI textures and their paths from what my mouse is pointing at (from all strata).

btw. my first macro is helpful, if you want to know how a particular frame is called for maybe anchoring another frame to this one. ;)

cag_dk 01-24-10 04:08 AM

FluidFrames ???
 
Doesn't FluidFrames do what ya want? :confused:

nehegeb 01-24-10 04:50 AM

No, not really. This addon moves frames in the UI but I need the textures (texturepaths) that are used for those frames to use them in my own addons.

Phanx 01-24-10 04:55 AM

Quote:

Originally Posted by nehegeb (Post 175884)
...in general I need a Macro that tells me, what texturepath a visible texture on the UI has got, so that I can use exactly this texture for my addons.

Well, if you're trying to figure out which textures are used by default UI stuff, you could just look at Blizzard's code.

http://wowcompares.com/

Otherwise, you're going to run into tons of issues trying to use macros to find textures. Some textures are Backdrops, while others are StatusBarTextures, and others are Texture regions that are either unnamed or don't follow any consistent naming pattern. There's pretty much no way to write a macro that will catch all of those cases and correctly identify which of a frame's child Texture regions you want.

nehegeb 01-24-10 05:40 AM

Thank you, Phanx! Your link is quite useful.
Checking those files will take a while, but it's a start! ;)

Edith asks:
Is there a site or program or whatever for seeing all the WoW textures with their paths? Or where do other addon-coder get their textures from (if they are not self-made)?

Aesh 01-24-10 10:56 AM

if you need to see textures
try this :
http://us.blizzard.com/support/artic...rticleId=21466

for converting BLP's to PNG i am using this litle program,maybe bit old but working very good for me.

http://www.wowinterface.com/download...7-BLP2PNG.html

Seerah 01-24-10 11:51 AM

Yep, extracting the UI art is a good idea. That will also allow you to extract the UI code (which is what Phanx linked you to, but that site shows you diffs between versions of the game).

There is also this to allow you to browse them online: http://wowprogramming.com/utils/artbrowser

(note, on the site I linked above, the path would start with Interface\... followed by the folders/files listed on that page)

ArrchDK 01-24-10 12:04 PM

Code:

/run
local function child(f)
    if f:GetObjectType() == "Texture" then
        print(f:GetTexture())
    else
        local c = { f:GetChildren() }
        for i = 1, getn(c) do
            child(c[i])
        end
    end
end
child(GetMouseFocus())

Untested, but it's a rough idea on how to do it. Basically just use recursion to walk the tree and find an object that is a texture. Remove the white space before testing, of course.

nehegeb 02-01-10 12:34 PM

Thank you very much for all of your help!

Your links and tips really helped me. Now my addon looks quite cool :D

Greetings nehegeb

nightcracker 02-01-10 12:56 PM

/framestack


All times are GMT -6. The time now is 05:45 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI