From fd347c7780fdfbd36e7a8d4079a6bd0c9a910884 Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Sat, 23 Nov 2024 16:50:16 +0100 Subject: [PATCH] =?UTF-8?q?Building=20property=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 24 ++-- .../monopoly/client/gui/BuildingProperty.java | 125 ++++++++++++++++++ .../monopoly/client/gui/CreateGameMenu.java | 2 + .../pp/monopoly/client/gui/FoodField.java | 117 ++++++++++++++++ .../pp/monopoly/client/gui/GateField.java | 117 ++++++++++++++++ .../monopoly/client/gui/popups/BuyCard.java | 12 +- 6 files changed, 384 insertions(+), 13 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingProperty.java create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FoodField.java create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GateField.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 e454bb9..2f3d820 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 @@ -16,8 +16,7 @@ import com.simsilica.lemur.style.BaseStyles; import pp.dialog.DialogBuilder; import pp.dialog.DialogManager; import pp.graphics.Draw; -import pp.monopoly.client.gui.SettingsMenu; -import pp.monopoly.client.gui.TestWorld; +import pp.monopoly.client.gui.*; import pp.monopoly.client.gui.popups.BuyCard; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; @@ -43,7 +42,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private MonopolyServer monopolyServer; private NetworkSupport networkSupport; + // TODO Temp später entfernen + private BuildingProperty buildingProperty; + private FoodField foodField; + private GateField gateField; private BuyCard buyCard; private boolean isBuyCardPopupOpen = false; private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed); @@ -143,20 +146,20 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga } } - //logik zum wechselnden erscheinen und verschwinden beim drücken von B + //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - if (buyCard != null && isBuyCardPopupOpen) { + if (buildingProperty != null && isBuyCardPopupOpen) { // Schließe das SettingsMenu System.out.println("Schließe BuyCardPopup..."); - buyCard.close(); - buyCard = null; + buildingProperty.close(); + buildingProperty = null; setBuyCardPopupOpen(false); } else { // Öffne das SettingsMenu System.out.println("Öffne BuyCardPopup..."); - buyCard = new BuyCard(this); - buyCard.open(); + buildingProperty = new BuildingProperty(this); + buildingProperty.open(); setBuyCardPopupOpen(true); } } @@ -224,6 +227,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga this.isSettingsMenuOpen = isOpen; } + // TODO später entfernen + public void setBuyCardPopupOpen(boolean isOpen) { this.isBuyCardPopupOpen = isOpen; } @@ -241,8 +246,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga testWorld.initializeScene(); // Initialisiere die Szene } - public void startBuyCard() { + // TODO später entfernen + public void startBuyCard() { } public void returnToMenu() { diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingProperty.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingProperty.java new file mode 100644 index 0000000..2bcf2ad --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingProperty.java @@ -0,0 +1,125 @@ +package pp.monopoly.client.gui; + +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +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; + +/** + * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + */ +public class BuildingProperty extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container settingsContainer; + private final Container backgroundContainer; + + public BuildingProperty(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 das Menü + settingsContainer = new Container(); + //settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1))); // hell + settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(2 / 255f, 112 / 255f, 191 / 255f, 1))); //dunkel + + + + + // Titel + Label settingsTitle = settingsContainer.addChild(new Label("Gebäude Arsch", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen + settingsTitle.setFontSize(48); + + int i = 0; + int a = 10; + int b = -45; + + // Effekt-Sound: Slider und Checkbox + Container propertyValuesContainer = settingsContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("„Grundstückswert:" + i, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Miete allein:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-mit 1 Haus:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-mit 2 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-mit 3 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-mit 4 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-mit 1 Hotel:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„-1 Haus kostet:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Hypothek:" + b, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Beenden-Button + Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); + quitButton.setFontSize(32); + // Kaufen-Button + Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); + buyButton.setFontSize(32); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); + + + // Zentriere das Menü + settingsContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, + 8 + ); + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(settingsContainer); + } + + /** + * 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() { + System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe + app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + app.setSettingsMenuOpen(false); // Menü als geschlossen markieren + app.unblockInputs(); // Eingaben wieder aktivieren + System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + } + + +} diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java index 3efc117..b4c0ca0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java @@ -110,6 +110,8 @@ public class CreateGameMenu { } }, "OpenTestWorld"); + // TODO später entfernen + app.getInputManager().addMapping("OpenBuyCard", new com.jme3.input.controls.KeyTrigger(com.jme3.input.KeyInput.KEY_B)); app.getInputManager().addListener(new com.jme3.input.controls.ActionListener() { @Override diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FoodField.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FoodField.java new file mode 100644 index 0000000..a45135b --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FoodField.java @@ -0,0 +1,117 @@ +package pp.monopoly.client.gui; + +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +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; + +/** + * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + */ +public class FoodField extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container settingsContainer; + private final Container backgroundContainer; + + public FoodField(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 das Menü + settingsContainer = new Container(); + settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f))); + + + + // Titel + Label settingsTitle = settingsContainer.addChild(new Label("Gebäude 30", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen + settingsTitle.setFontSize(48); + + int i = 0; + int a = 10; + int b = -45; + + // Effekt-Sound: Slider und Checkbox + Container propertyValuesContainer = settingsContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("„Preis:" + i, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Miete:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Hypothek:" + b, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Beenden-Button + Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); + quitButton.setFontSize(32); + // Kaufen-Button + Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); + buyButton.setFontSize(32); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); + + + // Zentriere das Menü + settingsContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, + 8 + ); + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(settingsContainer); + } + + /** + * 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() { + System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe + app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + app.setSettingsMenuOpen(false); // Menü als geschlossen markieren + app.unblockInputs(); // Eingaben wieder aktivieren + System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + } + + +} diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GateField.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GateField.java new file mode 100644 index 0000000..0d60b05 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GateField.java @@ -0,0 +1,117 @@ +package pp.monopoly.client.gui; + +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +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; + +/** + * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + */ +public class GateField extends Dialog { + private final MonopolyApp app; + private final Geometry overlayBackground; + private final Container settingsContainer; + private final Container backgroundContainer; + + public GateField(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 das Menü + settingsContainer = new Container(); + settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f))); + + + + // Titel + Label settingsTitle = settingsContainer.addChild(new Label("Gebäude 30", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen + settingsTitle.setFontSize(48); + + int i = 0; + int a = 10; + int b = -45; + + // Effekt-Sound: Slider und Checkbox + Container propertyValuesContainer = settingsContainer.addChild(new Container()); + propertyValuesContainer.addChild(new Label("„Preis:" + i, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Miete:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Hypothek:" + b, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + + // Beenden-Button + Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); + quitButton.setFontSize(32); + // Kaufen-Button + Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); + buyButton.setFontSize(32); + + float padding = 10; // Padding around the settingsContainer for the background + backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); + + + // Zentriere das Menü + settingsContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, + 8 + ); + + backgroundContainer.setLocalTranslation( + (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, + (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, + 7 + ); + + app.getGuiNode().attachChild(settingsContainer); + } + + /** + * 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() { + System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe + app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü + app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand + app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay + app.setSettingsMenuOpen(false); // Menü als geschlossen markieren + app.unblockInputs(); // Eingaben wieder aktivieren + System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + } + + +} 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 dadde7e..8cfba7f 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 @@ -41,14 +41,18 @@ public class BuyCard extends Dialog { // Titel - Label settingsTitle = settingsContainer.addChild(new Label("Gebäude XX", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen + Label settingsTitle = settingsContainer.addChild(new Label("Gebäude 30", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen settingsTitle.setFontSize(48); + int i = 0; + int a = 10; + int b = -45; + // Effekt-Sound: Slider und Checkbox Container propertyValuesContainer = settingsContainer.addChild(new Container()); - propertyValuesContainer.addChild(new Label("„Preis: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen - propertyValuesContainer.addChild(new Label("„Miete: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen - propertyValuesContainer.addChild(new Label("„Hypothek: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Preis:" + i, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Miete:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen + propertyValuesContainer.addChild(new Label("„Hypothek:" + b, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Beenden-Button