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:
-- rNamePlate: core
-- zork, 2016
-----------------------------
-- Variables
-----------------------------
local A, L = ...
local W = CreateFrame("Frame") --worker
local UFM = {} --unit frame mixin
local C_NamePlate = C_NamePlate
-----------------------------
-- SetCVar
-----------------------------
--default values
SetCVar('nameplateShowAll', GetCVarDefault("nameplateShowAll"))
SetCVar("nameplateMaxAlpha", GetCVarDefault("nameplateMaxAlpha"))
SetCVar("nameplateShowEnemies", GetCVarDefault("nameplateShowEnemies"))
SetCVar("ShowClassColorInNameplate", GetCVarDefault("ShowClassColorInNameplate"))
SetCVar("nameplateOtherTopInset", GetCVarDefault("nameplateOtherTopInset"))
SetCVar("nameplateOtherBottomInset", GetCVarDefault("nameplateOtherBottomInset"))
SetCVar("nameplateMinScale", GetCVarDefault("nameplateMinScale"))
SetCVar("namePlateMaxScale", GetCVarDefault("namePlateMaxScale"))
SetCVar("nameplateMinScaleDistance", GetCVarDefault("nameplateMinScaleDistance"))
SetCVar("nameplateMaxDistance", GetCVarDefault("nameplateMaxDistance"))
SetCVar("NamePlateHorizontalScale", GetCVarDefault("NamePlateHorizontalScale"))
SetCVar("NamePlateVerticalScale", GetCVarDefault("NamePlateVerticalScale"))
-----------------------------
-- Hide Blizzard
-----------------------------
function W:UpdateNamePlateOptions(...)
print("UpdateNamePlateOptions",...)
end
--disable blizzard nameplates
NamePlateDriverFrame:UnregisterAllEvents()
NamePlateDriverFrame:Hide()
NamePlateDriverFrame.UpdateNamePlateOptions = W.UpdateNamePlateOptions
-----------------------------
-- Worker
-----------------------------
function W:NAME_PLATE_CREATED(nameplate)
print("NAME_PLATE_CREATED",nameplate:GetName(),nameplate:GetSize())
local unitFrame = CreateFrame("Button", nameplate:GetName().."UnitFrame", nameplate)
unitFrame:SetAllPoints()
nameplate.unitFrame = unitFrame
--mix-in ubm table data
Mixin(unitFrame, UFM)
--create subframes (health, name, etc...)
unitFrame:Create(nameplate)
end
function W:NAME_PLATE_UNIT_ADDED(unit)
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
nameplate.unitFrame:UnitAdded(nameplate,unit)
end
function W:NAME_PLATE_UNIT_REMOVED(unit)
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
nameplate.unitFrame:UnitRemoved(nameplate,unit)
end
function W:OnEvent(event,...)
print("W:OnEvent",...)
self[event](event,...)
end
W:SetScript("OnEvent", W.OnEvent)
W:RegisterEvent("NAME_PLATE_CREATED")
W:RegisterEvent("NAME_PLATE_UNIT_ADDED")
W:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
--W:RegisterEvent("PLAYER_TARGET_CHANGED")
--W:RegisterEvent("DISPLAY_SIZE_CHANGED")
--W:RegisterEvent("UNIT_AURA")
--W:RegisterEvent("VARIABLES_LOADED")
--W:RegisterEvent("CVAR_UPDATE")
--W:RegisterEvent("RAID_TARGET_UPDATE")
--W:RegisterEvent("UNIT_FACTION")
-----------------------------
-- Unit Frame Mixin
-----------------------------
function UFM:Create(nameplate)
print("UFM:Create",self:GetName(),nameplate:GetName())
--create health bar
local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
t:SetColorTexture(0,1,0)
t:SetSize(32,32)
t:SetPoint("CENTER")
--create name
self:Hide()
end
function UFM:UnitAdded(nameplate,unit)
print("UFM:UnitAdded",self:GetName(),nameplate:GetName(),unit)
self.unit = unit
self.inVehicle = UnitInVehicle(unit)
self:Show()
end
function UFM:UnitRemoved(nameplate,unit)
print("UFM:UnitRemoved",self:GetName(),nameplate:GetName(),unit)
self.unit = nil
self.inVehicle = nil
self:Hide()
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