diff --git a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs index ad3b7c179..18e53bd1e 100644 --- a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs +++ b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs @@ -96,13 +96,13 @@ namespace Artemis.Core.Plugins.Modules /// public abstract class ProfileModule : Module { + protected readonly List HiddenPropertiesList = new List(); + protected ProfileModule() { OpacityOverride = 1; } - protected readonly List HiddenPropertiesList = new List(); - /// /// Gets a list of all properties ignored at runtime using IgnoreProperty(x => x.y) /// @@ -115,9 +115,59 @@ namespace Artemis.Core.Plugins.Modules /// public bool IsProfileUpdatingDisabled { get; set; } - /// - public override void Update(double deltaTime) + /// + /// Overrides the opacity of the root folder + /// + public double OpacityOverride { get; set; } + + /// + /// Indicates whether or not a profile change is being animated + /// + public bool AnimatingProfileChange { get; private set; } + + /// + /// Called before the profile updates, this is the best place to perform data model updates + /// + /// Time in seconds since the last update + public virtual void ProfileUpdate(double deltaTime) { + } + + /// + /// Called after the profile has updated + /// + /// Time in seconds since the last update + public virtual void ProfileUpdated(double deltaTime) + { + } + + /// + /// Called before the profile renders + /// + /// Time since the last render + /// The RGB Surface to render to + /// + /// + public virtual void ProfileRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo) + { + } + + /// + /// Called after the profile has rendered + /// + /// Time since the last render + /// The RGB Surface to render to + /// + /// + public virtual void ProfileRendered(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo) + { + } + + /// + public sealed override void Update(double deltaTime) + { + ProfileUpdate(deltaTime); + lock (this) { OpacityOverride = AnimatingProfileChange @@ -128,16 +178,22 @@ namespace Artemis.Core.Plugins.Modules if (!IsProfileUpdatingDisabled) ActiveProfile?.Update(deltaTime); } + + ProfileUpdated(deltaTime); } /// - public override void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo) + public sealed override void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo) { + ProfileRender(deltaTime, surface, canvas, canvasInfo); + lock (this) { // Render the profile ActiveProfile?.Render(deltaTime, canvas, canvasInfo); } + + ProfileRendered(deltaTime, surface, canvas, canvasInfo); } internal async Task ChangeActiveProfileAnimated(Profile profile, ArtemisSurface surface) @@ -183,16 +239,6 @@ namespace Artemis.Core.Plugins.Modules OnActiveProfileChanged(); } - /// - /// Overrides the opacity of the root folder - /// - public double OpacityOverride { get; set; } - - /// - /// Indicates whether or not a profile change is being animated - /// - public bool AnimatingProfileChange { get; private set; } - internal override void Deactivate(bool isOverride) { base.Deactivate(isOverride); diff --git a/src/Artemis.Core/Services/ModuleService.cs b/src/Artemis.Core/Services/ModuleService.cs index 201825b1b..812ab5cc9 100644 --- a/src/Artemis.Core/Services/ModuleService.cs +++ b/src/Artemis.Core/Services/ModuleService.cs @@ -44,18 +44,17 @@ namespace Artemis.Core.Services public async Task SetActiveModuleOverride(Module overrideModule) { - await ActiveModuleSemaphore.WaitAsync(); - - if (ActiveModuleOverride == overrideModule) - return; - try { - ActiveModuleOverride = overrideModule; + await ActiveModuleSemaphore.WaitAsync(); + + if (ActiveModuleOverride == overrideModule) + return; // If set to null, resume regular activation - if (ActiveModuleOverride == null) + if (overrideModule == null) { + ActiveModuleOverride = null; _logger.Information("Cleared active module override"); return; } @@ -65,14 +64,15 @@ namespace Artemis.Core.Services var tasks = new List(); foreach (var module in modules) { - if (module != ActiveModuleOverride) + if (module != overrideModule) tasks.Add(DeactivateModule(module, true)); } - if (!ActiveModuleOverride.IsActivated) - tasks.Add(ActivateModule(ActiveModuleOverride, true)); + if (!overrideModule.IsActivated) + tasks.Add(ActivateModule(overrideModule, true)); await Task.WhenAll(tasks); + ActiveModuleOverride = overrideModule; _logger.Information($"Set active module override to {ActiveModuleOverride.DisplayName}"); } @@ -88,13 +88,13 @@ namespace Artemis.Core.Services public async Task UpdateModuleActivation() { - if (ActiveModuleOverride != null) - return; - - await ActiveModuleSemaphore.WaitAsync(); - try { + await ActiveModuleSemaphore.WaitAsync(); + + if (ActiveModuleOverride != null) + return; + var stopwatch = new Stopwatch(); stopwatch.Start(); @@ -129,19 +129,19 @@ namespace Artemis.Core.Services modules.Remove(module); if (modules.Count == 0) - priority = 1; - else if (priority < 1) - priority = 1; + priority = 0; + else if (priority < 0) + priority = 0; else if (priority > modules.Count) priority = modules.Count; module.PriorityCategory = category; - modules.Insert(priority - 1, module); + modules.Insert(priority, module); for (var index = 0; index < modules.Count; index++) { var categoryModule = modules[index]; - categoryModule.Priority = index + 1; + categoryModule.Priority = index; categoryModule.ApplyToEntity(); _moduleRepository.Save(categoryModule.Entity); diff --git a/src/Artemis.Core/Utilities/IntroAnimation.cs b/src/Artemis.Core/Utilities/IntroAnimation.cs index 02a5c59a6..9b5cc0127 100644 --- a/src/Artemis.Core/Utilities/IntroAnimation.cs +++ b/src/Artemis.Core/Utilities/IntroAnimation.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using Artemis.Core.Extensions; using Artemis.Core.Models.Profile; +using Artemis.Core.Models.Surface; using Artemis.Core.Plugins.Modules; using Artemis.Core.Services.Storage.Interfaces; using Artemis.Storage.Entities.Profile; diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabView.xaml b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabView.xaml index 38b3d69c0..6637d78a4 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabView.xaml +++ b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabView.xaml @@ -6,15 +6,16 @@ xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Modules" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:s="https://github.com/canton7/Stylet" + xmlns:dd="urn:gong-wpf-dragdrop" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:ModuleOrderTabViewModel}"> - - - + + + @@ -35,7 +36,14 @@ - + @@ -57,7 +65,14 @@ - + @@ -79,7 +94,14 @@ - + diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs index 5c79f19da..4c707b455 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs @@ -10,7 +10,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Modules { private readonly IPluginService _pluginService; - public ModuleOrderTabViewModel(IPluginService pluginService) + public ModuleOrderTabViewModel(IPluginService pluginService, IModuleService moduleService) { DisplayName = "MODULE PRIORITY"; @@ -18,12 +18,17 @@ namespace Artemis.UI.Screens.Settings.Tabs.Modules NormalModules = new BindableCollection(); ApplicationModules = new BindableCollection(); OverlayModules = new BindableCollection(); + + ModulesDropHandler = new ModulesDropHandler(moduleService, NormalModules, ApplicationModules, OverlayModules); } public BindableCollection NormalModules { get; set; } public BindableCollection ApplicationModules { get; set; } public BindableCollection OverlayModules { get; set; } + public ModulesDropHandler ModulesDropHandler { get; } + + protected override void OnActivate() { // Take it off the UI thread to avoid freezing on tab change diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModulesDropHandler.cs b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModulesDropHandler.cs new file mode 100644 index 000000000..647eb72ea --- /dev/null +++ b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModulesDropHandler.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Artemis.Core.Plugins.Modules; +using Artemis.Core.Services.Interfaces; +using GongSolutions.Wpf.DragDrop; +using Stylet; + +namespace Artemis.UI.Screens.Settings.Tabs.Modules +{ + public class ModulesDropHandler : IDropTarget + { + private readonly IModuleService _moduleService; + private readonly BindableCollection _normalModules; + private readonly BindableCollection _applicationModules; + private readonly BindableCollection _overlayModules; + private DefaultDropHandler _defaultDropHandler; + + public ModulesDropHandler(IModuleService moduleService, + BindableCollection normalModules, + BindableCollection applicationModules, + BindableCollection overlayModules) + { + _defaultDropHandler = new DefaultDropHandler(); + _moduleService = moduleService; + _normalModules = normalModules; + _applicationModules = applicationModules; + _overlayModules = overlayModules; + } + + public void DragOver(IDropInfo dropInfo) + { + _defaultDropHandler.DragOver(dropInfo); + } + + public void Drop(IDropInfo dropInfo) + { + var module = (Core.Plugins.Modules.Module) dropInfo.Data; + var target = (BindableCollection) dropInfo.TargetCollection; + var insertIndex = dropInfo.InsertIndex; + + ModulePriorityCategory category; + if (target == _applicationModules) + category = ModulePriorityCategory.Application; + else if (target == _normalModules) + category = ModulePriorityCategory.Normal; + else + category = ModulePriorityCategory.Overlay; + + + if (target.Contains(module)) + { + target.Move(target.IndexOf(module), Math.Min(target.Count - 1, insertIndex)); + _moduleService.UpdateModulePriority(module, category, insertIndex); + } + else + { + if (module.PriorityCategory == ModulePriorityCategory.Application) + _applicationModules.Remove(module); + else if (module.PriorityCategory == ModulePriorityCategory.Normal) + _normalModules.Remove(module); + else if (module.PriorityCategory == ModulePriorityCategory.Overlay) + _overlayModules.Remove(module); + + _moduleService.UpdateModulePriority(module, category, insertIndex); + + if (module.PriorityCategory == ModulePriorityCategory.Application) + _applicationModules.Insert(insertIndex, module); + else if (module.PriorityCategory == ModulePriorityCategory.Normal) + _normalModules.Insert(insertIndex, module); + else if (module.PriorityCategory == ModulePriorityCategory.Overlay) + _overlayModules.Insert(insertIndex, module); + } + } + } +} \ No newline at end of file diff --git a/src/Artemis.sln b/src/Artemis.sln index 8b6d01397..e84109a10 100644 --- a/src/Artemis.sln +++ b/src/Artemis.sln @@ -79,6 +79,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.Devices.Deb EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.Modules.Overlay", "Plugins\Artemis.Plugins.Modules.Overlay\Artemis.Plugins.Modules.Overlay.csproj", "{00318027-7FDB-4C86-AB86-9005A481E330}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestModules", "TestModules", "{7497B6D5-FA21-4BDB-A752-28C935B748D2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModule1", "Plugins\TestModules\TestModule1\TestModule1.csproj", "{CA3F9E44-10BE-4940-96A5-CA25750E40DA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModule2", "Plugins\TestModules\TestModule2\TestModule2.csproj", "{228EF084-4430-4D0E-B728-D47C1C35F34D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModule3", "Plugins\TestModules\TestModule3\TestModule3.csproj", "{979A10FE-7994-4426-A542-97058163FC27}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -177,6 +185,18 @@ Global {00318027-7FDB-4C86-AB86-9005A481E330}.Debug|x64.Build.0 = Debug|x64 {00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.ActiveCfg = Release|x64 {00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.Build.0 = Release|x64 + {CA3F9E44-10BE-4940-96A5-CA25750E40DA}.Debug|x64.ActiveCfg = Debug|x64 + {CA3F9E44-10BE-4940-96A5-CA25750E40DA}.Debug|x64.Build.0 = Debug|x64 + {CA3F9E44-10BE-4940-96A5-CA25750E40DA}.Release|x64.ActiveCfg = Release|x64 + {CA3F9E44-10BE-4940-96A5-CA25750E40DA}.Release|x64.Build.0 = Release|x64 + {228EF084-4430-4D0E-B728-D47C1C35F34D}.Debug|x64.ActiveCfg = Debug|x64 + {228EF084-4430-4D0E-B728-D47C1C35F34D}.Debug|x64.Build.0 = Debug|x64 + {228EF084-4430-4D0E-B728-D47C1C35F34D}.Release|x64.ActiveCfg = Release|x64 + {228EF084-4430-4D0E-B728-D47C1C35F34D}.Release|x64.Build.0 = Release|x64 + {979A10FE-7994-4426-A542-97058163FC27}.Debug|x64.ActiveCfg = Debug|x64 + {979A10FE-7994-4426-A542-97058163FC27}.Debug|x64.Build.0 = Debug|x64 + {979A10FE-7994-4426-A542-97058163FC27}.Release|x64.ActiveCfg = Release|x64 + {979A10FE-7994-4426-A542-97058163FC27}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -205,6 +225,10 @@ Global {62214042-667E-4B29-B64E-1A68CE6FE209} = {2C1477DC-7A5C-4B65-85DB-1F16A18FB2EC} {3D83760B-0A36-4C8F-978D-7949C3FC862B} = {88792A7E-F037-4280-81D3-B131508EF1D8} {00318027-7FDB-4C86-AB86-9005A481E330} = {B258A061-FA19-4835-8DC4-E9C3AE3664A0} + {7497B6D5-FA21-4BDB-A752-28C935B748D2} = {B258A061-FA19-4835-8DC4-E9C3AE3664A0} + {CA3F9E44-10BE-4940-96A5-CA25750E40DA} = {7497B6D5-FA21-4BDB-A752-28C935B748D2} + {228EF084-4430-4D0E-B728-D47C1C35F34D} = {7497B6D5-FA21-4BDB-A752-28C935B748D2} + {979A10FE-7994-4426-A542-97058163FC27} = {7497B6D5-FA21-4BDB-A752-28C935B748D2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C203080A-4473-4CC2-844B-F552EA43D66A} diff --git a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs index d8759b149..7b9ae6c19 100644 --- a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs +++ b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs @@ -36,15 +36,14 @@ namespace Artemis.Plugins.Modules.General { } - public override void Update(double deltaTime) + public override void ProfileUpdate(double deltaTime) { DataModel.TimeDataModel.CurrentTime = DateTime.Now; DataModel.TimeDataModel.CurrentTimeUTC = DateTime.UtcNow; UpdateCurrentWindow(); - base.Update(deltaTime); } - + #region Open windows public void UpdateCurrentWindow() diff --git a/src/Plugins/TestModules/TestModule1/PluginModule.cs b/src/Plugins/TestModules/TestModule1/PluginModule.cs new file mode 100644 index 000000000..7e865baf2 --- /dev/null +++ b/src/Plugins/TestModules/TestModule1/PluginModule.cs @@ -0,0 +1,37 @@ +using Artemis.Core.Models.Surface; +using Artemis.Core.Plugins.Modules; +using SkiaSharp; + + + + +namespace TestModule1 +{ + // The core of your module. Hover over the method names to see a description. + public class PluginModule : ProfileModule + { + // This is the beginning of your plugin life cycle. Use this instead of a constructor. + public override void EnablePlugin() + { + DisplayName = "TestModule1"; + DisplayIcon = "ToyBrickPlus"; + DefaultPriorityCategory = ModulePriorityCategory.Normal; + + } + + // This is the end of your plugin life cycle. + public override void DisablePlugin() + { + // Make sure to clean up resources where needed (dispose IDisposables etc.) + } + + + public override void ModuleActivated(bool isOverride) + { + } + + public override void ModuleDeactivated(bool isOverride) + { + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule1/Properties/launchSettings.json b/src/Plugins/TestModules/TestModule1/Properties/launchSettings.json new file mode 100644 index 000000000..e7eb59a06 --- /dev/null +++ b/src/Plugins/TestModules/TestModule1/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "ModuleProject": { + "commandName": "Executable", + "executablePath": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1\\Artemis.UI.exe", + "workingDirectory": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1" + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule1/TestModule1.csproj b/src/Plugins/TestModules/TestModule1/TestModule1.csproj new file mode 100644 index 000000000..3138b0b63 --- /dev/null +++ b/src/Plugins/TestModules/TestModule1/TestModule1.csproj @@ -0,0 +1,39 @@ + + + netcoreapp3.1 + false + + TestModule1 + TestModule1 + x64 + + + x64 + + + + + + + + + + + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll + + + + + + PreserveNewest + + + + + + \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule1/plugin.json b/src/Plugins/TestModules/TestModule1/plugin.json new file mode 100644 index 000000000..a9b30c57a --- /dev/null +++ b/src/Plugins/TestModules/TestModule1/plugin.json @@ -0,0 +1,7 @@ +{ + "Guid": "e7aed08d-a998-457e-91d8-61cd5689896b", + "Name": "TestModule1", + "Description": "This is my awesome plugin", + "Version": "1.0.0.0", + "Main": "TestModule1.dll" +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule2/PluginModule.cs b/src/Plugins/TestModules/TestModule2/PluginModule.cs new file mode 100644 index 000000000..b8cdaefdc --- /dev/null +++ b/src/Plugins/TestModules/TestModule2/PluginModule.cs @@ -0,0 +1,38 @@ +using Artemis.Core.Models.Surface; +using Artemis.Core.Plugins.Modules; +using SkiaSharp; + + + + +namespace TestModule2 +{ + // The core of your module. Hover over the method names to see a description. + public class PluginModule : ProfileModule + { + // This is the beginning of your plugin life cycle. Use this instead of a constructor. + public override void EnablePlugin() + { + DisplayName = "TestModule2"; + DisplayIcon = "ToyBrickPlus"; + DefaultPriorityCategory = ModulePriorityCategory.Application; + + } + + // This is the end of your plugin life cycle. + public override void DisablePlugin() + { + // Make sure to clean up resources where needed (dispose IDisposables etc.) + } + + public override void ModuleActivated(bool isOverride) + { + // When this gets called your activation requirements have been met and the module will start displaying + } + + public override void ModuleDeactivated(bool isOverride) + { + // When this gets called your activation requirements are no longer met and your module will stop displaying + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule2/Properties/launchSettings.json b/src/Plugins/TestModules/TestModule2/Properties/launchSettings.json new file mode 100644 index 000000000..e7eb59a06 --- /dev/null +++ b/src/Plugins/TestModules/TestModule2/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "ModuleProject": { + "commandName": "Executable", + "executablePath": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1\\Artemis.UI.exe", + "workingDirectory": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1" + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule2/TestModule2.csproj b/src/Plugins/TestModules/TestModule2/TestModule2.csproj new file mode 100644 index 000000000..3cba5c3ab --- /dev/null +++ b/src/Plugins/TestModules/TestModule2/TestModule2.csproj @@ -0,0 +1,39 @@ + + + netcoreapp3.1 + false + + TestModule2 + TestModule2 + x64 + + + x64 + + + + + + + + + + + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll + + + + + + PreserveNewest + + + + + + \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule2/plugin.json b/src/Plugins/TestModules/TestModule2/plugin.json new file mode 100644 index 000000000..3b83d3294 --- /dev/null +++ b/src/Plugins/TestModules/TestModule2/plugin.json @@ -0,0 +1,7 @@ +{ + "Guid": "5ea31fec-3774-4cbf-8774-1cab7caaaa18", + "Name": "TestModule2", + "Description": "This is my awesome plugin", + "Version": "1.0.0.0", + "Main": "TestModule2.dll" +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule3/DataModels/PluginDataModel.cs b/src/Plugins/TestModules/TestModule3/DataModels/PluginDataModel.cs new file mode 100644 index 000000000..387358336 --- /dev/null +++ b/src/Plugins/TestModules/TestModule3/DataModels/PluginDataModel.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Artemis.Core.Plugins.DataModelExpansions; +using Artemis.Core.Plugins.DataModelExpansions.Attributes; + +namespace TestModule3.DataModels +{ + public class PluginDataModel : DataModel + { + public PluginDataModel() + { + PluginSubDataModel = new PluginSubDataModel(); + } + + // Your datamodel can have regular properties and you can annotate them if you'd like + [DataModelProperty(Name = "A test string", Description = "It doesn't do much, but it's there.")] + public string TemplateDataModelString { get; set; } + + // You can even have classes in your datamodel, just don't forget to instantiate them ;) + [DataModelProperty(Name = "A class within the datamodel")] + public PluginSubDataModel PluginSubDataModel { get; set; } + } + + public class PluginSubDataModel + { + public PluginSubDataModel() + { + ListOfInts = new List { 1, 2, 3, 4, 5 }; + } + + // You don't need to annotate properties, they will still show up + public float FloatyFloat { get; set; } + + // You can even have a list! + public List ListOfInts { get; set; } + + // If you don't want a property to show up in the datamodel, annotate it with DataModelIgnore + [DataModelIgnore] + public string MyDarkestSecret { get; set; } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule3/PluginModule.cs b/src/Plugins/TestModules/TestModule3/PluginModule.cs new file mode 100644 index 000000000..1594ae23c --- /dev/null +++ b/src/Plugins/TestModules/TestModule3/PluginModule.cs @@ -0,0 +1,36 @@ +using Artemis.Core.Models.Surface; +using Artemis.Core.Plugins.Modules; +using SkiaSharp; +using TestModule3.DataModels; + + + +namespace TestModule3 +{ + // The core of your module. Hover over the method names to see a description. + public class PluginModule : ProfileModule + { + // This is the beginning of your plugin life cycle. Use this instead of a constructor. + public override void EnablePlugin() + { + DisplayName = "TestModule3"; + DisplayIcon = "ToyBrickPlus"; + DefaultPriorityCategory = ModulePriorityCategory.Normal; + + } + + // This is the end of your plugin life cycle. + public override void DisablePlugin() + { + // Make sure to clean up resources where needed (dispose IDisposables etc.) + } + + public override void ModuleActivated(bool isOverride) + { + } + + public override void ModuleDeactivated(bool isOverride) + { + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule3/Properties/launchSettings.json b/src/Plugins/TestModules/TestModule3/Properties/launchSettings.json new file mode 100644 index 000000000..e7eb59a06 --- /dev/null +++ b/src/Plugins/TestModules/TestModule3/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "ModuleProject": { + "commandName": "Executable", + "executablePath": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1\\Artemis.UI.exe", + "workingDirectory": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1" + } + } +} \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule3/TestModule3.csproj b/src/Plugins/TestModules/TestModule3/TestModule3.csproj new file mode 100644 index 000000000..a1c4adfb5 --- /dev/null +++ b/src/Plugins/TestModules/TestModule3/TestModule3.csproj @@ -0,0 +1,39 @@ + + + netcoreapp3.1 + false + + TestModule3 + TestModule3 + x64 + + + x64 + + + + + + + + + + + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll + + + C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll + + + + + + PreserveNewest + + + + + + \ No newline at end of file diff --git a/src/Plugins/TestModules/TestModule3/plugin.json b/src/Plugins/TestModules/TestModule3/plugin.json new file mode 100644 index 000000000..826638c33 --- /dev/null +++ b/src/Plugins/TestModules/TestModule3/plugin.json @@ -0,0 +1,7 @@ +{ + "Guid": "48011e31-a309-4069-820e-e734f37fc79f", + "Name": "TestModule3", + "Description": "This is my awesome plugin", + "Version": "1.0.0.0", + "Main": "TestModule3.dll" +} \ No newline at end of file