Thread Tools Display Modes
05/24/16, 08:35 PM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
[outdated] Nameplates, their possible event flood & the unitTag problem

Okay, so Nameplates don't have a lot of API in order to play with them.

In an nice world, something like this could be interesting :

nameplateUnitIndex = An ID64 at the creation of EACH unit. This one will stay same for every unit in game until UI reload / character logoff.

If the unit is destroyed because it have disppeared from your screen, the ID64 must remain same when the same unit come back.
When unit is not visible, all those functions below returns nil
If the unit is an NPC and being killed, the respawn of that same npc can provide another id64 if there is any security issue.

Then the big question, are those events triggers / function return nil when nameplates are disabled ?





So, 2 events :

EVENT_NAMEPLATE_UNIT_CREATED(integer eventId, id64 nameplateUnitIndexCreated)
Event triggers when a nameplate enters on screen (should trigger only when 1st pixel of text is visible on screen).

EVENT_NAMEPLATE_UNIT_DESTROYED(integer eventId, id64 nameplateUnitIndexDestroyed)
Event triggers when a nameplate totally disappear from screen (should trigger only when last pixel of text exit screen).

Those events can be spammy. If I have 20 units front of me and I turn my camera, the event should fire 20 times. If I look at them back, even should fire 20 more times.





Few functions :

Lua Code:
  1. local numNameplatesVisible = GetNumNamePlateUnitVisible(nameplateUnitIndex)
  2. -- return the count of NamePlatesUnit visible
  3.  
  4. local nameplateUnitIndex = GetNamePlateUnitIndex(index)
  5. -- return the id64 nameplateUnitIndex at index X.
  6.  
  7. local displayName = GetNamePlateDisplayName(nameplateUnitIndex)
  8. -- return the DisplayName of the nameplateUnitIndex or nil if nameplateUnitIndex is not a player
  9.  
  10. local caption = GetNamePlateCaption(nameplateUnitIndex)
  11. -- return the caption of the NPC or nil if nameplateUnitIndex has no caption / not a NPC
  12.  
  13. local isVisible = IsNamePlateGuildShown(nameplateUnitIndex)
  14. -- return true if a guild name is displayed
  15.  
  16. local guildName = GetNamePlateGuildName(nameplateUnitIndex)
  17. -- return guildName of the nameplateUnitIndex or nil if no guild name / not a player
  18.  
  19. local namePlateType GetNamePlateType(nameplateUnitIndex)
  20. -- return an UnitNameplateType constant ( wiki.esoui.com/Globals#UnitNameplateType )
  21.  
  22. local name = GetNamePlateName(nameplateUnitIndex)
  23. -- return the name of the nameplateUnitIndex
  24. -- if unit is an NPC, it returns its whole name
  25. -- if unit is a player, it returns ONLY his characterName




The Title problem :

Titles are formatted with a translator convenience. They don't follow vanilla titles. Experts could find them in xx.csv
For PVP and emperor, they're prefixed. <<Title>> <<YourName>>
For PVE, they're suffixed with comma and pronoun. <<YourName>>, <<pronoun>> <<title>> (Except new "Silencer" Title which is prefixed like PVP titles).

And, when title is active, title is merged with your name.

a GetNamePlateTitle(nameplateUnitIndex) will return the title and your name I guess.

So :

Lua Code:
  1. local isTitleShown = IsNamePlateTitleShown(nameplateUnitIndex)
  2. -- return true if a title is displayed, nil if not a player or no title.

to get the Title.. I think we'll have to play with gsub.





Setting our own NamePlates :

Lua Code:
  1. SetNamePlateName(value, nameplateUnitIndex)
  2. -- Set the name of the concerned nameplateUnitIndex. if unit is a player, his title if shown won't be changed
  3.  
  4. SetNamePlateFullName(value, nameplateUnitIndex)
  5. -- Set the full name of the concerned nameplateUnitIndex (will erase title)
  6.  
  7. SetNamePlateGuild(value, nameplateUnitIndex)
  8. -- Set the Guild Name of the concerned nameplateUnitIndex if unit is a player
  9.  
  10. SetNamePlateCaption(value, nameplateUnitIndex)
  11. -- Set the name of the concerned nameplateUnitIndex if unit is a npc

For SetNamePlateName, if nameplateUnitIndex is a player, the value should follow at least the max length name.

For SetNamePlateFullName, the length of the value must not be > max name length + length the longest title available ingame (we have a title in french of 45 chars per ex.)

For those 2 last functions : They function should let us play with the format ("<" and ">") if we want to remove them. Without those chars, they must not be displayed. If I set "Something", it must be "Something", not "<Something>"




Colors :

Lua Code:
  1. SetNamePlateBaseColorForType(type, r, g, b, closeAlpha, farAlpha)
  2. -- Set the color of the UnitNameplateType when unit is not targetted. closeAlpha is the alpha value when the unit is the closest possible, farAlpha is the alpha when the unit is the farthest possible.
  3. SetNamePlateTargettedColorForType(type, r, g, b, closeAlpha, farAlpha)
  4. -- Set the color of the UnitNameplateType when unit is targetted. closeAlpha is the alpha value when the unit is the closest possible, farAlpha is the alpha when the unit is the farthest possible.

If type == UNIT_NAMEPLATE_DEFAULT (the local player), the 2nd function won't do nothing. And 1st function is inverted (the more we zoom, the less we see our nameplate).



Finally, the fonts :

Lua Code:
  1. GetNamePlateBaseFont() -- Returns the NamePlate font when unit is not targetted
  2. GetNamePlateTargettedFont() -- Returns the NamePlate font when unit is targetted
  3.  
  4. SetNamePlateBaseFont() -- Set the NamePlate font when unit is not targetted
  5. SetNamePlateTargettedFont() -- Set the NamePlate font when unit is targetted



That's all It was interesting writing this and we'll maybe never have those functions, maybe because already thinked and considered too intense. but we never know.
 

ESOUI » Developer Discussions » Wish List » [outdated] Nameplates, their possible event flood & the unitTag problem

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