Wednesday, April 18, 2012

ColorPickerFrame and RAID_CLASS_COLORS

I have a littlie problem with my addon. What I want to do is when i use the "classcolor" slashcomand it will open the CPF so you can select the color and if you use the comand again it set the color to the own classcolor. So now to my problem from classcolor "on" to classcolor "off" it works great but if you want to change it again to "on" the RAID_CLASS_COLORS[select(2, UnitClass("player"))] seems not to work you have to reload the ui first. When you start with Classcolor "off" and change it to "on" it works great but once you opend the CPF again it don't work again. So it have something to do with the CPF but I don't know how to change it.

I hope you understand what I mean and I hope someone here can help me.



so here are the important lines of the code:


Code:
function onUpdate()
hcoord.mmcoords:SetTextColor(hCoords2DB.Color.r, hCoords2DB.Color.g, hCoords2DB.Color.b)
hcoord:SetBackdropBorderColor(hCoords2DB.Color.r, hCoords2DB.Color.g, hCoords2DB.Color.b)
end
hcoord:SetScript("OnUpdate", onUpdate)

function hcoord2_Commands(cmd)
local c,x = string.split(" ",cmd)
if c == "classcolor" then
if hCoords2DB.ClassColors == true then
hCoords2DB.ClassColors = false
ColorPickerFrame:Show()
ColorPickerFrame.func = function ()
hCoords2DB.Color.r, hCoords2DB.Color.g,
hCoords2DB.Color.b = ColorPickerFrame:GetColorRGB()
end
DEFAULT_CHAT_FRAME:AddMessage("Classcolor: |cFFFF0000off|r")
else
hCoords2DB.ClassColors = true
hCoords2DB.Color=RAID_CLASS_COLORS[select(2, UnitClass("player"))]
DEFAULT_CHAT_FRAME:AddMessage("Classcolor: |cFF00FF21on|r")
end
end

No comments:

Post a Comment