diff --git a/classes/deck/deck.gd b/classes/deck/deck.gd index 4528d38..2ca6ddc 100644 --- a/classes/deck/deck.gd +++ b/classes/deck/deck.gd @@ -7,25 +7,6 @@ class_name Deck ## is the [DeckNode] instance. var nodes: Dictionary -## The list of [DeckType] for easy port creation. -enum Types{ - ERROR = -1, - BOOL, - NUMERIC, - STRING, - ARRAY, - DICTIONARY, -} - -## A dictionary mapping [enum Types] to [DeckType] subclasses. -static var type_assoc: Dictionary = { - Types.ERROR: DeckType.DeckTypeError, - Types.BOOL: DeckType.DeckTypeBool, - Types.NUMERIC: DeckType.DeckTypeNumeric, - Types.STRING: DeckType.DeckTypeString, - Types.ARRAY: DeckType.DeckTypeArray, - Types.DICTIONARY: DeckType.DeckTypeDictionary, -} ## A map of variables set on this deck. var variable_stack: Dictionary = {} @@ -91,12 +72,11 @@ func get_node(uuid: String) -> DeckNode: ## Attempt to connect two nodes. Returns [code]true[/code] if the connection succeeded. func connect_nodes(from_node: DeckNode, to_node: DeckNode, from_output_port: int, to_input_port: int) -> bool: - # first, check that we can do the type conversion. - var type_a: Types = from_node.get_output_ports()[from_output_port].type - var type_b: Types = to_node.get_input_ports()[to_input_port].type - var err: DeckType = (type_assoc[type_b]).from(type_assoc[type_a].new()) - if err is DeckType.DeckTypeError: - print(err.error_message) + # check that we can do the type conversion + var type_a: DeckType.Types = from_node.get_output_ports()[from_output_port].type + var type_b: DeckType.Types = to_node.get_input_ports()[to_input_port].type + if !DeckType.can_convert(type_a, type_b): + print("Can not convert from %s to %s." % [DeckType.type_str(type_a), DeckType.type_str(type_b)]) return false # TODO: prevent duplicate connections diff --git a/classes/deck/deck_node.gd b/classes/deck/deck_node.gd index a9c4778..6c01732 100644 --- a/classes/deck/deck_node.gd +++ b/classes/deck/deck_node.gd @@ -66,22 +66,22 @@ signal incoming_connection_removed(from_port: int) ## Add an input port to this node. Usually only used at initialization. -func add_input_port(type: Deck.Types, label: String, descriptor: String = "") -> void: +func add_input_port(type: DeckType.Types, label: String, descriptor: String = "") -> void: add_port(type, label, PortType.INPUT, get_input_ports().size(), descriptor) ## Add an output port to this node. Usually only used at initialization. -func add_output_port(type: Deck.Types, label: String, descriptor: String = "") -> void: +func add_output_port(type: DeckType.Types, label: String, descriptor: String = "") -> void: add_port(type, label, PortType.OUTPUT, get_output_ports().size(), descriptor) ## Add a virtual port to this node. Usually only used at initialization. -func add_virtual_port(type: Deck.Types, label: String, descriptor: String = "") -> void: +func add_virtual_port(type: DeckType.Types, label: String, descriptor: String = "") -> void: add_port(type, label, PortType.VIRTUAL, get_virtual_ports().size(), descriptor) ## Add a port to this node. Usually only used at initialization. -func add_port(type: Deck.Types, label: String, port_type: PortType, index_of_type: int, descriptor: String = "") -> void: +func add_port(type: DeckType.Types, label: String, port_type: PortType, index_of_type: int, descriptor: String = "") -> void: var port := Port.new(type, label, ports.size(), port_type, index_of_type, descriptor) ports.append(port) port_added.emit(ports.size() - 1) @@ -97,7 +97,7 @@ func remove_port(port_idx: int) -> void: ## Send data to all outgoing connections on port [param from_output_port]. -func send(from_output_port: int, data: DeckType, extra_data: Array = []) -> void: +func send(from_output_port: int, data: Variant, extra_data: Array = []) -> void: if outgoing_connections.get(from_output_port) == null: return @@ -110,7 +110,7 @@ func send(from_output_port: int, data: DeckType, extra_data: Array = []) -> void ## Virtual function that's called when this node receives data from another node's [method send] call. -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> void: +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: pass diff --git a/classes/deck/nodes/button.gd b/classes/deck/nodes/button.gd index ef3c9b5..e87fa0d 100644 --- a/classes/deck/nodes/button.gd +++ b/classes/deck/nodes/button.gd @@ -8,7 +8,7 @@ func _init() -> void: category = "general" add_output_port( - Deck.Types.BOOL, + DeckType.Types.BOOL, "Press me", "button" ) diff --git a/classes/deck/nodes/get_deck_var.gd b/classes/deck/nodes/get_deck_var.gd index 63301d9..44686f9 100644 --- a/classes/deck/nodes/get_deck_var.gd +++ b/classes/deck/nodes/get_deck_var.gd @@ -8,7 +8,7 @@ func _init() -> void: category = "general" add_output_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Variable", "field" ) diff --git a/classes/deck/nodes/group_input_node.gd b/classes/deck/nodes/group_input_node.gd index 249e668..e2f4dad 100644 --- a/classes/deck/nodes/group_input_node.gd +++ b/classes/deck/nodes/group_input_node.gd @@ -12,7 +12,7 @@ func _init() -> void: appears_in_search = false add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Input 0" ) outgoing_connection_added.connect(_on_outgoing_connection_added) @@ -24,7 +24,7 @@ func _on_outgoing_connection_added(port_idx: int) -> void: return add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Input %s" % (get_all_ports().size()) ) @@ -48,7 +48,7 @@ func _on_outgoing_connection_removed(port_idx: int) -> void: func _pre_connection() -> void: for i in output_count + 1: add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Input %s" % (i + 1) ) @@ -62,7 +62,7 @@ func _post_load() -> void: if ports.size() <= last_connected_port: for i in last_connected_port: add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Input %s" % get_output_ports().size() ) diff --git a/classes/deck/nodes/group_node.gd b/classes/deck/nodes/group_node.gd index eb1c7f9..d2ba8e8 100644 --- a/classes/deck/nodes/group_node.gd +++ b/classes/deck/nodes/group_node.gd @@ -19,9 +19,9 @@ func _pre_connection() -> void: var index_of_type: int match port_type: PortType.OUTPUT: - add_output_port(Deck.Types.STRING, "Output %s" % get_output_ports().size()) + add_output_port(DeckType.Types.ANY, "Output %s" % get_output_ports().size()) PortType.INPUT: - add_input_port(Deck.Types.STRING, "Input %s" % get_input_ports().size()) + add_input_port(DeckType.Types.ANY, "Input %s" % get_input_ports().size()) func init_io() -> void: @@ -46,13 +46,13 @@ func recalculate_ports() -> void: for output_port: Port in output_node.get_input_ports(): add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Output %s" % output_port.index ) for input_port: Port in input_node.get_output_ports(): add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Input %s" % input_port.index ) @@ -61,7 +61,7 @@ func recalculate_ports() -> void: extra_ports.append(port.port_type) -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []): +func _receive(to_input_port: int, data: Variant, extra_data: Array = []): input_node.send(get_input_ports()[to_input_port].index_of_type, data, extra_data) diff --git a/classes/deck/nodes/group_output_node.gd b/classes/deck/nodes/group_output_node.gd index 5eee3d9..477d90b 100644 --- a/classes/deck/nodes/group_output_node.gd +++ b/classes/deck/nodes/group_output_node.gd @@ -12,7 +12,7 @@ func _init() -> void: appears_in_search = false add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Output 0" ) @@ -25,7 +25,7 @@ func _on_incoming_connection_added(port_idx: int) -> void: return add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Output %s" % (get_all_ports().size()) ) @@ -49,7 +49,7 @@ func _on_incoming_connection_removed(port_idx: int) -> void: func _pre_connection() -> void: for i in input_count + 1: add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Output %s" % (i + 1) ) @@ -63,11 +63,11 @@ func _post_load() -> void: if ports.size() <= last_connected_port: for i in last_connected_port: add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Output %s" % get_input_ports().size() ) -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> void: +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: var group_node := _belonging_to._belonging_to.get_node(_belonging_to.group_node) group_node.send(group_node.get_output_ports()[to_input_port].index_of_type, data, extra_data) diff --git a/classes/deck/nodes/print.gd b/classes/deck/nodes/print.gd index d70a660..7088714 100644 --- a/classes/deck/nodes/print.gd +++ b/classes/deck/nodes/print.gd @@ -12,25 +12,25 @@ func _init() -> void: category = "general" add_input_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Text to print", "field" ) add_input_port( - Deck.Types.BOOL, + DeckType.Types.BOOL, "Trigger", "button" ) add_output_port( - Deck.Types.BOOL, + DeckType.Types.BOOL, "On Trigger", "label" ) -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> void: +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: if to_input_port != 1: return @@ -40,11 +40,11 @@ func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> voi elif get_input_ports()[0].value_callback.get_object() && get_input_ports()[0].value_callback.call() != "": data_to_print = get_input_ports()[0].value_callback.call() else: - data_to_print = data.get_value() + data_to_print = data times_activated += 1 # var data_to_print = input_ports[0].value_callback.call() print(data_to_print) print("extra data: ", extra_data) - send(0, DeckType.DeckTypeBool.new(true)) + send(0, true) diff --git a/classes/deck/nodes/set_deck_var.gd b/classes/deck/nodes/set_deck_var.gd index 6d5b1cb..66ae632 100644 --- a/classes/deck/nodes/set_deck_var.gd +++ b/classes/deck/nodes/set_deck_var.gd @@ -8,48 +8,47 @@ func _init() -> void: category = "general" add_input_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Variable Name", "field" ) add_input_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Value", "field" ) add_input_port( - Deck.Types.BOOL, + DeckType.Types.BOOL, "Set", "button" ) add_output_port( - Deck.Types.STRING, + DeckType.Types.ANY, "Value", "label" ) -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> void: +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: if to_input_port != 2: return var var_name: String = get_value_for_port(0, data) - # String for now, until i figure out an Any type - var var_value: String = get_value_for_port(1, data) + var var_value: Variant = get_value_for_port(1, data) _belonging_to.variable_stack[var_name] = var_value - send(0, DeckType.DeckTypeString.new(var_value)) + send(0, var_value) # this can probably go into DeckNode with a different name that makes it clear # that it prioritizes call-time resolution -func get_value_for_port(port: int, data: DeckType) -> Variant: +func get_value_for_port(port: int, data: Variant) -> Variant: if request_value(port) != null: return request_value(port) elif ports[port].value_callback.call() != "": return ports[port].value_callback.call() else: - return data.get_value() + return data diff --git a/classes/deck/nodes/string_constant.gd b/classes/deck/nodes/string_constant.gd index 530de33..9fab8bc 100644 --- a/classes/deck/nodes/string_constant.gd +++ b/classes/deck/nodes/string_constant.gd @@ -7,7 +7,7 @@ func _init() -> void: category = "general" add_output_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Text", "field" ) diff --git a/classes/deck/nodes/test_interleaved_node.gd b/classes/deck/nodes/test_interleaved_node.gd index f2cfc8d..5ecbedf 100644 --- a/classes/deck/nodes/test_interleaved_node.gd +++ b/classes/deck/nodes/test_interleaved_node.gd @@ -8,10 +8,10 @@ func _init() -> void: for i in 4: add_output_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Test" ) add_input_port( - Deck.Types.STRING, + DeckType.Types.STRING, "Test" ) diff --git a/classes/deck/nodes/test_types.gd b/classes/deck/nodes/test_types.gd new file mode 100644 index 0000000..d24a5d6 --- /dev/null +++ b/classes/deck/nodes/test_types.gd @@ -0,0 +1,43 @@ +extends DeckNode + + +func _init() -> void: + name = "Types Test" + node_type = name.to_snake_case() + description = "" + category = "test" + + props_to_serialize = [] + + add_input_port(DeckType.Types.BOOL, "BOOL") + add_input_port(DeckType.Types.NUMERIC, "NUMERIC") + add_input_port(DeckType.Types.STRING, "STRING") + add_input_port(DeckType.Types.ARRAY, "ARRAY") + add_input_port(DeckType.Types.DICTIONARY, "DICTIONARY") + add_input_port(DeckType.Types.ANY, "ANY") + + add_output_port(DeckType.Types.BOOL, "BOOL") + add_output_port(DeckType.Types.NUMERIC, "NUMERIC") + add_output_port(DeckType.Types.STRING, "STRING") + add_output_port(DeckType.Types.ARRAY, "ARRAY") + add_output_port(DeckType.Types.DICTIONARY, "DICTIONARY") + add_output_port(DeckType.Types.ANY, "ANY") + + add_input_port(DeckType.Types.BOOL, "Send", "button") + + +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: + if to_input_port == 6: + send(0, false) + send(1, 1.0) + send(2, "string") + send(3, ["foo", "bar", 5.3]) + send(4, {"foo": "bar", 1: 2}) + send(5, null) + return + + print("received data %s of type %s on port %s, expected type %s, converted v %s, converted type %s" % [ + data, typeof(data), to_input_port, DeckType.GODOT_TYPES_MAP[get_input_ports()[to_input_port].type], + DeckType.convert_value(data, get_input_ports()[to_input_port].type), + typeof(DeckType.convert_value(data, get_input_ports()[to_input_port].type)) + ]) diff --git a/classes/deck/port.gd b/classes/deck/port.gd index 3f41cbf..9cea9de 100644 --- a/classes/deck/port.gd +++ b/classes/deck/port.gd @@ -5,7 +5,7 @@ class_name Port ## them on a node. ## The type index of this port. -var type: Deck.Types +var type: DeckType.Types ## The label of this port. Used by the renderer to display. How it's displayed depends on the renderer ## and the [member descriptor]. var label: String @@ -29,7 +29,7 @@ var value: Variant: set = set_value func _init( - p_type: Deck.Types, + p_type: DeckType.Types, p_label: String, p_index: int, p_port_type: DeckNode.PortType, diff --git a/classes/types/deck_type.gd b/classes/types/deck_type.gd index f011c1a..0772628 100644 --- a/classes/types/deck_type.gd +++ b/classes/types/deck_type.gd @@ -1,161 +1,45 @@ class_name DeckType -## Base class for defining the types that can be used on a [Port]. -var _value: Variant -var _success: bool = true +enum Types{ + BOOL, + NUMERIC, + STRING, + ARRAY, + DICTIONARY, + ANY, +} + +const CONVERSION_MAP := { + Types.BOOL: [Types.NUMERIC, Types.STRING, Types.ANY], + Types.NUMERIC: [Types.BOOL, Types.STRING, Types.ANY], + Types.STRING: [Types.BOOL, Types.NUMERIC, Types.ANY], + Types.ARRAY: [Types.STRING, Types.BOOL, Types.ANY], + Types.DICTIONARY: [Types.STRING, Types.BOOL, Types.ANY], + Types.ANY: [Types.BOOL, Types.NUMERIC, Types.STRING, Types.ARRAY, Types.DICTIONARY] +} + +const GODOT_TYPES_MAP := { + Types.BOOL: TYPE_BOOL, + Types.NUMERIC: TYPE_FLOAT, + Types.STRING: TYPE_STRING, + Types.ARRAY: TYPE_ARRAY, + Types.DICTIONARY: TYPE_DICTIONARY, +} -## Returns [code]true[/code] if the type is valid and can be used. -func is_valid() -> bool: - return _success +static func can_convert(from: Types, to: Types) -> bool: + if from == to: + return true + + return (to in (CONVERSION_MAP[from] as Array)) -func get_value() -> Variant: - return _value +static func convert_value(value: Variant, to: Types) -> Variant: + if to == Types.ANY: + return value + + return type_convert(value, GODOT_TYPES_MAP[to]) -func set_value(new_value: Variant) -> void: - _value = new_value - - -## Virtual function. Used to convert [param other] to the overriding class' type. -static func from(other: DeckType) -> DeckType: - return null - - -## Generic Error type. -## -## Always returns [code]null[/code] as the value, and [code]false[/code] as success.[br] -## Always returns a new [DeckType.DeckTypeError] on conversion from any other type. -class DeckTypeError extends DeckType: - ## An optional error message. - var error_message: String - - - func _init(p_error_message: String = ""): - _value = self - _success = false - - error_message = p_error_message - - - static func from(other: DeckType) -> DeckTypeError: - return DeckTypeError.new() - - -## Numeric type. Corresponds to the JSON number type, so only supports the float primitive type. -class DeckTypeNumeric extends DeckType: - func _init(value: float = 0.0) -> void: - _value = value - - ## Converts either a [DeckType.DeckTypeString] or [DeckType.DeckTypeBool] to numeric. - ## In the case of [DeckType.DeckTypeBool], [code]1.0[/code] is used for [code]true[/code], - ## [code]0.0[/code] for [code]false[/code].[br] - ## In the case of [DeckType.DeckTypeString], converts to String if it is a valid number - ## or [DeckType.DeckTypeError] otherwise. - static func from(other: DeckType) -> DeckType: - if other is DeckTypeNumeric: - return other - - if other is DeckTypeString: - if (other.get_value() as String).is_valid_float(): - var value: float = float(other.get_value() as String) - var inst := DeckTypeNumeric.new() - inst._value = value - return inst - else: - var err: DeckTypeError = DeckTypeError.from(other) - err.error_message = "Conversion from String to Numeric failed, check the number" - return err - - if other is DeckTypeBool: - var inst := DeckTypeNumeric.new() - inst._value = float(other.get_value() as bool) - return inst - - var err: DeckTypeError = DeckTypeError.from(other) - err.error_message = "Conversion to Numeric is only possible from String or Bool" - return err - - -## String type. Corresponds to the JSON string type. Any type can be converted to String. -class DeckTypeString extends DeckType: - func _init(value: String = "") -> void: - _value = value - - - static func from(other: DeckType) -> DeckTypeString: - if other is DeckTypeString: - return other - - var inst := DeckTypeString.new() - inst._value = var_to_str(other.get_value()) - return inst - - -## Boolean type. Corresponds to the JSON bool type. -class DeckTypeBool extends DeckType: - func _init(value: bool = false) -> void: - _value = value - - ## Converts either [DeckType.DeckTypeNumeric], [DeckType.DeckTypeDictionary] or [DeckType.DeckTypeArray] - ## to a boolean.[br] - ## In the case of [DeckType.DeckTypeNumeric], the resulting value will be [code]false[/code] - ## if the value is a zero value ([code]0.0[/code] and [code]-0.0[/code]), [code]true[/code] otherwise.[br] - ## In the case of [DeckType.DeckTypeDictionary] or [DeckType.DeckTypeArray], - ## the resulting value will be [code]true[/code] if the container is not empty. - static func from(other: DeckType) -> DeckType: - if other is DeckTypeBool: - return other - - if other is DeckTypeNumeric: - var inst := DeckTypeBool.new() - inst._value = bool(other.get_value()) - return inst - - if other is DeckTypeDictionary or other is DeckTypeArray: - var inst := DeckTypeBool.new() - inst._value = !other.get_value().is_empty() - return inst - - var err := DeckTypeError.from(other) - err.error_message = "Cannot create a DeckTypeBool from non-numeric or non-container type" - return err - - -## Array type. Corresponds to the JSON Array type. -class DeckTypeArray extends DeckType: - func _init(value: Array = []) -> void: - _value = value - - - ## Arrays can only be converted from a string in the format - ## [code]"["foo", 2, "bar"][/code]. - static func from(other: DeckType) -> DeckType: - if other is DeckTypeString: - var inst := DeckTypeArray.new() - inst._value = str_to_var(other.get_value()) - return inst - - var err: DeckTypeError = DeckTypeError.from(other) - err.error_message = "Conversions to Array is only possible from String" - return err - - -## Dictionary class. Corresponds to the JSON Object type. -class DeckTypeDictionary extends DeckType: - func _init(value: Dictionary = {}) -> void: - _value = value - - - ## Dictionaries can only be converted from a string in the format - ## [code]{"key": "value"}[/code]. - static func from(other: DeckType) -> DeckType: - if other is DeckTypeString: - var inst := DeckTypeDictionary.new() - inst._value = str_to_var(other.get_value()) - return inst - - var err: DeckTypeError = DeckTypeError.from(other) - err.error_message = "conversions to Dictionary is only possible from String" - return err +static func type_str(type: Types) -> String: + return str(Types.keys()[type]) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd index 7aec59e..350d29b 100644 --- a/graph_node_renderer/deck_node_renderer_graph_node.gd +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -25,12 +25,12 @@ func _ready() -> void: if port.port_type == DeckNode.PortType.OUTPUT: button.pressed.connect( func(): - node.send(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node.send(port.index_of_type, true) ) elif port.port_type == DeckNode.PortType.INPUT: button.pressed.connect( func(): - node._receive(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node._receive(port.index_of_type, true) ) "field": var line_edit := LineEdit.new() @@ -48,10 +48,10 @@ func _ready() -> void: set_slot( port.index, port.port_type == DeckNode.PortType.INPUT, - 0, + port.type, Color.WHITE, port.port_type == DeckNode.PortType.OUTPUT, - 0, + port.type, Color.WHITE, ) @@ -82,12 +82,12 @@ func _on_node_port_added(port_idx: int) -> void: if port.port_type == DeckNode.PortType.OUTPUT: button.pressed.connect( func(): - node.send(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node.send(port.index_of_type, true) ) elif port.port_type == DeckNode.PortType.INPUT: button.pressed.connect( func(): - node._receive(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node._receive(port.index_of_type, true) ) "field": var line_edit := LineEdit.new() @@ -105,10 +105,10 @@ func _on_node_port_added(port_idx: int) -> void: set_slot( port.index, port.port_type == DeckNode.PortType.INPUT, - 0, + port.type, Color.WHITE, port.port_type == DeckNode.PortType.OUTPUT, - 0, + port.type, Color.WHITE, ) @@ -144,12 +144,12 @@ func _on_node_ports_updated() -> void: if port.port_type == DeckNode.PortType.OUTPUT: button.pressed.connect( func(): - node.send(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node.send(port.index_of_type, true) ) elif port.port_type == DeckNode.PortType.INPUT: button.pressed.connect( func(): - node._receive(port.index_of_type, DeckType.DeckTypeBool.new(true)) + node._receive(port.index_of_type, true) ) "field": var line_edit := LineEdit.new() @@ -167,9 +167,9 @@ func _on_node_ports_updated() -> void: set_slot( port.index, port.port_type == DeckNode.PortType.INPUT, - 0, + port.type, Color.WHITE, port.port_type == DeckNode.PortType.OUTPUT, - 0, + port.type, Color.WHITE, ) diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index 1b900b8..3cdd2e9 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -37,6 +37,10 @@ func _ready() -> void: search_popup_panel.size = search_popup_size add_child(search_popup_panel, false, Node.INTERNAL_MODE_BACK) + for t: DeckType.Types in DeckType.CONVERSION_MAP: + for out_type: DeckType.Types in DeckType.CONVERSION_MAP[t]: + add_valid_connection_type(t, out_type) + add_node_menu.node_selected.connect(_on_add_node_menu_node_selected) connection_request.connect(attempt_connection) diff --git a/script_templates/DeckNode/node_template.gd b/script_templates/DeckNode/node_template.gd index a94b5ea..8346316 100644 --- a/script_templates/DeckNode/node_template.gd +++ b/script_templates/DeckNode/node_template.gd @@ -5,10 +5,11 @@ func _init() -> void: name = "" node_type = name.to_snake_case() description = "" + category = "" props_to_serialize = [] - -func _receive(to_input_port: int, data: DeckType, extra_data: Array = []) -> void: + +func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: pass