feat(download): customize name of the mod to be downloaded.

This commit is contained in:
huanghongxun 2021-10-29 01:21:34 +08:00
parent de755d5495
commit a3c2642b93

View File

@ -52,6 +52,7 @@ import org.jackhuang.hmcl.ui.wizard.Navigation;
import org.jackhuang.hmcl.ui.wizard.WizardController; import org.jackhuang.hmcl.ui.wizard.WizardController;
import org.jackhuang.hmcl.ui.wizard.WizardProvider; import org.jackhuang.hmcl.ui.wizard.WizardProvider;
import org.jackhuang.hmcl.util.io.NetworkUtils; import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jackhuang.hmcl.util.platform.OperatingSystem;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.nio.file.Path; import java.nio.file.Path;
@ -166,7 +167,13 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
if (version == null) version = profile.getSelectedVersion(); if (version == null) version = profile.getSelectedVersion();
Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath(); Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath();
Path dest = runDirectory.resolve(subdirectoryName).resolve(file.getFile().getFilename());
Controllers.prompt(i18n("archive.name"), (result, resolve, reject) -> {
if (!OperatingSystem.isNameValid(result)) {
reject.accept(i18n("install.new_game.malformed"));
return;
}
Path dest = runDirectory.resolve(subdirectoryName).resolve(result);
TaskExecutorDialogPane downloadingPane = new TaskExecutorDialogPane(it -> { TaskExecutorDialogPane downloadingPane = new TaskExecutorDialogPane(it -> {
}); });
@ -190,6 +197,10 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
downloadingPane.setExecutor(executor, true); downloadingPane.setExecutor(executor, true);
Controllers.dialog(downloadingPane); Controllers.dialog(downloadingPane);
executor.start(); executor.start();
resolve.run();
}, file.getFile().getFilename());
} }
private void loadVersions(Profile profile) { private void loadVersions(Profile profile) {