Plugins - Added platform support

Settings - Fixed updating issues in plugin tab
UI - Don't initialize in design mode
UI - Move ReactiveCoreWindow to Artemis.Shared
Window service - Return window created by ShowWindow
Window service - Added CreateOpenFileDialog API
This commit is contained in:
Robert committed 2022-07-22 20:28:07 +02:00
1 parent e385165200
commit 75d85985a9
37 files changed
+600 -375

No files matched your search

@@ -26,6 +26,7 @@ namespace Artemis.Core
/// <summary>
/// Marks the feature to always be enabled as long as the plugin is enabled
/// <para>Note: always <see langword="true"/> if this is the plugin's only feature</para>
/// </summary>
public bool AlwaysEnabled { get; set; }
}
@@ -122,10 +122,11 @@ namespace Artemis.Core
}
/// <summary>
/// Marks the feature to always be enabled as long as the plugin is enabled and cannot be disabled
/// Marks the feature to always be enabled as long as the plugin is enabled and cannot be disabled.
/// <para>Note: always <see langword="true"/> if this is the plugin's only feature</para>
/// </summary>
[JsonProperty]
public bool AlwaysEnabled { get; }
public bool AlwaysEnabled { get; internal set; }
/// <summary>
/// Gets a boolean indicating whether the feature is enabled in persistent storage
+17 -2
View File
@@ -24,7 +24,7 @@ namespace Artemis.Core
private Plugin _plugin = null!;
private Version _version = null!;
private bool _requiresAdmin;
private PluginPlatform? _platforms;
internal PluginInfo()
{
@@ -142,7 +142,17 @@ namespace Artemis.Core
get => _requiresAdmin;
internal set => SetAndNotify(ref _requiresAdmin, value);
}
/// <summary>
/// Gets
/// </summary>
[JsonProperty]
public PluginPlatform? Platforms
{
get => _platforms;
internal set => _platforms = value;
}
/// <summary>
/// Gets the plugin this info is associated with
/// </summary>
@@ -164,6 +174,11 @@ namespace Artemis.Core
return Icon.Contains('.') ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}
/// <summary>
/// Gets a boolean indicating whether this plugin is compatible with the current operating system
/// </summary>
public bool IsCompatible => Platforms.MatchesCurrentOperatingSystem();
internal string PreferredPluginDirectory => $"{Main.Split(".dll")[0].Replace("/", "").Replace("\\", "")}-{Guid.ToString().Substring(0, 8)}";
+25 -3
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
namespace Artemis.Core;
@@ -6,15 +7,36 @@ namespace Artemis.Core;
/// Specifies OS platforms a plugin may support.
/// </summary>
[Flags]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum PluginPlatform
{
/// <summary>The Windows platform.</summary>
Windows = 0,
Windows = 1,
/// <summary>The Linux platform.</summary>
Linux = 1,
Linux = 2,
/// <summary>The OSX platform.</summary>
// ReSharper disable once InconsistentNaming
OSX = 2
OSX = 4
}
internal static class PluginPlatformExtensions
{
/// <summary>
/// Determines whether the provided platform matches the current operating system.
/// </summary>
internal static bool MatchesCurrentOperatingSystem(this PluginPlatform? platform)
{
if (platform == null)
return true;
if (OperatingSystem.IsWindows())
return platform.Value.HasFlag(PluginPlatform.Windows);
if (OperatingSystem.IsLinux())
return platform.Value.HasFlag(PluginPlatform.Linux);
if (OperatingSystem.IsMacOS())
return platform.Value.HasFlag(PluginPlatform.OSX);
return false;
}
}
@@ -101,16 +101,7 @@ namespace Artemis.Core
/// </summary>
public bool AppliesToPlatform()
{
if (Platform == null)
return true;
if (OperatingSystem.IsWindows())
return Platform.Value.HasFlag(PluginPlatform.Windows);
if (OperatingSystem.IsLinux())
return Platform.Value.HasFlag(PluginPlatform.Linux);
if (OperatingSystem.IsMacOS())
return Platform.Value.HasFlag(PluginPlatform.OSX);
return false;
return Platform.MatchesCurrentOperatingSystem();
}
/// <summary>