From 88aa8e84acb6f8015757dc0b0c76eadf9c66d4a5 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 5 Oct 2021 20:59:47 +0200 Subject: [PATCH] Optional range parameter for some of ht eadd slot methods. --- game/addons/mat_maker_gd/editor/mm_graph_node.gd | 14 +++++++++++--- game/addons/mat_maker_gd/nodes/noise/perlin.gd | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/game/addons/mat_maker_gd/editor/mm_graph_node.gd b/game/addons/mat_maker_gd/editor/mm_graph_node.gd index 8fb50e6c..bed98701 100644 --- a/game/addons/mat_maker_gd/editor/mm_graph_node.gd +++ b/game/addons/mat_maker_gd/editor/mm_graph_node.gd @@ -28,7 +28,7 @@ func add_slot_label(input_type : int, output_type : int, getter : String, setter return add_slot(input_type, output_type, getter, setter, l) -func add_slot_int(input_type : int, output_type : int, getter : String, setter : String, slot_name : String) -> int: +func add_slot_int(input_type : int, output_type : int, getter : String, setter : String, slot_name : String, prange : Vector2 = Vector2(-1000, 1000)) -> int: var bc : VBoxContainer = VBoxContainer.new() var l : Label = Label.new() @@ -37,6 +37,8 @@ func add_slot_int(input_type : int, output_type : int, getter : String, setter : var sb : SpinBox = SpinBox.new() sb.rounded = true + sb.min_value = prange.x + sb.max_value = prange.y bc.add_child(sb) var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc) @@ -47,7 +49,7 @@ func add_slot_int(input_type : int, output_type : int, getter : String, setter : return slot_idx -func add_slot_float(input_type : int, output_type : int, getter : String, setter : String, slot_name : String, step : float = 0.1) -> int: +func add_slot_float(input_type : int, output_type : int, getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int: var bc : VBoxContainer = VBoxContainer.new() var l : Label = Label.new() @@ -60,13 +62,15 @@ func add_slot_float(input_type : int, output_type : int, getter : String, setter var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc) sb.rounded = false sb.step = step + sb.min_value = prange.x + sb.max_value = prange.y sb.value = _node.call(getter) sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ]) return slot_idx -func add_slot_vector2(input_type : int, output_type : int, getter : String, setter : String, slot_name : String, step : float = 0.1) -> int: +func add_slot_vector2(input_type : int, output_type : int, getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int: var bc : VBoxContainer = VBoxContainer.new() var l : Label = Label.new() @@ -84,6 +88,10 @@ func add_slot_vector2(input_type : int, output_type : int, getter : String, sett sby.rounded = false sbx.step = step sby.step = step + sbx.min_value = prange.x + sbx.max_value = prange.y + sby.min_value = prange.x + sby.max_value = prange.y var val : Vector2 = _node.call(getter) diff --git a/game/addons/mat_maker_gd/nodes/noise/perlin.gd b/game/addons/mat_maker_gd/nodes/noise/perlin.gd index 6340a56b..ca3b502c 100644 --- a/game/addons/mat_maker_gd/nodes/noise/perlin.gd +++ b/game/addons/mat_maker_gd/nodes/noise/perlin.gd @@ -15,9 +15,9 @@ func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color: func register_methods(mm_graph_node) -> void: mm_graph_node.add_slot_texture(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_IMAGE, "recalculate_image", "") - mm_graph_node.add_slot_int(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_iterations", "set_iterations", "iterations") - mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence") - mm_graph_node.add_slot_vector2(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale", "set_scale", "scale") + mm_graph_node.add_slot_int(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_iterations", "set_iterations", "iterations")#, Vector2(1, 10)) + mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence", 0.05)#, Vector2(0, 1)) + mm_graph_node.add_slot_vector2(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale", "set_scale", "scale", 1)#, Vector2(1, 32)) func get_iterations() -> int: return iterations