Quantcast
Disabling Player Unit Frame's Autofading - WoWInterface
 
Thread Tools Display Modes
06-26-16, 08:34 PM   #1
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
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.
 
06-26-16, 10:24 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,236
If you are talking about the new Player Resource Bar (mini HUD) you would be better getting something like IceHud.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
 
06-27-16, 05:44 AM   #3
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 928
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
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
 
06-27-16, 06:14 AM   #4
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
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.

Last edited by whatisxml : 06-27-16 at 06:24 AM.
 
06-27-16, 07:39 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Find the frame, hook it's SetAlpha and override it.
 
06-27-16, 08:31 AM   #6
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
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?
 
06-28-16, 01:13 AM   #7
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
Originally Posted by Resike View Post
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?
 
06-28-16, 01:19 AM   #8
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
Also pretty new to all this so if I'm doing something obviously wrong, please let me know.
 
07-03-16, 11:14 AM   #9
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 928
Originally Posted by whatisxml View Post
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

 
07-03-16, 09:23 PM   #10
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
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.
 
07-04-16, 03:22 AM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
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.
 
07-04-16, 05:03 AM   #12
liquidbase
A Black Drake
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 88
Originally Posted by Resike View Post
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.
 
07-20-16, 08:50 PM   #13
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
there is these two cvars which can be set to artificially lock the position:

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

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » Disabling Player Unit Frame's Autofading

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