From fecd567eabcf6d62f7b524e3ac5f45fd894696c7 Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 26 Oct 2024 23:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=20ContainerAnimations=20(#33?= =?UTF-8?q?95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/AddAuthlibInjectorServerPane.java | 6 +- .../ui/animation/ContainerAnimations.java | 344 ++++++++++-------- .../hmcl/ui/construct/Navigator.java | 2 +- .../hmcl/ui/construct/SpinnerPane.java | 6 +- .../ui/decorator/DecoratorController.java | 2 +- .../hmcl/ui/decorator/DecoratorSkin.java | 6 +- .../hmcl/ui/decorator/DecoratorTabPage.java | 2 +- .../decorator/DecoratorWizardDisplayer.java | 2 +- .../hmcl/ui/download/DownloadPage.java | 2 +- .../hmcl/ui/download/VersionsPage.java | 8 +- .../hmcl/ui/main/LauncherSettingsPage.java | 2 +- .../org/jackhuang/hmcl/ui/main/MainPage.java | 4 +- .../hmcl/ui/versions/ModListPageSkin.java | 2 +- .../hmcl/ui/versions/VersionPage.java | 2 +- 14 files changed, 221 insertions(+), 169 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAuthlibInjectorServerPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAuthlibInjectorServerPane.java index 914046649..c19c80131 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAuthlibInjectorServerPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAuthlibInjectorServerPane.java @@ -147,7 +147,7 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement confirmServerPane.setActions(prevButton, cancelButton, finishButton); } - this.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer()); + this.setContent(addServerPane, ContainerAnimations.NONE); lblCreationWarning.maxWidthProperty().bind(((FlowPane) lblCreationWarning.getParent()).widthProperty()); btnAddNext.disableProperty().bind(txtServerUrl.textProperty().isEmpty()); @@ -198,7 +198,7 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverBeingAdded.getUrl()).getProtocol())); - this.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer()); + this.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT); } else { LOG.warning("Failed to resolve auth server: " + url, exception); lblCreationWarning.setText(resolveFetchExceptionMessage(exception)); @@ -208,7 +208,7 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement } private void onAddPrev() { - this.setContent(addServerPane, ContainerAnimations.SWIPE_RIGHT.getAnimationProducer()); + this.setContent(addServerPane, ContainerAnimations.SWIPE_RIGHT); } private void onAddFinish() { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/ContainerAnimations.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/ContainerAnimations.java index 20bca631d..281ac618d 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/ContainerAnimations.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/ContainerAnimations.java @@ -1,6 +1,6 @@ /* * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui and contributors + * Copyright (C) 2020 huangyuhui and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,165 +27,225 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; -public enum ContainerAnimations { - NONE(c -> { - c.getPreviousNode().setTranslateX(0); - c.getPreviousNode().setTranslateY(0); - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(1); - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - }, c -> Collections.emptyList()), +public enum ContainerAnimations implements AnimationProducer { + NONE { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setTranslateX(0); + c.getPreviousNode().setTranslateY(0); + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(1); + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + } + + @Override + public List animate(AnimationHandler c) { + return Collections.emptyList(); + } + }, /** * A fade between the old and new view */ - FADE(c -> { - c.getPreviousNode().setTranslateX(0); - c.getPreviousNode().setTranslateY(0); - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(1); - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(0); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + FADE { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setTranslateX(0); + c.getPreviousNode().setTranslateY(0); + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(1); + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(0); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(c.getCurrentNode().opacityProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(c.getDuration(), new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH), - new KeyValue(c.getCurrentNode().opacityProperty(), 1, Interpolator.EASE_BOTH)))), + new KeyValue(c.getCurrentNode().opacityProperty(), 1, Interpolator.EASE_BOTH))); + } + }, /** * A fade between the old and new view */ - FADE_IN(c -> { - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(0); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + FADE_IN { + @Override + public void init(AnimationHandler c) { + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(0); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)), new KeyFrame(c.getDuration(), - new KeyValue(c.getCurrentNode().opacityProperty(), 1, FXUtils.SINE)))), + new KeyValue(c.getCurrentNode().opacityProperty(), 1, FXUtils.SINE))); + } + }, /** * A fade between the old and new view */ - FADE_OUT(c -> { - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + FADE_OUT { + @Override + public void init(AnimationHandler c) { + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().opacityProperty(), 1, FXUtils.SINE)), new KeyFrame(c.getDuration(), - new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)))), + new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE))); + } + }, /** * A zoom effect */ - ZOOM_IN(c -> { - c.getPreviousNode().setTranslateX(0); - c.getPreviousNode().setTranslateY(0); - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(1); - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + ZOOM_IN { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setTranslateX(0); + c.getPreviousNode().setTranslateY(0); + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(1); + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)), new KeyFrame(c.getDuration(), new KeyValue(c.getPreviousNode().scaleXProperty(), 4, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().scaleYProperty(), 4, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH)))), + new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH))); + } + }, /** * A zoom effect */ - ZOOM_OUT(c -> { - c.getPreviousNode().setTranslateX(0); - c.getPreviousNode().setTranslateY(0); - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(1); - c.getCurrentNode().setTranslateX(0); - c.getCurrentNode().setTranslateY(0); - }, c -> - (Arrays.asList(new KeyFrame(Duration.ZERO, + ZOOM_OUT { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setTranslateX(0); + c.getPreviousNode().setTranslateY(0); + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(1); + c.getCurrentNode().setTranslateX(0); + c.getCurrentNode().setTranslateY(0); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)), new KeyFrame(c.getDuration(), new KeyValue(c.getPreviousNode().scaleXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().scaleYProperty(), 0, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH))))), + new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH))); + } + }, /** * A swipe effect */ - SWIPE_LEFT(c -> { - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(0); - c.getPreviousNode().setTranslateX(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + SWIPE_LEFT { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(0); + c.getPreviousNode().setTranslateX(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().translateXProperty(), c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(c.getDuration(), new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().translateXProperty(), -c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH)))), + new KeyValue(c.getPreviousNode().translateXProperty(), -c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH))); + } + }, /** * A swipe effect */ - SWIPE_RIGHT(c -> { - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(0); - c.getPreviousNode().setTranslateX(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - c.getCurrentNode().setTranslateX(-c.getCurrentRoot().getWidth()); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + SWIPE_RIGHT { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(0); + c.getPreviousNode().setTranslateX(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + c.getCurrentNode().setTranslateX(-c.getCurrentRoot().getWidth()); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().translateXProperty(), -c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(c.getDuration(), new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().translateXProperty(), c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH)))), + new KeyValue(c.getPreviousNode().translateXProperty(), c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH))); + } + }, - SWIPE_LEFT_FADE_SHORT(c -> { - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(0); - c.getPreviousNode().setTranslateX(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + SWIPE_LEFT_FADE_SHORT { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(0); + c.getPreviousNode().setTranslateX(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().translateXProperty(), 50, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(c.getCurrentNode().opacityProperty(), 0, Interpolator.EASE_BOTH), @@ -194,19 +254,26 @@ public enum ContainerAnimations { new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), -50, Interpolator.EASE_BOTH), new KeyValue(c.getCurrentNode().opacityProperty(), 1, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH)))), + new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH))); + } + }, - SWIPE_RIGHT_FADE_SHORT(c -> { - c.getPreviousNode().setScaleX(1); - c.getPreviousNode().setScaleY(1); - c.getPreviousNode().setOpacity(0); - c.getPreviousNode().setTranslateX(0); - c.getCurrentNode().setScaleX(1); - c.getCurrentNode().setScaleY(1); - c.getCurrentNode().setOpacity(1); - c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); - }, c -> - Arrays.asList(new KeyFrame(Duration.ZERO, + SWIPE_RIGHT_FADE_SHORT { + @Override + public void init(AnimationHandler c) { + c.getPreviousNode().setScaleX(1); + c.getPreviousNode().setScaleY(1); + c.getPreviousNode().setOpacity(0); + c.getPreviousNode().setTranslateX(0); + c.getCurrentNode().setScaleX(1); + c.getCurrentNode().setScaleY(1); + c.getCurrentNode().setOpacity(1); + c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth()); + } + + @Override + public List animate(AnimationHandler c) { + return Arrays.asList(new KeyFrame(Duration.ZERO, new KeyValue(c.getCurrentNode().translateXProperty(), -50, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(c.getCurrentNode().opacityProperty(), 0, Interpolator.EASE_BOTH), @@ -215,38 +282,12 @@ public enum ContainerAnimations { new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(c.getPreviousNode().translateXProperty(), 50, Interpolator.EASE_BOTH), new KeyValue(c.getCurrentNode().opacityProperty(), 1, Interpolator.EASE_BOTH), - new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH)))); + new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH))); + } + }; - private final AnimationProducer animationProducer; private ContainerAnimations opposite; - ContainerAnimations(Consumer init, Function> animationProducer) { - this.animationProducer = new AnimationProducer() { - @Override - public void init(AnimationHandler handler) { - init.accept(handler); - } - - @Override - public List animate(AnimationHandler handler) { - return animationProducer.apply(handler); - } - - @Override - public @Nullable AnimationProducer opposite() { - return opposite != null ? opposite.getAnimationProducer() : null; - } - }; - } - - public AnimationProducer getAnimationProducer() { - return animationProducer; - } - - public ContainerAnimations getOpposite() { - return opposite; - } - static { NONE.opposite = NONE; FADE.opposite = FADE; @@ -257,4 +298,15 @@ public enum ContainerAnimations { ZOOM_IN.opposite = ZOOM_OUT; ZOOM_OUT.opposite = ZOOM_IN; } + + @Override + public abstract void init(AnimationHandler handler); + + @Override + public abstract List animate(AnimationHandler handler); + + @Override + public @Nullable ContainerAnimations opposite() { + return opposite; + } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/Navigator.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/Navigator.java index 209c893f7..4ec498992 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/Navigator.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/Navigator.java @@ -126,7 +126,7 @@ public class Navigator extends TransitionPane { if (obj instanceof AnimationProducer) { setContent(node, (AnimationProducer) obj); } else { - setContent(node, ContainerAnimations.NONE.getAnimationProducer()); + setContent(node, ContainerAnimations.NONE); } NavigationEvent navigated = new NavigationEvent(this, node, Navigation.NavigationDirection.PREVIOUS, NavigationEvent.NAVIGATED); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/SpinnerPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/SpinnerPane.java index 8686011c2..2d6ee81f8 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/SpinnerPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/SpinnerPane.java @@ -146,12 +146,12 @@ public class SpinnerPane extends Control { observer = FXUtils.observeWeak(() -> { if (getSkinnable().getFailedReason() != null) { - root.setContent(failedPane, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(failedPane, ContainerAnimations.FADE); failedReasonLabel.setText(getSkinnable().getFailedReason()); } else if (getSkinnable().isLoading()) { - root.setContent(topPane, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(topPane, ContainerAnimations.FADE); } else { - root.setContent(contentPane, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(contentPane, ContainerAnimations.FADE); } }, getSkinnable().loadingProperty(), getSkinnable().failedReasonProperty()); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java index dc34c42de..7b7b55229 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java @@ -457,7 +457,7 @@ public class DecoratorController { public void startWizard(WizardProvider wizardProvider, String category) { FXUtils.checkFxUserThread(); - navigator.navigate(new DecoratorWizardDisplayer(wizardProvider, category), ContainerAnimations.FADE.getAnimationProducer()); + navigator.navigate(new DecoratorWizardDisplayer(wizardProvider, category), ContainerAnimations.FADE); } // ==== Authlib Injector DnD ==== diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java index 21b33277a..161bb51be 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java @@ -174,11 +174,11 @@ public class DecoratorSkin extends SkinBase { if (s.isAnimate()) { AnimationProducer animation; if (skinnable.getNavigationDirection() == Navigation.NavigationDirection.NEXT) { - animation = ContainerAnimations.SWIPE_LEFT_FADE_SHORT.getAnimationProducer(); + animation = ContainerAnimations.SWIPE_LEFT_FADE_SHORT; } else if (skinnable.getNavigationDirection() == Navigation.NavigationDirection.PREVIOUS) { - animation = ContainerAnimations.SWIPE_RIGHT_FADE_SHORT.getAnimationProducer(); + animation = ContainerAnimations.SWIPE_RIGHT_FADE_SHORT; } else { - animation = ContainerAnimations.FADE.getAnimationProducer(); + animation = ContainerAnimations.FADE; } skinnable.setNavigationDirection(Navigation.NavigationDirection.START); navBarPane.setContent(node, animation); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorTabPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorTabPage.java index 325edd269..e7cf6b033 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorTabPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorTabPage.java @@ -36,7 +36,7 @@ public abstract class DecoratorTabPage extends DecoratorTransitionPage implement if (newValue.getNode() != null) { onNavigating(getCurrentPage()); if (getCurrentPage() != null) getCurrentPage().fireEvent(new Navigator.NavigationEvent(null, getCurrentPage(), Navigation.NavigationDirection.NEXT, Navigator.NavigationEvent.NAVIGATING)); - navigate(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer()); + navigate(newValue.getNode(), ContainerAnimations.FADE); onNavigated(getCurrentPage()); if (getCurrentPage() != null) getCurrentPage().fireEvent(new Navigator.NavigationEvent(null, getCurrentPage(), Navigation.NavigationDirection.NEXT, Navigator.NavigationEvent.NAVIGATED)); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorWizardDisplayer.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorWizardDisplayer.java index ed6164e7f..e6a6b5b99 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorWizardDisplayer.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorWizardDisplayer.java @@ -74,7 +74,7 @@ public class DecoratorWizardDisplayer extends DecoratorTransitionPage implements @Override public void navigateTo(Node page, Navigation.NavigationDirection nav) { displayer.navigateTo(page, nav); - navigate(page, nav.getAnimation().getAnimationProducer()); + navigate(page, nav.getAnimation()); String prefix = category == null ? "" : category + " - "; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java index 7b8e89486..74e447abe 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java @@ -97,7 +97,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage tab.select(newGameTab); FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> { - transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer()); + transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE); }); { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java index f41981030..3d4a3c3ef 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java @@ -210,7 +210,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres @Override public void refresh() { VersionList currentVersionList = versionList; - root.setContent(spinner, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(spinner, ContainerAnimations.FADE); executor = currentVersionList.refreshAsync(gameVersion).whenComplete((result, exception) -> { if (exception == null) { List items = loadVersions(); @@ -218,7 +218,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres Platform.runLater(() -> { if (versionList != currentVersionList) return; if (currentVersionList.getVersions(gameVersion).isEmpty()) { - root.setContent(emptyPane, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(emptyPane, ContainerAnimations.FADE); } else { if (items.isEmpty()) { chkRelease.setSelected(true); @@ -227,14 +227,14 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres } else { list.getItems().setAll(items); } - root.setContent(center, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(center, ContainerAnimations.FADE); } }); } else { LOG.warning("Failed to fetch versions list", exception); Platform.runLater(() -> { if (versionList != currentVersionList) return; - root.setContent(failedPane, ContainerAnimations.FADE.getAnimationProducer()); + root.setContent(failedPane, ContainerAnimations.FADE); }); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/LauncherSettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/LauncherSettingsPage.java index 4806f58d5..8e59718fe 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/LauncherSettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/LauncherSettingsPage.java @@ -66,7 +66,7 @@ public class LauncherSettingsPage extends DecoratorAnimatedPage implements Decor gameTab.initializeIfNeeded(); gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null); FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> { - transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer()); + transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE); }); { 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 1c0f99162..08999fb7a 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 @@ -116,7 +116,7 @@ public final class MainPage extends StackPane implements DecoratorPage { announcementBox.getChildren().add(announcementCard); announcementPane = new TransitionPane(); - announcementPane.setContent(announcementBox, ContainerAnimations.NONE.getAnimationProducer()); + announcementPane.setContent(announcementBox, ContainerAnimations.NONE); getChildren().add(announcementPane); } @@ -301,7 +301,7 @@ public final class MainPage extends StackPane implements DecoratorPage { public void hideAnnouncementPane() { if (announcementPane != null) { config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION); - announcementPane.setContent(new StackPane(), ContainerAnimations.FADE.getAnimationProducer()); + announcementPane.setContent(new StackPane(), ContainerAnimations.FADE); } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java index 7da53efe9..cb3883342 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java @@ -204,7 +204,7 @@ class ModListPageSkin extends SkinBase { private void changeToolbar(HBox newToolbar) { Node oldToolbar = toolbarPane.getCurrentNode(); if (newToolbar != oldToolbar) { - toolbarPane.setContent(newToolbar, ContainerAnimations.FADE.getAnimationProducer()); + toolbarPane.setContent(newToolbar, ContainerAnimations.FADE); if (newToolbar == searchBar) { searchField.requestFocus(); } 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 0866e1e6e..6d36a9051 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 @@ -78,7 +78,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage tab.select(versionSettingsTab); FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> { - transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer()); + transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE); }); listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST));