mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Profiles - Only load nodes after the entire profile structure loaded
Profiles - Added API to get all render elements Nodes - Added layer property node
This commit is contained in:
1 parent
836e979991
commit
a4667fdc03
11 files changed
+317
-57
No files matched your search
@@ -242,7 +242,11 @@ namespace Artemis.Core
|
||||
|
||||
EasingTime = Entity.EasingTime;
|
||||
EasingFunction = (Easings.Functions) Entity.EasingFunction;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void LoadNodeScript()
|
||||
{
|
||||
Script.Dispose();
|
||||
Script = Entity.NodeScript != null
|
||||
? new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", Entity.NodeScript, LayerProperty.ProfileElement.Profile)
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Artemis.Core
|
||||
DataBinding = new DataBinding<TLayerProperty, TProperty>(LayerProperty, dataBinding);
|
||||
return DataBinding;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ClearDataBinding()
|
||||
{
|
||||
|
||||
@@ -19,5 +19,10 @@ namespace Artemis.Core
|
||||
/// Applies the data binding to the layer property
|
||||
/// </summary>
|
||||
void Apply();
|
||||
|
||||
/// <summary>
|
||||
/// If the data binding is enabled, loads the node script for that data binding
|
||||
/// </summary>
|
||||
void LoadNodeScript();
|
||||
}
|
||||
}
|
||||
@@ -206,12 +206,10 @@ namespace Artemis.Core
|
||||
}
|
||||
}
|
||||
|
||||
List<RenderProfileElement> renderElements = GetAllRenderElements();
|
||||
|
||||
if (ProfileEntity.LastSelectedProfileElement != Guid.Empty)
|
||||
{
|
||||
LastSelectedProfileElement = GetAllFolders().FirstOrDefault(f => f.EntityId == ProfileEntity.LastSelectedProfileElement);
|
||||
if (LastSelectedProfileElement == null)
|
||||
LastSelectedProfileElement = GetAllLayers().FirstOrDefault(f => f.EntityId == ProfileEntity.LastSelectedProfileElement);
|
||||
}
|
||||
LastSelectedProfileElement = renderElements.FirstOrDefault(f => f.EntityId == ProfileEntity.LastSelectedProfileElement);
|
||||
else
|
||||
LastSelectedProfileElement = null;
|
||||
|
||||
@@ -219,6 +217,10 @@ namespace Artemis.Core
|
||||
scriptConfiguration.Script?.Dispose();
|
||||
ScriptConfigurations.Clear();
|
||||
ScriptConfigurations.AddRange(ProfileEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
|
||||
|
||||
// Load node scripts last since they may rely on the profile structure being in place
|
||||
foreach (RenderProfileElement renderProfileElement in renderElements)
|
||||
renderProfileElement.LoadNodeScript();
|
||||
}
|
||||
|
||||
internal override void Save()
|
||||
@@ -253,10 +255,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IBreakableModel> GetBrokenHierarchy()
|
||||
{
|
||||
foreach (IBreakableModel breakableModel in GetAllFolders().SelectMany(folders => folders.GetBrokenHierarchy()))
|
||||
yield return breakableModel;
|
||||
foreach (IBreakableModel breakableModel in GetAllLayers().SelectMany(layer => layer.GetBrokenHierarchy()))
|
||||
yield return breakableModel;
|
||||
return GetAllRenderElements().SelectMany(folders => folders.GetBrokenHierarchy());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -99,6 +99,13 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public bool Disposed { get; protected set; }
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BrokenDisplayName => Name ?? GetType().Name;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Updates the element
|
||||
/// </summary>
|
||||
@@ -121,13 +128,6 @@ namespace Artemis.Core
|
||||
return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}";
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BrokenDisplayName => Name ?? GetType().Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hierarchy
|
||||
|
||||
/// <summary>
|
||||
@@ -147,7 +147,9 @@ namespace Artemis.Core
|
||||
|
||||
// Add to the end of the list
|
||||
if (order == null)
|
||||
{
|
||||
ChildrenList.Add(child);
|
||||
}
|
||||
// Insert at the given index
|
||||
else
|
||||
{
|
||||
@@ -191,6 +193,27 @@ namespace Artemis.Core
|
||||
ChildrenList[index].Order = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a flattened list of all child render elements
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RenderProfileElement> GetAllRenderElements()
|
||||
{
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<RenderProfileElement> elements = new();
|
||||
foreach (RenderProfileElement childElement in Children.Where(c => c is RenderProfileElement).Cast<RenderProfileElement>())
|
||||
{
|
||||
// Add all folders in this element
|
||||
elements.Add(childElement);
|
||||
// Add all folders in folders inside this element
|
||||
elements.AddRange(childElement.GetAllRenderElements());
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a flattened list of all child folders
|
||||
/// </summary>
|
||||
@@ -240,27 +263,6 @@ namespace Artemis.Core
|
||||
internal abstract void Load();
|
||||
internal abstract void Save();
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the profile element
|
||||
/// </summary>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
@@ -292,5 +294,26 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the profile element
|
||||
/// </summary>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -70,10 +70,6 @@ namespace Artemis.Core
|
||||
|
||||
internal void LoadRenderElement()
|
||||
{
|
||||
DisplayCondition = RenderElementEntity.NodeScript != null
|
||||
? new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", RenderElementEntity.NodeScript, Profile)
|
||||
: new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", Profile);
|
||||
|
||||
Timeline = RenderElementEntity.Timeline != null
|
||||
? new Timeline(RenderElementEntity.Timeline)
|
||||
: new Timeline();
|
||||
@@ -111,6 +107,19 @@ namespace Artemis.Core
|
||||
Timeline?.Save();
|
||||
}
|
||||
|
||||
internal void LoadNodeScript()
|
||||
{
|
||||
DisplayCondition = RenderElementEntity.NodeScript != null
|
||||
? new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", RenderElementEntity.NodeScript, Profile)
|
||||
: new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", Profile);
|
||||
|
||||
foreach (ILayerProperty layerProperty in GetAllLayerProperties())
|
||||
{
|
||||
foreach (IDataBindingRegistration dataBindingRegistration in layerProperty.GetAllDataBindingRegistrations())
|
||||
dataBindingRegistration.GetDataBinding()?.LoadNodeScript();
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnLayerEffectsUpdated()
|
||||
{
|
||||
LayerEffectsUpdated?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Reference in new issue
Block a user