• Colored DFrame
    11 replies, posted
Hello Again. So today i come to you with a question about DFrames, is it possible to have them turn different colors, and same thing with DButtons? I am new to coding and i can't find anything on the wiki about it. Thanks in advanced -Tobias
VGUI panels' drawing can be altered by using the function Paint for example... [code]function DFrame:Paint( Width, Height ) -- Draw just as you would with the hook HUDPaint end[/code]
Hi, Also maybe you should use the ApplySchemeSettings hook (search on google for some examples)
[code]local frame = vgui.Create("DFrame") function frame:Paint() draw.RoundedBox(blah blah with colors) end[/code]
You can do exactly how 'McDunkable' did his, I personally prefer DFrame.Paint, EX: [code] DFrame.Paint = function() draw.RoundedBox(0,0,0,DFrame:GetWide(),DFrame:GetTall(),Color(255,255,255,255)) end [/code] Probably the best way for beginners. You should also look into creating and applying skins.
[QUOTE=Gmremie;44708176]You can do exactly how 'McDunkable' did his, I personally prefer DFrame.Paint, EX: [code] DFrame.Paint = function() draw.RoundedBox(0,0,0,DFrame:GetWide(),DFrame:GetTall(),Color(255,255,255,255)) end [/code] Probably the best way for beginners. You should also look into creating and applying skins.[/QUOTE] Thank you so much, this worked for me very well. [editline]2nd May 2014[/editline] Ok. now when i open the equipment menu, i get this error [ERROR] gamemodes/terrortown/gamemode/cl_search.lua:288: calling 'GetWide' on bad self (Panel expected, got table) 1. GetWide - [C]:-1 2. unknown - gamemodes/terrortown/gamemode/cl_search.lua:288 I tried switching GetWide, to get Width, but nothing happened. Any suggestions?
Use [lua] DFrame.Paint = function(panel, w, h) draw.RoundedBox(0, 0, 0, w, h, color_white) end [/lua]
[QUOTE=Chessnut;44708307]Use [lua] DFrame.Paint = function(panel, w, h) draw.RoundedBox(0, 0, 0, w, h, color_white) end [/lua][/QUOTE] Thanks, no errors with this one
[CODE] function DFrame:Paint( w, h ) [/CODE] is how the cool kids do it. (on a serious note they're pretty close to exactly the same thing only this one automatically puts the panel in a variable called self. It's really just a matter of preference... And coolness)
[QUOTE=thelastpenguin;44708603][CODE] function DFrame:Paint( w, h ) [/CODE] is how the cool kids do it. (on a serious note they're pretty close to exactly the same thing only this one automatically puts the panel in a variable called self. It's really just a matter of preference... And coolness)[/QUOTE] I really don't get why people insist on using Frame.Paint = function() you're just creating a reference to an anonymous function? Just use function Frame:Paint(...)
I use frame.Paint = function() because in my opinion it's easier on the eyes. It's more up to preference, and there is no one "set right way" to do something.
Thank you to everyone that helped! I will be marking this as Solved
Sorry, you need to Log In to post a reply to this thread.