Refactored custom node parameters editor

This commit is contained in:
Rodolphe Suescun 2018-10-28 16:26:37 +01:00
parent 41fdc5783e
commit 5d80d9db63
14 changed files with 706 additions and 625 deletions

View File

@ -1 +1 @@
{"connections":[{"from":"colorize_0","from_port":0,"to":"Material","to_port":0},{"from":"custom_0","from_port":0,"to":"colorize_0","to_port":0}],"nodes":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":200,"y":0},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"contrast":1000,"model_data":{"global":"float mandelbrot(vec2 uv) {\n float di = 1.0;\n vec2 z = vec2(0.0);\n float m2 = 0.0;\n vec2 dz = vec2(0.0);\n for( int i=0; i<200; i++ )\n {\n if (m2>1024.0 ) {\n\t\t\tdi=0.0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Z' -> 2·Z·Z' + 1\n dz = 2.0*vec2(z.x*dz.x-z.y*dz.y, z.x*dz.y + z.y*dz.x) + vec2(1.0,0.0);\n\t\t\t\n // Z -> Z² + c\t\t\t\n z = vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ) + uv;\n\t\t\t\n m2 = dot(z,z);\n }\n\n // distance\t\n\t// d(c) = |Z|·log|Z|/|Z'|\n\tfloat d = 0.5*sqrt(dot(z,z)/dot(dz,dz))*log(dot(z,z));\n if( di>0.5 ) d=0.0;\n\treturn d;\n}","instance":"float $(name)_xyz(vec2 uv) {\n\treturn mandelbrot(uv);\n}","name":"Mandelbrot","outputs":[{"f":"clamp($(name)_xyz(vec2($(x), $(y))+$(scale)*(2.0*$(uv)-1.0))*$(contrast), 0.0, 1.0)"}],"parameters":[{"label":"Scale","max":3,"min":0,"name":"scale","step":0,"type":"float"},{"label":"X","max":2,"min":-2,"name":"x","step":0,"type":"float"},{"label":"Y","max":2,"min":-2,"name":"y","step":0,"type":"float"},{"label":"Label","max":1000,"min":1,"name":"contrast","step":0,"type":"float"}]},"name":"custom_0","node_position":{"x":-241,"y":223},"scale":0.046875,"type":"custom","x":0,"y":0.6875},{"gradient":{"points":[{"b":0,"g":0,"pos":0,"r":1},{"b":0,"g":0.96875,"pos":0.2,"r":1},{"b":0.0625,"g":1,"pos":0.4,"r":0},{"b":1,"g":1,"pos":0.618182,"r":0},{"b":0.965909,"g":0,"pos":0.818182,"r":0},{"b":1,"g":0,"pos":1,"r":0.9375}],"type":"Gradient"},"name":"colorize_0","node_position":{"x":1.25,"y":77.75},"type":"colorize"}]} {"connections":[{"from":"colorize_0","from_port":0,"to":"Material","to_port":0},{"from":"custom_0","from_port":0,"to":"colorize_0","to_port":0}],"nodes":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":200,"y":0},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"gradient":{"points":[{"b":0,"g":0,"pos":0,"r":1},{"b":0,"g":0.96875,"pos":0.2,"r":1},{"b":0.0625,"g":1,"pos":0.4,"r":0},{"b":1,"g":1,"pos":0.618182,"r":0},{"b":0.965909,"g":0,"pos":0.818182,"r":0},{"b":1,"g":0,"pos":1,"r":0.9375}],"type":"Gradient"},"name":"colorize_0","node_position":{"x":1.25,"y":77.75},"type":"colorize"},{"contrast":1,"model_data":{"global":"float mandelbrot(vec2 uv) {\n float di = 1.0;\n vec2 z = vec2(0.0);\n float m2 = 0.0;\n vec2 dz = vec2(0.0);\n for( int i=0; i<200; i++ )\n {\n if (m2>1024.0 ) {\n\t\t\tdi=0.0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Z' -> 2·Z·Z' + 1\n dz = 2.0*vec2(z.x*dz.x-z.y*dz.y, z.x*dz.y + z.y*dz.x) + vec2(1.0,0.0);\n\t\t\t\n // Z -> Z² + c\t\t\t\n z = vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ) + uv;\n\t\t\t\n m2 = dot(z,z);\n }\n\n // distance\t\n\t// d(c) = |Z|·log|Z|/|Z'|\n\tfloat d = 0.5*sqrt(dot(z,z)/dot(dz,dz))*log(dot(z,z));\n if( di>0.5 ) d=0.0;\n\treturn d;\n}","instance":"float $(name)_xyz(vec2 uv) {\n\treturn mandelbrot(uv);\n}","name":"Mandelbrot","outputs":[{"f":"clamp($(name)_xyz(vec2($(x), $(y))+$(scale)*(2.0*$(uv)-1.0))*$(contrast), 0.0, 1.0)"}],"parameters":[{"label":"Scale","max":3,"min":0,"name":"scale","step":0.0001,"type":"float","widget":"spinbox"},{"label":"X","max":2,"min":-2,"name":"x","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Y","max":2,"min":-2,"name":"y","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Contrast","max":10000,"min":1,"name":"contrast","step":0.0001,"type":"float","widget":"spinbox"}]},"name":"custom_0","node_position":{"x":-211,"y":208},"scale":0,"type":"custom","x":0,"y":0}]}

View File

@ -7,7 +7,7 @@
[ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5] [ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5]
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6] [ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6]
[node name="MainWindow" type="Panel"] [node name="MainWindow" type="Panel" index="0"]
anchor_left = 0.0 anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0

View File

@ -3,10 +3,10 @@ extends "res://addons/material_maker/nodes/node_generic.gd"
func _on_Edit_pressed(): func _on_Edit_pressed():
var edit_window = load("res://addons/material_maker/widgets/node_editor/node_editor.tscn").instance() var edit_window = load("res://addons/material_maker/widgets/node_editor/node_editor.tscn").instance()
add_child(edit_window)
if model_data != null: if model_data != null:
edit_window.set_model_data(model_data) edit_window.set_model_data(model_data)
edit_window.connect("node_changed", self, "update_node") edit_window.connect("node_changed", self, "update_node")
add_child(edit_window)
edit_window.popup_centered() edit_window.popup_centered()
func _on_Load_pressed(): func _on_Load_pressed():

View File

@ -78,6 +78,8 @@ func update_node(data):
var value = p.values[i] var value = p.values[i]
control.add_item(value.name) control.add_item(value.name)
control.selected = 0 if !p.has("default") else p.default control.selected = 0 if !p.has("default") else p.default
elif p.type == "boolean":
control = CheckBox.new()
if control != null: if control != null:
var label = p.name var label = p.name
control.name = label control.name = label

View File

@ -1,49 +1,11 @@
tool tool
extends HBoxContainer extends HBoxContainer
var size_first = 0
var size_last = 12
var size_default = 8
var enum_values = null
var enum_current = 0
const PARAMETER_TYPE = [ "float", "size", "enum", "boolean" ]
const ENUM_ADD = -1
const ENUM_EDIT = -2
const ENUM_REMOVE = -3
const ENUM_UP = -4
const ENUM_DOWN = -5
func _ready(): func _ready():
pass $Type.clear()
for t in $Types.get_children():
# Parameter of type SIZE $Type.add_item(t.name)
_on_Type_item_selected($Type.selected)
func update_size_option_button(button, first, last, current):
button.clear()
for i in range(first, last+1):
var s = pow(2, i)
button.add_item("%dx%d" % [ s, s ])
button.selected = current - first
func update_size_configuration():
update_size_option_button($Types/T1/First, 0, size_last, size_first)
update_size_option_button($Types/T1/Last, size_first, 12, size_last)
update_size_option_button($Types/T1/Default, size_first, size_last, size_default)
func _on_First_item_selected(ID):
size_first = ID
update_size_configuration()
func _on_Last_item_selected(ID):
size_last = size_first + ID
update_size_configuration()
func _on_Default_item_selected(ID):
size_default = size_first + ID
func set_model_data(data): func set_model_data(data):
if data.has("name"): if data.has("name"):
@ -52,121 +14,28 @@ func set_model_data(data):
$Label.text = data.label $Label.text = data.label
if !data.has("type"): if !data.has("type"):
return return
for t in $Types.get_children(): var type = $Types.get_node(data.type)
t.visible = false type.set_model_data(data)
var w = null var selected = type.get_index()
if data.type == "float": $Type.selected = selected
$Type.selected = 0 _on_Type_item_selected(selected)
w = $Types/T0
if data.has("min"):
$Types/T0/Min.value = data.min
if data.has("max"):
$Types/T0/Max.value = data.max
if data.has("step"):
$Types/T0/Step.value = data.step
$Types/T0/SpinBox.pressed = ( data.has("widget") && data.widget == "spinbox" )
elif data.type == "size":
$Type.selected = 1
w = $Types/T1
if data.has("first"):
size_first = data.first
if data.has("last"):
size_last = data.last
update_size_configuration()
elif data.type == "enum":
$Type.selected = 2
w = $Types/T2
data = data.duplicate()
enum_values = data.values
update_enum_list()
elif data.type == "boolean":
$Type.selected = 3
w = $Types/T3
if w != null:
w.visible = true
func get_model_data(): func get_model_data():
var data = { var data = $Types.get_node($Type.get_item_text($Type.selected)).get_model_data()
name=$Name.text, data.name=$Name.text
label=$Label.text, data.label=$Label.text
type=PARAMETER_TYPE[$Type.selected], data.type=$Type.get_item_text($Type.selected)
}
if $Type.selected == 0:
data.min = $Types/T0/Min.value
data.max = $Types/T0/Max.value
data.step = $Types/T0/Step.value
if $Types/T0/SpinBox.pressed:
data.widget = "spinbox"
elif $Type.selected == 1:
data.first = size_first
data.last = size_last
data.default = size_default
elif $Type.selected == 2:
data.values = enum_values
return data return data
func _on_Delete_pressed(): func _on_Delete_pressed():
queue_free() queue_free()
func _on_Type_item_selected(ID): func _on_Type_item_selected(ID):
for c in $Types.get_children(): for t in $Types.get_children():
c.visible = "T"+str(ID) == c.name t.visible = false
var t = $Types.get_child(ID)
func update_enum_list(): if t != null:
var options = $Types/T2/EnumValues t.visible = true
options.clear()
if !enum_values.empty():
for i in range(enum_values.size()):
var v = enum_values[i]
options.add_item(v.name+" ("+v.value+")", i)
options.add_separator()
var v = enum_values[enum_current]
options.add_item("Edit "+v.value, ENUM_EDIT)
options.add_item("Remove "+v.value, ENUM_REMOVE)
if enum_current > 0:
options.add_item("Move "+v.value+" up", ENUM_UP)
if enum_current < enum_values.size() - 1:
options.add_item("Move "+v.value+" down", ENUM_DOWN)
options.add_separator()
options.add_item("Add value", ENUM_ADD)
options.selected = enum_current
func _on_EnumValues_item_selected(id):
id = $Types/T2/EnumValues.get_item_id(id)
if id >= 0 and id < enum_values.size():
enum_current = id
elif id == ENUM_EDIT:
var dialog = load("res://addons/material_maker/widgets/node_editor/enum_editor.tscn").instance()
var v = enum_values[enum_current]
add_child(dialog)
dialog.set_value(v.name, v.value)
dialog.connect("ok", self, "update_enum_value", [ enum_current ])
dialog.popup_centered()
elif id == ENUM_ADD:
var dialog = load("res://addons/material_maker/widgets/node_editor/enum_editor.tscn").instance()
add_child(dialog)
dialog.connect("ok", self, "update_enum_value", [ -1 ])
dialog.popup_centered()
elif id == ENUM_REMOVE:
enum_values.remove(enum_current)
enum_current = 0
elif id == ENUM_UP:
var tmp = enum_values[enum_current]
enum_values[enum_current] = enum_values[enum_current-1]
enum_values[enum_current-1] = tmp
enum_current -= 1
elif id == ENUM_DOWN:
var tmp = enum_values[enum_current]
enum_values[enum_current] = enum_values[enum_current+1]
enum_values[enum_current+1] = tmp
enum_current += 1
update_enum_list()
func update_enum_value(n, v, i):
if i == -1:
enum_values.append({ name=n, value=v })
enum_current = enum_values.size()-1
else: else:
enum_values[i] = { name=n, value=v } print(ID)
enum_current = i
update_enum_list()

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/widgets/node_editor/parameter.gd" type="Script" id=1]
[ext_resource path="res://addons/material_maker/icons/minus.png" type="Texture" id=2] [ext_resource path="res://addons/material_maker/icons/minus.png" type="Texture" id=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_float.tscn" type="PackedScene" id=3]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_size.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_enum.tscn" type="PackedScene" id=5]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_boolean.tscn" type="PackedScene" id=6]
[node name="Parameter" type="HBoxContainer"] [node name="Parameter" type="HBoxContainer" index="0"]
anchor_left = 0.0 anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
@ -119,7 +123,7 @@ group = null
text = "Float" text = "Float"
flat = false flat = false
align = 0 align = 0
items = [ "Float", null, false, 0, null, "Size", null, false, 1, null, "Enum", null, false, 2, null, "Boolean", null, false, 3, null ] items = [ ]
selected = 0 selected = 0
[node name="Types" type="HBoxContainer" parent="." index="4"] [node name="Types" type="HBoxContainer" parent="." index="4"]
@ -129,254 +133,7 @@ anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_left = 254.0 margin_left = 254.0
margin_right = 801.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="T0" type="HBoxContainer" parent="Types" index="0"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 547.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
_sections_unfolded = [ "Visibility" ]
[node name="LabelMin" type="Label" parent="Types/T0" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 5.0
margin_right = 28.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Min:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Min" type="SpinBox" parent="Types/T0" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 32.0
margin_right = 106.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = -65536.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelMax" type="Label" parent="Types/T0" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 110.0
margin_top = 5.0
margin_right = 140.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Max:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Max" type="SpinBox" parent="Types/T0" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 144.0
margin_right = 218.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = -65536.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelStep" type="Label" parent="Types/T0" index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 222.0
margin_top = 5.0
margin_right = 254.0 margin_right = 254.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Step:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Step" type="SpinBox" parent="Types/T0" index="5"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 258.0
margin_right = 332.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = 0.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelDefault" type="Label" parent="Types/T0" index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 336.0
margin_top = 5.0
margin_right = 386.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Default:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Default" type="SpinBox" parent="Types/T0" index="7"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 390.0
margin_right = 464.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = 0.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="SpinBox" type="CheckBox" parent="Types/T0" index="8"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 468.0
margin_right = 547.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
text = "SpinBox"
flat = false
align = 0
[node name="T1" type="HBoxContainer" parent="Types" index="1"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 148.0
margin_bottom = 24.0 margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 ) rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false rect_clip_content = false
@ -386,239 +143,29 @@ size_flags_horizontal = 1
size_flags_vertical = 1 size_flags_vertical = 1
alignment = 0 alignment = 0
[node name="LabelFirst" type="Label" parent="Types/T1" index="0"] [node name="float" parent="Types" index="0" instance=ExtResource( 3 )]
anchor_left = 0.0 visible = false
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 5.0
margin_right = 28.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Min:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="First" type="OptionButton" parent="Types/T1" index="1"] [node name="size" parent="Types" index="1" instance=ExtResource( 4 )]
anchor_left = 0.0 visible = false
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 32.0
margin_right = 71.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="LabelLast" type="Label" parent="Types/T1" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 75.0
margin_top = 5.0
margin_right = 105.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Max:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Last" type="OptionButton" parent="Types/T1" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 109.0
margin_right = 148.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="LabelDefault" type="Label" parent="Types/T1" index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 551.0 margin_left = 551.0
margin_top = 5.0 margin_right = 796.0
margin_right = 581.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Default:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Default" type="OptionButton" parent="Types/T1" index="5"] [node name="enum" parent="Types" index="2" instance=ExtResource( 5 )]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 585.0
margin_right = 624.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="T2" type="HBoxContainer" parent="Types" index="2"]
visible = false visible = false
anchor_left = 0.0 margin_left = 800.0
anchor_top = 0.0 margin_right = 839.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 39.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="EnumValues" type="OptionButton" parent="Types/T2" index="0"] [node name="boolean" parent="Types" index="3" instance=ExtResource( 6 )]
anchor_left = 0.0 margin_left = 843.0
anchor_top = 0.0 margin_right = 917.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 39.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="T3" type="HBoxContainer" parent="Types" index="3"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 74.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="Default" type="CheckBox" parent="Types/T3" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 74.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
text = "Default"
flat = false
align = 0
[connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"] [connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]
[connection signal="item_selected" from="Type" to="." method="_on_Type_item_selected"] [connection signal="item_selected" from="Type" to="." method="_on_Type_item_selected"]
[connection signal="item_selected" from="Types/T1/First" to="." method="_on_First_item_selected"]
[connection signal="item_selected" from="Types/T1/Last" to="." method="_on_Last_item_selected"]
[connection signal="item_selected" from="Types/T1/Default" to="." method="_on_Default_item_selected"]
[connection signal="item_selected" from="Types/T2/EnumValues" to="." method="_on_EnumValues_item_selected"]

View File

@ -0,0 +1,12 @@
tool
extends HBoxContainer
func _ready():
pass
func get_model_data():
var data = {}
return data
func set_model_data(data):
pass

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_boolean.gd" type="Script" id=1]
[node name="boolean" type="HBoxContainer"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 74.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
script = ExtResource( 1 )
[node name="Default" type="CheckBox" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 74.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
text = "Default"
flat = false
align = 0

View File

@ -0,0 +1,82 @@
tool
extends HBoxContainer
var enum_values = [ {name="Foo", value="foo"} ]
var enum_current = 0
const ENUM_ADD = -1
const ENUM_EDIT = -2
const ENUM_REMOVE = -3
const ENUM_UP = -4
const ENUM_DOWN = -5
func _ready():
update_enum_list()
func get_model_data():
var data = {}
data.values = enum_values
return data
func set_model_data(data):
enum_values = data.values.duplicate()
update_enum_list()
func update_enum_list():
var options = $EnumValues
options.clear()
if !enum_values.empty():
for i in range(enum_values.size()):
var v = enum_values[i]
options.add_item(v.name+" ("+v.value+")", i)
options.add_separator()
var v = enum_values[enum_current]
options.add_item("Edit "+v.value, ENUM_EDIT)
options.add_item("Remove "+v.value, ENUM_REMOVE)
if enum_current > 0:
options.add_item("Move "+v.value+" up", ENUM_UP)
if enum_current < enum_values.size() - 1:
options.add_item("Move "+v.value+" down", ENUM_DOWN)
options.add_separator()
options.selected = enum_current
options.add_item("Add value", ENUM_ADD)
func _on_EnumValues_item_selected(id):
id = $EnumValues.get_item_id(id)
if id >= 0 and id < enum_values.size():
enum_current = id
elif id == ENUM_EDIT:
var dialog = load("res://addons/material_maker/widgets/node_editor/enum_editor.tscn").instance()
var v = enum_values[enum_current]
add_child(dialog)
dialog.set_value(v.name, v.value)
dialog.connect("ok", self, "update_enum_value", [ enum_current ])
dialog.popup_centered()
elif id == ENUM_ADD:
var dialog = load("res://addons/material_maker/widgets/node_editor/enum_editor.tscn").instance()
add_child(dialog)
dialog.connect("ok", self, "update_enum_value", [ -1 ])
dialog.popup_centered()
elif id == ENUM_REMOVE:
enum_values.remove(enum_current)
enum_current = 0
elif id == ENUM_UP:
var tmp = enum_values[enum_current]
enum_values[enum_current] = enum_values[enum_current-1]
enum_values[enum_current-1] = tmp
enum_current -= 1
elif id == ENUM_DOWN:
var tmp = enum_values[enum_current]
enum_values[enum_current] = enum_values[enum_current+1]
enum_values[enum_current+1] = tmp
enum_current += 1
update_enum_list()
func update_enum_value(n, v, i):
if i == -1:
enum_values.append({ name=n, value=v })
enum_current = enum_values.size()-1
else:
enum_values[i] = { name=n, value=v }
enum_current = i
update_enum_list()

View File

@ -0,0 +1,49 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_enum.gd" type="Script" id=1]
[node name="Enum" type="HBoxContainer"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 39.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
script = ExtResource( 1 )
[node name="EnumValues" type="OptionButton" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 39.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[connection signal="item_selected" from="EnumValues" to="." method="_on_EnumValues_item_selected"]

View File

@ -0,0 +1,23 @@
tool
extends HBoxContainer
func _ready():
pass
func get_model_data():
var data = {}
data.min = $Min.value
data.max = $Max.value
data.step = $Step.value
if $SpinBox.pressed:
data.widget = "spinbox"
return data
func set_model_data(data):
if data.has("min"):
$Min.value = data.min
if data.has("max"):
$Max.value = data.max
if data.has("step"):
$Step.value = data.step
$SpinBox.pressed = ( data.has("widget") && data.widget == "spinbox" )

View File

@ -0,0 +1,234 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_float.gd" type="Script" id=1]
[node name="float" type="HBoxContainer"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 547.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
script = ExtResource( 1 )
_sections_unfolded = [ "Visibility" ]
[node name="LabelMin" type="Label" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 5.0
margin_right = 28.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Min:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Min" type="SpinBox" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 32.0
margin_right = 106.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = -65536.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelMax" type="Label" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 110.0
margin_top = 5.0
margin_right = 140.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Max:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Max" type="SpinBox" parent="." index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 144.0
margin_right = 218.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = -65536.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelStep" type="Label" parent="." index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 222.0
margin_top = 5.0
margin_right = 254.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Step:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Step" type="SpinBox" parent="." index="5"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 258.0
margin_right = 332.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = 0.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="LabelDefault" type="Label" parent="." index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 336.0
margin_top = 5.0
margin_right = 386.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Default:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Default" type="SpinBox" parent="." index="7"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 390.0
margin_right = 464.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
min_value = 0.0
max_value = 65535.0
step = 0.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
editable = true
prefix = ""
suffix = ""
[node name="SpinBox" type="CheckBox" parent="." index="8"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 468.0
margin_right = 547.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
text = "SpinBox"
flat = false
align = 0

View File

@ -0,0 +1,48 @@
tool
extends HBoxContainer
var size_first = 0
var size_last = 12
var size_default = 8
func _ready():
update_size_configuration()
func get_model_data():
var data = {}
data.first = size_first
data.last = size_last
data.default = size_default
return data
func set_model_data(data):
if data.has("first"):
size_first = data.first
if data.has("last"):
size_last = data.last
if data.has("default"):
size_last = data.default
update_size_configuration()
func update_size_option_button(button, first, last, current):
button.clear()
for i in range(first, last+1):
var s = pow(2, i)
button.add_item("%dx%d" % [ s, s ])
button.selected = current - first
func update_size_configuration():
update_size_option_button($First, 0, size_last, size_first)
update_size_option_button($Last, size_first, 12, size_last)
update_size_option_button($Default, size_first, size_last, size_default)
func _on_First_item_selected(ID):
size_first = ID
update_size_configuration()
func _on_Last_item_selected(ID):
size_last = size_first + ID
update_size_configuration()
func _on_Default_item_selected(ID):
size_default = size_first + ID

View File

@ -0,0 +1,168 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_size.gd" type="Script" id=1]
[node name="size" type="HBoxContainer"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 148.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
script = ExtResource( 1 )
[node name="LabelFirst" type="Label" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 5.0
margin_right = 28.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Min:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="First" type="OptionButton" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 32.0
margin_right = 71.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="LabelLast" type="Label" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 75.0
margin_top = 5.0
margin_right = 105.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Max:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Last" type="OptionButton" parent="." index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 109.0
margin_right = 148.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[node name="LabelDefault" type="Label" parent="." index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 152.0
margin_top = 5.0
margin_right = 202.0
margin_bottom = 19.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Default:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Default" type="OptionButton" parent="." index="5"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 206.0
margin_right = 245.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
items = [ ]
selected = -1
[connection signal="item_selected" from="First" to="." method="_on_First_item_selected"]
[connection signal="item_selected" from="Last" to="." method="_on_Last_item_selected"]
[connection signal="item_selected" from="Default" to="." method="_on_Default_item_selected"]