From f0c5faf352d568a1727d25f9b32d4b522299e57d Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 11 Jul 2020 15:23:57 +0200 Subject: [PATCH 1/2] implemented "DO A BARREL ROLL!" - Easteregg --- .../envoy/client/ui/controller/ChatScene.java | 34 ++++++++++++++++++ src/main/resources/fxml/ChatScene.fxml | 13 +++++-- src/main/resources/icons/dark/rotate.png | Bin 0 -> 18694 bytes src/main/resources/icons/light/rotate.png | Bin 0 -> 17375 bytes 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/icons/dark/rotate.png create mode 100644 src/main/resources/icons/light/rotate.png diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index c5e6909..07d61d1 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -6,21 +6,26 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import javafx.animation.RotateTransition; import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.fxml.FXML; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; +import javafx.scene.layout.GridPane; import javafx.scene.paint.Color; import javafx.stage.FileChooser; +import javafx.util.Duration; import envoy.client.data.*; import envoy.client.data.audio.AudioRecorder; @@ -50,6 +55,9 @@ import envoy.util.EnvoyLog; */ public final class ChatScene implements Restorable { + @FXML + private GridPane scene; + @FXML private Label contactLabel; @@ -71,6 +79,9 @@ public final class ChatScene implements Restorable { @FXML private Button settingsButton; + @FXML + private Button rotateButton; + @FXML private TextArea messageTextArea; @@ -121,6 +132,7 @@ public final class ChatScene implements Restorable { voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", DEFAULT_ICON_SIZE))); attachmentButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("attachment", DEFAULT_ICON_SIZE))); attachmentView.setImage(DEFAULT_ATTACHMENT_VIEW_IMAGE); + rotateButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("rotate", (int) (DEFAULT_ICON_SIZE * 1.5)))); // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { @@ -346,6 +358,28 @@ public final class ChatScene implements Restorable { } } + /** + * Rotates every element in our application by 360° in at most 2.75s. + * + * @since Envoy Client v0.1-beta + */ + @FXML + private void doABarrelRoll() { + // contains all Node objects in ChatScene in alphabetical order + final var rotatableNodes = new Node[] { attachmentButton, attachmentView, contactLabel, infoLabel, messageList, messageTextArea, + postButton, remainingChars, rotateButton, scene, settingsButton, userList, voiceButton }; + final var random = new Random(); + for (final var node : rotatableNodes) { + // Defines one whole rotation in at most 2.75s + final var rotateTransition = new RotateTransition(Duration.seconds(random.nextDouble() * 2.25 + 0.5), node); + rotateTransition.setByAngle(360); + rotateTransition.play(); + // This is needed as for some strange reason objects could stop before being + // rotated back to 0° + rotateTransition.setOnFinished(e -> node.setRotate(0)); + } + } + /** * Checks the text length of the {@code messageTextArea}, adjusts the * {@code remainingChars} label and checks whether to send the message diff --git a/src/main/resources/fxml/ChatScene.fxml b/src/main/resources/fxml/ChatScene.fxml index fd48b75..5d1e762 100644 --- a/src/main/resources/fxml/ChatScene.fxml +++ b/src/main/resources/fxml/ChatScene.fxml @@ -15,9 +15,10 @@ - @@ -99,6 +100,12 @@ +