From ed87a6167d8487ee5543a61041af81e8e72f35bf Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Fri, 15 Nov 2024 05:36:57 +0100 Subject: [PATCH 1/2] Verbesserung SettingsMenu --- .../java/pp/monopoly/client/StartMenu.java | 7 +- .../monopoly/client/gui/CreateGameMenu.java | 4 +- .../pp/monopoly/client/gui/SettingsMenu.java | 65 ++++++++++++++++++- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java index 7b7de86..abd3799 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java @@ -8,7 +8,6 @@ import com.jme3.texture.Texture; import com.simsilica.lemur.Axis; import com.simsilica.lemur.Button; import com.simsilica.lemur.Container; -import com.simsilica.lemur.Label; import com.simsilica.lemur.component.SpringGridLayout; import pp.dialog.Dialog; @@ -51,9 +50,9 @@ public class StartMenu extends Dialog { // Center container for title and play button Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X)); - Label titleLabel = new Label("Hauptmenü"); - titleLabel.setFontSize(48); - centerMenu.addChild(titleLabel); + // Label titleLabel = new Label("Hauptmenü"); + //titleLabel.setFontSize(48); + //centerMenu.addChild(titleLabel); Button startButton = new Button("Spielen"); startButton.addClickCommands(source -> startGame(app)); 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 8e13fb5..96bd73a 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 @@ -27,8 +27,8 @@ public class CreateGameMenu { Label title = createGameContainer.addChild(new Label("Neues Spiel", new ElementId("title"))); // Fügt zwei Eingabefelder unter dem Titel hinzu - TextField inputField1 = createGameContainer.addChild(new TextField("Eingabefeld 1")); - TextField inputField2 = createGameContainer.addChild(new TextField("Eingabefeld 2")); + TextField inputField1 = createGameContainer.addChild(new TextField("Host")); + TextField inputField2 = createGameContainer.addChild(new TextField("Port")); // Erstellt einen Container mit einem Rasterlayout, um die Buttons nebeneinander anzuordnen Container buttonContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y)); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java index c5b2d19..eb882da 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java @@ -1,6 +1,10 @@ package pp.monopoly.client.gui; import com.jme3.math.ColorRGBA; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.shape.Quad; +import com.jme3.texture.Texture; import com.simsilica.lemur.Button; import com.simsilica.lemur.Checkbox; import com.simsilica.lemur.Container; @@ -15,15 +19,23 @@ import pp.monopoly.client.MonopolyApp; public class SettingsMenu extends Dialog { private final MonopolyApp app; private final Container settingsContainer; + private Geometry blockLayer; + private final Node savedGuiNodeContent = new Node("SavedGuiNodeContent"); public SettingsMenu(MonopolyApp app) { super(app.getDialogManager()); this.app = app; + // Blockierungsebene hinzufügen + addBlockLayer(); + + // Hintergrundbild + addBackgroundImage(); + settingsContainer = new Container(); - + // Hintergrundfarbe für das Container-Element setzen, um es undurchsichtig zu machen - settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1f))); // Dunkelgrauer, undurchsichtiger Hintergrund + settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.8f))); // Teiltransparent, falls gewünscht // Titel "Einstellungen" Label settingsTitle = settingsContainer.addChild(new Label("Einstellungen", new ElementId("settings-title"))); @@ -64,15 +76,62 @@ public class SettingsMenu extends Dialog { settingsContainer.setLocalTranslation( (app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, - 0 + 1 // Höhere Z-Ebene für den Vordergrund ); app.getGuiNode().attachChild(settingsContainer); } + private void addBlockLayer() { + // Sichern des aktuellen GUI-Inhalts + for (var child : app.getGuiNode().getChildren()) { + savedGuiNodeContent.attachChild(child); + } + app.getGuiNode().detachAllChildren(); + + // Blockierungsebene erstellen und hinzufügen + blockLayer = new Geometry("BlockLayer", new Quad(app.getCamera().getWidth(), app.getCamera().getHeight())); + blockLayer.setMaterial(createTransparentMaterial()); + blockLayer.setLocalTranslation(0, 0, 0); // Platzierung unterhalb des SettingsMenu + app.getGuiNode().attachChild(blockLayer); + } + + private com.jme3.material.Material createTransparentMaterial() { + com.jme3.material.Material material = new com.jme3.material.Material( + app.getAssetManager(), + "Common/MatDefs/Misc/Unshaded.j3md" + ); + material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent + material.getAdditionalRenderState().setBlendMode(com.jme3.material.RenderState.BlendMode.Alpha); + return material; + } + + private void addBackgroundImage() { + Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); + Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); + Geometry background = new Geometry("Background", quad); + com.jme3.material.Material backgroundMaterial = new com.jme3.material.Material( + app.getAssetManager(), + "Common/MatDefs/Misc/Unshaded.j3md" + ); + backgroundMaterial.setTexture("ColorMap", backgroundImage); + background.setMaterial(backgroundMaterial); + background.setLocalTranslation(0, 0, -1); // Platzierung hinter dem SettingsMenu + app.getGuiNode().attachChild(background); + } + @Override public void close() { + // Entfernt das SettingsMenu und die Blockierungsebene app.getGuiNode().detachChild(settingsContainer); + app.getGuiNode().detachChild(blockLayer); + + // Stellt die ursprüngliche GUI wieder her + for (var child : savedGuiNodeContent.getChildren()) { + app.getGuiNode().attachChild(child); + } + savedGuiNodeContent.detachAllChildren(); + app.setSettingsMenuOpen(false); } } From c31f924d77af3bf9e562e61494851fcc8014ebbc Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Fri, 15 Nov 2024 06:25:21 +0100 Subject: [PATCH 2/2] =?UTF-8?q?CreateGame=20fertig=20f=C3=BCr=20feinschlif?= =?UTF-8?q?f=20(Icon=20test)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 7 +- .../monopoly/client/gui/CreateGameMenu.java | 124 +++++++++++------- .../client/src/main/resources/icons/test.ico | Bin 0 -> 4286 bytes 3 files changed, 84 insertions(+), 47 deletions(-) create mode 100644 Projekte/monopoly/client/src/main/resources/icons/test.ico 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 ac40396..5897a6b 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 @@ -81,11 +81,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga GuiGlobals.initialize(this); BaseStyles.loadGlassStyle(); GuiGlobals.getInstance().getStyles().setDefaultStyle("glass"); - + setupInput(); setupGui(); - - // Erst jetzt StartMenu erstellen, nachdem GuiGlobals initialisiert ist + + // Initialisiere das Startmenü StartMenu.createStartMenu(this); } @@ -102,6 +102,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga inputManager.addMapping("ESC", new KeyTrigger(KeyInput.KEY_ESCAPE)); inputManager.addListener(escapeListener, "ESC"); } + private void handleEscape(boolean isPressed) { if (isPressed) { 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 96bd73a..bdfe782 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 @@ -1,70 +1,106 @@ package pp.monopoly.client.gui; +import com.jme3.material.Material; import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Quad; +import com.jme3.texture.Texture; import com.simsilica.lemur.Axis; import com.simsilica.lemur.Button; import com.simsilica.lemur.Container; -import com.simsilica.lemur.Insets3f; import com.simsilica.lemur.Label; import com.simsilica.lemur.TextField; import com.simsilica.lemur.component.SpringGridLayout; -import com.simsilica.lemur.style.ElementId; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.StartMenu; +/** + * CreateGameMenu class represents the menu for creating a new game. + */ public class CreateGameMenu { private final MonopolyApp app; - private final Container createGameContainer; + private final Container menuContainer; + private Geometry background; public CreateGameMenu(MonopolyApp app) { this.app = app; - - // Hauptcontainer für das Menü mit Innenabstand - createGameContainer = new Container(); - createGameContainer.setInsets(new Insets3f(10, 10, 10, 10)); - - // Setzt den Titel des Menüs - Label title = createGameContainer.addChild(new Label("Neues Spiel", new ElementId("title"))); - - // Fügt zwei Eingabefelder unter dem Titel hinzu - TextField inputField1 = createGameContainer.addChild(new TextField("Host")); - TextField inputField2 = createGameContainer.addChild(new TextField("Port")); - - // Erstellt einen Container mit einem Rasterlayout, um die Buttons nebeneinander anzuordnen - Container buttonContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y)); - buttonContainer.setInsets(new Insets3f(5, 5, 5, 5)); // Abstand zwischen den Buttons und dem Rand - - // Buttons hinzufügen und jeweils einen Innenabstand hinzufügen - Button button1 = buttonContainer.addChild(new Button("1")); - button1.setInsets(new Insets3f(5, 5, 5, 5)); - - Button button2 = buttonContainer.addChild(new Button("2")); - button2.setInsets(new Insets3f(5, 5, 5, 5)); - - Button button3 = buttonContainer.addChild(new Button("3")); - button3.setInsets(new Insets3f(5, 5, 5, 5)); - - // Fügt den Button-Container zum Hauptcontainer hinzu - createGameContainer.addChild(buttonContainer); - - // Setzt die Breite des Hauptcontainers - createGameContainer.setPreferredSize(new Vector3f(600, 400, 0)); - // Zentriert den Container auf dem Bildschirm - createGameContainer.setLocalTranslation( - (app.getCamera().getWidth() - createGameContainer.getPreferredSize().x) / 2, - (app.getCamera().getHeight() + createGameContainer.getPreferredSize().y) / 2, - 0 + // Hintergrundbild laden und hinzufügen + addBackgroundImage(); + + // Hauptcontainer für das Menü + menuContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X)); + menuContainer.setPreferredSize(new Vector3f(600, 400, 0)); // Feste Größe des Containers + + // Titel + Label title = menuContainer.addChild(new Label("Neues Spiel")); + title.setFontSize(48); + + // Eingabefelder-Container + Container inputContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X))); + inputContainer.setPreferredSize(new Vector3f(200, 150, 0)); // Eingabefelder nicht ganz so breit + inputContainer.setLocalTranslation(20, 0, 0); // Abstand vom Rand + + inputContainer.addChild(new Label("Server-Adresse:")); + TextField playerNameField = inputContainer.addChild(new TextField("localhost")); + playerNameField.setPreferredWidth(400); // Breite des Textfelds + + inputContainer.addChild(new Label("Port:")); + TextField serverAddressField = inputContainer.addChild(new TextField("42069")); + serverAddressField.setPreferredWidth(400); // Breite des Textfelds + + // Button-Container + Container buttonContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y))); + buttonContainer.setPreferredSize(new Vector3f(400, 50, 0)); + buttonContainer.setLocalTranslation(20, 0, 0); // Abstand vom Rand + + // "Abbrechen"-Button + Button cancelButton = buttonContainer.addChild(new Button("Abbrechen")); + cancelButton.setPreferredSize(new Vector3f(120, 40, 0)); + cancelButton.addClickCommands(source -> goBackToStartMenu()); + + // "Spiel hosten"-Button + Button hostButton = buttonContainer.addChild(new Button("Spiel hosten")); + hostButton.setPreferredSize(new Vector3f(120, 40, 0)); + // hostButton.addClickCommands(source -> hostGame()); // Placeholder for hosting logic + + // "Beitreten"-Button + Button joinButton = buttonContainer.addChild(new Button("Beitreten")); + joinButton.setPreferredSize(new Vector3f(120, 40, 0)); + // joinButton.addClickCommands(source -> joinGame()); // Placeholder for joining logic + + // Zentrierung des Containers + menuContainer.setLocalTranslation( + (app.getCamera().getWidth() - menuContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + menuContainer.getPreferredSize().y) / 2, + 1 // Höhere Z-Ebene für den Vordergrund ); - // Fügt das Menü zum GUI-Knoten der App hinzu - app.getGuiNode().attachChild(createGameContainer); + app.getGuiNode().attachChild(menuContainer); } /** - * Schließt das CreateGameMenu. + * Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu. */ - public void close() { - app.getGuiNode().detachChild(createGameContainer); + private void addBackgroundImage() { + Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); + Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); + background = new Geometry("Background", quad); + Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + backgroundMaterial.setTexture("ColorMap", backgroundImage); + background.setMaterial(backgroundMaterial); + background.setLocalTranslation(0, 0, -1); // Hintergrundebene + + app.getGuiNode().attachChild(background); + } + + /** + * Geht zum Startmenü zurück, wenn "Abbrechen" angeklickt wird. + */ + private void goBackToStartMenu() { + app.getGuiNode().detachChild(menuContainer); + app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild + StartMenu.createStartMenu(app); } } diff --git a/Projekte/monopoly/client/src/main/resources/icons/test.ico b/Projekte/monopoly/client/src/main/resources/icons/test.ico new file mode 100644 index 0000000000000000000000000000000000000000..0203f61cc3f255562e3172fb6459d7d3f1665503 GIT binary patch literal 4286 zcmbtXX;53&8CBADQg=GjX4=V*W*mbd0wj!NArK%T2}#IWScE``eTe}}EM}1rvOpFf z_I)v61I7k{**CLq#ttNLZ6`R1oAgI!l4)kzbUK~JowRkcaC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