diff --git a/MinecraftLaunch/Components/Installer/CompositionInstaller.cs b/MinecraftLaunch/Components/Installer/CompositionInstaller.cs
index 98f393f..e833b1a 100644
--- a/MinecraftLaunch/Components/Installer/CompositionInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/CompositionInstaller.cs
@@ -19,9 +19,12 @@ public sealed class CompositionInstaller : InstallerBase {
///
/// 自定义下载进度计算表达式
///
- public override Func CalculateExpression { get; set; } = x => x.ToPercentage(0.0d, 0.6d);
+ public override Func CalculateExpression { get; set; }
+ = x => x.ToPercentage(0.0d, 0.6d);
- public override GameEntry InheritedFrom { get; }
+ public event EventHandler SubInstallerCompleted;
+
+ public override GameEntry InheritedFrom { get; set; }
public CompositionInstaller(InstallerBase installerBase, string customId, OptiFineInstallEntity entity = default) {
if (installerBase is NeoForgeInstaller or QuiltInstaller) {
@@ -42,6 +45,7 @@ public CompositionInstaller(InstallerBase mainInstaller, InstallerBase subInstal
_entity = entity;
_customId = customId;
+ _subInstaller = subInstaller;
_mainInstaller = mainInstaller;
}
@@ -49,6 +53,7 @@ public override async Task InstallAsync(CancellationToken cancellation = d
_mainInstaller.ProgressChanged += OnProgressChanged;
await _mainInstaller.InstallAsync(cancellation);
+ SubInstallerCompleted?.Invoke(this, default);
if (_entity is null && _subInstaller is null) {
CalculateExpression = null;
ReportProgress(1.0d, "Installation is complete", TaskStatus.RanToCompletion);
@@ -59,11 +64,17 @@ public override async Task InstallAsync(CancellationToken cancellation = d
ReportProgress(0.6d, "Start installing the sub loader", TaskStatus.WaitingToRun);
//sub1
if (_subInstaller is not null) {
+ //handle gameEntry
+ if (_mainInstaller is VanlliaInstaller) {
+ _subInstaller.InheritedFrom = _mainInstaller.InheritedFrom;
+ }
+
CalculateExpression = x => x.ToPercentage(0.6d, 0.8d);
- _mainInstaller.ProgressChanged += OnProgressChanged;
- await _mainInstaller.InstallAsync(cancellation);
+ _subInstaller.ProgressChanged += OnProgressChanged;
+ await _subInstaller.InstallAsync(cancellation);
}
+ //sub1 end
if (_entity is null) {
CalculateExpression = null;
ReportProgress(1.0d, "Installation is complete", TaskStatus.RanToCompletion);
diff --git a/MinecraftLaunch/Components/Installer/FabricInstaller.cs b/MinecraftLaunch/Components/Installer/FabricInstaller.cs
index c183a32..112b0bb 100644
--- a/MinecraftLaunch/Components/Installer/FabricInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/FabricInstaller.cs
@@ -7,12 +7,25 @@
namespace MinecraftLaunch.Components.Installer;
-public sealed class FabricInstaller(GameEntry inheritedFrom, FabricBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) : InstallerBase {
- private readonly string _customId = customId;
- private readonly FabricBuildEntry _fabricBuildEntry = entry;
- private readonly DownloaderConfiguration _configuration = configuration;
+public sealed class FabricInstaller : InstallerBase {
+ private readonly string _customId;
+ private readonly FabricBuildEntry _fabricBuildEntry;
+ private readonly DownloaderConfiguration _configuration;
- public override GameEntry InheritedFrom => inheritedFrom;
+ public override GameEntry InheritedFrom { get; set; }
+
+ public FabricInstaller(FabricBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) {
+ _customId = customId;
+ _fabricBuildEntry = entry;
+ _configuration = configuration;
+ }
+
+ public FabricInstaller(GameEntry inheritedFrom, FabricBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) {
+ _customId = customId;
+ _fabricBuildEntry = entry;
+ _configuration = configuration;
+ InheritedFrom = inheritedFrom;
+ }
public override async Task InstallAsync(CancellationToken cancellation = default) {
/*
diff --git a/MinecraftLaunch/Components/Installer/ForgeInstaller.cs b/MinecraftLaunch/Components/Installer/ForgeInstaller.cs
index 4eee8fa..2cb7388 100644
--- a/MinecraftLaunch/Components/Installer/ForgeInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/ForgeInstaller.cs
@@ -10,13 +10,28 @@
namespace MinecraftLaunch.Components.Installer;
-public sealed class ForgeInstaller(GameEntry inheritedFrom, ForgeInstallEntry installEntry, string javaPath, string customId = default, DownloaderConfiguration configuration = default) : InstallerBase {
- private readonly string _customId = customId;
- private readonly string _javaPath = javaPath;
- private readonly ForgeInstallEntry _installEntry = installEntry;
+public sealed class ForgeInstaller : InstallerBase {
+ private readonly string _customId;
+ private readonly string _javaPath;
+ private readonly ForgeInstallEntry _installEntry;
private readonly DownloaderConfiguration _configuration = default;
- public override GameEntry InheritedFrom => inheritedFrom;
+ public ForgeInstaller(ForgeInstallEntry installEntry, string javaPath, string customId = default, DownloaderConfiguration configuration = default) {
+ _customId = customId;
+ _javaPath = javaPath;
+ _configuration = configuration;
+ _installEntry = installEntry;
+ }
+
+ public ForgeInstaller(GameEntry inheritedFrom, ForgeInstallEntry installEntry, string javaPath, string customId = default, DownloaderConfiguration configuration = default) {
+ _customId = customId;
+ _javaPath = javaPath;
+ _configuration = configuration;
+ _installEntry = installEntry;
+ InheritedFrom = inheritedFrom;
+ }
+
+ public override GameEntry InheritedFrom { get; set; }
public override async Task InstallAsync(CancellationToken cancellation = default) {
List highVersionForgeProcessors = default;
diff --git a/MinecraftLaunch/Components/Installer/InstallerBase.cs b/MinecraftLaunch/Components/Installer/InstallerBase.cs
index d306be6..a8ee25a 100644
--- a/MinecraftLaunch/Components/Installer/InstallerBase.cs
+++ b/MinecraftLaunch/Components/Installer/InstallerBase.cs
@@ -10,7 +10,7 @@ public abstract class InstallerBase : IInstaller {
public event EventHandler ProgressChanged;
- public abstract GameEntry InheritedFrom { get; }
+ public abstract GameEntry InheritedFrom { get; set; }
public virtual Func CalculateExpression { get; set; }
public abstract Task InstallAsync(CancellationToken cancellation = default);
diff --git a/MinecraftLaunch/Components/Installer/NeoForgeInstaller.cs b/MinecraftLaunch/Components/Installer/NeoForgeInstaller.cs
index 91eeb00..1786725 100644
--- a/MinecraftLaunch/Components/Installer/NeoForgeInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/NeoForgeInstaller.cs
@@ -3,7 +3,7 @@
namespace MinecraftLaunch.Components.Installer;
public sealed class NeoForgeInstaller : InstallerBase {
- public override GameEntry InheritedFrom => throw new NotImplementedException();
+ public override GameEntry InheritedFrom { get; set; }
public override Task InstallAsync(CancellationToken cancellation = default) {
throw new NotImplementedException();
diff --git a/MinecraftLaunch/Components/Installer/OptifineInstaller.cs b/MinecraftLaunch/Components/Installer/OptifineInstaller.cs
index 6d2b32f..f8f87d0 100644
--- a/MinecraftLaunch/Components/Installer/OptifineInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/OptifineInstaller.cs
@@ -21,7 +21,7 @@ public sealed class OptifineInstaller(
private readonly OptiFineInstallEntity _installEntry = installEntry;
private readonly DownloaderConfiguration _configuration = configuration;
- public override GameEntry InheritedFrom => inheritedFrom;
+ public override GameEntry InheritedFrom { get; set; } = inheritedFrom;
public override async Task InstallAsync(CancellationToken cancellation = default) {
/*
diff --git a/MinecraftLaunch/Components/Installer/QuiltInstaller.cs b/MinecraftLaunch/Components/Installer/QuiltInstaller.cs
index ad771f5..a3d2aec 100644
--- a/MinecraftLaunch/Components/Installer/QuiltInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/QuiltInstaller.cs
@@ -8,12 +8,25 @@
namespace MinecraftLaunch.Components.Installer;
-public sealed class QuiltInstaller(GameEntry inheritedFrom, QuiltBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) : InstallerBase {
- private readonly string _customId = customId;
- private readonly QuiltBuildEntry _quiltBuildEntry = entry;
- private readonly DownloaderConfiguration _configuration = configuration;
+public sealed class QuiltInstaller : InstallerBase {
+ private readonly string _customId;
+ private readonly QuiltBuildEntry _quiltBuildEntry;
+ private readonly DownloaderConfiguration _configuration;
- public override GameEntry InheritedFrom => inheritedFrom;
+ public override GameEntry InheritedFrom { get; set; }
+
+ public QuiltInstaller(QuiltBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) {
+ _configuration = configuration;
+ _quiltBuildEntry = entry;
+ _customId = customId;
+ }
+
+ public QuiltInstaller(GameEntry inheritedFrom, QuiltBuildEntry entry, string customId = default, DownloaderConfiguration configuration = default) {
+ _configuration = configuration;
+ _quiltBuildEntry = entry;
+ _customId = customId;
+ InheritedFrom = inheritedFrom;
+ }
public override async Task InstallAsync(CancellationToken cancellation = default) {
/*
diff --git a/MinecraftLaunch/Components/Installer/VanlliaInstaller.cs b/MinecraftLaunch/Components/Installer/VanlliaInstaller.cs
index b8bc464..21f7648 100644
--- a/MinecraftLaunch/Components/Installer/VanlliaInstaller.cs
+++ b/MinecraftLaunch/Components/Installer/VanlliaInstaller.cs
@@ -17,7 +17,7 @@ public sealed class VanlliaInstaller(IGameResolver gameFoloder, string gameId, D
private readonly IGameResolver _gameResolver = gameFoloder;
private readonly DownloaderConfiguration _configuration = configuration;
- public override GameEntry InheritedFrom => throw new NotSupportedException();
+ public override GameEntry InheritedFrom { get; set; }
public override async Task InstallAsync(CancellationToken cancellation = default) {
/*
@@ -62,6 +62,7 @@ await resourceChecker.MissingResources.DownloadResourceEntrysAsync(_configuratio
}, cancellation);
}
+ InheritedFrom = _gameResolver.GetGameEntity(_gameId);
ReportProgress(1.0d, "Installation is complete", TaskStatus.Canceled);
ReportCompleted();
return true;