Modules - Added ListItemName prop to the DataModelProperty attribute

Conditions - Display the full path of a condition (can be disabled in the editor options menu)
Hotkeys - Fixed hotkeys not working after restarting Artemis
Profile editor - Fixed display conditions not showing last selected layer on editor open
This commit is contained in:
Robert committed 2021-07-08 19:02:06 +02:00
1 parent 4034f438ed
commit 4fe0ea38cb
15 files changed
+111 -36

No files matched your search

@@ -30,12 +30,14 @@ namespace Artemis.UI.Shared.Input
private bool _isDataModelViewModelOpen;
private bool _isEnabled = true;
private string _placeholder = "Select a property";
private readonly PluginSetting<bool> _showFullPath;
internal DataModelDynamicViewModel(List<Module> modules, ISettingsService settingsService, IDataModelUIService dataModelUIService)
{
_modules = modules;
_dataModelUIService = dataModelUIService;
_updateTimer = new Timer(500);
_showFullPath = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
ExtraDataModelViewModels = new BindableCollection<DataModelPropertiesViewModel>();
ShowDataModelValues = settingsService.GetSetting<bool>("ProfileEditor.ShowDataModelValues");
@@ -127,6 +129,8 @@ namespace Artemis.UI.Shared.Input
/// </summary>
public PluginSetting<bool> ShowDataModelValues { get; }
public PluginSetting<bool> ShowFullPath { get; }
/// <summary>
/// Gets or sets root the data model view model
/// </summary>
@@ -177,7 +181,15 @@ namespace Artemis.UI.Shared.Input
/// <summary>
/// Gets the display name of the currently selected property
/// </summary>
public string? DisplayValue => DataModelPath?.GetPropertyDescription()?.Name ?? DataModelPath?.Segments.LastOrDefault()?.Identifier;
public string? DisplayValue
{
get
{
if (_showFullPath.Value)
return DisplayPath;
return DataModelPath?.GetPropertyDescription()?.Name ?? DataModelPath?.Segments.LastOrDefault()?.Identifier;
}
}
/// <summary>
/// Gets the human readable path of the currently selected property
@@ -190,7 +202,8 @@ namespace Artemis.UI.Shared.Input
return "Click to select a property";
if (!DataModelPath.IsValid)
return "Invalid path";
return string.Join(" › ", DataModelPath.Segments.Select(s => s.GetPropertyDescription()?.Name ?? s.Identifier));
return string.Join(" › ", DataModelPath.Segments.Where(s => s.GetPropertyDescription()!= null).Select(s => s.GetPropertyDescription()!.Name));
}
}
@@ -244,8 +257,10 @@ namespace Artemis.UI.Shared.Input
ExtraDataModelViewModels.CollectionChanged += ExtraDataModelViewModelsOnCollectionChanged;
_updateTimer.Start();
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
_showFullPath.SettingChanged += ShowFullPathOnSettingChanged;
}
private void ExecuteSelectPropertyCommand(object? context)
{
if (context is not DataModelVisualizationViewModel selected)
@@ -271,7 +286,8 @@ namespace Artemis.UI.Shared.Input
_updateTimer.Stop();
_updateTimer.Dispose();
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
_showFullPath.SettingChanged -= ShowFullPathOnSettingChanged;
DataModelViewModel?.Dispose();
DataModelPath?.Dispose();
}
@@ -330,6 +346,11 @@ namespace Artemis.UI.Shared.Input
}
}
private void ShowFullPathOnSettingChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(DisplayValue));
}
#endregion
#region Events
@@ -16,9 +16,9 @@ namespace Artemis.UI.Shared
private int _index;
private Type? _listType;
internal DataModelListPropertiesViewModel(Type listType) : base(null, null, null)
internal DataModelListPropertiesViewModel(Type listType, string? name) : base(null, null, null)
{
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType);
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType, name);
DataModel = _listPredicateWrapper;
ListType = listType;
}
@@ -14,17 +14,17 @@ namespace Artemis.UI.Shared
private int _index;
private Type? _listType;
internal DataModelListPropertyViewModel(Type listType, DataModelDisplayViewModel displayViewModel) : base(null, null, null)
internal DataModelListPropertyViewModel(Type listType, DataModelDisplayViewModel displayViewModel, string? name) : base(null, null, null)
{
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType);
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType, name);
DataModel = _listPredicateWrapper;
ListType = listType;
DisplayViewModel = displayViewModel;
}
internal DataModelListPropertyViewModel(Type listType) : base(null, null, null)
internal DataModelListPropertyViewModel(Type listType, string? name) : base(null, null, null)
{
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType);
_listPredicateWrapper = ListPredicateWrapperDataModel.Create(listType, name);
DataModel = _listPredicateWrapper;
ListType = listType;
}
@@ -91,7 +91,7 @@ namespace Artemis.UI.Shared
DataModelVisualizationViewModel? child;
if (ListChildren.Count <= index)
{
child = CreateListChild(dataModelUIService, item.GetType());
child = CreateListChild(dataModelUIService, item.GetType(), DataModelPath?.GetPropertyDescription()?.ListItemName);
if (child == null)
continue;
ListChildren.Add(child);
@@ -130,18 +130,18 @@ namespace Artemis.UI.Shared
return $"[List] {DisplayPath ?? Path} - {ListCount} item(s)";
}
private DataModelVisualizationViewModel? CreateListChild(IDataModelUIService dataModelUIService, Type listType)
private DataModelVisualizationViewModel? CreateListChild(IDataModelUIService dataModelUIService, Type listType, string? name)
{
// If a display VM was found, prefer to use that in any case
DataModelDisplayViewModel? typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType, PropertyDescription);
if (typeViewModel != null)
return new DataModelListPropertyViewModel(listType, typeViewModel);
return new DataModelListPropertyViewModel(listType, typeViewModel, name);
// For primitives, create a property view model, it may be null that is fine
if (listType.IsPrimitive || listType.IsEnum || listType == typeof(string))
return new DataModelListPropertyViewModel(listType);
return new DataModelListPropertyViewModel(listType, name);
// For other value types create a child view model
if (listType.IsClass || listType.IsStruct())
return new DataModelListPropertiesViewModel(listType);
return new DataModelListPropertiesViewModel(listType, name);
return null;
}