Go to Page... |
Thread Tools | Display Modes |
10-29-22, 09:41 AM | #1 |
Making interactive Personal Resource Display
Hiya complete beginner with addons as well as posting on forums so bear with me on this one!
I'd made a weakaura to display more information about my character than plater allows and match the nameplates I have installed visually and messed around trying to add Togglemenu functionality to it so I could do away with unit frames entirely and conserve UI space. I realize it's bad practice to add secure actions to a weakaura so I wrote a lil' addon for that process instead Code:
local function MoveStuff() local healthButton = CreateFrame("BUTTON","healthButton", YOUR_FRAME, "SecureActionButtonTemplate"); healthButton:SetPoint("CENTER", C_NamePlate.GetNamePlateForUnit("player"), "CENTER", 0, 0) healthButton:SetSize(130, 40) healthButton:RegisterForClicks('AnyUp') healthButton:SetAttribute('unit', 'player') healthButton:SetAttribute('*type1', 'target') healthButton:SetAttribute('*type2', 'togglemenu') end local f = CreateFrame('Frame') f:RegisterEvent('UPDATE_MOUSEOVER_UNIT') f:SetScript('OnEvent', MoveStuff) But if my character dies or seemingly at random points, the frame at the center reappears which I assume is down to the addon persisting to make these frames and the location of the nameplate not being available at all times, is there something I can do to fix this? A better event to check? I'm lost. |
|
10-29-22, 04:51 PM | #2 | ||
Making this idea work isn't completely impossible, though we'll need to take advantage of a quirk with how NamePlates are set up. Lua Code:
First, we hook NamePlateDriverFrame:AcquireUnitFrame() to attach our "clickframe" to. What the original function does is grab a CompactUnitFrame from a frame pool and attach it to the NamePlate. Note while the code names it NamePlateDriverMixin, this table is already loaded into NamePlateDriverFrame by the time our code runs. Hooking the function from NamePlateDriverMixin will essentially do nothing useful. What we do is access that CompactUnitFrame and attach our SecureUnitButton to it. This lets us access a feature of the secure templates to refer to their parent for one or more attributes. SecureUnitButton was swapped in for its special handling of spell target cursors. Notably, it cancels spell targeting if the action is to bring up a menu. Coincidentally, CompactUnitFrames are set with their own unit attribute, so we point to that by setting our "useparent-unit" to true. Note "useparent-" is the keyword and the "unit" suffix tells it which attribute to act on. Similarly, you can define "useparent*" to defer all undefined attributes to the parent. A side effect to this approach is we can't control which NamePlates get our "clickframes". They all will. I also created a fallback for NamePlates that are created while in combat. Since we can't manipulate them during lockdown, we delay it until we're no longer in combat. Last to note is use of the new EventRegistry, extending CallbackRegistry.
__________________
WoWInterface AddOns
Last edited by SDPhantom : 10-29-22 at 04:55 PM. |
|||
10-30-22, 06:27 AM | #3 |
Can't seem to get your suggestion to work for me, only got it working once while keeping two units in my line of sight, entering combat with one and not the other but I haven't been able to recreate it and it ends up putting default blizzard nameplates visibly behind my plater nameplates, thanks anyway though, will incorporate a combatlockdown check.
Edit: Bashed my head at it some more and came up with something resembling what I'm going for, the only issue remaining is new entities running off with a click frame that belongs to me, but it doesn't get rid of my own which is good. I realize it lacks elegance, decorum and grace but yeah Lua Code:
The reason I set the unit attribute specifically to "Player" is because I am also tracking my target, pet and targettarget on the PRD but writing those in separate addons with nigh identical code save for X and Y values and the Unit attribute on healthButton. Last edited by Pubert : 10-30-22 at 12:01 PM. Reason: Follow-up |
|
11-09-22, 06:32 AM | #4 |
Double post, ceased to work. Was janky anyway
|
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Making interactive Personal Resource Display |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|