mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Data model conditions - Added UI for event trigger modes
This commit is contained in:
1 parent
e7ce16ba73
commit
2b29e90189
6 files changed
+142
-59
No files matched your search
@@ -21,6 +21,8 @@ namespace Artemis.Core
|
||||
{
|
||||
Parent = parent;
|
||||
Entity = new DataModelConditionGroupEntity();
|
||||
ChildAdded += OnChildrenChanged;
|
||||
ChildRemoved += OnChildrenChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,6 +62,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public BooleanOperator BooleanOperator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this group contains any events
|
||||
/// </summary>
|
||||
public bool ContainsEvents { get; private set; }
|
||||
|
||||
internal DataModelConditionGroupEntity Entity { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -137,6 +148,11 @@ namespace Artemis.Core
|
||||
{
|
||||
return Entity;
|
||||
}
|
||||
|
||||
private void OnChildrenChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ContainsEvents = Children.Any(c => c is DataModelConditionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user