Skip to content

Commit 7d375f7

Browse files
author
Liam Sherwin
committed
Virtual Fixture FIxes
1 parent 08dd618 commit 7d375f7

File tree

7 files changed

+66
-22
lines changed

7 files changed

+66
-22
lines changed

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

core/components/fixtures/DMXFixture.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@ func _component_ready() -> void:
3737
## Internal: Sets a parameter to a float value
3838
func _set_parameter(p_parameter: String, p_function: String, p_value: Variant, p_zone: String) -> void:
3939
_raw_layers.get_or_add(p_zone, {})[p_parameter] = {"value": p_value, "function": p_function}
40+
parameter_changed.emit(p_parameter, p_function, p_value, p_zone)
4041

4142

4243
## Internal: Erases the parameter on the given layer
4344
func _erase_parameter(p_parameter: String, p_zone: String) -> void:
4445
_raw_layers.get_or_add(p_zone, {}).erace(p_parameter)
46+
parameter_erased.emit(p_parameter, p_zone)
47+
4548

4649

4750
## Internal: Sets a parameter override to a float value
4851
func _set_override(p_parameter: String, p_function: String, p_value: float, p_zone: String = "root") -> void:
4952
_raw_override_layers.get_or_add(p_zone, {})[p_parameter] = {"value": p_value, "function": p_function}
5053
override_changed.emit(p_parameter, p_function, p_value, p_zone)
51-
52-
print(p_function, ": ", p_value)
5354

5455

5556
## Internal: Erases the parameter override

core/static/Utils.gd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ static func get_htp_color(color_1: Color, color_2: Color) -> Color:
129129
return result_color
130130

131131

132+
## Blends two colors
133+
static func blend_color_additive(color_a: Color, color_b: Color) -> Color:
134+
return Color(
135+
clamp(color_a.r + color_b.r, 0.0, 1.0),
136+
clamp(color_a.g + color_b.g, 0.0, 1.0),
137+
clamp(color_a.b + color_b.b, 0.0, 1.0),
138+
clamp(color_a.a + color_b.a, 0.0, 1.0)
139+
)
140+
141+
132142
## Gets the most common variant in an array
133143
static func get_most_common_value(arr: Array) -> Variant:
134144
var count_dict := {}

panels/AddFixture/AddFixture.tscn

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

33
[ext_resource type="Theme" uid="uid://cyua45ur0ijqo" path="res://assets/Main.theme" id="1_460tm"]
4-
[ext_resource type="Script" path="res://panels/AddFixture/AddFixture.gd" id="2_q8wav"]
4+
[ext_resource type="Script" uid="uid://3asbuxb8omw8" path="res://panels/AddFixture/AddFixture.gd" id="2_q8wav"]
55
[ext_resource type="StyleBox" uid="uid://daxhx5qr5qdeu" path="res://assets/styles/SolidPanel.tres" id="2_v2e7d"]
66
[ext_resource type="StyleBox" uid="uid://csle20exwqtti" path="res://assets/styles/PanelMenuBar.tres" id="3_oo2yy"]
77
[ext_resource type="Texture2D" uid="uid://dpncjre34kf25" path="res://assets/icons/Storage.svg" id="4_7nytk"]
@@ -146,7 +146,7 @@ layout_mode = 2
146146
size_flags_horizontal = 10
147147
text = "Select Universe"
148148
icon = ExtResource("8_85xv7")
149-
filter = Array[String](["Universe"])
149+
filter = "Universe"
150150

151151
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer/HSplitContainer/PanelContainer/FixtureInfomation/FixtureInfomation/PanelContainer2/VBoxContainer2"]
152152
layout_mode = 2

panels/VirtualFixtures/VirtualFixture/VirtualFixture.gd

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var _fixture_signal_connections: Dictionary = {
3636
"override_erased": _on_override_value_erased,
3737
"all_override_removed": _on_override_value_erased,
3838
"parameter_changed": _on_parameter_changed,
39-
"parameter_eraced": _on_parameter_eraced,
39+
"parameter_erased": _on_parameter_eraced,
4040
}
4141

4242

@@ -49,6 +49,7 @@ func set_fixture(control_fixture: Fixture) -> void:
4949
if _fixture.has_overrides():
5050
$Override.show()
5151

52+
render_color()
5253
$UUID.text = control_fixture.uuid
5354

5455

@@ -75,14 +76,38 @@ func render_color():
7576
base_color.b = parameters["ColorAdd_B"].value
7677

7778

78-
if _fixture.has_parameter("root", "Dimmer") and "Dimmer" in parameters:
79-
base_color = base_color * parameters["Dimmer"].value
79+
if _fixture.has_parameter("root", "ColorAdd_W") and "ColorAdd_W" in parameters:
80+
base_color = Utils.blend_color_additive(base_color, Color.WHITE * parameters["ColorAdd_W"].value)
81+
82+
if _fixture.has_parameter("root", "ColorAdd_RY") and "ColorAdd_RY" in parameters:
83+
base_color = Utils.blend_color_additive(base_color, Color.ORANGE * parameters["ColorAdd_RY"].value)
84+
85+
if _fixture.has_parameter("root", "ColorAdd_UV") and "ColorAdd_UV" in parameters:
86+
base_color = Utils.blend_color_additive(base_color, Color.BLUE_VIOLET * parameters["ColorAdd_UV"].value)
87+
88+
89+
if _fixture.has_parameter("root", "ColorSub_C") and "ColorSub_C" in parameters:
90+
base_color.r -= parameters["ColorSub_C"].value
91+
92+
if _fixture.has_parameter("root", "ColorSub_M") and "ColorSub_M" in parameters:
93+
base_color.g -= parameters["ColorSub_M"].value
94+
95+
if _fixture.has_parameter("root", "ColorSub_Y") and "ColorSub_Y" in parameters:
96+
base_color.b -= parameters["ColorSub_Y"].value
97+
98+
99+
if _fixture.has_parameter("root", "Dimmer"):
100+
if "Dimmer" in parameters:
101+
base_color = base_color * parameters["Dimmer"].value
102+
else:
103+
base_color = Color.BLACK
80104

81105
set_color(base_color)
82106

83107

84108
## Sets the base color
85109
func set_color(color: Color) -> void:
110+
color.a = 1
86111
$Color.modulate = color
87112

88113

panels/VirtualFixtures/VirtualFixtures.gd

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ func _ready() -> void:
4141
set_edit_mode_disabled(true)
4242

4343

44+
## Zooms in the canvas
45+
func _zoom_in() -> void:
46+
fixture_container.scale += zoom_step
47+
#_update_scroll_containers()
48+
49+
50+
## Zooms out the canvas
51+
func _zoom_out() -> void:
52+
fixture_container.scale -= zoom_step
53+
#_update_scroll_containers()
54+
55+
4456
## Sets edit mode state
4557
func _edit_mode_toggled(p_edit_mode: bool) -> void:
4658
fixture_container.set_edit_mode(edit_mode)
@@ -71,6 +83,7 @@ func _on_selected_fixtures_changed(fixtures: Array) -> void:
7183
$TitleBar/HBoxContainer/PanelContainer/HBoxContainer/Import.disabled = fixtures == []
7284

7385

86+
## Called when when there is a GUI input on the fixture container
7487
func _on_fixture_container_gui_input(event: InputEvent) -> void:
7588
if event is InputEventMouseMotion and event.button_mask == MOUSE_BUTTON_MASK_MIDDLE:
7689
real_scroll.scroll_horizontal -= event.relative.x
@@ -90,15 +103,6 @@ func _on_grid_align_pressed() -> void:
90103
$GridAlignSize.show()
91104

92105

93-
func _on_zoom_in_pressed() -> void:
94-
fixture_container.scale += zoom_step
95-
_update_scroll_containers()
96-
97-
98-
func _on_zoom_out_pressed() -> void:
99-
fixture_container.scale -= zoom_step
100-
_update_scroll_containers()
101-
102106

103107
## Saves this VirtualFixture layout into a dict
104108
func _save() -> Dictionary:
@@ -117,3 +121,7 @@ func _load(saved_data) -> void:
117121
if fixture_group is FixtureGroup:
118122
fixture_container.set_fixture_group(fixture_group)
119123
)
124+
125+
126+
func _on_table_gui_input(event: InputEvent) -> void:
127+
print(event)

panels/VirtualFixtures/VirtualFixtures.tscn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ script = ExtResource("3_7v2kg")
108108
_virtual_fixtures_root = NodePath("../../../..")
109109

110110
[node name="Grid" type="ColorRect" parent="Table/RealScroll/ScrollSize/FixtureContainer"]
111+
visible = false
111112
material = SubResource("ShaderMaterial_10tdw")
112113
layout_mode = 1
113114
anchors_preset = 15
@@ -149,7 +150,6 @@ icon = ExtResource("6_n07cw")
149150
flat = true
150151

151152
[node name="Zoom Controls" type="PanelContainer" parent="TitleBar/HBoxContainer"]
152-
visible = false
153153
layout_mode = 2
154154
size_flags_vertical = 4
155155

@@ -304,8 +304,8 @@ update_on_text_changed = true
304304
[connection signal="gui_input" from="Table/RealScroll/ScrollSize/FixtureContainer" to="." method="_on_fixture_container_gui_input"]
305305
[connection signal="gui_input" from="Table/RealScroll/ScrollSize/FixtureContainer" to="Table/RealScroll/ScrollSize/FixtureContainer" method="_on_gui_input"]
306306
[connection signal="pressed" from="TitleBar/HBoxContainer/FixtureGroupName" to="Table/RealScroll/ScrollSize/FixtureContainer" method="_on_fixture_group_name_pressed"]
307-
[connection signal="pressed" from="TitleBar/HBoxContainer/Zoom Controls/HBoxContainer/ZoomIn" to="." method="_on_zoom_in_pressed"]
308-
[connection signal="pressed" from="TitleBar/HBoxContainer/Zoom Controls/HBoxContainer/ZoomOut" to="." method="_on_zoom_out_pressed"]
307+
[connection signal="pressed" from="TitleBar/HBoxContainer/Zoom Controls/HBoxContainer/ZoomIn" to="." method="_zoom_in"]
308+
[connection signal="pressed" from="TitleBar/HBoxContainer/Zoom Controls/HBoxContainer/ZoomOut" to="." method="_zoom_out"]
309309
[connection signal="toggled" from="TitleBar/HBoxContainer/GridControls/HBoxContainer/ShowGrid" to="Table/RealScroll/ScrollSize/FixtureContainer" method="_on_show_grid_toggled"]
310310
[connection signal="value_changed" from="TitleBar/HBoxContainer/GridControls/HBoxContainer/GridSize" to="Table/RealScroll/ScrollSize/FixtureContainer" method="_on_grid_size_value_changed"]
311311
[connection signal="pressed" from="TitleBar/HBoxContainer/PanelContainer/HBoxContainer/AddFixtures" to="Table/RealScroll/ScrollSize/FixtureContainer" method="_on_add_fixtures_pressed"]

0 commit comments

Comments
 (0)