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());