graphedit renderer beginnings

This commit is contained in:
Lera Elvoé 2023-06-12 18:32:36 +03:00
parent f0f3b2e685
commit 318efb9c34
No known key found for this signature in database
5 changed files with 94 additions and 1 deletions

View file

@ -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,
)

View file

@ -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")

View file

@ -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)
)

View file

@ -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")

View file

@ -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"