mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Merge branch 'development' into feature/cpm
This commit is contained in:
commit
d0e354952d
235 files changed
+645
-6611
No files matched your search
@@ -3,10 +3,12 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<PreserveCompilationContext>false</PreserveCompilationContext>
|
||||
<Platforms>x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiteDB" />
|
||||
<PackageReference Include="Serilog" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -11,7 +11,7 @@ public class QueuedActionEntity
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
public Dictionary<string, object> Parameters { get; set; }
|
||||
|
||||
@@ -6,6 +6,6 @@ public class ReleaseEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
public string Version { get; set; } = string.Empty;
|
||||
public DateTimeOffset? InstalledAt { get; set; }
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public class ScriptConfigurationEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string ScriptingProviderId { get; set; }
|
||||
public string ScriptContent { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string ScriptingProviderId { get; set; } = string.Empty;
|
||||
public string? ScriptContent { get; set; }
|
||||
}
|
||||
@@ -24,6 +24,6 @@ public class PluginEntity
|
||||
/// </summary>
|
||||
public class PluginFeatureEntity
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
@@ -10,6 +10,6 @@ public class PluginSettingEntity
|
||||
public Guid Id { get; set; }
|
||||
public Guid PluginGuid { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
public abstract class DataModelConditionPartEntity
|
||||
{
|
||||
public List<DataModelConditionPartEntity> Children { get; set; }
|
||||
}
|
||||
@@ -8,8 +8,8 @@ public abstract class RenderElementEntity
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; }
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; } = new();
|
||||
|
||||
public IConditionEntity DisplayCondition { get; set; }
|
||||
public TimelineEntity Timeline { get; set; }
|
||||
public IConditionEntity? DisplayCondition { get; set; }
|
||||
public TimelineEntity? Timeline { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
|
||||
public interface IAdaptionHintEntity
|
||||
{
|
||||
}
|
||||
public interface IAdaptionHintEntity;
|
||||
@@ -2,6 +2,4 @@
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class AlwaysOnConditionEntity : IConditionEntity
|
||||
{
|
||||
}
|
||||
public class AlwaysOnConditionEntity : IConditionEntity;
|
||||
@@ -8,6 +8,6 @@ public class EventConditionEntity : IConditionEntity
|
||||
public int TriggerMode { get; set; }
|
||||
public int OverlapMode { get; set; }
|
||||
public int ToggleOffMode { get; set; }
|
||||
public DataModelPathEntity EventPath { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
public DataModelPathEntity? EventPath { get; set; }
|
||||
public NodeScriptEntity? Script { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
public interface IConditionEntity
|
||||
{
|
||||
}
|
||||
public interface IConditionEntity;
|
||||
@@ -2,6 +2,4 @@
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class PlayOnceConditionEntity : IConditionEntity
|
||||
{
|
||||
}
|
||||
public class PlayOnceConditionEntity : IConditionEntity;
|
||||
@@ -7,5 +7,5 @@ public class StaticConditionEntity : IConditionEntity
|
||||
{
|
||||
public int PlayMode { get; set; }
|
||||
public int StopMode { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
public NodeScriptEntity? Script { get; set; }
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace Artemis.Storage.Entities.Profile.DataBindings;
|
||||
|
||||
public class DataBindingEntity
|
||||
{
|
||||
public string Identifier { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public NodeScriptEntity NodeScript { get; set; }
|
||||
public NodeScriptEntity? NodeScript { get; set; }
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public class DataModelPathEntity
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string DataModelId { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Path { get; set; } = string.Empty;
|
||||
public string? DataModelId { get; set; }
|
||||
public string? Type { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using LiteDB;
|
||||
|
||||
@@ -7,18 +6,13 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class FolderEntity : RenderElementEntity
|
||||
{
|
||||
public FolderEntity()
|
||||
{
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsExpanded { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
public ProfileEntity Profile { get; set; } = null!;
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
@@ -6,6 +6,6 @@ public class KeyframeEntity
|
||||
{
|
||||
public TimeSpan Position { get; set; }
|
||||
public int Timeline { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public int EasingFunction { get; set; }
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
public class LayerBrushEntity
|
||||
{
|
||||
public string ProviderId { get; set; }
|
||||
public string BrushType { get; set; }
|
||||
public string ProviderId { get; set; } = string.Empty;
|
||||
public string BrushType { get; set; } = string.Empty;
|
||||
|
||||
public PropertyGroupEntity PropertyGroup { get; set; }
|
||||
public PropertyGroupEntity? PropertyGroup { get; set; }
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
public class LayerEffectEntity
|
||||
{
|
||||
public string ProviderId { get; set; }
|
||||
public string EffectType { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ProviderId { get; set; } = string.Empty;
|
||||
public string EffectType { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool HasBeenRenamed { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public PropertyGroupEntity PropertyGroup { get; set; }
|
||||
public PropertyGroupEntity? PropertyGroup { get; set; }
|
||||
}
|
||||
@@ -12,22 +12,21 @@ public class LayerEntity : RenderElementEntity
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
public List<LedEntity> Leds { get; set; }
|
||||
public List<IAdaptionHintEntity> AdaptionHints { get; set; }
|
||||
|
||||
public PropertyGroupEntity GeneralPropertyGroup { get; set; }
|
||||
public PropertyGroupEntity TransformPropertyGroup { get; set; }
|
||||
public LayerBrushEntity LayerBrush { get; set; }
|
||||
public PropertyGroupEntity? GeneralPropertyGroup { get; set; }
|
||||
public PropertyGroupEntity? TransformPropertyGroup { get; set; }
|
||||
public LayerBrushEntity? LayerBrush { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
public ProfileEntity Profile { get; set; } = null!;
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class LedEntity
|
||||
{
|
||||
public string LedName { get; set; }
|
||||
public string DeviceIdentifier { get; set; }
|
||||
public string LedName { get; set; } = string.Empty;
|
||||
public string DeviceIdentifier { get; set; } = string.Empty;
|
||||
|
||||
public int? PhysicalLayout { get; set; }
|
||||
|
||||
@@ -14,7 +14,7 @@ public class LedEntity
|
||||
|
||||
private sealed class LedEntityEqualityComparer : IEqualityComparer<LedEntity>
|
||||
{
|
||||
public bool Equals(LedEntity x, LedEntity y)
|
||||
public bool Equals(LedEntity? x, LedEntity? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
return true;
|
||||
|
||||
@@ -20,12 +20,12 @@ public class NodeConnectionEntity
|
||||
TargetPinId = nodeConnectionEntity.TargetPinId;
|
||||
}
|
||||
|
||||
public string SourceType { get; set; }
|
||||
public string SourceType { get; set; } = string.Empty;
|
||||
public Guid SourceNode { get; set; }
|
||||
public Guid TargetNode { get; set; }
|
||||
public int SourcePinCollectionId { get; set; }
|
||||
public int SourcePinId { get; set; }
|
||||
public string TargetType { get; set; }
|
||||
public string TargetType { get; set; } = string.Empty;
|
||||
public int TargetPinCollectionId { get; set; }
|
||||
public int TargetPinId { get; set; }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class NodeEntity
|
||||
{
|
||||
Id = nodeEntity.Id;
|
||||
Type = nodeEntity.Type;
|
||||
PluginId = nodeEntity.PluginId;
|
||||
ProviderId = nodeEntity.ProviderId;
|
||||
|
||||
Name = nodeEntity.Name;
|
||||
Description = nodeEntity.Description;
|
||||
@@ -28,15 +28,15 @@ public class NodeEntity
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public Guid PluginId { get; set; }
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public string ProviderId { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsExitNode { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public string Storage { get; set; }
|
||||
public string Storage { get; set; } = string.Empty;
|
||||
|
||||
public List<NodePinCollectionEntity> PinCollections { get; set; }
|
||||
}
|
||||
@@ -10,8 +10,8 @@ public class NodeScriptEntity
|
||||
Connections = new List<NodeConnectionEntity>();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public List<NodeEntity> Nodes { get; set; }
|
||||
public List<NodeConnectionEntity> Connections { get; set; }
|
||||
|
||||
@@ -7,7 +7,7 @@ public class ProfileCategoryEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsCollapsed { get; set; }
|
||||
public bool IsSuspended { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class ProfileConfigurationEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string MaterialIcon { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? MaterialIcon { get; set; }
|
||||
public Guid FileIconId { get; set; }
|
||||
public int IconType { get; set; }
|
||||
public bool IconFill { get; set; }
|
||||
@@ -14,16 +14,17 @@ public class ProfileConfigurationEntity
|
||||
|
||||
public bool IsSuspended { get; set; }
|
||||
public int ActivationBehaviour { get; set; }
|
||||
public NodeScriptEntity ActivationCondition { get; set; }
|
||||
public NodeScriptEntity? ActivationCondition { get; set; }
|
||||
|
||||
public int HotkeyMode { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity EnableHotkey { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity DisableHotkey { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity? EnableHotkey { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity? DisableHotkey { get; set; }
|
||||
|
||||
public string ModuleId { get; set; }
|
||||
public string? ModuleId { get; set; }
|
||||
|
||||
public Guid ProfileCategoryId { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
|
||||
public bool FadeInAndOut { get; set; }
|
||||
public int Version { get; set; }
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class ProfileEntity
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsFreshImport { get; set; }
|
||||
|
||||
public List<FolderEntity> Folders { get; set; }
|
||||
@@ -28,7 +28,7 @@ public class ProfileEntity
|
||||
Guid oldGuid = Id;
|
||||
Id = guid;
|
||||
|
||||
FolderEntity rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid);
|
||||
FolderEntity? rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid);
|
||||
if (rootFolder != null)
|
||||
rootFolder.ParentId = Id;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class PropertyEntity
|
||||
{
|
||||
public string Identifier { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Identifier { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public bool KeyframesEnabled { get; set; }
|
||||
|
||||
public DataBindingEntity DataBinding { get; set; }
|
||||
public DataBindingEntity? DataBinding { get; set; }
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; } = new();
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class PropertyGroupEntity
|
||||
{
|
||||
public string Identifier { get; set; }
|
||||
public string Identifier { get; set; } = string.Empty;
|
||||
public List<PropertyEntity> Properties { get; set; } = new();
|
||||
public List<PropertyGroupEntity> PropertyGroups { get; set; } = new();
|
||||
}
|
||||
@@ -11,8 +11,8 @@ public class DeviceEntity
|
||||
Categories = new List<int>();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string DeviceProvider { get; set; }
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string DeviceProvider { get; set; } = string.Empty;
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Rotation { get; set; }
|
||||
@@ -24,9 +24,9 @@ public class DeviceEntity
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public int PhysicalLayout { get; set; }
|
||||
public string LogicalLayout { get; set; }
|
||||
public string LayoutType { get; set; }
|
||||
public string LayoutParameter { get; set; }
|
||||
public string? LogicalLayout { get; set; }
|
||||
public string? LayoutType { get; set; }
|
||||
public string? LayoutParameter { get; set; }
|
||||
|
||||
public List<DeviceInputIdentifierEntity> InputIdentifiers { get; set; }
|
||||
public List<InputMappingEntity> InputMappings { get; set; }
|
||||
@@ -41,6 +41,6 @@ public class InputMappingEntity
|
||||
|
||||
public class DeviceInputIdentifierEntity
|
||||
{
|
||||
public string InputProvider { get; set; }
|
||||
public object Identifier { get; set; }
|
||||
public string InputProvider { get; set; } = string.Empty;
|
||||
public object Identifier { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -10,13 +10,12 @@ public class EntryEntity
|
||||
public long EntryId { get; set; }
|
||||
public int EntryType { get; set; }
|
||||
|
||||
public string Author { get; set; }
|
||||
public string Author { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Summary { get; set; } = string.Empty;
|
||||
|
||||
public long ReleaseId { get; set; }
|
||||
public string ReleaseVersion { get; set; }
|
||||
public string ReleaseVersion { get; set; } = string.Empty;
|
||||
public DateTimeOffset InstalledAt { get; set; }
|
||||
|
||||
public Dictionary<string,object> Metadata { get; set; }
|
||||
public Dictionary<string,object>? Metadata { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
|
||||
public interface IProfileMigration
|
||||
{
|
||||
int Version { get; }
|
||||
void Migrate(JObject profileJson);
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations.Interfaces;
|
||||
namespace Artemis.Storage.Migrations;
|
||||
|
||||
public interface IStorageMigration
|
||||
{
|
||||
@@ -0,0 +1,88 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Artemis.Storage.Migrations.Profile;
|
||||
|
||||
/// <summary>
|
||||
/// Migrates nodes to be provider-based.
|
||||
/// This requires giving them a ProviderId and updating the their namespaces to match the namespace of the new plugin.
|
||||
/// </summary>
|
||||
internal class M0001NodeProviders : IProfileMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public int Version => 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Migrate(JObject profileJson)
|
||||
{
|
||||
JArray? folders = (JArray?) profileJson["Folders"]?["$values"];
|
||||
JArray? layers = (JArray?) profileJson["Layers"]?["$values"];
|
||||
|
||||
if (folders != null)
|
||||
{
|
||||
foreach (JToken folder in folders)
|
||||
MigrateProfileElement(folder);
|
||||
}
|
||||
|
||||
if (layers != null)
|
||||
{
|
||||
foreach (JToken layer in layers)
|
||||
{
|
||||
MigrateProfileElement(layer);
|
||||
MigratePropertyGroup(layer["GeneralPropertyGroup"]);
|
||||
MigratePropertyGroup(layer["TransformPropertyGroup"]);
|
||||
MigratePropertyGroup(layer["LayerBrush"]?["PropertyGroup"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MigrateProfileElement(JToken profileElement)
|
||||
{
|
||||
JArray? layerEffects = (JArray?) profileElement["LayerEffects"]?["$values"];
|
||||
if (layerEffects != null)
|
||||
{
|
||||
foreach (JToken layerEffect in layerEffects)
|
||||
MigratePropertyGroup(layerEffect["PropertyGroup"]);
|
||||
}
|
||||
|
||||
JToken? displayCondition = profileElement["DisplayCondition"];
|
||||
if (displayCondition != null)
|
||||
MigrateNodeScript(displayCondition["Script"]);
|
||||
}
|
||||
|
||||
private void MigratePropertyGroup(JToken? propertyGroup)
|
||||
{
|
||||
if (propertyGroup == null || !propertyGroup.HasValues)
|
||||
return;
|
||||
|
||||
JArray? properties = (JArray?) propertyGroup["Properties"]?["$values"];
|
||||
JArray? propertyGroups = (JArray?) propertyGroup["PropertyGroups"]?["$values"];
|
||||
|
||||
if (properties != null)
|
||||
{
|
||||
foreach (JToken property in properties)
|
||||
MigrateNodeScript(property["DataBinding"]?["NodeScript"]);
|
||||
}
|
||||
|
||||
if (propertyGroups != null)
|
||||
{
|
||||
foreach (JToken childPropertyGroup in propertyGroups)
|
||||
MigratePropertyGroup(childPropertyGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void MigrateNodeScript(JToken? nodeScript)
|
||||
{
|
||||
if (nodeScript == null || !nodeScript.HasValues)
|
||||
return;
|
||||
|
||||
JArray? nodes = (JArray?) nodeScript["Nodes"]?["$values"];
|
||||
if (nodes == null)
|
||||
return;
|
||||
|
||||
foreach (JToken node in nodes)
|
||||
{
|
||||
node["Type"] = node["Type"]?.Value<string>()?.Replace("Artemis.VisualScripting.Nodes", "Artemis.Plugins.Nodes.General.Nodes");
|
||||
node["ProviderId"] = "Artemis.Plugins.Nodes.General.GeneralNodesProvider-d9e1ee78";
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
namespace Artemis.Storage.Migrations.Storage;
|
||||
|
||||
public class M0020AvaloniaReset : IStorageMigration
|
||||
{
|
||||
+10
-8
@@ -3,18 +3,17 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
namespace Artemis.Storage.Migrations.Storage;
|
||||
|
||||
public class M0021GradientNodes : IStorageMigration
|
||||
{
|
||||
private void MigrateDataBinding(PropertyEntity property)
|
||||
{
|
||||
NodeScriptEntity script = property.DataBinding.NodeScript;
|
||||
NodeEntity exitNode = script.Nodes.FirstOrDefault(s => s.IsExitNode);
|
||||
if (exitNode == null)
|
||||
NodeScriptEntity? script = property.DataBinding?.NodeScript;
|
||||
NodeEntity? exitNode = script?.Nodes.FirstOrDefault(s => s.IsExitNode);
|
||||
if (script == null || exitNode == null)
|
||||
return;
|
||||
|
||||
// Create a new node at the same position of the exit node
|
||||
@@ -22,7 +21,7 @@ public class M0021GradientNodes : IStorageMigration
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Type = "ColorGradientNode",
|
||||
PluginId = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"),
|
||||
ProviderId = "Artemis.Plugins.Nodes.General.GeneralNodesProvider-d9e1ee78",
|
||||
Name = "Color Gradient",
|
||||
Description = "Outputs a color gradient with the given colors",
|
||||
X = exitNode.X,
|
||||
@@ -59,8 +58,11 @@ public class M0021GradientNodes : IStorageMigration
|
||||
exitNode.Y += 30;
|
||||
}
|
||||
|
||||
private void MigrateDataBinding(PropertyGroupEntity propertyGroup)
|
||||
private void MigrateDataBinding(PropertyGroupEntity? propertyGroup)
|
||||
{
|
||||
if (propertyGroup == null)
|
||||
return;
|
||||
|
||||
foreach (PropertyGroupEntity propertyGroupPropertyGroup in propertyGroup.PropertyGroups)
|
||||
MigrateDataBinding(propertyGroupPropertyGroup);
|
||||
|
||||
@@ -80,7 +82,7 @@ public class M0021GradientNodes : IStorageMigration
|
||||
foreach (ProfileEntity profileEntity in profiles)
|
||||
{
|
||||
foreach (LayerEntity layer in profileEntity.Layers.Where(le => le.LayerBrush != null))
|
||||
MigrateDataBinding(layer.LayerBrush.PropertyGroup);
|
||||
MigrateDataBinding(layer.LayerBrush?.PropertyGroup);
|
||||
|
||||
repository.Update(profileEntity);
|
||||
}
|
||||
+6
-7
@@ -3,14 +3,13 @@ using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Conditions;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
namespace Artemis.Storage.Migrations.Storage;
|
||||
|
||||
public class M0022TransitionNodes : IStorageMigration
|
||||
{
|
||||
private void MigrateNodeScript(NodeScriptEntity nodeScript)
|
||||
private void MigrateNodeScript(NodeScriptEntity? nodeScript)
|
||||
{
|
||||
if (nodeScript == null)
|
||||
return;
|
||||
@@ -28,7 +27,7 @@ public class M0022TransitionNodes : IStorageMigration
|
||||
}
|
||||
}
|
||||
|
||||
private void MigratePropertyGroup(PropertyGroupEntity propertyGroup)
|
||||
private void MigratePropertyGroup(PropertyGroupEntity? propertyGroup)
|
||||
{
|
||||
if (propertyGroup == null)
|
||||
return;
|
||||
@@ -39,7 +38,7 @@ public class M0022TransitionNodes : IStorageMigration
|
||||
MigrateNodeScript(property.DataBinding?.NodeScript);
|
||||
}
|
||||
|
||||
private void MigrateDisplayCondition(IConditionEntity conditionEntity)
|
||||
private void MigrateDisplayCondition(IConditionEntity? conditionEntity)
|
||||
{
|
||||
if (conditionEntity is EventConditionEntity eventConditionEntity)
|
||||
MigrateNodeScript(eventConditionEntity.Script);
|
||||
@@ -70,14 +69,14 @@ public class M0022TransitionNodes : IStorageMigration
|
||||
MigratePropertyGroup(layer.GeneralPropertyGroup);
|
||||
MigratePropertyGroup(layer.TransformPropertyGroup);
|
||||
foreach (LayerEffectEntity layerEffectEntity in layer.LayerEffects)
|
||||
MigratePropertyGroup(layerEffectEntity?.PropertyGroup);
|
||||
MigratePropertyGroup(layerEffectEntity.PropertyGroup);
|
||||
MigrateDisplayCondition(layer.DisplayCondition);
|
||||
}
|
||||
|
||||
foreach (FolderEntity folder in profileEntity.Folders)
|
||||
{
|
||||
foreach (LayerEffectEntity folderLayerEffect in folder.LayerEffects)
|
||||
MigratePropertyGroup(folderLayerEffect?.PropertyGroup);
|
||||
MigratePropertyGroup(folderLayerEffect.PropertyGroup);
|
||||
MigrateDisplayCondition(folder.DisplayCondition);
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
namespace Artemis.Storage.Migrations.Storage;
|
||||
|
||||
public class M0023LayoutProviders : IStorageMigration
|
||||
{
|
||||
@@ -0,0 +1,100 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations.Storage;
|
||||
|
||||
public class M0024NodeProviders : IStorageMigration
|
||||
{
|
||||
public int UserVersion => 24;
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
List<ProfileCategoryEntity> profileCategories = repository.Query<ProfileCategoryEntity>().ToList();
|
||||
foreach (ProfileCategoryEntity profileCategory in profileCategories)
|
||||
{
|
||||
foreach (ProfileConfigurationEntity profileConfigurationEntity in profileCategory.ProfileConfigurations)
|
||||
{
|
||||
profileConfigurationEntity.Version = 1;
|
||||
}
|
||||
repository.Update(profileCategory);
|
||||
}
|
||||
|
||||
ILiteCollection<BsonDocument> collection = repository.Database.GetCollection("ProfileEntity");
|
||||
foreach (BsonDocument profileBson in collection.FindAll())
|
||||
{
|
||||
BsonArray? folders = profileBson["Folders"]?.AsArray;
|
||||
BsonArray? layers = profileBson["Layers"]?.AsArray;
|
||||
|
||||
if (folders != null)
|
||||
{
|
||||
foreach (BsonValue folder in folders)
|
||||
MigrateProfileElement(folder.AsDocument);
|
||||
}
|
||||
|
||||
if (layers != null)
|
||||
{
|
||||
foreach (BsonValue layer in layers)
|
||||
{
|
||||
MigrateProfileElement(layer.AsDocument);
|
||||
MigratePropertyGroup(layer.AsDocument["GeneralPropertyGroup"].AsDocument);
|
||||
MigratePropertyGroup(layer.AsDocument["TransformPropertyGroup"].AsDocument);
|
||||
MigratePropertyGroup(layer.AsDocument["LayerBrush"]?["PropertyGroup"].AsDocument);
|
||||
}
|
||||
}
|
||||
|
||||
collection.Update(profileBson);
|
||||
}
|
||||
}
|
||||
|
||||
private void MigrateProfileElement(BsonDocument profileElement)
|
||||
{
|
||||
BsonArray? layerEffects = profileElement["LayerEffects"]?.AsArray;
|
||||
if (layerEffects != null)
|
||||
{
|
||||
foreach (BsonValue layerEffect in layerEffects)
|
||||
MigratePropertyGroup(layerEffect.AsDocument["PropertyGroup"].AsDocument);
|
||||
}
|
||||
|
||||
BsonValue? displayCondition = profileElement["DisplayCondition"];
|
||||
if (displayCondition != null)
|
||||
MigrateNodeScript(displayCondition.AsDocument["Script"].AsDocument);
|
||||
}
|
||||
|
||||
private void MigratePropertyGroup(BsonDocument? propertyGroup)
|
||||
{
|
||||
if (propertyGroup == null || propertyGroup.Keys.Count == 0)
|
||||
return;
|
||||
|
||||
BsonArray? properties = propertyGroup["Properties"]?.AsArray;
|
||||
BsonArray? propertyGroups = propertyGroup["PropertyGroups"]?.AsArray;
|
||||
|
||||
if (properties != null)
|
||||
{
|
||||
foreach (BsonValue property in properties)
|
||||
MigrateNodeScript(property.AsDocument["DataBinding"]?["NodeScript"]?.AsDocument);
|
||||
}
|
||||
|
||||
if (propertyGroups != null)
|
||||
{
|
||||
foreach (BsonValue childPropertyGroup in propertyGroups)
|
||||
MigratePropertyGroup(childPropertyGroup.AsDocument);
|
||||
}
|
||||
}
|
||||
|
||||
private void MigrateNodeScript(BsonDocument? nodeScript)
|
||||
{
|
||||
if (nodeScript == null || nodeScript.Keys.Count == 0)
|
||||
return;
|
||||
|
||||
BsonArray? nodes = nodeScript["Nodes"]?.AsArray;
|
||||
if (nodes == null)
|
||||
return;
|
||||
|
||||
foreach (BsonValue node in nodes)
|
||||
{
|
||||
node.AsDocument["Type"] = node.AsDocument["Type"]?.AsString?.Replace("Artemis.VisualScripting.Nodes", "Artemis.Plugins.Nodes.General.Nodes");
|
||||
node.AsDocument["ProviderId"] = "Artemis.Plugins.Nodes.General.GeneralNodesProvider-d9e1ee78";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ internal class DeviceRepository : IDeviceRepository
|
||||
_repository.Delete<DeviceEntity>(deviceEntity.Id);
|
||||
}
|
||||
|
||||
public DeviceEntity Get(string id)
|
||||
public DeviceEntity? Get(string id)
|
||||
{
|
||||
return _repository.FirstOrDefault<DeviceEntity>(s => s.Id == id);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ internal class EntryRepository : IEntryRepository
|
||||
_repository.Delete<EntryEntity>(entryEntity.Id);
|
||||
}
|
||||
|
||||
public EntryEntity Get(Guid id)
|
||||
public EntryEntity? Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<EntryEntity>(s => s.Id == id);
|
||||
}
|
||||
|
||||
public EntryEntity GetByEntryId(long entryId)
|
||||
public EntryEntity? GetByEntryId(long entryId)
|
||||
{
|
||||
return _repository.FirstOrDefault<EntryEntity>(s => s.EntryId == entryId);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public interface IDeviceRepository : IRepository
|
||||
{
|
||||
void Add(DeviceEntity deviceEntity);
|
||||
void Remove(DeviceEntity deviceEntity);
|
||||
DeviceEntity Get(string id);
|
||||
DeviceEntity? Get(string id);
|
||||
List<DeviceEntity> GetAll();
|
||||
void Save(DeviceEntity deviceEntity);
|
||||
void Save(IEnumerable<DeviceEntity> deviceEntities);
|
||||
|
||||
@@ -8,8 +8,8 @@ public interface IEntryRepository : IRepository
|
||||
{
|
||||
void Add(EntryEntity entryEntity);
|
||||
void Remove(EntryEntity entryEntity);
|
||||
EntryEntity Get(Guid id);
|
||||
EntryEntity GetByEntryId(long entryId);
|
||||
EntryEntity? Get(Guid id);
|
||||
EntryEntity? GetByEntryId(long entryId);
|
||||
List<EntryEntity> GetAll();
|
||||
void Save(EntryEntity entryEntity);
|
||||
void Save(IEnumerable<EntryEntity> entryEntities);
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace Artemis.Storage.Repositories.Interfaces;
|
||||
public interface IPluginRepository : IRepository
|
||||
{
|
||||
void AddPlugin(PluginEntity pluginEntity);
|
||||
PluginEntity GetPluginByGuid(Guid pluginGuid);
|
||||
PluginEntity? GetPluginByGuid(Guid pluginGuid);
|
||||
void SavePlugin(PluginEntity pluginEntity);
|
||||
|
||||
void AddSetting(PluginSettingEntity pluginSettingEntity);
|
||||
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
PluginSettingEntity? GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity? GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
void SaveSetting(PluginSettingEntity pluginSettingEntity);
|
||||
void RemoveSettings(Guid pluginGuid);
|
||||
}
|
||||
@@ -10,8 +10,8 @@ public interface IProfileCategoryRepository : IRepository
|
||||
void Add(ProfileCategoryEntity profileCategoryEntity);
|
||||
void Remove(ProfileCategoryEntity profileCategoryEntity);
|
||||
List<ProfileCategoryEntity> GetAll();
|
||||
ProfileCategoryEntity Get(Guid id);
|
||||
Stream GetProfileIconStream(Guid id);
|
||||
ProfileCategoryEntity? Get(Guid id);
|
||||
Stream? GetProfileIconStream(Guid id);
|
||||
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
|
||||
ProfileCategoryEntity IsUnique(string name, Guid? id);
|
||||
void Save(ProfileCategoryEntity profileCategoryEntity);
|
||||
|
||||
@@ -9,6 +9,6 @@ public interface IProfileRepository : IRepository
|
||||
void Add(ProfileEntity profileEntity);
|
||||
void Remove(ProfileEntity profileEntity);
|
||||
List<ProfileEntity> GetAll();
|
||||
ProfileEntity Get(Guid id);
|
||||
ProfileEntity? Get(Guid id);
|
||||
void Save(ProfileEntity profileEntity);
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IRepository
|
||||
{
|
||||
}
|
||||
public interface IRepository;
|
||||
@@ -21,7 +21,7 @@ internal class PluginRepository : IPluginRepository
|
||||
_repository.Insert(pluginEntity);
|
||||
}
|
||||
|
||||
public PluginEntity GetPluginByGuid(Guid pluginGuid)
|
||||
public PluginEntity? GetPluginByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginEntity>(p => p.Id == pluginGuid);
|
||||
}
|
||||
@@ -29,7 +29,6 @@ internal class PluginRepository : IPluginRepository
|
||||
public void SavePlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Upsert(pluginEntity);
|
||||
_repository.Database.Checkpoint();
|
||||
}
|
||||
|
||||
public void AddSetting(PluginSettingEntity pluginSettingEntity)
|
||||
@@ -37,12 +36,12 @@ internal class PluginRepository : IPluginRepository
|
||||
_repository.Insert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
|
||||
public PluginSettingEntity? GetSettingByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
|
||||
public PluginSettingEntity? GetSettingByNameAndGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository
|
||||
return _repository.Query<ProfileCategoryEntity>().ToList();
|
||||
}
|
||||
|
||||
public ProfileCategoryEntity Get(Guid id)
|
||||
public ProfileCategoryEntity? Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository
|
||||
_repository.Upsert(profileCategoryEntity);
|
||||
}
|
||||
|
||||
public Stream GetProfileIconStream(Guid id)
|
||||
public Stream? GetProfileIconStream(Guid id)
|
||||
{
|
||||
if (!_profileIcons.Exists(id))
|
||||
return null;
|
||||
|
||||
@@ -31,7 +31,7 @@ internal class ProfileRepository : IProfileRepository
|
||||
return _repository.Query<ProfileEntity>().ToList();
|
||||
}
|
||||
|
||||
public ProfileEntity Get(Guid id)
|
||||
public ProfileEntity? Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using Artemis.Storage.Migrations;
|
||||
using LiteDB;
|
||||
using Serilog;
|
||||
|
||||
|
||||
Reference in new issue
Block a user