diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPage.java index 43249550f..e9c052c3f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPage.java @@ -90,7 +90,7 @@ public final class MainPage extends StackPane implements DecoratorPage { this.profile = event.getProfile(); }); - btnAdd.setOnMouseClicked(e -> Controllers.getDecorator().startWizard(new DownloadWizardProvider(), i18n("install"))); + btnAdd.setOnMouseClicked(e -> Controllers.getDecorator().startWizard(new DownloadWizardProvider(0), i18n("install"))); FXUtils.installTooltip(btnAdd, i18n("install")); btnRefresh.setOnMouseClicked(e -> Settings.instance().getSelectedProfile().getRepository().refreshVersionsAsync().start()); FXUtils.installTooltip(btnRefresh, i18n("button.refresh")); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadWizardProvider.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadWizardProvider.java index 2c6721799..f5635bdc0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadWizardProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadWizardProvider.java @@ -38,6 +38,11 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public final class DownloadWizardProvider implements WizardProvider { private Profile profile; + private final int type; + + public DownloadWizardProvider(int type) { + this.type = type; + } @Override public void start(Map settings) { @@ -80,7 +85,7 @@ public final class DownloadWizardProvider implements WizardProvider { settings.put("success_message", i18n("install.success")); settings.put("failure_message", i18n("install.failed")); - switch (Lang.parseInt(settings.get(InstallTypePage.INSTALL_TYPE), -1)) { + switch (type) { case 0: return finishVersionDownloadingAsync(settings); case 1: return finishModpackInstallingAsync(settings); default: return null; @@ -92,16 +97,13 @@ public final class DownloadWizardProvider implements WizardProvider { DownloadProvider provider = profile.getDependency().getDownloadProvider(); switch (step) { case 0: - return new InstallTypePage(controller); - case 1: - int subStep = Lang.parseInt(settings.get(InstallTypePage.INSTALL_TYPE), -1); - switch (subStep) { + switch (type) { case 0: return new VersionsPage(controller, i18n("install.installer.choose", i18n("install.installer.game")), "", provider, "game", () -> controller.onNext(new InstallersPage(controller, profile.getRepository(), provider))); case 1: return new ModpackPage(controller); default: - throw new IllegalStateException("Error step " + step + ", subStep " + subStep + ", settings: " + settings + ", pages: " + controller.getPages()); + throw new IllegalStateException("Error step " + step + ", subStep " + type + ", settings: " + settings + ", pages: " + controller.getPages()); } default: throw new IllegalStateException("error step " + step + ", settings: " + settings + ", pages: " + controller.getPages()); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallTypePage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallTypePage.java deleted file mode 100644 index 00a119b5f..000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallTypePage.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Hello Minecraft! Launcher. - * Copyright (C) 2018 huangyuhui - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see {http://www.gnu.org/licenses/}. - */ -package org.jackhuang.hmcl.ui.download; - -import com.jfoenix.controls.JFXListView; -import javafx.fxml.FXML; -import javafx.scene.layout.StackPane; - -import org.jackhuang.hmcl.ui.FXUtils; -import org.jackhuang.hmcl.ui.wizard.WizardController; -import org.jackhuang.hmcl.ui.wizard.WizardPage; -import static org.jackhuang.hmcl.util.i18n.I18n.i18n; - -import java.util.Map; - -public final class InstallTypePage extends StackPane implements WizardPage { - - @FXML private JFXListView list; - - public InstallTypePage(WizardController controller) { - - FXUtils.loadFXML(this, "/assets/fxml/download/dltype.fxml"); - list.setOnMouseClicked(e -> { - if (list.getSelectionModel().getSelectedIndex() < 0) - return; - controller.getSettings().put(INSTALL_TYPE, list.getSelectionModel().getSelectedIndex()); - controller.onNext(); - }); - } - - @Override - public void cleanup(Map settings) { - settings.remove(INSTALL_TYPE); - } - - @Override - public String getTitle() { - return i18n("install.select"); - } - - public static final String INSTALL_TYPE = "INSTALL_TYPE"; -} diff --git a/HMCL/src/main/resources/assets/fxml/download/dltype.fxml b/HMCL/src/main/resources/assets/fxml/download/dltype.fxml deleted file mode 100644 index c558bc756..000000000 --- a/HMCL/src/main/resources/assets/fxml/download/dltype.fxml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -