Nodes - Rewrote storage

This commit is contained in:
Robert committed 2022-04-10 11:59:32 +02:00
1 parent 3dfc25b092
commit 5b183d3010
23 files changed
+270 -134

No files matched your search

@@ -18,7 +18,8 @@
DockPanel.Dock="Top"
HorizontalAlignment="Stretch"
FilterTypes="{CompiledBinding FilterTypes}"
DataModelPath="{CompiledBinding EventPath}"/>
DataModelPath="{CompiledBinding EventPath}"
ShowFullPath="{CompiledBinding ShowFullPaths.Value}"/>
<TextBlock DockPanel.Dock="Top">When the event fires..</TextBlock>
<ComboBox PlaceholderText="Select a play mode" HorizontalAlignment="Stretch" DockPanel.Dock="Top" SelectedIndex="{CompiledBinding SelectedTriggerMode}">
@@ -4,6 +4,7 @@ using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.Screens.VisualScripting;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
@@ -20,15 +21,17 @@ public class EventConditionViewModel : ActivatableViewModelBase
private readonly IProfileEditorService _profileEditorService;
private readonly ObservableAsPropertyHelper<bool> _showOverlapOptions;
private readonly IWindowService _windowService;
private readonly ISettingsService _settingsService;
private ObservableAsPropertyHelper<DataModelPath?>? _eventPath;
private ObservableAsPropertyHelper<int>? _selectedOverlapMode;
private ObservableAsPropertyHelper<int>? _selectedTriggerMode;
public EventConditionViewModel(EventCondition eventCondition, IProfileEditorService profileEditorService, IWindowService windowService)
public EventConditionViewModel(EventCondition eventCondition, IProfileEditorService profileEditorService, IWindowService windowService, ISettingsService settingsService)
{
_eventCondition = eventCondition;
_profileEditorService = profileEditorService;
_windowService = windowService;
_settingsService = settingsService;
_showOverlapOptions = this.WhenAnyValue(vm => vm.SelectedTriggerMode)
.Select(m => m == 0)
.ToProperty(this, vm => vm.ShowOverlapOptions);
@@ -47,6 +50,7 @@ public class EventConditionViewModel : ActivatableViewModelBase
public ReactiveCommand<Unit, Unit> OpenEditor { get; }
public bool ShowOverlapOptions => _showOverlapOptions.Value;
public bool IsConditionForLayer => _eventCondition.ProfileElement is Layer;
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
public DataModelPath? EventPath
{
@@ -128,40 +128,41 @@
<MenuItem Header="_Options">
<MenuItem Header="Focus Selected Layer"
ToolTip.Tip="If enabled, displays only the layer you currently have selected"
IsEnabled="False">
Command="{CompiledBinding ToggleBooleanSetting}"
CommandParameter="{CompiledBinding FocusSelectedLayer}">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="{Binding FocusSelectedLayer.Value}" />
</MenuItem.Icon>
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelectedLayer.Value}"></avalonia:MaterialIcon>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Display Data Model Values">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="{Binding ShowDataModelValues.Value}" />
</MenuItem.Icon>
<MenuItem Header="Display Data Model Values"
Command="{CompiledBinding ToggleBooleanSetting}"
CommandParameter="{CompiledBinding ShowDataModelValues}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowDataModelValues.Value}"></avalonia:MaterialIcon>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Display Full Condition Paths">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="{Binding ShowFullPaths.Value}" />
</MenuItem.Icon>
<MenuItem Header="Display Full Condition Paths"
Command="{CompiledBinding ToggleBooleanSetting}"
CommandParameter="{CompiledBinding ShowFullPaths}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowFullPaths.Value}"></avalonia:MaterialIcon>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Always Display Cable Values" ToolTip.Tip="If enabled, cable values are always shown instead of only on hover">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="{Binding AlwaysShowValues.Value}" />
</MenuItem.Icon>
<MenuItem Header="Always Display Cable Values"
ToolTip.Tip="If enabled, cable values are always shown instead of only on hover"
Command="{CompiledBinding ToggleBooleanSetting}"
CommandParameter="{CompiledBinding AlwaysShowValues}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysShowValues.Value}"></avalonia:MaterialIcon>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Apply All Data Bindings During Edit" ToolTip.Tip="If enabled, updates all data bindings instead of only the one you are editing">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="{Binding AlwaysApplyDataBindings.Value}" />
</MenuItem.Icon>
<MenuItem Header="Apply All Data Bindings During Edit"
ToolTip.Tip="If enabled, updates all data bindings instead of only the one you are editing"
Command="{CompiledBinding ToggleBooleanSetting}"
CommandParameter="{CompiledBinding AlwaysApplyDataBindings}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysApplyDataBindings.Value}"></avalonia:MaterialIcon>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="_Help">
@@ -1,4 +1,5 @@
using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Artemis.Core;
@@ -12,13 +13,15 @@ namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
public class MenuBarViewModel : ActivatableViewModelBase
{
private readonly IProfileService _profileService;
private readonly ISettingsService _settingsService;
private ProfileEditorHistory? _history;
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
private ObservableAsPropertyHelper<bool>? _isSuspended;
public MenuBarViewModel(IProfileEditorService profileEditorService, IProfileService profileService)
public MenuBarViewModel(IProfileEditorService profileEditorService, IProfileService profileService, ISettingsService settingsService)
{
_profileService = profileService;
_settingsService = settingsService;
this.WhenActivated(d =>
{
profileEditorService.History.Subscribe(history => History = history).DisposeWith(d);
@@ -29,16 +32,30 @@ public class MenuBarViewModel : ActivatableViewModelBase
.ToProperty(this, vm => vm.IsSuspended)
.DisposeWith(d);
});
ToggleBooleanSetting = ReactiveCommand.Create<PluginSetting<bool>>(ExecuteToggleBooleanSetting);
}
private void ExecuteToggleBooleanSetting(PluginSetting<bool> setting)
{
setting.Value = !setting.Value;
setting.Save();
}
public ReactiveCommand<PluginSetting<bool>, Unit> ToggleBooleanSetting { get; }
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
public PluginSetting<bool> FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", false);
public PluginSetting<bool> ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
public PluginSetting<bool> AlwaysShowValues => _settingsService.GetSetting("ProfileEditor.AlwaysShowValues", false);
public PluginSetting<bool> AlwaysApplyDataBindings => _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", false);
public ProfileEditorHistory? History
{
get => _history;
set => RaiseAndSetIfChanged(ref _history, value);
}
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
public bool IsSuspended
{
get => _isSuspended?.Value ?? false;