mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 22:07:01 -04:00
fix(ui): crash.
This commit is contained in:
parent
1b8cf6b1e5
commit
e4a1fa5bb4
@ -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));
|
||||
|
||||
|
@ -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<MainPage> 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<State> stateProperty() {
|
||||
return getMainPage().stateProperty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,7 +114,7 @@ public class RootPage extends DecoratorTabPage {
|
||||
return mainPage;
|
||||
}
|
||||
|
||||
private static class Skin extends SkinBase<RootPage> {
|
||||
private static class Skin extends DecoratorAnimatedPageSkin<RootPage> {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <T extends Node> Supplier<T> loadVersionFor(Supplier<T> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user