mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +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>
|
/// <summary>
|
||||||
/// The base path for Artemis application data folder
|
/// The base path for Artemis application data folder
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// The full path to the Artemis data folder
|
/// The full path to the Artemis data folder
|
||||||
@ -54,6 +56,11 @@ namespace Artemis.Core
|
|||||||
/// The full path to the Artemis user layouts folder
|
/// The full path to the Artemis user layouts folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string LayoutsFolder = Path.Combine(DataFolder, "User Layouts");
|
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>
|
/// <summary>
|
||||||
/// The plugin info used by core components of Artemis
|
/// The plugin info used by core components of Artemis
|
||||||
|
|||||||
@ -25,6 +25,7 @@ namespace Artemis.Core
|
|||||||
private Version _version = null!;
|
private Version _version = null!;
|
||||||
private bool _requiresAdmin;
|
private bool _requiresAdmin;
|
||||||
private PluginPlatform? _platforms;
|
private PluginPlatform? _platforms;
|
||||||
|
private Version? _api;
|
||||||
|
|
||||||
internal PluginInfo()
|
internal PluginInfo()
|
||||||
{
|
{
|
||||||
@ -150,7 +151,17 @@ namespace Artemis.Core
|
|||||||
public PluginPlatform? Platforms
|
public PluginPlatform? Platforms
|
||||||
{
|
{
|
||||||
get => _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>
|
/// <summary>
|
||||||
@ -176,9 +187,9 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </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)}";
|
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)
|
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();
|
OpenMainWindow();
|
||||||
|
|
||||||
// At this point there is a sidebar VM because the main window was opened
|
void OnEventHandler(object? sender, EventArgs args)
|
||||||
SidebarViewModel!.SelectedSidebarScreen = SidebarViewModel.SidebarScreens.FirstOrDefault(s => s.DisplayName == displayName);
|
{
|
||||||
|
if (SidebarViewModel != null)
|
||||||
|
SidebarViewModel.SelectedSidebarScreen = SidebarViewModel.SidebarScreens.FirstOrDefault(s => s.DisplayName == displayName);
|
||||||
|
MainWindowOpened -= OnEventHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OpenDebugger()
|
public async Task OpenDebugger()
|
||||||
@ -167,7 +173,7 @@ namespace Artemis.UI.Screens.Root
|
|||||||
|
|
||||||
_lifeTime.MainWindow.WindowState = WindowState.Normal;
|
_lifeTime.MainWindow.WindowState = WindowState.Normal;
|
||||||
_lifeTime.MainWindow.Activate();
|
_lifeTime.MainWindow.Activate();
|
||||||
OnMainWindowOpened();
|
OnMainWindowOpened();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user