From 119284f25662dc4b1cf7bf1f303df906c38a561d Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sat, 30 Nov 2024 00:40:58 +0100 Subject: [PATCH 1/3] resized WinnerPopUp --- .../java/pp/monopoly/client/MonopolyApp.java | 2 +- .../client/gui/popups/WinnerPopUp.java | 128 ++++++++++++++---- 2 files changed, 102 insertions(+), 28 deletions(-) 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 b3bc086..c8dfd27 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,7 +280,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 Rent(this); + Dialog tmp = new WinnerPopUp(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java index ffb4c09..841a6e8 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java @@ -1,51 +1,125 @@ package pp.monopoly.client.gui.popups; +import com.jme3.material.Material; +import com.jme3.material.RenderState; +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.IconComponent; - +import com.simsilica.lemur.component.QuadBackgroundComponent; +import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; public class WinnerPopUp extends Dialog { - private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container WinnerContainer; + private final Container backgroundContainer; + /** - * Constructs a new NetworkDialog. + * Constructs a new WinnerPopUp dialog. * - * @param app The NetworkSupport instance to be used for network operations. + * @param app The MonopolyApp instance. */ public WinnerPopUp(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - initializeDialog(); + + + // 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 + WinnerContainer = new Container(); + WinnerContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + WinnerContainer.setPreferredSize(new Vector3f(440,600,10)); + + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an + backgroundContainer.setPreferredSize(WinnerContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label winnerTitle = WinnerContainer.addChild(new Label("Herlichen Glückwunsch, du bist der neue Monopoly Champion!", new ElementId("header"))); + winnerTitle.setFontSize(25); + // winnerTitle.setColor(ColorRGBA.Black); + // Create the image container + Container imageContainer = WinnerContainer.addChild(new Container()); + imageContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Dark gray background + imageContainer.setPreferredSize(WinnerContainer.getPreferredSize().addLocal(-250, -200, 0)); // Adjust size for layout + + // Add the image to the container + Label imageLabel = new Label(""); // Create a label for the image + IconComponent icon = new IconComponent("Pictures/MonopolyWinner.png"); // Load the image as an icon + icon.setIconScale(1); // Scale the image appropriately + imageLabel.setIcon(icon); + imageContainer.addChild(imageLabel); // Add the image label to the container + + // Beenden-Button + Button quitButton = WinnerContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Popup + WinnerContainer.setLocalTranslation( + (app.getCamera().getWidth() - WinnerContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + WinnerContainer.getPreferredSize().y) / 2, + 8 + ); + + // Zentriere das Popup + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - WinnerContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + WinnerContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(WinnerContainer); } /** - * Initializes the dialog with input fields and connection buttons. + * Erstellt einen halbtransparenten Hintergrund für das Menü. + * + * @return Geometrie des Overlays */ - private void initializeDialog() { - Container inputContainer = new Container(); - - // Titel und Eingabefelder für Host und Port - inputContainer.addChild(new Label("Herlichen Glückwunsch!")); - inputContainer.addChild(new Label("Du,bist der Monopoly Champion!!!")); - - Label imageLabel = new Label(""); - IconComponent icon = new IconComponent("Pictures/MonopolyWinner.png"); // Icon mit Textur erstellen - icon.setIconScale(1); // Skalierung des Bildes - imageLabel.setIcon(icon); - - // Setze das Icon im Label - inputContainer.addChild(imageLabel); - - Button cancelButton = inputContainer.addChild(new Button("Spiel beenden")); - cancelButton.addClickCommands(source -> ifTopDialog(app::closeApp)); - - inputContainer.setLocalTranslation(300, 800, 0); - app.getGuiNode().attachChild(inputContainer); + 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(RenderState.BlendMode.Alpha); + overlay.setMaterial(material); + overlay.setLocalTranslation(0, 0, 0); + return overlay; } -} + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(WinnerContainer); // 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 174fe5cfb3ee27528a496635712af8a26b93ef38 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sat, 30 Nov 2024 00:58:24 +0100 Subject: [PATCH 2/3] resized LooserPopUp --- .../java/pp/monopoly/client/MonopolyApp.java | 2 +- .../client/gui/popups/LooserPopUp.java | 129 ++++++++++++++---- .../client/gui/popups/WinnerPopUp.java | 2 +- 3 files changed, 103 insertions(+), 30 deletions(-) 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 c8dfd27..64a832a 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,7 +280,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 WinnerPopUp(this); + Dialog tmp = new LooserPopUp(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java index 8c7ad48..075b4a4 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java @@ -1,52 +1,125 @@ package pp.monopoly.client.gui.popups; +import com.jme3.material.Material; +import com.jme3.material.RenderState; +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.IconComponent; - +import com.simsilica.lemur.component.QuadBackgroundComponent; +import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; public class LooserPopUp extends Dialog { - private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container LooserContainer; + private final Container backgroundContainer; + /** - * Constructs a new NetworkDialog. + * Constructs a new WinnerPopUp dialog. * - * @param network The NetworkSupport instance to be used for network operations. + * @param app The MonopolyApp instance. */ public LooserPopUp(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - initializeDialog(); + + + // 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 + LooserContainer = new Container(); + LooserContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + LooserContainer.setPreferredSize(new Vector3f(355,600,10)); + + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an + backgroundContainer.setPreferredSize(LooserContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label looserTitle = LooserContainer.addChild(new Label("Schade, du hast leider verloren, die nächste Runde wird besser!", new ElementId("header"))); + looserTitle.setFontSize(25); + // looserTitle.setColor(ColorRGBA.Black); + // Create the image container + Container imageContainer = LooserContainer.addChild(new Container()); + imageContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Dark gray background + imageContainer.setPreferredSize(LooserContainer.getPreferredSize().addLocal(-250, -200, 0)); // Adjust size for layout + + // Add the image to the container + Label imageLabel = new Label(""); // Create a label for the image + IconComponent icon = new IconComponent("Pictures/MonopolyLooser.png"); // Load the image as an icon + icon.setIconScale(0.7f); // Scale the image appropriately + imageLabel.setIcon(icon); + imageContainer.addChild(imageLabel); // Add the image label to the container + + // Beenden-Button + Button quitButton = LooserContainer.addChild(new Button("Spiel beenden", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Popup + LooserContainer.setLocalTranslation( + (app.getCamera().getWidth() - LooserContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + LooserContainer.getPreferredSize().y) / 2, + 8 + ); + + // Zentriere das Popup + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - LooserContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + LooserContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(LooserContainer); } /** - * Initializes the dialog with input fields and connection buttons. + * Erstellt einen halbtransparenten Hintergrund für das Menü. + * + * @return Geometrie des Overlays */ - private void initializeDialog() { - Container inputContainer = new Container(); - - // Titel und Eingabefelder für Host und Port - inputContainer.addChild(new Label("Schade, du hast leider verloren!")); - inputContainer.addChild(new Label("Die nächste Runde wird besser!")); - - Label imageLabel = new Label(""); - IconComponent icon = new IconComponent("Pictures/MonopolyLooser.png"); // Icon mit Textur erstellen - icon.setIconScale(1); // Skalierung des Bildes - imageLabel.setIcon(icon); - - // Setze das Icon im Label - inputContainer.addChild(imageLabel); - - Button cancelButton = inputContainer.addChild(new Button("Spiel beenden")); - cancelButton.addClickCommands(source -> ifTopDialog(app::closeApp)); - - inputContainer.setLocalTranslation(300, 800, 10); - app.getGuiNode().attachChild(inputContainer); - + 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(RenderState.BlendMode.Alpha); + overlay.setMaterial(material); + overlay.setLocalTranslation(0, 0, 0); + return overlay; } -} + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(LooserContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + super.close(); + } + + @Override + public void escape() { + close(); + } + +} diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java index 841a6e8..4a08de9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java @@ -68,7 +68,7 @@ public class WinnerPopUp extends Dialog { imageContainer.addChild(imageLabel); // Add the image label to the container // Beenden-Button - Button quitButton = WinnerContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + Button quitButton = WinnerContainer.addChild(new Button("Spiel beenden", new ElementId("button"))); quitButton.setFontSize(32); quitButton.addClickCommands(source -> close()); From 991fe5280fe4d9160847b22789db16beade4ff42 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sat, 30 Nov 2024 01:03:11 +0100 Subject: [PATCH 3/3] centered account values --- .../src/main/resources/Interface/Lemur/pp-styles.groovy | 8 ++++++++ .../src/main/java/pp/monopoly/client/gui/Toolbar.java | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy b/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy index 749dfdb..85b874f 100644 --- a/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy +++ b/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy @@ -71,6 +71,14 @@ selector("label-Text", "pp") { color = buttonEnabledColor } +selector("label-account", "pp") { + insets = new Insets3f(2, 2, 2, 2) + fontSize = 25 + color = buttonEnabledColor + textHAlignment = HAlignment.Center + textVAlignment = VAlignment.Center +} + selector("card-label", "pp") { insets = new Insets3f(2, 2, 2, 2) color = ColorRGBA.Black diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index 7712d78..c038006 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -245,12 +245,12 @@ public class Toolbar extends Dialog implements GameEventListener { accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold"))); accountContainer.addChild(new Label( playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR", - new ElementId("label-Text") + new ElementId("label-account") )); accountContainer.addChild(new Label("Gulag Karten", new ElementId("label-Bold"))); accountContainer.addChild(new Label( playerHandler.getPlayerById(app.getId()).getNumJailCard() + "", - new ElementId("label-Text") + new ElementId("label-account") )); accountContainer.setBackground(createBackground());