Skip to content

Commit a5989a6

Browse files
author
Liam Sherwin
committed
Version 1 update
1 parent 87fef1c commit a5989a6

File tree

5 files changed

+130
-125
lines changed

5 files changed

+130
-125
lines changed

Main.gd

Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,99 @@
1-
extends Control
1+
extends GraphEdit
22

33
var initial_position = Vector2(40,40)
44
var node_index = 0
5-
@onready var nodeList = $Control/NodeList
5+
@onready var node_list = get_parent().get_parent().get_node("Node List/NodeList")
66
var built_in_nodes = {
77
'DMX Value':"DMX_value",
88
'Art-Net Output':"ART_NET_output",
9+
'Merge':"Merge",
10+
'Value':"Value",
11+
'DMX Table': "DMX_table"
912
}
13+
1014
var connected_nodes = {}
15+
16+
var outbound_queue = {}
1117
# Called when the node enters the scene tree for the first time.
1218

1319
func _ready():
14-
pass # Replace with function body.
20+
for node in built_in_nodes:
21+
node_list.add_item(node)
1522

1623
# Called every frame. 'delta' is the elapsed time since the previous frame.
17-
#func _process(delta):
18-
# pass
19-
20-
24+
func _process(_delta):
25+
if Input.is_action_just_pressed("process_loop"):
26+
print(connected_nodes)
27+
if not outbound_queue.is_empty():
28+
for i in outbound_queue:
29+
if connected_nodes.has(i):
30+
for slot in connected_nodes[i]:
31+
get_node(NodePath(slot[1])).receive(outbound_queue[i][slot[0]], slot[2])
32+
outbound_queue = {}
33+
for N in self.get_children():
34+
N.node_process()
35+
2136
func send(node, data, slot):
22-
print(data)
23-
get_node(NodePath(connected_nodes[node][slot])).receive(data, slot)
37+
if node.name in outbound_queue:
38+
outbound_queue[node.name][slot] = data
39+
else:
40+
outbound_queue[node.name] = {slot:data}
41+
42+
# for node_to_send in connected_nodes:
43+
# get_node(NodePath(list[i]["to"])).receive(data, list[i]["to_port"])
44+
45+
# print(self.get_parent().get_node("Node Editor").get_connection_list())
46+
# if connected_nodes.has(node):
47+
# get_node(NodePath(connected_nodes[node][slot])).receive(data, slot)
2448

2549
func _on_GraphEdit_connection_request(from, from_slot, to, to_slot):
26-
self.get_parent().get_node("Node Editor").connect_node(from, from_slot, to, to_slot)
27-
print(from)
28-
connected_nodes[get_node(str(from))] = {from_slot:to}
50+
self.connect_node(from, from_slot, to, to_slot)
51+
if from in connected_nodes:
52+
connected_nodes[from].append([from_slot, to, to_slot])
53+
else:
54+
connected_nodes[from] = [[from_slot, to, to_slot]]
55+
print(connected_nodes)
2956

3057
func _on_GraphEdit_disconnection_request(from, from_slot, to, to_slot):
31-
self.get_parent().get_node("Node Editor").disconnect_node(from, from_slot, to, to_slot)
32-
print(from)
33-
connected_nodes[get_node(str(from))].erase(from_slot)
34-
35-
func _on_RunProgram_pressed():
36-
var G = self
37-
var connection_list = G.get_connection_list()
38-
print(G.get_connection_list())
39-
var result = 0
40-
for i in range(0, connection_list.size()):
41-
var value = G.get_node(NodePath(connection_list[i].from)).get_node('SpinBox').value
42-
var value_2 = G.get_node(NodePath(connection_list[i].to)).get_node('SpinBox').value
43-
result += value
44-
if i+1 == connection_list.size():
45-
result += value_2
46-
print(result)
58+
self.disconnect_node(from, from_slot, to, to_slot)
59+
connected_nodes[from].erase([from_slot, to, to_slot])
60+
if len(connected_nodes[from]) == 0:
61+
connected_nodes.erase(from)
62+
print(connected_nodes)
63+
64+
func delete(node):
65+
connected_nodes.erase(node.name)
66+
print(connected_nodes)
67+
for i in connected_nodes:
68+
print(i)
69+
for x in connected_nodes[i]:
70+
print(x)
71+
if node.name in x:
72+
print("found node to delete")
73+
print(x)
74+
connected_nodes[i].erase(x)
75+
if len(connected_nodes[i]) == 0:
76+
connected_nodes.erase(i)
77+
78+
#func _on_RunProgram_pressed():
79+
# var G = self
80+
# var connection_list = G.get_connection_list()
81+
# print(G.get_connection_list())
82+
# var result = 0
83+
# for i in range(0, connection_list.size()):
84+
# var value = G.get_node(NodePath(connection_list[i].from)).get_node('SpinBox').value
85+
# var value_2 = G.get_node(NodePath(connection_list[i].to)).get_node('SpinBox').value
86+
# result += value
87+
# if i+1 == connection_list.size():
88+
# result += value_2
89+
# print(result)
4790

4891

4992
func _on_item_list_item_clicked(index, _at_position, _mouse_button_index):
50-
print("res://Nodes/" + built_in_nodes[nodeList.get_item_text(index)] + ".tscn")
51-
var node_to_add = load("res://Nodes/" + built_in_nodes[nodeList.get_item_text(index)] + ".tscn").instantiate()
52-
node_to_add.position_offset += initial_position + (node_index * Vector2(20,20))
53-
set_editable_instance(node_to_add, true)
93+
print("res://Nodes/" + built_in_nodes[node_list.get_item_text(index)] + ".tscn")
94+
var node_to_add = load("res://Nodes/" + built_in_nodes[node_list.get_item_text(index)] + ".tscn").instantiate()
95+
node_to_add.position_offset = (get_viewport().get_mouse_position() + self.scroll_offset) / self.zoom
96+
# set_editable_instance(node_to_add, true)
5497
node_to_add.name = node_to_add.name + str(node_index)
5598
self.add_child(node_to_add)
5699
node_index += 1

Main.tscn

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[gd_scene load_steps=3 format=3 uid="uid://p3sohjs1pt37"]
1+
[gd_scene load_steps=4 format=3 uid="uid://p3sohjs1pt37"]
22

33
[ext_resource type="Script" path="res://Main.gd" id="1"]
44
[ext_resource type="Script" path="res://Scripts/NodeList.gd" id="2_8afhv"]
5+
[ext_resource type="Script" path="res://Scripts/fps.gd" id="3_l3bnx"]
56

67
[node name="Main" type="Control"]
78
layout_mode = 3
@@ -11,22 +12,6 @@ anchor_bottom = 1.0
1112
grow_horizontal = 2
1213
grow_vertical = 2
1314

14-
[node name="HBoxContainer" type="HBoxContainer" parent="."]
15-
visible = false
16-
layout_mode = 0
17-
offset_left = 12.2587
18-
offset_top = 9.01583
19-
offset_right = 202.259
20-
offset_bottom = 33.0158
21-
22-
[node name="Button" type="Button" parent="HBoxContainer"]
23-
layout_mode = 2
24-
text = "Add node +"
25-
26-
[node name="RunProgram" type="Button" parent="HBoxContainer"]
27-
layout_mode = 2
28-
text = "Do the magic!"
29-
3015
[node name="TabContainer" type="TabContainer" parent="."]
3116
layout_mode = 1
3217
anchors_preset = 15
@@ -41,46 +26,35 @@ right_disconnects = true
4126
scroll_offset = Vector2(0, -31)
4227
script = ExtResource("1")
4328

44-
[node name="Control" type="Control" parent="TabContainer/Node Editor"]
29+
[node name="Node List" type="Control" parent="."]
4530
visible = false
4631
layout_mode = 2
4732
anchors_preset = 0
48-
anchor_left = 0.0243056
49-
anchor_top = 0.146605
50-
anchor_right = 0.18316
51-
anchor_bottom = 0.595679
52-
offset_top = -26.4552
53-
offset_bottom = -26.4553
33+
anchor_left = 0.0229167
34+
anchor_top = 0.15463
35+
anchor_right = 0.0229167
36+
anchor_bottom = 0.15463
37+
offset_right = 186.0
38+
offset_bottom = 268.0
5439
script = ExtResource("2_8afhv")
5540
metadata/_edit_use_anchors_ = true
5641

57-
[node name="LineEdit" type="LineEdit" parent="TabContainer/Node Editor/Control"]
58-
layout_mode = 1
59-
anchors_preset = 10
60-
anchor_right = 1.0
61-
offset_bottom = 31.0
62-
grow_horizontal = 2
63-
placeholder_text = "Search"
64-
65-
[node name="NodeList" type="ItemList" parent="TabContainer/Node Editor/Control"]
42+
[node name="NodeList" type="ItemList" parent="Node List"]
6643
layout_mode = 1
67-
anchors_preset = 15
68-
anchor_right = 1.0
69-
anchor_bottom = 1.0
70-
offset_top = 34.0
71-
grow_horizontal = 2
72-
grow_vertical = 2
73-
item_count = 2
74-
item_0/text = "DMX Value"
75-
item_1/text = "Art-Net Output"
44+
offset_right = 186.0
45+
offset_bottom = 8.0
46+
auto_height = true
7647

77-
[node name="Control2" type="Control" parent="TabContainer"]
48+
[node name="Label" type="Label" parent="."]
7849
visible = false
79-
layout_mode = 2
50+
layout_mode = 0
51+
offset_left = 1834.0
52+
offset_top = 3.0
53+
offset_right = 1914.0
54+
offset_bottom = 26.0
55+
script = ExtResource("3_l3bnx")
8056

81-
[connection signal="pressed" from="HBoxContainer/Button" to="." method="_on_Button_pressed"]
82-
[connection signal="pressed" from="HBoxContainer/RunProgram" to="." method="_on_RunProgram_pressed"]
8357
[connection signal="connection_request" from="TabContainer/Node Editor" to="TabContainer/Node Editor" method="_on_GraphEdit_connection_request"]
8458
[connection signal="disconnection_request" from="TabContainer/Node Editor" to="TabContainer/Node Editor" method="_on_GraphEdit_disconnection_request"]
85-
[connection signal="item_clicked" from="TabContainer/Node Editor/Control/NodeList" to="TabContainer/Node Editor" method="_on_item_list_item_clicked"]
86-
[connection signal="item_clicked" from="TabContainer/Node Editor/Control/NodeList" to="TabContainer/Node Editor/Control" method="_on_node_list_item_clicked"]
59+
[connection signal="item_clicked" from="Node List/NodeList" to="TabContainer/Node Editor" method="_on_item_list_item_clicked"]
60+
[connection signal="item_clicked" from="Node List/NodeList" to="Node List" method="_on_node_list_item_clicked"]

Readme.md

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1 @@
1-
<br/>
2-
<p align="center">
3-
<a href="https://github.com/SpectrumPro/Spectrum-Website/">
4-
<img src="" alt="Logo" width="80" height="80">
5-
</a>
6-
7-
<h3 align="center">Spectrum</h3>
8-
<br>
9-
10-
</p>
11-
12-
![Contributors](https://img.shields.io/github/contributors/SpectrumPro/Spectrum?color=dark-green) ![Issues](https://img.shields.io/github/issues/Spectrum?color=dark-green) ![License](https://img.shields.io/github/license/Spectrum?color=dark-green)
13-
14-
## About The Project
15-
16-
This site is node based dmx control system
17-
18-
## Built With
19-
20-
* [Godot](https://godotengine.org/)
21-
* [Github](https://github.com/)
22-
23-
## Roadmap
24-
25-
There are numerous more features I intend to implement, with many more in the works.
26-
27-
## Contributing
28-
29-
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
30-
31-
* If you have suggestions for adding or removing projects, feel free to [open an issue](https://github.com/issues/new/SpectrumPro/Spectrum) to discuss it, or directly create a pull request after you edit the *README.md* file with necessary changes.
32-
* Please make sure you check your spelling and grammar.
33-
* Create individual PR for each suggestion.
34-
35-
## License
36-
37-
Distributed under the MPL License. See [LICENSE](https://github.com/SpectrumPro/Spectrum/blob/master/LICENSE) for more information.
38-
39-
## Authors
40-
41-
Main App
42-
* [Liam](https://liamsherwin.tech/)
43-
44-
Readme
45-
* [HuskyNZ](https://www.husky.nz)
1+
# Read me comming soon

Scripts/fps.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extends Label
2+
3+
4+
# Called when the node enters the scene tree for the first time.
5+
func _ready():
6+
pass # Replace with function body.
7+
8+
9+
# Called every frame. 'delta' is the elapsed time since the previous frame.
10+
func _process(_delta):
11+
self.text = str(Engine.get_frames_per_second())

project.godot

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ config_version=5
1313
config/name="Spectrum"
1414
run/main_scene="res://Main.tscn"
1515
config/features=PackedStringArray("4.1")
16+
boot_splash/bg_color=Color(0.133333, 0.133333, 0.133333, 1)
17+
boot_splash/image="res://Assets/icon-small.png"
18+
boot_splash/fullsize=false
1619
config/icon="res://icon.png"
20+
boot_splash/minimum_display_time=500
21+
22+
[audio]
23+
24+
driver/enable_input=true
25+
26+
[display]
27+
28+
window/size/viewport_width=1920
29+
window/size/viewport_height=1080
30+
window/vsync/vsync_mode=0
31+
window/ios/hide_home_indicator=false
32+
window/ios/hide_status_bar=false
1733

1834
[input]
1935

@@ -22,6 +38,11 @@ right_click={
2238
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(215, 15),"global_position":Vector2(219, 58),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
2339
]
2440
}
41+
process_loop={
42+
"deadzone": 0.5,
43+
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null)
44+
]
45+
}
2546

2647
[rendering]
2748

0 commit comments

Comments
 (0)