mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
在游戏安装界面隐藏不可用的模组管理器 (#2726)
* 在 Minecraft 1.13+ 的安装界面隐藏 liteloader 选项 * update * fix checkstyle * fix checkstyle
This commit is contained in:
parent
4c41f25314
commit
a79a2014b0
@ -38,6 +38,7 @@ import org.jackhuang.hmcl.setting.Theme;
|
|||||||
import org.jackhuang.hmcl.setting.VersionIconType;
|
import org.jackhuang.hmcl.setting.VersionIconType;
|
||||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||||
|
import org.jackhuang.hmcl.util.versioning.VersionNumber;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.download.LibraryAnalyzer.LibraryType.*;
|
import static org.jackhuang.hmcl.download.LibraryAnalyzer.LibraryType.*;
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
@ -121,7 +122,7 @@ public class InstallerItem extends Control {
|
|||||||
return new InstallerItemSkin(this);
|
return new InstallerItemSkin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InstallerItemGroup {
|
public final static class InstallerItemGroup {
|
||||||
public final InstallerItem game = new InstallerItem(MINECRAFT);
|
public final InstallerItem game = new InstallerItem(MINECRAFT);
|
||||||
public final InstallerItem fabric = new InstallerItem(FABRIC);
|
public final InstallerItem fabric = new InstallerItem(FABRIC);
|
||||||
public final InstallerItem fabricApi = new InstallerItem(FABRIC_API);
|
public final InstallerItem fabricApi = new InstallerItem(FABRIC_API);
|
||||||
@ -132,7 +133,9 @@ public class InstallerItem extends Control {
|
|||||||
public final InstallerItem quilt = new InstallerItem(QUILT);
|
public final InstallerItem quilt = new InstallerItem(QUILT);
|
||||||
public final InstallerItem quiltApi = new InstallerItem(QUILT_API);
|
public final InstallerItem quiltApi = new InstallerItem(QUILT_API);
|
||||||
|
|
||||||
public InstallerItemGroup() {
|
private final InstallerItem[] libraries;
|
||||||
|
|
||||||
|
public InstallerItemGroup(String gameVersion) {
|
||||||
forge.incompatibleLibraryName.bind(Bindings.createStringBinding(() -> {
|
forge.incompatibleLibraryName.bind(Bindings.createStringBinding(() -> {
|
||||||
if (fabric.libraryVersion.get() != null) return FABRIC.getPatchId();
|
if (fabric.libraryVersion.get() != null) return FABRIC.getPatchId();
|
||||||
if (quilt.libraryVersion.get() != null) return QUILT.getPatchId();
|
if (quilt.libraryVersion.get() != null) return QUILT.getPatchId();
|
||||||
@ -194,10 +197,19 @@ public class InstallerItem extends Control {
|
|||||||
if (quilt.libraryVersion.get() == null) return QUILT.getPatchId();
|
if (quilt.libraryVersion.get() == null) return QUILT.getPatchId();
|
||||||
else return null;
|
else return null;
|
||||||
}, quilt.libraryVersion));
|
}, quilt.libraryVersion));
|
||||||
|
|
||||||
|
|
||||||
|
if (gameVersion == null) {
|
||||||
|
this.libraries = new InstallerItem[]{game, forge, neoForge, liteLoader, optiFine, fabric, fabricApi, quilt, quiltApi};
|
||||||
|
} else if (VersionNumber.compare(gameVersion, "1.13") < 0) {
|
||||||
|
this.libraries = new InstallerItem[]{game, forge, liteLoader, optiFine};
|
||||||
|
} else {
|
||||||
|
this.libraries = new InstallerItem[]{game, forge, neoForge, optiFine, fabric, fabricApi, quilt, quiltApi};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstallerItem[] getLibraries() {
|
public InstallerItem[] getLibraries() {
|
||||||
return new InstallerItem[]{game, forge, neoForge, liteLoader, optiFine, fabric, fabricApi, quilt, quiltApi};
|
return libraries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +48,13 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
public class InstallersPage extends Control implements WizardPage {
|
public class InstallersPage extends Control implements WizardPage {
|
||||||
protected final WizardController controller;
|
protected final WizardController controller;
|
||||||
|
|
||||||
protected InstallerItem.InstallerItemGroup group = new InstallerItem.InstallerItemGroup();
|
protected InstallerItem.InstallerItemGroup group;
|
||||||
protected JFXTextField txtName = new JFXTextField();
|
protected JFXTextField txtName = new JFXTextField();
|
||||||
protected BooleanProperty installable = new SimpleBooleanProperty();
|
protected BooleanProperty installable = new SimpleBooleanProperty();
|
||||||
|
|
||||||
public InstallersPage(WizardController controller, HMCLGameRepository repository, String gameVersion, DownloadProvider downloadProvider) {
|
public InstallersPage(WizardController controller, HMCLGameRepository repository, String gameVersion, DownloadProvider downloadProvider) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
|
this.group = new InstallerItem.InstallerItemGroup(gameVersion);
|
||||||
|
|
||||||
txtName.getValidators().addAll(
|
txtName.getValidators().addAll(
|
||||||
new RequiredValidator(),
|
new RequiredValidator(),
|
||||||
@ -152,14 +153,22 @@ public class InstallersPage extends Control implements WizardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
FlowPane libraryPane = new FlowPane(control.group.getLibraries());
|
InstallerItem[] libraries = control.group.getLibraries();
|
||||||
|
|
||||||
|
FlowPane libraryPane = new FlowPane(libraries);
|
||||||
libraryPane.setVgap(16);
|
libraryPane.setVgap(16);
|
||||||
libraryPane.setHgap(16);
|
libraryPane.setHgap(16);
|
||||||
ScrollPane scrollPane = new ScrollPane(libraryPane);
|
|
||||||
scrollPane.setFitToWidth(true);
|
if (libraries.length <= 8) {
|
||||||
scrollPane.setFitToHeight(true);
|
BorderPane.setMargin(libraryPane, new Insets(16, 0, 16, 0));
|
||||||
BorderPane.setMargin(scrollPane, new Insets(16, 0, 16, 0));
|
root.setCenter(libraryPane);
|
||||||
root.setCenter(scrollPane);
|
} else {
|
||||||
|
ScrollPane scrollPane = new ScrollPane(libraryPane);
|
||||||
|
scrollPane.setFitToWidth(true);
|
||||||
|
scrollPane.setFitToHeight(true);
|
||||||
|
BorderPane.setMargin(scrollPane, new Insets(16, 0, 16, 0));
|
||||||
|
root.setCenter(scrollPane);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> implements Ve
|
|||||||
|
|
||||||
itemsProperty().clear();
|
itemsProperty().clear();
|
||||||
|
|
||||||
InstallerItem.InstallerItemGroup group = new InstallerItem.InstallerItemGroup();
|
InstallerItem.InstallerItemGroup group = new InstallerItem.InstallerItemGroup(gameVersion);
|
||||||
|
|
||||||
// Conventional libraries: game, fabric, forge, neoforge, liteloader, optifine
|
// Conventional libraries: game, fabric, forge, neoforge, liteloader, optifine
|
||||||
for (InstallerItem installerItem : group.getLibraries()) {
|
for (InstallerItem installerItem : group.getLibraries()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user