Many bug fixes, record node now takes custom parameters

This commit is contained in:
The 64th Gamer 2025-04-08 06:11:54 -06:00
parent ece5f8d724
commit 8993f80078
9 changed files with 132 additions and 10 deletions

View file

@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://bwvshov2sptun"]
[gd_scene load_steps=2 format=3 uid="uid://bwvshov2sptun"]
[ext_resource type="Script" uid="uid://0trc0nel0023" path="res://Scripts/GL_Node_Add.gd" id="1_vw1dw"]
[node name="OptionButton" type="OptionButton"]
offset_right = 68.0
@ -12,3 +14,63 @@ popup/item_1/text = "+Add Bool"
popup/item_1/id = 1
popup/item_2/text = "+Add Color"
popup/item_2/id = 2
script = ExtResource("1_vw1dw")
[node name="Panel" type="PanelContainer" parent="."]
visible = false
z_index = 10
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -75.0
offset_top = -130.0
offset_right = 75.0
grow_horizontal = 2
grow_vertical = 0
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
text = "Set Name"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
text = "X"
[node name="MarginContainer" type="MarginContainer" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="LineEdit" type="LineEdit" parent="Panel/MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
placeholder_text = "name"
alignment = 1
[connection signal="item_selected" from="." to="." method="_selected"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/Button" to="." method="_cancelled"]
[connection signal="text_submitted" from="Panel/MarginContainer/VBoxContainer/MarginContainer/LineEdit" to="." method="_named"]

View file

@ -3,6 +3,7 @@
[ext_resource type="Script" uid="uid://c46u2u0lup1mm" path="res://Scripts/GL_Search.gd" id="1_g1g1x"]
[node name="Search" type="Control"]
z_index = 100
custom_minimum_size = Vector2(200, 200)
layout_mode = 3
anchors_preset = 15

View file

@ -105,11 +105,10 @@ func _process(delta):
match(animParameters[key]["type"]):
"standard":
var value = float(animParameters[key]["signal_value"])
if value > 0.01:
if value > 0.5:
animParameters[key]["value"] = clamp(float(animParameters[key]["value"]) + (delta * animParameters[key]["out_speed"] * value),0,1)
else:
elif value < 0.5:
animParameters[key]["value"] = clamp(float(animParameters[key]["value"]) - (delta * animParameters[key]["in_speed"] * (1 - value)),0,1)
"move_to":
animParameters[key]["value"] = lerp(float(animParameters[key]["value"]), float(animParameters[key]["signal_value"]),delta * animParameters[key]["out_speed"])
var anim_length = anim_player.get_animation(key).length

View file

@ -17,6 +17,6 @@ func _input(event):
# Check if the mouse wheel up or down button is pressed
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
rows["Output"]["output"] = clamp(rows["Output"]["output"] + rows["Step Size"]["input"], 0, 1)
rows["Output"]["output"] = float(clamp(rows["Output"]["output"] + rows["Step Size"]["input"], 0, 1))
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
rows["Output"]["output"] = clamp(rows["Output"]["output"] - rows["Step Size"]["input"], 0, 1)
rows["Output"]["output"] = float(clamp(rows["Output"]["output"] - rows["Step Size"]["input"], 0, 1))

View file

@ -6,6 +6,7 @@ var dragging : bool
var canDrag : bool
var dragOffset : Vector2
var loadNodeRow : Resource
var special_condition : String
func _ready():
loadNodeRow = preload("res://Scenes/Nodes/Node Row.tscn")
@ -32,6 +33,8 @@ func _update_visuals():
for child in holder.get_children():
if child.name.contains("Node Row"):
child.queue_free()
if child.name.contains("OptionButton"):
child.queue_free()
for key in rows:
var nodeRow = loadNodeRow.instantiate()
holder.add_child(nodeRow)
@ -41,8 +44,10 @@ func _update_visuals():
var output = nodeRow.get_node("Output") as GL_Node_Point
input.valueName = str(key)
input.mainNode = self
input.update_lines()
output.valueName = str(key)
output.mainNode = self
output.update_lines()
if rows[key]["picker"] == true:
match typeof(rows[key]["pickValue"]):
TYPE_FLOAT:
@ -61,6 +66,12 @@ func _update_visuals():
_set_inout_type(nodeRow.get_node("Input") as Button,rows[key]["input"])
_set_inout_type(nodeRow.get_node("Output") as Button,rows[key]["output"])
match(special_condition):
"Record Node":
var add = load("res://Scenes/Nodes/Node Add.tscn").instantiate()
holder.add_child(add)
(add as GL_Node_Add).mainNode = self
func assignPick(pick:GL_Node_Picker,key:String):
if pick != null:
@ -96,6 +107,8 @@ func _set_title(name:String):
(get_node("Margins").get_node("Holder").get_node("Title") as Label).text = name
func _create_row(name:String,input,output,picker:bool,pickDefault,pickFloatMaximum:float):
if rows.has(name):
return
rows[name] = {"input": input, "output": output, "connections": [], "picker":picker,"pickValue":pickDefault,"backConnected":false,"pickFloatMax":pickFloatMaximum}
func _recieve_input(inputName:String,value):

27
Scripts/GL_Node_Add.gd Normal file
View file

@ -0,0 +1,27 @@
extends OptionButton
class_name GL_Node_Add
var mainNode:GL_Node
var setIndex:int
func _selected(index:int):
disabled = true
setIndex = index
(get_node("Panel") as PanelContainer).visible = true
func _named(name:String):
(get_node("Panel") as PanelContainer).visible = false
if name == "":
name = "my_property"
disabled = false
match(setIndex):
0:
mainNode._create_row(name,0.0,0.0,true,0.0,1.0)
1:
mainNode._create_row(name,false,false,true,false,0)
2:
mainNode._create_row(name,Color.WHITE,Color.WHITE,true,Color.WHITE,0)
mainNode._update_visuals()
func _cancelled():
disabled = false
(get_node("Panel") as PanelContainer).visible = false

View file

@ -0,0 +1 @@
uid://0trc0nel0023

View file

@ -14,7 +14,18 @@ func _process(delta):
if previewLine == null:
previewLine = _create_line()
previewLine.points[0] = global_position + Vector2(size.x / 2, size.y / 2)
previewLine.points[1] = get_viewport().get_mouse_position()# - previewLine.global_position
previewLine.points[1] = get_viewport().get_mouse_position()
var output = mainNode.rows[valueName]["output"]
match typeof(output):
TYPE_FLOAT:
previewLine.default_color = Color(0.254902 * output, 0.411765 * output, 0.882353 * output, 1)
TYPE_BOOL:
if output:
previewLine.default_color = Color.ORANGE
else:
previewLine.default_color = Color.BLACK
TYPE_COLOR:
previewLine.default_color = output
var connections = mainNode.rows[valueName].get("connections",[])
if connections != []:
@ -51,6 +62,8 @@ func _create_line() -> Line2D:
return previewLine
func update_lines():
if name == "Input":
return
for child in allLines:
child.queue_free()
allLines = []

View file

@ -1,14 +1,20 @@
extends GL_Node
var recording:Dictionary
func _ready():
super._ready()
_set_title("Record")
special_condition = "Record Node"
_create_row("Recording",false,null,true,false,0)
_create_row("Current Time",0.0,null,false,0,0)
_create_row("Current Time",0.0,0.0,false,0,0)
_update_visuals()
pass
func _process(delta):
super._process(delta)
#rows["Output"]["output"] = rows["Output"]["pickValue"]
#_send_input("Output")
for key in rows:
rows[key]["output"] = rows[key]["input"]
apply_pick_values()
for key in rows:
_send_input(key)