From bbaed35160882b62309f9b6191d4b163ab328011 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Fri, 21 Dec 2018 00:40:50 +0800 Subject: [PATCH] Add button to reveal world directory in explorer --- .../org/jackhuang/hmcl/ui/versions/WorldListItem.java | 9 +++++++++ .../jackhuang/hmcl/ui/versions/WorldListItemSkin.java | 3 ++- HMCL/src/main/resources/assets/lang/I18N.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_zh.properties | 1 + .../src/main/resources/assets/lang/I18N_zh_CN.properties | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItem.java index 63636a696..c2e419e6f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItem.java @@ -27,6 +27,7 @@ import javafx.scene.image.Image; import javafx.stage.FileChooser; import org.jackhuang.hmcl.game.World; import org.jackhuang.hmcl.ui.Controllers; +import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.wizard.SinglePageWizardProvider; import org.jackhuang.hmcl.util.versioning.VersionNumber; @@ -81,6 +82,14 @@ public class WorldListItem extends Control { Controllers.getDecorator().startWizard(new SinglePageWizardProvider(controller -> new WorldExportPage(world, file.toPath(), controller::onFinish))); } + public void reveal() { + try { + FXUtils.openFolder(world.getFile().toFile()); + } catch (UnsupportedOperationException e) { + e.printStackTrace(); + } + } + public void manageDatapacks() { if (world.getGameVersion() == null || // old game will not write game version to level.dat (VersionNumber.isIntVersionNumber(world.getGameVersion()) // we don't parse snapshot version diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItemSkin.java index 190b8e650..69492b1f0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItemSkin.java @@ -65,7 +65,8 @@ public class WorldListItemSkin extends SkinBase { menu.getContent().setAll( new IconedMenuItem(FXUtils.limitingSize(SVG.gear(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("world.datapack"), FXUtils.withJFXPopupClosing(skinnable::manageDatapacks, popup)), - new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("world.export"), FXUtils.withJFXPopupClosing(skinnable::export, popup))); + new IconedMenuItem(FXUtils.limitingSize(SVG.export(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("world.export"), FXUtils.withJFXPopupClosing(skinnable::export, popup)), + new IconedMenuItem(FXUtils.limitingSize(SVG.folderOpen(Theme.blackFillBinding(), 14, 14), 14, 14), i18n("world.reveal"), FXUtils.withJFXPopupClosing(skinnable::reveal, popup))); HBox right = new HBox(); right.setAlignment(Pos.CENTER_RIGHT); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index a1f547fcd..860d78979 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -275,6 +275,7 @@ world.import.failed=Unable to import this world: %s world.import.invalid=Not a valid world zip world.name=World Name world.name.enter=Enter the world name +world.reveal=Reveal in Explorer world.time=EEE, MMM d, yyyy HH:mm:ss profile=Game Directories diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index fc657b9a4..70b3b6fc8 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -274,6 +274,7 @@ world.import.invalid=無法識別的存檔壓縮包 world.game_version=遊戲版本 world.name=世界名稱 world.name.enter=輸入世界名稱 +world.reveal=打開資料夾 world.time=yyyy 年 MM 月 dd 日 HH:mm:ss profile=遊戲目錄 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 4bc2e590c..9b88730b7 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -274,6 +274,7 @@ world.import.failed=无法导入此世界:%s world.import.invalid=无法识别的存档压缩包 world.name=世界名称 world.name.enter=输入世界名称 +world.reveal=打开文件夹 world.time=yyyy 年 MM 月 dd 日 HH:mm:ss profile=游戏目录