Profile editor - Moved layer property input to the Shared UI project

This commit is contained in:
SpoinkyNL committed 2020-06-02 22:23:09 +02:00
1 parent eda57f6d32
commit 92faafe1de
71 files changed
+1211 -434

No files matched your search

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties
@@ -74,6 +75,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
public bool IsCoreProperty { get; internal set; }
public PropertyDescriptionAttribute PropertyDescription { get; internal set; }
/// <summary>
/// Gets a list of all the keyframes in their non-generic base form, without their values being available
/// </summary>
@@ -81,7 +84,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
/// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@@ -18,7 +18,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </para>
/// </summary>
/// <typeparam name="T">The type of property encapsulated in this layer property</typeparam>
public abstract class LayerProperty<T> : BaseLayerProperty
public class LayerProperty<T> : BaseLayerProperty
{
private T _baseValue;
private T _currentValue;
@@ -172,7 +172,10 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
/// <param name="keyframeProgress">The linear current keyframe progress</param>
/// <param name="keyframeProgressEased">The current keyframe progress, eased with the current easing function</param>
protected abstract void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased);
protected virtual void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new NotImplementedException();
}
/// <summary>
/// Updates the property, moving the timeline forwards by the provided <paramref name="deltaTime" />
@@ -51,6 +51,8 @@ namespace Artemis.Core.Models.Profile
/// </summary>
public bool IsCorePropertyGroup { get; internal set; }
public PropertyGroupDescriptionAttribute GroupDescription { get; internal set; }
/// <summary>
/// Gets or sets whether the property is hidden in the UI
/// </summary>
@@ -132,7 +134,9 @@ namespace Artemis.Core.Models.Profile
var instance = (BaseLayerProperty) Activator.CreateInstance(propertyInfo.PropertyType, true);
instance.Parent = this;
instance.PropertyDescription = (PropertyDescriptionAttribute)propertyDescription;
instance.Layer = layer;
InitializeProperty(layer, path + propertyInfo.Name, instance);
propertyInfo.SetValue(this, instance);
_layerProperties.Add(instance);
@@ -147,6 +151,7 @@ namespace Artemis.Core.Models.Profile
var instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType);
instance.Parent = this;
instance.GroupDescription = (PropertyGroupDescriptionAttribute)propertyGroupDescription;
instance.InitializeProperties(layerService, layer, $"{path}{propertyInfo.Name}.");
propertyInfo.SetValue(this, instance);
_layerPropertyGroups.Add(instance);
@@ -162,7 +167,7 @@ namespace Artemis.Core.Models.Profile
PropertiesInitialized = true;
OnPropertyGroupInitialized();
}
internal void ApplyToEntity()
{
if (!PropertiesInitialized)
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.IO;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Models;
@@ -44,12 +43,7 @@ namespace Artemis.Core.Plugins.Abstract
}
}
public override void Dispose()
{
// Does not happen with device providers, they require Artemis to restart
}
public override void DisablePlugin()
protected override void DisablePlugin()
{
// Does not happen with device providers, they require Artemis to restart
}
+57 -8
View File
@@ -17,30 +17,35 @@ namespace Artemis.Core.Plugins.Abstract
public PluginInfo PluginInfo { get; internal set; }
/// <summary>
/// Gets whether the plugin is enabled
/// </summary>
public bool Enabled { get; private set; }
/// <summary>
/// Gets or sets whether this plugin has a configuration view model.
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
/// </summary>
public bool HasConfigurationViewModel { get; protected set; }
/// <inheritdoc />
/// <summary>
/// Called when the plugin is unloaded, clean up any unmanaged resources here
/// </summary>
public abstract void Dispose();
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Called when the plugin is activated
/// </summary>
public abstract void EnablePlugin();
protected abstract void EnablePlugin();
/// <summary>
/// Called when the plugin is deactivated
/// </summary>
public abstract void DisablePlugin();
protected abstract void DisablePlugin();
/// <summary>
/// Called when the plugin's configuration window is opened from the UI. The UI will only attempt to open if
/// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if
/// <see cref="HasConfigurationViewModel" /> is set to True.
/// </summary>
/// <returns></returns>
@@ -48,5 +53,49 @@ namespace Artemis.Core.Plugins.Abstract
{
return null;
}
/// <summary>
/// Called when Artemis shuts down
/// </summary>
/// <param name="disposing"></param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
internal void SetEnabled(bool enable)
{
if (enable && !Enabled)
{
EnablePlugin();
OnPluginEnabled();
}
else if (!enable && Enabled)
{
DisablePlugin();
OnPluginDisabled();
}
Enabled = enable;
}
#region Events
public event EventHandler PluginEnabled;
public event EventHandler PluginDisabled;
protected virtual void OnPluginEnabled()
{
PluginEnabled?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnPluginDisabled()
{
PluginDisabled?.Invoke(this, EventArgs.Empty);
}
#endregion
}
}
@@ -15,11 +15,6 @@ namespace Artemis.Core.Plugins.Abstract
public Profile ActiveProfile { get; private set; }
public override void EnablePlugin()
{
throw new NotImplementedException();
}
/// <inheritdoc />
public override void Update(double deltaTime)
{
+4 -4
View File
@@ -167,7 +167,7 @@ namespace Artemis.Core.Services
var threwException = false;
try
{
pluginInfo.Instance.EnablePlugin();
pluginInfo.Instance.SetEnabled(true);
}
catch (Exception e)
{
@@ -289,7 +289,7 @@ namespace Artemis.Core.Services
{
try
{
pluginInfo.Instance.DisablePlugin();
pluginInfo.Instance.SetEnabled(false);
}
catch (Exception)
{
@@ -320,7 +320,7 @@ namespace Artemis.Core.Services
var threwException = false;
try
{
plugin.EnablePlugin();
plugin.SetEnabled(true);
}
catch (Exception e)
{
@@ -352,7 +352,7 @@ namespace Artemis.Core.Services
return;
}
plugin.DisablePlugin();
plugin.SetEnabled(false);
OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo));
}