Compare commits

..

No commits in common. "bafc3f1db656f5331eadb125018f56e83ed26f4b" and "e7a680248854be09de88f4eb26924dae83ff044c" have entirely different histories.

2 changed files with 22 additions and 49 deletions

View File

@ -27,8 +27,6 @@ import pp.monopoly.game.client.ClientGameLogic;
import pp.monopoly.game.server.Player;
import pp.monopoly.game.server.PlayerColor;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.model.Figure;
import pp.monopoly.model.Rotation;
import java.util.Set;
@ -42,33 +40,32 @@ public class LobbyMenu {
private Container lowerRightMenu;
private ColorRGBA playerColor= ColorRGBA.Gray;
private PlayerHandler playerHandler;
private TextField startingCapital;
private TextField playerInputField;
private Selector<String> figureDropdown;
private PlayerHandler playerHandler; // Reference to PlayerHandler
private TextField startingCapital; // Reference to the starting capital input field
public LobbyMenu(MonopolyApp app) {
this.app = app;
this.playerHandler = ClientGameLogic.getPlayerHandler(); // Initialize PlayerHandler
int playerID = app.getNetworkSupport().getId(); // Retrieve the player ID
assignPlayerColor(playerID); //set the Players Color
int playerID = app.getNetworkSupport().getId(); // Retrieve the player ID dynamically
assignPlayerColor(playerID);
// Entfernt das CreateGameMenu (inklusive Hintergrund)
app.getGuiNode().detachAllChildren();
app.getGuiNode().detachAllChildren(); // Entfernt das CreateGameMenu (inklusive Hintergrund)
addBackgroundImage();// Hintergrundbild laden und hinzufügen
// Hintergrundbild laden und hinzufügen
addBackgroundImage();
QuadBackgroundComponent translucentWhiteBackground =
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
menuContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
menuContainer.setPreferredSize(new Vector3f(1000, 600, 0));
menuContainer.setPreferredSize(new Vector3f(1000, 600, 0)); // Fixed size of the container
menuContainer.setBackground(translucentWhiteBackground);
// 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, 40, 0));
horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size
horizontalContainer.setBackground(null);
Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold")));
@ -108,12 +105,12 @@ public class LobbyMenu {
TextField playerInputField = new TextField("Spieler 1");
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
playerInputField.setInsets(new Insets3f(5, 10, 5, 10));
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));
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)));
@ -162,11 +159,9 @@ public class LobbyMenu {
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
readyButton.addClickCommands(source -> applyStartingCapital(playerID));
readyButton.addClickCommands(source -> applyPlayerName(playerID));
readyButton.addClickCommands(source -> applyFigure(playerID));
lowerRightMenu.addChild(readyButton);
//TODO aktivieren des Spielers in den ready Status und Sprung in den nächsten Menüzustand
// 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
@ -214,36 +209,6 @@ public class LobbyMenu {
}
}
/**
* Apply the player name from the input field.
*/
private void applyPlayerName(int playerID) {
Player currentPlayer = playerHandler.getPlayerById(playerID);
String playerName = playerInputField.getText().trim();
if (!playerName.isEmpty()) {
currentPlayer.setName(playerName);
System.out.println("Player name set to: " + playerName);
} else {
System.err.println("Invalid player name: Name cannot be empty.");
}
}
/**
* Apply the selected figure to the player.
*/
private void applyFigure(int playerID) {
Player currentPlayer = playerHandler.getPlayerById(playerID);
String selectedFigure = figureDropdown.getSelectedItem();
if (selectedFigure != null && !selectedFigure.isEmpty()) {
currentPlayer.setFigure(new Figure(0, 0, 0, Rotation.RIGHT, "selectedFigure"));
System.out.println("Player figure set to: " + selectedFigure);
} else {
System.err.println("Invalid figure selection.");
}
}
/**
* Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu.
*/
@ -311,6 +276,14 @@ public class LobbyMenu {
}
}
/**
* Schaltet den "Bereit"-Status um.
*/
private void toggleReady(Label playersLabel) {
// Beispiel-Logik für das Umschalten des Status
playersLabel.setText("Spielerstatus aktualisiert."); // Beispieltext
}
/**
* Geht zurück zum CreateGameMenu.
*/

View File

@ -84,7 +84,7 @@ public class Player implements FieldVisitor<Void>{
* Set the name of the Player
* @param name the new name
*/
public void setName(String name) {
void setName(String name) {
this.name = name;
}