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

@@ -1,4 +1,5 @@
using System;
using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile.Conditions;
@@ -69,7 +70,10 @@ namespace Artemis.Core
{
if (Entity.LeftPath != null)
LeftPath = DataModelConditionList.ListType != null
? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.LeftPath)
? new DataModelPath(ListPredicateWrapperDataModel.Create(
DataModelConditionList.ListType,
DataModelConditionList.ListPath?.GetPropertyDescription()?.ListItemName
), Entity.LeftPath)
: null;
}
@@ -82,7 +86,10 @@ namespace Artemis.Core
if (Entity.RightPath.WrapperType == PathWrapperType.List)
{
RightPath = DataModelConditionList.ListType != null
? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.RightPath)
? new DataModelPath(ListPredicateWrapperDataModel.Create(
DataModelConditionList.ListType,
DataModelConditionList.ListPath?.GetPropertyDescription()?.ListItemName
), Entity.RightPath)
: null;
}
// Right side dynamic
@@ -1,11 +1,11 @@
using System;
using System.Reflection;
using Artemis.Core.Modules;
namespace Artemis.Core
{
internal class ListPredicateWrapperDataModel<T> : ListPredicateWrapperDataModel
{
[DataModelProperty(Name = "List item", Description = "The current item in the list")]
public T Value => (UntypedValue is T typedValue ? typedValue : default)!;
}
@@ -26,15 +26,34 @@ namespace Artemis.Core
public object? UntypedValue { get; set; }
/// <summary>
/// Creates a new instance of the <see cref="ListPredicateWrapperDataModel"/> class
/// Gets or sets the name of the list item
/// </summary>
public static ListPredicateWrapperDataModel Create(Type type)
[DataModelIgnore]
public string? ItemName { get; set; }
#region Overrides of DataModel
/// <inheritdoc />
public override DataModelPropertyAttribute? GetPropertyDescription(PropertyInfo propertyInfo)
{
object? instance = Activator.CreateInstance(typeof(ListPredicateWrapperDataModel<>).MakeGenericType(type));
if (!string.IsNullOrWhiteSpace(ItemName))
return new DataModelPropertyAttribute {Name = ItemName};
return base.GetPropertyDescription(propertyInfo);
}
#endregion
/// <summary>
/// Creates a new instance of the <see cref="ListPredicateWrapperDataModel" /> class
/// </summary>
public static ListPredicateWrapperDataModel Create(Type type, string? name = null)
{
ListPredicateWrapperDataModel? instance = Activator.CreateInstance(typeof(ListPredicateWrapperDataModel<>).MakeGenericType(type)) as ListPredicateWrapperDataModel;
if (instance == null)
throw new ArtemisCoreException($"Failed to create an instance of ListPredicateWrapperDataModel<T> for type {type.Name}");
return (ListPredicateWrapperDataModel) instance;
instance.ItemName = name;
return instance;
}
}
}
@@ -122,7 +122,7 @@ namespace Artemis.Core
return null;
// Static types may have one as an attribute
DataModelPropertyAttribute? attribute = (DataModelPropertyAttribute?) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute));
DataModelPropertyAttribute? attribute = DataModelPath.Target?.GetPropertyDescription(propertyInfo);
if (attribute != null)
{
if (string.IsNullOrWhiteSpace(attribute.Name))
@@ -211,7 +211,7 @@ namespace Artemis.Core
// A static segment just needs to access the property or filed
else if (Type == DataModelPathSegmentType.Static)
{
accessorExpression = _property != null
accessorExpression = _property != null
? Expression.Property(expression, _property)
: Expression.PropertyOrField(expression, Identifier);
}