From a1105e287b65430dd55a8afd0bc0ecfeb57f97b5 Mon Sep 17 00:00:00 2001 From: fdai7736 <yannis.liebermann@informatik.hs-fulda.de> Date: Wed, 7 Feb 2024 15:46:54 +0100 Subject: [PATCH] add PlayerController to Game gui for each player --- .../onses/controllers/GameController.java | 8 ++++++- .../de/hsfulda/onses/views/player.fxml | 21 ++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/controllers/GameController.java b/src/main/java/de/hsfulda/onses/controllers/GameController.java index 2da4cb3..ce78ffe 100644 --- a/src/main/java/de/hsfulda/onses/controllers/GameController.java +++ b/src/main/java/de/hsfulda/onses/controllers/GameController.java @@ -23,9 +23,13 @@ public class GameController implements Controller { public Parent render() throws IOException { final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/game.fxml"))); final Pane lastPlayedCardPane = (Pane) parent.lookup("#lastPlayedCardPane"); - + final Pane enemyPane = (Pane) parent.lookup("#enemyPane"); + final Pane playerPane = (Pane) parent.lookup("#playerPane"); final Button playButton = (Button) parent.lookup("#playCardBtn"); + CardController lastPlayedCardController = new CardController(new Card().setValue(Card.Value.FIVE).setColor(Card.Color.BLUE)); + PlayerController playerController = new PlayerController(); + PlayerController enemyController = new PlayerController(); game.listeners().addPropertyChangeListener(Game.PROPERTY_LAST_PLAYED_CARD, e -> { lastPlayedCardPane.getChildren().removeAll(); @@ -42,6 +46,8 @@ public class GameController implements Controller { lastPlayedCardPane.getChildren().add(lastPlayedCardController.render()); + playerPane.getChildren().add(playerController.render()); + enemyPane.getChildren().add(enemyController.render()); return parent; } diff --git a/src/main/resources/de/hsfulda/onses/views/player.fxml b/src/main/resources/de/hsfulda/onses/views/player.fxml index fd33361..cda4d4a 100644 --- a/src/main/resources/de/hsfulda/onses/views/player.fxml +++ b/src/main/resources/de/hsfulda/onses/views/player.fxml @@ -1,13 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<?import java.lang.*?> -<?import java.util.*?> -<?import javafx.scene.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.text.Font?> -<AnchorPane xmlns="http://javafx.com/javafx" - xmlns:fx="http://javafx.com/fxml" - prefHeight="400.0" prefWidth="600.0"> +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="220.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <Label fx:id="playerNameLabel" layoutX="14.0" layoutY="14.0" text="Player Name" AnchorPane.leftAnchor="7.0" AnchorPane.topAnchor="7.0"> + <font> + <Font size="17.0" /> + </font> + </Label> + <Pane fx:id="cardsPane" layoutX="16.0" layoutY="28.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="7.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="28.0" /> + </children> </AnchorPane>