mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile editor - Continue updating datamodel in editor
Display conditions - Added setting to display current values while selecting condition targets
This commit is contained in:
1 parent
35c46a4825
commit
f3cbd819f5
26 files changed
+382
-93
No files matched your search
@@ -25,6 +25,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
{
|
||||
Parent = parent;
|
||||
DisplayConditionPredicateEntity = entity;
|
||||
PredicateType = (PredicateType) entity.PredicateType;
|
||||
}
|
||||
|
||||
public DisplayConditionPredicateEntity DisplayConditionPredicateEntity { get; set; }
|
||||
@@ -124,6 +125,9 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
StaticConditionLambda = null;
|
||||
CompiledStaticConditionLambda = null;
|
||||
|
||||
if (Operator == null)
|
||||
return;
|
||||
|
||||
// If the operator does not support a right side, create a static expression because the right side will simply be null
|
||||
if (PredicateType == PredicateType.Dynamic && Operator.SupportsRightSide)
|
||||
CreateDynamicExpression();
|
||||
@@ -133,6 +137,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
DisplayConditionPredicateEntity.PredicateType = (int)PredicateType;
|
||||
DisplayConditionPredicateEntity.LeftDataModelGuid = LeftDataModel?.PluginInfo?.Guid;
|
||||
DisplayConditionPredicateEntity.LeftPropertyPath = LeftPropertyPath;
|
||||
|
||||
@@ -173,14 +178,14 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
}
|
||||
|
||||
// Right side dynamic
|
||||
if (DisplayConditionPredicateEntity.RightDataModelGuid != null)
|
||||
if (PredicateType == PredicateType.Dynamic && DisplayConditionPredicateEntity.RightDataModelGuid != null)
|
||||
{
|
||||
var dataModel = dataModelService.GetPluginDataModelByGuid(DisplayConditionPredicateEntity.RightDataModelGuid.Value);
|
||||
if (dataModel != null && dataModel.ContainsPath(DisplayConditionPredicateEntity.RightPropertyPath))
|
||||
UpdateRightSide(dataModel, DisplayConditionPredicateEntity.RightPropertyPath);
|
||||
}
|
||||
// Right side static
|
||||
else if (DisplayConditionPredicateEntity.RightStaticValue != null)
|
||||
else if (PredicateType == PredicateType.Static && DisplayConditionPredicateEntity.RightStaticValue != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -188,7 +193,20 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
{
|
||||
// Use the left side type so JSON.NET has a better idea what to do
|
||||
var leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath);
|
||||
UpdateRightSide(JsonConvert.DeserializeObject(DisplayConditionPredicateEntity.RightStaticValue, leftSideType));
|
||||
object rightSideValue;
|
||||
|
||||
try
|
||||
{
|
||||
rightSideValue = JsonConvert.DeserializeObject(DisplayConditionPredicateEntity.RightStaticValue, leftSideType);
|
||||
}
|
||||
// If deserialization fails, use the type's default
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
dataModelService.LogDeserializationFailure(this, e);
|
||||
rightSideValue = Activator.CreateInstance(leftSideType);
|
||||
}
|
||||
|
||||
UpdateRightSide(rightSideValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -265,7 +283,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
|
||||
private void CreateDynamicExpression()
|
||||
{
|
||||
if (LeftDataModel == null || RightDataModel == null)
|
||||
if (LeftDataModel == null || RightDataModel == null || Operator == null)
|
||||
return;
|
||||
|
||||
var leftSideParameter = Expression.Parameter(typeof(DataModel), "leftDataModel");
|
||||
@@ -306,8 +324,8 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
return;
|
||||
|
||||
// If the right side value is null, the constant type cannot be inferred and must be provided manually
|
||||
var rightSideConstant = RightStaticValue != null
|
||||
? Expression.Constant(RightStaticValue)
|
||||
var rightSideConstant = RightStaticValue != null
|
||||
? Expression.Constant(RightStaticValue)
|
||||
: Expression.Constant(null, leftSideAccessor.Type);
|
||||
|
||||
var conditionExpression = Operator.CreateExpression(leftSideAccessor, rightSideConstant);
|
||||
@@ -315,6 +333,13 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
StaticConditionLambda = Expression.Lambda<Func<DataModel, bool>>(conditionExpression, leftSideParameter);
|
||||
CompiledStaticConditionLambda = StaticConditionLambda.Compile();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (PredicateType == PredicateType.Dynamic)
|
||||
return $"[Dynamic] {LeftPropertyPath} {Operator.Description} {RightPropertyPath}";
|
||||
return $"[Static] {LeftPropertyPath} {Operator.Description} {RightStaticValue}";
|
||||
}
|
||||
}
|
||||
|
||||
public enum PredicateType
|
||||
|
||||
@@ -223,12 +223,14 @@ namespace Artemis.Core.Models.Profile
|
||||
// Ensure the layer must still be displayed
|
||||
UpdateDisplayCondition();
|
||||
|
||||
// TODO: No point updating further than this if the layer is not going to be rendered
|
||||
|
||||
// Update the layer timeline, this will give us a new delta time which could be negative in case the main segment wrapped back
|
||||
// to it's start
|
||||
UpdateTimeline(deltaTime);
|
||||
|
||||
// No point updating further than this if the layer is not going to be rendered
|
||||
if (TimelinePosition > TimelineLength)
|
||||
return;
|
||||
|
||||
General.Update();
|
||||
Transform.Update();
|
||||
LayerBrush.BaseProperties?.Update();
|
||||
@@ -285,7 +287,7 @@ namespace Artemis.Core.Models.Profile
|
||||
/// <inheritdoc />
|
||||
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||
{
|
||||
if (!Enabled)
|
||||
if (!Enabled || TimelinePosition > TimelineLength)
|
||||
return;
|
||||
|
||||
// Ensure the layer is ready
|
||||
|
||||
Reference in new issue
Block a user