From 7e2b48e71cd95c6d1815f34b38ca3ab7424a6ba3 Mon Sep 17 00:00:00 2001 From: AlphaBs Date: Sun, 5 Sep 2021 00:09:17 +0900 Subject: [PATCH] add checkAndDownload option CMLauncher.CreateProcess --- CmlLib/Core/CMLauncher.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/CmlLib/Core/CMLauncher.cs b/CmlLib/Core/CMLauncher.cs index 603fb9a..d493dd4 100644 --- a/CmlLib/Core/CMLauncher.cs +++ b/CmlLib/Core/CMLauncher.cs @@ -179,6 +179,7 @@ public async Task CheckAndDownloadAsync(MVersion version) } } + // not stable public Process CreateProcess(string mcversion, string forgeversion, MLaunchOption option) { CheckAndDownload(GetVersion(mcversion)); @@ -188,27 +189,35 @@ public Process CreateProcess(string mcversion, string forgeversion, MLaunchOptio return CreateProcess(versionName, option); } - public Process CreateProcess(string versionName, MLaunchOption option) - => CreateProcess(GetVersion(versionName), option); + public Process CreateProcess(string versionName, MLaunchOption option, bool checkAndDownload=true) + => CreateProcess(GetVersion(versionName), option, checkAndDownload); [MethodTimer.Time] - public Process CreateProcess(MVersion version, MLaunchOption option) + public Process CreateProcess(MVersion version, MLaunchOption option, bool checkAndDownload=true) { option.StartVersion = version; - CheckAndDownload(option.StartVersion); + + if (checkAndDownload) + CheckAndDownload(option.StartVersion); + return CreateProcess(option); } - public async Task CreateProcessAsync(string versionName, MLaunchOption option) + public async Task CreateProcessAsync(string versionName, MLaunchOption option, + bool checkAndDownload=true) { var version = await GetVersionAsync(versionName).ConfigureAwait(false); - return await CreateProcessAsync(version, option).ConfigureAwait(false); + return await CreateProcessAsync(version, option, checkAndDownload).ConfigureAwait(false); } - public async Task CreateProcessAsync(MVersion version, MLaunchOption option) + public async Task CreateProcessAsync(MVersion version, MLaunchOption option, + bool checkAndDownload=true) { option.StartVersion = version; - await CheckAndDownloadAsync(option.StartVersion).ConfigureAwait(false); + + if (checkAndDownload) + await CheckAndDownloadAsync(option.StartVersion).ConfigureAwait(false); + return await CreateProcessAsync(option).ConfigureAwait(false); }