From bb63a4df9fba249a7fa1b0ce3086f3556ca9249d Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Thu, 28 Nov 2024 03:16:11 +0100 Subject: [PATCH] =?UTF-8?q?Popup=5FHandel=5Fbest=C3=A4tigen=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 9 +- .../monopoly/client/gui/popups/BuyCard.java | 2 +- .../client/gui/popups/ConfirmTrade.java | 119 ++++++++++++++++++ 3 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.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 70d39d4..2490a06 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 @@ -21,15 +21,11 @@ import com.jme3.system.AppSettings; import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.Label; import com.simsilica.lemur.style.BaseStyles; +import pp.monopoly.client.gui.popups.*; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.StartMenu; import pp.monopoly.client.gui.TestWorld; -import pp.monopoly.client.gui.popups.BuildingPropertyCard; -import pp.monopoly.client.gui.popups.BuyCard; -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.ServerConnection; import pp.monopoly.notification.ClientStateEvent; @@ -134,6 +130,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private FoodFieldCard foodField; private GateFieldCard gateField; private BuyCard buyCard; + private LooserPopUp looserpopup; private boolean isBuyCardPopupOpen = false; private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed); private final ActionListener TListener = (name, isPressed, tpf) -> handleT(isPressed); @@ -278,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 BuyCard(this); + Dialog tmp = new ConfirmTrade(this); tmp.open(); } } 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 5d9c46e..d8261a5 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 @@ -28,7 +28,7 @@ public class BuyCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Create the background container 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 new file mode 100644 index 0000000..d205591 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java @@ -0,0 +1,119 @@ +package pp.monopoly.client.gui.popups; + +import com.jme3.math.ColorRGBA; +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.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 ConfirmTrade extends Dialog { + private final MonopolyApp app; + private final Container confirmTradeContainer; + private final Container backgroundContainer; + + + public ConfirmTrade(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 + confirmTradeContainer = new Container(); + + + Label title = confirmTradeContainer.addChild(new Label( "Handel", new ElementId("label-Bold"))); + title.setFontSize(48); + title.setColor(ColorRGBA.Black); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + Container propertyValuesContainer = confirmTradeContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("„Spieler XXX möchte:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen + propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + propertyValuesContainer.addChild(new Label("- XXX Gebäude", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- XXX EUR", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- XXX Sonderkaten", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + propertyValuesContainer.addChild(new Label("gegen:", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + propertyValuesContainer.addChild(new Label("- XXX Gebäude", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- XXX EUR", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- XXX Sonderkaten", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile + propertyValuesContainer.addChild(new Label("tauschen, willst du das Angebot annehmen?", new ElementId("label-Text"))); + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Beenden-Button + Button declineButton = confirmTradeContainer.addChild(new Button("Ablehnen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + declineButton.setFontSize(32); + declineButton.addClickCommands(s -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); + // 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( () -> { + app.getGameLogic().playSound(Sound.BUTTON); + app.getGameLogic().send(new BuyPropertyRequest()); + })); + // Kaufen-Button + Button confirmButton = confirmTradeContainer.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(confirmTradeContainer.getPreferredSize().addLocal(padding, padding, 0)); + + + // Zentriere das Menü + confirmTradeContainer.setLocalTranslation( + (app.getCamera().getWidth() - confirmTradeContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + confirmTradeContainer.getPreferredSize().y) / 2, + 8 + ); + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - confirmTradeContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + confirmTradeContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(confirmTradeContainer); + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(confirmTradeContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + super.close(); + } + + @Override + public void escape() { + new SettingsMenu(app).open(); + } +}