diff --git a/CringeLauncher/Launcher.cs b/CringeLauncher/Launcher.cs index 3b80268..5c65688 100644 --- a/CringeLauncher/Launcher.cs +++ b/CringeLauncher/Launcher.cs @@ -46,7 +46,7 @@ public class Launcher : ICorePlugin private const uint AppId = 244850U; private SpaceEngineersGame? _game; private readonly Harmony _harmony = new("CringeBootstrap"); - private PluginsLifetime? _lifetime; + private IPluginsLifetime? _lifetime; private MyGameRenderComponent? _renderComponent; @@ -93,7 +93,7 @@ public class Launcher : ICorePlugin var serviceProvider = SetupServices(); - splash.DefineStage(_lifetime = serviceProvider.GetRequiredService()); + splash.DefineStage(_lifetime = serviceProvider.GetRequiredService()); InitTexts(); SpaceEngineersGame.SetupBasicGameInfo(); @@ -166,6 +166,7 @@ public class Launcher : ICorePlugin .AddPolicyHandler(HttpPolicyExtensions.HandleTransientHttpError().WaitAndRetryAsync(5, _ => TimeSpan.FromSeconds(1))); services.AddSingleton(_ => RenderHandler.Current) + .AddSingleton(s => s.GetRequiredService()) .AddSingleton(_ => new ConfigHandler(Directory.CreateDirectory(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher", "config")))); return GameServicesExtension.GameServices = services.BuildServiceProvider(); diff --git a/CringePlugins/Loader/IPluginsLifetime.cs b/CringePlugins/Loader/IPluginsLifetime.cs new file mode 100644 index 0000000..b3ae672 --- /dev/null +++ b/CringePlugins/Loader/IPluginsLifetime.cs @@ -0,0 +1,8 @@ +using CringePlugins.Splash; + +namespace CringePlugins.Loader; + +internal interface IPluginsLifetime : ILoadingStage +{ + void RegisterLifetime(); +} \ No newline at end of file diff --git a/CringePlugins/Loader/PluginsLifetime.cs b/CringePlugins/Loader/PluginsLifetime.cs index d32f46c..9413cee 100644 --- a/CringePlugins/Loader/PluginsLifetime.cs +++ b/CringePlugins/Loader/PluginsLifetime.cs @@ -1,6 +1,5 @@ using System.Collections.Immutable; using System.Runtime.InteropServices; -using System.Text.Json; using CringePlugins.Config; using CringePlugins.Render; using CringePlugins.Resolver; @@ -11,13 +10,12 @@ using NuGet; using NuGet.Deps; using NuGet.Frameworks; using NuGet.Models; -using NuGet.Versioning; using SharedCringe.Loader; using VRage.FileSystem; namespace CringePlugins.Loader; -public class PluginsLifetime(ConfigHandler configHandler, HttpClient client) : ILoadingStage +internal class PluginsLifetime(ConfigHandler configHandler, HttpClient client) : IPluginsLifetime { public static ImmutableArray Contexts { get; private set; } = []; @@ -26,7 +24,6 @@ public class PluginsLifetime(ConfigHandler configHandler, HttpClient client) : I public string Name => "Loading Plugins"; private ImmutableArray _plugins = []; - // TODO move this as api for other plugins private readonly DirectoryInfo _dir = Directory.CreateDirectory(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher")); private readonly NuGetRuntimeFramework _runtimeFramework = new(NuGetFramework.ParseFolder("net9.0-windows10.0.19041.0"), RuntimeInformation.RuntimeIdentifier);