4 files changed
+62
-53
No files matched your search
@@ -25,6 +25,7 @@ import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.jackhuang.hmcl.setting.SettingsManager.settings;
|
||||
|
||||
@@ -42,8 +43,8 @@ public final class ExportWizardProvider implements WizardProvider {
|
||||
@Override
|
||||
public Object finish(SettingsMap settings) {
|
||||
List<String> whitelist = settings.get(ModpackFileSelectionPage.MODPACK_FILE_SELECTION);
|
||||
Path modpackFile = settings.get(ModpackInfoPage.MODPACK_FILE);
|
||||
ModpackExportInfo exportInfo = settings.get(ModpackInfoPage.MODPACK_INFO);
|
||||
Path modpackFile = settings.get(ModpackFileSelectionPage.MODPACK_FILE);
|
||||
ModpackExportInfo exportInfo = Objects.requireNonNull(settings.get(ModpackInfoPage.MODPACK_INFO));
|
||||
exportInfo.setWhitelist(whitelist);
|
||||
String modpackType = settings.get(ModpackTypeSelectionPage.MODPACK_TYPE);
|
||||
|
||||
|
||||
@@ -14,9 +14,11 @@ import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jackhuang.hmcl.game.HMCLGameInstance;
|
||||
import org.jackhuang.hmcl.modpack.ModAdviser;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
@@ -26,6 +28,7 @@ import org.jackhuang.hmcl.util.Pair;
|
||||
import org.jackhuang.hmcl.util.SettingsMap;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jetbrains.annotations.NotNullByDefault;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,9 +38,13 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackInfoPage.MODPACK_INFO;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.MODPACK_TYPE;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.MODPACK_TYPE_MODRINTH;
|
||||
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
@@ -47,6 +54,7 @@ import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class ModpackFileSelectionPage extends BorderPane implements WizardPage {
|
||||
public static final SettingsMap.Key<Path> MODPACK_FILE = new SettingsMap.Key<>("modpack.file");
|
||||
private final WizardController controller;
|
||||
private final HMCLGameInstance gameInstance;
|
||||
private final ModAdviser adviser;
|
||||
@@ -204,6 +212,22 @@ public final class ModpackFileSelectionPage extends BorderPane implements Wizard
|
||||
}
|
||||
|
||||
private void onNext() {
|
||||
var info = Objects.requireNonNull(controller.getSettings().get(MODPACK_INFO));
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle(i18n("modpack.wizard.step.initialization.save"));
|
||||
if (!info.isPackWithLauncher() && MODPACK_TYPE_MODRINTH.equals(controller.getSettings().get(MODPACK_TYPE))) {
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.mrpack"));
|
||||
fileChooser.setInitialFileName(info.getName() + (OperatingSystem.CURRENT_OS == OperatingSystem.MACOS ? "" : ".mrpack"));
|
||||
} else {
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
||||
fileChooser.setInitialFileName(info.getName() + ".zip");
|
||||
}
|
||||
Path file = Controllers.showSaveDialog(fileChooser);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
controller.getSettings().put(MODPACK_FILE, file);
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
getFilesNeeded(rootNode, "minecraft", list);
|
||||
controller.getSettings().put(MODPACK_FILE_SELECTION, list);
|
||||
|
||||
@@ -8,15 +8,17 @@ import com.jfoenix.controls.JFXTextArea;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.validation.base.ValidatorBase;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jackhuang.hmcl.Metadata;
|
||||
import org.jackhuang.hmcl.auth.Account;
|
||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
||||
@@ -25,7 +27,6 @@ import org.jackhuang.hmcl.modpack.ModpackExportInfo;
|
||||
import org.jackhuang.hmcl.modpack.mcbbs.McbbsModpackManifest;
|
||||
import org.jackhuang.hmcl.setting.Accounts;
|
||||
import org.jackhuang.hmcl.setting.GameSettings;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.construct.*;
|
||||
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
||||
@@ -33,17 +34,16 @@ import org.jackhuang.hmcl.ui.wizard.WizardPage;
|
||||
import org.jackhuang.hmcl.util.SettingsMap;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.io.JarUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.SystemInfo;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.jackhuang.hmcl.setting.SettingsManager.getAuthlibInjectorServers;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.MODPACK_TYPE;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.MODPACK_TYPE_MODRINTH;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.MODPACK_TYPE_SERVER;
|
||||
import static org.jackhuang.hmcl.ui.export.ModpackTypeSelectionPage.*;
|
||||
import static org.jackhuang.hmcl.util.DataSizeUnit.MEGABYTES;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
|
||||
@@ -91,34 +91,20 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
||||
}
|
||||
|
||||
private void onNext() {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle(i18n("modpack.wizard.step.initialization.save"));
|
||||
if (!packWithLauncher.get() && controller.getSettings().get(MODPACK_TYPE) == MODPACK_TYPE_MODRINTH) {
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.mrpack"));
|
||||
fileChooser.setInitialFileName(name.get() + (OperatingSystem.CURRENT_OS == OperatingSystem.MACOS ? "" : ".mrpack"));
|
||||
} else {
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
||||
fileChooser.setInitialFileName(name.get() + ".zip");
|
||||
}
|
||||
Path file = Controllers.showSaveDialog(fileChooser);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
exportInfo.setName(name.get());
|
||||
exportInfo.setFileApi(fileApi.get());
|
||||
exportInfo.setVersion(version.get());
|
||||
exportInfo.setAuthor(author.get());
|
||||
exportInfo.setDescription(description.get());
|
||||
exportInfo.setUrl(url.get());
|
||||
exportInfo.setForceUpdate(forceUpdate.get());
|
||||
exportInfo.setPackWithLauncher(packWithLauncher.get());
|
||||
exportInfo.setMinMemory(minMemory.get());
|
||||
exportInfo.setLaunchArguments(launchArguments.get());
|
||||
exportInfo.setJavaArguments(javaArguments.get());
|
||||
exportInfo.setAuthlibInjectorServer(authlibInjectorServer.get());
|
||||
exportInfo.setNoCreateRemoteFiles(noCreateRemoteFiles.get());
|
||||
exportInfo.setSkipCurseForgeRemoteFiles(skipCurseForgeRemoteFiles.get());
|
||||
exportInfo.setName(name.get())
|
||||
.setFileApi(fileApi.get())
|
||||
.setVersion(version.get())
|
||||
.setAuthor(author.get())
|
||||
.setDescription(description.get())
|
||||
.setUrl(url.get())
|
||||
.setForceUpdate(forceUpdate.get())
|
||||
.setPackWithLauncher(packWithLauncher.get())
|
||||
.setMinMemory(minMemory.get())
|
||||
.setLaunchArguments(launchArguments.get())
|
||||
.setJavaArguments(javaArguments.get())
|
||||
.setAuthlibInjectorServer(authlibInjectorServer.get())
|
||||
.setNoCreateRemoteFiles(noCreateRemoteFiles.get())
|
||||
.setSkipCurseForgeRemoteFiles(skipCurseForgeRemoteFiles.get());
|
||||
|
||||
if (StringUtils.isNotBlank(mcbbsThreadId.get())) {
|
||||
exportInfo.setOrigins(Collections.singletonList(new McbbsModpackManifest.Origin(
|
||||
@@ -127,7 +113,6 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
||||
}
|
||||
|
||||
controller.getSettings().put(MODPACK_INFO, exportInfo);
|
||||
controller.getSettings().put(MODPACK_FILE, file);
|
||||
controller.onNext();
|
||||
}
|
||||
|
||||
@@ -147,12 +132,9 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
||||
}
|
||||
|
||||
public static final SettingsMap.Key<ModpackExportInfo> MODPACK_INFO = new SettingsMap.Key<>("modpack.info");
|
||||
public static final SettingsMap.Key<Path> MODPACK_FILE = new SettingsMap.Key<>("modpack.file");
|
||||
public static final SettingsMap.Key<ModpackExportInfo.Options> MODPACK_INFO_OPTION = new SettingsMap.Key<>("modpack.info.option");
|
||||
|
||||
public static class ModpackInfoPageSkin extends SkinBase<ModpackInfoPage> {
|
||||
private ObservableList<Node> originList;
|
||||
|
||||
private final List<JFXTextField> validatingFields = new ArrayList<>();
|
||||
|
||||
public ModpackInfoPageSkin(ModpackInfoPage skinnable) {
|
||||
@@ -171,12 +153,12 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
||||
borderPane.setStyle("-fx-padding: 16;");
|
||||
scroll.setContent(borderPane);
|
||||
|
||||
if (skinnable.controller.getSettings().get(MODPACK_TYPE) == MODPACK_TYPE_SERVER) {
|
||||
if (MODPACK_TYPE_SERVER.equals(skinnable.controller.getSettings().get(MODPACK_TYPE))) {
|
||||
Hyperlink hyperlink = new Hyperlink(i18n("modpack.wizard.step.initialization.server"));
|
||||
hyperlink.setOnAction(e -> FXUtils.openLink(Metadata.DOCS_URL + "/modpack/serverpack.html"));
|
||||
borderPane.setTop(hyperlink);
|
||||
}
|
||||
if (skinnable.controller.getSettings().get(MODPACK_TYPE) == MODPACK_TYPE_MODRINTH) {
|
||||
if (MODPACK_TYPE_MODRINTH.equals(skinnable.controller.getSettings().get(MODPACK_TYPE))) {
|
||||
HintPane pane = new HintPane(MessageDialogPane.MessageType.INFO);
|
||||
pane.setText(i18n("modpack.wizard.step.initialization.modrinth.info"));
|
||||
borderPane.setTop(pane);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ModpackExportInfo {
|
||||
|
||||
private String authlibInjectorServer;
|
||||
|
||||
private List<McbbsModpackManifest.Origin> origins = new ArrayList<>();
|
||||
private final List<McbbsModpackManifest.Origin> origins = new ArrayList<>();
|
||||
|
||||
private boolean noCreateRemoteFiles;
|
||||
private boolean skipCurseForgeRemoteFiles;
|
||||
@@ -84,7 +84,7 @@ public class ModpackExportInfo {
|
||||
|
||||
/**
|
||||
* Description of this modpack.
|
||||
*
|
||||
* <p>
|
||||
* Supports plain HTML text.
|
||||
*/
|
||||
public String getDescription() {
|
||||
@@ -195,16 +195,18 @@ public class ModpackExportInfo {
|
||||
return noCreateRemoteFiles;
|
||||
}
|
||||
|
||||
public void setNoCreateRemoteFiles(boolean noCreateRemoteFiles) {
|
||||
public ModpackExportInfo setNoCreateRemoteFiles(boolean noCreateRemoteFiles) {
|
||||
this.noCreateRemoteFiles = noCreateRemoteFiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSkipCurseForgeRemoteFiles() {
|
||||
return skipCurseForgeRemoteFiles;
|
||||
}
|
||||
|
||||
public void setSkipCurseForgeRemoteFiles(boolean skipCurseForgeRemoteFiles) {
|
||||
public ModpackExportInfo setSkipCurseForgeRemoteFiles(boolean skipCurseForgeRemoteFiles) {
|
||||
this.skipCurseForgeRemoteFiles = skipCurseForgeRemoteFiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModpackExportInfo validate() throws NullPointerException {
|
||||
|
||||
Reference in new issue
Block a user