diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd new file mode 100644 index 0000000..9a553c3 --- /dev/null +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -0,0 +1,40 @@ +extends GraphNode +class_name DeckNodeRendererGraphNode + +var node: DeckNode + + +func _ready() -> void: + title = node.name + + for port in node.get_all_ports(): + var descriptor_split := port.descriptor.split(":") + match descriptor_split[0]: + "button": + var button := Button.new() + add_child(button) + button.text = port.label + if port.port_type == DeckNode.PortType.OUTPUT: + button.pressed.connect( + func(): + node.send(port.index, DeckType.DeckTypeString.new("Button Pressed")) + ) + "field": + var line_edit := LineEdit.new() + add_child(line_edit) + line_edit.placeholder_text = port.label + port.value_callback = line_edit.get_text + _: + var label := Label.new() + add_child(label) + label.text = port.label + + set_slot( + port.index, + port.port_type == DeckNode.PortType.INPUT, + 0, + Color.WHITE, + port.port_type == DeckNode.PortType.OUTPUT, + 0, + Color.WHITE, + ) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.tscn b/graph_node_renderer/deck_node_renderer_graph_node.tscn new file mode 100644 index 0000000..d716bd1 --- /dev/null +++ b/graph_node_renderer/deck_node_renderer_graph_node.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://vjpj2074hiex"] + +[ext_resource type="Script" path="res://graph_node_renderer/deck_node_renderer_graph_node.gd" id="1_pos0w"] + +[node name="DeckNodeRendererGraphNode" type="GraphNode"] +offset_right = 280.0 +offset_bottom = 217.0 +title = "Deck Node" +script = ExtResource("1_pos0w") diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd new file mode 100644 index 0000000..929be2b --- /dev/null +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -0,0 +1,32 @@ +extends GraphEdit + +const NODE_SCENE := preload("res://graph_node_renderer/deck_node_renderer_graph_node.tscn") + +var deck: Deck = Deck.new() +var button_node = preload("res://classes/deck/nodes/button.gd") +var print_node = preload("res://classes/deck/nodes/print.gd") + + +func _ready() -> void: + var add_button := Button.new() + add_button.text = "Button" + var add_print := Button.new() + add_print.text = "Print" + get_zoom_hbox().add_child(add_button) + get_zoom_hbox().add_child(add_print) + + add_button.pressed.connect( + func(): + var node := deck.add_node(button_node) + var node_renderer: DeckNodeRendererGraphNode = NODE_SCENE.instantiate() + node_renderer.node = node + add_child(node_renderer) + ) + + add_print.pressed.connect( + func(): + var node := deck.add_node(print_node) + var node_renderer: DeckNodeRendererGraphNode = NODE_SCENE.instantiate() + node_renderer.node = node + add_child(node_renderer) + ) diff --git a/graph_node_renderer/deck_renderer_graph_edit.tscn b/graph_node_renderer/deck_renderer_graph_edit.tscn new file mode 100644 index 0000000..7f6f336 --- /dev/null +++ b/graph_node_renderer/deck_renderer_graph_edit.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://b18qpb48df14l"] + +[ext_resource type="Script" path="res://graph_node_renderer/deck_renderer_graph_edit.gd" id="1_pojfs"] + +[node name="DeckRendererGraphEdit" type="GraphEdit"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +right_disconnects = true +script = ExtResource("1_pojfs") diff --git a/project.godot b/project.godot index 064e347..80a16fb 100644 --- a/project.godot +++ b/project.godot @@ -12,6 +12,6 @@ config_version=5 config/name="Re-DotDeck" config/tags=PackedStringArray("dot_deck") -run/main_scene="res://test.tscn" +run/main_scene="res://graph_node_renderer/deck_renderer_graph_edit.tscn" config/features=PackedStringArray("4.1", "Forward Plus") config/icon="res://icon.svg"