mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 20:29:44 +01:00
oberfläche der lobby fertig
This commit is contained in:
parent
ecba1c3135
commit
738b04f2d9
@ -7,6 +7,7 @@ import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.simsilica.lemur.Axis;
|
||||
import com.simsilica.lemur.Button;
|
||||
@ -30,7 +31,6 @@ public class LobbyMenu {
|
||||
private final MonopolyApp app;
|
||||
private final Container menuContainer;
|
||||
private Geometry background;
|
||||
private final Selector<String> dropdown;
|
||||
|
||||
public LobbyMenu(MonopolyApp app) {
|
||||
this.app = app;
|
||||
@ -50,11 +50,11 @@ public class LobbyMenu {
|
||||
|
||||
// Create a smaller horizontal container for the label, input field, and spacers
|
||||
Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
|
||||
horizontalContainer.setPreferredSize(new Vector3f(600, 50, 0)); // Adjust container size
|
||||
horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size
|
||||
horizontalContainer.setBackground(null);
|
||||
|
||||
Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold")));
|
||||
title.setFontSize(48);
|
||||
title.setFontSize(40);
|
||||
|
||||
// Add a spacer between the title and the input field
|
||||
Label spacerBeforeInput = horizontalContainer.addChild(new Label("")); // Invisible spacer
|
||||
@ -77,40 +77,81 @@ public class LobbyMenu {
|
||||
);
|
||||
app.getGuiNode().attachChild(menuContainer);
|
||||
|
||||
// Spielerstatus anzeigen
|
||||
Container playerListContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
|
||||
playerListContainer.addChild(new Label("Spieler in der Lobby:"));
|
||||
playerListContainer.setBackground(null);
|
||||
Label playersLabel = playerListContainer.addChild(new Label("Noch keine Spieler verbunden.")); // Beispieltext
|
||||
|
||||
VersionedList<String> items = new VersionedList<>();
|
||||
items.add("Alpha");
|
||||
items.add("Beta");
|
||||
items.add("Gamma");
|
||||
items.add("Back");
|
||||
|
||||
dropdown = new Selector<>(items,"glass");
|
||||
dropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
||||
menuContainer.addChild(dropdown);
|
||||
|
||||
// Add the custom action listener
|
||||
addSelectionActionListener(dropdown, this::onDropdownSelectionChanged);
|
||||
// Dropdowns and Labels
|
||||
Container dropdownContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
|
||||
dropdownContainer.setPreferredSize(new Vector3f(800, 200, 0));
|
||||
dropdownContainer.setBackground(null);
|
||||
dropdownContainer.setInsets(new Insets3f(10, 0, 0, 0));
|
||||
// Player Input Field
|
||||
Container playerInputContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
|
||||
playerInputContainer.addChild(new Label("Spieler:"));
|
||||
playerInputContainer.setBackground(null);
|
||||
|
||||
|
||||
TextField playerInputField = new TextField("");
|
||||
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
|
||||
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
|
||||
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
||||
playerInputContainer.addChild(playerInputField);
|
||||
// Spacer (Center Circle Area)
|
||||
Label spacer = dropdownContainer.addChild(new Label(""));
|
||||
spacer.setPreferredSize(new Vector3f(200, 200, 0)); // Adjust this to fit the center graphic
|
||||
|
||||
// Figur Dropdown
|
||||
Container figureDropdownContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
|
||||
figureDropdownContainer.addChild(new Label("Figur:"));
|
||||
figureDropdownContainer.setBackground(null);
|
||||
|
||||
VersionedList<String> figures = new VersionedList<>();
|
||||
figures.add("Hund");
|
||||
figures.add("Katze");
|
||||
figures.add("Panzer");
|
||||
figures.add("Pot");
|
||||
|
||||
Selector<String> figureDropdown = new Selector<>(figures, "glass");
|
||||
figureDropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.DarkGray));
|
||||
figureDropdown.setPreferredSize(new Vector3f(100, 20, 0));
|
||||
figureDropdownContainer.addChild(figureDropdown);
|
||||
|
||||
addSelectionActionListener(figureDropdown, this::onDropdownSelectionChanged);
|
||||
|
||||
// Buttons
|
||||
Container buttonContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
|
||||
buttonContainer.setPreferredSize(new Vector3f(400, 50, 0));
|
||||
buttonContainer.setPreferredSize(new Vector3f(100, 40, 0));
|
||||
buttonContainer.setInsets(new Insets3f(20, 0, 10, 0)); // Add spacing above the buttons
|
||||
buttonContainer.setBackground(null);
|
||||
// Lower-left container for "Abbrechen" button
|
||||
Container lowerLeftMenu = new Container();
|
||||
Button cancelButton = new Button("Abbrechen");
|
||||
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||
cancelButton.setFontSize(18); // Adjust font size
|
||||
cancelButton.addClickCommands(source -> goBackToCreateGame()); // Add functionality
|
||||
lowerLeftMenu.addChild(cancelButton);
|
||||
|
||||
// "Bereit"-Button
|
||||
Button readyButton = buttonContainer.addChild(new Button("Bereit"));
|
||||
readyButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
readyButton.addClickCommands(source -> toggleReady(playersLabel));
|
||||
// Position the container near the bottom-left corner
|
||||
lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 3)); // Adjust X and Y to align with the bottom-left corner
|
||||
app.getGuiNode().attachChild(lowerLeftMenu);
|
||||
|
||||
// "Zurück"-Button
|
||||
Button backButton = buttonContainer.addChild(new Button("Zurück"));
|
||||
backButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
backButton.addClickCommands(source -> goBackToCreateGame());
|
||||
// Lower-right container for "Bereit" button
|
||||
Container lowerRightMenu = new Container();
|
||||
Button readyButton = new Button("Bereit");
|
||||
readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||
readyButton.setFontSize(18); // Adjust font size
|
||||
readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style
|
||||
readyButton.addClickCommands(source -> toggleReady(null)); // Add functionality
|
||||
lowerRightMenu.addChild(readyButton);
|
||||
|
||||
// Position the container near the bottom-right corner
|
||||
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 3)); // X: 220px from the right, Y: 50px above the bottom
|
||||
app.getGuiNode().attachChild(lowerRightMenu);
|
||||
|
||||
// Add a colored circle between the input field and the dropdown menu
|
||||
Geometry circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
|
||||
circle.setLocalTranslation(new Vector3f(
|
||||
(app.getCamera().getWidth()) / 2, // Center horizontally
|
||||
(app.getCamera().getHeight() / 2) - 90, // Adjust Y position
|
||||
2 // Ensure it's in front of the background but behind the dropdown
|
||||
));
|
||||
app.getGuiNode().attachChild(circle); // Attach to the GUI node
|
||||
|
||||
// Zentrierung des Containers
|
||||
menuContainer.setLocalTranslation(
|
||||
@ -122,11 +163,12 @@ public class LobbyMenu {
|
||||
app.getGuiNode().attachChild(menuContainer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu.
|
||||
*/
|
||||
private void addBackgroundImage() {
|
||||
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
|
||||
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/lobby.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");
|
||||
@ -137,6 +179,19 @@ public class LobbyMenu {
|
||||
app.getGuiNode().attachChild(background);
|
||||
}
|
||||
|
||||
private Geometry createCircle(ColorRGBA color) {
|
||||
|
||||
Sphere sphere = new Sphere(90,90,60.0f);
|
||||
Geometry circleGeometry = new Geometry("Circle", sphere);
|
||||
|
||||
// Create a material with a solid color
|
||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
material.setColor("Color", color); // Set the desired color
|
||||
circleGeometry.setMaterial(material);
|
||||
|
||||
return circleGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltet den "Bereit"-Status um.
|
||||
*/
|
||||
|
BIN
Projekte/monopoly/client/src/main/resources/Pictures/lobby.png
Normal file
BIN
Projekte/monopoly/client/src/main/resources/Pictures/lobby.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 MiB |
Loading…
Reference in New Issue
Block a user