Profile editor - Finished most of the refactor except databindings

This commit is contained in:
SpoinkyNL committed 2020-09-14 01:24:07 +02:00
1 parent 7fff1a593f
commit fea454ad12
56 files changed
+866 -459

No files matched your search

@@ -61,5 +61,12 @@ namespace Artemis.Core.LayerBrushes
layer.LayerBrush = brush;
layer.OnLayerBrushUpdated();
}
public bool MatchesLayerBrushReference(LayerBrushReference reference)
{
if (reference == null)
return false;
return LayerBrushProvider.PluginInfo.Guid == reference.BrushPluginGuid && LayerBrushType.Name == reference.BrushType;
}
}
}
@@ -95,7 +95,7 @@ namespace Artemis.Core.LayerEffects
/// <summary>
/// Gets the plugin info that defined this effect
/// </summary>
public PluginInfo PluginInfo => Descriptor.LayerEffectProvider.PluginInfo;
public PluginInfo PluginInfo => Descriptor.LayerEffectProvider?.PluginInfo;
/// <summary>
/// Gets a reference to the layer property group without knowing it's type
@@ -108,7 +108,7 @@ namespace Artemis.Core.LayerEffects
public void Dispose()
{
DisableLayerEffect();
BaseProperties.Dispose();
BaseProperties?.Dispose();
}
/// <summary>
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Artemis.Core.LayerEffects.Placeholder;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile;
using Ninject;
@@ -47,9 +48,9 @@ namespace Artemis.Core.LayerEffects
public LayerEffectProvider LayerEffectProvider { get; }
/// <summary>
/// Gets a boolean indicating if this descriptor is a placeholder for a missing plugin
/// Gets the GUID this descriptor is acting as a placeholder for. If null, this descriptor is not a placeholder
/// </summary>
public bool IsPlaceHolder { get; internal set; }
public Guid? PlaceholderFor { get; internal set; }
/// <summary>
/// Creates an instance of the described effect and applies it to the render element
@@ -60,7 +61,7 @@ namespace Artemis.Core.LayerEffects
if (renderElement.LayerEffects.Any(e => e.EntityId == entity.Id))
return;
if (IsPlaceHolder)
if (PlaceholderFor != null)
{
CreatePlaceHolderInstance(renderElement, entity);
return;
@@ -82,7 +83,8 @@ namespace Artemis.Core.LayerEffects
private void CreatePlaceHolderInstance(RenderProfileElement renderElement, LayerEffectEntity entity)
{
var effect = new PlaceholderLayerEffect(entity) {ProfileElement = renderElement, Descriptor = this};
var effect = new PlaceholderLayerEffect(entity, PlaceholderFor.Value) {ProfileElement = renderElement, Descriptor = this};
effect.Initialize();
renderElement.ActivateLayerEffect(effect);
}
}
@@ -1,17 +1,19 @@
using Artemis.Storage.Entities.Profile;
using System;
using Artemis.Storage.Entities.Profile;
using SkiaSharp;
namespace Artemis.Core.LayerEffects
namespace Artemis.Core.LayerEffects.Placeholder
{
/// <summary>
/// Represents a layer effect that could not be loaded due to a missing plugin
/// </summary>
public class PlaceholderLayerEffect : BaseLayerEffect
internal class PlaceholderLayerEffect : LayerEffect<PlaceholderProperties>
{
internal PlaceholderLayerEffect(LayerEffectEntity originalEntity)
internal PlaceholderLayerEffect(LayerEffectEntity originalEntity, Guid placeholderFor)
{
OriginalEntity = originalEntity;
PlaceholderFor = placeholderFor;
EntityId = OriginalEntity.Id;
Order = OriginalEntity.Order;
Name = OriginalEntity.Name;
@@ -20,6 +22,7 @@ namespace Artemis.Core.LayerEffects
}
internal LayerEffectEntity OriginalEntity { get; }
public Guid PlaceholderFor { get; }
/// <inheritdoc />
public override void EnableLayerEffect()
@@ -50,8 +53,22 @@ namespace Artemis.Core.LayerEffects
{
return OriginalEntity.EffectType;
}
}
internal override void Initialize()
/// <summary>
/// This is in place so that the UI has something to show
/// </summary>
internal class PlaceholderProperties : LayerPropertyGroup
{
protected override void PopulateDefaults()
{
}
protected override void EnableProperties()
{
}
protected override void DisableProperties()
{
}
}
@@ -1,10 +1,16 @@
namespace Artemis.Core.LayerEffects.Placeholder
using System;
namespace Artemis.Core.LayerEffects.Placeholder
{
internal static class PlaceholderLayerEffectDescriptor
{
public static LayerEffectDescriptor Create()
public static LayerEffectDescriptor Create(Guid missingPluginGuid)
{
var descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, null) {IsPlaceHolder = true};
var descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin)
{
PlaceholderFor = missingPluginGuid
};
return descriptor;
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Artemis.Core
/// <summary>
/// Gets whether the plugin is enabled
/// </summary>
public bool Enabled { get; private set; }
public bool Enabled { get; internal set; }
/// <summary>
/// Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins