Sidebar - Show message when profile is broken

Events - Keep the old event type around for if you change your mind
This commit is contained in:
Robert committed 2021-09-18 13:38:09 +02:00
1 parent d6372dffad
commit 02f4609eae
8 files changed
+78 -27

No files matched your search

@@ -15,7 +15,6 @@
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type displayConditions:DisplayConditionsViewModel}}">
<UserControl.Resources>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<converters:ComparisonConverter x:Key="ComparisonConverter" />
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources>
@@ -100,6 +99,20 @@
s:View.Model="{Binding ActiveItem}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsTabStop="False"/>
IsTabStop="False"
Visibility="{Binding ActiveItem, Converter={StaticResource NullToVisibilityConverter}}"/>
<StackPanel Grid.Row="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding ActiveItem, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}">
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" TextWrapping="Wrap" TextAlignment="Center" Margin="0 10">
Display conditions disabled
<materialDesign:PackIcon Kind="No" Margin="0 0 0 -6" Width="30" Height="30" VerticalAlignment="Center" />
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap" TextAlignment="Center">
This element will always display.
</TextBlock>
</StackPanel>
</Grid>
</UserControl>
@@ -11,6 +11,8 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
private readonly IConditionVmFactory _conditionVmFactory;
private readonly IProfileEditorService _profileEditorService;
private DisplayConditionType _displayConditionType;
private StaticCondition _staticCondition;
private EventCondition _eventCondition;
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IConditionVmFactory conditionVmFactory)
{
@@ -47,12 +49,19 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
if (_profileEditorService.SelectedProfileElement == null)
return;
// Keep the old condition around in case the user changes their mind
if (_profileEditorService.SelectedProfileElement.DisplayCondition is StaticCondition staticCondition)
_staticCondition = staticCondition;
else if (_profileEditorService.SelectedProfileElement.DisplayCondition is EventCondition eventCondition)
_eventCondition = eventCondition;
// If we have the old condition around put it back
if (DisplayConditionType == DisplayConditionType.Static)
_profileEditorService.SelectedProfileElement.ChangeDisplayCondition(new StaticCondition(_profileEditorService.SelectedProfileElement));
_profileEditorService.SelectedProfileElement.DisplayCondition = _staticCondition ?? new StaticCondition(_profileEditorService.SelectedProfileElement);
else if (DisplayConditionType == DisplayConditionType.Events)
_profileEditorService.SelectedProfileElement.ChangeDisplayCondition(new EventCondition(_profileEditorService.SelectedProfileElement));
_profileEditorService.SelectedProfileElement.DisplayCondition = _eventCondition ?? new EventCondition(_profileEditorService.SelectedProfileElement);
else
_profileEditorService.SelectedProfileElement.ChangeDisplayCondition(null);
_profileEditorService.SelectedProfileElement.DisplayCondition = null;
_profileEditorService.SaveSelectedProfileElement();
Update(_profileEditorService.SelectedProfileElement);
@@ -87,6 +96,11 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
private void ProfileEditorServiceOnSelectedProfileElementChanged(object sender, RenderProfileElementEventArgs e)
{
if (_staticCondition != null && e.PreviousRenderProfileElement?.DisplayCondition != _staticCondition)
_staticCondition.Dispose();
if (_eventCondition != null && e.PreviousRenderProfileElement?.DisplayCondition != _eventCondition)
_eventCondition.Dispose();
Update(e.RenderProfileElement);
}
}
@@ -50,7 +50,7 @@
IsChecked="{Binding TriggerConditionally}"
Content="Conditional trigger"
VerticalAlignment="Center"
ToolTip="When enabled, the layer will only trigger if the script evaluates to true"
ToolTip="When enabled, the element will only trigger if the script evaluates to true"
Style="{StaticResource MaterialDesignDarkCheckBox}" />
<Grid Grid.Row="1"
@@ -60,7 +60,7 @@
Cursor="Hand"
Visibility="{Binding EventCondition.Script, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Normal, Mode=OneWay}">
<controls:VisualScriptPresenter Script="{Binding EventCondition.Script}" AutoFitScript="True" />
<Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Opacity="0">
<Border.Background>
<SolidColorBrush Color="{Binding Color, Source={StaticResource MaterialDesignCardBackground}}" Opacity="0.75" />
</Border.Background>
@@ -105,7 +105,7 @@
<materialDesign:PackIcon Kind="No" Margin="0 0 0 -6" Width="30" Height="30" VerticalAlignment="Center" />
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap" TextAlignment="Center">
When enabled, the layer will only trigger if the script evaluates to true
This element will trigger any time the event fires.
</TextBlock>
</StackPanel>
</Grid>
@@ -84,6 +84,7 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions.Event
{
EventCondition.UpdateEventNode();
DisplayName = EventCondition.EventPath?.Segments.LastOrDefault()?.GetPropertyDescription()?.Name ?? "Invalid event";
_profileEditorService.SaveSelectedProfileElement();
}
public void ScriptGridMouseUp(object sender, MouseButtonEventArgs e)