mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Removed seperate plugins project since you're always referencing both..
Added more loading logic
This commit is contained in:
1 parent
3db4aab8bc
commit
c22a78cd30
57 files changed
+959
-650
No files matched your search
@@ -1,23 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.ProfileElements
|
||||
{
|
||||
public class Folder : IProfileElement
|
||||
{
|
||||
public Folder()
|
||||
{
|
||||
Children = new List<IProfileElement>();
|
||||
}
|
||||
|
||||
public List<IProfileElement> Children { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// Folders don't update but their children do
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Update();
|
||||
}
|
||||
|
||||
public void Render(IRGBDevice rgbDevice)
|
||||
{
|
||||
// Folders don't render but their children do
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Render(rgbDevice);
|
||||
}
|
||||
|
||||
public static Folder FromFolderEntity(FolderEntity folderEntity, IPluginService pluginService)
|
||||
{
|
||||
var folder = new Folder
|
||||
{
|
||||
Name = folderEntity.Name,
|
||||
Order = folderEntity.Order
|
||||
};
|
||||
|
||||
// Load child folders
|
||||
foreach (var childFolder in folderEntity.Folders)
|
||||
folder.Children.Add(FromFolderEntity(childFolder, pluginService));
|
||||
// Load child layers
|
||||
foreach (var childLayer in folderEntity.Layers)
|
||||
folder.Children.Add(Layer.FromLayerEntity(childLayer, pluginService));
|
||||
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,16 @@ namespace Artemis.Core.ProfileElements.Interfaces
|
||||
/// </summary>
|
||||
List<IProfileElement> Children { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The order in which this element appears in the update loop and editor
|
||||
/// </summary>
|
||||
int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name which appears in the editor
|
||||
/// </summary>
|
||||
string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates the element
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.ProfileElements
|
||||
{
|
||||
public class Layer : IProfileElement
|
||||
{
|
||||
public Layer()
|
||||
{
|
||||
Children = new List<IProfileElement>();
|
||||
}
|
||||
|
||||
public ILayerType LayerType { get; private set; }
|
||||
|
||||
public List<IProfileElement> Children { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (LayerType == null)
|
||||
return;
|
||||
|
||||
lock (LayerType)
|
||||
{
|
||||
LayerType.Update(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(IRGBDevice rgbDevice)
|
||||
{
|
||||
if (LayerType == null)
|
||||
return;
|
||||
|
||||
lock (LayerType)
|
||||
{
|
||||
LayerType.Render(this, rgbDevice);
|
||||
}
|
||||
}
|
||||
|
||||
public static Layer FromLayerEntity(LayerEntity layerEntity, IPluginService pluginService)
|
||||
{
|
||||
var layer = new Layer
|
||||
{
|
||||
Name = layerEntity.Name,
|
||||
Order = layerEntity.Order,
|
||||
LayerType = pluginService.GetLayerTypeByGuid(Guid.Parse(layerEntity.Guid))
|
||||
};
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void UpdateLayerType(ILayerType layerType)
|
||||
{
|
||||
if (LayerType != null)
|
||||
{
|
||||
lock (LayerType)
|
||||
{
|
||||
LayerType.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
LayerType = layerType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.ProfileElements
|
||||
{
|
||||
public class Profile : IProfileElement
|
||||
{
|
||||
private Profile(PluginInfo pluginInfo)
|
||||
{
|
||||
PluginInfo = pluginInfo;
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public PluginInfo PluginInfo { get; }
|
||||
public List<IProfileElement> Children { get; set; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Update();
|
||||
}
|
||||
|
||||
public void Render(IRGBDevice rgbDevice)
|
||||
@@ -17,5 +30,15 @@ namespace Artemis.Core.ProfileElements
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Render(rgbDevice);
|
||||
}
|
||||
|
||||
public static Profile FromProfileEntity(PluginInfo pluginInfo, ProfileEntity profileEntity, IPluginService pluginService)
|
||||
{
|
||||
var profile = new Profile(pluginInfo) {Name = profileEntity.Name};
|
||||
|
||||
// Populate the profile starting at the root, the rest is populated recursively
|
||||
profile.Children.Add(Folder.FromFolderEntity(profileEntity.RootFolder, pluginService));
|
||||
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user