Thread Tools Display Modes
10-02-16, 08:28 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
oUF for nameplate creation?

I posted a barebone nameplate setup here:
http://www.wowinterface.com/forums/s...4&postcount=62

Most important are the following three.

- nameplate_create when we spawn the frame using a certain style.
- unit_added when we show the frame and set the unit of the frame.
- unit_removed when we hide the frame and remove the unit.

Is this possible with the default oUF core?

I need to be able to pass the nameplate base as an anchor frame into the Spawn function.

*edit*

Wooow. It actually works!



Fixed scaling:


magic bean:

Lua Code:
  1. function W:NAME_PLATE_UNIT_ADDED(unit)
  2.   local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  3.  
  4.   if not nameplate.unitFrame then
  5.     local unitFrame = oUF:Spawn(unit, A..nameplate:GetName())
  6.     unitFrame:SetParent(nameplate)
  7.     unitFrame:ClearAllPoints()
  8.     unitFrame:SetPoint("CENTER")
  9.     nameplate.unitFrame = unitFrame
  10.     --mix-in ubm table data
  11.     Mixin(unitFrame, UFM)
  12.   end
  13.  
  14.   nameplate.unitFrame:UnitAdded(nameplate,unit)
  15. end

Not perfect yet though. But it shows that it should be possible.

Currently I seem to struggle with the unit update. Nameplates shuffle units quite often and I need a way to tell oUF about the unit change.

Hasn't oUF a function to trigger a full update? Sth like UpdateAllElements.

If you want to test it here is the code I'm using atm:

https://github.com/zorker/rothui/blo...imple/core.lua

Units do not update properly and clicking on a unit does not activate the correct unit.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-02-16 at 10:44 AM.
  Reply With Quote
10-02-16, 11:10 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I think I got it!!! (But it works only out of combat atm. I need a secure way to apply the unit attribute (I think...))

Lua Code:
  1. --UFM:UnitAdded
  2. function UFM:UnitAdded(nameplate,unit)
  3.   self.unit = unit
  4.   self.inVehicle = UnitInVehicle(unit)
  5.   self:SetAttribute("unit", unit)
  6.   self:UpdateAllElements("NAME_PLATE_UNIT_ADDED")
  7. end
  8.  
  9. --UFM:UnitRemoved
  10. function UFM:UnitRemoved(nameplate,unit)
  11.   self.unit = nil
  12.   self.inVehicle = nil
  13.   self:SetAttribute("unit", unit)
  14.   self:UpdateAllElements("NAME_PLATE_UNIT_REMOVED")
  15. end

Full solution (all you need is your own style function)

Lua Code:
  1. ------------------------------------------------------------------------------
  2. ------------------------------------------------------------------------------
  3. ------------------------------------------------------------------------------
  4. -- NAMEPLATE TEST
  5. ------------------------------------------------------------------------------
  6. ------------------------------------------------------------------------------
  7. ------------------------------------------------------------------------------
  8.  
  9. --register focus
  10. oUF:RegisterStyle(A.."NamePlateStyle", CreateNamePlateStyle)
  11. oUF:SetActiveStyle(A.."NamePlateStyle")
  12.  
  13. local W = CreateFrame("Frame") --worker
  14. local UFM = {} --unit frame mixin
  15. local C_NamePlate = C_NamePlate
  16.  
  17. -----------------------------
  18. -- Hide Blizzard
  19. -----------------------------
  20.  
  21. function W:UpdateNamePlateOptions(...)
  22.   print("UpdateNamePlateOptions",...)
  23. end
  24.  
  25. --disable blizzard nameplates
  26. NamePlateDriverFrame:UnregisterAllEvents()
  27. NamePlateDriverFrame:Hide()
  28. NamePlateDriverFrame.UpdateNamePlateOptions = W.UpdateNamePlateOptions
  29.  
  30. -----------------------------
  31. -- Worker
  32. -----------------------------
  33.  
  34. function W:NAME_PLATE_UNIT_ADDED(unit)
  35.   local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  36.   if not nameplate.unitFrame then
  37.     local unitFrame = oUF:Spawn(unit, A..nameplate:GetName())
  38.     unitFrame:SetParent(nameplate)
  39.     unitFrame:ClearAllPoints()
  40.     unitFrame:SetPoint("CENTER")
  41.     nameplate.unitFrame = unitFrame
  42.     Mixin(unitFrame, UFM)
  43.   end
  44.   nameplate.unitFrame:UnitAdded(nameplate,unit)
  45. end
  46.  
  47. function W:NAME_PLATE_UNIT_REMOVED(unit)
  48.   local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  49.   nameplate.unitFrame:UnitRemoved(nameplate,unit)
  50. end
  51.  
  52. function W:OnEvent(event,...)
  53.   self[event](event,...)
  54. end
  55.  
  56. W:SetScript("OnEvent", W.OnEvent)
  57.  
  58. W:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  59. W:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  60.  
  61. -----------------------------
  62. -- Unit Frame Mixin
  63. -----------------------------
  64.  
  65. function UFM:UnitAdded(nameplate,unit)
  66.   self.unit = unit
  67.   self.inVehicle = UnitInVehicle(unit)
  68.   self:SetAttribute("unit", unit)
  69.   self:UpdateAllElements("NAME_PLATE_UNIT_ADDED")
  70. end
  71.  
  72. function UFM:UnitRemoved(nameplate,unit)
  73.   self.unit = nil
  74.   self.inVehicle = nil
  75.   self:SetAttribute("unit", unit)
  76.   self:UpdateAllElements("NAME_PLATE_UNIT_REMOVED")
  77. end

I either need a spawn that does not need secure environment or I need a way to spawn/change the unit attribute securely.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-02-16 at 11:48 AM.
  Reply With Quote
10-02-16, 11:34 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I tried adding the following change as a test to the oUF Spawn function:

Lua Code:
  1. function oUF:Spawn(unit, overrideName, type, nameplate)
  2.   argcheck(unit, 2, 'string')
  3.   if(not style) then return error("Unable to create frame. No styles have been registered.") end
  4.  
  5.   unit = unit:lower()
  6.  
  7.   local name = overrideName or generateName(unit)
  8.   local object
  9.   if type == "nameplate" then
  10.     object = CreateFrame("Button", name, nameplate)
  11.   else
  12.     object = CreateFrame("Button", name, oUF_PetBattleFrameHider, "SecureUnitButtonTemplate")
  13.   end
  14.   Private.UpdateUnits(object, unit)
  15.  
  16.   self:DisableBlizzard(unit)
  17.   walkObject(object, unit)
  18.  
  19.   object:SetAttribute("unit", unit)
  20.   RegisterUnitWatch(object)
  21.  
  22.   return object
  23. end

This gets rid of the in combat error. But sometimes the health will not update properly. I think that is because going from secure to not secure unitframes is not just removing the template and be done?!

Well another issue is that nameplates will pop up during combat. They must be spawnable in combat. Maybe nameplates can be handled like party or raid via secure group header?

The current solution works perfectly. Out of combat.

*edit*

I went back to the adjusted oUF spawn because I think it is the only solution. We need to spawn the nameplates without the secure template. From what I can tell the only thing that is missing atm is that UNIT_HEALTH is not updating the target nameplate properly.

Hmm yeah...when fighting UNIT_HEALTH fires only for target and oUF is not updating the target nameplate correctly.

But I can fix that by doing C_NamePlate.GetNamePlateForUnit("target") and applying the value on postupdate to the corresponding nameplate. Will see how that goes. Imo anything that affects the target unit has to be populated to a corresponding nameplate target unit aswell since it will only fire once.

Urgs...the same is also true party/raid units...hmm that sounds messy. No sure if seperating nameplate from other unit frames in two seperate ouf layouts helps with that.

*edit*

Yes that seems to have fixed all issues. I disabled all unitframes but the nameplate spawn. I only used nameplate unit ids. I spawned them with the adjusted oUF spawn function as a not secure button.

So here is my idea for now.

1.) Adjust the oUF spawn function to allow the creation of non secure nameplate units.
2.) Create a seperate layout for nameplates only that does only spawn nameplate units (never use anything else but nameplate1..n as your unit id)

The tricky part is that I want to access style function from my oUF unit layout. But I probably can circumvent this by making the layout functions globally available.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-02-16 at 12:35 PM.
  Reply With Quote
10-02-16, 12:27 PM   #4
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Yeah the UNIT_HEALTH on nameplates work badly. Blizzard registers both UNIT_HEALTH and the frequent one (forgot the name). I'm using the frequent one only on mine.

If you get the OnEvent onevent of the unitframe and change it so it bails out if there's a unit and unit does not match the nameplate, would that fix it?

Last edited by sticklord : 10-02-16 at 02:09 PM.
  Reply With Quote
10-02-16, 04:03 PM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I'm currently doing that sticklord is suggesting. Trying to create a seperate spawn function for nameplates.

Currently I get this taint:
Lua Code:
  1. 10/2 23:59:09.464  An action was blocked in combat because of taint from oUF - SecureStateDriverManager:SetAttribute()
  2. 10/2 23:59:09.464      Interface\FrameXML\SecureStateDriver.lua:42 RegisterUnitWatch()
  3. 10/2 23:59:09.464      Interface\AddOns\oUF\ouf.lua:553 SpawnNamePlate()
  4. 10/2 23:59:09.464      Interface\AddOns\oUF_Simple\core.lua:592 ?()
  5. 10/2 23:59:09.464      Interface\AddOns\oUF_Simple\core.lua:617

Currently trying to get rid of that error.

*edit*

Ok I could just remove the unit watch since we have unit_added and unit_removed for nameples. The error seems to be gone.

Lua Code:
  1. function oUF:SpawnNamePlate(unit, overrideName, nameplate)
  2.   argcheck(unit, 2, 'string')
  3.   if(not style) then return error("Unable to create frame. No styles have been registered.") end
  4.   unit = unit:lower()
  5.   local name = overrideName or generateName(unit)
  6.   local object = CreateFrame("Button", name, nameplate)
  7.   Private.UpdateUnits(object, unit)
  8.   walkObject(object, unit)
  9.   object:SetAttribute("unit", unit)
  10.   return object
  11. end

This is all I have for nameplate_added and nameplate_removed atm. Works fine.

Lua Code:
  1. -----------------------------
  2. -- Unit Frame Mixin
  3. -----------------------------
  4.  
  5. function UFM:UnitAdded(nameplate,unit)
  6.   self:SetAttribute("unit", unit)
  7.   self:UpdateAllElements("NAME_PLATE_UNIT_ADDED")
  8. end
  9.  
  10. function UFM:PlayerTargetChanged(nameplate,unit)
  11.   self:UpdateAllElements("PLAYER_TARGET_CHANGED")
  12. end
  13.  
  14. function UFM:UnitRemoved(nameplate,unit)
  15.   self:SetAttribute("unit", nil)
  16.   self:UpdateAllElements("NAME_PLATE_UNIT_REMOVED")
  17. end
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-02-16 at 04:14 PM.
  Reply With Quote
10-02-16, 04:30 PM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Not sure why but I commented in my unitframes again and everything is working as it should! I now have a template that runs both nameplates and normal unitframes.

http://imgur.com/a/mGgbb

It is fucking beautiful!!!

Hopefully auras will not cause issues. >_<
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-02-16, 04:38 PM   #7
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Neat!

Should be easy to add support for nameplates in oUF.
  Reply With Quote
10-02-16, 04:48 PM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Created a pull request: https://github.com/oUF-wow/oUF/pull/312

That is all I had to change in oUF to get it working.

Hmmm. Yeah of course one could integrate the worker aswell in oUF but not sure if that is really needed since you probably want to keep control over what the events are doing.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-02-16 at 04:59 PM.
  Reply With Quote
10-03-16, 10:24 AM   #9
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Here is the final result for now. Implementation of auras cause no issues at all.

It is fucking amazing!

__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-04-16, 01:04 PM   #10
groin
A Cyclonian
AddOn Compiler - Click to view compilations
Join Date: Nov 2008
Posts: 45
hi, this is great.
it's possible to change font size for debuff?

Last edited by groin : 10-04-16 at 03:34 PM.
  Reply With Quote
10-04-16, 04:52 PM   #11
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Anything on screen is spawned by an oUF style function that you need to define or that you can adjust. Yes, you can do that.

Shot from 5man


Blizzard increases the size of boss nameplates by default.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-05-16, 12:45 AM   #12
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by zork View Post
Blizzard increases the size of boss nameplates by default.
Probably because they are anchored to WorldFrame and not UIParent.
  Reply With Quote
10-05-16, 02:23 AM   #13
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
There is a so called nameplate base frame. They must adjust the scale of the nameplate base frame for bosses. But it should be easily detectable on UNIT_ADDED.

I already offset the worldframe scale. Otherwise the size of all my nameplates would be off.

https://github.com/zorker/rothui/blo.../core.lua#L688
Lua Code:
  1. --CreateNamePlateStyle
  2. local function CreateNamePlateStyle(self)
  3.   --...
  4.   cfg.scale = 1*GetCVar("uiScale") --nameplates are not part of uiparent!
  5.   --...
  6. end

Nameplates shuffle units constantly. There is no specific nameplate for player or bosses. Any nameplate may be used for any unit.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-05-16 at 02:29 AM.
  Reply With Quote
10-14-16, 02:53 PM   #14
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
This is really cool, looking forward it being implemented in oUF!
  Reply With Quote
10-26-16, 03:29 AM   #15
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
oUF generated nameplates can't be clicked?
Edit: Hmm, it felt weird at first, maybe I was just missing something, not sure. Just ignore this, will test them later

Last edited by sezz : 10-26-16 at 08:09 AM.
  Reply With Quote
10-26-16, 10:22 AM   #16
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Of course they can be clicked! One very important thing though. Your nameplate unitframe must not be clickable! Do not register this for units of type nameplate!

Lua Code:
  1. --SetupHeader
  2. local function SetupHeader(self)
  3.   if not self.settings.setupHeader then return end
  4.   self:RegisterForClicks("AnyDown")
  5.   self:SetScript("OnEnter", UnitFrame_OnEnter)
  6.   self:SetScript("OnLeave", UnitFrame_OnLeave)
  7. end
  8. L.F.SetupHeader = SetupHeader

https://github.com/zorker/rothui/blo...eplate.lua#L17

The nameplate base is clickable, that is all we need.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-26-16 at 10:25 AM.
  Reply With Quote
10-26-16, 11:52 AM   #17
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Yeah, works fine now. No idea what went wrong when I created a simple test layout with only name text and health bar, guess the anchors were completely wrong and that's why it felt like I couldn't click them.

By the way, any idea why friendly player nameplates are now shown for units with missing health who aren't in my group? I think that's new for 7.1...
  Reply With Quote
10-26-16, 12:32 PM   #18
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
No clue. Still need to update the cvarlist of the nameplates. Not sure if they changed sth.
This is the live 7.0 to PTR 7.1 diff.
https://github.com/zorker/rothui/com...76b1ccbee2d4ad

Still need to make a new one for 7.1 on live.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-31-16, 01:33 AM   #19
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
7.1 brought a lot of restrictions to nameplates. None of them affects oUF nameplates.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF for nameplate creation?

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