Optional range parameter for some of ht eadd slot methods.

This commit is contained in:
Relintai 2021-10-05 20:59:47 +02:00
parent 59c43c0cab
commit 88aa8e84ac
2 changed files with 14 additions and 6 deletions

View File

@ -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) 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 bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.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() var sb : SpinBox = SpinBox.new()
sb.rounded = true sb.rounded = true
sb.min_value = prange.x
sb.max_value = prange.y
bc.add_child(sb) bc.add_child(sb)
var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc) 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 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 bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.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) var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc)
sb.rounded = false sb.rounded = false
sb.step = step sb.step = step
sb.min_value = prange.x
sb.max_value = prange.y
sb.value = _node.call(getter) sb.value = _node.call(getter)
sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ]) sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ])
return 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 bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.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 sby.rounded = false
sbx.step = step sbx.step = step
sby.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) var val : Vector2 = _node.call(getter)

View File

@ -15,9 +15,9 @@ func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color:
func register_methods(mm_graph_node) -> void: 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_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_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") 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") 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: func get_iterations() -> int:
return iterations return iterations