Quantcast
Trying to anchor a frame to the personal resource display - WoWInterface
Thread Tools Display Modes
05-14-20, 10:36 PM   #1
Yakkers
A Murloc Raider
Join Date: May 2020
Posts: 4
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!
  Reply With Quote
05-14-20, 11:20 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 506
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.
  Reply With Quote
05-15-20, 04:36 PM   #3
Yakkers
A Murloc Raider
Join Date: May 2020
Posts: 4
Originally Posted by Kanegasi View Post
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.
  Reply With Quote
05-15-20, 10:39 PM   #4
Yakkers
A Murloc Raider
Join Date: May 2020
Posts: 4
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to anchor a frame to the personal resource display

Thread Tools
Display Modes

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