2024-02-22 07:59:23 +01:00
|
|
|
# (c) 2023-present Eroax
|
|
|
|
# (c) 2023-present Yagich
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
extends HBoxContainer
|
|
|
|
class_name DescriptorContainer
|
|
|
|
|
|
|
|
@onready var type_icon: TextureRect = %TypeIcon
|
|
|
|
var descriptor: Array
|
2024-04-16 17:16:38 +02:00
|
|
|
var ignore_signal: bool = false
|
|
|
|
|
2024-02-22 07:59:23 +01:00
|
|
|
|
|
|
|
const TYPE_ICONS := {
|
|
|
|
DeckType.Types.BOOL: preload("res://graph_node_renderer/textures/type_bool.svg"),
|
|
|
|
DeckType.Types.NUMERIC: preload("res://graph_node_renderer/textures/type_numeric.svg"),
|
|
|
|
DeckType.Types.STRING: preload("res://graph_node_renderer/textures/type_string.svg"),
|
|
|
|
DeckType.Types.ARRAY: preload("res://graph_node_renderer/textures/type_array.svg"),
|
|
|
|
DeckType.Types.DICTIONARY: preload("res://graph_node_renderer/textures/type_dictionary.svg"),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@warning_ignore("unused_parameter")
|
2024-04-16 17:16:38 +02:00
|
|
|
func set_up_from_port(port: Port, node: DeckNode, in_node: bool = true) -> void:
|
2024-02-22 07:59:23 +01:00
|
|
|
descriptor = port.descriptor.split(":")
|
2024-04-16 17:16:38 +02:00
|
|
|
Util.safe_connect(port.value_updated,
|
|
|
|
func(new_value: Variant):
|
|
|
|
if ignore_signal:
|
|
|
|
return
|
2024-05-20 10:54:19 +02:00
|
|
|
if new_value != null:
|
|
|
|
set_value(new_value)
|
2024-04-16 17:16:38 +02:00
|
|
|
)
|
2024-02-22 07:59:23 +01:00
|
|
|
_setup(port, node)
|
2024-04-16 17:16:38 +02:00
|
|
|
if (port.port_type == DeckNode.PortType.VIRTUAL or port.type == DeckType.Types.ANY) or not in_node:
|
2024-02-22 07:59:23 +01:00
|
|
|
type_icon.visible = false
|
|
|
|
return
|
|
|
|
|
|
|
|
type_icon.modulate = DeckNodeRendererGraphNode.TYPE_COLORS[port.type]
|
|
|
|
type_icon.tooltip_text = "Type: %s" % DeckType.type_str(port.type).to_lower()
|
|
|
|
type_icon.texture = TYPE_ICONS[port.type]
|
2024-04-16 17:16:38 +02:00
|
|
|
if port.port_type == DeckNode.PortType.OUTPUT and in_node:
|
2024-02-22 07:59:23 +01:00
|
|
|
move_child(type_icon, -1)
|
|
|
|
|
|
|
|
|
|
|
|
@warning_ignore("unused_parameter")
|
|
|
|
func _setup(port: Port, node: DeckNode) -> void:
|
|
|
|
pass
|
2024-04-16 17:16:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
@warning_ignore("unused_parameter")
|
|
|
|
func set_value(new_value: Variant) -> void:
|
|
|
|
pass
|