mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model conditions - Added UI for event trigger modes
This commit is contained in:
parent
e7ce16ba73
commit
2b29e90189
@ -21,6 +21,8 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Entity = new DataModelConditionGroupEntity();
|
Entity = new DataModelConditionGroupEntity();
|
||||||
|
ChildAdded += OnChildrenChanged;
|
||||||
|
ChildRemoved += OnChildrenChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -49,6 +51,10 @@ namespace Artemis.Core
|
|||||||
else if (childEntity is DataModelConditionEventPredicateEntity eventPredicateEntity)
|
else if (childEntity is DataModelConditionEventPredicateEntity eventPredicateEntity)
|
||||||
AddChild(new DataModelConditionEventPredicate(this, eventPredicateEntity));
|
AddChild(new DataModelConditionEventPredicate(this, eventPredicateEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContainsEvents = Children.Any(c => c is DataModelConditionEvent);
|
||||||
|
ChildAdded += OnChildrenChanged;
|
||||||
|
ChildRemoved += OnChildrenChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -56,6 +62,11 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BooleanOperator BooleanOperator { get; set; }
|
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; }
|
internal DataModelConditionGroupEntity Entity { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -137,6 +148,11 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
return Entity;
|
return Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnChildrenChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ContainsEvents = Children.Any(c => c is DataModelConditionEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -127,11 +127,13 @@ namespace Artemis.Core
|
|||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// If the condition is event-based, never display continuously
|
||||||
|
bool displayContinuously = (DisplayCondition == null || !DisplayCondition.ContainsEvents) && DisplayContinuously;
|
||||||
TimeSpan beginTime = TimelinePosition;
|
TimeSpan beginTime = TimelinePosition;
|
||||||
|
|
||||||
if (stickToMainSegment)
|
if (stickToMainSegment)
|
||||||
{
|
{
|
||||||
if (!DisplayContinuously)
|
if (!displayContinuously)
|
||||||
{
|
{
|
||||||
TimeSpan position = timeOverride + StartSegmentLength;
|
TimeSpan position = timeOverride + StartSegmentLength;
|
||||||
if (position > StartSegmentLength + EndSegmentLength)
|
if (position > StartSegmentLength + EndSegmentLength)
|
||||||
|
|||||||
@ -301,11 +301,13 @@ namespace Artemis.Core
|
|||||||
bool wasApplyingDataBindings = ApplyDataBindingsEnabled;
|
bool wasApplyingDataBindings = ApplyDataBindingsEnabled;
|
||||||
ApplyDataBindingsEnabled = false;
|
ApplyDataBindingsEnabled = false;
|
||||||
|
|
||||||
|
// If the condition is event-based, never display continuously
|
||||||
|
bool displayContinuously = (DisplayCondition == null || !DisplayCondition.ContainsEvents) && DisplayContinuously;
|
||||||
TimeSpan beginTime = TimelinePosition;
|
TimeSpan beginTime = TimelinePosition;
|
||||||
|
|
||||||
if (stickToMainSegment)
|
if (stickToMainSegment)
|
||||||
{
|
{
|
||||||
if (!DisplayContinuously)
|
if (!displayContinuously)
|
||||||
{
|
{
|
||||||
TimelinePosition = StartSegmentLength + timeOverride;
|
TimelinePosition = StartSegmentLength + timeOverride;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -228,6 +228,16 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
protected double UpdateTimeline(double deltaTime)
|
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 oldPosition = _timelinePosition;
|
||||||
TimeSpan deltaTimeSpan = TimeSpan.FromSeconds(deltaTime);
|
TimeSpan deltaTimeSpan = TimeSpan.FromSeconds(deltaTime);
|
||||||
TimeSpan mainSegmentEnd = StartSegmentLength + MainSegmentLength;
|
TimeSpan mainSegmentEnd = StartSegmentLength + MainSegmentLength;
|
||||||
@ -237,13 +247,13 @@ namespace Artemis.Core
|
|||||||
if (DisplayConditionMet)
|
if (DisplayConditionMet)
|
||||||
{
|
{
|
||||||
// If we are at the end of the main timeline, wrap around back to the beginning
|
// 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;
|
TimelinePosition = StartSegmentLength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Skip to the last segment if conditions are no longer met
|
// Skip to the last segment if conditions are no longer met
|
||||||
if (!AlwaysFinishTimeline && TimelinePosition < mainSegmentEnd)
|
if (!alwaysFinishTimeline && TimelinePosition < mainSegmentEnd)
|
||||||
TimelinePosition = mainSegmentEnd;
|
TimelinePosition = mainSegmentEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,9 +56,9 @@
|
|||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="3">
|
<Grid Grid.Row="3" Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="20" />
|
<RowDefinition Height="18" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -67,9 +67,7 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- Play mode -->
|
<!-- Play mode -->
|
||||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
<TextBlock Grid.Column="0" Text="Play mode">
|
||||||
<materialDesign:PackIcon Kind="PlayOutline" VerticalAlignment="Center" />
|
|
||||||
<TextBlock Text="Play mode" VerticalAlignment="Center">
|
|
||||||
<TextBlock.ToolTip>
|
<TextBlock.ToolTip>
|
||||||
<ToolTip Placement="Center" VerticalOffset="-30">
|
<ToolTip Placement="Center" VerticalOffset="-30">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
@ -78,8 +76,6 @@
|
|||||||
</ToolTip>
|
</ToolTip>
|
||||||
</TextBlock.ToolTip>
|
</TextBlock.ToolTip>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<materialDesign:ColorZone Grid.Row="1" Grid.Column="0" Mode="Standard" CornerRadius="3" Margin="0 0 2 0">
|
<materialDesign:ColorZone Grid.Row="1" Grid.Column="0" Mode="Standard" CornerRadius="3" Margin="0 0 2 0">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -98,10 +94,10 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
</RadioButton.ToolTip>
|
</RadioButton.ToolTip>
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
<materialDesign:PackIcon Kind="Repeat" VerticalAlignment="Center" />
|
<materialDesign:PackIcon Kind="Repeat" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
<TextBlock FontSize="12" VerticalAlignment="Center">REPEAT</TextBlock>
|
REPEAT
|
||||||
</StackPanel>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton Grid.Column="1"
|
<RadioButton Grid.Column="1"
|
||||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||||
@ -115,18 +111,16 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
</RadioButton.ToolTip>
|
</RadioButton.ToolTip>
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
<materialDesign:PackIcon Kind="StopwatchOutline" VerticalAlignment="Center" />
|
<materialDesign:PackIcon Kind="StopwatchOutline" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
<TextBlock FontSize="12" VerticalAlignment="Center">ONCE</TextBlock>
|
ONCE
|
||||||
</StackPanel>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:ColorZone>
|
</materialDesign:ColorZone>
|
||||||
|
|
||||||
<!-- Stop mode -->
|
<!-- Stop mode -->
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
<TextBlock Grid.Row="0" Grid.Column="1" Text="Stop mode">
|
||||||
<materialDesign:PackIcon Kind="Stop" VerticalAlignment="Center" />
|
|
||||||
<TextBlock Text="Stop mode" VerticalAlignment="Center">
|
|
||||||
<TextBlock.ToolTip>
|
<TextBlock.ToolTip>
|
||||||
<ToolTip Placement="Center" VerticalOffset="-30">
|
<ToolTip Placement="Center" VerticalOffset="-30">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
@ -135,7 +129,6 @@
|
|||||||
</ToolTip>
|
</ToolTip>
|
||||||
</TextBlock.ToolTip>
|
</TextBlock.ToolTip>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
|
||||||
<materialDesign:ColorZone Grid.Row="1" Grid.Column="1" Mode="Standard" CornerRadius="3" Margin="2 0 0 0" HorizontalAlignment="Stretch">
|
<materialDesign:ColorZone Grid.Row="1" Grid.Column="1" Mode="Standard" CornerRadius="3" Margin="2 0 0 0" HorizontalAlignment="Stretch">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -154,10 +147,10 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
</RadioButton.ToolTip>
|
</RadioButton.ToolTip>
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
<materialDesign:PackIcon Kind="PlayOutline" VerticalAlignment="Center" />
|
<materialDesign:PackIcon Kind="PlayOutline" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
<TextBlock FontSize="12" VerticalAlignment="Center">FINISH</TextBlock>
|
FINISH
|
||||||
</StackPanel>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton Grid.Column="1"
|
<RadioButton Grid.Column="1"
|
||||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||||
@ -171,25 +164,85 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
</RadioButton.ToolTip>
|
</RadioButton.ToolTip>
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
<materialDesign:PackIcon Kind="SkipNextOutline" VerticalAlignment="Center" />
|
<materialDesign:PackIcon Kind="SkipNextOutline" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
<TextBlock FontSize="12" VerticalAlignment="Center">SKIP TO END</TextBlock>
|
SKIP TO END
|
||||||
</StackPanel>
|
</TextBlock>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:ColorZone>
|
</materialDesign:ColorZone>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Indicator for events, overlaps the previous grid -->
|
<Grid Grid.Row="3" Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
<materialDesign:Card Grid.Row="3"
|
<Grid.RowDefinitions>
|
||||||
Grid.Column="0"
|
<RowDefinition Height="18" />
|
||||||
Margin="-10 0 -10 -10"
|
<RowDefinition />
|
||||||
Opacity="0.95"
|
</Grid.RowDefinitions>
|
||||||
Background="{DynamicResource MaterialDesignPaper}"
|
|
||||||
Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
<!-- Trigger mode -->
|
||||||
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14">
|
<TextBlock Grid.Column="0" Text="Rapid trigger mode">
|
||||||
<materialDesign:PackIcon Kind="FlashAlert" Height="20" Width="20" Margin="0 -5" /> Timeline modes not available to event-based conditions
|
<TextBlock.ToolTip>
|
||||||
|
<ToolTip Placement="Center" VerticalOffset="-30">
|
||||||
|
<TextBlock>
|
||||||
|
Configure how the layer should act when the event(s) trigger before the timeline finishes
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</materialDesign:Card>
|
</ToolTip>
|
||||||
|
</TextBlock.ToolTip>
|
||||||
|
</TextBlock>
|
||||||
|
<materialDesign:ColorZone Grid.Row="1" Grid.Column="0" Mode="Standard" CornerRadius="3">
|
||||||
|
<Grid HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<RadioButton Grid.Column="0"
|
||||||
|
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||||
|
IsChecked="True">
|
||||||
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
|
<materialDesign:PackIcon Kind="Repeat" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
|
RESTART
|
||||||
|
</TextBlock>
|
||||||
|
<RadioButton.ToolTip>
|
||||||
|
<ToolTip Placement="Center" VerticalOffset="-40">
|
||||||
|
<TextBlock>
|
||||||
|
Stop the current run and restart the timeline
|
||||||
|
</TextBlock>
|
||||||
|
</ToolTip>
|
||||||
|
</RadioButton.ToolTip>
|
||||||
|
</RadioButton>
|
||||||
|
<RadioButton Grid.Column="1"
|
||||||
|
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||||
|
IsChecked="False">
|
||||||
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
|
<materialDesign:PackIcon Kind="EarHearingOff" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
|
IGNORE
|
||||||
|
</TextBlock>
|
||||||
|
<RadioButton.ToolTip>
|
||||||
|
<ToolTip Placement="Center" VerticalOffset="-40">
|
||||||
|
<TextBlock>
|
||||||
|
Ignore subsequent event fires until the timeline finishes
|
||||||
|
</TextBlock>
|
||||||
|
</ToolTip>
|
||||||
|
</RadioButton.ToolTip>
|
||||||
|
</RadioButton>
|
||||||
|
<RadioButton Grid.Column="2"
|
||||||
|
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||||
|
IsChecked="False">
|
||||||
|
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||||
|
COPY
|
||||||
|
</TextBlock>
|
||||||
|
<RadioButton.ToolTip>
|
||||||
|
<ToolTip Placement="Center" VerticalOffset="-40">
|
||||||
|
<TextBlock>
|
||||||
|
Play another copy of the timeline on top of the current run
|
||||||
|
</TextBlock>
|
||||||
|
</ToolTip>
|
||||||
|
</RadioButton.ToolTip>
|
||||||
|
</RadioButton>
|
||||||
|
</Grid>
|
||||||
|
</materialDesign:ColorZone>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -13,7 +13,7 @@ namespace Artemis.Plugins.DataModelExpansions.TestData
|
|||||||
{
|
{
|
||||||
_rand = new Random();
|
_rand = new Random();
|
||||||
AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate);
|
AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate);
|
||||||
AddTimedUpdate(TimeSpan.FromSeconds(5), TriggerEvent);
|
AddTimedUpdate(TimeSpan.FromSeconds(0.5), TriggerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TriggerEvent(double obj)
|
private void TriggerEvent(double obj)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user