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 86bc7b0..1c129e3 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 @@ -38,6 +38,7 @@ import static pp.monopoly.Resources.lookup; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.StartMenu; import pp.monopoly.client.gui.TestWorld; +import pp.monopoly.client.gui.popups.*; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -129,6 +130,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private GateFieldCard gateField; private BuyCard buyCard; private LooserPopUp looserpopup; + private Bankrupt bankrupt; private boolean isBuyCardPopupOpen = false; private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed); private TestWorld testWorld; @@ -272,7 +274,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 SellHouse(this); + Dialog tmp = new Bankrupt(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java new file mode 100644 index 0000000..28f1b24 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -0,0 +1,119 @@ +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 ist ein Overlay-Menü, welches aufgerufen werden kann, wenn man mit einem negativen Kontostand den Zug beenden möchte. // TODO welche menü-Klasse + */ +public class Bankrupt extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container bankruptContainer; + private final Container backgroundContainer; + + + + public Bankrupt(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 Gebäudekarte + bankruptContainer = new Container(); + bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + bankruptContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + // Die Namen werden dynamisch dem BoardManager entnommen + Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + Container Container = bankruptContainer.addChild(new Container()); + Container.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", new ElementId("label-Text"))); + Container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + Container.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Menü + bankruptContainer.setLocalTranslation( + (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2, + 8 + ); + + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(bankruptContainer); + } + + /** + * 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; + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(bankruptContainer); // 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/ConfirmTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java index 4fd7f14..89b47af 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 @@ -69,7 +69,7 @@ public class ConfirmTrade extends Dialog { // 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( () -> { + negotiateButton.addClickCommands(s -> ifTopDialog( () -> { //TODO Buttonfunktion prüfen app.getGameLogic().playSound(Sound.BUTTON); })); // Kaufen-Button diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java new file mode 100644 index 0000000..7f72153 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -0,0 +1,122 @@ +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; +import pp.monopoly.notification.Sound; +import static pp.monopoly.Resources.lookup; + +/** + * TimeOut ist ein Overlay-Menü, welches aufgerufen wird, wenn die Verbindung zum Server unterbrochen wurde. + */ +public class TimeOut extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container timeOutContainer; + private final Container backgroundContainer; + + + + public TimeOut(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 Gebäudekarte + timeOutContainer = new Container(); + timeOutContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + timeOutContainer.setPreferredSize(new Vector3f(550,250,10)); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + // Die Namen werden dynamisch dem BoardManager entnommen + Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift + gateFieldTitle.setFontSize(48); + gateFieldTitle.setColor(ColorRGBA.Black); + + // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen + Container propertyValuesContainer = timeOutContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text"))); + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + propertyValuesContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0)); + + // Beenden-Button + Button quitButton = timeOutContainer.addChild(new Button("Bestätigen", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(source -> close()); + + + // Zentriere das Menü + timeOutContainer.setLocalTranslation( + (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2, + 8 + ); + + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(timeOutContainer); + } + + /** + * 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; + } + + /** + * Schließt das Menü und entfernt die GUI-Elemente. + */ + @Override + public void close() { + app.getGuiNode().detachChild(timeOutContainer); // 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