miggor-StreamGraph/test.gd

50 lines
1.5 KiB
GDScript3
Raw Normal View History

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
2023-06-11 18:26:21 +02:00
@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
)
2023-06-11 17:39:26 +02:00
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)
)
2023-06-11 18:26:21 +02:00
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)
)