@@ -418,7 +418,7 @@ local function populate_bookmarks(menu, mode, self)
418418 local mat_no_ext = string .StripExtension (string.sub (file ,11 ,# file )) -- "materials/"
419419 local option = menu3 :AddOption (mat_no_ext , function ()
420420 self :SetValue (mat_no_ext )
421- pace .current_part :SetProperty (self .CurrentKey , str )
421+ pace .current_part :SetProperty (self .CurrentKey , mat_no_ext )
422422 end ) option :SetMaterial (mat_no_ext )
423423 if preview_hovers :GetBool () then install_generic_preview_hover (option , self .CurrentKey , mat_no_ext ) end
424424 end
@@ -476,10 +476,62 @@ local function populate_bookmarks(menu, mode, self)
476476 end
477477
478478 if self .CurrentKey == " Material" and pace .current_part .ClassName == " particles" then
479- pnl :SetTooltip (" Appropriate shaders for particles are UnlitGeneric materials.\n OOtherwise , they should usually be additive or use VertexAlpha" )
479+ pnl :SetTooltip (" Appropriate shaders for particles are UnlitGeneric materials.\n Otherwise , they should usually be additive or use VertexAlpha" )
480480 elseif self .CurrentKey == " SpritePath" then
481- pnl :SetTooltip (" Appropriate shaders for sprites are UnlitGeneric materials.\n OOtherwise , they should usually be additive or use VertexAlpha" )
481+ pnl :SetTooltip (" Appropriate shaders for sprites are UnlitGeneric materials.\n Otherwise , they should usually be additive or use VertexAlpha" )
482482 end
483+
484+ local part_material = pace .current_part :GetProperty (self .CurrentKey )
485+ local mat_name = part_material :match (" .+/(.+)" ) or " "
486+
487+ mat_name = mat_name .. " _" .. string.sub (pace .current_part .UniqueID ,1 ,6 )
488+ mat_name = string .Replace (mat_name , " " , " " )
489+ local material_class = " material_2d"
490+ -- models will use vertexlitgeneric
491+ if pace .current_part .is_model_part or pace .current_part .is_entity_part then
492+ material_class = " material_3d"
493+ end
494+
495+ local function create_material (path , shader )
496+ local newmaterial = pac .CreatePart (shader , pace .current_part )
497+ if self .CurrentKey == " SpritePath" then
498+ newmaterial :SetParent (pace .current_part :GetParent ())
499+ newmaterial :SetDrawOrder (pace .current_part :GetDrawOrder () - 1 )
500+ end
501+ newmaterial :SetName (mat_name )
502+ newmaterial :SetProperty (" LoadVmt" , path )
503+ pace .current_part :SetProperty (self .CurrentKey , mat_name )
504+
505+ return newmaterial
506+ end
507+
508+ local menu2 , pnl = menu :AddSubMenu (" Edit Material (will be named " .. mat_name .. " )" , function ()
509+ create_material (part_material , material_class )
510+ end )
511+ pnl :SetImage (" icon16/paintcan.png" )
512+ pnl :SetTooltip (material_class )
513+
514+ -- duplicate in case people don't know they can click the parent submenu
515+ menu2 :AddOption (" simple load VMT (" .. material_class .. " )" , function ()
516+ create_material (part_material , material_class )
517+ end ):SetImage (" icon16/paintcan.png" )
518+
519+ local menu3 , pnl2 = menu2 :AddSubMenu (" choose specific shader..." )
520+ pnl2 :SetImage (" icon16/chart_organisation.png" )
521+ menu3 :AddOption (" material_3d" , function () create_material (part_material , " material_3d" ) end ):SetImage (" icon16/paintcan.png" )
522+ menu3 :AddOption (" material_2d" , function () create_material (part_material , " material_2d" ) end ):SetImage (" icon16/paintcan.png" )
523+ menu3 :AddOption (" material_refract" , function () create_material (part_material , " material_refract" ) end ):SetImage (" icon16/paintcan.png" )
524+ menu3 :AddOption (" material_eyerefract" , function () create_material (part_material , " material_eyerefract" ) end ):SetImage (" icon16/paintcan.png" )
525+
526+ menu2 :AddOption (" Make transparent (vertex alpha) (for transparent textures)" , function ()
527+ local newmaterial = create_material (part_material , material_class )
528+ newmaterial :Setvertexalpha (true )
529+ end ):SetImage (" icon16/paintcan.png" )
530+
531+ menu2 :AddOption (" Make transparent (additive) (for black backgrounds)" , function ()
532+ local newmaterial = create_material (part_material , material_class )
533+ newmaterial :Setadditive (true )
534+ end ):SetImage (" icon16/paintcan.png" )
483535 elseif mode == " sound" then
484536 pace .bookmarked_ressources = pace .bookmarked_ressources or {}
485537 if not pace .bookmarked_ressources [" sound" ] then
@@ -2387,51 +2439,6 @@ do -- base editable
23872439
23882440 if self .udata .editor_panel == " material" then
23892441 populate_bookmarks (menu , " materials" , self )
2390-
2391- local part_material = pace .current_part :GetProperty (self .CurrentKey )
2392- local mat_name = part_material :match (" .+/(.+)" ) or " "
2393- mat_name = mat_name .. " _" .. string.sub (pace .current_part .UniqueID ,1 ,6 )
2394- mat_name = string .Replace (mat_name , " " , " " )
2395- local menu2 , pnl = menu :AddSubMenu (" Edit Material (will be named " .. mat_name .. " )" , function ()
2396- local newmaterial = pac .CreatePart (" material_2d" )
2397- if self .CurrentKey == " SpritePath" then
2398- newmaterial :SetParent (pace .current_part :GetParent ())
2399- newmaterial :SetDrawOrder (pace .current_part :GetDrawOrder () - 1 )
2400- else
2401- newmaterial :SetParent (pace .current_part )
2402- end
2403- newmaterial :SetName (mat_name )
2404- newmaterial :SetProperty (" LoadVmt" , part_material )
2405- pace .current_part :SetProperty (self .CurrentKey , mat_name )
2406- end )
2407- pnl :SetImage (" icon16/paintcan.png" )
2408-
2409- menu2 :AddOption (" Make transparent (vertex alpha) (for transparent textures)" , function ()
2410- local newmaterial = pac .CreatePart (" material_2d" )
2411- if self .CurrentKey == " SpritePath" then
2412- newmaterial :SetParent (pace .current_part :GetParent ())
2413- newmaterial :SetDrawOrder (pace .current_part :GetDrawOrder () - 1 )
2414- else
2415- newmaterial :SetParent (pace .current_part )
2416- end
2417- newmaterial :SetName (mat_name )
2418- newmaterial :SetProperty (" LoadVmt" , part_material )
2419- pace .current_part :SetProperty (self .CurrentKey , mat_name )
2420- newmaterial :Setvertexalpha (true )
2421- end ):SetImage (" icon16/paintcan.png" )
2422- menu2 :AddOption (" Make transparent (additive) (for black backgrounds)" , function ()
2423- local newmaterial = pac .CreatePart (" material_2d" )
2424- if self .CurrentKey == " SpritePath" then
2425- newmaterial :SetParent (pace .current_part :GetParent ())
2426- newmaterial :SetDrawOrder (pace .current_part :GetDrawOrder () - 1 )
2427- else
2428- newmaterial :SetParent (pace .current_part )
2429- end
2430- newmaterial :SetName (mat_name )
2431- newmaterial :SetProperty (" LoadVmt" , part_material )
2432- pace .current_part :SetProperty (self .CurrentKey , mat_name )
2433- newmaterial :Setadditive (true )
2434- end ):SetImage (" icon16/paintcan.png" )
24352442 end
24362443
24372444 if string.find (pace .current_part .ClassName , " sound" ) then
0 commit comments