diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs index b25050d15..449a68b74 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs @@ -21,6 +21,8 @@ namespace Artemis.Core { Parent = parent; Entity = new DataModelConditionGroupEntity(); + ChildAdded += OnChildrenChanged; + ChildRemoved += OnChildrenChanged; } /// @@ -45,10 +47,14 @@ namespace Artemis.Core else if (childEntity is DataModelConditionGeneralPredicateEntity predicateEntity) AddChild(new DataModelConditionGeneralPredicate(this, predicateEntity)); else if (childEntity is DataModelConditionListPredicateEntity listPredicateEntity) - AddChild(new DataModelConditionListPredicate(this, listPredicateEntity)); + AddChild(new DataModelConditionListPredicate(this, listPredicateEntity)); else if (childEntity is DataModelConditionEventPredicateEntity eventPredicateEntity) AddChild(new DataModelConditionEventPredicate(this, eventPredicateEntity)); } + + ContainsEvents = Children.Any(c => c is DataModelConditionEvent); + ChildAdded += OnChildrenChanged; + ChildRemoved += OnChildrenChanged; } /// @@ -56,6 +62,11 @@ namespace Artemis.Core /// public BooleanOperator BooleanOperator { get; set; } + /// + /// Gets whether this group contains any events + /// + public bool ContainsEvents { get; private set; } + internal DataModelConditionGroupEntity Entity { get; set; } /// @@ -137,6 +148,11 @@ namespace Artemis.Core { return Entity; } + + private void OnChildrenChanged(object? sender, EventArgs e) + { + ContainsEvents = Children.Any(c => c is DataModelConditionEvent); + } } /// diff --git a/src/Artemis.Core/Models/Profile/Folder.cs b/src/Artemis.Core/Models/Profile/Folder.cs index e615ba920..dab4fc5a4 100644 --- a/src/Artemis.Core/Models/Profile/Folder.cs +++ b/src/Artemis.Core/Models/Profile/Folder.cs @@ -127,11 +127,13 @@ namespace Artemis.Core if (!Enabled) return; + // If the condition is event-based, never display continuously + bool displayContinuously = (DisplayCondition == null || !DisplayCondition.ContainsEvents) && DisplayContinuously; TimeSpan beginTime = TimelinePosition; if (stickToMainSegment) { - if (!DisplayContinuously) + if (!displayContinuously) { TimeSpan position = timeOverride + StartSegmentLength; if (position > StartSegmentLength + EndSegmentLength) diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 398011573..3bb195fd4 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -301,11 +301,13 @@ namespace Artemis.Core bool wasApplyingDataBindings = ApplyDataBindingsEnabled; ApplyDataBindingsEnabled = false; + // If the condition is event-based, never display continuously + bool displayContinuously = (DisplayCondition == null || !DisplayCondition.ContainsEvents) && DisplayContinuously; TimeSpan beginTime = TimelinePosition; if (stickToMainSegment) { - if (!DisplayContinuously) + if (!displayContinuously) { TimelinePosition = StartSegmentLength + timeOverride; } diff --git a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs index a30f31c17..c94b48ca4 100644 --- a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs +++ b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs @@ -228,6 +228,16 @@ namespace Artemis.Core protected double UpdateTimeline(double deltaTime) { + bool displayContinuously = DisplayContinuously; + bool alwaysFinishTimeline = AlwaysFinishTimeline; + + // If the condition is event-based, never display continuously and always finish the timeline + if (DisplayCondition != null && DisplayCondition.ContainsEvents) + { + displayContinuously = false; + alwaysFinishTimeline = true; + } + TimeSpan oldPosition = _timelinePosition; TimeSpan deltaTimeSpan = TimeSpan.FromSeconds(deltaTime); TimeSpan mainSegmentEnd = StartSegmentLength + MainSegmentLength; @@ -237,13 +247,13 @@ namespace Artemis.Core if (DisplayConditionMet) { // If we are at the end of the main timeline, wrap around back to the beginning - if (DisplayContinuously && TimelinePosition >= mainSegmentEnd) + if (displayContinuously && TimelinePosition >= mainSegmentEnd) TimelinePosition = StartSegmentLength; } else { // Skip to the last segment if conditions are no longer met - if (!AlwaysFinishTimeline && TimelinePosition < mainSegmentEnd) + if (!alwaysFinishTimeline && TimelinePosition < mainSegmentEnd) TimelinePosition = mainSegmentEnd; } diff --git a/src/Artemis.UI/Screens/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml b/src/Artemis.UI/Screens/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml index a2b531bbb..4ba2ff183 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml @@ -56,9 +56,9 @@ - + - + @@ -67,19 +67,15 @@ - - - - - - - Configure how the layer should act while the conditions above are met - - - - - - + + + + + Configure how the layer should act while the conditions above are met + + + + @@ -98,10 +94,10 @@ - - - REPEAT - + + + REPEAT + - - - ONCE - + + + ONCE + - - - - - - - Configure how the layer should act when the conditions above are no longer met - - - - - + + + + + Configure how the layer should act when the conditions above are no longer met + + + + @@ -154,10 +147,10 @@ - - - FINISH - + + + FINISH + - - - SKIP TO END - + + + SKIP TO END + - - - - Timeline modes not available to event-based conditions + + + + + + + + + + + + Configure how the layer should act when the event(s) trigger before the timeline finishes + + + - + + + + + + + + + + + RESTART + + + + + Stop the current run and restart the timeline + + + + + + + + IGNORE + + + + + Ignore subsequent event fires until the timeline finishes + + + + + + + + COPY + + + + + Play another copy of the timeline on top of the current run + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/PluginDataModelExpansion.cs b/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/PluginDataModelExpansion.cs index 260110186..084a012f3 100644 --- a/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/PluginDataModelExpansion.cs +++ b/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/PluginDataModelExpansion.cs @@ -13,7 +13,7 @@ namespace Artemis.Plugins.DataModelExpansions.TestData { _rand = new Random(); AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate); - AddTimedUpdate(TimeSpan.FromSeconds(5), TriggerEvent); + AddTimedUpdate(TimeSpan.FromSeconds(0.5), TriggerEvent); } private void TriggerEvent(double obj)