TestWord eingefügt

This commit is contained in:
Luca Puderbach 2024-11-15 07:00:55 +01:00
parent 2b772199b0
commit 2e0d1c059d
3 changed files with 70 additions and 3 deletions

View File

@ -17,6 +17,7 @@ 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;
@ -81,10 +82,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
GuiGlobals.initialize(this); GuiGlobals.initialize(this);
BaseStyles.loadGlassStyle(); BaseStyles.loadGlassStyle();
GuiGlobals.getInstance().getStyles().setDefaultStyle("glass"); GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
setupInput(); setupInput();
setupGui(); setupGui();
// Initialisiere das Startmenü // Initialisiere das Startmenü
StartMenu.createStartMenu(this); StartMenu.createStartMenu(this);
} }
@ -117,6 +118,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
} }
} }
void setInfoText(String text) { void setInfoText(String text) {
topText.setText(text); topText.setText(text);
} }
@ -157,4 +159,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
.build() .build()
.open(); .open();
} }
//altes Fenster beim Start von TestWorld schließen
public void startTestWorld() {
// Beendet das MonopolyApp-Fenster
stop(false);
// Startet die TestWorld
TestWorld testWorld = new TestWorld();
testWorld.start();
}
} }

View File

@ -63,7 +63,8 @@ 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 -> hostGame()); // Placeholder for hosting logic hostButton.addClickCommands(source -> startTestWorld());
// "Beitreten"-Button // "Beitreten"-Button
Button joinButton = buttonContainer.addChild(new Button("Beitreten")); Button joinButton = buttonContainer.addChild(new Button("Beitreten"));
@ -103,4 +104,18 @@ public class CreateGameMenu {
app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
StartMenu.createStartMenu(app); StartMenu.createStartMenu(app);
} }
/*
* Link zwischen createGame und TestWorld
*/
private void startTestWorld() {
// Entfernt das Menü
app.getGuiNode().detachChild(menuContainer);
app.getGuiNode().detachChild(background);
// Startet die Testszene
TestWorld.startTestWorld();
}
} }

View File

@ -0,0 +1,39 @@
package pp.monopoly.client.gui;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
/**
* TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat.
*/
public class TestWorld extends SimpleApplication {
@Override
public void simpleInitApp() {
// Erstelle ein Quadrat
Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur
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"); // Ersetze durch den Pfad zum gewünschten Bild
mat.setTexture("ColorMap", texture);
geom.setMaterial(mat);
// Füge das Quadrat zur Szene hinzu
rootNode.attachChild(geom);
// Setze die Kameraposition, um das Quadrat zu fokussieren
cam.setLocation(new Vector3f(0, 0, 3)); // Kamera auf der Z-Achse, nah am Quadrat
cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y);
}
public static void startTestWorld() {
TestWorld testWorldApp = new TestWorld();
testWorldApp.start();
}
}