From 4079561f7efea5ab98da83df3c1394e09d5ebd59 Mon Sep 17 00:00:00 2001 From: Seraina Date: Thu, 12 May 2022 14:58:40 +0200 Subject: [PATCH] Added the gameView so to the TrainAnimationViewDay but the whole thing is currently in front of all the lobby elements, because the boarder pane is in the way TODO: find a way to make boarderPane truly transparent --- OgGhostWinners.txt | 1 + .../gui/TrainAnimationDayController.java | 56 +++++++++++++++++++ .../gui/lounge/LoungeSceneViewController.java | 20 ++++++- .../client/gui/TrainAnimationViewDay.fxml | 33 ++++++----- .../client/gui/game/GameDayAll.fxml | 32 +++++------ .../client/gui/lounge/LoungeSceneView.fxml | 16 +++--- 6 files changed, 117 insertions(+), 41 deletions(-) diff --git a/OgGhostWinners.txt b/OgGhostWinners.txt index 7a46d02..473f560 100644 --- a/OgGhostWinners.txt +++ b/OgGhostWinners.txt @@ -2,3 +2,4 @@ B serai serai Jonas of Istanbul +serai diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationDayController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationDayController.java index 14f6dd7..33eecae 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationDayController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationDayController.java @@ -10,6 +10,7 @@ import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.StackPane; import javafx.util.Duration; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -37,8 +38,11 @@ public class TrainAnimationDayController implements Initializable { @FXML private ImageView lokiImageView; + private ChatApp chatApp; private static ChatApp cApp; + private static AnchorPane gamePane; + private static ImageView loki; public TrainAnimationDayController(){ super(); @@ -57,9 +61,22 @@ public class TrainAnimationDayController implements Initializable { TrainAnimationDayController.cApp = cApp; } + public AnchorPane getGameAnchorPane() { + return gameAnchorPane; + } + + public ImageView getWagonFullImageView() { + return wagonFullImageView; + } + @Override public void initialize(URL location, ResourceBundle resources) { + LoungeSceneViewController.setTrainAnimationDayController(this); + LOGGER.debug(cApp); setChatApp(cApp); + LOGGER.debug(gameAnchorPane); + gamePane = gameAnchorPane; + loki = lokiImageView; Platform.runLater(new Runnable() { @Override public void run() { @@ -69,4 +86,43 @@ public class TrainAnimationDayController implements Initializable { } }); } + + /** + * Adds the gameView to the existing LobbyView + */ + public void addGameView(ChatApp c) { + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + TrainAnimationDayController controller = new TrainAnimationDayController(); + LOGGER.debug(gamePane); + LOGGER.debug(loki); + LOGGER.debug(cApp); + gameAnchorPane.getChildren().add(c.game); + wagonFullImageView.setVisible(false); + } catch (Exception e) { + LOGGER.debug("Not yet initialized"); + e.printStackTrace(); + } + } + }); + } + + /** + * Removes the GameView again - needed when a game is over or a lobby is left + */ + public void removeGameView(ChatApp c) { + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + gameAnchorPane.getChildren().clear(); + wagonFullImageView.setVisible(true); + } catch (Exception e) { + LOGGER.debug("Not yet initialized"); + } + } + }); + } } diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneViewController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneViewController.java index 20033b7..80d1370 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneViewController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneViewController.java @@ -97,6 +97,7 @@ public class LoungeSceneViewController implements Initializable { public static ClientModel client; private static ChatApp chatApp; private ChatApp cApp; + private static TrainAnimationDayController trainAnimationDayController; ObservableList clients = FXCollections.observableArrayList(); ObservableList lobbies = FXCollections.observableArrayList(); @@ -119,6 +120,15 @@ public class LoungeSceneViewController implements Initializable { this.cApp = cApp; } + public static void setTrainAnimationDayController( + TrainAnimationDayController trainAnimationDayController) { + LoungeSceneViewController.trainAnimationDayController = trainAnimationDayController; + } + + public static TrainAnimationDayController getTrainAnimationDayController() { + return trainAnimationDayController; + } + /** * Called to initialize a controller after its root element has been completely processed. * @@ -141,7 +151,9 @@ public class LoungeSceneViewController implements Initializable { ClientListView.setItems(clients); addChatView(); addBackgroundDay(); - TrainAnimationDayController.setcApp(this.cApp); + LOGGER.debug("cApp = " + cApp); + LOGGER.debug("chatApp = " + chatApp); + TrainAnimationDayController.setcApp(cApp); ClientListView.setItems(clients); ClientListView.setCellFactory(param -> { @@ -321,13 +333,15 @@ public class LoungeSceneViewController implements Initializable { * Adds the gameView to the existing LobbyView */ public void addGameView() { + Platform.runLater(new Runnable() { @Override public void run() { try { + LOGGER.debug(" in addGameView()" + chatApp); newGameButton.setVisible(false); startGame.setVisible(false); - gameAnchorPane.getChildren().add(chatApp.game); + trainAnimationDayController.addGameView(chatApp); } catch (Exception e) { LOGGER.debug("Not yet initialized"); } @@ -345,7 +359,7 @@ public class LoungeSceneViewController implements Initializable { try { newGameButton.setVisible(true); startGame.setVisible(true); - gameAnchorPane.getChildren().clear(); + trainAnimationDayController.removeGameView(chatApp); } catch (Exception e) { LOGGER.debug("Not yet initialized"); } diff --git a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationViewDay.fxml b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationViewDay.fxml index eb72e59..1ace55b 100644 --- a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationViewDay.fxml +++ b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/TrainAnimationViewDay.fxml @@ -3,44 +3,49 @@ - - + - + - + - + - + - + - - + + + + + + + - + - + - - + + + - + diff --git a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/GameDayAll.fxml b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/GameDayAll.fxml index f09f239..dc4b5d7 100644 --- a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/GameDayAll.fxml +++ b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/GameDayAll.fxml @@ -9,48 +9,48 @@ - + - + - + - + - + - + - + - + - - - - - - + + + + + + @@ -99,7 +99,7 @@ - - + + diff --git a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneView.fxml b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneView.fxml index 9838413..052ee44 100644 --- a/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneView.fxml +++ b/src/main/resources/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneView.fxml @@ -10,12 +10,11 @@ - + - - + - +