Thread Tools Display Modes
06-24-12, 08:07 AM   #1
CClassiquee
A Deviate Faerie Dragon
 
CClassiquee's Avatar
Join Date: Jun 2012
Posts: 17
KGpanels class colors.

Does anyone have the code for making the color the exact same as your class is? I'd love that.
  Reply With Quote
06-24-12, 08:36 AM   #2
Léthalvenom
A Wyrmkin Dreamwalker
 
Léthalvenom's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 50
normally this should do the job

OnLoad

Code:
local _, class = UnitClass("player");
if class == "WARRIOR" then
self.bg:SetVertexColor(0.95, 0.23, 0.23, self.bg:GetAlpha())
elseif class == "PRIEST" then
self.bg:SetVertexColor(1, 0.96, 0.98, self.bg:GetAlpha())
elseif class == "MAGE" then
self.bg:SetVertexColor(0.00, 1, 1, self.bg:GetAlpha())
elseif class == "DRUID" then
self.bg:SetVertexColor(1, 0.49, 0.04, self.bg:GetAlpha())
elseif class == "PALADIN" then
self.bg:SetVertexColor(0.92, 0.22, 0.46, self.bg:GetAlpha())
elseif class == "HUNTER" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
elseif class == "ROGUE" then
self.bg:SetVertexColor(1, 0.94, 0.16, self.bg:GetAlpha())
elseif class == "SHAMAN" then
self.bg:SetVertexColor(0.13, 0.42, 1, self.bg:GetAlpha())
elseif class == "WARLOCK" then
self.bg:SetVertexColor(0.36, 0.18, 1, self.bg:GetAlpha())
end

Last edited by Léthalvenom : 06-24-12 at 08:39 AM.
  Reply With Quote
06-24-12, 08:39 AM   #3
CClassiquee
A Deviate Faerie Dragon
 
CClassiquee's Avatar
Join Date: Jun 2012
Posts: 17
Thanks =))))
  Reply With Quote
06-24-12, 11:39 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can do the same thing in a lot less code by getting the value from the class colors table instead of hard-coding in a bunch of checks and values for every class:
Lua Code:
  1. local _, class = UnitClass("player")
  2. local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  3. self.bg:SetVertexColor(color.r, color.g, color.b, self.bg:GetAlpha())
This also has the advantage of supporting custom class colors.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-25-12, 03:37 AM   #5
Léthalvenom
A Wyrmkin Dreamwalker
 
Léthalvenom's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 50
Thnx Phanx,didn t know that one. Just tested it,works like a charm.
  Reply With Quote
06-25-12, 08:28 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
RAID_CLASS_COLORS is the table defined and used in Blizzard's UI code. CUSTOM_CLASS_COLORS is the table defined by the "custom class colors" standard. Currently I think my addon is the only one that creates it and provides a UI for changing the colors (which makes sense, since it's my standard!) but many popular addons will look for it and use the colors in it instead of the Blizzard table if it exists.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-26-12, 11:25 AM   #7
CClassiquee
A Deviate Faerie Dragon
 
CClassiquee's Avatar
Join Date: Jun 2012
Posts: 17
Originally Posted by Phanx View Post
RAID_CLASS_COLORS is the table defined and used in Blizzard's UI code. CUSTOM_CLASS_COLORS is the table defined by the "custom class colors" standard. Currently I think my addon is the only one that creates it and provides a UI for changing the colors (which makes sense, since it's my standard!) but many popular addons will look for it and use the colors in it instead of the Blizzard table if it exists.
Could you just copy paste the exact code I need to use?
I dont get the code language lol.
  Reply With Quote
06-26-12, 11:34 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Phanx already gave you the exact code to use. She was just explaining to you what RAID_CLASS_COLORS and CUSTOM_CLASS_COLORS are.
__________________
"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

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KGpanels class colors.

Thread Tools
Display Modes

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