简化 ContainerAnimations (#3395)
This commit is contained in:
@@ -147,7 +147,7 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement
|
|||||||
confirmServerPane.setActions(prevButton, cancelButton, finishButton);
|
confirmServerPane.setActions(prevButton, cancelButton, finishButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer());
|
this.setContent(addServerPane, ContainerAnimations.NONE);
|
||||||
|
|
||||||
lblCreationWarning.maxWidthProperty().bind(((FlowPane) lblCreationWarning.getParent()).widthProperty());
|
lblCreationWarning.maxWidthProperty().bind(((FlowPane) lblCreationWarning.getParent()).widthProperty());
|
||||||
btnAddNext.disableProperty().bind(txtServerUrl.textProperty().isEmpty());
|
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()));
|
lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverBeingAdded.getUrl()).getProtocol()));
|
||||||
|
|
||||||
this.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer());
|
this.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT);
|
||||||
} else {
|
} else {
|
||||||
LOG.warning("Failed to resolve auth server: " + url, exception);
|
LOG.warning("Failed to resolve auth server: " + url, exception);
|
||||||
lblCreationWarning.setText(resolveFetchExceptionMessage(exception));
|
lblCreationWarning.setText(resolveFetchExceptionMessage(exception));
|
||||||
@@ -208,7 +208,7 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onAddPrev() {
|
private void onAddPrev() {
|
||||||
this.setContent(addServerPane, ContainerAnimations.SWIPE_RIGHT.getAnimationProducer());
|
this.setContent(addServerPane, ContainerAnimations.SWIPE_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAddFinish() {
|
private void onAddFinish() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Hello Minecraft! Launcher
|
* Hello Minecraft! Launcher
|
||||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* 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.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public enum ContainerAnimations {
|
public enum ContainerAnimations implements AnimationProducer {
|
||||||
NONE(c -> {
|
NONE {
|
||||||
c.getPreviousNode().setTranslateX(0);
|
@Override
|
||||||
c.getPreviousNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setScaleX(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getPreviousNode().setScaleY(1);
|
c.getPreviousNode().setTranslateY(0);
|
||||||
c.getPreviousNode().setOpacity(1);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setTranslateY(0);
|
c.getPreviousNode().setOpacity(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getCurrentNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getCurrentNode().setTranslateY(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
}, c -> Collections.emptyList()),
|
c.getCurrentNode().setScaleY(1);
|
||||||
|
c.getCurrentNode().setOpacity(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fade between the old and new view
|
* A fade between the old and new view
|
||||||
*/
|
*/
|
||||||
FADE(c -> {
|
FADE {
|
||||||
c.getPreviousNode().setTranslateX(0);
|
@Override
|
||||||
c.getPreviousNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setScaleX(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getPreviousNode().setScaleY(1);
|
c.getPreviousNode().setTranslateY(0);
|
||||||
c.getPreviousNode().setOpacity(1);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setTranslateY(0);
|
c.getPreviousNode().setOpacity(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getCurrentNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getCurrentNode().setTranslateY(0);
|
||||||
c.getCurrentNode().setOpacity(0);
|
c.getCurrentNode().setScaleX(1);
|
||||||
}, c ->
|
c.getCurrentNode().setScaleY(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setOpacity(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 0, Interpolator.EASE_BOTH)),
|
new KeyValue(c.getCurrentNode().opacityProperty(), 0, Interpolator.EASE_BOTH)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getPreviousNode().opacityProperty(), 0, Interpolator.EASE_BOTH),
|
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
|
* A fade between the old and new view
|
||||||
*/
|
*/
|
||||||
FADE_IN(c -> {
|
FADE_IN {
|
||||||
c.getCurrentNode().setTranslateX(0);
|
@Override
|
||||||
c.getCurrentNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getCurrentNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getCurrentNode().setTranslateY(0);
|
||||||
c.getCurrentNode().setOpacity(0);
|
c.getCurrentNode().setScaleX(1);
|
||||||
}, c ->
|
c.getCurrentNode().setScaleY(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setOpacity(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)),
|
new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)),
|
||||||
new KeyFrame(c.getDuration(),
|
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
|
* A fade between the old and new view
|
||||||
*/
|
*/
|
||||||
FADE_OUT(c -> {
|
FADE_OUT {
|
||||||
c.getCurrentNode().setTranslateX(0);
|
@Override
|
||||||
c.getCurrentNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getCurrentNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getCurrentNode().setTranslateY(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
}, c ->
|
c.getCurrentNode().setScaleY(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setOpacity(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 1, FXUtils.SINE)),
|
new KeyValue(c.getCurrentNode().opacityProperty(), 1, FXUtils.SINE)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)))),
|
new KeyValue(c.getCurrentNode().opacityProperty(), 0, FXUtils.SINE)));
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* A zoom effect
|
* A zoom effect
|
||||||
*/
|
*/
|
||||||
ZOOM_IN(c -> {
|
ZOOM_IN {
|
||||||
c.getPreviousNode().setTranslateX(0);
|
@Override
|
||||||
c.getPreviousNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setScaleX(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getPreviousNode().setScaleY(1);
|
c.getPreviousNode().setTranslateY(0);
|
||||||
c.getPreviousNode().setOpacity(1);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setTranslateY(0);
|
c.getPreviousNode().setOpacity(1);
|
||||||
}, c ->
|
c.getCurrentNode().setTranslateX(0);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)),
|
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getPreviousNode().scaleXProperty(), 4, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleXProperty(), 4, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().scaleYProperty(), 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
|
* A zoom effect
|
||||||
*/
|
*/
|
||||||
ZOOM_OUT(c -> {
|
ZOOM_OUT {
|
||||||
c.getPreviousNode().setTranslateX(0);
|
@Override
|
||||||
c.getPreviousNode().setTranslateY(0);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setScaleX(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getPreviousNode().setScaleY(1);
|
c.getPreviousNode().setTranslateY(0);
|
||||||
c.getPreviousNode().setOpacity(1);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setTranslateY(0);
|
c.getPreviousNode().setOpacity(1);
|
||||||
}, c ->
|
c.getCurrentNode().setTranslateX(0);
|
||||||
(Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleXProperty(), 1, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleYProperty(), 1, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)),
|
new KeyValue(c.getPreviousNode().opacityProperty(), 1, Interpolator.EASE_BOTH)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getPreviousNode().scaleXProperty(), 0, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().scaleXProperty(), 0, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().scaleYProperty(), 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
|
* A swipe effect
|
||||||
*/
|
*/
|
||||||
SWIPE_LEFT(c -> {
|
SWIPE_LEFT {
|
||||||
c.getPreviousNode().setScaleX(1);
|
@Override
|
||||||
c.getPreviousNode().setScaleY(1);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setOpacity(0);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getPreviousNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getPreviousNode().setOpacity(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
c.getCurrentNode().setScaleY(1);
|
||||||
}, c ->
|
c.getCurrentNode().setOpacity(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH),
|
new KeyValue(c.getCurrentNode().translateXProperty(), c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)),
|
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
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
|
* A swipe effect
|
||||||
*/
|
*/
|
||||||
SWIPE_RIGHT(c -> {
|
SWIPE_RIGHT {
|
||||||
c.getPreviousNode().setScaleX(1);
|
@Override
|
||||||
c.getPreviousNode().setScaleY(1);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setOpacity(0);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getPreviousNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getPreviousNode().setOpacity(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(-c.getCurrentRoot().getWidth());
|
c.getCurrentNode().setScaleY(1);
|
||||||
}, c ->
|
c.getCurrentNode().setOpacity(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateX(-c.getCurrentRoot().getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), -c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH),
|
new KeyValue(c.getCurrentNode().translateXProperty(), -c.getCurrentRoot().getWidth(), Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)),
|
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH)),
|
||||||
new KeyFrame(c.getDuration(),
|
new KeyFrame(c.getDuration(),
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
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 -> {
|
SWIPE_LEFT_FADE_SHORT {
|
||||||
c.getPreviousNode().setScaleX(1);
|
@Override
|
||||||
c.getPreviousNode().setScaleY(1);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setOpacity(0);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getPreviousNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getPreviousNode().setOpacity(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
c.getCurrentNode().setScaleY(1);
|
||||||
}, c ->
|
c.getCurrentNode().setOpacity(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), 50, Interpolator.EASE_BOTH),
|
new KeyValue(c.getCurrentNode().translateXProperty(), 50, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 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.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), -50, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().translateXProperty(), -50, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 1, 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 -> {
|
SWIPE_RIGHT_FADE_SHORT {
|
||||||
c.getPreviousNode().setScaleX(1);
|
@Override
|
||||||
c.getPreviousNode().setScaleY(1);
|
public void init(AnimationHandler c) {
|
||||||
c.getPreviousNode().setOpacity(0);
|
c.getPreviousNode().setScaleX(1);
|
||||||
c.getPreviousNode().setTranslateX(0);
|
c.getPreviousNode().setScaleY(1);
|
||||||
c.getCurrentNode().setScaleX(1);
|
c.getPreviousNode().setOpacity(0);
|
||||||
c.getCurrentNode().setScaleY(1);
|
c.getPreviousNode().setTranslateX(0);
|
||||||
c.getCurrentNode().setOpacity(1);
|
c.getCurrentNode().setScaleX(1);
|
||||||
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
c.getCurrentNode().setScaleY(1);
|
||||||
}, c ->
|
c.getCurrentNode().setOpacity(1);
|
||||||
Arrays.asList(new KeyFrame(Duration.ZERO,
|
c.getCurrentNode().setTranslateX(c.getCurrentRoot().getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyFrame> animate(AnimationHandler c) {
|
||||||
|
return Arrays.asList(new KeyFrame(Duration.ZERO,
|
||||||
new KeyValue(c.getCurrentNode().translateXProperty(), -50, Interpolator.EASE_BOTH),
|
new KeyValue(c.getCurrentNode().translateXProperty(), -50, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 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.getCurrentNode().translateXProperty(), 0, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getPreviousNode().translateXProperty(), 50, Interpolator.EASE_BOTH),
|
new KeyValue(c.getPreviousNode().translateXProperty(), 50, Interpolator.EASE_BOTH),
|
||||||
new KeyValue(c.getCurrentNode().opacityProperty(), 1, 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;
|
private ContainerAnimations opposite;
|
||||||
|
|
||||||
ContainerAnimations(Consumer<AnimationHandler> init, Function<AnimationHandler, List<KeyFrame>> animationProducer) {
|
|
||||||
this.animationProducer = new AnimationProducer() {
|
|
||||||
@Override
|
|
||||||
public void init(AnimationHandler handler) {
|
|
||||||
init.accept(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<KeyFrame> 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 {
|
static {
|
||||||
NONE.opposite = NONE;
|
NONE.opposite = NONE;
|
||||||
FADE.opposite = FADE;
|
FADE.opposite = FADE;
|
||||||
@@ -257,4 +298,15 @@ public enum ContainerAnimations {
|
|||||||
ZOOM_IN.opposite = ZOOM_OUT;
|
ZOOM_IN.opposite = ZOOM_OUT;
|
||||||
ZOOM_OUT.opposite = ZOOM_IN;
|
ZOOM_OUT.opposite = ZOOM_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void init(AnimationHandler handler);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract List<KeyFrame> animate(AnimationHandler handler);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable ContainerAnimations opposite() {
|
||||||
|
return opposite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class Navigator extends TransitionPane {
|
|||||||
if (obj instanceof AnimationProducer) {
|
if (obj instanceof AnimationProducer) {
|
||||||
setContent(node, (AnimationProducer) obj);
|
setContent(node, (AnimationProducer) obj);
|
||||||
} else {
|
} else {
|
||||||
setContent(node, ContainerAnimations.NONE.getAnimationProducer());
|
setContent(node, ContainerAnimations.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationEvent navigated = new NavigationEvent(this, node, Navigation.NavigationDirection.PREVIOUS, NavigationEvent.NAVIGATED);
|
NavigationEvent navigated = new NavigationEvent(this, node, Navigation.NavigationDirection.PREVIOUS, NavigationEvent.NAVIGATED);
|
||||||
|
|||||||
@@ -146,12 +146,12 @@ public class SpinnerPane extends Control {
|
|||||||
|
|
||||||
observer = FXUtils.observeWeak(() -> {
|
observer = FXUtils.observeWeak(() -> {
|
||||||
if (getSkinnable().getFailedReason() != null) {
|
if (getSkinnable().getFailedReason() != null) {
|
||||||
root.setContent(failedPane, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(failedPane, ContainerAnimations.FADE);
|
||||||
failedReasonLabel.setText(getSkinnable().getFailedReason());
|
failedReasonLabel.setText(getSkinnable().getFailedReason());
|
||||||
} else if (getSkinnable().isLoading()) {
|
} else if (getSkinnable().isLoading()) {
|
||||||
root.setContent(topPane, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(topPane, ContainerAnimations.FADE);
|
||||||
} else {
|
} else {
|
||||||
root.setContent(contentPane, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(contentPane, ContainerAnimations.FADE);
|
||||||
}
|
}
|
||||||
}, getSkinnable().loadingProperty(), getSkinnable().failedReasonProperty());
|
}, getSkinnable().loadingProperty(), getSkinnable().failedReasonProperty());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ public class DecoratorController {
|
|||||||
public void startWizard(WizardProvider wizardProvider, String category) {
|
public void startWizard(WizardProvider wizardProvider, String category) {
|
||||||
FXUtils.checkFxUserThread();
|
FXUtils.checkFxUserThread();
|
||||||
|
|
||||||
navigator.navigate(new DecoratorWizardDisplayer(wizardProvider, category), ContainerAnimations.FADE.getAnimationProducer());
|
navigator.navigate(new DecoratorWizardDisplayer(wizardProvider, category), ContainerAnimations.FADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==== Authlib Injector DnD ====
|
// ==== Authlib Injector DnD ====
|
||||||
|
|||||||
@@ -174,11 +174,11 @@ public class DecoratorSkin extends SkinBase<Decorator> {
|
|||||||
if (s.isAnimate()) {
|
if (s.isAnimate()) {
|
||||||
AnimationProducer animation;
|
AnimationProducer animation;
|
||||||
if (skinnable.getNavigationDirection() == Navigation.NavigationDirection.NEXT) {
|
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) {
|
} else if (skinnable.getNavigationDirection() == Navigation.NavigationDirection.PREVIOUS) {
|
||||||
animation = ContainerAnimations.SWIPE_RIGHT_FADE_SHORT.getAnimationProducer();
|
animation = ContainerAnimations.SWIPE_RIGHT_FADE_SHORT;
|
||||||
} else {
|
} else {
|
||||||
animation = ContainerAnimations.FADE.getAnimationProducer();
|
animation = ContainerAnimations.FADE;
|
||||||
}
|
}
|
||||||
skinnable.setNavigationDirection(Navigation.NavigationDirection.START);
|
skinnable.setNavigationDirection(Navigation.NavigationDirection.START);
|
||||||
navBarPane.setContent(node, animation);
|
navBarPane.setContent(node, animation);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public abstract class DecoratorTabPage extends DecoratorTransitionPage implement
|
|||||||
if (newValue.getNode() != null) {
|
if (newValue.getNode() != null) {
|
||||||
onNavigating(getCurrentPage());
|
onNavigating(getCurrentPage());
|
||||||
if (getCurrentPage() != null) getCurrentPage().fireEvent(new Navigator.NavigationEvent(null, getCurrentPage(), Navigation.NavigationDirection.NEXT, Navigator.NavigationEvent.NAVIGATING));
|
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());
|
onNavigated(getCurrentPage());
|
||||||
if (getCurrentPage() != null) getCurrentPage().fireEvent(new Navigator.NavigationEvent(null, getCurrentPage(), Navigation.NavigationDirection.NEXT, Navigator.NavigationEvent.NAVIGATED));
|
if (getCurrentPage() != null) getCurrentPage().fireEvent(new Navigator.NavigationEvent(null, getCurrentPage(), Navigation.NavigationDirection.NEXT, Navigator.NavigationEvent.NAVIGATED));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class DecoratorWizardDisplayer extends DecoratorTransitionPage implements
|
|||||||
@Override
|
@Override
|
||||||
public void navigateTo(Node page, Navigation.NavigationDirection nav) {
|
public void navigateTo(Node page, Navigation.NavigationDirection nav) {
|
||||||
displayer.navigateTo(page, nav);
|
displayer.navigateTo(page, nav);
|
||||||
navigate(page, nav.getAnimation().getAnimationProducer());
|
navigate(page, nav.getAnimation());
|
||||||
|
|
||||||
String prefix = category == null ? "" : category + " - ";
|
String prefix = category == null ? "" : category + " - ";
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
|
|
||||||
tab.select(newGameTab);
|
tab.select(newGameTab);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
||||||
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer());
|
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
|||||||
@Override
|
@Override
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
VersionList<?> currentVersionList = versionList;
|
VersionList<?> currentVersionList = versionList;
|
||||||
root.setContent(spinner, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(spinner, ContainerAnimations.FADE);
|
||||||
executor = currentVersionList.refreshAsync(gameVersion).whenComplete((result, exception) -> {
|
executor = currentVersionList.refreshAsync(gameVersion).whenComplete((result, exception) -> {
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
List<RemoteVersion> items = loadVersions();
|
List<RemoteVersion> items = loadVersions();
|
||||||
@@ -218,7 +218,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
|||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (versionList != currentVersionList) return;
|
if (versionList != currentVersionList) return;
|
||||||
if (currentVersionList.getVersions(gameVersion).isEmpty()) {
|
if (currentVersionList.getVersions(gameVersion).isEmpty()) {
|
||||||
root.setContent(emptyPane, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(emptyPane, ContainerAnimations.FADE);
|
||||||
} else {
|
} else {
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
chkRelease.setSelected(true);
|
chkRelease.setSelected(true);
|
||||||
@@ -227,14 +227,14 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
|||||||
} else {
|
} else {
|
||||||
list.getItems().setAll(items);
|
list.getItems().setAll(items);
|
||||||
}
|
}
|
||||||
root.setContent(center, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(center, ContainerAnimations.FADE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
LOG.warning("Failed to fetch versions list", exception);
|
LOG.warning("Failed to fetch versions list", exception);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (versionList != currentVersionList) return;
|
if (versionList != currentVersionList) return;
|
||||||
root.setContent(failedPane, ContainerAnimations.FADE.getAnimationProducer());
|
root.setContent(failedPane, ContainerAnimations.FADE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class LauncherSettingsPage extends DecoratorAnimatedPage implements Decor
|
|||||||
gameTab.initializeIfNeeded();
|
gameTab.initializeIfNeeded();
|
||||||
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
|
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
||||||
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE.getAnimationProducer());
|
transitionPane.setContent(newValue.getNode(), ContainerAnimations.FADE);
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
announcementBox.getChildren().add(announcementCard);
|
announcementBox.getChildren().add(announcementCard);
|
||||||
|
|
||||||
announcementPane = new TransitionPane();
|
announcementPane = new TransitionPane();
|
||||||
announcementPane.setContent(announcementBox, ContainerAnimations.NONE.getAnimationProducer());
|
announcementPane.setContent(announcementBox, ContainerAnimations.NONE);
|
||||||
|
|
||||||
getChildren().add(announcementPane);
|
getChildren().add(announcementPane);
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
public void hideAnnouncementPane() {
|
public void hideAnnouncementPane() {
|
||||||
if (announcementPane != null) {
|
if (announcementPane != null) {
|
||||||
config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION);
|
config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION);
|
||||||
announcementPane.setContent(new StackPane(), ContainerAnimations.FADE.getAnimationProducer());
|
announcementPane.setContent(new StackPane(), ContainerAnimations.FADE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class ModListPageSkin extends SkinBase<ModListPage> {
|
|||||||
private void changeToolbar(HBox newToolbar) {
|
private void changeToolbar(HBox newToolbar) {
|
||||||
Node oldToolbar = toolbarPane.getCurrentNode();
|
Node oldToolbar = toolbarPane.getCurrentNode();
|
||||||
if (newToolbar != oldToolbar) {
|
if (newToolbar != oldToolbar) {
|
||||||
toolbarPane.setContent(newToolbar, ContainerAnimations.FADE.getAnimationProducer());
|
toolbarPane.setContent(newToolbar, ContainerAnimations.FADE);
|
||||||
if (newToolbar == searchBar) {
|
if (newToolbar == searchBar) {
|
||||||
searchField.requestFocus();
|
searchField.requestFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
|
|
||||||
tab.select(versionSettingsTab);
|
tab.select(versionSettingsTab);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
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));
|
listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST));
|
||||||
|
|||||||
Reference in New Issue
Block a user