mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Display conditions - Added Toggle mode to event conditions
Display conditions - Added Contains and Does not contain for enums Profile editor - Changed display behaviour on zero-length timelines
This commit is contained in:
parent
048864fe78
commit
f24e1ae264
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
internal class EnumContainsConditionOperator : ConditionOperator<Enum, Enum>
|
||||
{
|
||||
public override string Description => "Contains";
|
||||
public override string Icon => "Contain";
|
||||
|
||||
public override bool Evaluate(Enum a, Enum b)
|
||||
{
|
||||
return a != null && b != null && a.HasFlag(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
internal class EnumNotContainsConditionOperator : ConditionOperator<Enum, Enum>
|
||||
{
|
||||
public override string Description => "Does not contain";
|
||||
public override string Icon => "FormatStrikethrough";
|
||||
|
||||
public override bool Evaluate(Enum a, Enum b)
|
||||
{
|
||||
return a != null && (b == null || !a.HasFlag(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ namespace Artemis.Core
|
||||
|
||||
public override bool Evaluate(string a, string b)
|
||||
{
|
||||
return a != null && b != null && !a.Contains(b, StringComparison.InvariantCultureIgnoreCase);
|
||||
return a != null && (b == null || !a.Contains(b, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,8 +124,8 @@ namespace Artemis.Core
|
||||
public void UpdateTimeline(double deltaTime)
|
||||
{
|
||||
// The play mode dictates whether to stick to the main segment unless the display conditions contains events
|
||||
bool stickToMainSegment = Timeline.PlayMode == TimelinePlayMode.Repeat && DisplayConditionMet;
|
||||
if (DisplayCondition != null && DisplayCondition.ContainsEvents)
|
||||
bool stickToMainSegment = (Timeline.PlayMode == TimelinePlayMode.Repeat || Timeline.EventOverlapMode == TimeLineEventOverlapMode.Toggle) && DisplayConditionMet;
|
||||
if (DisplayCondition != null && DisplayCondition.ContainsEvents && Timeline.EventOverlapMode != TimeLineEventOverlapMode.Toggle)
|
||||
stickToMainSegment = false;
|
||||
|
||||
Timeline.Update(TimeSpan.FromSeconds(deltaTime), stickToMainSegment);
|
||||
@ -356,6 +356,7 @@ namespace Artemis.Core
|
||||
|
||||
private DataModelConditionGroup? _displayCondition;
|
||||
private bool _displayConditionMet;
|
||||
private bool _toggledOnByEvent = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the root display condition group
|
||||
@ -383,6 +384,9 @@ namespace Artemis.Core
|
||||
return;
|
||||
}
|
||||
|
||||
if (Timeline.EventOverlapMode != TimeLineEventOverlapMode.Toggle)
|
||||
_toggledOnByEvent = false;
|
||||
|
||||
bool conditionMet = DisplayCondition.Evaluate();
|
||||
if (Parent is RenderProfileElement parent && !parent.DisplayConditionMet)
|
||||
conditionMet = false;
|
||||
@ -398,25 +402,36 @@ namespace Artemis.Core
|
||||
}
|
||||
else if (conditionMet)
|
||||
{
|
||||
// Event conditions reset if the timeline finished
|
||||
if (Timeline.IsFinished)
|
||||
if (Timeline.EventOverlapMode == TimeLineEventOverlapMode.Toggle)
|
||||
{
|
||||
Timeline.JumpToStart();
|
||||
_toggledOnByEvent = !_toggledOnByEvent;
|
||||
if (_toggledOnByEvent)
|
||||
Timeline.JumpToStart();
|
||||
}
|
||||
// and otherwise apply their overlap mode
|
||||
else
|
||||
{
|
||||
if (Timeline.EventOverlapMode == TimeLineEventOverlapMode.Restart)
|
||||
// Event conditions reset if the timeline finished
|
||||
if (Timeline.IsFinished)
|
||||
{
|
||||
Timeline.JumpToStart();
|
||||
else if (Timeline.EventOverlapMode == TimeLineEventOverlapMode.Copy)
|
||||
Timeline.AddExtraTimeline();
|
||||
// The third option is ignore which is handled below:
|
||||
}
|
||||
// and otherwise apply their overlap mode
|
||||
else
|
||||
{
|
||||
if (Timeline.EventOverlapMode == TimeLineEventOverlapMode.Restart)
|
||||
Timeline.JumpToStart();
|
||||
else if (Timeline.EventOverlapMode == TimeLineEventOverlapMode.Copy)
|
||||
Timeline.AddExtraTimeline();
|
||||
// The third option is ignore which is handled below:
|
||||
|
||||
// done
|
||||
// done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayConditionMet = conditionMet;
|
||||
DisplayConditionMet = Timeline.EventOverlapMode == TimeLineEventOverlapMode.Toggle
|
||||
? _toggledOnByEvent
|
||||
: conditionMet;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -155,7 +155,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the timeline has finished its run
|
||||
/// </summary>
|
||||
public bool IsFinished => (Position > Length || Length == TimeSpan.Zero) && !ExtraTimelines.Any();
|
||||
public bool IsFinished => Position > Length && !ExtraTimelines.Any();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the timeline progress has been overridden
|
||||
@ -516,6 +516,11 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Play another copy of the timeline on top of the current run
|
||||
/// </summary>
|
||||
Copy
|
||||
Copy,
|
||||
|
||||
/// <summary>
|
||||
/// Repeat the timeline until the event fires again
|
||||
/// </summary>
|
||||
Toggle
|
||||
}
|
||||
}
|
||||
@ -64,6 +64,10 @@ namespace Artemis.Core.Services
|
||||
RegisterConditionOperator(Constants.CorePlugin, new StringNullConditionOperator());
|
||||
RegisterConditionOperator(Constants.CorePlugin, new StringNotNullConditionOperator());
|
||||
|
||||
// Enum operators
|
||||
RegisterConditionOperator(Constants.CorePlugin, new EnumContainsConditionOperator());
|
||||
RegisterConditionOperator(Constants.CorePlugin, new EnumNotContainsConditionOperator());
|
||||
|
||||
// Null checks, at the bottom
|
||||
// TODO: Implement a priority mechanism
|
||||
RegisterConditionOperator(Constants.CorePlugin, new NullConditionOperator());
|
||||
|
||||
@ -192,11 +192,11 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Trigger mode -->
|
||||
<TextBlock Grid.Column="0" Text="Rapid trigger mode">
|
||||
<TextBlock Grid.Column="0" Text="Trigger mode">
|
||||
<TextBlock.ToolTip>
|
||||
<ToolTip Placement="Center" VerticalOffset="-30">
|
||||
<TextBlock>
|
||||
Configure how the layer should act when the event(s) trigger before the timeline finishes
|
||||
Configure how the layer should act when the event(s) trigger
|
||||
</TextBlock>
|
||||
</ToolTip>
|
||||
</TextBlock.ToolTip>
|
||||
@ -207,6 +207,7 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<RadioButton Grid.Column="0"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
@ -224,6 +225,21 @@
|
||||
</RadioButton.ToolTip>
|
||||
</RadioButton>
|
||||
<RadioButton Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Toggle}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
<materialDesign:PackIcon Kind="TrafficLight" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||
TOGGLE
|
||||
</TextBlock>
|
||||
<RadioButton.ToolTip>
|
||||
<ToolTip Placement="Center" VerticalOffset="-40">
|
||||
<TextBlock>
|
||||
Repeat the timeline until the event fires again
|
||||
</TextBlock>
|
||||
</ToolTip>
|
||||
</RadioButton.ToolTip>
|
||||
</RadioButton>
|
||||
<RadioButton Grid.Column="2"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Ignore}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
@ -238,7 +254,7 @@
|
||||
</ToolTip>
|
||||
</RadioButton.ToolTip>
|
||||
</RadioButton>
|
||||
<RadioButton Grid.Column="2"
|
||||
<RadioButton Grid.Column="3"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Copy}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user