WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   KGpanels class colors. (https://www.wowinterface.com/forums/showthread.php?t=43565)

CClassiquee 06-24-12 08:07 AM

KGpanels class colors.
 
Does anyone have the code for making the color the exact same as your class is? I'd love that.

Léthalvenom 06-24-12 08:36 AM

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


CClassiquee 06-24-12 08:39 AM

Thanks =))))

Phanx 06-24-12 11:39 PM

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. ;)

Léthalvenom 06-25-12 03:37 AM

Thnx Phanx,didn t know that one. Just tested it,works like a charm. :)

Phanx 06-25-12 08:28 PM

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.

CClassiquee 06-26-12 11:25 AM

Quote:

Originally Posted by Phanx (Post 257144)
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.

Seerah 06-26-12 11:34 AM

Phanx already gave you the exact code to use. She was just explaining to you what RAID_CLASS_COLORS and CUSTOM_CLASS_COLORS are.


All times are GMT -6. The time now is 10:21 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI