alt: navigate to game version list when no versions exist

This commit is contained in:
huanghongxun
2020-04-11 23:56:04 +08:00
parent 4c44a3c410
commit 80f27f5ea4
2 changed files with 25 additions and 4 deletions

View File

@@ -18,11 +18,9 @@
package org.jackhuang.hmcl.ui.main;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.SkinBase;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.event.EventBus;
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
import org.jackhuang.hmcl.game.HMCLGameRepository;
@@ -182,6 +180,26 @@ public class RootPage extends DecoratorTabPage {
return profileListPage;
}
public Tab getMainTab() {
return mainTab;
}
public Tab getSettingsTab() {
return settingsTab;
}
public Tab getGameTab() {
return gameTab;
}
public Tab getAccountTab() {
return accountTab;
}
public Tab getProfileTab() {
return profileTab;
}
private static class Skin extends SkinBase<RootPage> {
protected Skin(RootPage control) {

View File

@@ -19,16 +19,17 @@ package org.jackhuang.hmcl.ui.versions;
import javafx.stage.FileChooser;
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
import org.jackhuang.hmcl.game.GameDirectoryType;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.LauncherHelper;
import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.game.GameDirectoryType;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.construct.PromptDialogPane;
import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider;
@@ -150,7 +151,9 @@ public class Versions {
if (Accounts.getSelectedAccount() == null)
Controllers.getRootPage().checkAccount();
else if (id == null || !profile.getRepository().isLoaded() || !profile.getRepository().hasVersion(id))
Controllers.dialog(i18n("version.empty.launch"));
Controllers.dialog(i18n("version.empty.launch"), i18n("launch.failed"), MessageDialogPane.MessageType.ERROR, () -> {
Controllers.getRootPage().getSelectionModel().select(Controllers.getRootPage().getGameTab());
});
else
return true;
return false;