From bde76707f3773e7533dc14a8a907e2b845197643 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Mon, 16 Mar 2020 22:48:42 +0800 Subject: [PATCH] alt: actions in game list now also in version page --- .../org/jackhuang/hmcl/ui/Controllers.java | 12 +- .../hmcl/ui/construct/InputDialogPane.java | 13 ++- .../ui/download/ModpackSelectionPage.java | 4 +- .../ui/versions/DatapackListPageSkin.java | 2 +- .../hmcl/ui/versions/GameListItemSkin.java | 32 +++--- .../hmcl/ui/versions/ModListPageSkin.java | 2 +- .../hmcl/ui/versions/VersionPage.java | 103 +++++++++++++++++- .../jackhuang/hmcl/ui/versions/Versions.java | 9 +- .../hmcl/ui/versions/WorldListPage.java | 4 +- .../assets/fxml/version/version.fxml | 47 -------- 10 files changed, 147 insertions(+), 81 deletions(-) delete mode 100644 HMCL/src/main/resources/assets/fxml/version/version.fxml diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 38ef92620..88068bc4a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -40,6 +40,7 @@ import org.jackhuang.hmcl.util.Logging; import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.platform.JavaVersion; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import static org.jackhuang.hmcl.setting.ConfigHolder.config; @@ -138,14 +139,19 @@ public final class Controllers { dialog(new MessageDialogPane(text, title, type, onAccept)); } - public static void confirmDialog(String text, String title, Runnable onAccept, Runnable onCancel) { + public static void confirm(String text, String title, Runnable onAccept, Runnable onCancel) { dialog(new MessageDialogPane(text, title, onAccept, onCancel)); } - public static InputDialogPane inputDialog(String text, FutureCallback onResult) { + public static CompletableFuture prompt(String text, FutureCallback onResult) { + return prompt(text, onResult, ""); + } + + public static CompletableFuture prompt(String text, FutureCallback onResult, String initialValue) { InputDialogPane pane = new InputDialogPane(text, onResult); dialog(pane); - return pane; + pane.setInitialValue(initialValue); + return pane.getCompletableFuture(); } public static TaskExecutorDialogPane taskDialog(TaskExecutor executor, String title) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/InputDialogPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/InputDialogPane.java index d4465d79b..9e7c9de3e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/InputDialogPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/InputDialogPane.java @@ -26,7 +26,10 @@ import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.util.FutureCallback; +import java.util.concurrent.CompletableFuture; + public class InputDialogPane extends StackPane { + private final CompletableFuture future = new CompletableFuture<>(); @FXML private JFXButton acceptButton; @@ -47,8 +50,10 @@ public class InputDialogPane extends StackPane { cancelButton.setOnMouseClicked(e -> fireEvent(new DialogCloseEvent())); acceptButton.setOnMouseClicked(e -> { acceptPane.showSpinner(); + onResult.call(textField.getText(), () -> { acceptPane.hideSpinner(); + future.complete(textField.getText()); fireEvent(new DialogCloseEvent()); }, msg -> { acceptPane.hideSpinner(); @@ -62,7 +67,11 @@ public class InputDialogPane extends StackPane { )); } - public void setInitialText(String text) { - textField.setText(text); + public void setInitialValue(String value) { + textField.setText(value); + } + + public CompletableFuture getCompletableFuture() { + return future; } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackSelectionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackSelectionPage.java index 7dbf9787d..e79ec773a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackSelectionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackSelectionPage.java @@ -42,7 +42,7 @@ import java.nio.file.Path; import java.util.Map; import java.util.Optional; -import static org.jackhuang.hmcl.ui.download.LocalModpackPage.*; +import static org.jackhuang.hmcl.ui.download.LocalModpackPage.MODPACK_FILE; import static org.jackhuang.hmcl.ui.download.RemoteModpackPage.MODPACK_SERVER_MANIFEST; import static org.jackhuang.hmcl.util.Lang.tryCast; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; @@ -90,7 +90,7 @@ public final class ModpackSelectionPage extends StackPane implements WizardPage @FXML private void onChooseRemoteFile() { - Controllers.inputDialog(i18n("modpack.choose.remote.tooltip"), (urlString, resolve, reject) -> { + Controllers.prompt(i18n("modpack.choose.remote.tooltip"), (urlString, resolve, reject) -> { try { URL url = new URL(urlString); if (urlString.endsWith("server-manifest.json")) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DatapackListPageSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DatapackListPageSkin.java index 157c4d793..bd7e1ba6c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DatapackListPageSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DatapackListPageSkin.java @@ -58,7 +58,7 @@ class DatapackListPageSkin extends SkinBase { toolbar.getChildren().add(createToolbarButton(i18n("button.refresh"), SVG::refresh, skinnable::refresh)); toolbar.getChildren().add(createToolbarButton(i18n("datapack.add"), SVG::plus, skinnable::add)); toolbar.getChildren().add(createToolbarButton(i18n("button.remove"), SVG::delete, () -> { - Controllers.confirmDialog(i18n("button.remove.confirm"), i18n("button.remove"), () -> { + Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), () -> { skinnable.removeSelected(listView.getSelectionModel().getSelectedItems()); }, null); })); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java index b95eab78d..93b95971a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java @@ -39,6 +39,8 @@ import static org.jackhuang.hmcl.ui.FXUtils.runInFX; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public class GameListItemSkin extends SkinBase { + private static JFXPopup popup; + private static GameListItem currentSkinnable; public GameListItemSkin(GameListItem skinnable) { super(skinnable); @@ -56,20 +58,22 @@ public class GameListItemSkin extends SkinBase { gameItem.setMouseTransparent(true); root.setCenter(gameItem); - PopupMenu menu = new PopupMenu(); - JFXPopup popup = new JFXPopup(menu); + if (popup == null) { + PopupMenu menu = new PopupMenu(); + popup = new JFXPopup(menu); - menu.getContent().setAll( - new IconedMenuItem(FXUtils.limitingSize(SVG.launch(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch.test"), FXUtils.withJFXPopupClosing(skinnable::launch, popup)), - new IconedMenuItem(FXUtils.limitingSize(SVG.script(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch_script"), FXUtils.withJFXPopupClosing(skinnable::generateLaunchScript, popup)), - new MenuSeparator(), - new IconedMenuItem(FXUtils.limitingSize(SVG.gear(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.manage"), FXUtils.withJFXPopupClosing(skinnable::modifyGameSettings, popup)), - new MenuSeparator(), - new IconedMenuItem(FXUtils.limitingSize(SVG.pencil(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(skinnable::rename, popup)), - new IconedMenuItem(FXUtils.limitingSize(SVG.delete(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(skinnable::remove, popup)), - new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("modpack.export"), FXUtils.withJFXPopupClosing(skinnable::export, popup)), - new MenuSeparator(), - new IconedMenuItem(FXUtils.limitingSize(SVG.folderOpen(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("folder.game"), FXUtils.withJFXPopupClosing(skinnable::browse, popup))); + menu.getContent().setAll( + new IconedMenuItem(FXUtils.limitingSize(SVG.launch(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch.test"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.launch(), popup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.script(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch_script"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.generateLaunchScript(), popup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.gear(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.manage"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.modifyGameSettings(), popup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.pencil(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.rename(), popup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.delete(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.remove(), popup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("modpack.export"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.export(), popup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.folderOpen(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("folder.game"), FXUtils.withJFXPopupClosing(() -> currentSkinnable.browse(), popup))); + } HBox right = new HBox(); right.setAlignment(Pos.CENTER_RIGHT); @@ -84,6 +88,7 @@ public class GameListItemSkin extends SkinBase { JFXButton btnManage = new JFXButton(); btnManage.setOnMouseClicked(e -> { + currentSkinnable = skinnable; popup.show(root, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, 0, root.getHeight()); }); btnManage.getStyleClass().add("toggle-icon4"); @@ -105,6 +110,7 @@ public class GameListItemSkin extends SkinBase { skinnable.modifyGameSettings(); } } else if (e.getButton() == MouseButton.SECONDARY) { + currentSkinnable = skinnable; popup.show(root, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, e.getX(), e.getY()); } }); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java index 9bbde83a3..63d28f2f0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java @@ -64,7 +64,7 @@ class ModListPageSkin extends SkinBase { toolbar.getChildren().add(createToolbarButton(i18n("button.refresh"), SVG::refresh, skinnable::refresh)); toolbar.getChildren().add(createToolbarButton(i18n("mods.add"), SVG::plus, skinnable::add)); toolbar.getChildren().add(createToolbarButton(i18n("button.remove"), SVG::delete, () -> { - Controllers.confirmDialog(i18n("button.remove.confirm"), i18n("button.remove"), () -> { + Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), () -> { skinnable.removeSelected(listView.getSelectionModel().getSelectedItems()); }, null); })); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java index 1c07109ff..0a1ebc1c9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java @@ -18,20 +18,19 @@ package org.jackhuang.hmcl.ui.versions; import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXListCell; import com.jfoenix.controls.JFXListView; import com.jfoenix.controls.JFXPopup; import javafx.application.Platform; import javafx.beans.property.*; import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.scene.control.Control; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.SkinBase; +import javafx.scene.control.*; +import javafx.scene.input.MouseButton; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; -import javafx.scene.paint.Color; -import javafx.scene.shape.Rectangle; +import javafx.util.Callback; import org.jackhuang.hmcl.game.HMCLGameRepository; import org.jackhuang.hmcl.game.Version; import org.jackhuang.hmcl.setting.Profile; @@ -71,16 +70,27 @@ public class VersionPage extends Control implements DecoratorPage { private final WorldListPage worldListPage = new WorldListPage(); private final TransitionPane transitionPane = new TransitionPane(); private final ObjectProperty selectedTab = new SimpleObjectProperty<>(); + private final BooleanProperty currentVersionUpgradable = new SimpleBooleanProperty(); private Profile profile; private String version; + private String preferredVersionName = null; + { Profiles.registerVersionsListener(this::loadVersions); listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null && !Objects.equals(oldValue, newValue)) loadVersion(newValue, profile); + if (newValue == null && !Objects.equals(oldValue, newValue)) { + if (listView.getItems().contains(preferredVersionName)) { + loadVersion(preferredVersionName, profile); + preferredVersionName = null; + } else if (!listView.getItems().isEmpty()) { + loadVersion(listView.getItems().get(0), profile); + } + } }); versionSettingsTab.setNode(versionSettingsPage); @@ -118,6 +128,7 @@ public class VersionPage extends Control implements DecoratorPage { listView.getSelectionModel().select(version); versionSettingsPage.loadVersion(profile, version); + currentVersionUpgradable.set(profile.getRepository().isModpack(version)); CompletableFuture.allOf( modListPage.loadVersion(profile, version), @@ -160,6 +171,27 @@ public class VersionPage extends Control implements DecoratorPage { Versions.testGame(profile, version); } + private void updateGame() { + Versions.updateVersion(profile, version); + } + + private void generateLaunchScript() { + Versions.generateLaunchScript(profile, version); + } + + private void export() { + Versions.exportVersion(profile, version); + } + + private void rename() { + Versions.renameVersion(profile, version) + .thenApply(newVersionName -> this.preferredVersionName = newVersionName); + } + + private void remove() { + Versions.deleteVersion(profile, version); + } + @Override protected Skin createDefaultSkin() { return new Skin(this); @@ -172,6 +204,9 @@ public class VersionPage extends Control implements DecoratorPage { public static class Skin extends SkinBase { + String currentVersion; + private JFXPopup listViewItemPopup; + /** * Constructor for all SkinBase instances. * @@ -180,7 +215,46 @@ public class VersionPage extends Control implements DecoratorPage { protected Skin(VersionPage control) { super(control); + PopupMenu menu = new PopupMenu(); + listViewItemPopup = new JFXPopup(menu); + menu.getContent().setAll( + new IconedMenuItem(FXUtils.limitingSize(SVG.launch(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch.test"), FXUtils.withJFXPopupClosing(() -> { + Versions.testGame(getSkinnable().profile, currentVersion); + }, listViewItemPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.script(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch_script"), FXUtils.withJFXPopupClosing(() -> { + Versions.generateLaunchScript(getSkinnable().profile, currentVersion); + }, listViewItemPopup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.pencil(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> { + Versions.renameVersion(getSkinnable().profile, currentVersion).thenApply(name -> getSkinnable().preferredVersionName = name); + }, listViewItemPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.delete(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> { + Versions.deleteVersion(getSkinnable().profile, currentVersion); + }, listViewItemPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("modpack.export"), FXUtils.withJFXPopupClosing(() -> { + Versions.exportVersion(getSkinnable().profile, currentVersion); + }, listViewItemPopup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.folderOpen(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("folder.game"), FXUtils.withJFXPopupClosing(() -> { + Versions.openFolder(getSkinnable().profile, currentVersion); + }, listViewItemPopup)) + ); + control.listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + control.listView.setCellFactory(new Callback, ListCell>() { + @Override + public ListCell call(ListView param) { + JFXListCell cell = new JFXListCell<>(); + cell.setOnMouseClicked(e -> { + if (cell.getItem() == null) return; + currentVersion = cell.getItem(); + if (e.getButton() == MouseButton.SECONDARY) { + listViewItemPopup.show(cell, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, e.getX(), e.getY()); + } + }); + return cell; + } + }); SpinnerPane spinnerPane = new SpinnerPane(); spinnerPane.getStyleClass().add("large-spinner-pane"); @@ -235,11 +309,28 @@ public class VersionPage extends Control implements DecoratorPage { PopupMenu managementList = new PopupMenu(); JFXPopup managementPopup = new JFXPopup(managementList); managementList.getContent().setAll( + new IconedMenuItem(FXUtils.limitingSize(SVG.launch(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch.test"), FXUtils.withJFXPopupClosing(control::testGame, managementPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.script(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.launch_script"), FXUtils.withJFXPopupClosing(control::generateLaunchScript, managementPopup)), + new MenuSeparator(), + new IconedMenuItem(FXUtils.limitingSize(SVG.pencil(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(control::rename, managementPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.delete(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(control::remove, managementPopup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("modpack.export"), FXUtils.withJFXPopupClosing(control::export, managementPopup)), + new MenuSeparator(), new IconedMenuItem(null, i18n("version.manage.redownload_assets_index"), FXUtils.withJFXPopupClosing(control::redownloadAssetIndex, managementPopup)), new IconedMenuItem(null, i18n("version.manage.remove_libraries"), FXUtils.withJFXPopupClosing(control::clearLibraries, managementPopup)), new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(control::clearJunkFiles, managementPopup)).addTooltip(i18n("version.manage.clean.tooltip")) ); + JFXButton upgradeButton = new JFXButton(); + FXUtils.setLimitWidth(upgradeButton, 40); + FXUtils.setLimitHeight(upgradeButton, 40); + upgradeButton.setGraphic(SVG.update(Theme.whiteFillBinding(), 20, 20)); + upgradeButton.getStyleClass().add("jfx-decorator-button"); + upgradeButton.ripplerFillProperty().bind(Theme.whiteFillBinding()); + upgradeButton.setOnAction(event -> control.updateGame()); + upgradeButton.visibleProperty().bind(control.currentVersionUpgradable); + FXUtils.installFastTooltip(upgradeButton, i18n("version.update")); + JFXButton testGameButton = new JFXButton(); FXUtils.setLimitWidth(testGameButton, 40); FXUtils.setLimitHeight(testGameButton, 40); @@ -267,7 +358,7 @@ public class VersionPage extends Control implements DecoratorPage { managementMenuButton.setOnAction(event -> managementPopup.show(managementMenuButton, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, 0, managementMenuButton.getHeight())); FXUtils.installFastTooltip(managementMenuButton, i18n("settings.game.management")); - toolBar.getChildren().setAll(testGameButton, browseMenuButton, managementMenuButton); + toolBar.getChildren().setAll(upgradeButton, testGameButton, browseMenuButton, managementMenuButton); } BorderPane titleBar = new BorderPane(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java index 9faca2884..fb267e306 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java @@ -35,6 +35,7 @@ import org.jackhuang.hmcl.util.platform.OperatingSystem; import java.io.File; import java.io.IOException; +import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; @@ -47,20 +48,20 @@ public class Versions { String message = isIndependent ? i18n("version.manage.remove.confirm.independent", version) : isMovingToTrashSupported ? i18n("version.manage.remove.confirm.trash", version, version + "_removed") : i18n("version.manage.remove.confirm", version); - Controllers.confirmDialog(message, i18n("message.confirm"), () -> { + Controllers.confirm(message, i18n("message.confirm"), () -> { profile.getRepository().removeVersionFromDisk(version); }, null); } - public static void renameVersion(Profile profile, String version) { - Controllers.inputDialog(i18n("version.manage.rename.message"), (res, resolve, reject) -> { + public static CompletableFuture renameVersion(Profile profile, String version) { + return Controllers.prompt(i18n("version.manage.rename.message"), (res, resolve, reject) -> { if (profile.getRepository().renameVersion(version, res)) { profile.getRepository().refreshVersionsAsync().start(); resolve.run(); } else { reject.accept(i18n("version.manage.rename.fail")); } - }).setInitialText(version); + }, version); } public static void exportVersion(Profile profile, String version) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListPage.java index b73c0445a..2171369fc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListPage.java @@ -113,7 +113,7 @@ public class WorldListPage extends ListPageBase { // Or too many input dialogs are popped. Task.supplyAsync(() -> new World(zipFile.toPath())) .whenComplete(Schedulers.javafx(), world -> { - Controllers.inputDialog(i18n("world.name.enter"), (name, resolve, reject) -> { + Controllers.prompt(i18n("world.name.enter"), (name, resolve, reject) -> { Task.runAsync(() -> world.install(savesDir, name)) .whenComplete(Schedulers.javafx(), () -> { itemsProperty().add(new WorldListItem(new World(savesDir.resolve(name)))); @@ -126,7 +126,7 @@ public class WorldListPage extends ListPageBase { else reject.accept(i18n("world.import.failed", e.getClass().getName() + ": " + e.getLocalizedMessage())); }).start(); - }).setInitialText(world.getWorldName()); + }, world.getWorldName()); }, e -> { Logging.LOG.log(Level.WARNING, "Unable to parse world file " + zipFile, e); Controllers.dialog(i18n("world.import.invalid")); diff --git a/HMCL/src/main/resources/assets/fxml/version/version.fxml b/HMCL/src/main/resources/assets/fxml/version/version.fxml deleted file mode 100644 index af5e5f455..000000000 --- a/HMCL/src/main/resources/assets/fxml/version/version.fxml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -