mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
Add Fabric installerItem in list page
This commit is contained in:
parent
55d38f2b36
commit
ea19e6efd8
@ -24,6 +24,7 @@ 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;
|
||||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
*/
|
*/
|
||||||
public class InstallerItem extends BorderPane {
|
public class InstallerItem extends BorderPane {
|
||||||
|
|
||||||
public InstallerItem(String artifact, String version, Runnable upgrade, Consumer<InstallerItem> deleteCallback) {
|
public InstallerItem(String artifact, String version, @Nullable Runnable upgrade, @Nullable Consumer<InstallerItem> deleteCallback) {
|
||||||
getStyleClass().add("two-line-list-item");
|
getStyleClass().add("two-line-list-item");
|
||||||
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);
|
||||||
@ -49,19 +50,24 @@ public class InstallerItem extends BorderPane {
|
|||||||
{
|
{
|
||||||
HBox hBox = new HBox();
|
HBox hBox = new HBox();
|
||||||
|
|
||||||
|
if (upgrade != null) {
|
||||||
JFXButton upgradeButton = new JFXButton();
|
JFXButton upgradeButton = new JFXButton();
|
||||||
upgradeButton.setGraphic(SVG.update(Theme.blackFillBinding(), -1, -1));
|
upgradeButton.setGraphic(SVG.update(Theme.blackFillBinding(), -1, -1));
|
||||||
upgradeButton.getStyleClass().add("toggle-icon4");
|
upgradeButton.getStyleClass().add("toggle-icon4");
|
||||||
FXUtils.installFastTooltip(upgradeButton, i18n("install.change_version"));
|
FXUtils.installFastTooltip(upgradeButton, i18n("install.change_version"));
|
||||||
upgradeButton.setOnMouseClicked(e -> upgrade.run());
|
upgradeButton.setOnMouseClicked(e -> upgrade.run());
|
||||||
|
hBox.getChildren().add(upgradeButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deleteCallback != null) {
|
||||||
JFXButton deleteButton = new JFXButton();
|
JFXButton deleteButton = new JFXButton();
|
||||||
deleteButton.setGraphic(SVG.close(Theme.blackFillBinding(), -1, -1));
|
deleteButton.setGraphic(SVG.close(Theme.blackFillBinding(), -1, -1));
|
||||||
deleteButton.getStyleClass().add("toggle-icon4");
|
deleteButton.getStyleClass().add("toggle-icon4");
|
||||||
deleteButton.setOnMouseClicked(e -> deleteCallback.accept(this));
|
deleteButton.setOnMouseClicked(e -> deleteCallback.accept(this));
|
||||||
|
hBox.getChildren().add(deleteButton);
|
||||||
|
}
|
||||||
|
|
||||||
hBox.setAlignment(Pos.CENTER_RIGHT);
|
hBox.setAlignment(Pos.CENTER_RIGHT);
|
||||||
hBox.getChildren().setAll(upgradeButton, deleteButton);
|
|
||||||
setRight(hBox);
|
setRight(hBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ public class InstallerListPage extends ListPage<InstallerItem> {
|
|||||||
new InstallerItem("OptiFine", library.getVersion(), () -> {
|
new InstallerItem("OptiFine", library.getVersion(), () -> {
|
||||||
Controllers.getDecorator().startWizard(new UpdateInstallerWizardProvider(profile, gameVersion, version, "optifine", library));
|
Controllers.getDecorator().startWizard(new UpdateInstallerWizardProvider(profile, gameVersion, version, "optifine", library));
|
||||||
}, removeAction.apply(library))));
|
}, removeAction.apply(library))));
|
||||||
|
analyzer.get(FABRIC).ifPresent(library -> itemsProperty().add(new InstallerItem("Fabric", library.getVersion(), null, null)));
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public final class LibraryAnalyzer {
|
|||||||
FORGE(true, Pattern.compile("net\\.minecraftforge"), Pattern.compile("forge")),
|
FORGE(true, Pattern.compile("net\\.minecraftforge"), Pattern.compile("forge")),
|
||||||
LITELOADER(true, Pattern.compile("com\\.mumfrey"), Pattern.compile("liteloader")),
|
LITELOADER(true, Pattern.compile("com\\.mumfrey"), Pattern.compile("liteloader")),
|
||||||
OPTIFINE(false, Pattern.compile("(net\\.)?optifine"), Pattern.compile(".*")),
|
OPTIFINE(false, Pattern.compile("(net\\.)?optifine"), Pattern.compile(".*")),
|
||||||
FABRIC(true, Pattern.compile("net\\.fabricmc"), Pattern.compile(".*"));
|
FABRIC(true, Pattern.compile("net\\.fabricmc"), Pattern.compile("fabric-loader"));
|
||||||
|
|
||||||
private final Pattern group, artifact;
|
private final Pattern group, artifact;
|
||||||
private final boolean modLoader;
|
private final boolean modLoader;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user