WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   object with no name (https://www.wowinterface.com/forums/showthread.php?t=27329)

Gethe 09-15-09 03:24 PM

object with no name
 
Is there any way to reference/modify an object if it was not given a name?

Yhor 09-15-09 04:27 PM

Quote:

Originally Posted by Gethe (Post 158973)
Is there any way to reference/modify an object if it was not given a name?


Everything (should) has a name, you just have to figure out what it is. What is the object, what created it, and what do you want to do with it? Those answers should get you some help :).

Edit: This thread may also be of help too..

http://www.wowinterface.com/forums/s...ad.php?t=27325

Akryn 09-15-09 04:51 PM

Quote:

Originally Posted by Gethe (Post 158973)
Is there any way to reference/modify an object if it was not given a name?

Of course, you just have to get a reference to it. :p

There are situations where that is not possible. Assuming it is possible, how you go about doing it depends on what you're trying to access. Knowing that would make it easier to help.

Gethe 09-15-09 05:10 PM

im trying to make a color picker addon and i want to move the ColorValueTexture object somewhere else, but blizz didn't give it a name.

Waverian 09-15-09 07:59 PM

Quote:

Originally Posted by Yhor (Post 158984)
Everything (should) has a name, you just have to figure out what it is. What is the object, what created it, and what do you want to do with it? Those answers should get you some help :).

Edit: This thread may also be of help too..

http://www.wowinterface.com/forums/s...ad.php?t=27325

This isn't true. If I have this in an addon:

Code:

local f = CreateFrame'Frame'
Nothing can modify it in any way, at all (without editing the code itself).


Quote:

Originally Posted by Gethe (Post 158991)
im trying to make a color picker addon and i want to move the ColorValueTexture object somewhere else, but blizz didn't give it a name.

The square showing the currently selected color value? It's called ColorSwatch. The UI developers are quite thorough. Almost everything in the default UI can be accessed by outside addons in one way or another, you just need to find out how. You should download the addon development kit to look through the UI code.

Gethe 09-15-09 10:25 PM

Quote:

Originally Posted by Waverian (Post 159005)
The square showing the currently selected color value? It's called ColorSwatch. The UI developers are quite thorough. Almost everything in the default UI can be accessed by outside addons in one way or another, you just need to find out how. You should download the addon development kit to look through the UI code.

i have looked through the code and what i am talking about is the slider with the gradient from the picked color to black, right of the color wheel, the tag used for it is ColorValueTexture. This object has no name.

Layrajha 09-17-09 07:45 PM

Quote:

Originally Posted by Waverian (Post 159005)
This isn't true. If I have this in an addon:

Code:

local f = CreateFrame'Frame'
Nothing can modify it in any way, at all (without editing the code itself).

This is what I used to think, but I had a discussion with Haste like two years ago in which, if I remember well, he explained that he used something that iterated among un-named frames in order to play with the unit plates (I can't remember the exact name, but you know, these bars that show up above your enemy's head, if you've enabled them in the default UI). I cannot remember exactly how it was done and it was a long time ago so I may have just mixed things up, but I think it's possible anyway.

Seerah 09-17-09 09:25 PM

Quote:

Originally Posted by Akryn (Post 158987)
Of course, you just have to get a reference to it. :p

There are situations where that is not possible. Assuming it is possible, how you go about doing it depends on what you're trying to access. Knowing that would make it easier to help.

QFE

For example, this is how I modify the game clock in PocketPlot:
Code:

        clockFrame, clockTime = TimeManagerClockButton:GetRegions()
        clockFrame:Hide()
        clockTime:SetFont(LSM:Fetch("font", db.lsmfont), db.clockSize, db.fontFlag)


Layrajha 09-18-09 05:48 AM

Quote:

Originally Posted by Layrajha (Post 159263)
This is what I used to think, but I had a discussion with Haste like two years ago in which, if I remember well, he explained that he used something that iterated among un-named frames in order to play with the unit plates (I can't remember the exact name, but you know, these bars that show up above your enemy's head, if you've enabled them in the default UI). I cannot remember exactly how it was done and it was a long time ago so I may have just mixed things up, but I think it's possible anyway.

After thinking about it again and reading Seerah's example, I think it was just something like looping through the children of UIParent or WorldFrame, or something like this. As you create a frame with no parent by calling CreateFrame'Frame', this method wouldn't work.

The only way I can think of to gain access to this frame (without editing your code) would be to hook CreateFrame or one of the methods that you use on the frame, using an addon loaded before yours. I'm not sure how the hook would recognize your frame among the other frames created though. Using debugstack() would probably work?

Tristanian 09-18-09 06:37 AM

Quote:

Originally Posted by Layrajha (Post 159314)
After thinking about it again and reading Seerah's example, I think it was just something like looping through the children of UIParent or WorldFrame, or something like this.

Correct. Something along the lines of (for nameplates at least):

(Drycoded)

local nameplates = { WorldFrame:GetChildren() }
local num = #nameplates

if num > 0 then
for i = 1, num do
nameplates[i]:<Method>(...) -- do something
end
end


Quote:

As you create a frame with no parent by calling CreateFrame'Frame', this method wouldn't work.
Also correct, as I've mentioned in a similar thread.

Quote:

The only way I can think of to gain access to this frame (without editing your code) would be to hook CreateFrame or one of the methods that you use on the frame, using an addon loaded before yours. I'm not sure how the hook would recognize your frame among the other frames created though. Using debugstack() would probably work?
Not sure if that would accomplish much, since it has too many issues plus I'm not even sure if the hook would execute for frames created via xml.

All in all, if you absolutely need to reference/modify an unnamed frame created by another addon, either bug the author to "expose" it or find a way around it. More often than not, unnamed frames exist in such a state for good reason.

Waverian 09-18-09 06:41 AM

Quote:

Originally Posted by Layrajha (Post 159263)
This is what I used to think, but I had a discussion with Haste like two years ago in which, if I remember well, he explained that he used something that iterated among un-named frames in order to play with the unit plates (I can't remember the exact name, but you know, these bars that show up above your enemy's head, if you've enabled them in the default UI). I cannot remember exactly how it was done and it was a long time ago so I may have just mixed things up, but I think it's possible anyway.

I'm aware of the concept, but it's hardly reliable for the vast majority of frames. Nameplates are a rare exception because of some of their attributes.

Nameplates are unnamed children of the worldframe whose GetTexture() call returns Interface\TargetingFrame\UI-TargetingFrame-Flash

My frame has no defining attributes at all, and isn't a child of anything. While this isn't necessarily the case for the frame in question, finding these defining attributes (if they exist) wouldn't be trivial.

Slakah 09-18-09 07:40 AM

Quote:

My frame has no defining attributes at all, and isn't a child of anything
If you know when it's created you can find it.

also you can still find frames with no parents via EnumerateFrames().

What I use in StatusQuo:
lua Code:
  1. local lastframe -- the last frame we met.
  2. local otype
  3. local function TextureStatusBars(f)
  4.     local f = EnumerateFrames(f)
  5.     while f do
  6.         otype = f:GetObjectType()
  7.         if otype ~= "Button" then
  8.             if otype == "StatusBar" then
  9.                 SetTexture(f)
  10.                 f.SetStatusBarTexture = dummy
  11.             end
  12.             lastframe = f
  13.         end
  14.         f = EnumerateFrames(f)
  15.     end
  16. end
  17.  
  18. local function TextureNewStatusBars()
  19.     TextureStatusBars(lastframe)
  20. end

Layrajha 09-20-09 04:35 AM

Quote:

Originally Posted by Slakah (Post 159333)
EnumerateFrames()

Ah, I wasn't sure anymore but I wondered if something along this line didn't exist :) Thank you for refreshing my memory.


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

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