Thread Tools Display Modes
09-12-15, 10:05 PM   #1
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Trying to change font/color on unit frames for player targets only.

I have this code that adds class colors on the default unit frames

Code:
local frame = CreateFrame("FRAME")
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
frame:RegisterEvent("PLAYER_FOCUS_CHANGED")
frame:RegisterEvent("UNIT_FACTION")

local function eventHandler(self, event, ...)
        if UnitIsPlayer("target") then
                c = RAID_CLASS_COLORS[select(2, UnitClass("target"))]
                TargetFrameNameBackground:SetVertexColor(c.r, c.g, c.b)
        end
        if UnitIsPlayer("focus") then
                c = RAID_CLASS_COLORS[select(2, UnitClass("focus"))]
                FocusFrameNameBackground:SetVertexColor(c.r, c.g, c.b)
        end
end

frame:SetScript("OnEvent", eventHandler)

for _, BarTextures in pairs({TargetFrameNameBackground, FocusFrameNameBackground}) do
        BarTextures:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
end
And am trying to also adjust the font/color of the focus/target frame respectively. I added this but it changes for non-player targets aswell.

Code:
TargetFrameTextureFrameName:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
TargetFrameTextureFrameName:SetTextColor(1,.9,0)
FocusFrameTextureFrameName:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
FocusFrameTextureFrameName:SetTextColor(1,.9,0)
I thought if you just put that in the two blocks of code that add the color it would also just be another adjustment but it doesn't work like that I guess.
  Reply With Quote
09-13-15, 04:31 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
That's probably because the default UI doesn't reset it. Your original idea works because the default UI sets that color every time, and you just override it. So you need to set it back to the default font as appropriate, too.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-13-15, 10:05 PM   #3
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
So, how do I make the font adjust only on player targets instead of all targets?
  Reply With Quote
09-14-15, 09:05 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Again, you'll need to set it back to the original font when the target is an NPC, as Lombra mentioned.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-14-15, 09:15 PM   #5
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Figured it out eventually through trial and error.

Thanks.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to change font/color on unit frames for player targets only.


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