优化 TaskListPane 的显示效果 (#4306)

Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
This commit is contained in:
Glavo
2025-08-21 16:45:07 +08:00
committed by GitHub
parent 9ee55cd17d
commit 96f2d011ca
9 changed files with 49 additions and 8 deletions

View File

@@ -50,10 +50,7 @@ import java.nio.file.FileSystem;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays; import java.util.*;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.jackhuang.hmcl.util.Lang.mapOf; import static org.jackhuang.hmcl.util.Lang.mapOf;
@@ -210,14 +207,17 @@ public final class ModpackHelper {
if (modpack.getManifest() instanceof MultiMCInstanceConfiguration) if (modpack.getManifest() instanceof MultiMCInstanceConfiguration)
return modpack.getInstallTask(profile.getDependency(), zipFile, name) return modpack.getInstallTask(profile.getDependency(), zipFile, name)
.whenComplete(Schedulers.defaultScheduler(), success, failure) .whenComplete(Schedulers.defaultScheduler(), success, failure)
.thenComposeAsync(createMultiMCPostInstallTask(profile, (MultiMCInstanceConfiguration) modpack.getManifest(), name)); .thenComposeAsync(createMultiMCPostInstallTask(profile, (MultiMCInstanceConfiguration) modpack.getManifest(), name))
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
else if (modpack.getManifest() instanceof McbbsModpackManifest) else if (modpack.getManifest() instanceof McbbsModpackManifest)
return modpack.getInstallTask(profile.getDependency(), zipFile, name) return modpack.getInstallTask(profile.getDependency(), zipFile, name)
.whenComplete(Schedulers.defaultScheduler(), success, failure) .whenComplete(Schedulers.defaultScheduler(), success, failure)
.thenComposeAsync(createMcbbsPostInstallTask(profile, (McbbsModpackManifest) modpack.getManifest(), name)); .thenComposeAsync(createMcbbsPostInstallTask(profile, (McbbsModpackManifest) modpack.getManifest(), name))
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
else else
return modpack.getInstallTask(profile.getDependency(), zipFile, name) return modpack.getInstallTask(profile.getDependency(), zipFile, name)
.whenComplete(Schedulers.javafx(), success, failure); .whenComplete(Schedulers.javafx(), success, failure)
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
} }
public static Task<Void> getUpdateTask(Profile profile, ServerModpackManifest manifest, Charset charset, String name, ModpackConfiguration<?> configuration) throws UnsupportedModpackException { public static Task<Void> getUpdateTask(Profile profile, ServerModpackManifest manifest, Charset charset, String name, ModpackConfiguration<?> configuration) throws UnsupportedModpackException {

View File

@@ -97,6 +97,7 @@ public final class TaskListPane extends StackPane {
public TaskListPane() { public TaskListPane() {
listView.setPadding(new Insets(12, 0, 0, 0)); listView.setPadding(new Insets(12, 0, 0, 0));
listView.setCellFactory(l -> new Cell()); listView.setCellFactory(l -> new Cell());
listView.setSelectionModel(null);
FXUtils.onChangeAndOperate(listView.widthProperty(), width -> { FXUtils.onChangeAndOperate(listView.widthProperty(), width -> {
double w = width.doubleValue(); double w = width.doubleValue();
cellWidth.set(w <= 12.0 ? w : w - 12.0); cellWidth.set(w <= 12.0 ? w : w - 12.0);
@@ -160,6 +161,8 @@ public final class TaskListPane extends StackPane {
if (task instanceof GameAssetDownloadTask) { if (task instanceof GameAssetDownloadTask) {
task.setName(i18n("assets.download_all")); task.setName(i18n("assets.download_all"));
} else if (task instanceof GameInstallTask) { } else if (task instanceof GameInstallTask) {
if (task.getInheritedStage() != null && task.getInheritedStage().startsWith("hmcl.install.game"))
return;
task.setName(i18n("install.installer.install", i18n("install.installer.game"))); task.setName(i18n("install.installer.install", i18n("install.installer.game")));
} else if (task instanceof ForgeNewInstallTask || task instanceof ForgeOldInstallTask) { } else if (task instanceof ForgeNewInstallTask || task instanceof ForgeOldInstallTask) {
task.setName(i18n("install.installer.install", i18n("install.installer.forge"))); task.setName(i18n("install.installer.install", i18n("install.installer.forge")));
@@ -433,6 +436,7 @@ public final class TaskListPane extends StackPane {
case "hmcl.modpack": message = i18n("install.modpack"); break; case "hmcl.modpack": message = i18n("install.modpack"); break;
case "hmcl.modpack.download": message = i18n("launch.state.modpack"); break; case "hmcl.modpack.download": message = i18n("launch.state.modpack"); break;
case "hmcl.install.assets": message = i18n("assets.download"); break; case "hmcl.install.assets": message = i18n("assets.download"); break;
case "hmcl.install.libraries": message = i18n("libraries.download"); break;
case "hmcl.install.game": message = i18n("install.installer.install", i18n("install.installer.game") + " " + stageValue); break; case "hmcl.install.game": message = i18n("install.installer.install", i18n("install.installer.game") + " " + stageValue); break;
case "hmcl.install.forge": message = i18n("install.installer.install", i18n("install.installer.forge") + " " + stageValue); break; case "hmcl.install.forge": message = i18n("install.installer.install", i18n("install.installer.forge") + " " + stageValue); break;
case "hmcl.install.neoforge": message = i18n("install.installer.install", i18n("install.installer.neoforge") + " " + stageValue); break; case "hmcl.install.neoforge": message = i18n("install.installer.install", i18n("install.installer.neoforge") + " " + stageValue); break;

View File

@@ -85,6 +85,7 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
ret = ret.thenComposeAsync(version -> dependencyManager.installLibraryAsync(version, remoteVersion)); ret = ret.thenComposeAsync(version -> dependencyManager.installLibraryAsync(version, remoteVersion));
stages.add(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion())); stages.add(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion()));
if ("game".equals(remoteVersion.getLibraryId())) { if ("game".equals(remoteVersion.getLibraryId())) {
stages.add("hmcl.install.libraries");
stages.add("hmcl.install.assets"); stages.add("hmcl.install.assets");
} }
} else if (value instanceof RemoveVersionAction) { } else if (value instanceof RemoveVersionAction) {

View File

@@ -77,6 +77,10 @@ public final class ExportWizardProvider implements WizardProvider {
File tempModpack; File tempModpack;
Task<?> exportTask; Task<?> exportTask;
{
setSignificance(TaskSignificance.MODERATE);
}
@Override @Override
public boolean doPreExecute() { public boolean doPreExecute() {
return true; return true;
@@ -165,6 +169,10 @@ public final class ExportWizardProvider implements WizardProvider {
return new Task<Void>() { return new Task<Void>() {
Task<?> dependency = null; Task<?> dependency = null;
{
setSignificance(TaskSignificance.MODERATE);
}
@Override @Override
public void execute() { public void execute() {
dependency = new McbbsModpackExportTask(profile.getRepository(), version, exportInfo, modpackFile); dependency = new McbbsModpackExportTask(profile.getRepository(), version, exportInfo, modpackFile);
@@ -181,6 +189,10 @@ public final class ExportWizardProvider implements WizardProvider {
return new Task<Void>() { return new Task<Void>() {
Task<?> dependency; Task<?> dependency;
{
setSignificance(TaskSignificance.MODERATE);
}
@Override @Override
public void execute() { public void execute() {
VersionSetting vs = profile.getVersionSetting(version); VersionSetting vs = profile.getVersionSetting(version);
@@ -225,6 +237,10 @@ public final class ExportWizardProvider implements WizardProvider {
return new Task<Void>() { return new Task<Void>() {
Task<?> dependency; Task<?> dependency;
{
setSignificance(TaskSignificance.MODERATE);
}
@Override @Override
public void execute() { public void execute() {
dependency = new ServerModpackExportTask(profile.getRepository(), version, exportInfo, modpackFile); dependency = new ServerModpackExportTask(profile.getRepository(), version, exportInfo, modpackFile);
@@ -241,6 +257,10 @@ public final class ExportWizardProvider implements WizardProvider {
return new Task<Void>() { return new Task<Void>() {
Task<?> dependency; Task<?> dependency;
{
setSignificance(TaskSignificance.MODERATE);
}
@Override @Override
public void execute() { public void execute() {
dependency = new ModrinthModpackExportTask( dependency = new ModrinthModpackExportTask(

View File

@@ -827,6 +827,8 @@ launcher.crash.java_internal_error=Hello Minecraft! Launcher has encountered a f
launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher has encountered a fatal error! Your launcher is outdated. Please update your launcher! launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher has encountered a fatal error! Your launcher is outdated. Please update your launcher!
launcher.update_java=Please update your Java version. launcher.update_java=Please update your Java version.
libraries.download=Downloading Libraries
login.empty_username=You have not set your username yet! login.empty_username=You have not set your username yet!
login.enter_password=Please enter your password. login.enter_password=Please enter your password.

View File

@@ -643,6 +643,8 @@ launcher.crash.java_internal_error=Hello Minecraft! Launcher 由於目前 Java
launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher 遇到了無法處理的錯誤。已偵測到你的啟動器不是最新版本,請更新後重試! launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher 遇到了無法處理的錯誤。已偵測到你的啟動器不是最新版本,請更新後重試!
launcher.update_java=請更新你的 Java launcher.update_java=請更新你的 Java
libraries.download=下載依賴庫
login.empty_username=你還未設定使用者名稱! login.empty_username=你還未設定使用者名稱!
login.enter_password=請輸入你的密碼 login.enter_password=請輸入你的密碼

View File

@@ -653,6 +653,8 @@ launcher.crash.java_internal_error=Hello Minecraft! Launcher 由于当前 Java
launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher 遇到了无法处理的错误。已检测到你的启动器不是最新版本,请更新后再试。 launcher.crash.hmcl_out_dated=Hello Minecraft! Launcher 遇到了无法处理的错误。已检测到你的启动器不是最新版本,请更新后再试。
launcher.update_java=请更新你的 Java。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 launcher.update_java=请更新你的 Java。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
libraries.download=下载依赖库
login.empty_username=你还未设置用户名! login.empty_username=你还未设置用户名!
login.enter_password=请输入你的密码 login.enter_password=请输入你的密码

View File

@@ -48,6 +48,7 @@ public class DefaultGameBuilder extends GameBuilder {
Task<Version> libraryTask = Task.supplyAsync(() -> new Version(name)); Task<Version> libraryTask = Task.supplyAsync(() -> new Version(name));
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "game", gameVersion)); libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "game", gameVersion));
stages.add("hmcl.install.game:" + gameVersion); stages.add("hmcl.install.game:" + gameVersion);
stages.add("hmcl.install.libraries");
stages.add("hmcl.install.assets"); stages.add("hmcl.install.assets");
for (Map.Entry<String, String> entry : toolVersions.entrySet()) { for (Map.Entry<String, String> entry : toolVersions.entrySet()) {

View File

@@ -75,6 +75,7 @@ public final class GameLibrariesTask extends Task<Void> {
this.integrityCheck = integrityCheck; this.integrityCheck = integrityCheck;
this.libraries = libraries; this.libraries = libraries;
setStage("hmcl.install.libraries");
setSignificance(TaskSignificance.MODERATE); setSignificance(TaskSignificance.MODERATE);
} }
@@ -115,6 +116,7 @@ public final class GameLibrariesTask extends Task<Void> {
@Override @Override
public void execute() throws IOException { public void execute() throws IOException {
int progress = 0;
GameRepository gameRepository = dependencyManager.getGameRepository(); GameRepository gameRepository = dependencyManager.getGameRepository();
for (Library library : libraries) { for (Library library : libraries) {
if (!library.appliesToCurrentEnvironment()) { if (!library.appliesToCurrentEnvironment()) {
@@ -135,10 +137,17 @@ public final class GameLibrariesTask extends Task<Void> {
} }
} }
if (shouldDownloadLibrary(gameRepository, version, library, integrityCheck) && (library.hasDownloadURL() || !"optifine".equals(library.getGroupId()))) { if (shouldDownloadLibrary(gameRepository, version, library, integrityCheck) && (library.hasDownloadURL() || !"optifine".equals(library.getGroupId()))) {
dependencies.add(new LibraryDownloadTask(dependencyManager, file, library)); dependencies.add(new LibraryDownloadTask(dependencyManager, file, library).withCounter("hmcl.install.libraries"));
} else { } else {
dependencyManager.getCacheRepository().tryCacheLibrary(library, file.toPath()); dependencyManager.getCacheRepository().tryCacheLibrary(library, file.toPath());
} }
updateProgress(++progress, libraries.size());
}
if (!dependencies.isEmpty()) {
getProperties().put("total", dependencies.size());
notifyPropertiesChanged();
} }
} }