diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index 34757369d..bbfe9488e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -90,7 +90,7 @@ public final class MainPage extends StackPane implements DecoratorPage { titleLabel.getStyleClass().add("jfx-decorator-title"); titleNode.getChildren().setAll(titleIcon, titleLabel); - state.setValue(State.fromTitleNode(titleNode)); + state.setValue(new State(null, titleNode, false, false, true)); setPadding(new Insets(20)); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java index 33619b809..c6b2fa13c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/RootPage.java @@ -17,9 +17,7 @@ */ package org.jackhuang.hmcl.ui.main; -import javafx.scene.Node; -import javafx.scene.control.SkinBase; -import javafx.scene.layout.BorderPane; +import javafx.beans.property.ReadOnlyObjectProperty; import org.jackhuang.hmcl.event.EventBus; import org.jackhuang.hmcl.event.RefreshedVersionsEvent; import org.jackhuang.hmcl.game.HMCLGameRepository; @@ -36,8 +34,8 @@ import org.jackhuang.hmcl.ui.SVG; import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem; import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.AdvancedListItem; -import org.jackhuang.hmcl.ui.construct.TabHeader; -import org.jackhuang.hmcl.ui.decorator.DecoratorTabPage; +import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage; +import org.jackhuang.hmcl.ui.decorator.DecoratorPage; import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider; import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem; import org.jackhuang.hmcl.ui.versions.Versions; @@ -57,14 +55,10 @@ import static org.jackhuang.hmcl.ui.FXUtils.runInFX; import static org.jackhuang.hmcl.ui.versions.VersionPage.wrap; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class RootPage extends DecoratorTabPage { +public class RootPage extends DecoratorAnimatedPage implements DecoratorPage { private MainPage mainPage = null; - private final TabHeader.Tab mainTab = new TabHeader.Tab<>("main"); - public RootPage() { - setLeftPaneWidth(200); - EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class) .register(event -> onRefreshedVersions((HMCLGameRepository) event.getSource())); @@ -72,25 +66,13 @@ public class RootPage extends DecoratorTabPage { if (profile != null && profile.getRepository().isLoaded()) onRefreshedVersions(Profiles.selectedProfileProperty().get().getRepository()); - mainTab.setNodeSupplier(this::getMainPage); - getTabs().setAll(mainTab); + getStyleClass().remove("gray-background"); + getLeft().getStyleClass().add("gray-background"); } @Override - public boolean back() { - if (mainTab.isSelected()) - return true; - else { - getSelectionModel().select(mainTab); - return false; - } - } - - @Override - protected void onNavigated(Node to) { - backableProperty().set(!(to instanceof MainPage)); - - super.onNavigated(to); + public ReadOnlyObjectProperty stateProperty() { + return getMainPage().stateProperty(); } @Override @@ -132,7 +114,7 @@ public class RootPage extends DecoratorTabPage { return mainPage; } - private static class Skin extends SkinBase { + private static class Skin extends DecoratorAnimatedPageSkin { protected Skin(RootPage control) { super(control); @@ -195,18 +177,8 @@ public class RootPage extends DecoratorTabPage { .add(launcherSettingsItem); // the root page, with the sidebar in left, navigator in center. - BorderPane root = new BorderPane(); - sideBar.setPrefWidth(200); - root.setLeft(sideBar); - - { - control.transitionPane.getStyleClass().add("jfx-decorator-content-container"); - control.transitionPane.getChildren().setAll(getSkinnable().getMainPage()); - FXUtils.setOverflowHidden(control.transitionPane, 8); - root.setCenter(control.transitionPane); - } - - getChildren().setAll(root); + setLeft(sideBar); + setCenter(getSkinnable().getMainPage()); } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java index 8c9e9fd3a..4e7da72db 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java @@ -29,7 +29,6 @@ import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import org.jackhuang.hmcl.setting.Profile; -import org.jackhuang.hmcl.setting.Profiles; import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -78,9 +77,9 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage private Supplier loadVersionFor(Supplier nodeSupplier) { return () -> { T node = nodeSupplier.get(); - if (this.version.get() != null) { + if (version.get() != null) { if (node instanceof VersionPage.VersionLoadable) { - ((VersionPage.VersionLoadable) node).loadVersion(Profiles.getSelectedProfile(), null); + ((VersionLoadable) node).loadVersion(version.get().getProfile(), version.get().getVersion()); } } return node;