1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profiles - Fix brush properties being carried over from previous brush

This commit is contained in:
Robert 2022-07-30 21:55:28 +02:00
parent 3625d1ad11
commit eec2419005
5 changed files with 18 additions and 8 deletions

View File

@ -793,8 +793,7 @@ namespace Artemis.Core
General.BrushReference.SetCurrentValue(layerBrush != null ? new LayerBrushReference(layerBrush.Descriptor) : null, null);
LayerBrush = layerBrush;
LayerEntity.LayerBrush = new LayerBrushEntity();
oldLayerBrush?.InternalDisable();
if (LayerBrush != null)

View File

@ -235,9 +235,20 @@ namespace Artemis.Core
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
string json = CoreJson.SerializeObject(DefaultValue, true);
if (DefaultValue == null)
return;
KeyframesEnabled = false;
SetCurrentValue(CoreJson.DeserializeObject<T>(json)!, null);
// For value types there's no need to make a copy
if (DefaultValue.GetType().IsValueType)
SetCurrentValue(DefaultValue);
// Reference types make a deep clone (ab)using JSON
else
{
string json = CoreJson.SerializeObject(DefaultValue, true);
SetCurrentValue(CoreJson.DeserializeObject<T>(json)!);
}
}
internal void ReapplyUpdate()

View File

@ -33,11 +33,11 @@ namespace Artemis.Core.LayerBrushes
internal set => _properties = value;
}
internal void InitializeProperties(PropertyGroupEntity? propertyGroupEntity)
internal void InitializeProperties()
{
Properties = new T();
PropertyGroupDescriptionAttribute groupDescription = new() {Identifier = "Brush", Name = Descriptor.DisplayName, Description = Descriptor.Description};
Properties.Initialize(Layer, null, groupDescription, propertyGroupEntity);
Properties.Initialize(Layer, null, groupDescription, LayerBrushEntity.PropertyGroup);
PropertiesInitialized = true;
}
}

View File

@ -33,7 +33,7 @@ namespace Artemis.Core.LayerBrushes
internal override void Initialize()
{
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
TryOrBreak(InitializeProperties, "Failed to initialize");
}
}
}

View File

@ -76,7 +76,7 @@ namespace Artemis.Core.LayerBrushes
internal override void Initialize()
{
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
TryOrBreak(InitializeProperties, "Failed to initialize");
}
}
}