mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 00:36:10 -04:00
feat: show java version detection progress when launching game.
This commit is contained in:
parent
36d1096976
commit
e01c31fb1d
@ -63,7 +63,7 @@ import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
||||
@ -104,17 +104,12 @@ public final class LauncherHelper {
|
||||
}
|
||||
|
||||
public void launch() {
|
||||
FXUtils.checkFxUserThread();
|
||||
|
||||
Logging.LOG.info("Launching game version: " + selectedVersion);
|
||||
|
||||
GameRepository repository = profile.getRepository();
|
||||
Version version = repository.getResolvedVersion(selectedVersion);
|
||||
|
||||
Platform.runLater(() -> {
|
||||
checkGameState(profile, setting, version, javaVersion -> {
|
||||
Controllers.dialog(launchingStepsPane);
|
||||
Schedulers.defaultScheduler().execute(() -> launch0(javaVersion));
|
||||
});
|
||||
});
|
||||
Controllers.dialog(launchingStepsPane);
|
||||
launch0();
|
||||
}
|
||||
|
||||
public void makeLaunchScript(File scriptFile) {
|
||||
@ -123,7 +118,7 @@ public final class LauncherHelper {
|
||||
launch();
|
||||
}
|
||||
|
||||
private void launch0(JavaVersion javaVersion) {
|
||||
private void launch0() {
|
||||
HMCLGameRepository repository = profile.getRepository();
|
||||
DefaultDependencyManager dependencyManager = profile.getDependency();
|
||||
Version version = MaintainTask.maintain(repository, repository.getResolvedVersion(selectedVersion));
|
||||
@ -131,7 +126,13 @@ public final class LauncherHelper {
|
||||
boolean integrityCheck = repository.unmarkVersionLaunchedAbnormally(selectedVersion);
|
||||
CountDownLatch launchingLatch = new CountDownLatch(1);
|
||||
|
||||
TaskExecutor executor = dependencyManager.checkPatchCompletionAsync(repository.getVersion(selectedVersion), integrityCheck)
|
||||
AtomicReference<JavaVersion> javaVersionRef = new AtomicReference<>();
|
||||
|
||||
TaskExecutor executor = checkGameState(profile, setting, version)
|
||||
.thenComposeAsync(javaVersion -> {
|
||||
javaVersionRef.set(Objects.requireNonNull(javaVersion));
|
||||
return dependencyManager.checkPatchCompletionAsync(repository.getVersion(selectedVersion), integrityCheck);
|
||||
})
|
||||
.thenComposeAsync(Task.allOf(
|
||||
Task.composeAsync(() -> {
|
||||
if (setting.isNotCheckGame())
|
||||
@ -172,7 +173,7 @@ public final class LauncherHelper {
|
||||
}
|
||||
}).withStage("launch.state.logging_in"))
|
||||
.thenComposeAsync(authInfo -> Task.supplyAsync(() -> {
|
||||
LaunchOptions launchOptions = repository.getLaunchOptions(selectedVersion, javaVersion, profile.getGameDir());
|
||||
LaunchOptions launchOptions = repository.getLaunchOptions(selectedVersion, javaVersionRef.get(), profile.getGameDir());
|
||||
return new HMCLGameLauncher(
|
||||
repository,
|
||||
version,
|
||||
@ -211,6 +212,7 @@ public final class LauncherHelper {
|
||||
launchingLatch.await();
|
||||
}).withStage("launch.state.waiting_launching"))
|
||||
.withStagesHint(Lang.immutableListOf(
|
||||
"launch.state.java",
|
||||
"launch.state.dependencies",
|
||||
"launch.state.logging_in",
|
||||
"launch.state.waiting_launching"))
|
||||
@ -298,19 +300,16 @@ public final class LauncherHelper {
|
||||
executor.start();
|
||||
}
|
||||
|
||||
private static void checkGameState(Profile profile, VersionSetting setting, Version version, Consumer<JavaVersion> onAccept) {
|
||||
private static Task<JavaVersion> checkGameState(Profile profile, VersionSetting setting, Version version) {
|
||||
VersionNumber gameVersion = VersionNumber.asVersion(profile.getRepository().getGameVersion(version).orElse("Unknown"));
|
||||
|
||||
if (setting.isNotCheckJVM()) {
|
||||
Task.composeAsync(() -> {
|
||||
return setting.getJavaVersion(gameVersion, version);
|
||||
}).thenAcceptAsync(javaVersion -> {
|
||||
onAccept.accept(Optional.ofNullable(javaVersion).orElseGet(JavaVersion::fromCurrentEnvironment));
|
||||
}).start();
|
||||
return;
|
||||
return Task.composeAsync(() -> setting.getJavaVersion(gameVersion, version))
|
||||
.thenApplyAsync(javaVersion -> Optional.ofNullable(javaVersion).orElseGet(JavaVersion::fromCurrentEnvironment))
|
||||
.withStage("launch.state.java");
|
||||
}
|
||||
|
||||
Task.composeAsync(() -> {
|
||||
return Task.composeAsync(() -> {
|
||||
return setting.getJavaVersion(gameVersion, version);
|
||||
}).thenComposeAsync(Schedulers.javafx(), javaVersion -> {
|
||||
// Reset invalid java version
|
||||
@ -493,13 +492,7 @@ public final class LauncherHelper {
|
||||
}
|
||||
|
||||
return Task.fromCompletableFuture(future);
|
||||
}).thenAcceptAsync(Schedulers.javafx(), javaVersion -> {
|
||||
if (javaVersion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
onAccept.accept(javaVersion);
|
||||
}).start();
|
||||
}).withStage("launch.state.java");
|
||||
}
|
||||
|
||||
private static CompletableFuture<Void> downloadJava(GameJavaVersion javaVersion, Profile profile) {
|
||||
|
@ -21,7 +21,10 @@ import org.jackhuang.hmcl.event.Event;
|
||||
import org.jackhuang.hmcl.util.gson.JsonSubtype;
|
||||
import org.jackhuang.hmcl.util.gson.JsonType;
|
||||
|
||||
public class MultiplayerChannel {
|
||||
public final class MultiplayerChannel {
|
||||
|
||||
private MultiplayerChannel() {
|
||||
}
|
||||
|
||||
@JsonType(
|
||||
property = "type",
|
||||
|
@ -345,6 +345,7 @@ game.crash.reason.mod=Game crashed because of the mod: %1$s.\nYou may update or
|
||||
game.crash.reason.mod_resolution=Game crashed because of mod resolution failure.\nFabric gives following information:\n%s
|
||||
game.crash.reason.mod_resolution_conflict=Game crashed because of conflicted mods.\n%1$s conflicts with %2$s.
|
||||
game.crash.reason.mod_resolution_missing=Game crashed because the mod that some mod depends on is not installed.\n%1$s requires mod to be installed: %2$s.\nThis means that you need to download %2$s from the download page or online websites.
|
||||
game.crash.reason.mod_resolution_missing_minecraft=Game crashed because a mod is incompatible with current Minecraft version.\n%1$s requires Minecraft version %2$s。\nIf you want to keep the installed version of the mod, you should change the game version.\nIf you want to continue using current game version, you should reinstall a suitable mod.
|
||||
game.crash.reason.mod_resolution_mod_version=%1$s (Version: %2$s)
|
||||
game.crash.reason.mod_resolution_mod_version.any=%1$s (Any version)
|
||||
game.crash.reason.no_class_def_found_error=Game cannot run because of incomplete code.\nYour game may be missing a mod, or some mod files may be incomplete.\nYou may need to reinstall the game and mods, or ask for help.\nMissing %1$s
|
||||
@ -434,6 +435,7 @@ launch.failed.exited_abnormally=Game exited abnormally, please check the log, or
|
||||
launch.failed.no_accepted_java=Cannot find the Java installation suitable for current game. If you think you have installed a suitable Java VM, you can manually select it in game settings.
|
||||
launch.state.dependencies=Dependencies
|
||||
launch.state.done=Done
|
||||
launch.state.java=Detect Java Version
|
||||
launch.state.logging_in=Logging In
|
||||
launch.state.modpack=Loading modpack
|
||||
launch.state.waiting_launching=Launching Game
|
||||
|
@ -345,6 +345,7 @@ game.crash.reason.mod=當前遊戲因為 %1$s 的問題,無法繼續運行。\
|
||||
game.crash.reason.mod_resolution=當前遊戲因為 Mod 依賴問題,無法繼續運行。Fabric 提供了如下訊息:\n%1$s
|
||||
game.crash.reason.mod_resolution_conflict=當前遊戲因為 Mod 衝突,無法繼續運行。\n%1$s 與 %2$s 不能相容。
|
||||
game.crash.reason.mod_resolution_missing=當前遊戲因為缺少 Mod 前置,無法繼續運行。\n%1$s 需要前置 Mod:%2$s 才能繼續運行。\n這表示你少安裝了 Mod,或該 Mod 版本不夠。你可以到下載頁的模組下載,或到網路上下載 %2$s。
|
||||
game.crash.reason.mod_resolution_missing_minecraft=當前遊戲因為 Mod 和 Minecraft 遊戲版本不匹配,無法繼續運行。\n%1$s 需要 Minecraft %2$s 才能運行。\n如果你要繼續使用你已經安裝的 Mod,你可以選擇安裝對應的 Minecraft 版本;如果你要繼續使用當前 Minecraft 版本,你需要安裝對應版本的 Mod。
|
||||
game.crash.reason.mod_resolution_mod_version=%1$s (版本號 %2$s)
|
||||
game.crash.reason.mod_resolution_mod_version.any=%1$s (任意版本)
|
||||
game.crash.reason.no_class_def_found_error=當前遊戲因為代碼不完整,無法繼續運行。\n你的遊戲可能缺失了某個 Mod,或者某些 Mod 檔案不完整。\n你可能需要重新安裝遊戲和 Mod,或請求他人幫助。\n缺失:%1$s
|
||||
@ -434,6 +435,7 @@ launch.failed.exited_abnormally=遊戲非正常退出,請查看記錄檔案,
|
||||
launch.failed.no_accepted_java=找不到適合當前遊戲使用的 Java。如果您認為實際存在合適的 Java,您可以在遊戲設置中手動設置 Java。
|
||||
launch.state.dependencies=處理遊戲相依元件
|
||||
launch.state.done=啟動完成
|
||||
launch.state.java=檢測 Java 版本
|
||||
launch.state.logging_in=登入
|
||||
launch.state.modpack=下載必要檔案
|
||||
launch.state.waiting_launching=等待遊戲啟動
|
||||
|
@ -435,6 +435,7 @@ launch.failed.exited_abnormally=游戏非正常退出,请查看日志文件,
|
||||
launch.failed.no_accepted_java=找不到适合当前游戏使用的 Java。如果您认为实际存在合适的 Java,您可以在游戏设置中手动设置 Java。
|
||||
launch.state.dependencies=处理游戏依赖
|
||||
launch.state.done=启动完成
|
||||
launch.state.java=检测 Java 版本
|
||||
launch.state.logging_in=登录
|
||||
launch.state.modpack=下载必要文件
|
||||
launch.state.waiting_launching=等待游戏启动
|
||||
@ -846,14 +847,14 @@ update.accept=更新
|
||||
update.changelog=更新日志
|
||||
update.channel.dev=测试版
|
||||
update.channel.dev.hint=你正在使用测试版。测试版包含一些未在正式版中包含的测试性功能,仅用于体验新功能。\n\
|
||||
测试版功能未受充分验证,使用起来可能不稳定!\n\
|
||||
测试版功能未受充分验证,使用起来可能不稳定!<a href="https://hmcl.huangyuhui.net/download">下载稳定版</a>\n\
|
||||
如果你遇到了使用问题,可以在设置的 <a href="hmcl://settings/feedback">反馈页面</a> 中进行反馈,或加入反馈页面中提供的 <a href="https://discord.gg/jVvC7HfM6U">Discord</a> 或 <a href="https://kaihei.co/Kx7n3t">开黑啦</a>群以反馈问题。\n\n\
|
||||
你需要 <a href="https://hmcl.huangyuhui.net/api/redirect/sponsor">赞助</a> 或在反馈过程中作出贡献以隐藏本提示。
|
||||
update.channel.dev.title=测试版提示
|
||||
update.channel.dev.update=更新到开发版
|
||||
update.channel.nightly=预览版
|
||||
update.channel.nightly.hint=你正在使用预览版。预览版可能会每天更新一次,包含一些未在正式版和测试版中包含的测试性功能,仅用于体验新功能。\n\
|
||||
测试版功能未受充分验证,使用起来可能不稳定!\n\
|
||||
测试版功能未受充分验证,使用起来可能不稳定!<a href="https://hmcl.huangyuhui.net/download">下载稳定版</a>\n\
|
||||
如果你遇到了使用问题,可以在设置的 <a href="hmcl://settings/feedback">反馈页面</a> 中进行反馈,或加入反馈页面中提供的 <a href="https://discord.gg/jVvC7HfM6U">Discord</a> 或 <a href="https://kaihei.co/Kx7n3t">开黑啦</a>群以反馈问题。\n\n\
|
||||
你需要 <a href="https://hmcl.huangyuhui.net/api/redirect/sponsor">赞助</a> 或在反馈过程中作出贡献以隐藏本提示。
|
||||
update.channel.nightly.title=预览版提示
|
||||
|
Loading…
x
Reference in New Issue
Block a user