From 7dcd0eb61649a2d0ca0c056f9ecd24a0bf846fce Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Tue, 23 Oct 2018 13:52:47 +0800 Subject: [PATCH] Only display installer when game repository finished loading --- .../ui/download/ModpackInstallWizardProvider.java | 12 ++++++------ .../ui/download/VanillaInstallWizardProvider.java | 6 +++--- .../org/jackhuang/hmcl/ui/versions/GameList.java | 14 ++++++++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackInstallWizardProvider.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackInstallWizardProvider.java index 7925efd4d..c907252ee 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackInstallWizardProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/ModpackInstallWizardProvider.java @@ -1,5 +1,6 @@ package org.jackhuang.hmcl.ui.download; +import javafx.application.Platform; import javafx.scene.Node; import org.jackhuang.hmcl.download.DownloadProvider; 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; public class ModpackInstallWizardProvider implements WizardProvider { - private Profile profile; + private final Profile profile; private final File file; - public ModpackInstallWizardProvider() { - this(null); + public ModpackInstallWizardProvider(Profile profile) { + this(profile, null); } - public ModpackInstallWizardProvider(File modpackFile) { + public ModpackInstallWizardProvider(Profile profile, File modpackFile) { + this.profile = profile; this.file = modpackFile; } @Override public void start(Map settings) { - profile = Profiles.getSelectedProfile(); - if (file != null) settings.put(ModpackPage.MODPACK_FILE, file); settings.put(PROFILE, profile); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VanillaInstallWizardProvider.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VanillaInstallWizardProvider.java index 8bf71e4a7..f82fb61d1 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VanillaInstallWizardProvider.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VanillaInstallWizardProvider.java @@ -33,14 +33,14 @@ import java.util.Map; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public final class VanillaInstallWizardProvider implements WizardProvider { - private Profile profile; + private final Profile profile; - public VanillaInstallWizardProvider() { + public VanillaInstallWizardProvider(Profile profile) { + this.profile = profile; } @Override public void start(Map settings) { - profile = Profiles.getSelectedProfile(); settings.put(PROFILE, profile); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameList.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameList.java index 488853269..783a41da3 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameList.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameList.java @@ -101,12 +101,18 @@ public class GameList extends Control implements DecoratorPage { return new GameListSkin(this); } - public void addNewGame() { - Controllers.getDecorator().startWizard(new VanillaInstallWizardProvider(), i18n("install.new_game")); + void addNewGame() { + Profile profile = Profiles.getSelectedProfile(); + if (profile.getRepository().isLoaded()) { + Controllers.getDecorator().startWizard(new VanillaInstallWizardProvider(profile), i18n("install.new_game")); + } } - public void importModpack() { - Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(), i18n("install.modpack")); + void importModpack() { + Profile profile = Profiles.getSelectedProfile(); + if (profile.getRepository().isLoaded()) { + Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(profile), i18n("install.modpack")); + } } public void refresh() {