I am unable to get DColorMixer:SetColor()/SetBaseColor() to work right
0 replies, posted
So I've got a pnl which holds 3 different dcolormixers. I tab through the 3 different mixers with my own tab function, that is all working fine and dandy. My only issue is when I initialize the dcolormixers, the color and base color is not being change when I call SetColor/SetBaseColor
-- prnt is a valid dpanel
-- prfl:GetColor() returns Color(255, 255, 255, 255)
-- prfl:GetHeadshotColor() returns Color(
-- prfl:GetKillColor() returns Color(
---------- Color Picker Panel ----------
local colPick = vgui.Create("DPanel", prnt)
colPick:SetTall(prnt:GetTall() / 2)
colPick:Dock(TOP)
colPick:InvalidateParent(true)
colPick._colForms = { vgui.Create("DPanel", colPick), vgui.Create("DPanel", colPick),
vgui.Create("DPanel", colPick) }
buildColPickerTabs(colPick)
colPick._colForms[1] = buildColorPicker(colPick, colPick._colForms[1], prfl, prfl:GetColor(),
function(col) prfl:SetColor(col) end)
colPick._colForms[1]:SetVisible(true) -- have to make sure one is visible by default
colPick._colForms[2] = buildColorPicker(colPick, colPick._colForms[2], prfl, prfl:GetHeadshotColor(),
function(col) prfl:SetHeadshotColor(col) end)
colPick._colForms[3] = buildColorPicker(colPick, colPick._colForms[3], prfl, prfl:GetKillColor(),
function(col) prfl:SetKillColor(col) end)
----------------------------------------
--[[-----------------------------
buildColPickerTabs( DPanel prnt )
- builds the tabs for the color picker pnl,
(normal/head/kill hit)
]]-------------------------------
local function buildColPickerTabs(prnt)
local tabs = vgui.Create("DPanel", prnt)
tabs:SetTall(tabs_h)
tabs:Dock(TOP)
tabs:InvalidateParent(true)
local names = { "Normal Shot", "Head Shot", "Kill Shot" }
local xPos = 0
for i = 1, 3 do
local tab = vgui.Create("DButton", tabs)
tab:SetSize((tabs:GetWide() / 3) + 3, tabs_h)
tab:SetPos(xPos, 0)
tab:SetText(names[i])
function tab:DoClick()
for c = 1, 3 do
prnt._colForms[c]:SetVisible(false)
end -- disable all
prnt._colForms[i]:SetVisible(true) -- enable this one
end
xPos = xPos + (tabs:GetWide() / 3) - 1
end
end
--[[------------------------------------------------------
buildColorPicker( DPanel prnt, HitProfile prfl, DPanel pnl
Color initVal, function onChange )
- Builds a color picker form on the passed pnl,
changes the colors of the HitProfile
]]--------------------------------------------------------
local function buildColorPicker(prnt, pnl, prfl, initVal, onChange)
pnl:Dock(FILL)
pnl:InvalidateParent(true)
pnl:SetVisible(false)
local colPick = vgui.Create("DColorMixer", pnl)
colPick:Dock(FILL)
colPick:SetBaseColor(initVal)
colPick:SetColor(initVal)
-- ISSUE: SETTING DEFAULT COLORS ISNT WORKING RIGHT
function colPick:ValueChanged(col)
onChange(col) end
return pnl
end
As I said, everything is working the way I'd like it except for the dcolormixer's color/basecolor.
I know you can't see the color mixer's changing but I have validated they with various prints.
Here is a gif below showing how the base colors don't change.
Screen capture
Sorry, you need to Log In to post a reply to this thread.