mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 23:59:44 +01:00
CreateGame fertig für feinschliff (Icon test)
This commit is contained in:
parent
ed87a6167d
commit
c31f924d77
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
BIN
Projekte/monopoly/client/src/main/resources/icons/test.ico
Normal file
BIN
Projekte/monopoly/client/src/main/resources/icons/test.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue
Block a user