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());
|
client = new Client(new InetSocketAddress("localhost", 6665), this, UsernameSingleton.getInstance().getUsername());
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
Stage stage = (Stage) vueContainer.getScene().getWindow();
|
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 -> {
|
stage.setOnCloseRequest(event -> {
|
||||||
connected = false;
|
connected = false;
|
||||||
client.close();
|
client.close();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package client;
|
package client;
|
||||||
|
|
||||||
|
import javafx.animation.PauseTransition;
|
||||||
import javafx.animation.RotateTransition;
|
import javafx.animation.RotateTransition;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
@@ -7,11 +8,8 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.shape.Arc;
|
import javafx.scene.shape.Arc;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import network.protocol.packets.ServerResponsePacket;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static utilities.FxUtilities.centerStage;
|
import static utilities.FxUtilities.centerStage;
|
||||||
|
|
||||||
@@ -19,23 +17,33 @@ public class ClientLoading {
|
|||||||
@FXML
|
@FXML
|
||||||
private Arc spinnerArc;
|
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);
|
RotateTransition rotate = new RotateTransition(Duration.seconds(1), spinnerArc);
|
||||||
rotate.setByAngle(360);
|
rotate.setByAngle(360);
|
||||||
rotate.setCycleCount(RotateTransition.INDEFINITE);
|
rotate.setCycleCount(RotateTransition.INDEFINITE);
|
||||||
rotate.play();
|
rotate.play();
|
||||||
|
|
||||||
// new Thread(() -> {
|
// Yes, this loading screen is just for show. But it's fun and pretty.
|
||||||
// try {
|
// PauseTransition allows no to block the rotation animation.
|
||||||
// Thread.sleep(2000);
|
PauseTransition pause = new PauseTransition(Duration.millis(1000));
|
||||||
// login();
|
pause.setOnFinished(event -> {
|
||||||
// } catch (IOException | InterruptedException e) {
|
try {
|
||||||
// e.printStackTrace();
|
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 {
|
public void login() throws IOException {
|
||||||
var loader = new FXMLLoader(getClass().getResource("/client/clientVue.fxml"));
|
var loader = new FXMLLoader(getClass().getResource("/client/clientVue.fxml"));
|
||||||
loader.load();
|
loader.load();
|
||||||
|
|||||||
Reference in New Issue
Block a user