diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerItem.java index 345f87760..21efe1c30 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerItem.java @@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui; import com.jfoenix.controls.JFXButton; import com.jfoenix.effects.JFXDepthManager; import javafx.geometry.Pos; +import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import org.jackhuang.hmcl.setting.Theme; @@ -40,11 +41,16 @@ public class InstallerItem extends BorderPane { setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;"); JFXDepthManager.setDepth(this, 1); - { + if (version != null) { TwoLineListItem item = new TwoLineListItem(); item.setTitle(artifact); item.setSubtitle(i18n("archive.version") + ": " + version); setCenter(item); + } else { + Label label = new Label(artifact); + label.setStyle("-fx-font-size: 15px;"); + BorderPane.setAlignment(label, Pos.CENTER_LEFT); + setCenter(label); } { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameItem.java index ebafffe23..569451823 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameItem.java @@ -28,6 +28,7 @@ import javafx.scene.image.Image; import org.jackhuang.hmcl.download.LibraryAnalyzer; import org.jackhuang.hmcl.game.GameVersion; import org.jackhuang.hmcl.setting.Profile; +import org.jackhuang.hmcl.util.i18n.I18n; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; @@ -57,12 +58,13 @@ public class GameItem extends Control { CompletableFuture.supplyAsync(() -> GameVersion.minecraftVersion(profile.getRepository().getVersionJar(id)).orElse(i18n("message.unknown")), POOL_VERSION_RESOLVE) .thenAcceptAsync(game -> { StringBuilder libraries = new StringBuilder(game); - LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedVersion(id)); - for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) - analyzer.getVersion(type).ifPresent(library -> - libraries - .append(", ").append(i18n("install.installer." + type.name().toLowerCase())) - .append(": ").append(modifyVersion(game, library.replaceAll("(?i)" + type.name().toLowerCase(), "")))); + LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedPreservingPatchesVersion(id)); + analyzer.forEachLibrary((libraryId, libraryVersion) -> { + if (I18n.hasKey("install.installer." + libraryId)) + libraries + .append(", ").append(i18n("install.installer." + libraryId)) + .append(": ").append(modifyVersion(game, libraryVersion.replaceAll("(?i)" + libraryId, ""))); + }); subtitle.set(libraries.toString()); }, Platform::runLater) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/InstallerListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/InstallerListPage.java index b85560375..aed1b4117 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/InstallerListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/InstallerListPage.java @@ -36,6 +36,8 @@ import org.jackhuang.hmcl.ui.SVG; import org.jackhuang.hmcl.ui.ToolbarListPageSkin; import org.jackhuang.hmcl.ui.download.InstallerWizardProvider; import org.jackhuang.hmcl.ui.download.UpdateInstallerWizardProvider; +import org.jackhuang.hmcl.util.Lang; +import org.jackhuang.hmcl.util.i18n.I18n; import org.jackhuang.hmcl.util.io.FileUtils; import java.io.File; @@ -74,7 +76,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> { Task.supplyAsync(() -> { gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version)).orElse(null); - return LibraryAnalyzer.analyze(profile.getRepository().getResolvedVersion(versionId)); + return LibraryAnalyzer.analyze(profile.getRepository().getResolvedPreservingPatchesVersion(versionId)); }).thenAcceptAsync(Schedulers.javafx(), analyzer -> { Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> { profile.getDependency().removeLibraryAsync(version.getId(), libraryId) @@ -84,13 +86,16 @@ public class InstallerListPage extends ListPageBase<InstallerItem> { }; itemsProperty().clear(); - for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) { - String libraryId = type.getPatchId(); - analyzer.getVersion(type).ifPresent(libraryVersion -> itemsProperty().add( - new InstallerItem(i18n("install.installer." + libraryId), libraryVersion, () -> { + analyzer.forEachLibrary((libraryId, libraryVersion) -> { + String title = I18n.hasKey("install.installer." + libraryId) ? i18n("install.installer." + libraryId) : libraryId; + if (Lang.test(() -> profile.getDependency().getVersionList(libraryId))) + itemsProperty().add( + new InstallerItem(title, libraryVersion, () -> { Controllers.getDecorator().startWizard(new UpdateInstallerWizardProvider(profile, gameVersion, version, libraryId, libraryVersion)); - }, removeAction.apply(libraryId)))); - } + }, removeAction.apply(libraryId))); + else + itemsProperty().add(new InstallerItem(title, libraryVersion, null, removeAction.apply(libraryId))); + }); }).start(); } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DownloadProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DownloadProvider.java index 19c222c2f..8c3f2a564 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DownloadProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DownloadProvider.java @@ -44,6 +44,7 @@ public interface DownloadProvider { * * @param id the id of specific version list that this download provider provides. i.e. "forge", "liteloader", "game", "optifine" * @return the version list + * @throws IllegalArgumentException if the version list does not exist */ VersionList<?> getVersionListById(String id); }