mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
49 lines
1.5 KiB
GDScript
49 lines
1.5 KiB
GDScript
extends Control
|
|
|
|
var node_renderer_scene := preload("res://test_node_renderer.tscn")
|
|
@onready var nodes_container: HBoxContainer = $NodesContainer
|
|
|
|
@onready var add_button_button: Button = $AddButtonButton
|
|
@onready var add_print_button: Button = $AddPrintButton
|
|
@onready var connect_them_button: Button = $ConnectThemButton
|
|
@onready var disconnect_them_button: Button = $DisconnectThemButton
|
|
|
|
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:
|
|
add_button_button.pressed.connect(
|
|
func():
|
|
var node := deck.add_node(button_node)
|
|
var node_renderer = node_renderer_scene.instantiate()
|
|
node_renderer.node = node
|
|
nodes_container.add_child(node_renderer)
|
|
add_button_button.disabled = true
|
|
)
|
|
|
|
add_print_button.pressed.connect(
|
|
func():
|
|
var node := deck.add_node(print_node)
|
|
var node_renderer = node_renderer_scene.instantiate()
|
|
node_renderer.node = node
|
|
nodes_container.add_child(node_renderer)
|
|
add_print_button.disabled = true
|
|
)
|
|
|
|
connect_them_button.pressed.connect(
|
|
func():
|
|
var node_a: DeckNode = nodes_container.get_child(0).node
|
|
var node_b: DeckNode = nodes_container.get_child(1).node
|
|
|
|
deck.connect_nodes(node_a, node_b, 0, 1)
|
|
)
|
|
|
|
disconnect_them_button.pressed.connect(
|
|
func():
|
|
var node_a: DeckNode = nodes_container.get_child(0).node
|
|
var node_b: DeckNode = nodes_container.get_child(1).node
|
|
|
|
deck.disconnect_nodes(node_a, node_b, 0, 1)
|
|
)
|