From f4bf38bca1a87610a8c722486e1829b1203e1e8e Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Sat, 30 Nov 2024 22:01:35 +0100 Subject: [PATCH] =?UTF-8?q?AcceptTrade,=20RejectTrade=20und=20NoMoneyWarni?= =?UTF-8?q?ng=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