Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scenes/Nodes/node_logic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ extends GraphNode
@export var min_gap: float = 0.5 # editable value in inspector for the minimum gap between min and max
var undo_redo: UndoRedo
var button_states = {}
var cache_button: Button
signal open_help
signal inlet_removed
signal node_moved
signal play_cached(node: Node)

func _ready() -> void:
var sliders := _get_all_hsliders(self) #finds all sliders
Expand All @@ -32,6 +34,15 @@ func _ready() -> void:
btn.tooltip_text = "Open help for " + self.title
btn.connect("pressed", Callable(self, "_open_help")) #pass key (process name) when button is pressed
titlebar.add_child(btn)

#add cache preview button
var cache_btn = Button.new()
cache_btn.text = "▶"
cache_btn.tooltip_text = "Preview cached output (run thread first)"
cache_btn.connect("pressed", Callable(self, "_play_cache"))
cache_btn.visible = false
cache_button = cache_btn
titlebar.add_child(cache_btn)

if has_meta("allow_bypass") and get_meta("allow_bypass"):
#add bypass
Expand Down Expand Up @@ -107,6 +118,9 @@ func _on_slider_value_changed(value: float, changed_slider: HSlider) -> void:
func _open_help():
open_help.emit(self.get_meta("command"), self.title)

func _play_cache():
play_cached.emit(self)

func add_inlet_to_node():
#called when the + button is pressed on an addremoveinlets node in the graphnode
var inlet_count = self.get_input_port_count()
Expand Down Expand Up @@ -188,6 +202,10 @@ func set_button_value(value, button) -> void:

button_states[button] = value

func set_cache_button_visible(v: bool) -> void:
if is_instance_valid(cache_button):
cache_button.visible = v

func _bypass_node() -> void:
if has_meta("bypassed") and get_meta("bypassed"):
set_meta("bypassed", false)
Expand Down
1 change: 1 addition & 0 deletions scenes/main/scripts/control.gd
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func load_from_filesystem():
break

func new_patch():
run_thread.clear_cache()
#clear old patch
graph_edit.clear_connections()

Expand Down
5 changes: 4 additions & 1 deletion scenes/main/scripts/graph_edit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
pass

graphnode.set_script(node_logic)

control_script.undo_redo.create_action("Add Node")
control_script.undo_redo.add_do_method(add_child.bind(graphnode))
control_script.undo_redo.add_do_reference(graphnode)
control_script.undo_redo.add_undo_method(delete_node.bind(graphnode))
control_script.undo_redo.commit_action()
graphnode.undo_redo = control_script.undo_redo
graphnode.connect("open_help", open_help)
graphnode.connect("play_cached", Callable(control_script.run_thread, "play_node_cache"))
graphnode.connect("inlet_removed", Callable(self, "on_inlet_removed"))
graphnode.node_moved.connect(_auto_link_nodes)
graphnode.dragged.connect(node_position_changed.bind(graphnode))
Expand Down Expand Up @@ -454,6 +455,8 @@ func restore_node(node_to_restore: GraphNode) -> void:
#relink everything
if not node_to_restore.is_connected("open_help", open_help):
node_to_restore.connect("open_help", open_help)
if node_to_restore.has_signal("play_cached") and not node_to_restore.is_connected("play_cached", Callable(control_script.run_thread, "play_node_cache")):
node_to_restore.connect("play_cached", Callable(control_script.run_thread, "play_node_cache"))
if not node_to_restore.is_connected("node_moved", _auto_link_nodes):
node_to_restore.node_moved.connect(_auto_link_nodes)
if "undo_redo" in node_to_restore:
Expand Down
Loading