Merge remote-tracking branch 'origin/gui' into gui

This commit is contained in:
Yvonne Schmidt 2024-11-15 18:39:47 +01:00
commit 61b88f6bf8
2 changed files with 39 additions and 7 deletions

View File

@ -9,7 +9,12 @@ import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput; import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger; 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.system.AppSettings;
import com.jme3.texture.Texture;
import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.BaseStyles; import com.simsilica.lemur.style.BaseStyles;
@ -17,7 +22,6 @@ import pp.dialog.DialogBuilder;
import pp.dialog.DialogManager; import pp.dialog.DialogManager;
import pp.graphics.Draw; import pp.graphics.Draw;
import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.client.gui.TestWorld;
import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.ClientGameLogic;
import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.MonopolyClient;
import pp.monopoly.game.client.ServerConnection; 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 //altes Fenster beim Start von TestWorld schließen
public void startTestWorld() { public void startTestWorld() {
// Beendet das MonopolyApp-Fenster // Entferne die aktuelle GUI
stop(false); guiNode.detachAllChildren();
// Startet die TestWorld // Erstelle ein Quadrat mit Textur
TestWorld testWorld = new TestWorld(); Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat
testWorld.start(); 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);
} }

View File

@ -63,7 +63,10 @@ public class CreateGameMenu {
// "Spiel hosten"-Button // "Spiel hosten"-Button
Button hostButton = buttonContainer.addChild(new Button("Spiel hosten")); Button hostButton = buttonContainer.addChild(new Button("Spiel hosten"));
hostButton.setPreferredSize(new Vector3f(120, 40, 0)); 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 // "Beitreten"-Button
@ -116,6 +119,11 @@ public class CreateGameMenu {
// Startet die Testszene // Startet die Testszene
TestWorld.startTestWorld(); TestWorld.startTestWorld();
} }
private void closeCreateGameMenu() {
app.getGuiNode().detachChild(menuContainer); // Entfernt den Menü-Container
app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
}
} }