From 85b2181622dc45b54b9ce500544267ffa0faf47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Tue, 28 Nov 2023 11:13:18 +0300 Subject: [PATCH] save selected scene in obs scene list node renderer --- classes/deck/nodes/obs_scene_list.gd | 1 + classes/deck/port.gd | 4 ++++ graph_node_renderer/deck_node_renderer_graph_node.gd | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/classes/deck/nodes/obs_scene_list.gd b/classes/deck/nodes/obs_scene_list.gd index 222cec9..601942d 100644 --- a/classes/deck/nodes/obs_scene_list.gd +++ b/classes/deck/nodes/obs_scene_list.gd @@ -2,6 +2,7 @@ extends DeckNode var noobs: NoOBSWS + func _init() -> void: name = "Scene Selector" node_type = "obs_scene_list" diff --git a/classes/deck/port.gd b/classes/deck/port.gd index e1c1816..000c822 100644 --- a/classes/deck/port.gd +++ b/classes/deck/port.gd @@ -27,6 +27,8 @@ var index: int ## The value of this port. var value: Variant: set = set_value +signal value_updated(new_value: Variant) + func _init( p_type: DeckType.Types, @@ -50,6 +52,8 @@ func _init( func set_value(v: Variant) -> void: if v is Callable: value = v.call() + value_updated.emit(value) return value = v + value_updated.emit(value) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd index 57d31a4..e9a93aa 100644 --- a/graph_node_renderer/deck_node_renderer_graph_node.gd +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -92,8 +92,14 @@ func update_port(port: Port) -> void: line_edit.text_changed.connect(port.set_value) "singlechoice": var box := OptionButton.new() - for item in descriptor_split.slice(1): - box.add_item(item) + if descriptor_split.slice(1).is_empty(): + if port.value: + box.add_item(port.value) + else: + box.add_item(port.label) + else: + for item in descriptor_split.slice(1): + box.add_item(item) add_child(box) port.value_callback = func(): return box.get_item_text(box.get_selected_id()) if port.type == DeckType.Types.STRING: