From b7f511709a99e4b10e3bc4e60eda78bf576097b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Mon, 4 Dec 2023 17:16:39 +0300 Subject: [PATCH] fix a bunch of warnings --- classes/deck/deck.gd | 2 +- classes/deck/deck_node.gd | 15 +++++---- classes/deck/nodes/delay.gd | 32 +++++++++---------- classes/deck/nodes/dictionary_get_key.gd | 2 +- classes/deck/nodes/expression_node.gd | 24 +++++++------- classes/deck/nodes/get_deck_var.gd | 2 +- classes/deck/nodes/group_node.gd | 1 - classes/deck/nodes/obs_scene_list.gd | 4 +-- classes/deck/nodes/obs_search_source.gd | 2 +- .../deck/nodes/obs_set_source_transform.gd | 2 +- classes/deck/nodes/obs_switch_scene.gd | 2 +- classes/deck/nodes/obs_vector_to_position.gd | 2 +- .../nodes/obs_websocket_generic_request.gd | 2 +- classes/deck/nodes/set_deck_var.gd | 2 +- classes/deck/nodes/string_constant.gd | 2 +- classes/deck/nodes/test_types.gd | 2 +- classes/deck/nodes/vector_add.gd | 2 +- classes/deck/nodes/vector_compose.gd | 2 +- classes/deck/nodes/vector_dot.gd | 2 +- classes/deck/nodes/vector_multiply.gd | 2 +- classes/deck/nodes/vector_normalize.gd | 2 +- classes/deck/nodes/vector_subtract.gd | 2 +- .../deck_renderer_graph_edit.gd | 11 ++----- 23 files changed, 58 insertions(+), 63 deletions(-) diff --git a/classes/deck/deck.gd b/classes/deck/deck.gd index c22ac10..f946253 100644 --- a/classes/deck/deck.gd +++ b/classes/deck/deck.gd @@ -235,7 +235,7 @@ func copy_nodes_json(nodes_to_copy: Array[String]) -> String: func allocate_ids(count: int) -> Array[String]: - var res: Array[String] + var res: Array[String] = [] for i in count: res.append(UUID.v4()) return res diff --git a/classes/deck/deck_node.gd b/classes/deck/deck_node.gd index e374bbd..4f60b17 100644 --- a/classes/deck/deck_node.gd +++ b/classes/deck/deck_node.gd @@ -107,6 +107,7 @@ func send(from_output_port: int, data: Variant, extra_data: Array = []) -> void: ## Virtual function that's called when this node receives data from another node's [method send] call. +@warning_ignore("unused_parameter") func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: pass @@ -115,9 +116,9 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void ## at [param to_port]. func add_outgoing_connection(from_port: int, to_node: String, to_port: int) -> void: var inner: Dictionary = outgoing_connections.get(from_port, {}) as Dictionary - var ports: Array = inner.get(to_node, []) as Array - ports.append(to_port) - inner[to_node] = ports + var inner_ports: Array = inner.get(to_node, []) as Array + inner_ports.append(to_port) + inner[to_node] = inner_ports outgoing_connections[from_port] = inner get_node(to_node).add_incoming_connection(to_port, _id, from_port) outgoing_connection_added.emit(from_port) @@ -155,6 +156,7 @@ func request_value_async(on_port: int) -> Variant: ## Virtual function that's called when this node has been requested a value from the output port ## at [param from_port]. +@warning_ignore("unused_parameter") func _value_request(from_port: int) -> Variant: return null @@ -166,10 +168,10 @@ func remove_outgoing_connection(from_port: int, to_node: String, to_port: int) - if connections.is_empty(): return - var ports: Array = connections.get(to_node, []) as Array - ports.erase(to_port) + var inner_ports: Array = connections.get(to_node, []) as Array + inner_ports.erase(to_port) - if ports.is_empty(): + if inner_ports.is_empty(): (outgoing_connections[from_port] as Dictionary).erase(to_node) if (outgoing_connections[from_port] as Dictionary).is_empty(): outgoing_connections.erase(from_port) @@ -184,6 +186,7 @@ func remove_incoming_connection(to_port: int) -> void: incoming_connection_removed.emit(to_port) +@warning_ignore("unused_parameter") func _event_received(event_name: StringName, event_data: Dictionary = {}) -> void: pass diff --git a/classes/deck/nodes/delay.gd b/classes/deck/nodes/delay.gd index 1bea237..de6f090 100644 --- a/classes/deck/nodes/delay.gd +++ b/classes/deck/nodes/delay.gd @@ -7,37 +7,37 @@ func _init(): node_type = name.to_snake_case() description = "A Node that passes through the input after the set time." category = "general" - + add_output_port(DeckType.Types.STRING, "Value", "") - + add_input_port(DeckType.Types.NUMERIC, "Delay Time", "field") add_input_port(DeckType.Types.NUMERIC, "Value", "field") - -func _receive(to_input_port : int, data: Variant, extra_data: Array = []) -> void: - + +func _receive(_to_input_port : int, data: Variant, _extra_data: Array = []) -> void: + thread = Thread.new() thread.start(handle_delay.bind(data)) - + func handle_delay(data): - + var goal_time = Time.get_ticks_msec() + (int(get_input_ports()[0].value_callback.call()) * 1000) - + while Time.get_ticks_msec() < goal_time: - + pass - - + + print("Delay over") send(0, data) - + func _notification(what): - + if what == NOTIFICATION_PREDELETE and thread != null: - + thread.wait_to_finish() - - + + diff --git a/classes/deck/nodes/dictionary_get_key.gd b/classes/deck/nodes/dictionary_get_key.gd index f49d26c..9d165f7 100644 --- a/classes/deck/nodes/dictionary_get_key.gd +++ b/classes/deck/nodes/dictionary_get_key.gd @@ -24,7 +24,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var d = request_value(0) if d == null: return null diff --git a/classes/deck/nodes/expression_node.gd b/classes/deck/nodes/expression_node.gd index ce2bdac..5a67666 100644 --- a/classes/deck/nodes/expression_node.gd +++ b/classes/deck/nodes/expression_node.gd @@ -9,28 +9,28 @@ func _init(): category = "general" props_to_serialize = [] - + add_output_port(DeckType.Types.ANY, "Expression Text", "codeblock") - -func _value_request(from_port : int) -> Variant: - + +func _value_request(_from_port : int) -> Variant: + var text = get_output_ports()[0].value_callback.call() - + var err = expr.parse(text) if err != OK: - + printerr(err) return null - - + + var res = expr.execute() if expr.has_execute_failed(): - + printerr("Expression Execution Failed: ", text) return null - - + + return res - + diff --git a/classes/deck/nodes/get_deck_var.gd b/classes/deck/nodes/get_deck_var.gd index d71d9ba..83b5547 100644 --- a/classes/deck/nodes/get_deck_var.gd +++ b/classes/deck/nodes/get_deck_var.gd @@ -14,6 +14,6 @@ func _init() -> void: ) -func _value_request(from_port: int) -> Variant: +func _value_request(_from_port: int) -> Variant: var key = ports[0].value_callback.call() return _belonging_to.variable_stack.get(key) diff --git a/classes/deck/nodes/group_node.gd b/classes/deck/nodes/group_node.gd index d2ba8e8..120c41b 100644 --- a/classes/deck/nodes/group_node.gd +++ b/classes/deck/nodes/group_node.gd @@ -16,7 +16,6 @@ func _init() -> void: func _pre_connection() -> void: for port_type: PortType in extra_ports: - var index_of_type: int match port_type: PortType.OUTPUT: add_output_port(DeckType.Types.ANY, "Output %s" % get_output_ports().size()) diff --git a/classes/deck/nodes/obs_scene_list.gd b/classes/deck/nodes/obs_scene_list.gd index 601942d..6c2498d 100644 --- a/classes/deck/nodes/obs_scene_list.gd +++ b/classes/deck/nodes/obs_scene_list.gd @@ -24,7 +24,7 @@ func _init() -> void: ) -func _receive(on_virtual_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(on_virtual_port: int, _data: Variant, _extra_data: Array = []) -> void: if on_virtual_port != 0: return @@ -43,7 +43,7 @@ func _receive(on_virtual_port: int, data: Variant, extra_data: Array = []) -> vo ports_updated.emit() -func _value_request(on_input_port: int) -> Variant: +func _value_request(_on_input_port: int) -> Variant: if ports[0].value != null: return ports[0].value diff --git a/classes/deck/nodes/obs_search_source.gd b/classes/deck/nodes/obs_search_source.gd index 7133f6a..28b7f93 100644 --- a/classes/deck/nodes/obs_search_source.gd +++ b/classes/deck/nodes/obs_search_source.gd @@ -27,7 +27,7 @@ func _init() -> void: ) -func _value_request(on_output_port: int) -> Variant: +func _value_request(_on_output_port: int) -> Variant: if noobs == null: noobs = Connections.obs_websocket diff --git a/classes/deck/nodes/obs_set_source_transform.gd b/classes/deck/nodes/obs_set_source_transform.gd index 7765800..73cfaec 100644 --- a/classes/deck/nodes/obs_set_source_transform.gd +++ b/classes/deck/nodes/obs_set_source_transform.gd @@ -41,7 +41,7 @@ func _init() -> void: ) -func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> void: #{ "scene_item_transform": { "alignment": 5, "bounds_alignment": 0, "bounds_height": 0, "bounds_type": "OBS_BOUNDS_NONE", "bounds_width": 0, "crop_bottom": 0, "crop_left": 0, "crop_right": 0, "crop_top": 0, "height": 257, "position_x": 1800, "position_y": 414, "rotation": 0, "scale_x": 1, "scale_y": 1, "source_height": 257, "source_width": 146, "width": 146 }} if to_input_port != 3: return diff --git a/classes/deck/nodes/obs_switch_scene.gd b/classes/deck/nodes/obs_switch_scene.gd index dd4861b..caf0742 100644 --- a/classes/deck/nodes/obs_switch_scene.gd +++ b/classes/deck/nodes/obs_switch_scene.gd @@ -23,7 +23,7 @@ func _init() -> void: ) -func _receive(on_input_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(on_input_port: int, _data: Variant, _extra_data: Array = []) -> void: if on_input_port != 1: return diff --git a/classes/deck/nodes/obs_vector_to_position.gd b/classes/deck/nodes/obs_vector_to_position.gd index d9f3acd..2e5a67d 100644 --- a/classes/deck/nodes/obs_vector_to_position.gd +++ b/classes/deck/nodes/obs_vector_to_position.gd @@ -17,7 +17,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var v = request_value(0) if !v: return null diff --git a/classes/deck/nodes/obs_websocket_generic_request.gd b/classes/deck/nodes/obs_websocket_generic_request.gd index e13ca8b..ca06daf 100644 --- a/classes/deck/nodes/obs_websocket_generic_request.gd +++ b/classes/deck/nodes/obs_websocket_generic_request.gd @@ -35,7 +35,7 @@ func _init() -> void: ) -func _receive(on_virtual_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(on_virtual_port: int, _data: Variant, _extra_data: Array = []) -> void: if on_virtual_port != 2: return diff --git a/classes/deck/nodes/set_deck_var.gd b/classes/deck/nodes/set_deck_var.gd index cb13b66..f2121d3 100644 --- a/classes/deck/nodes/set_deck_var.gd +++ b/classes/deck/nodes/set_deck_var.gd @@ -32,7 +32,7 @@ func _init() -> void: ) -func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> void: if to_input_port != 2: return diff --git a/classes/deck/nodes/string_constant.gd b/classes/deck/nodes/string_constant.gd index 9fab8bc..1abb9f0 100644 --- a/classes/deck/nodes/string_constant.gd +++ b/classes/deck/nodes/string_constant.gd @@ -12,7 +12,7 @@ func _init() -> void: "field" ) -func _value_request(from_port: int) -> Variant: +func _value_request(_from_port: int) -> Variant: if ports[0].value_callback.get_object(): return ports[0].value_callback.call() else: diff --git a/classes/deck/nodes/test_types.gd b/classes/deck/nodes/test_types.gd index d24a5d6..ef9b09c 100644 --- a/classes/deck/nodes/test_types.gd +++ b/classes/deck/nodes/test_types.gd @@ -26,7 +26,7 @@ func _init() -> void: add_input_port(DeckType.Types.BOOL, "Send", "button") -func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void: +func _receive(to_input_port: int, data: Variant, _extra_data: Array = []) -> void: if to_input_port == 6: send(0, false) send(1, 1.0) diff --git a/classes/deck/nodes/vector_add.gd b/classes/deck/nodes/vector_add.gd index bcd7fe4..573d7fb 100644 --- a/classes/deck/nodes/vector_add.gd +++ b/classes/deck/nodes/vector_add.gd @@ -21,7 +21,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var va = request_value(0) var vb = request_value(1) diff --git a/classes/deck/nodes/vector_compose.gd b/classes/deck/nodes/vector_compose.gd index 7fc1d9f..363f1da 100644 --- a/classes/deck/nodes/vector_compose.gd +++ b/classes/deck/nodes/vector_compose.gd @@ -24,7 +24,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Dictionary: +func _value_request(_on_port: int) -> Dictionary: var x = float(get_value_for_input_port(0)) var y = float(get_value_for_input_port(1)) return {"x": x, "y": y} diff --git a/classes/deck/nodes/vector_dot.gd b/classes/deck/nodes/vector_dot.gd index bffff3c..feaf4f9 100644 --- a/classes/deck/nodes/vector_dot.gd +++ b/classes/deck/nodes/vector_dot.gd @@ -22,7 +22,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var va = request_value(0) var vb = request_value(1) diff --git a/classes/deck/nodes/vector_multiply.gd b/classes/deck/nodes/vector_multiply.gd index 725ff71..83b09ad 100644 --- a/classes/deck/nodes/vector_multiply.gd +++ b/classes/deck/nodes/vector_multiply.gd @@ -23,7 +23,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var v = request_value(0) if !v: diff --git a/classes/deck/nodes/vector_normalize.gd b/classes/deck/nodes/vector_normalize.gd index 88d865b..976ef89 100644 --- a/classes/deck/nodes/vector_normalize.gd +++ b/classes/deck/nodes/vector_normalize.gd @@ -18,7 +18,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var v = request_value(0) if !v: return null diff --git a/classes/deck/nodes/vector_subtract.gd b/classes/deck/nodes/vector_subtract.gd index 560ebc7..f8f5adc 100644 --- a/classes/deck/nodes/vector_subtract.gd +++ b/classes/deck/nodes/vector_subtract.gd @@ -21,7 +21,7 @@ func _init() -> void: ) -func _value_request(on_port: int) -> Variant: +func _value_request(_on_port: int) -> Variant: var va = request_value(0) var vb = request_value(1) diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index b2577aa..113e9b9 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -115,13 +115,6 @@ func initialize_from_deck() -> void: add_child(node_renderer) node_renderer.position_offset = node_renderer.node.position_as_vector2() - for node_id in deck.nodes: - var node: DeckNode = deck.nodes[node_id] - var from_node = get_children().filter( - func(c: DeckNodeRendererGraphNode): - return c.node._id == node_id - )[0] - refresh_connections() ## Loops through all [DeckNode]s in [member Deck.nodes] and calls @@ -268,7 +261,7 @@ func _on_copy_nodes_request() -> void: if selected.is_empty(): return - var selected_ids: Array[String] + var selected_ids: Array[String] = [] selected_ids.assign(selected.map( func(x: DeckNodeRendererGraphNode): return x.node._id @@ -296,7 +289,7 @@ func _on_duplicate_nodes_request() -> void: if selected.is_empty(): return - var selected_ids: Array[String] + var selected_ids: Array[String] = [] selected_ids.assign(selected.map( func(x: DeckNodeRendererGraphNode): return x.node._id