mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
use logger in nodes
This commit is contained in:
parent
d67ccdbad2
commit
7e35529100
12 changed files with 27 additions and 9 deletions
|
@ -30,7 +30,7 @@ func handle_delay(data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
print("Delay over")
|
#print("Delay over")
|
||||||
send(0, data)
|
send(0, data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ func _value_request(_from_port : int) -> Variant:
|
||||||
var err = expr.parse(text, ["deck_var", "input"])
|
var err = expr.parse(text, ["deck_var", "input"])
|
||||||
if err != OK:
|
if err != OK:
|
||||||
|
|
||||||
|
DeckHolder.logger.log_node("Expression parse failed: %s" % err, Logger.LogType.ERROR)
|
||||||
printerr(err)
|
printerr(err)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ func _value_request(_from_port : int) -> Variant:
|
||||||
var res = expr.execute([_belonging_to.variable_stack, request_value(0)])
|
var res = expr.execute([_belonging_to.variable_stack, request_value(0)])
|
||||||
if expr.has_execute_failed():
|
if expr.has_execute_failed():
|
||||||
|
|
||||||
printerr("Expression Execution Failed: ", text)
|
DeckHolder.logger.log_node("Expression Execution Failed: %s" % text, Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func _on_outgoing_connection_removed(port_idx: int) -> void:
|
||||||
if !(outgoing_connections.get(port, {}) as Dictionary).is_empty():
|
if !(outgoing_connections.get(port, {}) as Dictionary).is_empty():
|
||||||
last_connected_port = port
|
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:
|
if port_idx < last_connected_port:
|
||||||
return
|
return
|
||||||
|
|
|
@ -39,7 +39,7 @@ func _on_incoming_connection_removed(port_idx: int) -> void:
|
||||||
if !(incoming_connections[port] as Dictionary).is_empty():
|
if !(incoming_connections[port] as Dictionary).is_empty():
|
||||||
last_connected_port = port
|
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:
|
if port_idx < last_connected_port:
|
||||||
return
|
return
|
||||||
|
|
|
@ -34,9 +34,11 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
|
||||||
if to_input_port != 1:
|
if to_input_port != 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
var data_to_print = resolve_input_port_value(0)
|
var data_to_print = str(resolve_input_port_value(0))
|
||||||
if data_to_print == null || data_to_print.is_empty():
|
if data_to_print == null:
|
||||||
data_to_print = str(data)
|
data_to_print = str(data)
|
||||||
|
if (data_to_print as String).is_empty():
|
||||||
|
data_to_print = "<nothing>"
|
||||||
|
|
||||||
times_activated += 1
|
times_activated += 1
|
||||||
|
|
||||||
|
@ -44,4 +46,6 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
|
||||||
#print(data_to_print)
|
#print(data_to_print)
|
||||||
#print("extra data: ", extra_data)
|
#print("extra data: ", extra_data)
|
||||||
DeckHolder.logger.log_node(data_to_print)
|
DeckHolder.logger.log_node(data_to_print)
|
||||||
|
if !extra_data.is_empty():
|
||||||
|
DeckHolder.logger.log_node(str("Extra data: ", extra_data))
|
||||||
send(0, true)
|
send(0, true)
|
||||||
|
|
|
@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant:
|
||||||
var vb = request_value(1)
|
var vb = request_value(1)
|
||||||
|
|
||||||
if !va || !vb:
|
if !va || !vb:
|
||||||
|
DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
var res := {}
|
var res := {}
|
||||||
|
|
|
@ -25,9 +25,11 @@ func _init() -> void:
|
||||||
func _value_request(on_port: int) -> Variant:
|
func _value_request(on_port: int) -> Variant:
|
||||||
var v = request_value(0)
|
var v = request_value(0)
|
||||||
if !v:
|
if !v:
|
||||||
|
DeckHolder.logger.log_node("Vector Decompose: the vector is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
if on_port == 0:
|
if on_port == 0:
|
||||||
|
|
|
@ -27,12 +27,15 @@ func _value_request(_on_port: int) -> Variant:
|
||||||
var vb = request_value(1)
|
var vb = request_value(1)
|
||||||
|
|
||||||
if !va || !vb:
|
if !va || !vb:
|
||||||
|
DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
|
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 null
|
||||||
|
|
||||||
return va.x * vb.x + va.y * vb.y
|
return va.x * vb.x + va.y * vb.y
|
||||||
|
|
|
@ -27,9 +27,11 @@ func _value_request(_on_port: int) -> Variant:
|
||||||
var v = request_value(0)
|
var v = request_value(0)
|
||||||
|
|
||||||
if !v:
|
if !v:
|
||||||
|
DeckHolder.logger.log_node("Vector Mult: the vector is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
var s = float(resolve_input_port_value(1))
|
var s = float(resolve_input_port_value(1))
|
||||||
|
|
|
@ -21,9 +21,11 @@ func _init() -> void:
|
||||||
func _value_request(_on_port: int) -> Variant:
|
func _value_request(_on_port: int) -> Variant:
|
||||||
var v = request_value(0)
|
var v = request_value(0)
|
||||||
if !v:
|
if !v:
|
||||||
|
DeckHolder.logger.log_node("Vector Normalize: the vector is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
var l: float = (v.x ** 2.0) + (v.y ** 2.0)
|
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
|
res.y = res.y / l
|
||||||
return res
|
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
|
return null
|
||||||
|
|
|
@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant:
|
||||||
var vb = request_value(1)
|
var vb = request_value(1)
|
||||||
|
|
||||||
if !va || !vb:
|
if !va || !vb:
|
||||||
|
DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
|
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
|
return null
|
||||||
|
|
||||||
var res := {}
|
var res := {}
|
||||||
|
|
|
@ -195,7 +195,6 @@ func get_selected_nodes() -> Array:
|
||||||
## based off the action "group_nodes".
|
## based off the action "group_nodes".
|
||||||
func _gui_input(event: InputEvent) -> void:
|
func _gui_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("group_nodes") && get_selected_nodes().size() > 0:
|
if event.is_action_pressed("group_nodes") && get_selected_nodes().size() > 0:
|
||||||
print("?")
|
|
||||||
clear_connections()
|
clear_connections()
|
||||||
var nodes = get_selected_nodes().map(
|
var nodes = get_selected_nodes().map(
|
||||||
func(x: DeckNodeRendererGraphNode):
|
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 event.is_action_pressed("enter_group") && get_selected_nodes().size() == 1:
|
||||||
if !((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.node_type == "group_node"):
|
if !((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.node_type == "group_node"):
|
||||||
return
|
return
|
||||||
print("tried to enter group")
|
|
||||||
group_enter_requested.emit((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.group_id)
|
group_enter_requested.emit((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.group_id)
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue