Skip to content

Commit 6287576

Browse files
author
Liam Sherwin
committed
Auto generated settings
1 parent db6b1c0 commit 6287576

20 files changed

+604
-58
lines changed

assets/ClassSettingsBG.tres

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[gd_resource type="StyleBoxFlat" format=3 uid="uid://bxwylw4uk8cyk"]
2+
3+
[resource]
4+
content_margin_left = 10.0
5+
content_margin_top = 10.0
6+
content_margin_right = 10.0
7+
content_margin_bottom = 10.0
8+
bg_color = Color(0.136826, 0.136826, 0.136826, 1)
9+
border_width_left = 1
10+
border_width_top = 1
11+
border_width_right = 1
12+
border_width_bottom = 1
13+
border_color = Color(0.309804, 0.309804, 0.309804, 0.254902)
14+
corner_radius_top_left = 5
15+
corner_radius_top_right = 5
16+
corner_radius_bottom_right = 5
17+
corner_radius_bottom_left = 5

assets/Main.theme

29 Bytes
Binary file not shown.

assets/icons/UnfoldLess.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/UnfoldLess.svg.import

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dj7k0od8o16ok"
6+
path="res://.godot/imported/UnfoldLess.svg-4ab1d5f33b61759a0c6b1e265ce5f770.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://assets/icons/UnfoldLess.svg"
14+
dest_files=["res://.godot/imported/UnfoldLess.svg-4ab1d5f33b61759a0c6b1e265ce5f770.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
35+
svg/scale=1.0
36+
editor/scale_with_editor_scale=false
37+
editor/convert_colors_with_editor_theme=false

assets/icons/UnfoldMore.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/UnfoldMore.svg.import

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cauhar0guyod0"
6+
path="res://.godot/imported/UnfoldMore.svg-7b0712bccb20df8575b24651f5385f1e.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://assets/icons/UnfoldMore.svg"
14+
dest_files=["res://.godot/imported/UnfoldMore.svg-7b0712bccb20df8575b24651f5385f1e.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
35+
svg/scale=1.0
36+
editor/scale_with_editor_scale=false
37+
editor/convert_colors_with_editor_theme=false

assets/icons/remove.svg.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://b2irkd31agi0x"
6-
path="res://.godot/imported/Remove.svg-d6b561eec13de9ed9a6b262ecffa42bf.ctex"
6+
path="res://.godot/imported/remove.svg-4d209cc049dad917abe1dad4ca8edd56.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://assets/icons/Remove.svg"
14-
dest_files=["res://.godot/imported/Remove.svg-d6b561eec13de9ed9a6b262ecffa42bf.ctex"]
13+
source_file="res://assets/icons/remove.svg"
14+
dest_files=["res://.godot/imported/remove.svg-4d209cc049dad917abe1dad4ca8edd56.ctex"]
1515

1616
[params]
1717

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[gd_scene load_steps=5 format=3 uid="uid://cx2fhdc52ft54"]
2+
3+
[ext_resource type="StyleBox" uid="uid://daxhx5qr5qdeu" path="res://assets/SolidPanel.tres" id="1_l6ycl"]
4+
[ext_resource type="Script" path="res://components/ComponentSettings/ClassCustomModules/DmxOutputStatusDisplay.gd" id="1_oxcgw"]
5+
[ext_resource type="FontFile" uid="uid://crlak6jhg5jy2" path="res://assets/font/RubikMonoOne-Regular.ttf" id="2_iltl1"]
6+
7+
[sub_resource type="LabelSettings" id="LabelSettings_wu1ck"]
8+
font = ExtResource("2_iltl1")
9+
font_size = 24
10+
11+
[node name="DmxOutputStatusDisplay" type="PanelContainer" node_paths=PackedStringArray("_status_label")]
12+
anchors_preset = 15
13+
anchor_right = 1.0
14+
anchor_bottom = 1.0
15+
grow_horizontal = 2
16+
grow_vertical = 2
17+
size_flags_horizontal = 3
18+
size_flags_vertical = 3
19+
theme_override_styles/panel = ExtResource("1_l6ycl")
20+
script = ExtResource("1_oxcgw")
21+
_status_label = NodePath("ConnectionState")
22+
23+
[node name="ConnectionState" type="Label" parent="."]
24+
layout_mode = 2
25+
size_flags_horizontal = 4
26+
text = "DISCONNEDTED"
27+
label_settings = SubResource("LabelSettings_wu1ck")
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) 2024 Liam Sherwin, All rights reserved.
2+
# This file is part of the Spectrum Lighting Engine, licensed under the GPL v3.
3+
4+
class_name DMXOutputStatusDisplay extends PanelContainer
5+
## Custom status display for DMXOutput
6+
7+
8+
## The ConnectionState label
9+
@export var _status_label: Label = null
10+
11+
12+
## Connected color
13+
var _connected_color: Color = Color(0.32, 1, 0.32)
14+
15+
## Disconnected color
16+
var _disconnected_color: Color = Color(1, 0.32, 0.32)
17+
18+
## The current DMXOutput
19+
var _output: DMXOutput = null
20+
21+
## Signal connections for the DMXOutput
22+
var _signal_connections: Dictionary = {"connection_state_changed": _on_connection_state_changed}
23+
24+
25+
func _ready() -> void:
26+
add_theme_stylebox_override("panel", get_theme_stylebox("panel").duplicate())
27+
28+
29+
## Sets the output
30+
func set_output(output: DMXOutput) -> void:
31+
Utils.disconnect_signals(_signal_connections, _output)
32+
_output = output
33+
Utils.connect_signals(_signal_connections, _output)
34+
35+
_on_connection_state_changed(_output.get_connection_state(), _output.get_previous_note())
36+
37+
38+
## Called when the connection state changes on the DMXOutput
39+
func _on_connection_state_changed(state: bool, note: String) -> void:
40+
_status_label.tooltip_text = note
41+
42+
if state:
43+
#get_theme_stylebox("panel").bg_color = _connected_color
44+
_status_label.text = "CONNECTED"
45+
_status_label.label_settings.font_color = _connected_color
46+
47+
else:
48+
#get_theme_stylebox("panel").bg_color = _disconnected_color
49+
_status_label.text = "DISCONNECTED"
50+
_status_label.label_settings.font_color = _disconnected_color
51+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copyright (c) 2024 Liam Sherwin, All rights reserved.
2+
# This file is part of the Spectrum Lighting Engine, licensed under the GPL v3.
3+
4+
class_name ClassSettingsModule extends PanelContainer
5+
## Class settings module
6+
7+
8+
## Title label
9+
@export var _title: Label
10+
11+
## ExpandHide button
12+
@export var _expand_hide_button: Button
13+
14+
## SettingsContainer VBox
15+
@export var _settings_container: VBoxContainer
16+
17+
## CustomContainer VBox
18+
@export var _custom_container: VBoxContainer
19+
20+
21+
## Contains all the lines of settings
22+
var _lines: Dictionary = {}
23+
24+
25+
## Sets the title
26+
func set_title(title: String) -> void:
27+
_title.text = title
28+
29+
30+
## Shows a custom panel
31+
func show_custom(panel: Control) -> void:
32+
_custom_container.add_child(panel)
33+
34+
35+
## Shows a setting
36+
func show_setting(setter: Callable, getter: Callable, p_signal: Signal, type: String, line_number: int, p_name: String) -> void:
37+
if not _lines.has(line_number):
38+
var new_line: HBoxContainer = HBoxContainer.new()
39+
_lines[line_number] = new_line
40+
41+
_settings_container.add_child(new_line)
42+
_settings_container.move_child(new_line, line_number + 1)
43+
44+
var line: HBoxContainer = _lines[line_number]
45+
var control: Control = null
46+
47+
match type:
48+
Utils.TYPE_STRING, Utils.TYPE_IP:
49+
var line_edit: LineEdit = LineEdit.new()
50+
line_edit.text = getter.call()
51+
52+
line_edit.text_submitted.connect(setter)
53+
p_signal.connect(line_edit.set_text)
54+
control = line_edit
55+
56+
Utils.TYPE_BOOL:
57+
var check_button: CheckButton = CheckButton.new()
58+
check_button.set_pressed_no_signal(getter.call())
59+
check_button.text = "TRUE" if check_button.button_pressed else "FALSE"
60+
61+
check_button.toggled.connect(setter)
62+
p_signal.connect(func (state: bool):
63+
check_button.set_pressed_no_signal(state)
64+
check_button.text = "TRUE" if state else "FALSE"
65+
)
66+
control = check_button
67+
68+
Utils.TYPE_INT:
69+
var spin_box: SpinBox = SpinBox.new()
70+
spin_box.set_value_no_signal(getter.call())
71+
spin_box.max_value = 1 << 32
72+
spin_box.min_value = -(1 << 32)
73+
74+
spin_box.value_changed.connect(setter)
75+
p_signal.connect(spin_box.set_value_no_signal)
76+
control = spin_box
77+
78+
Utils.TYPE_NULL:
79+
if getter.is_null():
80+
var button: Button = Button.new()
81+
button.text = p_name
82+
83+
button.pressed.connect(setter)
84+
control = button
85+
86+
87+
if true:
88+
if not getter.is_null():
89+
var hbox: HBoxContainer = HBoxContainer.new()
90+
var label: Label = Label.new()
91+
92+
label.text = p_name
93+
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
94+
control.size_flags_horizontal = Control.SIZE_EXPAND_FILL
95+
hbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
96+
97+
hbox.add_child(label)
98+
hbox.add_child(control)
99+
line.add_child(hbox)
100+
101+
else:
102+
control.size_flags_horizontal = Control.SIZE_EXPAND_FILL
103+
line.add_child(control)
104+
105+
106+
## Called when the ExpandHide button is toggled
107+
func _on_expand_hide_toggled(toggled_on: bool) -> void:
108+
_settings_container.visible = not toggled_on
109+
_expand_hide_button.icon = preload("res://assets/icons/UnfoldLess.svg") if toggled_on else preload("res://assets/icons/UnfoldMore.svg")
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[gd_scene load_steps=6 format=3 uid="uid://cr7gbtpobxvsr"]
2+
3+
[ext_resource type="StyleBox" uid="uid://bxwylw4uk8cyk" path="res://assets/ClassSettingsBG.tres" id="1_hragf"]
4+
[ext_resource type="Theme" uid="uid://cyua45ur0ijqo" path="res://assets/Main.theme" id="1_pf2nj"]
5+
[ext_resource type="Texture2D" uid="uid://dj7k0od8o16ok" path="res://assets/icons/UnfoldLess.svg" id="2_873xa"]
6+
[ext_resource type="Script" path="res://components/ComponentSettings/ClassSettingsModule/ClassSettingsModule.gd" id="3_2hkcc"]
7+
8+
[sub_resource type="LabelSettings" id="LabelSettings_hbu47"]
9+
font_size = 18
10+
11+
[node name="ClassSettingsModule" type="PanelContainer" node_paths=PackedStringArray("_title", "_expand_hide_button", "_settings_container", "_custom_container")]
12+
custom_minimum_size = Vector2(450, 0)
13+
theme = ExtResource("1_pf2nj")
14+
theme_override_styles/panel = ExtResource("1_hragf")
15+
script = ExtResource("3_2hkcc")
16+
_title = NodePath("VBoxContainer/HBoxContainer/Title")
17+
_expand_hide_button = NodePath("VBoxContainer/HBoxContainer/ExpandHide")
18+
_settings_container = NodePath("VBoxContainer/SettingContainer")
19+
_custom_container = NodePath("VBoxContainer/SettingContainer/CustomContainer")
20+
21+
[node name="VBoxContainer" type="VBoxContainer" parent="."]
22+
layout_mode = 2
23+
24+
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
25+
layout_mode = 2
26+
27+
[node name="Title" type="Label" parent="VBoxContainer/HBoxContainer"]
28+
layout_mode = 2
29+
text = "ArtNetOutput:"
30+
label_settings = SubResource("LabelSettings_hbu47")
31+
32+
[node name="ExpandHide" type="Button" parent="VBoxContainer/HBoxContainer"]
33+
layout_mode = 2
34+
size_flags_horizontal = 10
35+
tooltip_text = "Expand / Hide"
36+
toggle_mode = true
37+
icon = ExtResource("2_873xa")
38+
flat = true
39+
40+
[node name="SettingContainer" type="VBoxContainer" parent="VBoxContainer"]
41+
layout_mode = 2
42+
43+
[node name="CustomContainer" type="VBoxContainer" parent="VBoxContainer/SettingContainer"]
44+
layout_mode = 2
45+
46+
[connection signal="toggled" from="VBoxContainer/HBoxContainer/ExpandHide" to="." method="_on_expand_hide_toggled"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) 2024 Liam Sherwin, All rights reserved.
2+
# This file is part of the Spectrum Lighting Controller, licensed under the GPL v3.
3+
4+
class_name ComponentSettings extends PanelContainer
5+
## ComponentSettings
6+
7+
8+
## SettingsModuleContainer VBox
9+
@export var _settings_module_container: VBoxContainer
10+
11+
12+
## Sets the component
13+
func set_component(component: EngineComponent) -> void:
14+
for old_module: ClassSettingsModule in _settings_module_container.get_children():
15+
old_module.queue_free()
16+
_settings_module_container.remove_child(old_module)
17+
18+
if not is_instance_valid(component):
19+
return
20+
21+
for classname: String in component.class_tree:
22+
var new_module: ClassSettingsModule = load("res://components/ComponentSettings/ClassSettingsModule/ClassSettingsModule.tscn").instantiate()
23+
new_module.set_title(classname)
24+
25+
for setting: Dictionary in component.get_settings(classname).values():
26+
if setting.data_type == Utils.TYPE_CUSTOM:
27+
var panel: Control = setting.custom_panel.instantiate()
28+
29+
if panel.has_method(setting.entry_point):
30+
panel.get(setting.entry_point).call(component)
31+
32+
new_module.show_custom(panel)
33+
else:
34+
new_module.show_setting(setting.setter, setting.getter, setting.signal, setting.data_type, setting.visual_line, setting.visual_name)
35+
36+
_settings_module_container.add_child(new_module)

0 commit comments

Comments
 (0)