mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
New recent projects menu entry and paper sample texture.
This commit is contained in:
parent
b36d44eb06
commit
4baba77243
1
addons/material_maker/examples/paper.ptex
Normal file
1
addons/material_maker/examples/paper.ptex
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"connections":[{"from":"pattern_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"pattern_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":0},{"from":"colorize_1","from_port":0,"to":"blend_0","to_port":1},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"shape_0","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_2","from_port":0,"to":"transform_0","to_port":0},{"from":"perlin_1","from_port":0,"to":"transform_0","to_port":1},{"from":"colorize_3","from_port":0,"to":"blend_1","to_port":0},{"from":"transform_0","from_port":0,"to":"blend_1","to_port":1},{"from":"perlin_1","from_port":0,"to":"colorize_3","to_port":0}],"nodes":[{"name":"Material","node_position":{"x":479,"y":-5},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"pattern_1","node_position":{"x":-295.25,"y":-24.25},"parameters":{"mix":3,"x_scale":8,"x_wave":1,"y_scale":8,"y_wave":1},"type":"pattern"},{"name":"pattern_0","node_position":{"x":-303,"y":-157},"parameters":{"mix":3,"x_scale":4,"x_wave":4,"y_scale":32,"y_wave":1},"type":"pattern"},{"name":"colorize_1","node_position":{"x":-13.25,"y":-31.25},"parameters":{"gradient":{"points":[{"a":1,"b":1,"g":0.752604,"pos":0.036364,"r":0.583333},{"a":1,"b":1,"g":1,"pos":0.054545,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"colorize_0","node_position":{"x":-34,"y":-153},"parameters":{"gradient":{"points":[{"a":1,"b":1,"g":0.752604,"pos":0.054545,"r":0.583333},{"a":1,"b":1,"g":1,"pos":0.081818,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"blend_0","node_position":{"x":231,"y":5.5},"parameters":{"amount":1,"blend_type":10},"type":"blend"},{"name":"perlin_0","node_position":{"x":-27.999969,"y":111},"parameters":{"iterations":3,"persistence":0.5,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"shape_0","node_position":{"x":-300.999969,"y":281},"parameters":{"edge":0.465753,"radius":0.452055,"shape":1,"sides":4},"type":"shape"},{"name":"colorize_2","node_position":{"x":-137.999969,"y":291},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0.3,"r":0},{"a":1,"b":1,"g":1,"pos":0.509091,"r":1},{"a":1,"b":0,"g":0,"pos":0.754545,"r":0}],"type":"Gradient"}},"type":"colorize"},{"name":"perlin_1","node_position":{"x":-267.999969,"y":487},"parameters":{"iterations":6,"persistence":0.5,"scale_x":16,"scale_y":16},"type":"perlin"},{"name":"blend_1","node_position":{"x":312.000031,"y":380.5},"parameters":{"amount":1,"blend_type":0},"type":"blend"},{"name":"colorize_3","node_position":{"x":48.000031,"y":499.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":1,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"transform_0","node_position":{"x":66.000031,"y":250.5},"parameters":{"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":0.01,"translate_y":0},"type":"transform"}]}
|
@ -1,12 +1,16 @@
|
|||||||
tool
|
tool
|
||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
|
var recent_files = []
|
||||||
|
var recent_files_submenu = null
|
||||||
|
|
||||||
var editor_interface = null
|
var editor_interface = null
|
||||||
var current_tab = null
|
var current_tab = null
|
||||||
|
|
||||||
const MENU = [
|
const MENU = [
|
||||||
{ menu="File", command="new_material", description="New material" },
|
{ menu="File", command="new_material", description="New material" },
|
||||||
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
||||||
|
{ menu="File", submenu="load_recent", description="Load recent", standalone_only=true },
|
||||||
{ menu="File" },
|
{ menu="File" },
|
||||||
{ menu="File", command="save_material", shortcut="Control+S", description="Save material" },
|
{ menu="File", command="save_material", shortcut="Control+S", description="Save material" },
|
||||||
{ menu="File", command="save_material_as", shortcut="Control+Shift+S", description="Save material as..." },
|
{ menu="File", command="save_material_as", shortcut="Control+Shift+S", description="Save material as..." },
|
||||||
@ -32,6 +36,7 @@ signal quit
|
|||||||
func _ready():
|
func _ready():
|
||||||
if !Engine.editor_hint:
|
if !Engine.editor_hint:
|
||||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||||
|
load_recents()
|
||||||
for m in $VBoxContainer/Menu.get_children():
|
for m in $VBoxContainer/Menu.get_children():
|
||||||
var menu = m.get_popup()
|
var menu = m.get_popup()
|
||||||
create_menu(menu, m.name)
|
create_menu(menu, m.name)
|
||||||
@ -42,10 +47,16 @@ func create_menu(menu, menu_name):
|
|||||||
menu.clear()
|
menu.clear()
|
||||||
menu.connect("id_pressed", self, "_on_PopupMenu_id_pressed")
|
menu.connect("id_pressed", self, "_on_PopupMenu_id_pressed")
|
||||||
for i in MENU.size():
|
for i in MENU.size():
|
||||||
|
if MENU[i].has("standalone_only") and MENU[i].standalone_only and Engine.editor_hint:
|
||||||
|
continue
|
||||||
if MENU[i].menu != menu_name:
|
if MENU[i].menu != menu_name:
|
||||||
continue
|
continue
|
||||||
if MENU[i].has("submenu"):
|
if MENU[i].has("submenu"):
|
||||||
var submenu = PopupMenu.new()
|
var submenu = PopupMenu.new()
|
||||||
|
var submenu_function = "create_menu_"+MENU[i].submenu
|
||||||
|
if has_method(submenu_function):
|
||||||
|
call(submenu_function, submenu)
|
||||||
|
else:
|
||||||
create_menu(submenu, MENU[i].submenu)
|
create_menu(submenu, MENU[i].submenu)
|
||||||
menu.add_child(submenu)
|
menu.add_child(submenu)
|
||||||
menu.add_submenu_item(MENU[i].description, submenu.get_name())
|
menu.add_submenu_item(MENU[i].description, submenu.get_name())
|
||||||
@ -66,6 +77,37 @@ func create_menu(menu, menu_name):
|
|||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
func update_recents_menu():
|
||||||
|
if recent_files_submenu != null:
|
||||||
|
recent_files_submenu.clear()
|
||||||
|
for i in recent_files.size():
|
||||||
|
recent_files_submenu.add_item(recent_files[i], i)
|
||||||
|
|
||||||
|
func create_menu_load_recent(menu):
|
||||||
|
menu.connect("id_pressed", self, "_on_LoadRecent_id_pressed")
|
||||||
|
recent_files_submenu = menu
|
||||||
|
update_recents_menu()
|
||||||
|
|
||||||
|
func load_recents():
|
||||||
|
var f = File.new()
|
||||||
|
if f.open("user://recent_files.bin", File.READ) == OK:
|
||||||
|
recent_files = parse_json(f.get_as_text())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
func add_recent(path):
|
||||||
|
while true:
|
||||||
|
var index = recent_files.find(path)
|
||||||
|
if index >= 0:
|
||||||
|
recent_files.remove(index)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
recent_files.push_front(path)
|
||||||
|
update_recents_menu()
|
||||||
|
var f = File.new()
|
||||||
|
f.open("user://recent_files.bin", File.WRITE)
|
||||||
|
f.store_string(to_json(recent_files))
|
||||||
|
f.close()
|
||||||
|
|
||||||
func menu_about_to_show(name, menu):
|
func menu_about_to_show(name, menu):
|
||||||
for i in MENU.size():
|
for i in MENU.size():
|
||||||
if MENU[i].menu != name:
|
if MENU[i].menu != name:
|
||||||
@ -120,6 +162,7 @@ func do_load_material(filename):
|
|||||||
if node_count > 1:
|
if node_count > 1:
|
||||||
graph_edit = new_pane()
|
graph_edit = new_pane()
|
||||||
graph_edit.do_load_file(filename)
|
graph_edit.do_load_file(filename)
|
||||||
|
add_recent(filename)
|
||||||
|
|
||||||
func save_material():
|
func save_material():
|
||||||
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
||||||
@ -235,6 +278,9 @@ func _on_PopupMenu_id_pressed(id):
|
|||||||
if has_method(command):
|
if has_method(command):
|
||||||
call(command)
|
call(command)
|
||||||
|
|
||||||
|
func _on_LoadRecent_id_pressed(id):
|
||||||
|
do_load_material(recent_files[id])
|
||||||
|
|
||||||
# Preview
|
# Preview
|
||||||
|
|
||||||
func update_preview():
|
func update_preview():
|
||||||
|
Loading…
Reference in New Issue
Block a user