diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java index 8e4be3a..7724bd9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java @@ -31,19 +31,47 @@ import pp.monopoly.notification.Sound; import java.util.Set; +/** + * Represents the lobby menu in the Monopoly application. + *

+ * Provides functionality for player configuration, including input for starting capital, + * player name, and figure selection, as well as options to ready up or exit the game. + *

+ */ public class LobbyMenu extends Dialog { + /** Reference to the Monopoly application instance. */ private final MonopolyApp app; + + /** Main container for the lobby menu UI. */ private final Container menuContainer; + + /** Background geometry for the menu. */ private Geometry background; + + /** Colored circle displayed between input fields and dropdown menus. */ private Geometry circle; + + /** Container for the lower-left section of the menu. */ private Container lowerLeftMenu; + + /** Container for the lower-right section of the menu. */ private Container lowerRightMenu; + /** Text field for entering the player's name. */ private TextField playerInputField; + + /** Text field for entering the starting capital. */ private TextField startingCapital = new TextField("15000"); + + /** Selected player figure. */ private String figure; + /** + * Constructs the lobby menu for player configuration. + * + * @param app the Monopoly application instance + */ public LobbyMenu(MonopolyApp app) { super(app.getDialogManager()); this.app = app; @@ -193,7 +221,7 @@ public class LobbyMenu extends Dialog { /** - * Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu. + * Adds a background image to the lobby menu. */ private void addBackgroundImage() { Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/lobby.png"); @@ -207,6 +235,11 @@ public class LobbyMenu extends Dialog { app.getGuiNode().attachChild(background); } + /** + * Creates a circle graphic element for the menu. + * + * @return the created circle geometry + */ private Geometry createCircle() { Sphere sphere = new Sphere(90,90,60.0f); @@ -220,6 +253,11 @@ public class LobbyMenu extends Dialog { return circleGeometry; } + /** + * Maps the player's ID to a corresponding color. + * + * @return the color associated with the player's ID + */ private ColorRGBA idToColor() { switch (app.getId()+1) { case 1: return PlayerColor.CYAN.getColor(); @@ -235,19 +273,25 @@ public class LobbyMenu extends Dialog { } /** - * Schaltet den "Bereit"-Status um. + * Toggles the player's ready state and sends the configuration to the server. */ private void toggleReady() { app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText()))); } + /** + * Opens the settings menu when the escape key is pressed. + */ @Override public void escape() { new SettingsMenu(app).open(); } /** - * Adds a custom action listener to the Selector. + * Adds a custom action listener to a dropdown selector. + * + * @param selector the selector to add the listener to + * @param listener the action to perform when a selection changes */ private void addSelectionActionListener(Selector selector, SelectionActionListener listener) { VersionedReference> selectionRef = selector.getSelectionModel().createReference(); @@ -282,7 +326,9 @@ public class LobbyMenu extends Dialog { } /** - * Callback for when the dropdown selection changes. + * Updates the selected figure based on the dropdown menu selection. + * + * @param selected the selected figure */ private void onDropdownSelectionChanged(String selected) { app.getGameLogic().playSound(Sound.BUTTON); @@ -311,10 +357,17 @@ public class LobbyMenu extends Dialog { } /** - * Functional interface for a selection action listener. + * Functional interface for handling selection changes in dropdown menus. + * + * @param the type of the selection */ @FunctionalInterface private interface SelectionActionListener { + /** + * Triggered when the selection changes. + * + * @param selection the new selection + */ void onSelectionChanged(T selection); } }