diff --git a/addons/material_maker/engine/gen_base.gd b/addons/material_maker/engine/gen_base.gd index a85fd13..acc3eab 100644 --- a/addons/material_maker/engine/gen_base.gd +++ b/addons/material_maker/engine/gen_base.gd @@ -116,6 +116,9 @@ func get_parameter_def(param_name : String) -> Dictionary: return p return {} +func get_parameter(n : String): + return parameters[n] + func set_parameter(n : String, v) -> void: parameters[n] = v source_changed(0) diff --git a/addons/material_maker/graph_edit.gd b/addons/material_maker/graph_edit.gd index bfcc056..bd28cd9 100644 --- a/addons/material_maker/graph_edit.gd +++ b/addons/material_maker/graph_edit.gd @@ -10,6 +10,8 @@ var need_save = false var top_generator = null var generator = null +var last_selected = null + onready var timer : Timer = $Timer onready var subgraph_ui : HBoxContainer = $GraphUI/SubGraphUI @@ -354,3 +356,16 @@ func edit_subgraph(g : MMGenGraph) -> void: func _on_ButtonTransmitsSeed_toggled(button_pressed) -> void: if button_pressed != generator.transmits_seed: generator.transmits_seed = button_pressed + +func _on_GraphEdit_node_selected(node) -> void: + last_selected = node + +func _on_GraphEdit_gui_input(event) -> void: + if event is InputEventMouseButton: + call_deferred("check_last_selected") + +func check_last_selected() -> void: + if last_selected != null and !(is_instance_valid(last_selected) && last_selected.selected): + print("Unselected") + last_selected = null + emit_signal("node_selected", null) \ No newline at end of file diff --git a/addons/material_maker/graph_edit.tscn b/addons/material_maker/graph_edit.tscn index c2bc1ed..9319a45 100644 --- a/addons/material_maker/graph_edit.tscn +++ b/addons/material_maker/graph_edit.tscn @@ -79,6 +79,8 @@ icon = SubResource( 4 ) [connection signal="connection_request" from="." to="." method="connect_node"] [connection signal="disconnection_request" from="." to="." method="disconnect_node"] [connection signal="duplicate_nodes_request" from="." to="." method="duplicate_selected"] +[connection signal="gui_input" from="." to="." method="_on_GraphEdit_gui_input"] +[connection signal="node_selected" from="." to="." method="_on_GraphEdit_node_selected"] [connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"] [connection signal="text_changed" from="GraphUI/SubGraphUI/Label" to="." method="_on_Label_text_changed"] [connection signal="toggled" from="GraphUI/SubGraphUI/ButtonTransmitsSeed" to="." method="_on_ButtonTransmitsSeed_toggled"] diff --git a/addons/material_maker/icons/icons.svg b/addons/material_maker/icons/icons.svg index ad9aa94..31fb4ee 100644 --- a/addons/material_maker/icons/icons.svg +++ b/addons/material_maker/icons/icons.svg @@ -15,7 +15,7 @@ viewBox="0 0 128 128" version="1.1" id="svg8" - inkscape:version="0.92.3 (2405546, 2018-03-11)" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" sodipodi:docname="icons.svg"> @@ -55,9 +55,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="28.608854" - inkscape:cx="54.703743" - inkscape:cy="64.734209" + inkscape:zoom="20.229515" + inkscape:cx="12.288977" + inkscape:cy="55.740147" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -86,7 +86,7 @@ image/svg+xml - + @@ -525,5 +525,15 @@ id="path4610" inkscape:connector-curvature="0" sodipodi:nodetypes="ccczccccczccc" /> + + diff --git a/addons/material_maker/library/base.json b/addons/material_maker/library/base.json index adf3eb7..ee289d6 100644 --- a/addons/material_maker/library/base.json +++ b/addons/material_maker/library/base.json @@ -739,7 +739,6 @@ "cx": 0, "cy": 0, "h": 0.2, - "r": 0.3, "w": 0.3 }, "tree_item": "Simple/SDF/Shapes/sdBox", @@ -750,15 +749,10 @@ "icon": "simple_sdf_shapes_sdline", "name": "sdline", "parameters": { - "ax": 0.2, - "ay": 0.2, - "bx": 0.8, - "by": 0.8, - "cx": 0, - "cy": 0, - "h": 0.2, - "r": 0.3, - "w": 0.3 + "ax": -0.3, + "ay": -0.3, + "bx": 0.3, + "by": 0.3 }, "tree_item": "Simple/SDF/Shapes/sdLine", "type": "sdline" @@ -771,7 +765,6 @@ "cx": 0, "cy": 0, "h": 0.2, - "r": 0.3, "w": 0.3 }, "tree_item": "Simple/SDF/Shapes/sdRhombus", diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index 8b7107e..0139047 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -488,6 +488,8 @@ func update_preview_2d(node = null) -> void: result.copy_to_texture(tex) result.release() preview_2d.set_preview_texture(tex) + else: + preview_2d.set_preview_texture(null) func update_preview_3d(previews : Array) -> void: var graph_edit : MMGraphEdit = get_current_graph_edit() @@ -499,6 +501,10 @@ func update_preview_3d(previews : Array) -> void: for p in previews: gen_material.update_materials(p.get_materials()) +func on_selected_node_change(node) -> void: + preview_2d.setup_controls(node.generator if node != null else null) + update_preview_2d(node) + func _on_Projects_tab_changed(tab) -> void: var new_tab = projects.get_current_tab_control() if new_tab != current_tab: @@ -507,7 +513,7 @@ func _on_Projects_tab_changed(tab) -> void: if c.method_name == "update_preview" or c.method_name == "update_preview_2d": c.source.disconnect(c.signal_name, self, c.method_name) new_tab.connect("graph_changed", self, "update_preview") - new_tab.connect("node_selected", self, "update_preview_2d") + new_tab.connect("node_selected", self, "on_selected_node_change") current_tab = new_tab update_preview() diff --git a/addons/material_maker/nodes/base.gd b/addons/material_maker/nodes/base.gd index 60c177e..bd3086e 100644 --- a/addons/material_maker/nodes/base.gd +++ b/addons/material_maker/nodes/base.gd @@ -7,6 +7,9 @@ var generator : MMGenBase = null setget set_generator func _ready() -> void: connect("offset_changed", self, "_on_offset_changed") +func _exit_tree() -> void: + get_parent().call_deferred("check_last_selected") + func _draw() -> void: if generator != null and generator.has_randomness(): var icon = preload("res://addons/material_maker/icons/randomness_locked.tres") if generator.is_seed_locked() else preload("res://addons/material_maker/icons/randomness_unlocked.tres") diff --git a/addons/material_maker/nodes/sdannularshape.mmg b/addons/material_maker/nodes/sdannularshape.mmg index 12124a2..4d20335 100644 --- a/addons/material_maker/nodes/sdannularshape.mmg +++ b/addons/material_maker/nodes/sdannularshape.mmg @@ -35,6 +35,7 @@ ], "parameters": [ { + "control": "Radius1.x", "default": 0, "label": "", "max": 1, diff --git a/addons/material_maker/nodes/sdarc.mmg b/addons/material_maker/nodes/sdarc.mmg index 6bb49ba..79b96d6 100644 --- a/addons/material_maker/nodes/sdarc.mmg +++ b/addons/material_maker/nodes/sdarc.mmg @@ -6,12 +6,12 @@ }, "parameters": { "a1": 0, - "a2": 0, + "a2": -50, "cx": 0, "cy": 0, "r": 0.4, - "r1": 0.3, - "r2": 0.1 + "r1": 0.29021, + "r2": 0.075098 }, "shader_model": { "code": "", @@ -29,6 +29,7 @@ ], "parameters": [ { + "control": "None", "default": 0, "label": "Angle 1", "max": 180, @@ -38,6 +39,7 @@ "type": "float" }, { + "control": "None", "default": 0, "label": "Angle 2", "max": 180, @@ -47,6 +49,7 @@ "type": "float" }, { + "control": "Radius1.x", "default": 0.5, "label": "Radius 1", "max": 1, @@ -56,6 +59,7 @@ "type": "float" }, { + "control": "Radius11.x", "default": 0.1, "label": "Radius 2", "max": 1, diff --git a/addons/material_maker/nodes/sdbox.mmg b/addons/material_maker/nodes/sdbox.mmg index 9592fdc..e6f92ea 100644 --- a/addons/material_maker/nodes/sdbox.mmg +++ b/addons/material_maker/nodes/sdbox.mmg @@ -12,7 +12,7 @@ "w": 0.3 }, "shader_model": { - "code": "vec2 $(name_uv)_d = abs($uv-0.5*vec2($cx+1.0, $cy+1.0))-vec2($w, $h);\n", + "code": "vec2 $(name_uv)_d = abs($uv-vec2($cx+0.5, $cy+0.5))-vec2($w, $h);\n", "global": "", "inputs": [ @@ -27,6 +27,7 @@ ], "parameters": [ { + "control": "Rect1.x", "default": 0.5, "label": "Width", "max": 1, @@ -36,6 +37,7 @@ "type": "float" }, { + "control": "Rect1.y", "default": 1, "label": "Height", "max": 1, @@ -45,6 +47,7 @@ "type": "float" }, { + "control": "P1.x", "default": 0, "label": "Center X", "max": 1, @@ -54,6 +57,7 @@ "type": "float" }, { + "control": "P1.y", "default": 0, "label": "Center Y", "max": 1, diff --git a/addons/material_maker/nodes/sdcircle.mmg b/addons/material_maker/nodes/sdcircle.mmg index e9881b5..923a960 100644 --- a/addons/material_maker/nodes/sdcircle.mmg +++ b/addons/material_maker/nodes/sdcircle.mmg @@ -7,7 +7,7 @@ "parameters": { "cx": 0, "cy": 0, - "r": 0.25 + "r": 0.4 }, "shader_model": { "code": "", @@ -19,12 +19,13 @@ "name": "sdCircle", "outputs": [ { - "sdf2d": "length($uv-0.5*vec2($cx+1.0, $cy+1.0))-$r", + "sdf2d": "length($uv-vec2($cx+0.5, $cy+0.5))-$r", "type": "sdf2d" } ], "parameters": [ { + "control": "Radius1.x", "default": 0.5, "label": "Radius", "max": 1, @@ -34,6 +35,7 @@ "type": "float" }, { + "control": "P1.x", "default": 0, "label": "Center X", "max": 1, @@ -43,6 +45,7 @@ "type": "float" }, { + "control": "P1.y", "default": 0, "label": "Center Y", "max": 1, diff --git a/addons/material_maker/nodes/sdline.mmg b/addons/material_maker/nodes/sdline.mmg index 763df54..aded4bf 100644 --- a/addons/material_maker/nodes/sdline.mmg +++ b/addons/material_maker/nodes/sdline.mmg @@ -5,10 +5,10 @@ "y": 0 }, "parameters": { - "ax": 0.2, - "ay": 0.2, - "bx": 0.8, - "by": 0.8, + "ax": 0.224, + "ay": 0.2672, + "bx": -0.272, + "by": -0.2344, "cx": 0, "cy": 0, "h": 0.2, @@ -25,43 +25,47 @@ "name": "sdLine", "outputs": [ { - "sdf2d": "sdLine($uv, vec2($ax, $ay), vec2($bx, $by))", + "sdf2d": "sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5))", "type": "sdf2d" } ], "parameters": [ { + "control": "P1.x", "default": 0, "label": "A X", "max": 1, - "min": 0, + "min": -1, "name": "ax", "step": 0.01, "type": "float" }, { + "control": "P1.y", "default": 0, "label": "A Y", "max": 1, - "min": 0, + "min": -1, "name": "ay", "step": 0.01, "type": "float" }, { + "control": "P2.x", "default": 1, "label": "B X", "max": 1, - "min": 0, + "min": -1, "name": "bx", "step": 0.01, "type": "float" }, { + "control": "P2.y", "default": 1, "label": "B Y", "max": 1, - "min": 0, + "min": -1, "name": "by", "step": 0.01, "type": "float" diff --git a/addons/material_maker/nodes/sdrhombus.mmg b/addons/material_maker/nodes/sdrhombus.mmg index 02925e1..13029a9 100644 --- a/addons/material_maker/nodes/sdrhombus.mmg +++ b/addons/material_maker/nodes/sdrhombus.mmg @@ -5,11 +5,11 @@ "y": 0 }, "parameters": { - "cx": 0, - "cy": 0, - "h": 0.2, + "cx": -0.19353, + "cy": -0.224011, + "h": 0.187815, "r": 0.3, - "w": 0.5 + "w": 0.393785 }, "shader_model": { "code": "", @@ -21,12 +21,13 @@ "name": "sdRhombus", "outputs": [ { - "sdf2d": "sdRhombus($uv-0.5*vec2($cx+1.0, $cy+1.0), vec2($w, $h))", + "sdf2d": "sdRhombus($uv-vec2($cx+0.5, $cy+0.5), vec2($w, $h))", "type": "sdf2d" } ], "parameters": [ { + "control": "Rect1.x", "default": 0.5, "label": "Width", "max": 1, @@ -36,6 +37,7 @@ "type": "float" }, { + "control": "Rect1.y", "default": 1, "label": "Height", "max": 1, @@ -45,6 +47,7 @@ "type": "float" }, { + "control": "P1.x", "default": 0, "label": "Center X", "max": 1, @@ -54,6 +57,7 @@ "type": "float" }, { + "control": "P1.y", "default": 0, "label": "Center Y", "max": 1, diff --git a/addons/material_maker/nodes/sdroundedshape.mmg b/addons/material_maker/nodes/sdroundedshape.mmg index 80305a4..898bd82 100644 --- a/addons/material_maker/nodes/sdroundedshape.mmg +++ b/addons/material_maker/nodes/sdroundedshape.mmg @@ -11,7 +11,7 @@ "h": 0.08, "k": 0.15, "op": 0, - "r": 0.1, + "r": 0.15, "w": 0.28 }, "shader_model": { @@ -35,6 +35,7 @@ ], "parameters": [ { + "control": "Radius1.x", "default": 0, "label": "", "max": 1, diff --git a/addons/material_maker/nodes/sdscale.mmg b/addons/material_maker/nodes/sdscale.mmg index 0b5c875..6ffe6a2 100644 --- a/addons/material_maker/nodes/sdscale.mmg +++ b/addons/material_maker/nodes/sdscale.mmg @@ -6,7 +6,7 @@ }, "parameters": { "a": 0, - "s": 2.21, + "s": 1, "x": 0.35, "y": 0, "z": 0 @@ -32,6 +32,7 @@ ], "parameters": [ { + "control": "Scale1.x", "default": 1, "label": "", "max": 5, diff --git a/addons/material_maker/nodes/sdtranslate.mmg b/addons/material_maker/nodes/sdtranslate.mmg index a4b72f7..2dd0563 100644 --- a/addons/material_maker/nodes/sdtranslate.mmg +++ b/addons/material_maker/nodes/sdtranslate.mmg @@ -5,8 +5,8 @@ "y": 0 }, "parameters": { - "x": 0, - "y": 0, + "x": 0.024, + "y": 0.024, "z": 0 }, "shader_model": { @@ -30,6 +30,7 @@ ], "parameters": [ { + "control": "P1.x", "default": 0, "label": "X", "max": 1, @@ -39,6 +40,7 @@ "type": "float" }, { + "control": "P1.y", "default": 0, "label": "Y", "max": 1, diff --git a/addons/material_maker/preview/control_point.gd b/addons/material_maker/preview/control_point.gd new file mode 100644 index 0000000..8845b1e --- /dev/null +++ b/addons/material_maker/preview/control_point.gd @@ -0,0 +1,112 @@ +extends TextureRect + +export var parent_control : String = "" +export(int, "Simple", "Rect", "Radius", "Scale", "ScaleXY" ) var control_type : int = 0 + +var generator : MMGenBase = null +var parameter_x : String = "" +var parameter_y : String = "" +var dragging = false + +var parent_control_node = null +var children_control_nodes = [] + +func _ready() -> void: + if parent_control != "": + parent_control_node = get_parent().get_node(parent_control) + if parent_control_node != null: + parent_control_node.children_control_nodes.push_back(self) + +func _draw() -> void: + match control_type: + 1: # Rect + var ppos = parent_control_node.rect_position+0.5*parent_control_node.rect_size + draw_rect(Rect2(0.5*rect_size, 2.0*(ppos-(rect_position+0.5*rect_size))), modulate, false) + 2: # Radius + draw_line(0.5*rect_size, 0.5*rect_size-get_parent().value_to_offset(get_value()), modulate) + 3: # Scale + draw_line(0.5*rect_size, 0.5*rect_size-get_parent().value_to_offset(0.25*get_value()), modulate) + 4: # ScaleXY + var ppos = parent_control_node.rect_position+0.5*parent_control_node.rect_size + draw_rect(Rect2(0.5*rect_size, ppos-(rect_position+0.5*rect_size)), modulate, false) + +func setup_control(g : MMGenBase, param_defs : Array) -> void: + hide() + if is_instance_valid(generator): + generator.disconnect("parameter_changed", self, "on_parameter_changed") + generator = g + parameter_x = "" + parameter_y = "" + for p in param_defs: + if p.has("control"): + if p.control == name+".x": + show() + parameter_x = p.name + elif p.control == name+".y": + show() + parameter_y = p.name + if visible: + generator.connect("parameter_changed", self, "on_parameter_changed") + update_position(get_value()) + else: + generator = null + update_position(Vector2(0, 0)) + +func get_value() -> Vector2: + var pos : Vector2 = Vector2(0, 0) + if is_instance_valid(generator): + if parameter_x != "": + pos.x = generator.get_parameter(parameter_x) + if parameter_y != "": + pos.y = generator.get_parameter(parameter_y) + return pos + +func on_parameter_changed(p, v) -> void: + if !dragging and (p == parameter_x or p == parameter_y): + update_position(get_value()) + update() + +func update_parameters(pos : Vector2) -> void: + if !is_instance_valid(generator): + return + if parent_control_node != null: + pos -= parent_control_node.get_value() + match control_type: + 1: # Rect + pos.x = abs(pos.x) + pos.y = abs(pos.y) + 3: # Scale + pos.x = 4.0*pos.x + if parameter_x != "": + generator.set_parameter(parameter_x, pos.x) + if parameter_y != "": + generator.set_parameter(parameter_y, pos.y) + +func update_position(pos : Vector2) -> void: + match control_type: + 3: # Scale + pos *= 0.25 + if parent_control_node != null: + pos += parent_control_node.get_value() + rect_position = get_parent().value_to_pos(pos+Vector2(0.5, 0.5))-0.5*rect_size + for c in children_control_nodes: + c.update_position(c.get_value()) + update() + +func _on_Point_gui_input(event : InputEvent): + if event is InputEventMouseMotion and event.button_mask == BUTTON_MASK_LEFT: + rect_position += event.relative + match control_type: + 2: # Radius + rect_position.x = max(rect_position.x, parent_control_node.rect_position.x+0.5*(parent_control_node.rect_size.x-rect_size.x)) + rect_position.y = parent_control_node.rect_position.y+0.5*(parent_control_node.rect_size.y-rect_size.y) + 3: # Scale + rect_position.x = max(rect_position.x, parent_control_node.rect_position.x+0.5*(parent_control_node.rect_size.x-rect_size.x)) + rect_position.y = parent_control_node.rect_position.y+0.5*(parent_control_node.rect_size.y-rect_size.y) + var pos = get_parent().pos_to_value(rect_position+0.5*rect_size)-Vector2(0.5, 0.5) + dragging = true + update_parameters(pos) + update() + dragging = false + for c in children_control_nodes: + c.update_position(c.get_value()) diff --git a/addons/material_maker/preview/control_point.tscn b/addons/material_maker/preview/control_point.tscn new file mode 100644 index 0000000..001ce32 --- /dev/null +++ b/addons/material_maker/preview/control_point.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/material_maker/preview/control_point.gd" type="Script" id=1] + +[node name="Point" type="TextureRect"] +mouse_filter = 0 +mouse_default_cursor_shape = 13 +script = ExtResource( 1 ) +[connection signal="gui_input" from="." to="." method="_on_Point_gui_input"] diff --git a/addons/material_maker/preview/preview_2d.gd b/addons/material_maker/preview/preview_2d.gd index f687363..a70f161 100644 --- a/addons/material_maker/preview/preview_2d.gd +++ b/addons/material_maker/preview/preview_2d.gd @@ -1,8 +1,31 @@ tool extends ColorRect +var generator = null + func set_preview_texture(tex: Texture) -> void: material.set_shader_param("tex", tex) func on_resized() -> void: material.set_shader_param("size", rect_size) + setup_controls(generator) + +func setup_controls(g : MMGenBase) -> void: + if is_instance_valid(g): + generator = g + var param_defs : Array = generator.get_parameter_defs() + for c in get_children(): + c.setup_control(generator, param_defs) + else: + g = null + for c in get_children(): + c.setup_control(generator, []) + +func value_to_pos(value : Vector2) -> Vector2: + return rect_size*0.5+(value-Vector2(0.5, 0.5))*min(rect_size.x, rect_size.y)/1.2 + +func value_to_offset(value : Vector2) -> Vector2: + return value*min(rect_size.x, rect_size.y)/1.2 + +func pos_to_value(pos : Vector2) -> Vector2: + return (pos - rect_size*0.5)*1.2/min(rect_size.x, rect_size.y)+Vector2(0.5, 0.5) diff --git a/addons/material_maker/preview/preview_2d.tscn b/addons/material_maker/preview/preview_2d.tscn index 3b84e68..bcb8872 100644 --- a/addons/material_maker/preview/preview_2d.tscn +++ b/addons/material_maker/preview/preview_2d.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://addons/material_maker/preview/preview_2d.gd" type="Script" id=1] +[ext_resource path="res://addons/material_maker/preview/control_point.tscn" type="PackedScene" id=2] +[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=3] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -17,17 +19,77 @@ void fragment() { [sub_resource type="ShaderMaterial" id=2] shader = SubResource( 1 ) -shader_param/size = Vector2( 64, 64 ) +shader_param/size = Vector2( 721, 546 ) + +[sub_resource type="AtlasTexture" id=3] +flags = 4 +atlas = ExtResource( 3 ) +region = Rect2( 64, 48, 32, 32 ) + +[sub_resource type="AtlasTexture" id=4] +flags = 4 +atlas = ExtResource( 3 ) +region = Rect2( 0, 64, 16, 16 ) [node name="Preview2D" type="ColorRect"] material = SubResource( 2 ) anchor_right = 1.0 anchor_bottom = 1.0 -margin_right = -1216.0 -margin_bottom = -656.0 +margin_right = -559.0 +margin_bottom = -174.0 rect_min_size = Vector2( 64, 64 ) +rect_clip_content = true mouse_filter = 1 size_flags_horizontal = 0 size_flags_vertical = 8 script = ExtResource( 1 ) + +[node name="P1" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 1, 0.466667, 0, 1 ) +texture = SubResource( 3 ) + +[node name="P2" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 0, 0.505882, 1, 1 ) +texture = SubResource( 3 ) + +[node name="Rect1" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 1, 0.631373, 0, 1 ) +margin_right = 16.0 +margin_bottom = 16.0 +texture = SubResource( 4 ) +parent_control = "P1" +control_type = 1 + +[node name="Radius1" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 1, 0.631373, 0, 1 ) +margin_right = 16.0 +margin_bottom = 16.0 +mouse_default_cursor_shape = 10 +texture = SubResource( 4 ) +parent_control = "P1" +control_type = 2 + +[node name="Radius11" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 1, 0.631373, 0, 1 ) +margin_right = 16.0 +margin_bottom = 16.0 +mouse_default_cursor_shape = 10 +texture = SubResource( 4 ) +parent_control = "Radius1" +control_type = 2 + +[node name="Scale1" parent="." instance=ExtResource( 2 )] +visible = false +self_modulate = Color( 1, 0.631373, 0, 1 ) +margin_right = 16.0 +margin_bottom = 16.0 +mouse_default_cursor_shape = 10 +texture = SubResource( 4 ) +parent_control = "P1" +control_type = 3 [connection signal="resized" from="." to="." method="on_resized"] diff --git a/addons/material_maker/preview/preview_3d.tscn b/addons/material_maker/preview/preview_3d.tscn index c7651d5..af2de4b 100644 --- a/addons/material_maker/preview/preview_3d.tscn +++ b/addons/material_maker/preview/preview_3d.tscn @@ -32,4 +32,3 @@ physics_object_picking = true [node name="Preview3d" parent="MaterialPreview" instance=ExtResource( 2 )] [connection signal="gui_input" from="." to="." method="on_gui_input"] -[connection signal="resized" from="." to="." method="_on_Preview_resized"] diff --git a/addons/material_maker/widgets/node_editor/parameter_float.gd b/addons/material_maker/widgets/node_editor/parameter_float.gd index fed7579..0171951 100644 --- a/addons/material_maker/widgets/node_editor/parameter_float.gd +++ b/addons/material_maker/widgets/node_editor/parameter_float.gd @@ -7,8 +7,8 @@ func get_model_data() -> Dictionary: max = $Max.value, step = $Step.value, default = $Default.value, + control = $Control.get_item_text($Control.selected) } - return data func set_model_data(data) -> void: @@ -23,6 +23,12 @@ func set_model_data(data) -> void: $Default.step = data.step if data.has("default"): $Default.value = data.default + if data.has("control"): + $Control.selected = 0 + for i in range($Control.get_item_count()): + if data.control == $Control.get_item_text(i): + $Control.selected = i + break func _on_Min_value_changed(v : float) -> void: diff --git a/addons/material_maker/widgets/node_editor/parameter_float.tscn b/addons/material_maker/widgets/node_editor/parameter_float.tscn index be82c6c..79ed7b8 100644 --- a/addons/material_maker/widgets/node_editor/parameter_float.tscn +++ b/addons/material_maker/widgets/node_editor/parameter_float.tscn @@ -81,6 +81,21 @@ margin_left = 342.0 margin_right = 400.0 margin_bottom = 24.0 step = 0.1 + +[node name="LabelControl" type="Label" parent="."] +margin_left = 404.0 +margin_top = 5.0 +margin_right = 454.0 +margin_bottom = 19.0 +text = "Control:" + +[node name="Control" type="OptionButton" parent="."] +margin_left = 458.0 +margin_right = 533.0 +margin_bottom = 24.0 +text = "None" +items = [ "None", null, false, 0, null, "P1.x", null, false, 1, null, "P1.y", null, false, 2, null, "P2.x", null, false, 3, null, "P2.y", null, false, 4, null, "Rect1.x", null, false, 5, null, "Rect1.y", null, false, 6, null, "Radius1.x", null, false, 7, null, "Radius11.x", null, false, 8, null, "Scale1.x", null, false, 9, null ] +selected = 0 [connection signal="value_changed" from="Min" to="." method="_on_Min_value_changed"] [connection signal="value_changed" from="Max" to="." method="_on_Max_value_changed"] [connection signal="value_changed" from="Step" to="." method="_on_Step_value_changed"]