From 48b1cf817a9034794812911f8e985c639c8736d0 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Fri, 29 Nov 2024 04:32:57 +0100 Subject: [PATCH 1/3] refactor --- .../pp/monopoly/client/gui/ChoosePartner.java | 93 ++++++------------- 1 file changed, 27 insertions(+), 66 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java index b0f89e0..452770f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java @@ -2,24 +2,19 @@ package pp.monopoly.client.gui; import java.util.Set; -import com.jme3.app.Application; -import com.jme3.app.state.BaseAppState; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Quad; import com.jme3.texture.Texture; -import com.simsilica.lemur.Axis; -import com.simsilica.lemur.Button; -import com.simsilica.lemur.Container; -import com.simsilica.lemur.Label; -import com.simsilica.lemur.Selector; +import com.simsilica.lemur.*; import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.core.VersionedList; import com.simsilica.lemur.core.VersionedReference; import com.simsilica.lemur.style.ElementId; + import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; import pp.monopoly.game.server.Player; @@ -37,6 +32,9 @@ public class ChoosePartner extends Dialog { private Container lowerRightMenu; private Geometry background; private TradeHandler tradeHandler; + private VersionedReference> selectionRef; // Reference to track selector changes + private String lastSelected = ""; // To keep track of the last selected value + QuadBackgroundComponent translucentWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); @@ -70,8 +68,6 @@ public class ChoosePartner extends Dialog { // Add buttons mainContainer.addChild(createButtonContainer()); - addSelectionActionListener(playerSelector, this::onDropdownSelectionChanged); - // Attach main container to GUI node app.getGuiNode().attachChild(mainContainer); mainContainer.setLocalTranslation( @@ -79,6 +75,9 @@ public class ChoosePartner extends Dialog { (app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2, 4 ); + + // Initialize selection reference for tracking changes + selectionRef = playerSelector.getSelectionModel().createReference(); } /** @@ -95,7 +94,7 @@ public class ChoosePartner extends Dialog { for (Player player : app.getGameLogic().getPlayerHandler().getPlayers()) { if (player.getId() != app.getId()) { - playerOptions.add(player.getName() + " (ID: "+player.getId()+")"); + playerOptions.add(player.getName() + " (ID: " + player.getId() + ")"); } } @@ -103,10 +102,14 @@ public class ChoosePartner extends Dialog { dropdownContainer.addChild(playerSelector); Vector3f dimens = dropdownContainer.getPreferredSize(); Vector3f dimens2 = playerSelector.getPopupContainer().getPreferredSize(); - dimens2.setX( dimens.getX() ); - playerSelector.getPopupContainer().setPreferredSize(new Vector3f(200,200,3)); - playerSelector.setLocalTranslation(0,0,5); - onDropdownSelectionChanged(playerOptions.get(0)); + dimens2.setX(dimens.getX()); + playerSelector.getPopupContainer().setPreferredSize(new Vector3f(200, 200, 3)); + playerSelector.setLocalTranslation(0, 0, 5); + + // Set initial selection + if (!playerOptions.isEmpty()) { + onDropdownSelectionChanged(playerOptions.get(0)); + } return dropdownContainer; } @@ -134,7 +137,6 @@ public class ChoosePartner extends Dialog { lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 5)); // Adjust X and Y to align with the bottom-left corner app.getGuiNode().attachChild(lowerLeftMenu); - // "Bestätigen" button lowerRightMenu = new Container(); confirmButton.setPreferredSize(new Vector3f(200, 60, 0)); @@ -150,7 +152,6 @@ public class ChoosePartner extends Dialog { lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 5)); // X: 220px from the right, Y: 50px above the bottom app.getGuiNode().attachChild(lowerRightMenu); - return buttonContainer; } @@ -183,7 +184,14 @@ public class ChoosePartner extends Dialog { */ @Override public void update(float delta) { - // Periodic updates (if needed) can be implemented here + // Check if the selection has changed + if (selectionRef.update()) { + String selected = playerSelector.getSelectedItem(); + if (!selected.equals(lastSelected)) { + lastSelected = selected; + onDropdownSelectionChanged(selected); + } + } } @Override @@ -196,42 +204,6 @@ public class ChoosePartner extends Dialog { super.close(); } - /** - * Adds a custom action listener to the Selector. - */ - private void addSelectionActionListener(Selector selector, SelectionActionListener listener) { - VersionedReference> selectionRef = selector.getSelectionModel().createReference(); - - app.getStateManager().attach(new BaseAppState() { - @Override - public void update(float tpf) { - if (selectionRef.update()) { - String selected = selectionRef.get().toString(); - listener.onSelectionChanged(selected); - } - } - - @Override - protected void initialize(Application app) { - update(1); - } - - @Override - protected void cleanup(Application app) { - } - - @Override - protected void onEnable() { - - } - - @Override - protected void onDisable() { - - } - }); - } - /** * Callback for when the dropdown selection changes. */ @@ -241,23 +213,12 @@ public class ChoosePartner extends Dialog { int idEnd = selected.indexOf(")", idStart); // Find end of the ID String idStr = selected.substring(idStart, idEnd); // Extract the ID as a string int playerId = Integer.parseInt(idStr); // Convert the ID to an integer - + // Find the player by ID Player selectedPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(playerId); - + if (selectedPlayer != null) { tradeHandler.setReceiver(selectedPlayer); // Set the receiver in TradeHandler } } - - /** - * Functional interface for a selection action listener. - */ - @FunctionalInterface - private interface SelectionActionListener { - void onSelectionChanged(T selection); - } } - - - From 91826b730f071684cf56e886f5e343f698dbf8fd Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Fri, 29 Nov 2024 04:35:16 +0100 Subject: [PATCH 2/3] Lade Figuren auf Spielbrett --- .../java/pp/monopoly/client/GameAppState.java | 17 ++- .../java/pp/monopoly/client/MonopolyApp.java | 44 +++--- .../pp/monopoly/client/gui/TestWorld.java | 142 ++++++++++-------- .../java/pp/monopoly/client/gui/Toolbar.java | 7 +- .../src/main/resources/Models/Flugzeug.j30 | Bin 3224 -> 0 bytes .../main/resources/Models/Handyholster.j30 | Bin 3232 -> 0 bytes .../main/resources/Models/Jägermeister.j30 | Bin 3229 -> 0 bytes .../src/main/resources/Models/Katze.j30 | Bin 3219 -> 0 bytes .../src/main/resources/Models/Laptop.j30 | Bin 3220 -> 0 bytes .../client/src/main/resources/Models/OOP.j30 | Bin 3228 -> 0 bytes .../java/pp/monopoly/game/server/Player.java | 8 + .../main/java/pp/monopoly/model/Figure.java | 9 +- 12 files changed, 125 insertions(+), 102 deletions(-) delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/Flugzeug.j30 delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/Handyholster.j30 delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/Jägermeister.j30 delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/Katze.j30 delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/Laptop.j30 delete mode 100644 Projekte/monopoly/client/src/main/resources/Models/OOP.j30 diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameAppState.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameAppState.java index 48032e0..01a264c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameAppState.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameAppState.java @@ -7,15 +7,15 @@ package pp.monopoly.client; +import java.lang.System.Logger; +import java.util.List; + import com.jme3.input.controls.ActionListener; import com.jme3.scene.Node; import com.jme3.system.AppSettings; -import pp.monopoly.client.MonopolyAppState; -import pp.monopoly.client.gui.TestWorld; -import pp.monopoly.model.IntPoint; -import java.lang.System.Logger; -import java.lang.System.Logger.Level; +import pp.monopoly.client.gui.TestWorld; +import pp.monopoly.game.server.Player; /** * Represents the state responsible for managing the battle interface within the Battleship game. @@ -71,9 +71,14 @@ public class GameAppState extends MonopolyAppState { * Creates the opponent's map view and adds a grid overlay to it. */ private void initializeGuiComponents() { - testWorld = new TestWorld(getApp()); + // Abrufen der Spielerliste aus der ClientGameLogic + List players = getApp().getGameLogic().getPlayerHandler().getPlayers(); + + // Initialisiere TestWorld mit Spielern + testWorld = new TestWorld(getApp(), players); testWorld.initializeScene(); } + /** * Adds the initialized GUI components to the battle node. diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 70d39d4..5c60621 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -7,6 +7,15 @@ package pp.monopoly.client; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.LogManager; + import com.jme3.app.DebugKeysAppState; import com.jme3.app.SimpleApplication; import com.jme3.app.StatsAppState; @@ -19,9 +28,13 @@ import com.jme3.input.controls.KeyTrigger; import com.jme3.input.controls.MouseButtonTrigger; import com.jme3.system.AppSettings; import com.simsilica.lemur.GuiGlobals; -import com.simsilica.lemur.Label; import com.simsilica.lemur.style.BaseStyles; -import pp.monopoly.game.client.MonopolyClient; + +import pp.dialog.Dialog; +import pp.dialog.DialogBuilder; +import pp.dialog.DialogManager; +import pp.graphics.Draw; +import static pp.monopoly.Resources.lookup; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.StartMenu; import pp.monopoly.client.gui.TestWorld; @@ -31,26 +44,12 @@ import pp.monopoly.client.gui.popups.EventCard; import pp.monopoly.client.gui.popups.FoodFieldCard; import pp.monopoly.client.gui.popups.GateFieldCard; import pp.monopoly.game.client.ClientGameLogic; +import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; import pp.monopoly.notification.ClientStateEvent; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.InfoTextEvent; import pp.monopoly.notification.Sound; -import pp.dialog.Dialog; -import pp.dialog.DialogBuilder; -import pp.dialog.DialogManager; -import pp.graphics.Draw; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.System.Logger; -import java.lang.System.Logger.Level; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.LogManager; - -import static pp.monopoly.Resources.lookup; /** * The main class for the Battleship client application. @@ -136,7 +135,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private BuyCard buyCard; private boolean isBuyCardPopupOpen = false; private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed); - private final ActionListener TListener = (name, isPressed, tpf) -> handleT(isPressed); private TestWorld testWorld; static { @@ -272,7 +270,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga inputManager.addMapping("B", new KeyTrigger(KeyInput.KEY_B)); inputManager.addListener(BListener, "B"); inputManager.addMapping("T", new KeyTrigger(KeyInput.KEY_T)); - inputManager.addListener(TListener, "T"); + } //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen @@ -283,13 +281,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga } } - //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen - private void handleT(boolean isPressed) { - if (isPressed) { - testWorld = new TestWorld(this); - testWorld.initializeScene(); - } - } + diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index 82c3f25..ff670e9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -2,103 +2,115 @@ package pp.monopoly.client.gui; import java.util.List; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; -import com.jme3.scene.Geometry; -import com.jme3.scene.shape.Box; -import com.jme3.texture.Texture; - import pp.monopoly.client.MonopolyApp; -import pp.monopoly.client.gui.popups.EventCard; -import pp.monopoly.notification.DiceRollEvent; -import pp.monopoly.notification.EventCardEvent; -import pp.monopoly.notification.GameEventListener; +import pp.monopoly.game.server.Player; /** - * TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat. - * Die Kamera wird durch den CameraController gesteuert. + * TestWorld zeigt eine einfache Szene mit Spielfeld und Spielfiguren. */ -public class TestWorld implements GameEventListener{ +public class TestWorld { private final MonopolyApp app; - private CameraController cameraController; // Steuert die Kamera - private Toolbar toolbar; + private final List players; // Liste der Spieler, bereits aus GameStart geladen + private CameraController cameraController; /** - * Konstruktor für TestWorld. + * Konstruktor für die TestWorld. * - * @param app Die Hauptanwendung (MonopolyApp) + * @param app Die Hauptanwendung + * @param players Die Liste der Spieler mit ihren Figuren */ - public TestWorld(MonopolyApp app) { + public TestWorld(MonopolyApp app, List players) { this.app = app; - app.getGameLogic().addListener(this); + this.players = players; } /** - * Initialisiert die Szene und startet die Kamerabewegung. + * Initialisiert die Szene mit Spielfeld und Figuren. */ public void initializeScene() { - app.getGuiNode().detachAllChildren(); // Entferne GUI - app.getRootNode().detachAllChildren(); // Entferne andere Szenenobjekte + // Entferne bestehende Inhalte + app.getGuiNode().detachAllChildren(); + app.getRootNode().detachAllChildren(); - setSkyColor(); // Setze den Himmel auf hellblau - createBoard(); // Erstelle das Spielfeld + System.out.println("Szene initialisiert."); - // Erstelle den CameraController - cameraController = new CameraController( - app.getCamera(), // Die Kamera der App - Vector3f.ZERO, // Fokus auf die Mitte des Spielfelds - 4, // Radius des Kreises - 15, // Höhe der Kamera - 0 // Geschwindigkeit der Bewegung - ); - - // Füge die Toolbar hinzu - toolbar = new Toolbar(app); - toolbar.open(); - - cameraController.setPosition(0); - } - - - /** - * Aktualisiert die Kameraposition. - * - * @param tpf Zeit pro Frame - */ - public void update(float tpf) { - if (cameraController != null) { - cameraController.update(tpf); - } + // Initialisiere Szene + setSkyColor(); + createBoard(); + createPlayerFigures(); // Lädt Figuren aus der bereits vorhandenen Liste + setupCamera(); } /** * Setzt die Hintergrundfarbe der Szene auf hellblau. */ private void setSkyColor() { - app.getViewPort().setBackgroundColor(new ColorRGBA(0.5f, 0.7f, 1.0f, 1.0f)); // Hellblauer Himmel + app.getViewPort().setBackgroundColor(new com.jme3.math.ColorRGBA(0.5f, 0.7f, 1.0f, 1.0f)); } /** - * Erstelle das Spielfeld. + * Erstellt das Spielfeld und fügt es zur Szene hinzu. */ private void createBoard() { - // Erstelle ein Quadrat - Box box = new Box(10, 0.1f, 10); // Dünnes Quadrat für die Textur - Geometry geom = new Geometry("Board", box); + try { + // Erstelle das Spielfeld als flaches Rechteck + com.jme3.scene.shape.Box box = new com.jme3.scene.shape.Box(10, 0.1f, 10); // Breite, Höhe, Tiefe + com.jme3.scene.Geometry geom = new com.jme3.scene.Geometry("Board", box); - // Setze das Material mit Textur - Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - Texture texture = app.getAssetManager().loadTexture("Pictures/board2.png"); - mat.setTexture("ColorMap", texture); - geom.setMaterial(mat); + // Lade und setze das Material mit der Textur + com.jme3.material.Material mat = new com.jme3.material.Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + com.jme3.texture.Texture texture = app.getAssetManager().loadTexture("Pictures/board2.png"); + mat.setTexture("ColorMap", texture); + geom.setMaterial(mat); - app.getRootNode().attachChild(geom); + // Positioniere das Spielfeld in der Szene + geom.setLocalTranslation(0, -0.1f, 0); // Direkt auf der Grundebene + app.getRootNode().attachChild(geom); + + System.out.println("Spielbrett erfolgreich erstellt und hinzugefügt."); + } catch (Exception e) { + System.err.println("Fehler beim Erstellen des Spielfelds: " + e.getMessage()); + } } - @Override - public void receivedEvent(EventCardEvent event) { - new EventCard(app, event.description()).open(); + /** + * Erstellt die Spielfiguren basierend auf der bereits bekannten Spielerliste. + */ + private void createPlayerFigures() { + for (int i = 0; i < players.size(); i++) { + Player player = players.get(i); + try { + // Lade das 3D-Modell der Spielfigur + com.jme3.scene.Spatial model = app.getAssetManager().loadModel("Models/" + player.getFigure().getType() + ".j3O"); + model.setLocalScale(0.5f); // Skaliere das Modell + model.setLocalTranslation(0, 0, -i * 2); // Positioniere die Figur auf dem Startfeld + + app.getRootNode().attachChild(model); + System.out.println("Figur für Spieler " + player.getId() + " hinzugefügt."); + } catch (Exception e) { + System.err.println("Fehler beim Laden des Modells für Spieler " + player.getId() + ": " + e.getMessage()); + } + } + } + + /** + * Richtet die Kamera auf das Spielfeld aus. + */ + private void setupCamera() { + app.getCamera().setLocation(new com.jme3.math.Vector3f(0, 20, 20)); // Über dem Spielfeld + app.getCamera().lookAt(new com.jme3.math.Vector3f(0, 0, 0), com.jme3.math.Vector3f.UNIT_Y); // Fokus auf Spielfeldmitte + System.out.println("Kamera eingerichtet."); + } + + /** + * Wird bei jedem Frame aufgerufen, um die Szene zu aktualisieren. + * + * @param tpf Zeit seit dem letzten Frame in Sekunden + */ + public void update(float tpf) { + if (cameraController != null) { + cameraController.update(tpf); // Aktualisiere die Kameraposition + } } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index 9b87a5b..bcb0abf 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -3,7 +3,10 @@ package pp.monopoly.client.gui; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; -import com.simsilica.lemur.*; +import com.simsilica.lemur.Axis; +import com.simsilica.lemur.Button; +import com.simsilica.lemur.Container; +import com.simsilica.lemur.Label; import com.simsilica.lemur.component.IconComponent; import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.SpringGridLayout; @@ -142,7 +145,7 @@ public class Toolbar extends Dialog implements GameEventListener { Thread diceAnimation = new Thread(() -> { int[] currentFace = {1}; try { - while (System.currentTimeMillis() - startTime < 2500) { // Animation läuft für 4 Sekunden + while (System.currentTimeMillis() - startTime < 2000) { // Animation läuft für 4 Sekunden currentFace[0] = (currentFace[0] % 6) + 1; String rotatingImage1 = diceToString(currentFace[0]); diff --git a/Projekte/monopoly/client/src/main/resources/Models/Flugzeug.j30 b/Projekte/monopoly/client/src/main/resources/Models/Flugzeug.j30 deleted file mode 100644 index e0156e1290653e6d3cea22c25f0a968782c5a98d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3224 zcma)8TWB0*6rMA)_uQIGvq>*ni--uhK>DCfv)d+ZV``$cNflH~C%gY{ww;|xXJ(U4 zd}xH$7Zqv|U+RNM5xf+sR4R>4Ev5=$!AB|jBI-k>s6|9jsNeZ#Cz)KtB%J^J=Rf!J zpV{*t7~0pRD2fWGiV;@++nlkA?MI8EtKG>6Q?x%NY*& z6!NCX4v$;5tM12f)tD3;b*CqUR>nb`<@Otv?kWk83D};nOkuhXv3$7X=y?(1Z6s&e zMcvi>Fj^MF!0CAVlO^31wpp-D$SUF0Qbr*^?zRu|I#_UA2$7OyyOQBVIZ6L->!R&3 zt7K*iX1=|*vgx%r?2y`oH9Ebo>>^f85;Gp5JOfSyl|eWp8D)oWeIZS+?@kumC zA4=zjj)9DN*Y9Y|t0|a{tD6}i`Lb+@qLmefEVara)xr=(R8mS1*UtC46t?HJUs$M! zJq?kV$~O>qZQXRZXQE8T{Cdjj%36l__Tv^Jv9^x0Q4*TGLa#3(ybl$TRG8(f zGnVPvmf>&@sjH)boALG$-!&98nV4oOSBN zz+V8@1OEWr0Q@I#BV23-MsCp*@J3)RTr;o(oCJOy7&fC9fRRJ=D`3upcm-UiF`?snRZ=yIgpgQ-qEV{j#N!HSL?M;JoW9ImE_F(J7G`-- zdEsI}o@?=dLNTHim8w~j!W33Wg_SVH0ST(2YO0}HE?0wsv()Uj@2RQTD>*GS`@ut8 z-8yAg!`*|FI{&w=UU~MVKTuKHDFcZNyJ(P%O0k2MQ{Yz7=+Sc%r&6VGGX3S;+4;^- zCg(f*lj+#jH|Hm2rsj?3lIizH2T~{NPNgnvN~YVkA4t`_axzu>_QySMOdeQv9+ZFn z#q#{E4=?pJT^vXS_d%JUuY0df&7X-}>iOu-+4HQ^B*)VLiqQLq*=lyFv3gW0vFdZG2Y2{<)9Y4)cA? za-JUd#%YB=@aTwc=6Ph(ksEhUTs^L7-3vco<2t1m>7SO<*MD42FI4!)YP9a}?w&~h zeqxK%|E1ca?^Nhj{EGZ<75>ZHweIhsf9KT)rT!__2{R-KXvWIZ>Mez~_gTfFWp?1%wO8bv4*4qdR(|Up?J8!8V&KZx8M=o5 z_ZD)wk|U`8up@kyd@eau%LCdl^zx&E-G3RDno2Cc4f4Gh z^g=gjjR-aQ8oNiKuzYLN%7{ZfgJ0iR?YEMKN*md4(~@6}BakDJm9_+(uS}T*T7uau dmO!PJidl#df7lu?i)LGw!d)s>sBcD5{slV-I@|yN diff --git a/Projekte/monopoly/client/src/main/resources/Models/Handyholster.j30 b/Projekte/monopoly/client/src/main/resources/Models/Handyholster.j30 deleted file mode 100644 index d61fbdffc1f19c84e1b6b2c70f420cee2a544d8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3232 zcma)8U2GIp6rMA)|NVoubX$IupfSdT(pVC;rMuAbR|G){ny9f%ckgz$%+8dV*>>%WXF--Bl7G6R z7j;+j!)UFBfzy2ZvnAaXwpp-D$SUE5Qbu7o@3!yeb$7vWAw)`+?Mj9d{m3%;EOl%BI)iutRDy*67h~Wf!q(l9=!apuh8p@2=7BhBo$`) z+Kgqowq-cnL+Zk4;3nUGz;_J=O(v$4@MuuhRE*e$F8Fn(dArii&#d~8PUpTbG zGWzJ4ZXdu06ykfS8PkoD7|ih}G}|ZICa@A7Ysj(;>8j479eqq6G6V$L0KQ``?h^nF zuniCb>;i-VdjSzZ1`q{|0Ahf*0dc@N0AJTNKn+aJ0N2742T=!8tAOia>SN#rn0gp^ z8SuBj%Yp9zHv<0y+yoa70VB64e+VnMYk*sT`G+M5dYu**mJ^hE-BEiiD6`grZSu;N0U1X+$BF!dwBFzFZoV z^dv0vqVmG^fIOGu5rtwztt!>BCWR@ikP0hdiUSf#^<1$=1!t+rA3so2lUH(D zYVzD;T;K*}Q{&7&N}d1PR?11@?bqf%_2Hxy>UEM|K4Xk?~Lu5 za~_m``PK5&-H$HzG+*dX1@}Rjpsxq7j!&J6T8YUK zpv|C6Fqi*|IcPr^Lr^zplgszy-10@9;i+MucvhpFG<5?P8s! z>>+oR?Xv7r_K>~Ia_nO%dya$UU|+`ce|whWT-nD`_WVKL;s&PK-a8=5eU@csHR@25 zwP{EI4h8UL?D?GWwUmc_n(<`i+{dus*{R@3=&&ARg`pzv_RO+7q&GuG3?a}l3C&9l3{*CWF zKH^P}Yue>|XRmiv;!iuEZ%xnA$nP@ZUz9)JpHH{#Sv($}zq;S!7m*Lg^IIjK^Po8& zzaDqz@Na3cKpYKr{n#u~vmis7d_fi;2AQ;Tua z0I0{h45OtHYa>QVGsZ{~(1Mi**1HO=>$8eQ%iMsM*H)2pHpqvexAJpuq_dbMih(O1 zXy_XL-&)A!N{*oA2OZ(FX!_33XkZ+(=K| z{<=-=vYPre9!;#Y7D~Ms_(C^nkuWv+DtkbouzYjV{IEkkyT7}+(0L^nl~#Dp+1u<$ qtU6yEbUr_Cw%Qs@sagk>S}SHDLi}~Byj0D$&4xQ$u~6THqWlX|TR-Cf diff --git a/Projekte/monopoly/client/src/main/resources/Models/Jägermeister.j30 b/Projekte/monopoly/client/src/main/resources/Models/Jägermeister.j30 deleted file mode 100644 index cb0c503eeec38fe0d3d993fa249f84b047718f32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3229 zcma)8U2GIp6rMA)|NVoubjzPsVvL$}X;K~(=q|KCEw+jjG*M%j?%v%l%+8dV*|O9J zY68Bf3G$#Z^}!fo;tw$z6a!Ku6n&BCqapfY)CUYvi4P`_;CJrqY^OiQwmJ9QbI<>| zXZGCPLp!?_MNt8DF~Z7!YqM4&l$&>ibQn zSTIFyc+9e0br+87My1$@dvsiA6&%D_ZkJ){u95(mfbDV16sGGC%ZJO3UJxPPM)HHIHHEXS_gN!3k(Z?inR-d62f<5>>o)dKbwYlgZ9$u3xRb1F+1+_*kAt9!jD?QM zz-hA1S4_@V?6VBZ-rL{19XcVI7wL*LV0)UQo}EI(H_%cu;I+e$aK@k^29I|134PQM5LgZH9dmIv0W?4_ zAOz?KgaLzq2;cx93Mc?#fKz}t;C%pJ*F``bOx^*mhp9(_8(^v(xDlq#05`$ZeZVV# zzXo0j{4;Pf@NM80xaa^zZqYvARlp;_ZNU8HC4t`phRx{bz{nx`9WduXylhmc<(VsA z+IeA&*p{Pr7SI}jLB3%wAGv8d8p6U8x zVy3GB#oiS#FHl9|p8yVDJ?9#1#E`&rK$6T9b~2jyRQ zsWNlp<8wW&X9v>3eNZOo>)uO8W==)U^?Z73dM3Esm@t?Cjr(U0)3HlA%49Wy^ z`LCFR_Jc75b%Qp!e2>g8U*riM83u}HHEUZGWh%3GVEy^!?BAQ7JrCK={)_|q`s^Hy{4OB=CHV{e`Sj|crQ`AW>jpf23Hfk5e^m211Df;k>v3a2 zz6<%>bJqM1HauYFL?uKG^Inc&x*zw4$wc_^)fD;DjWvQ<6vIz<0&4e)kiJu8OC^qh6Xq1f=a z$d(P=rugt!(JY$6abSD}HB$?dNJ*VZqgEAYVt{Tk3wPj;HHIPhk6FTy|&nSH5Zju1)Q@>ITCBm*9Dy~ k%$u#Y2UDumL8bPpS%?sS-6}6Nv#aOAovT==Z&FeI1>fdAn*aa+ diff --git a/Projekte/monopoly/client/src/main/resources/Models/Katze.j30 b/Projekte/monopoly/client/src/main/resources/Models/Katze.j30 deleted file mode 100644 index eb3b559b7a46163ebe4a4f8eb1de2b123f9540d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3219 zcma)8U2GIp6rMA)|NWysbX$HDi802cKS_B|N_U|JYOz(MMH4la>F(X`!t6|$nQgcA zftr9XYD8ju!3SfAi3%|q42DXPSoB2_9}UqLqds7WLVPgM1iy1Vu722b z3gf284(Bb~Rrlk#YD|iay3-RvE8`%}a{CQSca;Rl1Z+=OrZ8QHSUy~G^l=g5Z6s&e zMcvi>Fj^MFz-hky>5}dW+bmcnWR>u0DWfo+ciRVf9V|F5gh$bG*H`vgx%r?2y`oH9Ebo>>^f85;Gp5JO@q$l|eWp8D)rhq945Zc_#~R6 z52bTM$3RBC>vuHf)f7y})y<5Md|9?c(aH)#mRe4^cMSziCZ^ezOKho1hGpn38db&_b~3sl627Iid*dKqIJCnu z`sk!?kKh9e@x4?{>PAV7=J*p@>Jx1jSP73cW?6=GRpZf)KB$(D{g2{h?t6}Of;2M}}0j`Cq3&3?S^#Je& z;IDz}fqw#S0KNm<2p7%3$SunH8-Wi4<1EUbb`tmvVAzbF2SyIj>%g1`@zSACcMUdd^x+4GNZ zb?cN}4fhUG>cZc)dgb|7{zOG-rwk-A?4m(3D#Z?3PJvrRqsPxpoJy6#$@DjKXXiUV zpPcXPPo`sA->Eb{txDUz%ecgX`YW_^*QqQM%&&~(;ZMRRRI{v!YbLP#n^FhBsn?adi zF8>vC(0(w6pl;A6m+#T#<%>MYBf~)PtOl)HQD)PJ2DV;a&;I?h3zs3glXcd!hul@R z%d+d)Lw1hk*vESI90$w6zKrSr_AJM_vXAxb`D?z(4NObDHzLY?mStx(>Qt0%X-EK$ z1n_R``JC~WDG&QJHQ^B*)VLiqQLq*=lyFv3gW0vFdZG2Y2{<)9Y4)cA? za-JUd#%YB=@aTwcj`PT-BRB4yxO!aEx)*-E#&t?B(!VUHum8N9Ua0Vo)o9&6+&huJ zb7G6s|E=1i?^ftl{EGY^75=N+weBCGfA{r=rT!_o1&G7)}!HAVh(V~t=I#qiUez?#6^sm83S1Jq*O zfVt9uwE^>_2{R-KXvWIZ>RpAl_gTfFWp?1%wO8bv4*4qdR(|Up?J8!8V&KZx8M=o5 z_ZD)wk|U`8up@kyd@eau%LCdl^z!3^-IESSP^V0;5LP$M-_GbO2&M`==_sP~B5L5r?cs>gUmvgu84<>gdj(QOdz z#f%raNoxeB$%oi|3Wen}n^p!J>KXj@#%h<93{=|4E}P`|(|86hjYL-35_G;YTNY>u hCbF2lN-Y($5YhOX=8x5zw5-*-6z)=;LVYue@-O>#I*tGU diff --git a/Projekte/monopoly/client/src/main/resources/Models/Laptop.j30 b/Projekte/monopoly/client/src/main/resources/Models/Laptop.j30 deleted file mode 100644 index e442c42004cb2b989882eb4baca7487e340ab0a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3220 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 public void setFigure(Figure figure) { this.figure = figure; } + + public Figure getFigure(){ + return figure; + } public PlayerColor getColor() { switch ((id%6)+1) { @@ -540,4 +544,8 @@ public class Player implements FieldVisitor{ } } + @Override + public String toString() { + return "Player{name=" + name + ", figure=" + figure + "}"; + } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java index 9ac874b..d1bf462 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java @@ -1,14 +1,13 @@ package pp.monopoly.model; +import static java.lang.Math.max; +import static java.lang.Math.min; import java.util.Collections; import java.util.HashSet; import java.util.Set; import com.jme3.network.serializing.Serializable; -import static java.lang.Math.max; -import static java.lang.Math.min; - @Serializable public class Figure implements Item{ private final String type; @@ -313,5 +312,9 @@ public class Figure implements Item{ public void accept(VoidVisitor visitor) { visitor.visit(this); } + + public String getType() { + return type; + } } From a1247cdae53d1cad75c9693a938eae3181ac86d6 Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Fri, 29 Nov 2024 05:11:24 +0100 Subject: [PATCH 3/3] Bankrott-Warnung und Timeout-Warning erstellt erstellt --- .../java/pp/monopoly/client/MonopolyApp.java | 4 +- .../monopoly/client/gui/popups/Bankrupt.java | 119 +++++++++++++++++ .../client/gui/popups/ConfirmTrade.java | 2 +- .../monopoly/client/gui/popups/TimeOut.java | 122 ++++++++++++++++++ 4 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 86bc7b0..1c129e3 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -38,6 +38,7 @@ import static pp.monopoly.Resources.lookup; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.StartMenu; import pp.monopoly.client.gui.TestWorld; +import pp.monopoly.client.gui.popups.*; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -129,6 +130,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private GateFieldCard gateField; private BuyCard buyCard; private LooserPopUp looserpopup; + private Bankrupt bankrupt; private boolean isBuyCardPopupOpen = false; private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed); private TestWorld testWorld; @@ -272,7 +274,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - Dialog tmp = new SellHouse(this); + Dialog tmp = new Bankrupt(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java new file mode 100644 index 0000000..28f1b24 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -0,0 +1,119 @@ +package pp.monopoly.client.gui.popups; + +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Quad; +import com.simsilica.lemur.Button; +import com.simsilica.lemur.Container; +import com.simsilica.lemur.Label; +import com.simsilica.lemur.component.QuadBackgroundComponent; +import com.simsilica.lemur.style.ElementId; +import pp.dialog.Dialog; +import pp.monopoly.client.MonopolyApp; + +/** + * Bankrupt ist ein Overlay-Menü, welches aufgerufen werden kann, wenn man mit einem negativen Kontostand den Zug beenden möchte. // TODO welche menü-Klasse + */ +public class Bankrupt extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container bankruptContainer; + private final Container backgroundContainer; + + + + public Bankrupt(MonopolyApp app) { + super(app.getDialogManager()); + this.app = app; + + + // Halbtransparentes Overlay hinzufügen + overlayBackground = createOverlayBackground(); + app.getGuiNode().attachChild(overlayBackground); + + // Create the background container + backgroundContainer = new Container(); + backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background + app.getGuiNode().attachChild(backgroundContainer); + + + // Hauptcontainer für die Gebäudekarte + bankruptContainer = new Container(); + bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + bankruptContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + // Die Namen werden dynamisch dem BoardManager entnommen + Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + Container Container = bankruptContainer.addChild(new Container()); + Container.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", new ElementId("label-Text"))); + Container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + Container.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Menü + bankruptContainer.setLocalTranslation( + (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2, + 8 + ); + + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(bankruptContainer); + } + + /** + * Erstellt einen halbtransparenten Hintergrund für das Menü. + * + * @return Geometrie des Overlays + */ + private Geometry createOverlayBackground() { + Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); + Geometry overlay = new Geometry("Overlay", quad); + Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent + material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + overlay.setMaterial(material); + overlay.setLocalTranslation(0, 0, 0); + return overlay; + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(bankruptContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + super.close(); + } + + @Override + public void escape() { + close(); + } + +} \ No newline at end of file diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java index 4fd7f14..89b47af 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java @@ -69,7 +69,7 @@ public class ConfirmTrade extends Dialog { // Kaufen-Button Button negotiateButton = confirmTradeContainer.addChild(new Button("Verhandeln", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen negotiateButton.setFontSize(32); - negotiateButton.addClickCommands(s -> ifTopDialog( () -> { + negotiateButton.addClickCommands(s -> ifTopDialog( () -> { //TODO Buttonfunktion prüfen app.getGameLogic().playSound(Sound.BUTTON); })); // Kaufen-Button diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java new file mode 100644 index 0000000..7f72153 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -0,0 +1,122 @@ +package pp.monopoly.client.gui.popups; + +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Quad; +import com.simsilica.lemur.Button; +import com.simsilica.lemur.Container; +import com.simsilica.lemur.Label; +import com.simsilica.lemur.component.QuadBackgroundComponent; +import com.simsilica.lemur.style.ElementId; +import pp.dialog.Dialog; +import pp.monopoly.client.MonopolyApp; +import pp.monopoly.notification.Sound; +import static pp.monopoly.Resources.lookup; + +/** + * TimeOut ist ein Overlay-Menü, welches aufgerufen wird, wenn die Verbindung zum Server unterbrochen wurde. + */ +public class TimeOut extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container timeOutContainer; + private final Container backgroundContainer; + + + + public TimeOut(MonopolyApp app) { + super(app.getDialogManager()); + this.app = app; + + + // Halbtransparentes Overlay hinzufügen + overlayBackground = createOverlayBackground(); + app.getGuiNode().attachChild(overlayBackground); + + // Create the background container + backgroundContainer = new Container(); + backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background + app.getGuiNode().attachChild(backgroundContainer); + + + + // Hauptcontainer für die Gebäudekarte + timeOutContainer = new Container(); + timeOutContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + timeOutContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + // Die Namen werden dynamisch dem BoardManager entnommen + Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + Container propertyValuesContainer = timeOutContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text"))); + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + propertyValuesContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = timeOutContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Menü + timeOutContainer.setLocalTranslation( + (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2, + 8 + ); + + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(timeOutContainer); + } + + /** + * Erstellt einen halbtransparenten Hintergrund für das Menü. + * + * @return Geometrie des Overlays + */ + private Geometry createOverlayBackground() { + Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); + Geometry overlay = new Geometry("Overlay", quad); + Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent + material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + overlay.setMaterial(material); + overlay.setLocalTranslation(0, 0, 0); + return overlay; + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(timeOutContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + super.close(); + } + + @Override + public void escape() { + close(); + } + +} \ No newline at end of file