Pass Client & ClientListener through all controllers
This commit is contained in:
@@ -7,14 +7,20 @@ 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;
|
||||
|
||||
public class ClientLoading {
|
||||
public class ClientLoading implements ClientListener {
|
||||
@FXML
|
||||
private Arc spinnerArc;
|
||||
|
||||
private Client client;
|
||||
|
||||
public void initialize() throws IOException, InterruptedException {
|
||||
// Création de l'animation de rotation
|
||||
RotateTransition rotate = new RotateTransition(Duration.seconds(1), spinnerArc);
|
||||
@@ -23,11 +29,57 @@ public class ClientLoading {
|
||||
rotate.play();
|
||||
}
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void login() throws IOException {
|
||||
var loader = new FXMLLoader(getClass().getResource("/client/clientVue.fxml"));
|
||||
loader.load();
|
||||
client.changeCallback(loader.getController());
|
||||
((ClientGuiController) loader.getController()).setClient(client);
|
||||
Stage stage = (Stage) spinnerArc.getScene().getWindow();
|
||||
stage.setScene(new Scene(loader.getRoot(), 800, 600));
|
||||
centerStage(stage);
|
||||
stage.getScene().getStylesheets().add(getClass().getResource("clientStyle.css").toExternalForm());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDisconnect() {
|
||||
System.out.println("Disconnected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnexionError() {
|
||||
System.out.println("Connection error");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnect() {
|
||||
try {
|
||||
login();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChatMessage(Instant time, String chatter, String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRoomList(List<String> roomNames) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerResponse(ServerResponsePacket.Response response) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleActualRoom(String roomName) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user