mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
graphedit renderer beginnings
This commit is contained in:
parent
f0f3b2e685
commit
318efb9c34
5 changed files with 94 additions and 1 deletions
40
graph_node_renderer/deck_node_renderer_graph_node.gd
Normal file
40
graph_node_renderer/deck_node_renderer_graph_node.gd
Normal 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,
|
||||||
|
)
|
9
graph_node_renderer/deck_node_renderer_graph_node.tscn
Normal file
9
graph_node_renderer/deck_node_renderer_graph_node.tscn
Normal 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")
|
32
graph_node_renderer/deck_renderer_graph_edit.gd
Normal file
32
graph_node_renderer/deck_renderer_graph_edit.gd
Normal 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)
|
||||||
|
)
|
12
graph_node_renderer/deck_renderer_graph_edit.tscn
Normal file
12
graph_node_renderer/deck_renderer_graph_edit.tscn
Normal 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")
|
|
@ -12,6 +12,6 @@ config_version=5
|
||||||
|
|
||||||
config/name="Re-DotDeck"
|
config/name="Re-DotDeck"
|
||||||
config/tags=PackedStringArray("dot_deck")
|
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/features=PackedStringArray("4.1", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
Loading…
Reference in a new issue