WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Nameplate hacking and unit IDs (https://www.wowinterface.com/forums/showthread.php?t=53439)

sticklord 09-17-16 05:41 AM

I've been working on my own nameplate mod for abit and I noticed that blizzard uses both 'UNIT_HEALTH_FREQUENT' and 'UNIT_HEALTH'. Anyone know why they do that? This makes the nameplate update twice on some frame updates and that seems abit needless to me.

Here's what i got: https://github.com/Sticklord/AbuName...aster/core.lua

zork 10-02-16 08:16 AM

Decided to scrap the Blizzard nameplates and create my own. Sort of like Abu and Blooblahguy did it.



The following is the code to spawn nameplates as seen in the image above. Basically a bare bone nameplate generator.
All that is needed is a unit framework to style the unit and handle all the unit events.

Lua Code:
  1. -- rNamePlate: core
  2. -- zork, 2016
  3.  
  4. -----------------------------
  5. -- Variables
  6. -----------------------------
  7.  
  8. local A, L = ...
  9.  
  10. local W = CreateFrame("Frame") --worker
  11. local UFM = {} --unit frame mixin
  12. local C_NamePlate = C_NamePlate
  13.  
  14. -----------------------------
  15. -- SetCVar
  16. -----------------------------
  17.  
  18. --default values
  19. SetCVar('nameplateShowAll', GetCVarDefault("nameplateShowAll"))
  20. SetCVar("nameplateMaxAlpha", GetCVarDefault("nameplateMaxAlpha"))
  21. SetCVar("nameplateShowEnemies", GetCVarDefault("nameplateShowEnemies"))
  22. SetCVar("ShowClassColorInNameplate", GetCVarDefault("ShowClassColorInNameplate"))
  23. SetCVar("nameplateOtherTopInset", GetCVarDefault("nameplateOtherTopInset"))
  24. SetCVar("nameplateOtherBottomInset", GetCVarDefault("nameplateOtherBottomInset"))
  25. SetCVar("nameplateMinScale", GetCVarDefault("nameplateMinScale"))
  26. SetCVar("namePlateMaxScale", GetCVarDefault("namePlateMaxScale"))
  27. SetCVar("nameplateMinScaleDistance", GetCVarDefault("nameplateMinScaleDistance"))
  28. SetCVar("nameplateMaxDistance", GetCVarDefault("nameplateMaxDistance"))
  29. SetCVar("NamePlateHorizontalScale", GetCVarDefault("NamePlateHorizontalScale"))
  30. SetCVar("NamePlateVerticalScale", GetCVarDefault("NamePlateVerticalScale"))
  31.  
  32. -----------------------------
  33. -- Hide Blizzard
  34. -----------------------------
  35.  
  36. function W:UpdateNamePlateOptions(...)
  37.   print("UpdateNamePlateOptions",...)
  38. end
  39.  
  40. --disable blizzard nameplates
  41. NamePlateDriverFrame:UnregisterAllEvents()
  42. NamePlateDriverFrame:Hide()
  43. NamePlateDriverFrame.UpdateNamePlateOptions = W.UpdateNamePlateOptions
  44.  
  45. -----------------------------
  46. -- Worker
  47. -----------------------------
  48.  
  49. function W:NAME_PLATE_CREATED(nameplate)
  50.   print("NAME_PLATE_CREATED",nameplate:GetName(),nameplate:GetSize())
  51.   local unitFrame = CreateFrame("Button", nameplate:GetName().."UnitFrame", nameplate)
  52.   unitFrame:SetAllPoints()
  53.   nameplate.unitFrame = unitFrame
  54.   --mix-in ubm table data
  55.   Mixin(unitFrame, UFM)
  56.   --create subframes (health, name, etc...)
  57.   unitFrame:Create(nameplate)
  58. end
  59.  
  60. function W:NAME_PLATE_UNIT_ADDED(unit)
  61.   local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  62.   nameplate.unitFrame:UnitAdded(nameplate,unit)
  63. end
  64.  
  65. function W:NAME_PLATE_UNIT_REMOVED(unit)
  66.   local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  67.   nameplate.unitFrame:UnitRemoved(nameplate,unit)
  68. end
  69.  
  70. function W:OnEvent(event,...)
  71.   print("W:OnEvent",...)
  72.   self[event](event,...)
  73. end
  74.  
  75. W:SetScript("OnEvent", W.OnEvent)
  76.  
  77. W:RegisterEvent("NAME_PLATE_CREATED")
  78. W:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  79. W:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  80. --W:RegisterEvent("PLAYER_TARGET_CHANGED")
  81. --W:RegisterEvent("DISPLAY_SIZE_CHANGED")
  82. --W:RegisterEvent("UNIT_AURA")
  83. --W:RegisterEvent("VARIABLES_LOADED")
  84. --W:RegisterEvent("CVAR_UPDATE")
  85. --W:RegisterEvent("RAID_TARGET_UPDATE")
  86. --W:RegisterEvent("UNIT_FACTION")
  87.  
  88. -----------------------------
  89. -- Unit Frame Mixin
  90. -----------------------------
  91.  
  92. function UFM:Create(nameplate)
  93.   print("UFM:Create",self:GetName(),nameplate:GetName())
  94.   --create health bar
  95.   local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
  96.   t:SetColorTexture(0,1,0)
  97.   t:SetSize(32,32)
  98.   t:SetPoint("CENTER")
  99.  
  100.   --create name
  101.   self:Hide()
  102. end
  103.  
  104. function UFM:UnitAdded(nameplate,unit)
  105.   print("UFM:UnitAdded",self:GetName(),nameplate:GetName(),unit)
  106.  
  107.   self.unit = unit
  108.   self.inVehicle = UnitInVehicle(unit)
  109.  
  110.  
  111.   self:Show()
  112.  
  113. end
  114.  
  115. function UFM:UnitRemoved(nameplate,unit)
  116.   print("UFM:UnitRemoved",self:GetName(),nameplate:GetName(),unit)
  117.  
  118.   self.unit = nil
  119.   self.inVehicle = nil
  120.  
  121.   self:Hide()
  122.  
  123. end

Not sure but since nameplates are normal unit buttons now...you may be able to just use oUF to spawn your unit button using a certain layout.

If that is possible it means that you can integrate nameplates into your default unitframe layout.

Tested the oUF integration:
http://www.wowinterface.com/forums/s...ad.php?t=54584

*edit* Turned out it is no problem to use oUF to spawn your nameplates.

http://i.imgur.com/vmjAGET.jpg


All times are GMT -6. The time now is 03:41 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI