From 5bb84956ff51014aee4a1c3caa38433c6c9eb6e1 Mon Sep 17 00:00:00 2001 From: KawaiiZenbo <48113593+kawaiizenbo@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:28:03 -0700 Subject: [PATCH] merge in 0.2 changes --- Scenes/Node Types/Bool.tscn | 17 +++++ Scenes/Node Types/Color.tscn | 17 +++++ Scenes/Node Types/Invert.tscn | 17 +++++ Scenes/Node Types/Record.tscn | 2 +- Scenes/Nodes/Node Row.tscn | 1 + Scenes/Nodes/Node.tscn | 13 +++- Scenes/UI/Node Map.tscn | 7 +- Scripts/GL_Bool.gd | 14 ++++ Scripts/GL_Bool.gd.uid | 1 + Scripts/GL_Color.gd | 14 ++++ Scripts/GL_Color.gd.uid | 1 + Scripts/GL_Float.gd | 4 +- Scripts/GL_Invert.gd | 21 ++++++ Scripts/GL_Invert.gd.uid | 1 + Scripts/GL_Node.gd | 10 ++- Scripts/GL_Node_Map.gd | 62 ++++++++++++++-- Scripts/GL_Node_Point.gd | 8 +++ Scripts/GL_Record.gd | 130 +++++++++++++++++++++++++++++++++- Scripts/GL_Search.gd | 5 +- Scripts/GL_Spotlight.gd | 2 +- 20 files changed, 331 insertions(+), 16 deletions(-) create mode 100644 Scenes/Node Types/Bool.tscn create mode 100644 Scenes/Node Types/Color.tscn create mode 100644 Scenes/Node Types/Invert.tscn create mode 100644 Scripts/GL_Bool.gd create mode 100644 Scripts/GL_Bool.gd.uid create mode 100644 Scripts/GL_Color.gd create mode 100644 Scripts/GL_Color.gd.uid create mode 100644 Scripts/GL_Invert.gd create mode 100644 Scripts/GL_Invert.gd.uid diff --git a/Scenes/Node Types/Bool.tscn b/Scenes/Node Types/Bool.tscn new file mode 100644 index 0000000..87874ed --- /dev/null +++ b/Scenes/Node Types/Bool.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://ul4mdxf3qx5b"] + +[ext_resource type="PackedScene" uid="uid://b0arjg8r75f8y" path="res://Scenes/Nodes/Node.tscn" id="1_qf2se"] +[ext_resource type="Script" uid="uid://3rg2qunautt5" path="res://Scripts/GL_Bool.gd" id="2_qf2se"] + +[node name="Node" type="Control"] +layout_mode = 3 +anchors_preset = 0 +mouse_filter = 1 + +[node name="Node" parent="." groups=["GL Node"] instance=ExtResource("1_qf2se")] +layout_mode = 0 +tooltip_text = "A bool refers to something on or off. Can also connect to float inputs as a converted 0.0 or 1.0." +script = ExtResource("2_qf2se") + +[connection signal="mouse_entered" from="Node" to="Node" method="mouse_enter"] +[connection signal="mouse_exited" from="Node" to="Node" method="mouse_exit"] diff --git a/Scenes/Node Types/Color.tscn b/Scenes/Node Types/Color.tscn new file mode 100644 index 0000000..a7cee0a --- /dev/null +++ b/Scenes/Node Types/Color.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://dd1nkkq5jvu6t"] + +[ext_resource type="PackedScene" uid="uid://b0arjg8r75f8y" path="res://Scenes/Nodes/Node.tscn" id="1_ouhok"] +[ext_resource type="Script" uid="uid://bi27y3jflhagl" path="res://Scripts/GL_Color.gd" id="2_ouhok"] + +[node name="Node" type="Control"] +layout_mode = 3 +anchors_preset = 0 +mouse_filter = 1 + +[node name="Node" parent="." groups=["GL Node"] instance=ExtResource("1_ouhok")] +layout_mode = 0 +tooltip_text = "Outputs a color." +script = ExtResource("2_ouhok") + +[connection signal="mouse_entered" from="Node" to="Node" method="mouse_enter"] +[connection signal="mouse_exited" from="Node" to="Node" method="mouse_exit"] diff --git a/Scenes/Node Types/Invert.tscn b/Scenes/Node Types/Invert.tscn new file mode 100644 index 0000000..4b39d69 --- /dev/null +++ b/Scenes/Node Types/Invert.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://brgcm5aas061o"] + +[ext_resource type="PackedScene" uid="uid://b0arjg8r75f8y" path="res://Scenes/Nodes/Node.tscn" id="1_x0ewx"] +[ext_resource type="Script" uid="uid://8acchs5jv70x" path="res://Scripts/GL_Invert.gd" id="2_x0ewx"] + +[node name="Node" type="Control"] +layout_mode = 3 +anchors_preset = 0 +mouse_filter = 1 + +[node name="Node" parent="." groups=["GL Node"] instance=ExtResource("1_x0ewx")] +layout_mode = 0 +tooltip_text = "Inverts the input, not the same as multiplying by -1. This is 1 - Input. The 'On' input toggles the inversion." +script = ExtResource("2_x0ewx") + +[connection signal="mouse_entered" from="Node" to="Node" method="mouse_enter"] +[connection signal="mouse_exited" from="Node" to="Node" method="mouse_exit"] diff --git a/Scenes/Node Types/Record.tscn b/Scenes/Node Types/Record.tscn index ae5f15e..a20d5eb 100644 --- a/Scenes/Node Types/Record.tscn +++ b/Scenes/Node Types/Record.tscn @@ -10,7 +10,7 @@ mouse_filter = 1 [node name="Node" parent="." groups=["GL Node"] instance=ExtResource("1_ltih5")] layout_mode = 0 -tooltip_text = "When 'Recording' is set to ON, it records inputs and saves them with the time from 'Current Time'. Going back in time will play back those inputs along with any you send in. Rows can be added and named based on how you want them identified." +tooltip_text = "When 'Recording' is set to ON, it records inputs and saves them with the time from 'Current Time'. Going back in time will play back those inputs along with any you send in. Rows can be added and named based on how you want them identified. When recording past the first time, it will ignore your current input values until they change, then it will record alongside your previous inputs for that particular row." script = ExtResource("2_ltih5") [connection signal="mouse_entered" from="Node" to="Node" method="mouse_enter"] diff --git a/Scenes/Nodes/Node Row.tscn b/Scenes/Nodes/Node Row.tscn index e0cda79..88e9a20 100644 --- a/Scenes/Nodes/Node Row.tscn +++ b/Scenes/Nodes/Node Row.tscn @@ -47,6 +47,7 @@ mouse_default_cursor_shape = 2 text = "◉" script = ExtResource("1_fygh4") +[connection signal="button_down" from="Input" to="Input" method="_detatch"] [connection signal="mouse_entered" from="Input" to="Input" method="mouse_enter"] [connection signal="mouse_exited" from="Input" to="Input" method="mouse_exit"] [connection signal="value_changed" from="Pick Float" to="Pick Float" method="value_changed"] diff --git a/Scenes/Nodes/Node.tscn b/Scenes/Nodes/Node.tscn index 42aa5ec..a6a437f 100644 --- a/Scenes/Nodes/Node.tscn +++ b/Scenes/Nodes/Node.tscn @@ -18,8 +18,19 @@ layout_mode = 2 [node name="Holder" type="VBoxContainer" parent="Margins"] layout_mode = 2 -[node name="Title" type="Label" parent="Margins/Holder"] +[node name="Title" type="HBoxContainer" parent="Margins/Holder"] layout_mode = 2 + +[node name="Title Label" type="Label" parent="Margins/Holder/Title"] +layout_mode = 2 +size_flags_horizontal = 3 text = "Test" horizontal_alignment = 1 clip_text = true + +[node name="Exit Button" type="Button" parent="Margins/Holder/Title"] +layout_mode = 2 +size_flags_horizontal = 8 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 8 +text = "X" diff --git a/Scenes/UI/Node Map.tscn b/Scenes/UI/Node Map.tscn index 959c353..0085f27 100644 --- a/Scenes/UI/Node Map.tscn +++ b/Scenes/UI/Node Map.tscn @@ -32,5 +32,8 @@ stretch_mode = 1 [node name="Search" parent="." instance=ExtResource("1_xwfut")] visible = false layout_mode = 1 -offset_right = -1400.0 -offset_bottom = -700.0 + +[node name="Holder" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 diff --git a/Scripts/GL_Bool.gd b/Scripts/GL_Bool.gd new file mode 100644 index 0000000..bdad6e7 --- /dev/null +++ b/Scripts/GL_Bool.gd @@ -0,0 +1,14 @@ +extends GL_Node + +func _ready(): + super._ready() + _set_title("Bool") + _create_row("Output",null,false,true,false,0) + _update_visuals() + +func _process(delta): + super._process(delta) + apply_pick_values() + for key in rows: + rows[key]["output"] = rows[key]["input"] + _send_input("Output") diff --git a/Scripts/GL_Bool.gd.uid b/Scripts/GL_Bool.gd.uid new file mode 100644 index 0000000..74c573c --- /dev/null +++ b/Scripts/GL_Bool.gd.uid @@ -0,0 +1 @@ +uid://3rg2qunautt5 diff --git a/Scripts/GL_Color.gd b/Scripts/GL_Color.gd new file mode 100644 index 0000000..4810669 --- /dev/null +++ b/Scripts/GL_Color.gd @@ -0,0 +1,14 @@ +extends GL_Node + +func _ready(): + super._ready() + _set_title("Color") + _create_row("Output",null,Color.WHITE,true,Color.WHITE,0) + _update_visuals() + +func _process(delta): + super._process(delta) + apply_pick_values() + for key in rows: + rows[key]["output"] = rows[key]["input"] + _send_input("Output") diff --git a/Scripts/GL_Color.gd.uid b/Scripts/GL_Color.gd.uid new file mode 100644 index 0000000..b941783 --- /dev/null +++ b/Scripts/GL_Color.gd.uid @@ -0,0 +1 @@ +uid://bi27y3jflhagl diff --git a/Scripts/GL_Float.gd b/Scripts/GL_Float.gd index 25afcdb..12f4182 100644 --- a/Scripts/GL_Float.gd +++ b/Scripts/GL_Float.gd @@ -8,5 +8,7 @@ func _ready(): func _process(delta): super._process(delta) - rows["Output"]["output"] = rows["Output"]["pickValue"] + apply_pick_values() + for key in rows: + rows[key]["output"] = rows[key]["input"] _send_input("Output") diff --git a/Scripts/GL_Invert.gd b/Scripts/GL_Invert.gd new file mode 100644 index 0000000..51a15f3 --- /dev/null +++ b/Scripts/GL_Invert.gd @@ -0,0 +1,21 @@ +extends GL_Node + + +func _ready(): + super._ready() + _set_title("Invert") + _create_row("Value",0.0,0.0,false,0,0) + _create_row("On",true,null,true,true,0) + _update_visuals() + +func _process(delta): + super._process(delta) + for key in rows: + rows[key]["output"] = rows[key]["input"] + apply_pick_values() + + if rows["On"]["output"] == true: + rows["Value"]["output"] = 1 - rows["Value"]["input"] + else: + rows["Value"]["output"] = rows["Value"]["input"] + _send_input("Value") diff --git a/Scripts/GL_Invert.gd.uid b/Scripts/GL_Invert.gd.uid new file mode 100644 index 0000000..a346162 --- /dev/null +++ b/Scripts/GL_Invert.gd.uid @@ -0,0 +1 @@ +uid://8acchs5jv70x diff --git a/Scripts/GL_Node.gd b/Scripts/GL_Node.gd index ec9012e..2281eba 100644 --- a/Scripts/GL_Node.gd +++ b/Scripts/GL_Node.gd @@ -10,6 +10,7 @@ var special_condition : String func _ready(): loadNodeRow = preload("res://Scenes/Nodes/Node Row.tscn") + (get_node("Margins").get_node("Holder").get_node("Title").get_node("Exit Button") as Button).connect("button_down",self.delete_whole_node) func _process(delta): if dragging: @@ -104,7 +105,7 @@ func _set_inout_type(label:Button, value): label.visible = false func _set_title(name:String): - (get_node("Margins").get_node("Holder").get_node("Title") as Label).text = name + (get_node("Margins").get_node("Holder").get_node("Title").get_node("Title Label") as Label).text = name func _create_row(name:String,input,output,picker:bool,pickDefault,pickFloatMaximum:float): if rows.has(name): @@ -191,3 +192,10 @@ func apply_pick_values(): for key in rows: if rows[key]["picker"] == true && rows[key]["backConnected"] == false: rows[key]["input"] = rows[key]["pickValue"] + +func delete_whole_node(): + for node in get_tree().get_nodes_in_group("Outputs"): + if node is GL_Node_Point: + for key in rows: + node.mainNode.destroy_connection(self,key) + queue_free() diff --git a/Scripts/GL_Node_Map.gd b/Scripts/GL_Node_Map.gd index 4c529db..ba8a701 100644 --- a/Scripts/GL_Node_Map.gd +++ b/Scripts/GL_Node_Map.gd @@ -1,15 +1,67 @@ extends Control +var holder: Control +var is_panning: bool = false +var last_mouse_pos: Vector2 +var is_hovered: bool = false + func _ready(): visible = false + holder = get_node("Holder") + + connect("mouse_entered", _on_mouse_entered) + connect("mouse_exited", _on_mouse_exited) + +func _on_mouse_entered(): + is_hovered = true + +func _on_mouse_exited(): + is_hovered = false func _input(event: InputEvent) -> void: if event is InputEventKey and event.pressed: - match(event.keycode): + match event.keycode: KEY_ESCAPE: visible = not visible - - if visible: - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - else: + + if not visible: Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + return + else: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + + if not is_hovered: + return + + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_MIDDLE: + is_panning = event.pressed + if is_panning: + last_mouse_pos = event.position + + if event.pressed and (event.button_index == MOUSE_BUTTON_WHEEL_UP or event.button_index == MOUSE_BUTTON_WHEEL_DOWN): + var mouse_pos = event.position + var global_xform = holder.get_global_transform() + var local_mouse_pos = global_xform.affine_inverse().basis_xform(mouse_pos) + + var zoom_factor := 1.0 + if event.button_index == MOUSE_BUTTON_WHEEL_UP: + zoom_factor = 1.1 + elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN: + zoom_factor = 0.9 + + # Apply scale + holder.scale *= zoom_factor + + # Recalculate the new local position of the mouse after scaling + var new_global_xform = holder.get_global_transform() + var new_local_mouse_pos = new_global_xform.affine_inverse().basis_xform(mouse_pos) + + # Calculate offset to shift so the mouse stays “anchored” + var delta = (new_local_mouse_pos - local_mouse_pos) + holder.position += delta * holder.scale + + if event is InputEventMouseMotion and is_panning: + var delta = event.position - last_mouse_pos + holder.position += delta + last_mouse_pos = event.position diff --git a/Scripts/GL_Node_Point.gd b/Scripts/GL_Node_Point.gd index 9dafd6a..4847ebf 100644 --- a/Scripts/GL_Node_Point.gd +++ b/Scripts/GL_Node_Point.gd @@ -81,6 +81,11 @@ func _start_drag(): dragging = true lastToDrag = true +func _detatch(): + for node in get_tree().get_nodes_in_group("Outputs"): + if node is GL_Node_Point: + node._node_disconnect(mainNode,valueName) + func mouse_enter(): mouseInside = true @@ -101,3 +106,6 @@ func _node_connect(node:GL_Node,inputValue:String): return mainNode._create_connection(node,inputValue,valueName) update_lines() + +func _node_disconnect(node: GL_Node, outputValue: String): + mainNode.destroy_connection(node,outputValue) diff --git a/Scripts/GL_Record.gd b/Scripts/GL_Record.gd index 89366cf..5d63f7f 100644 --- a/Scripts/GL_Record.gd +++ b/Scripts/GL_Record.gd @@ -1,6 +1,12 @@ extends GL_Node - +var timer:float +const sampleRate = 0.05 var recording:Dictionary +var oldTime:float = 0.000030042452 #sorta random number +var time:float = 0 +var rng:RandomNumberGenerator +var oldRecording:bool +var defaultValues:Dictionary func _ready(): super._ready() @@ -9,12 +15,130 @@ func _ready(): _create_row("Recording",false,null,true,false,0) _create_row("Current Time",0.0,0.0,false,0,0) _update_visuals() + rng = RandomNumberGenerator.new() + rng.seed = Time.get_ticks_msec() pass func _process(delta): super._process(delta) - for key in rows: - rows[key]["output"] = rows[key]["input"] apply_pick_values() + for key in rows: + rows[key]["output"] = rows[key]["input"] + time = float(rows["Current Time"]["output"]) + _traverse() + var recordBool = rows["Recording"]["input"] + if recordBool == true: + if recordBool != oldRecording || time == 0: + for key in rows: + defaultValues[key] = rows[key]["output"] + if timer <= 0: + timer = sampleRate + _record() + timer -= delta + oldTime = time + oldRecording = recordBool for key in rows: _send_input(key) + +func _traverse(): + if time == oldTime: + return + for key in recording: + if key == "Recording" || key == "Current Time": + continue + if recording[key]["start"] == null || recording[key]["end"] == null: + continue + if recording[key]["current"] == null: + recording[key]["current"] = recording[key]["start"] + if time < oldTime: #rewind + continue #fix pls + else: #forward + var current = recording[key]["current"] + var newCurrent = recursive_traverse_forward(key,current) + if current != newCurrent: + recording[key]["lastUsed"] = current + recording[key]["current"] = newCurrent + if recording[key]["lastUsed"] != null && recording[key]["current"] != recording[key]["end"]: + rows[key]["output"] = lerp(recording[key]["list"][recording[key]["lastUsed"]]["value"],recording[key]["list"][recording[key]["current"]]["value"],remap_time(time,recording[key]["list"][recording[key]["lastUsed"]]["time"],recording[key]["list"][recording[key]["current"]]["time"])) +func remap_time(value: float, start: float, end: float) -> float: + if start == end: + return 0.0 + return (value - start) / (end - start) + + +func recursive_traverse_forward(key:String,current:String) -> String: + var dict = recording[key]["list"][current] + if dict["time"] > time: + if dict["back"] != null: + return recursive_traverse_forward(key,dict["back"]) + if dict["time"] <= time: + if dict["forward"] != null && recording[key]["list"][dict["forward"]]["time"] <= time: + return recursive_traverse_forward(key,dict["forward"]) + return current + +func _record(): + for key in recording: + if key == "Recording" || key == "Current Time": + continue + if defaultValues[key] == rows[key]["input"]: + continue + elif defaultValues[key] != null: + defaultValues[key] == null #is this gonna bite me back if I allow null values to pass + var currentSave = recording[key]["current"] + if currentSave == null: + var id = "ID_" + str(rng.randi()) + recording[key]["list"][id] = { + "value":rows[key]["input"], + "time":time, + "back":null, + "forward":null + } + recording[key]["current"] = id + recording[key]["start"] = id + recording[key]["end"] = id + rows[key]["output"] = recording[key]["list"][id]["value"] + continue + else: + if time < oldTime: #rewind + continue #fix pls + else: #forward + if recording[key]["list"][currentSave]["time"] == time: #paused recording + recording[key]["list"][currentSave]["value"] = rows[key]["input"] + rows[key]["output"] = rows[key]["input"] + elif recording[key]["list"][currentSave]["time"] < time: + var id = "ID_" + str(rng.randi()) + if recording[key]["list"][currentSave]["forward"] == null: + recording[key]["list"][id] = { + "value":rows[key]["input"], + "time":time, + "back":currentSave, + "forward":null + } + recording[key]["list"][currentSave]["forward"] = id + recording[key]["current"] = id + recording[key]["end"] = id + else: + var forward = recording[key]["list"][currentSave]["forward"] + recording[key]["list"][id] = { + "value":rows[key]["input"], + "time":time, + "back":currentSave, + "forward":forward + } + recording[key]["list"][forward]["back"] = id + recording[key]["list"][currentSave]["forward"] = id + recording[key]["current"] = id + rows[key]["output"] = recording[key]["list"][id]["value"] + #else: Somethings messed up and you need to re-traverse + + continue + pass + + +func _create_row(name:String,input,output,picker:bool,pickDefault,pickFloatMaximum:float): + super._create_row(name,input,output,picker,pickDefault,pickFloatMaximum) + if name == "Recording" || name == "Current Time": + return + for key in rows: + if !recording.has(key): + recording[key] = {"start":null,"end":null,"current":null,"list":{},"lastUsed":null} diff --git a/Scripts/GL_Search.gd b/Scripts/GL_Search.gd index 9bfad0f..48c03a3 100644 --- a/Scripts/GL_Search.gd +++ b/Scripts/GL_Search.gd @@ -3,7 +3,10 @@ extends Control var rows : Dictionary = { "CyberChuck":1, "CyberHelen":1, + "Bool":1, + "Color":1, "Float":1, + "Invert":1, "Keystrokes":1, "Keystroke Ramp":1, "Lerp":1, @@ -52,7 +55,7 @@ func _set_rows(): func _create_node(name:String): var node = load("res://Scenes/Node Types/" + name + ".tscn").instantiate() - get_parent().add_child(node) + get_parent().get_node("Holder").add_child(node) node = (node as Control).get_child(0) as GL_Node node.position = lastMousePos node._create_uuid() diff --git a/Scripts/GL_Spotlight.gd b/Scripts/GL_Spotlight.gd index 1982cc2..8fc86f9 100644 --- a/Scripts/GL_Spotlight.gd +++ b/Scripts/GL_Spotlight.gd @@ -10,7 +10,7 @@ func _ready(): func _sent_signals(signal_ID:String,the_signal): match(signal_ID): "intensity": - light.light_energy = the_signal * energyMultiplier + light.light_energy = max(the_signal,0) * energyMultiplier "color": if canChangeColor: light.light_color = the_signal