First screen now working

This commit is contained in:
The 64th Gamer 2025-04-07 04:22:46 -06:00
parent e10b6ec7d4
commit b3d24b3de1
6 changed files with 56 additions and 49 deletions

View file

@ -5,12 +5,12 @@
[node name="Sine" type="Control"] [node name="Sine" type="Control"]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 0
anchor_right = 1.0 mouse_filter = 2
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Node" parent="." instance=ExtResource("1_m6pki")] [node name="Node" parent="." instance=ExtResource("1_m6pki")]
layout_mode = 0 layout_mode = 0
script = ExtResource("2_claki") script = ExtResource("2_claki")
[connection signal="mouse_entered" from="Node" to="Node" method="mouse_enter"]
[connection signal="mouse_exited" from="Node" to="Node" method="mouse_exit"]

View file

@ -1,22 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://bdcxusbd86oox"] [gd_scene load_steps=2 format=3 uid="uid://bdcxusbd86oox"]
[ext_resource type="Script" uid="uid://dwl36vn5chqmq" path="res://Scripts/GL_Node_Point.gd" id="1_fygh4"] [ext_resource type="Script" uid="uid://dwl36vn5chqmq" path="res://Scripts/GL_Node_Point.gd" id="1_fygh4"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ljh8l"]
size = Vector2(15, 15)
[node name="Node Row" type="HBoxContainer"] [node name="Node Row" type="HBoxContainer"]
[node name="Input" type="Label" parent="."] [node name="Input" type="Button" parent="."]
layout_mode = 2 layout_mode = 2
mouse_default_cursor_shape = 2
text = "◉" text = "◉"
[node name="Point" type="Area2D" parent="Input"]
script = ExtResource("1_fygh4") script = ExtResource("1_fygh4")
isOutput = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Input/Point"]
position = Vector2(7, 13)
shape = SubResource("RectangleShape2D_ljh8l")
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
layout_mode = 2 layout_mode = 2
@ -24,15 +17,12 @@ size_flags_horizontal = 3
text = "Testtesttesttesttest" text = "Testtesttesttesttest"
clip_text = true clip_text = true
[node name="Output" type="Label" parent="."] [node name="Output" type="Button" parent="."]
layout_mode = 2 layout_mode = 2
mouse_default_cursor_shape = 2
text = "◉" text = "◉"
[node name="Point" type="Area2D" parent="Output"]
position = Vector2(-23, 0)
script = ExtResource("1_fygh4") script = ExtResource("1_fygh4")
isOutput = true isOutput = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Output/Point"] [connection signal="pressed" from="Input" to="Input" method="_start_drag"]
position = Vector2(7, 13) [connection signal="pressed" from="Output" to="Output" method="_start_drag"]
shape = SubResource("RectangleShape2D_ljh8l")

View file

@ -4,6 +4,7 @@
custom_minimum_size = Vector2(100, 100) custom_minimum_size = Vector2(100, 100)
offset_right = 100.0 offset_right = 100.0
offset_bottom = 100.0 offset_bottom = 100.0
mouse_default_cursor_shape = 6
[node name="Holder" type="VBoxContainer" parent="."] [node name="Holder" type="VBoxContainer" parent="."]
custom_minimum_size = Vector2(100, 100) custom_minimum_size = Vector2(100, 100)

View file

@ -2,13 +2,23 @@ extends Panel
class_name GL_Node class_name GL_Node
var rows : Dictionary var rows : Dictionary
var uuid : int #REMEMBER TO SET THIS ON CREATION var uuid : int #REMEMBER TO SET THIS ON CREATION
var dragging : bool
var canDrag : bool
func _ready(): func _ready():
_init_visuals() _init_visuals()
pass
func _process(delta): func _process(delta):
pass if dragging:
position = get_viewport().get_mouse_position()
func _on_input_event(viewport, event, shape_idx):
print(str(event) + "A")
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT && event.pressed && canDrag:
dragging = true
if event.button_index == MOUSE_BUTTON_LEFT && event.canceled && dragging:
dragging = false
func _create_uuid(): func _create_uuid():
var rand = RandomNumberGenerator.new() var rand = RandomNumberGenerator.new()
@ -20,24 +30,22 @@ func _init_visuals():
call_deferred("add_child",nodeVisuals) call_deferred("add_child",nodeVisuals)
func _update_visuals(): func _update_visuals():
var holder = get_node("Node").get_node("Holder") var holder = get_node("Holder")
for child in holder.get_children(): for child in holder.get_children():
if child.name != "Title": if child.name != "Title":
child.queue_free() child.queue_free()
for key in rows: for key in rows:
if rows[key].get("type","default") == "default": if rows[key].get("type","default") == "default":
var nodeRow = load("res://Scenes/Nodes/Node Row.tscn").instantiate() var nodeRow = load("res://Scenes/Nodes/Node Row.tscn").instantiate()
holder.call_deferred("add_child",nodeRow) holder.add_child(nodeRow)
(nodeRow.get_node("Label") as Label).text = str(key) (nodeRow.get_node("Label") as Label).text = str(key)
(nodeRow.get_node("Input").get_note("Point") as GL_Node_Point).valueName = str(key) (nodeRow.get_node("Input") as GL_Node_Point).valueName = str(key)
(nodeRow.get_node("Output").get_note("Point") as GL_Node_Point).valueName = str(key) (nodeRow.get_node("Output") as GL_Node_Point).valueName = str(key)
_set_inout_type(nodeRow.get_node("Input") as Label,rows[key].get("input","null")) _set_inout_type(nodeRow.get_node("Input") as Button,rows[key]["input"])
_set_inout_type(nodeRow.get_node("Output") as Label,rows[key].get("output","null")) _set_inout_type(nodeRow.get_node("Output") as Button,rows[key]["output"])
func _set_inout_type(label:Label, value): func _set_inout_type(label:Button, value):
match typeof(value): match typeof(value):
_:
label.visible = false
TYPE_FLOAT: TYPE_FLOAT:
label.text = "" label.text = ""
label.add_theme_color_override("font_color", Color.ROYAL_BLUE) label.add_theme_color_override("font_color", Color.ROYAL_BLUE)
@ -47,9 +55,11 @@ func _set_inout_type(label:Label, value):
TYPE_COLOR: TYPE_COLOR:
label.text = "" label.text = ""
label.add_theme_color_override("font_color", Color.WHITE_SMOKE) label.add_theme_color_override("font_color", Color.WHITE_SMOKE)
_:
label.visible = false
func _set_title(name:String): func _set_title(name:String):
(get_node("Node").get_node("Holder").get_node("Title") as Label).text = name (get_node("Holder").get_node("Title") as Label).text = name
func _create_row(name:String,input,output): func _create_row(name:String,input,output):
rows[name] = {"input": input, "output": output} rows[name] = {"input": input, "output": output}
@ -69,3 +79,8 @@ func _send_input(output_name: String, value):
var input_name = conn.get("input_name", null) var input_name = conn.get("input_name", null)
if target and input_name: if target and input_name:
target._recieve_input(input_name, value) target._recieve_input(input_name, value)
func mouse_enter():
canDrag = true
func mouse_exit():
canDrag = false

View file

@ -1,4 +1,4 @@
extends Area2D extends Button
class_name GL_Node_Point class_name GL_Node_Point
var mainNode : GL_Node var mainNode : GL_Node
@ -22,9 +22,7 @@ func process(delta):
func _on_input_event(viewport, event, shape_idx): func _on_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed: if !event.pressed:
_start_drag()
else:
_finish_drag() _finish_drag()
func _start_drag(): func _start_drag():

View file

@ -8,18 +8,18 @@ func _ready():
_set_State(false) _set_State(false)
_set_rows() _set_rows()
func _process(delta):
pass
func _input(event): func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT: if event is InputEventMouseButton:
if event.pressed: if event.button_index == MOUSE_BUTTON_RIGHT && event.pressed:
_set_State(!searching) _set_State(!searching)
#if event.button_index == MOUSE_BUTTON_LEFT && event.pressed && searching:
#_set_State(false) #fix when not hovered
func _set_State(state:bool): func _set_State(state:bool):
searching = state searching = state
visible = searching visible = searching
lastMousePos = get_viewport().get_mouse_position() lastMousePos = get_viewport().get_mouse_position()
position = lastMousePos
func _set_rows(): func _set_rows():
var container = get_node("Panel").get_node("ScrollContainer").get_node("Container") var container = get_node("Panel").get_node("ScrollContainer").get_node("Container")
@ -32,12 +32,15 @@ func _set_rows():
button.pressed.connect(func(): button.pressed.connect(func():
_create_node(button.text) _create_node(button.text)
) )
button.pressed.connect(func():
_set_State(false)
)
container.call_deferred("add_child",row) container.call_deferred("add_child",row)
func _create_node(name:String): func _create_node(name:String):
var node = load("res://Scenes/Node Types/" + name + ".tscn").instantiate() var node = load("res://Scenes/Node Types/" + name + ".tscn").instantiate()
get_tree().root.add_child(node) get_tree().root.add_child(node)
print("res://Scenes/Node Types/" + name + ".tscn") node = (node as Control).get_child(0) as GL_Node
node = node as GL_Node node.position = lastMousePos
node._create_uuid() node._create_uuid()