Show unrecognized patches in InstallerListPage

This commit is contained in:
huanghongxun
2019-08-19 00:17:03 +08:00
parent 60fa4eb0a1
commit fb24516b90
4 changed files with 28 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
import com.jfoenix.effects.JFXDepthManager; import com.jfoenix.effects.JFXDepthManager;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import org.jackhuang.hmcl.setting.Theme; 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;"); setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;");
JFXDepthManager.setDepth(this, 1); JFXDepthManager.setDepth(this, 1);
{ if (version != null) {
TwoLineListItem item = new TwoLineListItem(); TwoLineListItem item = new TwoLineListItem();
item.setTitle(artifact); item.setTitle(artifact);
item.setSubtitle(i18n("archive.version") + ": " + version); item.setSubtitle(i18n("archive.version") + ": " + version);
setCenter(item); setCenter(item);
} else {
Label label = new Label(artifact);
label.setStyle("-fx-font-size: 15px;");
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
setCenter(label);
} }
{ {

View File

@@ -28,6 +28,7 @@ import javafx.scene.image.Image;
import org.jackhuang.hmcl.download.LibraryAnalyzer; import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.game.GameVersion; import org.jackhuang.hmcl.game.GameVersion;
import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.util.i18n.I18n;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor; 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) CompletableFuture.supplyAsync(() -> GameVersion.minecraftVersion(profile.getRepository().getVersionJar(id)).orElse(i18n("message.unknown")), POOL_VERSION_RESOLVE)
.thenAcceptAsync(game -> { .thenAcceptAsync(game -> {
StringBuilder libraries = new StringBuilder(game); StringBuilder libraries = new StringBuilder(game);
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedVersion(id)); LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedPreservingPatchesVersion(id));
for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) analyzer.forEachLibrary((libraryId, libraryVersion) -> {
analyzer.getVersion(type).ifPresent(library -> if (I18n.hasKey("install.installer." + libraryId))
libraries libraries
.append(", ").append(i18n("install.installer." + type.name().toLowerCase())) .append(", ").append(i18n("install.installer." + libraryId))
.append(": ").append(modifyVersion(game, library.replaceAll("(?i)" + type.name().toLowerCase(), "")))); .append(": ").append(modifyVersion(game, libraryVersion.replaceAll("(?i)" + libraryId, "")));
});
subtitle.set(libraries.toString()); subtitle.set(libraries.toString());
}, Platform::runLater) }, Platform::runLater)

View File

@@ -36,6 +36,8 @@ import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.ToolbarListPageSkin; import org.jackhuang.hmcl.ui.ToolbarListPageSkin;
import org.jackhuang.hmcl.ui.download.InstallerWizardProvider; import org.jackhuang.hmcl.ui.download.InstallerWizardProvider;
import org.jackhuang.hmcl.ui.download.UpdateInstallerWizardProvider; 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 org.jackhuang.hmcl.util.io.FileUtils;
import java.io.File; import java.io.File;
@@ -74,7 +76,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
Task.supplyAsync(() -> { Task.supplyAsync(() -> {
gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version)).orElse(null); 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 -> { }).thenAcceptAsync(Schedulers.javafx(), analyzer -> {
Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> { Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> {
profile.getDependency().removeLibraryAsync(version.getId(), libraryId) profile.getDependency().removeLibraryAsync(version.getId(), libraryId)
@@ -84,13 +86,16 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
}; };
itemsProperty().clear(); itemsProperty().clear();
for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) { analyzer.forEachLibrary((libraryId, libraryVersion) -> {
String libraryId = type.getPatchId(); String title = I18n.hasKey("install.installer." + libraryId) ? i18n("install.installer." + libraryId) : libraryId;
analyzer.getVersion(type).ifPresent(libraryVersion -> itemsProperty().add( if (Lang.test(() -> profile.getDependency().getVersionList(libraryId)))
new InstallerItem(i18n("install.installer." + libraryId), libraryVersion, () -> { itemsProperty().add(
new InstallerItem(title, libraryVersion, () -> {
Controllers.getDecorator().startWizard(new UpdateInstallerWizardProvider(profile, gameVersion, version, libraryId, 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(); }).start();
} }

View File

@@ -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" * @param id the id of specific version list that this download provider provides. i.e. "forge", "liteloader", "game", "optifine"
* @return the version list * @return the version list
* @throws IllegalArgumentException if the version list does not exist
*/ */
VersionList<?> getVersionListById(String id); VersionList<?> getVersionListById(String id);
} }