Only display installer when game repository finished loading

This commit is contained in:
huanghongxun
2018-10-23 13:52:47 +08:00
parent e79a95b885
commit 7dcd0eb616
3 changed files with 19 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
package org.jackhuang.hmcl.ui.download; package org.jackhuang.hmcl.ui.download;
import javafx.application.Platform;
import javafx.scene.Node; import javafx.scene.Node;
import org.jackhuang.hmcl.download.DownloadProvider; import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.game.ModpackHelper; import org.jackhuang.hmcl.game.ModpackHelper;
@@ -18,21 +19,20 @@ import static org.jackhuang.hmcl.util.Lang.tryCast;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public class ModpackInstallWizardProvider implements WizardProvider { public class ModpackInstallWizardProvider implements WizardProvider {
private Profile profile; private final Profile profile;
private final File file; private final File file;
public ModpackInstallWizardProvider() { public ModpackInstallWizardProvider(Profile profile) {
this(null); this(profile, null);
} }
public ModpackInstallWizardProvider(File modpackFile) { public ModpackInstallWizardProvider(Profile profile, File modpackFile) {
this.profile = profile;
this.file = modpackFile; this.file = modpackFile;
} }
@Override @Override
public void start(Map<String, Object> settings) { public void start(Map<String, Object> settings) {
profile = Profiles.getSelectedProfile();
if (file != null) if (file != null)
settings.put(ModpackPage.MODPACK_FILE, file); settings.put(ModpackPage.MODPACK_FILE, file);
settings.put(PROFILE, profile); settings.put(PROFILE, profile);

View File

@@ -33,14 +33,14 @@ import java.util.Map;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public final class VanillaInstallWizardProvider implements WizardProvider { public final class VanillaInstallWizardProvider implements WizardProvider {
private Profile profile; private final Profile profile;
public VanillaInstallWizardProvider() { public VanillaInstallWizardProvider(Profile profile) {
this.profile = profile;
} }
@Override @Override
public void start(Map<String, Object> settings) { public void start(Map<String, Object> settings) {
profile = Profiles.getSelectedProfile();
settings.put(PROFILE, profile); settings.put(PROFILE, profile);
} }

View File

@@ -101,12 +101,18 @@ public class GameList extends Control implements DecoratorPage {
return new GameListSkin(this); return new GameListSkin(this);
} }
public void addNewGame() { void addNewGame() {
Controllers.getDecorator().startWizard(new VanillaInstallWizardProvider(), i18n("install.new_game")); Profile profile = Profiles.getSelectedProfile();
if (profile.getRepository().isLoaded()) {
Controllers.getDecorator().startWizard(new VanillaInstallWizardProvider(profile), i18n("install.new_game"));
}
} }
public void importModpack() { void importModpack() {
Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(), i18n("install.modpack")); Profile profile = Profiles.getSelectedProfile();
if (profile.getRepository().isLoaded()) {
Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(profile), i18n("install.modpack"));
}
} }
public void refresh() { public void refresh() {