Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void delete(World world) {
}

public void copy(World world) {
WorldManageUIUtils.copyWorld(world, this::refresh);
WorldManageUIUtils.copyWorld(world, false, this::refresh);
}

public void reveal(World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private AdvancedListBox getToolBar() {
managePopupMenu.getContent().addAll(
new IconedMenuItem(SVG.OUTPUT, i18n("world.export"), () -> WorldManageUIUtils.export(getSkinnable().world, getSkinnable().sessionLockChannel), managePopup),
new IconedMenuItem(SVG.DELETE_FOREVER, i18n("world.delete"), () -> WorldManageUIUtils.delete(getSkinnable().world, () -> getSkinnable().fireEvent(new PageCloseEvent()), getSkinnable().sessionLockChannel), managePopup),
new IconedMenuItem(SVG.CONTENT_COPY, i18n("world.duplicate"), () -> WorldManageUIUtils.copyWorld(getSkinnable().world, null), managePopup)
new IconedMenuItem(SVG.CONTENT_COPY, i18n("world.duplicate"), () -> WorldManageUIUtils.copyWorld(getSkinnable().world, !getSkinnable().isReadOnly(), null), managePopup)
);

toolbar.addNavigationDrawerItem(i18n("settings.game.management"), SVG.MENU, null, managePopupMenuItem ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void export(World world, FileChannel sessionLockChannel) {
Controllers.getDecorator().startWizard(new SinglePageWizardProvider(controller -> new WorldExportPage(world, file, controller::onFinish)));
}

public static void copyWorld(World world, Runnable runnable) {
public static void copyWorld(World world, boolean lockedByHmcl, Runnable runnable) {
Path worldPath = world.getFile();
Controllers.dialog(new InputDialogPane(
i18n("world.duplicate.prompt"),
Expand All @@ -109,7 +109,7 @@ public static void copyWorld(World world, Runnable runnable) {
return;
}

Task.runAsync(Schedulers.io(), () -> world.copy(result))
Task.runAsync(Schedulers.io(), () -> world.copy(result, lockedByHmcl))
.thenAcceptAsync(Schedulers.javafx(), (Void) -> Controllers.showToast(i18n("world.duplicate.success.toast")))
.thenAcceptAsync(Schedulers.javafx(), (Void) -> {
if (runnable != null) {
Expand Down
4 changes: 2 additions & 2 deletions HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ public void delete() throws IOException {
FileUtils.forceDelete(file);
}

public void copy(String newName) throws IOException {
public void copy(String newName, boolean lockedByHmcl) throws IOException {
if (!Files.isDirectory(file)) {
throw new IOException("Not a valid world directory");
}

if (isLocked()) {
if (!lockedByHmcl && isLocked()) {
throw new WorldLockedException("The world " + getFile() + " has been locked");
}

Expand Down