From ff4940e79fa8037229136b1b58f27b8f186a17b1 Mon Sep 17 00:00:00 2001 From: Glavo Date: Wed, 26 Feb 2025 01:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=97=AD=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=99=A8=E6=97=B6=E7=9A=84=E6=B7=A1=E5=87=BA=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=20(#3652)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加关闭启动器时的淡出动画 * update --- .../ui/decorator/DecoratorController.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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 2d0d555a0..002db232e 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 @@ -19,6 +19,10 @@ package org.jackhuang.hmcl.ui.decorator; import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXSnackbar; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; import javafx.application.Platform; import javafx.beans.InvalidationListener; import javafx.beans.WeakInvalidationListener; @@ -35,6 +39,7 @@ import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.stage.Stage; +import javafx.util.Duration; import org.jackhuang.hmcl.Launcher; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD; import org.jackhuang.hmcl.setting.EnumBackgroundImage; @@ -42,6 +47,7 @@ import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.account.AddAuthlibInjectorServerPane; +import org.jackhuang.hmcl.ui.animation.AnimationUtils; import org.jackhuang.hmcl.ui.animation.ContainerAnimations; import org.jackhuang.hmcl.ui.construct.DialogAware; import org.jackhuang.hmcl.ui.construct.DialogCloseEvent; @@ -49,6 +55,7 @@ import org.jackhuang.hmcl.ui.construct.Navigator; import org.jackhuang.hmcl.ui.construct.StackContainerPane; import org.jackhuang.hmcl.ui.wizard.Refreshable; import org.jackhuang.hmcl.ui.wizard.WizardProvider; +import org.jackhuang.hmcl.util.platform.OperatingSystem; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -81,7 +88,32 @@ public class DecoratorController { public DecoratorController(Stage stage, Node mainPage) { decorator = new Decorator(stage); - decorator.setOnCloseButtonAction(Launcher::stopApplication); + decorator.setOnCloseButtonAction(() -> { + if (AnimationUtils.isAnimationEnabled() && !OperatingSystem.CURRENT_OS.isLinuxOrBSD()) { + Interpolator ease = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); + + Timeline timeline = (new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(decorator.opacityProperty(), 1, ease), + new KeyValue(decorator.translateYProperty(), 0, ease), + new KeyValue(decorator.scaleXProperty(), 1, ease), + new KeyValue(decorator.scaleYProperty(), 1, ease), + new KeyValue(decorator.scaleZProperty(), 0.3, ease) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(decorator.opacityProperty(), 0, ease), + new KeyValue(decorator.translateYProperty(), 200, ease), + new KeyValue(decorator.scaleXProperty(), 0.3, ease), + new KeyValue(decorator.scaleYProperty(), 0.3, ease), + new KeyValue(decorator.scaleZProperty(), 0.3, ease) + ) + )); + timeline.setOnFinished(event -> Launcher.stopApplication()); + timeline.play(); + } else { + Launcher.stopApplication(); + } + }); decorator.titleTransparentProperty().bind(config().titleTransparentProperty()); navigator = new Navigator();