wait animation for loading
This commit is contained in:
@@ -50,7 +50,7 @@ public void initialize() throws SocketException {
|
||||
client = new Client(new InetSocketAddress("localhost", 6665), this, UsernameSingleton.getInstance().getUsername());
|
||||
Platform.runLater(() -> {
|
||||
Stage stage = (Stage) vueContainer.getScene().getWindow();
|
||||
stage.setResizable(true); // Fixed a bug that made the close button disappear under my Wayland setup (don't know if it's the same for x11)
|
||||
// stage.setResizable(true); // Fixed a bug that made the close button disappear under my Wayland setup (don't know if it's the same for x11)
|
||||
stage.setOnCloseRequest(event -> {
|
||||
connected = false;
|
||||
client.close();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package client;
|
||||
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.animation.RotateTransition;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
@@ -7,11 +8,8 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.shape.Arc;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
import network.protocol.packets.ServerResponsePacket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import static utilities.FxUtilities.centerStage;
|
||||
|
||||
@@ -19,23 +17,33 @@ public class ClientLoading {
|
||||
@FXML
|
||||
private Arc spinnerArc;
|
||||
|
||||
public void initialize() throws IOException, InterruptedException {
|
||||
// Création de l'animation de rotation
|
||||
/**
|
||||
* Initialize the loading screen.
|
||||
*/
|
||||
public void initialize() {
|
||||
// Rotation animation cycle
|
||||
RotateTransition rotate = new RotateTransition(Duration.seconds(1), spinnerArc);
|
||||
rotate.setByAngle(360);
|
||||
rotate.setCycleCount(RotateTransition.INDEFINITE);
|
||||
rotate.play();
|
||||
|
||||
// new Thread(() -> {
|
||||
// try {
|
||||
// Thread.sleep(2000);
|
||||
// login();
|
||||
// } catch (IOException | InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
// Yes, this loading screen is just for show. But it's fun and pretty.
|
||||
// PauseTransition allows no to block the rotation animation.
|
||||
PauseTransition pause = new PauseTransition(Duration.millis(1000));
|
||||
pause.setOnFinished(event -> {
|
||||
try {
|
||||
login();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
pause.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the client GUI and switch to it.
|
||||
* @throws IOException if the FXML file is not found.
|
||||
*/
|
||||
public void login() throws IOException {
|
||||
var loader = new FXMLLoader(getClass().getResource("/client/clientVue.fxml"));
|
||||
loader.load();
|
||||
|
||||
Reference in New Issue
Block a user