From 7e355291001e17563cb485a3b62637d3ec848b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 15 Dec 2023 00:04:29 +0300 Subject: [PATCH] use logger in nodes --- classes/deck/nodes/delay.gd | 2 +- classes/deck/nodes/expression_node.gd | 3 ++- classes/deck/nodes/group_input_node.gd | 2 +- classes/deck/nodes/group_output_node.gd | 2 +- classes/deck/nodes/print.gd | 8 ++++++-- classes/deck/nodes/vector_add.gd | 3 +++ classes/deck/nodes/vector_decompose.gd | 2 ++ classes/deck/nodes/vector_dot.gd | 3 +++ classes/deck/nodes/vector_multiply.gd | 2 ++ classes/deck/nodes/vector_normalize.gd | 4 +++- classes/deck/nodes/vector_subtract.gd | 3 +++ graph_node_renderer/deck_renderer_graph_edit.gd | 2 -- 12 files changed, 27 insertions(+), 9 deletions(-) diff --git a/classes/deck/nodes/delay.gd b/classes/deck/nodes/delay.gd index 2bf0b64..2233eb8 100644 --- a/classes/deck/nodes/delay.gd +++ b/classes/deck/nodes/delay.gd @@ -30,7 +30,7 @@ func handle_delay(data): pass - print("Delay over") + #print("Delay over") send(0, data) diff --git a/classes/deck/nodes/expression_node.gd b/classes/deck/nodes/expression_node.gd index e37fab2..1160d68 100644 --- a/classes/deck/nodes/expression_node.gd +++ b/classes/deck/nodes/expression_node.gd @@ -33,6 +33,7 @@ func _value_request(_from_port : int) -> Variant: var err = expr.parse(text, ["deck_var", "input"]) if err != OK: + DeckHolder.logger.log_node("Expression parse failed: %s" % err, Logger.LogType.ERROR) printerr(err) return null @@ -40,7 +41,7 @@ func _value_request(_from_port : int) -> Variant: var res = expr.execute([_belonging_to.variable_stack, request_value(0)]) if expr.has_execute_failed(): - printerr("Expression Execution Failed: ", text) + DeckHolder.logger.log_node("Expression Execution Failed: %s" % text, Logger.LogType.ERROR) return null diff --git a/classes/deck/nodes/group_input_node.gd b/classes/deck/nodes/group_input_node.gd index 1230b6e..936b83d 100644 --- a/classes/deck/nodes/group_input_node.gd +++ b/classes/deck/nodes/group_input_node.gd @@ -41,7 +41,7 @@ func _on_outgoing_connection_removed(port_idx: int) -> void: if !(outgoing_connections.get(port, {}) as Dictionary).is_empty(): last_connected_port = port - prints("l:", last_connected_port, "p:", port_idx) + #prints("l:", last_connected_port, "p:", port_idx) if port_idx < last_connected_port: return diff --git a/classes/deck/nodes/group_output_node.gd b/classes/deck/nodes/group_output_node.gd index 5643b09..2bc82f0 100644 --- a/classes/deck/nodes/group_output_node.gd +++ b/classes/deck/nodes/group_output_node.gd @@ -39,7 +39,7 @@ func _on_incoming_connection_removed(port_idx: int) -> void: if !(incoming_connections[port] as Dictionary).is_empty(): last_connected_port = port - prints("l:", last_connected_port, "p:", port_idx) + #prints("l:", last_connected_port, "p:", port_idx) if port_idx < last_connected_port: return diff --git a/classes/deck/nodes/print.gd b/classes/deck/nodes/print.gd index cb937e8..a424b14 100644 --- a/classes/deck/nodes/print.gd +++ b/classes/deck/nodes/print.gd @@ -34,9 +34,11 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void if to_input_port != 1: return - var data_to_print = resolve_input_port_value(0) - if data_to_print == null || data_to_print.is_empty(): + var data_to_print = str(resolve_input_port_value(0)) + if data_to_print == null: data_to_print = str(data) + if (data_to_print as String).is_empty(): + data_to_print = "" times_activated += 1 @@ -44,4 +46,6 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void #print(data_to_print) #print("extra data: ", extra_data) DeckHolder.logger.log_node(data_to_print) + if !extra_data.is_empty(): + DeckHolder.logger.log_node(str("Extra data: ", extra_data)) send(0, true) diff --git a/classes/deck/nodes/vector_add.gd b/classes/deck/nodes/vector_add.gd index 6a57390..7defaf8 100644 --- a/classes/deck/nodes/vector_add.gd +++ b/classes/deck/nodes/vector_add.gd @@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant: var vb = request_value(1) if !va || !vb: + DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR) return null var res := {} diff --git a/classes/deck/nodes/vector_decompose.gd b/classes/deck/nodes/vector_decompose.gd index 0263880..ccd1b13 100644 --- a/classes/deck/nodes/vector_decompose.gd +++ b/classes/deck/nodes/vector_decompose.gd @@ -25,9 +25,11 @@ func _init() -> void: func _value_request(on_port: int) -> Variant: var v = request_value(0) if !v: + DeckHolder.logger.log_node("Vector Decompose: the vector is invalid.", Logger.LogType.ERROR) return null if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Decompose: the vector is invalid.", Logger.LogType.ERROR) return null if on_port == 0: diff --git a/classes/deck/nodes/vector_dot.gd b/classes/deck/nodes/vector_dot.gd index b1b7e38..d2da0cc 100644 --- a/classes/deck/nodes/vector_dot.gd +++ b/classes/deck/nodes/vector_dot.gd @@ -27,12 +27,15 @@ func _value_request(_on_port: int) -> Variant: var vb = request_value(1) if !va || !vb: + DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR) return null return va.x * vb.x + va.y * vb.y diff --git a/classes/deck/nodes/vector_multiply.gd b/classes/deck/nodes/vector_multiply.gd index 9fb9597..17f1d6b 100644 --- a/classes/deck/nodes/vector_multiply.gd +++ b/classes/deck/nodes/vector_multiply.gd @@ -27,9 +27,11 @@ func _value_request(_on_port: int) -> Variant: var v = request_value(0) if !v: + DeckHolder.logger.log_node("Vector Mult: the vector is invalid.", Logger.LogType.ERROR) return null if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Mult: the vector is invalid.", Logger.LogType.ERROR) return null var s = float(resolve_input_port_value(1)) diff --git a/classes/deck/nodes/vector_normalize.gd b/classes/deck/nodes/vector_normalize.gd index c624aaa..9473003 100644 --- a/classes/deck/nodes/vector_normalize.gd +++ b/classes/deck/nodes/vector_normalize.gd @@ -21,9 +21,11 @@ func _init() -> void: func _value_request(_on_port: int) -> Variant: var v = request_value(0) if !v: + DeckHolder.logger.log_node("Vector Normalize: the vector is invalid.", Logger.LogType.ERROR) return null if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Normalize: the vector is invalid.", Logger.LogType.ERROR) return null var l: float = (v.x ** 2.0) + (v.y ** 2.0) @@ -34,6 +36,6 @@ func _value_request(_on_port: int) -> Variant: res.y = res.y / l return res - print("vector length is 0, can't normalize. returning null") + DeckHolder.logger.log_node("Vector Normalize: the vector is length 0. Returning null.", Logger.LogType.ERROR) return null diff --git a/classes/deck/nodes/vector_subtract.gd b/classes/deck/nodes/vector_subtract.gd index fe206e6..3d30f70 100644 --- a/classes/deck/nodes/vector_subtract.gd +++ b/classes/deck/nodes/vector_subtract.gd @@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant: var vb = request_value(1) if !va || !vb: + DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR) return null if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"): + DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR) return null var res := {} diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index 90ba370..4d51a65 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -195,7 +195,6 @@ func get_selected_nodes() -> Array: ## based off the action "group_nodes". func _gui_input(event: InputEvent) -> void: if event.is_action_pressed("group_nodes") && get_selected_nodes().size() > 0: - print("?") clear_connections() var nodes = get_selected_nodes().map( func(x: DeckNodeRendererGraphNode): @@ -222,7 +221,6 @@ func _input(event: InputEvent) -> void: if event.is_action_pressed("enter_group") && get_selected_nodes().size() == 1: if !((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.node_type == "group_node"): return - print("tried to enter group") group_enter_requested.emit((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.group_id) get_viewport().set_input_as_handled()