Split download wizard into { new game, install modpack }
This commit is contained in:
@@ -90,7 +90,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
this.profile = event.getProfile();
|
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"));
|
FXUtils.installTooltip(btnAdd, i18n("install"));
|
||||||
btnRefresh.setOnMouseClicked(e -> Settings.instance().getSelectedProfile().getRepository().refreshVersionsAsync().start());
|
btnRefresh.setOnMouseClicked(e -> Settings.instance().getSelectedProfile().getRepository().refreshVersionsAsync().start());
|
||||||
FXUtils.installTooltip(btnRefresh, i18n("button.refresh"));
|
FXUtils.installTooltip(btnRefresh, i18n("button.refresh"));
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
|
|
||||||
public final class DownloadWizardProvider implements WizardProvider {
|
public final class DownloadWizardProvider implements WizardProvider {
|
||||||
private Profile profile;
|
private Profile profile;
|
||||||
|
private final int type;
|
||||||
|
|
||||||
|
public DownloadWizardProvider(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Map<String, Object> settings) {
|
public void start(Map<String, Object> settings) {
|
||||||
@@ -80,7 +85,7 @@ public final class DownloadWizardProvider implements WizardProvider {
|
|||||||
settings.put("success_message", i18n("install.success"));
|
settings.put("success_message", i18n("install.success"));
|
||||||
settings.put("failure_message", i18n("install.failed"));
|
settings.put("failure_message", i18n("install.failed"));
|
||||||
|
|
||||||
switch (Lang.parseInt(settings.get(InstallTypePage.INSTALL_TYPE), -1)) {
|
switch (type) {
|
||||||
case 0: return finishVersionDownloadingAsync(settings);
|
case 0: return finishVersionDownloadingAsync(settings);
|
||||||
case 1: return finishModpackInstallingAsync(settings);
|
case 1: return finishModpackInstallingAsync(settings);
|
||||||
default: return null;
|
default: return null;
|
||||||
@@ -92,16 +97,13 @@ public final class DownloadWizardProvider implements WizardProvider {
|
|||||||
DownloadProvider provider = profile.getDependency().getDownloadProvider();
|
DownloadProvider provider = profile.getDependency().getDownloadProvider();
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case 0:
|
case 0:
|
||||||
return new InstallTypePage(controller);
|
switch (type) {
|
||||||
case 1:
|
|
||||||
int subStep = Lang.parseInt(settings.get(InstallTypePage.INSTALL_TYPE), -1);
|
|
||||||
switch (subStep) {
|
|
||||||
case 0:
|
case 0:
|
||||||
return new VersionsPage(controller, i18n("install.installer.choose", i18n("install.installer.game")), "", provider, "game", () -> controller.onNext(new InstallersPage(controller, profile.getRepository(), provider)));
|
return new VersionsPage(controller, i18n("install.installer.choose", i18n("install.installer.game")), "", provider, "game", () -> controller.onNext(new InstallersPage(controller, profile.getRepository(), provider)));
|
||||||
case 1:
|
case 1:
|
||||||
return new ModpackPage(controller);
|
return new ModpackPage(controller);
|
||||||
default:
|
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:
|
default:
|
||||||
throw new IllegalStateException("error step " + step + ", settings: " + settings + ", pages: " + controller.getPages());
|
throw new IllegalStateException("error step " + step + ", settings: " + settings + ", pages: " + controller.getPages());
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Hello Minecraft! Launcher.
|
|
||||||
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
|
|
||||||
*
|
|
||||||
* 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<Object> 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<String, Object> settings) {
|
|
||||||
settings.remove(INSTALL_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return i18n("install.select");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String INSTALL_TYPE = "INSTALL_TYPE";
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import com.jfoenix.controls.JFXListView?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<fx:root xmlns="http://javafx.com/javafx"
|
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
|
||||||
type="StackPane">
|
|
||||||
<StackPane prefHeight="400.0" prefWidth="600.0">
|
|
||||||
<JFXListView fx:id="list" styleClass="jfx-list-view" maxWidth="300" maxHeight="100">
|
|
||||||
<BorderPane mouseTransparent="true">
|
|
||||||
<left>
|
|
||||||
<Label text="%install.new_game" />
|
|
||||||
</left>
|
|
||||||
<right>
|
|
||||||
<fx:include source="/assets/svg/arrow-right.fxml"/>
|
|
||||||
</right>
|
|
||||||
</BorderPane>
|
|
||||||
<BorderPane mouseTransparent="true">
|
|
||||||
<left>
|
|
||||||
<Label text="%install.modpack" />
|
|
||||||
</left>
|
|
||||||
<right>
|
|
||||||
<fx:include source="/assets/svg/arrow-right.fxml"/>
|
|
||||||
</right>
|
|
||||||
</BorderPane>
|
|
||||||
</JFXListView>
|
|
||||||
</StackPane>
|
|
||||||
|
|
||||||
<HBox alignment="BOTTOM_CENTER" style="-fx-padding: 20;" pickOnBounds="false">
|
|
||||||
<Label text="%modpack.introduction" />
|
|
||||||
</HBox>
|
|
||||||
</fx:root>
|
|
||||||
Reference in New Issue
Block a user