• Derma Menu Materials Dark?
    3 replies, posted
I have tried a few things to fix this, but sadly the materials are always dark, or glitchy, never what I want. (I have tried DImage, but it doesn't like hovering and the material never shows up) [CODE] for k,v in pairs( CDoors.Materials ) do odm_mat = vgui.Create( "DPanel", odm_list ) odm_mat:SetPos( 0, 0 ) odm_mat:SetSize( 100, 100 ) odm_mat:SetText( "" ) odm_mat.DoClick = function( ) net.Start( "customdoor_stuff" ) net.WriteEntity( door ) net.WriteString( v ) net.WriteString( "Material" ) net.SendToServer() end function odm_mat:Paint() surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( Material( v ) ) surface.DrawTexturedRect( 0, 0, 100, 100 ) local new_mat = string.Split( v, "/" ) draw.SimpleText( new_mat[table.maxn(new_mat)], "DermaDefault", 50, 50, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) if self:IsHovered() then draw.RoundedBox( 0, 0, 0, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 97, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 97, 0, 3, 100, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 0, 3, 100, Color( 255, 215, 0, 255 ) ) end if door:GetMaterial() == v then draw.RoundedBox( 0, 0, 0, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 97, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 97, 0, 3, 100, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 0, 3, 100, Color( 255, 215, 0, 255 ) ) end end end[/CODE] Here is what it does; [IMG]https://steamuserimages-a.akamaihd.net/ugc/849345845411855811/50CE526B0B2B85373CDE52943D99C665373C9071/[/IMG] [editline]15th August 2017[/editline] *bump* Anyone know how to fix this problem?
Anyone?
[QUOTE=JacobsReturn;52574995]I have tried a few things to fix this, but sadly the materials are always dark, or glitchy, never what I want. (I have tried DImage, but it doesn't like hovering and the material never shows up) [CODE] for k,v in pairs( CDoors.Materials ) do odm_mat = vgui.Create( "DPanel", odm_list ) odm_mat:SetPos( 0, 0 ) odm_mat:SetSize( 100, 100 ) odm_mat:SetText( "" ) odm_mat.DoClick = function( ) net.Start( "customdoor_stuff" ) net.WriteEntity( door ) net.WriteString( v ) net.WriteString( "Material" ) net.SendToServer() end function odm_mat:Paint() surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( Material( v ) ) surface.DrawTexturedRect( 0, 0, 100, 100 ) local new_mat = string.Split( v, "/" ) draw.SimpleText( new_mat[table.maxn(new_mat)], "DermaDefault", 50, 50, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) if self:IsHovered() then draw.RoundedBox( 0, 0, 0, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 97, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 97, 0, 3, 100, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 0, 3, 100, Color( 255, 215, 0, 255 ) ) end if door:GetMaterial() == v then draw.RoundedBox( 0, 0, 0, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 97, 100, 3, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 97, 0, 3, 100, Color( 255, 215, 0, 255 ) ) draw.RoundedBox( 0, 0, 0, 3, 100, Color( 255, 215, 0, 255 ) ) end end end[/CODE] Here is what it does; [IMG]https://steamuserimages-a.akamaihd.net/ugc/849345845411855811/50CE526B0B2B85373CDE52943D99C665373C9071/[/IMG] [editline]15th August 2017[/editline] *bump* Anyone know how to fix this problem?[/QUOTE] Did this with me as well although I was using the HudPaint hook so idk if that's a common error when trying to display materials.
I just wanted to mention that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/GetFileFromFilename]string.GetFileFromFilename[/url] exists. You don't need to do [CODE] local new_mat = string.Split( v, "/" ) draw.SimpleText( new_mat[table.maxn(new_mat)], "DermaDefault", 50, 50, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) [/CODE] [editline]16th August 2017[/editline] Also, I suggest doing Material( v ) when the actual CDoors.Materials is loaded, not every single time you render it. That's very slow.
Sorry, you need to Log In to post a reply to this thread.