WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Trying to anchor a frame to the personal resource display (https://www.wowinterface.com/forums/showthread.php?t=57995)

Yakkers 05-14-20 10:36 PM

Trying to anchor a frame to the personal resource display
 
I'm very new to addon development and I'm working on a simple addon for myself to use. Basically I'm just doing the kind of things I do with weakauras, but I want to do some more hardcoded animation stuff that weakauras doesn't really support so I figured it was time to finally start learning how to make standalone addons.

Anyways, most of my weakauras stuff is anchored to the personal resource display, but trying to do that in lua with a custom frame doesn't seem to be doing anything at all.

Here's my code setting up the texture:

Code:

local frame = CreateFrame("Frame", "HitComboPopups_Frame", NamePlatePlayerResourceFrame)
frame:SetPoint("CENTER", NamePlatePlayerResourceFrame, "CENTER", 0, -150)
frame:SetFrameStrata("HIGH")
frame:SetWidth(popupSize)
frame:SetHeight(popupSize)
frame:Hide()

local texture = frame:CreateTexture()
texture:SetWidth(frame:GetWidth())
texture:SetHeight(frame:GetHeight())
texture:SetAllPoints(frame)


I got "NamePlatePlayerResourceFrame" from another thread, it doesn't seem to be anywhere in the either wowprogramming or the wiki's documentation. print(NamePlatePlayerResourceFrame) just spits out nil, so I it just falls back on UIParent.

So, what's the proper way to attach a frame to the personal resource display so it moves with it and fades in and out with it? I tried to dig through weakauras' code to see how they did it, but I really couldn't make heads or tails of it. I'm not sure if this NamePlatePlayerResourceFrame identifier is even still current, the threads I saw it in were fairly old.

Thanks in advance!

Kanegasi 05-14-20 11:20 PM

You can use /fstack in-game and mouseover the frame to get its name. However, the personal resource frame is a custom nameplate and I believe is treated like a friendly nameplate, which can't be altered or anchored to in instances.

Yakkers 05-15-20 04:36 PM

Quote:

Originally Posted by Kanegasi (Post 335928)
You can use /fstack in-game and mouseover the frame to get its name. However, the personal resource frame is a custom nameplate and I believe is treated like a friendly nameplate, which can't be altered or anchored to in instances.

I believe the PRD has an exception to that, because in instances my PRD-anchored weakuaras still appear and also the bar uses kuinameplates' appearance unlike the ally nameplates.

Mousing over the PRD with /fstack gives me this:



I tried using both NamePlate1UnitFrame and NamePlate1 as a parent, but both of those still result in a nil parent for my frame. Printing NamePlate1UnitFrame or NamePlate1 gives me a hex string instead of nil though, so that's a start.

Is there something specific I need to do to fetch a frame from its name or something? It's hard to know exactly what I'm looking for when dealing with dynamically-typed languages.

Yakkers 05-15-20 10:39 PM

Sorry for double post, but I got it! For anyone else's future reference, here's a quick and dirty way to do it:

Code:

yourFrame:SetPoint("CENTER", C_NamePlate.GetNamePlateForUnit("player"), "CENTER", 0, 0)
Do be aware that the nameplate object for the personal resource display does change, as I believe the UI engine has pre-allocated nameplates that cycle around as they become used and unused. It looks like Weakauras checks events for nameplates loading and unloading and calls the SetPoint then, but in my case I'm able to just set the point every time the animation starts since it only occurs when you're in combat and have a target anyways.

I tested with an aoe hit while not targeting the mob (so the PRD isn't already visible) on a fresh reaload and it still works, so it should be golden in this case.


All times are GMT -6. The time now is 05:08 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI