mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profile editor - Changed data binding behaviour in profile editor
This commit is contained in:
1 parent
15759c9289
commit
c885ae225c
4 files changed
+34
-52
No files matched your search
@@ -6,10 +6,12 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public class DataBinding<TLayerProperty, TProperty> : IDataBinding
|
||||
{
|
||||
private TProperty _currentValue = default!;
|
||||
private bool _disposed;
|
||||
private TimeSpan _easingProgress;
|
||||
private bool _reapplyValue;
|
||||
private TProperty _currentValue = default!;
|
||||
private TProperty _previousValue = default!;
|
||||
private TProperty _lastAppliedValue = default!;
|
||||
|
||||
internal DataBinding(DataBindingRegistration<TLayerProperty, TProperty> dataBindingRegistration)
|
||||
{
|
||||
@@ -114,6 +116,9 @@ namespace Artemis.Core
|
||||
_easingProgress = _easingProgress.Add(delta);
|
||||
if (_easingProgress > EasingTime)
|
||||
_easingProgress = EasingTime;
|
||||
|
||||
// Tell Apply() to apply a new value next call
|
||||
_reapplyValue = false;
|
||||
}
|
||||
|
||||
private void ResetEasing(TProperty value)
|
||||
@@ -158,6 +163,11 @@ namespace Artemis.Core
|
||||
/// <param name="timeline">The timeline to apply during update</param>
|
||||
public void Update(Timeline timeline)
|
||||
{
|
||||
// Don't update data bindings if there is no delta, otherwise this creates an inconsistency between
|
||||
// data bindings with easing and data bindings without easing (the ones with easing will seemingly not update)
|
||||
if (timeline.Delta == TimeSpan.Zero)
|
||||
return;
|
||||
|
||||
UpdateWithDelta(timeline.Delta);
|
||||
}
|
||||
|
||||
@@ -170,9 +180,19 @@ namespace Artemis.Core
|
||||
if (Converter == null)
|
||||
return;
|
||||
|
||||
// If Update() has not been called, reapply the previous value
|
||||
if (_reapplyValue)
|
||||
{
|
||||
Converter.ApplyValue(_lastAppliedValue);
|
||||
return;
|
||||
}
|
||||
|
||||
TProperty converterValue = Converter.GetValue();
|
||||
TProperty value = GetValue(converterValue);
|
||||
Converter.ApplyValue(value);
|
||||
|
||||
_lastAppliedValue = value;
|
||||
_reapplyValue = true;
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
@@ -289,9 +289,9 @@ namespace Artemis.Core
|
||||
if (keyframeEntity.Position > ProfileElement.Timeline.Length)
|
||||
return null;
|
||||
T value = CoreJson.DeserializeObject<T>(keyframeEntity.Value);
|
||||
if (value == null)
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
|
||||
LayerPropertyKeyframe<T> keyframe = new LayerPropertyKeyframe<T>(
|
||||
CoreJson.DeserializeObject<T>(keyframeEntity.Value)!, keyframeEntity.Position, (Easings.Functions) keyframeEntity.EasingFunction, this
|
||||
);
|
||||
@@ -470,10 +470,6 @@ namespace Artemis.Core
|
||||
|
||||
private void UpdateDataBindings(Timeline timeline)
|
||||
{
|
||||
// To avoid data bindings applying at non-regular updating (during editing) only update when not overriden
|
||||
if (timeline.IsOverridden)
|
||||
return;
|
||||
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
{
|
||||
dataBinding.Update(timeline);
|
||||
@@ -543,7 +539,7 @@ namespace Artemis.Core
|
||||
_keyframes.Clear();
|
||||
try
|
||||
{
|
||||
foreach (KeyframeEntity keyframeEntity in Entity.KeyframeEntities.Where(k => k.Position <= ProfileElement.Timeline.Length))
|
||||
foreach (KeyframeEntity keyframeEntity in Entity.KeyframeEntities.Where(k => k.Position <= ProfileElement.Timeline.Length))
|
||||
AddKeyframeEntity(keyframeEntity);
|
||||
}
|
||||
catch (JsonException)
|
||||
|
||||
Reference in new issue
Block a user