mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Data model conditions - Expanded events UI logic
This commit is contained in:
1 parent
fbd319beb9
commit
e7ce16ba73
15 files changed
+226
-54
No files matched your search
@@ -17,7 +17,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
||||
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -45,13 +45,24 @@
|
||||
</Button>
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
ToolTip="Change the operator of the group, determining which conditions should match"
|
||||
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
||||
Background="#E74C4C"
|
||||
BorderBrush="#E74C4C"
|
||||
Margin="3 1"
|
||||
Content="{Binding SelectedBooleanOperator}"
|
||||
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
|
||||
IsEnabled="{Binding IsEventGroup, Converter={StaticResource InverseBooleanConverter}}"
|
||||
ToolTipService.ShowOnDisabled="True">
|
||||
<Button.ToolTip>
|
||||
<StackPanel>
|
||||
<TextBlock Visibility="{Binding IsEventGroup, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
Change the operator of the group, determining which conditions should match
|
||||
</TextBlock>
|
||||
<TextBlock Visibility="{Binding IsEventGroup, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
The operator of the root group cannot be changed for event-based conditions
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.ToolTip>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="And"
|
||||
|
||||
+13
-3
@@ -19,6 +19,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private bool _isInitialized;
|
||||
private bool _isRootGroup;
|
||||
private bool _isEventGroup;
|
||||
|
||||
public DataModelConditionGroupViewModel(DataModelConditionGroup dataModelConditionGroup,
|
||||
ConditionGroupType groupType,
|
||||
@@ -48,6 +49,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
set => SetAndNotify(ref _isRootGroup, value);
|
||||
}
|
||||
|
||||
public bool IsEventGroup
|
||||
{
|
||||
get => _isEventGroup;
|
||||
set => SetAndNotify(ref _isEventGroup, value);
|
||||
}
|
||||
|
||||
public bool IsInitialized
|
||||
{
|
||||
get => _isInitialized;
|
||||
@@ -98,7 +105,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
public override void Update()
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
||||
|
||||
// Remove VMs of effects no longer applied on the layer
|
||||
Items.RemoveRange(Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList());
|
||||
|
||||
@@ -140,8 +146,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
foreach (DataModelConditionViewModel childViewModel in Items)
|
||||
childViewModel.Update();
|
||||
|
||||
if (IsRootGroup && Parent is DisplayConditionsViewModel displayConditionsViewModel)
|
||||
displayConditionsViewModel.DisplayStartHint = !Items.Any();
|
||||
IsEventGroup = Items.Any(i => i is DataModelConditionEventViewModel);
|
||||
if (IsEventGroup)
|
||||
{
|
||||
if (DataModelConditionGroup.BooleanOperator != BooleanOperator.And)
|
||||
SelectBooleanOperator("And");
|
||||
}
|
||||
|
||||
OnUpdated();
|
||||
}
|
||||
|
||||
+3
-2
@@ -54,7 +54,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
|
||||
protected override List<DataModelPropertiesViewModel> GetExtraRightSideDataModelViewModels()
|
||||
{
|
||||
return new List<DataModelPropertiesViewModel> {GetEventDataModel()};
|
||||
// Extra data models are expected to not have an empty root, so lets return the child
|
||||
return GetEventDataModel().Children.Cast<DataModelPropertiesViewModel>().ToList();
|
||||
}
|
||||
|
||||
private DataModelPropertiesViewModel GetEventDataModel()
|
||||
@@ -63,7 +64,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
||||
);
|
||||
|
||||
return wrapper.CreateViewModel();
|
||||
return wrapper.CreateViewModel(_dataModelUIService);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -20,6 +20,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
: base(dataModelConditionGeneralPredicate, profileEditorService, dataModelUIService, conditionOperatorService, settingsService)
|
||||
{
|
||||
_dataModelUIService = dataModelUIService;
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -29,8 +33,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
List<Type> supportedInputTypes = editors.Select(e => e.SupportedType).ToList();
|
||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
||||
|
||||
// Events are only supported in the root group enforce that here
|
||||
if (Parent is DataModelConditionGroupViewModel groupViewModel && groupViewModel.IsRootGroup)
|
||||
{
|
||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
||||
}
|
||||
|
||||
return supportedInputTypes;
|
||||
}
|
||||
|
||||
@@ -179,5 +179,17 @@
|
||||
</Grid>
|
||||
</materialDesign:ColorZone>
|
||||
</Grid>
|
||||
|
||||
<!-- Indicator for events, overlaps the previous grid -->
|
||||
<materialDesign:Card Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="-10 0 -10 -10"
|
||||
Opacity="0.95"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14">
|
||||
<materialDesign:PackIcon Kind="FlashAlert" Height="20" Width="20" Margin="0 -5" /> Timeline modes not available to event-based conditions
|
||||
</TextBlock>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+27
-3
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
||||
@@ -14,6 +15,7 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RenderProfileElement _renderProfileElement;
|
||||
private bool _displayStartHint;
|
||||
private bool _isEventCondition;
|
||||
|
||||
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IDataModelConditionsVmFactory dataModelConditionsVmFactory)
|
||||
{
|
||||
@@ -27,6 +29,12 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
set => SetAndNotify(ref _displayStartHint, value);
|
||||
}
|
||||
|
||||
public bool IsEventCondition
|
||||
{
|
||||
get => _isEventCondition;
|
||||
set => SetAndNotify(ref _isEventCondition, value);
|
||||
}
|
||||
|
||||
public RenderProfileElement RenderProfileElement
|
||||
{
|
||||
get => _renderProfileElement;
|
||||
@@ -71,7 +79,14 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
if (RenderProfileElement != null)
|
||||
{
|
||||
RenderProfileElement.DisplayCondition.ChildAdded -= DisplayConditionOnChildrenModified;
|
||||
RenderProfileElement.DisplayCondition.ChildRemoved -= DisplayConditionOnChildrenModified;
|
||||
}
|
||||
|
||||
RenderProfileElement = e.RenderProfileElement;
|
||||
|
||||
NotifyOfPropertyChange(nameof(DisplayContinuously));
|
||||
NotifyOfPropertyChange(nameof(AlwaysFinishTimeline));
|
||||
NotifyOfPropertyChange(nameof(ConditionBehaviourEnabled));
|
||||
@@ -90,8 +105,17 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
ActiveItem.IsRootGroup = true;
|
||||
ActiveItem.Update();
|
||||
|
||||
// Only show the intro to conditions once, and only if the layer has no conditions
|
||||
DisplayStartHint = !ActiveItem.Items.Any();
|
||||
DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||
IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||
|
||||
RenderProfileElement.DisplayCondition.ChildAdded += DisplayConditionOnChildrenModified;
|
||||
RenderProfileElement.DisplayCondition.ChildRemoved += DisplayConditionOnChildrenModified;
|
||||
}
|
||||
|
||||
private void DisplayConditionOnChildrenModified(object? sender, EventArgs e)
|
||||
{
|
||||
DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||
IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user