From afdf43ebf14c6be2a91d7b66ddef72edc582f529 Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Fri, 15 Nov 2024 08:36:16 +0100 Subject: [PATCH] =?UTF-8?q?=C3=9Cbergang=20zu=20TestMap=20verbessert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/MonopolyApp.java | 36 +++++++++++++++---- .../monopoly/client/gui/CreateGameMenu.java | 10 +++++- 2 files changed, 39 insertions(+), 7 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 e369133..4bba43f 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 @@ -9,7 +9,12 @@ import com.jme3.font.BitmapText; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; +import com.jme3.material.Material; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Box; import com.jme3.system.AppSettings; +import com.jme3.texture.Texture; import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.style.BaseStyles; @@ -17,7 +22,6 @@ 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.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -161,12 +165,32 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga } //altes Fenster beim Start von TestWorld schließen public void startTestWorld() { - // Beendet das MonopolyApp-Fenster - stop(false); + // Entferne die aktuelle GUI + guiNode.detachAllChildren(); - // Startet die TestWorld - TestWorld testWorld = new TestWorld(); - testWorld.start(); + // Erstelle ein Quadrat mit Textur + Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat + Geometry geom = new Geometry("Box", box); + + // Setze das Material mit Textur + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + Texture texture = assetManager.loadTexture("Pictures/board.png"); + mat.setTexture("ColorMap", texture); + geom.setMaterial(mat); + + // Füge das Quadrat zur Szene hinzu + rootNode.attachChild(geom); + + // Setze die Kameraposition + cam.setLocation(new Vector3f(0, 0, 3)); + cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y); + } + public void returnToMenu() { + // Entferne die Testszene + rootNode.detachAllChildren(); + + // Zeige das Startmenü erneut + StartMenu.createStartMenu(this); } 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 7d2fe3b..6b88b62 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 @@ -63,7 +63,10 @@ public class CreateGameMenu { // "Spiel hosten"-Button Button hostButton = buttonContainer.addChild(new Button("Spiel hosten")); hostButton.setPreferredSize(new Vector3f(120, 40, 0)); - hostButton.addClickCommands(source -> startTestWorld()); + hostButton.addClickCommands(source -> { + closeCreateGameMenu(); // Schließt das Menü + app.startTestWorld(); // Startet die Testwelt in der Hauptanwendung +}); // "Beitreten"-Button @@ -116,6 +119,11 @@ public class CreateGameMenu { // Startet die Testszene TestWorld.startTestWorld(); } + + private void closeCreateGameMenu() { + app.getGuiNode().detachChild(menuContainer); // Entfernt den Menü-Container + app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild + } }