mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-12-01 09:59:45 +01:00
Compare commits
4 Commits
e7a6802488
...
bafc3f1db6
Author | SHA1 | Date | |
---|---|---|---|
|
bafc3f1db6 | ||
|
03571fcf74 | ||
|
a6e6b5e158 | ||
|
f67fa4d7f0 |
@ -27,6 +27,8 @@ 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;
|
||||
|
||||
@ -40,32 +42,33 @@ public class LobbyMenu {
|
||||
private Container lowerRightMenu;
|
||||
private ColorRGBA playerColor= ColorRGBA.Gray;
|
||||
|
||||
private PlayerHandler playerHandler; // Reference to PlayerHandler
|
||||
private TextField startingCapital; // Reference to the starting capital input field
|
||||
private PlayerHandler playerHandler;
|
||||
private TextField startingCapital;
|
||||
private TextField playerInputField;
|
||||
private Selector<String> figureDropdown;
|
||||
|
||||
|
||||
public LobbyMenu(MonopolyApp app) {
|
||||
this.app = app;
|
||||
this.playerHandler = ClientGameLogic.getPlayerHandler(); // Initialize PlayerHandler
|
||||
|
||||
int playerID = app.getNetworkSupport().getId(); // Retrieve the player ID dynamically
|
||||
assignPlayerColor(playerID);
|
||||
// Entfernt das CreateGameMenu (inklusive Hintergrund)
|
||||
app.getGuiNode().detachAllChildren();
|
||||
int playerID = app.getNetworkSupport().getId(); // Retrieve the player ID
|
||||
assignPlayerColor(playerID); //set the Players Color
|
||||
|
||||
// Hintergrundbild laden und hinzufügen
|
||||
addBackgroundImage();
|
||||
app.getGuiNode().detachAllChildren(); // Entfernt das CreateGameMenu (inklusive Hintergrund)
|
||||
|
||||
addBackgroundImage();// Hintergrundbild laden und hinzufügen
|
||||
|
||||
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)); // Fixed size of the container
|
||||
menuContainer.setPreferredSize(new Vector3f(1000, 600, 0));
|
||||
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)); // Adjust container size
|
||||
horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0));
|
||||
horizontalContainer.setBackground(null);
|
||||
|
||||
Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold")));
|
||||
@ -105,12 +108,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)); // Add padding for the text inside the field
|
||||
playerInputField.setInsets(new Insets3f(5, 10, 5, 10));
|
||||
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
|
||||
spacer.setPreferredSize(new Vector3f(200, 200, 0));
|
||||
|
||||
// Figur Dropdown
|
||||
Container figureDropdownContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
|
||||
@ -159,9 +162,11 @@ 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
|
||||
@ -209,6 +214,36 @@ 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.
|
||||
*/
|
||||
@ -276,14 +311,6 @@ 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.
|
||||
*/
|
||||
|
@ -84,7 +84,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
* Set the name of the Player
|
||||
* @param name the new name
|
||||
*/
|
||||
void setName(String name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user