View Single Post
01-20-10, 05:08 AM   #5
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by alimjocox View Post
i know how to make borders and things that use class colored::
blah:Set...Color(r,g,b,a)

but not text or specific parts of the text

I believe what you're looking for is the proper way to use the " |c " and the " |r " right? I don't know the correct terminology but here goes.

Here's an example(For direct string usage):

"|cff00ff00TEXT|r"

So what is happening here is we have just like in HTML or BBC you have beginning and ending tags to show where the color is placed. The first "ff" I BELIEVE is intensity? I have no idea tbh, and the next 6 numbers/letters are the hex equivalent of the color you're wanting.

Now how do we make it the color of your character?

Since there isn't a hex color relationship from the RAID_CLASS_COLORS * from my crap knowledge * you can set a table to represent each class with the color corresponding:

Code:
local classColor = { 
SHAMAN 		= "2459FF", 
MAGE 		= "69CCF0",
WARLOCK 	= "9482C9",
HUNTER		= "ABD473",
ROGUE		= "FFF569",
PRIEST		= "FFFFFF",
DRUID 		= "FF7D0A",
DEATHKNIGHT = "C41F3B",
WARRIOR 	= "C79C6E",
PALADIN 	= "F58CBA",
}
From here we have a nice footing to make a "plugin" to our texts.

To ensure the name of our class is exact to the table, we want to avoid using the localized name of the class:

Code:
local _, pClass = UnitClass("player")
The variable pClass will now give whichever character you're on the value of your unlocalized class.

Now for the text:

Code:
string = "|cff"..classColor[pClass].."TEXT|r"
This text will now always be corresponding to your player's class color.

So looking at your code here:
Code:
Text:SetText(floor(GetFramerate()).." |cff"..classColor[pClass].."fps || |r"..select(3, GetNetStats()).." |cff"..classColor[pClass].."ms|r")
Now I'm not actually 100% sure this will work for a SetText function as there is a "SetTextColor(r,g,b,a)" which you could use a completely different function to set their colors according to class.

...but I think I got what you were looking for?

Last edited by suicidalkatt : 01-20-10 at 05:16 AM.
  Reply With Quote