From f4bf38bca1a87610a8c722486e1829b1203e1e8e Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Sat, 30 Nov 2024 22:01:35 +0100 Subject: [PATCH 1/6] =?UTF-8?q?AcceptTrade,=20RejectTrade=20und=20NoMoneyW?= =?UTF-8?q?arning=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 6 +- .../client/gui/popups/AcceptTrade.java | 120 ++++++++++++++++++ .../client/gui/popups/NoMoneyWarning.java | 118 +++++++++++++++++ .../client/gui/popups/RejectTrade.java | 120 ++++++++++++++++++ 4 files changed, 359 insertions(+), 5 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.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 64a832a..83f8a7f 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 @@ -280,15 +280,11 @@ 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 LooserPopUp(this); + Dialog tmp = new NoMoneyWarning(this); tmp.open(); } } - - - - /** * Initializes and attaches the necessary application states for the game. */ diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java new file mode 100644 index 0000000..fdbd22d --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java @@ -0,0 +1,120 @@ +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 is a Warning-Popup which appears when the balance is negative at the end of a player´s turn + */ +public class AcceptTrade extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container noMoneyWarningContainer; + private final Container backgroundContainer; + + + + public AcceptTrade(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 Warnung + noMoneyWarningContainer = new Container(); + noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an + backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Handel angenommen!", new ElementId("warning-title"))); + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der im Popup steht + Container textContainer = noMoneyWarningContainer.addChild(new Container()); + textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text"))); + textContainer.addChild(new Label("", new ElementId("label-Text"))); + textContainer.addChild(new Label("Der Handel wurde angenommen", new ElementId("label-Text"))); + textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Passt den textContainer an die Größe des bankruptContainers an + textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Popup + noMoneyWarningContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2, + 8 + ); + + // Zentriere das Popup + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(noMoneyWarningContainer); + } + + /** + * 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; + } + + /** + * Closes the menu and removes the GUI elements. + */ + @Override + public void close() { + app.getGuiNode().detachChild(noMoneyWarningContainer); // 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/NoMoneyWarning.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java new file mode 100644 index 0000000..a4d3c21 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java @@ -0,0 +1,118 @@ +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 is a Warning-Popup which appears when the balance is negative at the end of a player´s turn + */ +public class NoMoneyWarning extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container noMoneyWarningContainer; + private final Container backgroundContainer; + + + + public NoMoneyWarning(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 Warnung + noMoneyWarningContainer = new Container(); + noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an + backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Na, schon wieder Pleite?", new ElementId("warning-title"))); + gateFieldTitle.setFontSize(38); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der im Popup steht + Container textContainer = noMoneyWarningContainer.addChild(new Container()); + textContainer.addChild(new Label("Du hast nicht genug Geld, um dieses Gebäude zu kaufen", new ElementId("label-Text"))); + textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Passt den textContainer an die Größe des bankruptContainers an + textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Popup + noMoneyWarningContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2, + 8 + ); + + // Zentriere das Popup + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(noMoneyWarningContainer); + } + + /** + * 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; + } + + /** + * Closes the menu and removes the GUI elements. + */ + @Override + public void close() { + app.getGuiNode().detachChild(noMoneyWarningContainer); // 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/RejectTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java new file mode 100644 index 0000000..2caa095 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java @@ -0,0 +1,120 @@ +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 is a Warning-Popup which appears when the balance is negative at the end of a player´s turn + */ +public class RejectTrade extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container noMoneyWarningContainer; + private final Container backgroundContainer; + + + + public RejectTrade(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 Warnung + noMoneyWarningContainer = new Container(); + noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an + backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Handel abgelehnt!", new ElementId("warning-title"))); + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der im Popup steht + Container textContainer = noMoneyWarningContainer.addChild(new Container()); + textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text"))); + textContainer.addChild(new Label("", new ElementId("label-Text"))); + textContainer.addChild(new Label("Der Handel wurde abgelehnt", new ElementId("label-Text"))); + textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Passt den textContainer an die Größe des bankruptContainers an + textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Popup + noMoneyWarningContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2, + 8 + ); + + // Zentriere das Popup + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(noMoneyWarningContainer); + } + + /** + * 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; + } + + /** + * Closes the menu and removes the GUI elements. + */ + @Override + public void close() { + app.getGuiNode().detachChild(noMoneyWarningContainer); // 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 From 89d5185c9138d861d65c658ec45958acba69f38a Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sat, 30 Nov 2024 22:39:08 +0100 Subject: [PATCH 2/6] rent popup fixed --- .../pp/monopoly/client/gui/popups/Rent.java | 149 +++++++++++------- 1 file changed, 89 insertions(+), 60 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java index f11c947..9ae5eec 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java @@ -16,7 +16,7 @@ import pp.monopoly.client.MonopolyApp; import pp.monopoly.notification.Sound; /** - * Rent is a popup that is triggered when a player enters a field that does not belong himself and is owned by another player + * Rent popup is triggered when a player enters a field owned by another player and needs to pay rent. */ public class Rent extends Dialog { private final MonopolyApp app; @@ -28,93 +28,122 @@ public class Rent extends Dialog { super(app.getDialogManager()); this.app = app; - // Halbtransparentes Overlay hinzufügen + // Create the overlay 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 + // Create and position the background container + backgroundContainer = createBackgroundContainer(); app.getGuiNode().attachChild(backgroundContainer); - - - // Hauptcontainer für die Warnung - rentContainer = new Container(); - rentContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray)); - rentContainer.setPreferredSize(new Vector3f(550,250,10)); - - float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an - backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0)); - - // Titel - Label gateFieldTitle = rentContainer.addChild(new Label( "Miete !", new ElementId("label-Bold"))); - gateFieldTitle.setFontSize(48); - gateFieldTitle.setColor(ColorRGBA.Black); - - // Text, der auf der Karte steht - Container textContainer = rentContainer.addChild(new Container()); - textContainer.addChild(new Label("Du must Spieler "+ playerName + " "+ amount+" EUR Miete zahlen", new ElementId("label-Text"))); - textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); - textContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(-250,-200,0)); - - // Beenden-Button - Button quitButton = rentContainer.addChild(new Button("Überweisen", new ElementId("button"))); - quitButton.addClickCommands(s -> ifTopDialog(() -> { - app.getGameLogic().playSound(Sound.BUTTON); - close(); - })); - quitButton.setFontSize(32); - quitButton.addClickCommands(source -> close()); - - - // Zentriere das Popup - rentContainer.setLocalTranslation( - (app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2, - (app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2, - 10 - ); - - // Zentriere das Popup - backgroundContainer.setLocalTranslation( - (app.getCamera().getWidth() - rentContainer.getPreferredSize().x - padding) / 2, - (app.getCamera().getHeight() + rentContainer.getPreferredSize().y+ padding) / 2, - 10 - ); - + // Create and position the rent container + rentContainer = createRentContainer(playerName, amount); app.getGuiNode().attachChild(rentContainer); + + centerContainers(); } /** - * Erstellt einen halbtransparenten Hintergrund für das Menü. + * Creates a semi-transparent overlay background. * - * @return Geometrie des Overlays + * @return the overlay geometry */ 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.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); overlay.setMaterial(material); - overlay.setLocalTranslation(0, 0, 10); + overlay.setLocalTranslation(0, 0, 0); return overlay; } /** - * Schließt das Menü und entfernt die GUI-Elemente. + * Creates the background container with styling. + * + * @return the styled background container + */ + private Container createBackgroundContainer() { + Container container = new Container(); + container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background + return container; + } + + /** + * Creates the main rent container with title, text, and button. + * + * @param playerName the name of the player to whom the rent is owed + * @param amount the rent amount + * @return the rent container + */ + private Container createRentContainer(String playerName, int amount) { + Container container = new Container(); + container.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray)); + container.setPreferredSize(new Vector3f(550, 250, 10)); + + // Title + Label title = container.addChild(new Label("Miete!", new ElementId("label-Bold"))); + title.setFontSize(48); + title.setColor(ColorRGBA.Black); + + // Rent message + Container textContainer = container.addChild(new Container()); + textContainer.addChild(new Label("Du musst Spieler " + playerName + " " + amount + " EUR Miete zahlen", + new ElementId("label-Text"))); + textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + textContainer.setPreferredSize(container.getPreferredSize().addLocal(-250, -200, 0)); + + // Payment button + Button payButton = container.addChild(new Button("Überweisen", new ElementId("button"))); + payButton.setFontSize(32); + payButton.addClickCommands(s -> ifTopDialog( () -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + + })); + + return container; + } + + /** + * Centers the rent and background containers on the screen. + */ + private void centerContainers() { + float padding = 10; + + // Center rent container + rentContainer.setLocalTranslation( + (app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2, + 8 + ); + + // Center background container with padding + backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0)); + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - backgroundContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + backgroundContainer.getPreferredSize().y) / 2, + 7 + ); + } + + /** + * Closes the popup and removes GUI elements. */ @Override public void close() { + app.getGuiNode().detachChild(rentContainer); + app.getGuiNode().detachChild(backgroundContainer); + app.getGuiNode().detachChild(overlayBackground); super.close(); - app.getGuiNode().detachChild(rentContainer); // Entferne das Menü - app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand - app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay } + /** + * Handles the escape action to close the dialog. + */ @Override public void escape() { close(); } - -} \ No newline at end of file +} From 488ae154cfcbb6ecb5b6bbe7de6c70b49fb842c2 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sat, 30 Nov 2024 23:26:37 +0100 Subject: [PATCH 3/6] fixed overlapping popups --- .../main/java/pp/monopoly/client/gui/popups/BuyCard.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java index 25c6489..895b4a5 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java @@ -27,7 +27,7 @@ public class BuyCard extends Dialog { super(app.getDialogManager()); this.app = app; - //Generate the corresponfing field + //Generate the corresponding field int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); @@ -84,14 +84,14 @@ public class BuyCard extends Dialog { buyCardContainer.setLocalTranslation( (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y) / 2, - 8 + 10 ); // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y+ padding) / 2, - 7 + 9 ); app.getGuiNode().attachChild(buyCardContainer); From b89d40b39fdb98eb7e4d5c8d48d52ac108eba0a9 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sun, 1 Dec 2024 00:14:04 +0100 Subject: [PATCH 4/6] fixed nullPointer --- .../pp/monopoly/client/gui/PropertyOverviewMenu.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java index a6dd56d..e64079a 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java @@ -95,8 +95,14 @@ public class PropertyOverviewMenu extends Dialog { // Fetch the current player Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); - // Iterate through the player's properties - for (PropertyField property : currentPlayer.getPropertyFields()) { + // Fetch the player's properties using their indices + List fields = new ArrayList<>(); + for (Integer i : currentPlayer.getProperties()) { + fields.add((PropertyField) app.getGameLogic().getBoardManager().getFieldAtIndex(i)); + } + + // Iterate through the fetched properties + for (PropertyField property : fields) { if (property instanceof BuildingProperty) { BuildingProperty building = (BuildingProperty) property; cards.add(createBuildingCard(building)); From f333e2d2c0aa946cd5895e42b7819e9f6464c2ff Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 1 Dec 2024 00:30:50 +0100 Subject: [PATCH 5/6] button function --- .../client/gui/BuildingAdminMenu.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java index ab3f85c..a96d8e2 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java @@ -12,12 +12,17 @@ import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.gui.popups.BuyHouse; +import pp.monopoly.client.gui.popups.RepayMortage; +import pp.monopoly.client.gui.popups.SellHouse; +import pp.monopoly.client.gui.popups.TakeMortage; import pp.monopoly.notification.Sound; public class BuildingAdminMenu extends Dialog { private final MonopolyApp app; private final Container mainContainer; + private Geometry background; private final Button backButton = new Button("Zurück"); private final Button buildButton = new Button("Bauen"); private final Button demolishButton = new Button("Abriss"); @@ -81,6 +86,7 @@ public class BuildingAdminMenu extends Dialog { overviewButton.setPreferredSize(new Vector3f(200, 50, 0)); overviewButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); + new PropertyOverviewMenu(app).open(); })); overviewColumn.addChild(overviewButton); @@ -88,7 +94,7 @@ public class BuildingAdminMenu extends Dialog { backButton.setPreferredSize(new Vector3f(200, 50, 0)); backButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); - this.close(); + close(); })); overviewColumn.addChild(backButton); @@ -103,6 +109,7 @@ public class BuildingAdminMenu extends Dialog { buildButton.setPreferredSize(new Vector3f(200, 50, 0)); buildButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); + new BuyHouse(app).open(); })); buildColumn.addChild(buildButton); @@ -110,6 +117,7 @@ public class BuildingAdminMenu extends Dialog { demolishButton.setPreferredSize(new Vector3f(200, 50, 0)); demolishButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); + new SellHouse(app).open(); })); buildColumn.addChild(demolishButton); @@ -124,6 +132,7 @@ public class BuildingAdminMenu extends Dialog { takeMortgageButton.setPreferredSize(new Vector3f(200, 50, 0)); takeMortgageButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); + new TakeMortage(app).open(); })); mortgageColumn.addChild(takeMortgageButton); @@ -131,8 +140,9 @@ public class BuildingAdminMenu extends Dialog { payMortgageButton.setPreferredSize(new Vector3f(200, 50, 0)); payMortgageButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); + new RepayMortage(app).open(); })); - mortgageColumn.addChild(payMortgageButton); + mortgageColumn.addChild(payMortgageButton); contentContainer.addChild(mortgageColumn); @@ -145,7 +155,7 @@ public class BuildingAdminMenu extends Dialog { private void addBackgroundImage() { Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); - Geometry background = new Geometry("Background", quad); + background = new Geometry("Background", quad); Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); backgroundMaterial.setTexture("ColorMap", backgroundImage); background.setMaterial(backgroundMaterial); @@ -161,6 +171,13 @@ public class BuildingAdminMenu extends Dialog { close(); } + @Override + public void close() { + app.getGuiNode().detachChild(mainContainer); + app.getGuiNode().detachChild(background); + super.close(); + } + @Override public void escape() { handleBack(); From 54118071cbd32f65a4d30580065b331b07c16139 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sun, 1 Dec 2024 00:34:57 +0100 Subject: [PATCH 6/6] fixed popup overlap --- .../src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java | 4 ++-- .../main/java/pp/monopoly/client/gui/popups/RepayMortage.java | 4 ++-- .../main/java/pp/monopoly/client/gui/popups/SellHouse.java | 4 ++-- .../main/java/pp/monopoly/client/gui/popups/TakeMortage.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java index ff142d9..76f85eb 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java @@ -125,14 +125,14 @@ public class BuyHouse extends Dialog { buyHouseContainer.setLocalTranslation( (app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y) / 2, - 8 + 9 ); // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y+ padding) / 2, - 7 + 8 ); app.getGuiNode().attachChild(buyHouseContainer); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java index d9da422..8afa4a0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java @@ -125,14 +125,14 @@ public class RepayMortage extends Dialog { repayMortageContainer.setLocalTranslation( (app.getCamera().getWidth() - repayMortageContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + repayMortageContainer.getPreferredSize().y) / 2, - 8 + 9 ); // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - repayMortageContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + repayMortageContainer.getPreferredSize().y+ padding) / 2, - 7 + 8 ); app.getGuiNode().attachChild(repayMortageContainer); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 1725946..ed6e7d7 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -129,14 +129,14 @@ public class SellHouse extends Dialog { sellhouseContainer.setLocalTranslation( (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y) / 2, - 8 + 9 ); // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y+ padding) / 2, - 7 + 8 ); app.getGuiNode().attachChild(sellhouseContainer); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java index 60137ac..332fba9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java @@ -125,14 +125,14 @@ public class TakeMortage extends Dialog { takeMortageContainer.setLocalTranslation( (app.getCamera().getWidth() - takeMortageContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + takeMortageContainer.getPreferredSize().y) / 2, - 8 + 9 ); // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - takeMortageContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + takeMortageContainer.getPreferredSize().y+ padding) / 2, - 7 + 8 ); app.getGuiNode().attachChild(takeMortageContainer);