mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
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:
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
|
||||
|
||||
+25
-6
@@ -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);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace Artemis.Core.Modules
|
||||
/// </summary>
|
||||
public string? Affix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of list items, only applicable to enumerable data model properties
|
||||
/// </summary>
|
||||
public string? ListItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional maximum value, this value is not enforced but used for percentage calculations.
|
||||
/// </summary>
|
||||
|
||||
@@ -69,6 +69,15 @@ namespace Artemis.Core.Modules
|
||||
return Module.HiddenProperties;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property description of the provided property info
|
||||
/// </summary>
|
||||
/// <returns>If found, the property description attribute, otherwise <see langword="null"/>.</returns>
|
||||
public virtual DataModelPropertyAttribute? GetPropertyDescription(PropertyInfo propertyInfo)
|
||||
{
|
||||
return (DataModelPropertyAttribute?) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute));
|
||||
}
|
||||
|
||||
#region Dynamic children
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace Artemis.Core.Services
|
||||
_pluginManagementService.PluginFeatureEnabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||
_pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||
|
||||
HotkeysEnabled = true;
|
||||
inputService.KeyboardKeyUp += InputServiceOnKeyboardKeyUp;
|
||||
|
||||
if (!_profileCategories.Any())
|
||||
|
||||
Reference in new issue
Block a user