From 970a0ae25497e377e6516b77c797db13a2053559 Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Thu, 28 Nov 2024 04:34:33 +0100 Subject: [PATCH] =?UTF-8?q?Geb=C3=A4ude=5FAbrei=C3=9Fen=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 2 +- .../client/gui/popups/ConfirmTrade.java | 2 +- .../monopoly/client/gui/popups/SellHouse.java | 117 ++++++++++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.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 2490a06..117f83a 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 @@ -275,7 +275,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 ConfirmTrade(this); + Dialog tmp = new SellHouse(this); tmp.open(); } } 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 d205591..3bc6db6 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 @@ -38,7 +38,7 @@ public class ConfirmTrade extends Dialog { confirmTradeContainer = new Container(); - Label title = confirmTradeContainer.addChild(new Label( "Handel", new ElementId("label-Bold"))); + Label title = confirmTradeContainer.addChild(new Label( "Handel", new ElementId("label-Bold"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen title.setFontSize(48); title.setColor(ColorRGBA.Black); 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 new file mode 100644 index 0000000..95b5f5f --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -0,0 +1,117 @@ +package pp.monopoly.client.gui.popups; + +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +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.style.ElementId; +import pp.dialog.Dialog; +import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.gui.SettingsMenu; +import pp.monopoly.message.client.BuyPropertyRequest; +import pp.monopoly.notification.Sound; + +/** + * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + */ +public class SellHouse extends Dialog { + private final MonopolyApp app; + private final Container sellhouseContainer; + private final Container backgroundContainer; + + + public SellHouse(MonopolyApp app) { + super(app.getDialogManager()); + this.app = app; + + //Generate the corresponfing field + //int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; + // BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); + + // Create the background container + backgroundContainer = new Container(); + backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background + attachChild(backgroundContainer); + + // Hauptcontainer für die Gebäudekarte + sellhouseContainer = new Container(); + + + Label title = sellhouseContainer.addChild(new Label( "Gebäude Abreißen", new ElementId("label-Bold"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + title.setFontSize(48); + title.setColor(ColorRGBA.Black); + + Container upContainer = sellhouseContainer.addChild(new Container()); + Container middleContainer = sellhouseContainer.addChild(new Container()); + Container downContainer = sellhouseContainer.addChild(new Container()); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen + upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + middleContainer.setPreferredSize(new Vector3f(100, 150, 0)); + middleContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Red)); + middleContainer.addChild(new Label("Dies ist ein Container", new ElementId("label-Text"))); + middleContainer.addChild(new Label("", new ElementId("label-Text"))); + middleContainer.addChild(new Label("Hier kann der Slider und die Checkbocen eingefügt werden", new ElementId("label-Text"))); + downContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + downContainer.addChild(new Label("Erstattung:", new ElementId("label-Text")));// Leerzeile + downContainer.addChild(new Label("Hier die tätsächliche Erstattung", new ElementId("label-Text"))); + downContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Beenden-Button + Button cancelButton = sellhouseContainer.addChild(new Button("Abbrechen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + cancelButton.setFontSize(32); + cancelButton.addClickCommands(s -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); + // Kaufen-Button + Button confirmButton = sellhouseContainer.addChild(new Button("Bestätigen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + confirmButton.setFontSize(32); + confirmButton.addClickCommands(s -> ifTopDialog( () -> { + app.getGameLogic().playSound(Sound.BUTTON); + app.getGameLogic().send(new BuyPropertyRequest()); + })); + + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(sellhouseContainer.getPreferredSize().addLocal(padding, padding, 0)); + + + // Zentriere das Menü + sellhouseContainer.setLocalTranslation( + (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y) / 2, + 8 + ); + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(sellhouseContainer); + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(sellhouseContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + super.close(); + } + + @Override + public void escape() { + new SettingsMenu(app).open(); + } +}