Add class colored names to the unit frames
This commit is contained in:
@@ -56,6 +56,7 @@ function UnitFrame:Init(unit, width, height, hideInRaid)
|
||||
overlays:SetAllPoints(true)
|
||||
overlays:Show()
|
||||
self.overlays = overlays
|
||||
self:CreateName()
|
||||
self.indicators = {
|
||||
Indicator:new(self, self.auras, 14, "TOPLEFT", 2, -2, colors.white, 383648),
|
||||
Indicator:new(self, self.auras, 14, "TOPLEFT", 2, -2, colors.white, 974),
|
||||
@@ -75,6 +76,20 @@ function UnitFrame:StartRangeTicker()
|
||||
end)
|
||||
end
|
||||
|
||||
-- TODO: maybe string indicators need to be a thing
|
||||
function UnitFrame:CreateName()
|
||||
local name = self.overlays:CreateFontString(nil, "BACKGROUND")
|
||||
self.name = name
|
||||
|
||||
name:SetFont("Interface\\AddOns\\OmicronFrames\\media\\fonts\\roboto\\Roboto-Bold.ttf", 13, "")
|
||||
name:SetTextColor(0.8, 0.6, 0.1)
|
||||
name:SetShadowColor(0, 0, 0)
|
||||
name:SetShadowOffset(1, -1)
|
||||
name:SetPoint("CENTER")
|
||||
name:SetText("")
|
||||
name:Show()
|
||||
end
|
||||
|
||||
function UnitFrame:StopRangeTicker()
|
||||
if self.rangeTicker then
|
||||
self.rangeTicker:Cancel()
|
||||
@@ -244,6 +259,7 @@ function UnitFrame:RegisterEvents()
|
||||
secure:RegisterUnitEvent("UNIT_AURA", unit)
|
||||
secure:RegisterUnitEvent("UNIT_HEALTH", unit)
|
||||
secure:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
|
||||
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
||||
end
|
||||
|
||||
-- returns whether or not the unit guid has changed since the last call to this
|
||||
@@ -300,6 +316,10 @@ function UnitFrame:PLAYER_TARGET_CHANGED()
|
||||
self:UpdateAll(self:HasUnitChanged())
|
||||
end
|
||||
|
||||
function UnitFrame:UNIT_NAME_UPDATE()
|
||||
self:UpdateName()
|
||||
end
|
||||
|
||||
function UnitFrame:OnShow()
|
||||
self:StartRangeTicker()
|
||||
self:UpdateAll(self:HasUnitChanged())
|
||||
@@ -320,6 +340,7 @@ function UnitFrame:UpdateAll(unitChanged)
|
||||
self:UpdateHealth()
|
||||
self:UpdateHealthColor()
|
||||
self:UpdateRange()
|
||||
self:UpdateName()
|
||||
end
|
||||
|
||||
function UnitFrame:UpdateHealth()
|
||||
@@ -372,6 +393,17 @@ function UnitFrame:UpdateHealthColor()
|
||||
end
|
||||
end
|
||||
|
||||
function UnitFrame:UpdateName()
|
||||
if UnitIsPlayer(self.unit) then
|
||||
local _, class = UnitClass(self.unit)
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
self.name:SetTextColor(color.r, color.g, color.b)
|
||||
else
|
||||
self.name:SetTextColor(1, 1, 1)
|
||||
end
|
||||
self.name:SetText(UnitName(self.unit):sub(1, 5))
|
||||
end
|
||||
|
||||
--[[
|
||||
-- UNIT_AURA
|
||||
-- UNIT_CLASSIFICATION_CHANGED
|
||||
|
Reference in New Issue
Block a user