WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Disabling Player Unit Frame's Autofading (https://www.wowinterface.com/forums/showthread.php?t=53782)

whatisxml 06-26-16 08:34 PM

Disabling Player Unit Frame's Autofading
 
When leaving combat, the player unit frame quickly fades to about 0.5 alpha and then completely fades out a few seconds later. It's then unlinked from the player and can be used for other units' name plates.

I've been trying to figure out a way to prevent it from fading at all. At first I thought I could hijack the NAME_PLATE_UNIT_REMOVED event to avoid a call to OnNamePlateRemoved() in Blizzard_NamePlates.lua but that didn't have the effect I wanted.

I also tried messing with UIFadeIn() and UIFadeOut() but it seems to be fading using some other method. I also thought it was being added to the AddToAutoHide() list, so I set the UnitFrameXNamePlate.disableMouse=false but the Frame faded even while my cursor was hovering over it.

Any thoughts on how to keep the unit frame visible?
I'd prefer to use the built-in frame rather than remake my own.

Fizzlemizz 06-26-16 10:24 PM

If you are talking about the new Player Resource Bar (mini HUD) you would be better getting something like IceHud.

Ketho 06-27-16 05:44 AM

I've been trying to find out how the personal resource display works.

But I just can't find anything to do with the alpha, or on what events it starts fading out :confused:
Lua Code:
  1. -- normal
  2. C_NamePlate.GetNamePlateForUnit("player"):GetAlpha() => 0.74901960784314
  3. C_NamePlate.GetNamePlateForUnit("player").UnitFrame:GetAlpha() => 1
  4.  
  5. -- fading out
  6. C_NamePlate.GetNamePlateForUnit("player"):GetAlpha() => 0.37254901960784
  7. C_NamePlate.GetNamePlateForUnit("player").UnitFrame:GetAlpha() => 1

whatisxml 06-27-16 06:14 AM

Yes, same problem here. I'm able to change it to show all character buffs, move the buffs, I can change its position, and increase scale of the various bars/combo points. But the fading is a mystery.

Much of the fading seems triggered by PLAYER_REGEN_ENABLE and PLAYER_REGEN_DISABLE but it also fades in if the character is out of combat and completes a heal on itself. What event is that?

At any rate I've scoured the codebase for uses of those two REGEN events but none seem to be our culprit.

EDIT: at one point I thought the out-of-combat heal event was even triggered by certain COMBAT_TEXT_UPDATE events but that would just be silly.

Resike 06-27-16 07:39 AM

Find the frame, hook it's SetAlpha and override it.

whatisxml 06-27-16 08:31 AM

I'll give that a try when I'm back home. I had tried to do that originally but thinking back it's likely I was only hooking the SetAlpha of a child frame.

Somewhat related, has anyone found where namePlateUnitTokens are assigned/removed from UnitIDs?

For instance what changes to make UnitIsUnit("player",UnitToken) return true?

whatisxml 06-28-16 01:13 AM

Quote:

Originally Posted by Resike (Post 316017)
Find the frame, hook it's SetAlpha and override it.

It was a little bit more difficult than that. I have a solution but not an answer, if that makes sense.

For instance, let's say you have the player name plate.

Code:

local namePlate=C_NamePlate.GetNamePlateForUnit("player")
During combat namePlate:GetAlpha() == 0.75. When you leave combat this value goes down to about 0.375 for a second and then down to nearly 0. Then the NAME_PLATE_UNIT_REMOVED event fires which causes namePlate:Hide() and also destroys all the namePlate's and namePlate.UnitFrame's metadata, breaking its link to the player so it can be reused for other units' name plates. If this happens, you can't get it back. It's gone until the next magic event resummons it.

A few notes on this: destroying its SetAlpha method with namePlate["SetAlpha"]=function()end doesn't prevent the namePlate from fading out or fading back in. I thought maybe just its children were fading but all its children's alphas are at 1.0 the whole time. So something else is driving its fading. The only other way to make it fade is by running WorldFrame:SetAlpha. But again, destroying WorldFrame["SetAlpha"]=function()end doesn't prevent it from fading.

Could there be some hidden frame used to fade it? There's nothing obvious showing up in fstack.

At any rate, here is the temporary solution for the problem:

Code:

local tempFun=NamePlateDriverFrame:GetScript("OnEvent");
local function newOnEvent(self,event,...)
        if event=="NAME_PLATE_UNIT_REMOVED" and UnitIsPlayer(...) then
                -- do nothing
        else
                tempFun(self,event,...);
        end
end
NamePlateDriverFrame:SetScript("OnEvent",newOnEvent);

or if you prefer a macro like I've been using (because I have no idea what I'm doing)

Code:

/run local f=NamePlateDriverFrame;gn=f:GetScript("OnEvent");function fn(s,e,...)if e=="NAME_PLATE_UNIT_REMOVED" and UnitIsPlayer(...)then else gn(s,e,...)end end f:SetScript("OnEvent",fn)
This just prevents the NAME_PLATE_UNIT_REMOVED event script from firing if it's the player's name plate that's removed. Now if you turn off all other nameplates so that yours is the only and let's say it's NamePlate1. You can now make it reappear after it fades by simply running the following snippet:

Code:

/run NamePlate1:Show(); NamePlate1:SetAlpha(0.75);
Unfortunately the name plate is no longer reserved for the player at this point so if another unit on your screen needs a nameplate, it will steal your NamePlate1. I don't think we have access to the code where NamePlates are actually assigned to units so it doesn't seem possible to create a new NamePlate reserved for "player".

And as for the source of the alpha fading, who knows?

whatisxml 06-28-16 01:19 AM

Also pretty new to all this so if I'm doing something obviously wrong, please let me know.

Ketho 07-03-16 11:14 AM

Quote:

Originally Posted by whatisxml (Post 316029)
And as for the source of the alpha fading, who knows?

This question has irked me for a while, it's like complete magic to me now :x


whatisxml 07-03-16 09:23 PM

Yeah seriously! It's probably done in that same magical place that decides how nameplates move around.

The closest I got to preventing the autofading was being able to reshow my resource bar after it faded. But then the next time a new nameplate was needed, it stole my resource bar. What was funny is it would keep displaying my health/energy/combo points even though it would be floating over another unit.

It's too bad all of that functionality is unavailable to us.

Resike 07-04-16 03:22 AM

I have also look into this, it looks like the animation and SetAlpha changes run directly in the game's C code, so we won't be able to override it. You bets bet would be to hide the frame and build a replica. It should't be that hard.

liquidbase 07-04-16 05:03 AM

Quote:

Originally Posted by Resike (Post 316152)
You bets bet would be to hide the frame and build a replica. It should't be that hard.

Yep this the best way.
I had the same issue for DuffedUI and after trying to override the alpha and position for the ressourcenameplate, I have decided to write a complete replica, like the old ressource-bars from the live-version. Another problem is the combatprotection for the default ressource-nameplate.

Tercioo 07-20-16 08:50 PM

there is these two cvars which can be set to artificially lock the position:

SetCVar ("nameplateSelfTopInset", .69999)
SetCVar ("nameplateSelfBottomInset, .3)


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

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