mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Modules - Ordering WIP
This commit is contained in:
parent
d62d389d9f
commit
bfb122e95a
@ -96,13 +96,13 @@ namespace Artemis.Core.Plugins.Modules
|
||||
/// </summary>
|
||||
public abstract class ProfileModule : Module
|
||||
{
|
||||
protected readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
|
||||
|
||||
protected ProfileModule()
|
||||
{
|
||||
OpacityOverride = 1;
|
||||
}
|
||||
|
||||
protected readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all properties ignored at runtime using IgnoreProperty(x => x.y)
|
||||
/// </summary>
|
||||
@ -115,9 +115,59 @@ namespace Artemis.Core.Plugins.Modules
|
||||
/// </summary>
|
||||
public bool IsProfileUpdatingDisabled { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(double deltaTime)
|
||||
/// <summary>
|
||||
/// Overrides the opacity of the root folder
|
||||
/// </summary>
|
||||
public double OpacityOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not a profile change is being animated
|
||||
/// </summary>
|
||||
public bool AnimatingProfileChange { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called before the profile updates, this is the best place to perform data model updates
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time in seconds since the last update</param>
|
||||
public virtual void ProfileUpdate(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the profile has updated
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time in seconds since the last update</param>
|
||||
public virtual void ProfileUpdated(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before the profile renders
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time since the last render</param>
|
||||
/// <param name="surface">The RGB Surface to render to</param>
|
||||
/// <param name="canvas"></param>
|
||||
/// <param name="canvasInfo"></param>
|
||||
public virtual void ProfileRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the profile has rendered
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time since the last render</param>
|
||||
/// <param name="surface">The RGB Surface to render to</param>
|
||||
/// <param name="canvas"></param>
|
||||
/// <param name="canvasInfo"></param>
|
||||
public virtual void ProfileRendered(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the opacity of the root folder
|
||||
/// </summary>
|
||||
public double OpacityOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not a profile change is being animated
|
||||
/// </summary>
|
||||
public bool AnimatingProfileChange { get; private set; }
|
||||
|
||||
internal override void Deactivate(bool isOverride)
|
||||
{
|
||||
base.Deactivate(isOverride);
|
||||
|
||||
@ -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<Task>();
|
||||
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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<Grid Margin="15" MaxWidth="800">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Profile editor settings -->
|
||||
@ -35,7 +36,14 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding OverlayModules}" DisplayMemberPath="DisplayName"/>
|
||||
<ListBox ItemsSource="{Binding OverlayModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
@ -57,7 +65,14 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding ApplicationModules}" DisplayMemberPath="DisplayName"/>
|
||||
<ListBox ItemsSource="{Binding ApplicationModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
@ -79,7 +94,14 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding NormalModules}" DisplayMemberPath="DisplayName"/>
|
||||
<ListBox ItemsSource="{Binding NormalModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
@ -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<Core.Plugins.Modules.Module>();
|
||||
ApplicationModules = new BindableCollection<Core.Plugins.Modules.Module>();
|
||||
OverlayModules = new BindableCollection<Core.Plugins.Modules.Module>();
|
||||
|
||||
ModulesDropHandler = new ModulesDropHandler(moduleService, NormalModules, ApplicationModules, OverlayModules);
|
||||
}
|
||||
|
||||
public BindableCollection<Core.Plugins.Modules.Module> NormalModules { get; set; }
|
||||
public BindableCollection<Core.Plugins.Modules.Module> ApplicationModules { get; set; }
|
||||
public BindableCollection<Core.Plugins.Modules.Module> OverlayModules { get; set; }
|
||||
|
||||
public ModulesDropHandler ModulesDropHandler { get; }
|
||||
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Take it off the UI thread to avoid freezing on tab change
|
||||
|
||||
@ -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<Core.Plugins.Modules.Module> _normalModules;
|
||||
private readonly BindableCollection<Core.Plugins.Modules.Module> _applicationModules;
|
||||
private readonly BindableCollection<Core.Plugins.Modules.Module> _overlayModules;
|
||||
private DefaultDropHandler _defaultDropHandler;
|
||||
|
||||
public ModulesDropHandler(IModuleService moduleService,
|
||||
BindableCollection<Core.Plugins.Modules.Module> normalModules,
|
||||
BindableCollection<Core.Plugins.Modules.Module> applicationModules,
|
||||
BindableCollection<Core.Plugins.Modules.Module> 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<Core.Plugins.Modules.Module>) 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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}
|
||||
|
||||
@ -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()
|
||||
|
||||
37
src/Plugins/TestModules/TestModule1/PluginModule.cs
Normal file
37
src/Plugins/TestModules/TestModule1/PluginModule.cs
Normal file
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/Plugins/TestModules/TestModule1/TestModule1.csproj
Normal file
39
src/Plugins/TestModules/TestModule1/TestModule1.csproj
Normal file
@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
|
||||
<AssemblyName>TestModule1</AssemblyName>
|
||||
<RootNamespace>TestModule1</RootNamespace>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="SkiaSharp" Version="1.68.3" />
|
||||
<PackageReference Include="Stylet" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Artemis.Core">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Artemis.UI.Shared">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<Exec Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis plugin directory
XCOPY "$(TargetDir.TrimEnd('\'))" "%25ProgramData%25\Artemis\Plugins\$(ProjectName)" /s /q /i /y
" />
|
||||
</Target>
|
||||
</Project>
|
||||
7
src/Plugins/TestModules/TestModule1/plugin.json
Normal file
7
src/Plugins/TestModules/TestModule1/plugin.json
Normal file
@ -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"
|
||||
}
|
||||
38
src/Plugins/TestModules/TestModule2/PluginModule.cs
Normal file
38
src/Plugins/TestModules/TestModule2/PluginModule.cs
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/Plugins/TestModules/TestModule2/TestModule2.csproj
Normal file
39
src/Plugins/TestModules/TestModule2/TestModule2.csproj
Normal file
@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
|
||||
<AssemblyName>TestModule2</AssemblyName>
|
||||
<RootNamespace>TestModule2</RootNamespace>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="SkiaSharp" Version="1.68.3" />
|
||||
<PackageReference Include="Stylet" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Artemis.Core">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Artemis.UI.Shared">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<Exec Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis plugin directory
XCOPY "$(TargetDir.TrimEnd('\'))" "%25ProgramData%25\Artemis\Plugins\$(ProjectName)" /s /q /i /y
" />
|
||||
</Target>
|
||||
</Project>
|
||||
7
src/Plugins/TestModules/TestModule2/plugin.json
Normal file
7
src/Plugins/TestModules/TestModule2/plugin.json
Normal file
@ -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"
|
||||
}
|
||||
@ -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<int> { 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<int> 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; }
|
||||
}
|
||||
}
|
||||
36
src/Plugins/TestModules/TestModule3/PluginModule.cs
Normal file
36
src/Plugins/TestModules/TestModule3/PluginModule.cs
Normal file
@ -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<PluginDataModel>
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/Plugins/TestModules/TestModule3/TestModule3.csproj
Normal file
39
src/Plugins/TestModules/TestModule3/TestModule3.csproj
Normal file
@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
|
||||
<AssemblyName>TestModule3</AssemblyName>
|
||||
<RootNamespace>TestModule3</RootNamespace>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="SkiaSharp" Version="1.68.3" />
|
||||
<PackageReference Include="Stylet" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Artemis.Core">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Artemis.UI.Shared">
|
||||
<HintPath>C:\Repos\Artemis\src\Artemis.UI\bin\x64\Debug\netcoreapp3.1\Artemis.UI.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<Exec Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis plugin directory
XCOPY "$(TargetDir.TrimEnd('\'))" "%25ProgramData%25\Artemis\Plugins\$(ProjectName)" /s /q /i /y
" />
|
||||
</Target>
|
||||
</Project>
|
||||
7
src/Plugins/TestModules/TestModule3/plugin.json
Normal file
7
src/Plugins/TestModules/TestModule3/plugin.json
Normal file
@ -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"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user