mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Plugins - Added API versioning
Tray icon - Fix crash when restoring main window from tray
This commit is contained in:
parent
a282bf3fd7
commit
9d2136dd6a
@ -33,7 +33,9 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// The base path for Artemis application data folder
|
||||
/// </summary>
|
||||
public static readonly string BaseFolder = Environment.GetFolderPath(OperatingSystem.IsWindows() ? Environment.SpecialFolder.CommonApplicationData : Environment.SpecialFolder.LocalApplicationData);
|
||||
public static readonly string BaseFolder = Environment.GetFolderPath(OperatingSystem.IsWindows()
|
||||
? Environment.SpecialFolder.CommonApplicationData
|
||||
: Environment.SpecialFolder.LocalApplicationData);
|
||||
|
||||
/// <summary>
|
||||
/// The full path to the Artemis data folder
|
||||
@ -54,6 +56,11 @@ namespace Artemis.Core
|
||||
/// The full path to the Artemis user layouts folder
|
||||
/// </summary>
|
||||
public static readonly string LayoutsFolder = Path.Combine(DataFolder, "User Layouts");
|
||||
|
||||
/// <summary>
|
||||
/// The current API version for plugins
|
||||
/// </summary>
|
||||
public static readonly Version PluginApi = new Version(1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// The plugin info used by core components of Artemis
|
||||
|
||||
@ -25,6 +25,7 @@ namespace Artemis.Core
|
||||
private Version _version = null!;
|
||||
private bool _requiresAdmin;
|
||||
private PluginPlatform? _platforms;
|
||||
private Version? _api;
|
||||
|
||||
internal PluginInfo()
|
||||
{
|
||||
@ -150,7 +151,17 @@ namespace Artemis.Core
|
||||
public PluginPlatform? Platforms
|
||||
{
|
||||
get => _platforms;
|
||||
internal set => _platforms = value;
|
||||
internal set => SetAndNotify(ref _platforms , value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API version the plugin was built for
|
||||
/// </summary>
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public Version? Api
|
||||
{
|
||||
get => _api;
|
||||
internal set => SetAndNotify(ref _api, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -176,9 +187,9 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether this plugin is compatible with the current operating system
|
||||
/// Gets a boolean indicating whether this plugin is compatible with the current operating system and API version
|
||||
/// </summary>
|
||||
public bool IsCompatible => Platforms.MatchesCurrentOperatingSystem();
|
||||
public bool IsCompatible => Platforms.MatchesCurrentOperatingSystem() && Api != null && Api >= Constants.PluginApi;
|
||||
|
||||
internal string PreferredPluginDirectory => $"{Main.Split(".dll")[0].Replace("/", "").Replace("\\", "")}-{Guid.ToString().Substring(0, 8)}";
|
||||
|
||||
|
||||
@ -127,10 +127,16 @@ namespace Artemis.UI.Screens.Root
|
||||
|
||||
public void OpenScreen(string displayName)
|
||||
{
|
||||
// The window will open on the UI thread at some point, respond to that to select the chosen screen
|
||||
MainWindowOpened += OnEventHandler;
|
||||
OpenMainWindow();
|
||||
|
||||
// At this point there is a sidebar VM because the main window was opened
|
||||
SidebarViewModel!.SelectedSidebarScreen = SidebarViewModel.SidebarScreens.FirstOrDefault(s => s.DisplayName == displayName);
|
||||
void OnEventHandler(object? sender, EventArgs args)
|
||||
{
|
||||
if (SidebarViewModel != null)
|
||||
SidebarViewModel.SelectedSidebarScreen = SidebarViewModel.SidebarScreens.FirstOrDefault(s => s.DisplayName == displayName);
|
||||
MainWindowOpened -= OnEventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OpenDebugger()
|
||||
@ -167,7 +173,7 @@ namespace Artemis.UI.Screens.Root
|
||||
|
||||
_lifeTime.MainWindow.WindowState = WindowState.Normal;
|
||||
_lifeTime.MainWindow.Activate();
|
||||
OnMainWindowOpened();
|
||||
OnMainWindowOpened();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user