Skip to content

Commit 21af038

Browse files
author
Liam Sherwin
committed
Added per fixture, and global LTP layer options
1 parent 62b1d82 commit 21af038

File tree

5 files changed

+97
-9
lines changed

5 files changed

+97
-9
lines changed

core/components/fixtures/DMXFixture.gd

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ var _parameters: Dictionary = {}
2929
## { "zone": { "parameter": { value: float, function: String } } }
3030
var _active_values: Dictionary[String, Dictionary]
3131

32+
## Stores all active LTP parameters
33+
## { "zone": { "parameter": [ layer_id ] } }
34+
var _active_ltp_parameters: Dictionary[String, Dictionary]
35+
3236
## All the input value layers. Mapped to the DMX value used to calculate HTP
3337
## { "zone": { "parameter": { "layer_id": mapped_value } } }
3438
var _mapped_layers: Dictionary[String, Dictionary] = {}
@@ -134,9 +138,23 @@ func set_parameter(p_parameter: String, p_function: String, p_value: float, p_la
134138
var mapped_layer: Dictionary = _mapped_layers.get_or_add(p_zone, {}).get_or_add(p_parameter, {})
135139
mapped_layer[p_layer_id] = mapped_value
136140

137-
var max: int = mapped_layer.values().max()
138-
139-
if max != _current.get(p_zone, {}).get(p_parameter, null):
141+
var new_value: int = mapped_layer.values().max()
142+
143+
# if has_ltp_layer(p_layer_id):
144+
# if uuid == "7dcf43e3-34f4-4564-aee2-68eb788abf38": print("Using LTP, Current")
145+
# new_value = mapped_value
146+
# if not _active_ltp_parameters.get_or_add(p_zone, {}).get_or_add(p_parameter, {}).has(p_layer_id):
147+
# _active_ltp_parameters[p_zone][p_parameter][p_layer_id] = null
148+
149+
# elif _active_ltp_parameters.get(p_zone, {}).get(p_parameter, []) and _current.get(p_zone, {}).has(p_parameter):
150+
# if uuid == "7dcf43e3-34f4-4564-aee2-68eb788abf38": print("Using LTP, Pre existing")
151+
# new_value = _current[p_zone][p_parameter]
152+
153+
# else:
154+
# if uuid == "7dcf43e3-34f4-4564-aee2-68eb788abf38": print("Using HTP")
155+
# new_value = mapped_layer.values().max()
156+
157+
if new_value != _current.get(p_zone, {}).get(p_parameter, null):
140158
_current.get_or_add(p_zone, {})[p_parameter] = mapped_value
141159
_active_values.get_or_add(p_zone, {})[p_parameter] = {
142160
"value": p_value,

core/components/fixtures/Fixture.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static var RootZone: String = "root"
2626

2727

2828
## Enables layer based LTP on layers
29-
var _ltp_layers: Array[String]
29+
var _ltp_layers: Dictionary[String, Variant]
3030

3131

3232
## Called when this EngineComponent is ready
@@ -148,16 +148,16 @@ func function_can_fade(p_zone: String, p_parameter: String, p_function: String)
148148

149149
## Enabled LTP on a layer
150150
func add_ltp_layer(p_layer_id: String) -> bool:
151-
if p_layer_id in _ltp_layers:
151+
if _ltp_layers.has(p_layer_id):
152152
return false
153153

154-
_ltp_layers.append(p_layer_id)
154+
_ltp_layers[p_layer_id] = null
155155
return true
156156

157157

158158
## Enabled LTP on a layer
159159
func remove_ltp_layer(p_layer_id: String) -> bool:
160-
if p_layer_id not in _ltp_layers:
160+
if not _ltp_layers.has(p_layer_id):
161161
return false
162162

163163
_ltp_layers.erase(p_layer_id)
@@ -166,4 +166,4 @@ func remove_ltp_layer(p_layer_id: String) -> bool:
166166

167167
## Enabled LTP on a layer
168168
func has_ltp_layer(p_layer_id: String) -> bool:
169-
return p_layer_id in _ltp_layers
169+
return _ltp_layers.has(p_layer_id) or FixtureLibrary.has_global_ltp_layer(p_layer_id)

core/components/functions/Function.gd

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ signal on_active_state_changed(state: ActiveState)
1414
## Emitted when the transport state changes
1515
signal on_transport_state_changed(state: TransportState)
1616

17+
## Emitted when the PriorityMode state changes
18+
signal on_priority_mode_state_changed(state: PriorityMode)
19+
1720
## Emitted when auto start is changed
1821
signal on_auto_start_changed(auto_start: bool)
1922

@@ -27,13 +30,21 @@ enum ActiveState {
2730
ENABLED,
2831
}
2932

30-
## Transport Stae
33+
## Transport State
3134
enum TransportState {
3235
PAUSED,
3336
FORWARDS,
3437
BACKWARDS
3538
}
3639

40+
41+
## Priority Mode
42+
enum PriorityMode {
43+
HTP,
44+
LTP
45+
}
46+
47+
3748
## Intensity of this function
3849
var _intensity: float = 0
3950

@@ -46,6 +57,9 @@ var _transport_state: TransportState = TransportState.PAUSED
4657
## The previous transport state before setting it to Paused
4758
var _previous_transport_state: TransportState = TransportState.PAUSED
4859

60+
## The current PriorityMode
61+
var _priority_mode: PriorityMode = PriorityMode.HTP
62+
4963
## Should this Function set ActiveState to ENABLED when intensity is not 0
5064
var _auto_start: bool = true
5165

@@ -197,6 +211,31 @@ func get_intensity() -> float:
197211
return _intensity
198212

199213

214+
## Sets the _priority_mode state
215+
func set_priority_mode_state(p_priority_mode: PriorityMode) -> void:
216+
if p_priority_mode == _priority_mode:
217+
return
218+
219+
_priority_mode = p_priority_mode
220+
on_priority_mode_state_changed.emit(_priority_mode)
221+
_handle_priority_mode_change(_priority_mode)
222+
223+
224+
## Override this function to handle _priority_mode changes
225+
func _handle_priority_mode_change(p_priority_mode: PriorityMode) -> void:
226+
match p_priority_mode:
227+
PriorityMode.HTP:
228+
FixtureLibrary.remove_global_ltp_layer(uuid)
229+
230+
PriorityMode.LTP:
231+
FixtureLibrary.add_global_ltp_layer(uuid)
232+
233+
234+
## Gets the current PriorityMode
235+
func get_priority_mode_state() -> PriorityMode:
236+
return _priority_mode
237+
238+
200239
## Sets the auto start state
201240
func set_auto_start(p_auto_start: bool) -> void:
202241
if _auto_start == p_auto_start:
@@ -233,6 +272,7 @@ func get_data_container() -> DataContainer:
233272
## Returns serialized version of this component, change the mode to define if this object should be serialized for saving to disk, or for networking to clients
234273
func serialize(p_mode: int = CoreEngine.SERIALIZE_MODE_NETWORK) -> Dictionary:
235274
return super.serialize(p_mode).merged({
275+
"priority_mode": _priority_mode,
236276
"auto_start": _auto_start,
237277
"auto_stop": _auto_stop
238278
}.merged({
@@ -244,6 +284,8 @@ func serialize(p_mode: int = CoreEngine.SERIALIZE_MODE_NETWORK) -> Dictionary:
244284

245285
## Loades this object from a serialized version
246286
func load(p_serialized_data: Dictionary) -> void:
287+
set_priority_mode_state(type_convert(p_serialized_data.get("priority_mode", _priority_mode), TYPE_INT))
288+
247289
_auto_start = type_convert(p_serialized_data.get("auto_start", _auto_start), TYPE_BOOL)
248290
_auto_stop = type_convert(p_serialized_data.get("auto_stop", _auto_stop), TYPE_BOOL)
249291

core/global/Debug.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func dump_fixture_data(fixture: Fixture) -> String:
4444
var path: String = debug_file_location + "fixture_" + fixture.uuid + "/"
4545

4646
if fixture is DMXFixture:
47+
Utils.save_json_to_file(path, "_active_ltp_parameters", fixture._active_ltp_parameters)
48+
Utils.save_json_to_file(path, "_active_values", fixture._active_values)
4749
Utils.save_json_to_file(path, "_parameters", fixture._parameters)
4850
Utils.save_json_to_file(path, "_mapped_layers", fixture._mapped_layers)
4951
Utils.save_json_to_file(path, "_raw_layers", fixture._raw_layers)

core/global/FixtureLibrary.gd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ var _manifest_importers: Dictionary = {
3636
"gdtf": GDTFImport.new()
3737
}
3838

39+
## Global LTP layers for fixtures
40+
var _global_ltp_layers: Dictionary[String, Variant]
41+
3942

4043
## Load the fixture manifests from the folders, buit in manifests will override user manifests
4144
func _ready() -> void:
@@ -119,6 +122,29 @@ func is_loaded() -> bool:
119122
return _is_loaded
120123

121124

125+
## Enabled LTP on a layer
126+
func add_global_ltp_layer(p_layer_id: String) -> bool:
127+
if has_global_ltp_layer(p_layer_id):
128+
return false
129+
130+
_global_ltp_layers[p_layer_id] = null
131+
return true
132+
133+
134+
## Enabled LTP on a layer
135+
func remove_global_ltp_layer(p_layer_id: String) -> bool:
136+
if not has_global_ltp_layer(p_layer_id):
137+
return false
138+
139+
_global_ltp_layers.erase(p_layer_id)
140+
return true
141+
142+
143+
## Enabled LTP on a layer
144+
func has_global_ltp_layer(p_layer_id: String) -> bool:
145+
return _global_ltp_layers.has(p_layer_id)
146+
147+
122148
## Finds all the fixture manifetsts in the folders
123149
func _find_manifests(folder_path: String) -> Dictionary:
124150
# var user_library: Dictionary = _get_gdtf_list_from_folder(_user_fixture_library_path, true)

0 commit comments

Comments
 (0)