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:
parent
3625d1ad11
commit
eec2419005
@ -793,8 +793,7 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
General.BrushReference.SetCurrentValue(layerBrush != null ? new LayerBrushReference(layerBrush.Descriptor) : null, null);
|
General.BrushReference.SetCurrentValue(layerBrush != null ? new LayerBrushReference(layerBrush.Descriptor) : null, null);
|
||||||
LayerBrush = layerBrush;
|
LayerBrush = layerBrush;
|
||||||
LayerEntity.LayerBrush = new LayerBrushEntity();
|
|
||||||
|
|
||||||
oldLayerBrush?.InternalDisable();
|
oldLayerBrush?.InternalDisable();
|
||||||
|
|
||||||
if (LayerBrush != null)
|
if (LayerBrush != null)
|
||||||
|
|||||||
@ -235,9 +235,20 @@ namespace Artemis.Core
|
|||||||
if (_disposed)
|
if (_disposed)
|
||||||
throw new ObjectDisposedException("LayerProperty");
|
throw new ObjectDisposedException("LayerProperty");
|
||||||
|
|
||||||
string json = CoreJson.SerializeObject(DefaultValue, true);
|
if (DefaultValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
KeyframesEnabled = false;
|
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()
|
internal void ReapplyUpdate()
|
||||||
|
|||||||
@ -33,11 +33,11 @@ namespace Artemis.Core.LayerBrushes
|
|||||||
internal set => _properties = value;
|
internal set => _properties = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void InitializeProperties(PropertyGroupEntity? propertyGroupEntity)
|
internal void InitializeProperties()
|
||||||
{
|
{
|
||||||
Properties = new T();
|
Properties = new T();
|
||||||
PropertyGroupDescriptionAttribute groupDescription = new() {Identifier = "Brush", Name = Descriptor.DisplayName, Description = Descriptor.Description};
|
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;
|
PropertiesInitialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace Artemis.Core.LayerBrushes
|
|||||||
|
|
||||||
internal override void Initialize()
|
internal override void Initialize()
|
||||||
{
|
{
|
||||||
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
|
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ namespace Artemis.Core.LayerBrushes
|
|||||||
|
|
||||||
internal override void Initialize()
|
internal override void Initialize()
|
||||||
{
|
{
|
||||||
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
|
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user