From 4095d9e79d3e43d22abeaa71fc4e8b46a47a4909 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 25 Nov 2024 21:29:00 +0100 Subject: [PATCH] fixed buyCard color and button function --- .../monopoly/client/gui/popups/BuyCard.java | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 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 8a65d6a..565e0dc 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 @@ -15,13 +15,13 @@ import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.model.fields.BoardManager; import pp.monopoly.model.fields.BuildingProperty; +import pp.monopoly.notification.Sound; /** * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. */ public class BuyCard extends Dialog { private final MonopolyApp app; - private final Geometry overlayBackground; private final Container buyCardContainer; private final Container backgroundContainer; @@ -34,22 +34,18 @@ public class BuyCard extends Dialog { //Generate the corresponfing field BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); - // 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); + attachChild(backgroundContainer); // Hauptcontainer für die Gebäudekarte buyCardContainer = new Container(); - buyCardContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); - - - Label settingsTitle = buyCardContainer.addChild(new Label( field.getName(), new ElementId("settings-title"))); - settingsTitle.setFontSize(48); + + + Label title = buyCardContainer.addChild(new Label( field.getName(), new ElementId("label-Bold"))); + title.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); + title.setFontSize(48); // Text, der auf der Karte steht // Die Preise werden dynamisch dem BoardManager entnommen @@ -70,9 +66,17 @@ public class BuyCard extends Dialog { // Beenden-Button Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button"))); quitButton.setFontSize(32); + quitButton.addClickCommands(s -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); // Kaufen-Button Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button"))); buyButton.setFontSize(32); + buyButton.addClickCommands(s -> ifTopDialog( () -> { + app.getGameLogic().playSound(Sound.BUTTON); + //TODO send buy property request + })); float padding = 10; // Padding around the settingsContainer for the background backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0)); @@ -94,22 +98,6 @@ public class BuyCard extends Dialog { app.getGuiNode().attachChild(buyCardContainer); } - /** - * 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. */ @@ -117,7 +105,6 @@ public class BuyCard extends Dialog { public void close() { app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand - app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay super.close(); }