mirror of
				https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
				synced 2025-10-31 07:41:52 +01:00 
			
		
		
		
	added documentation for LobbyMenu
This commit is contained in:
		| @@ -31,19 +31,47 @@ import pp.monopoly.notification.Sound; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * Represents the lobby menu in the Monopoly application. | ||||
|  * <p> | ||||
|  * 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. | ||||
|  * </p> | ||||
|  */ | ||||
| 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<String> selector, SelectionActionListener<String> listener) { | ||||
|         VersionedReference<Set<Integer>> 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 <T> the type of the selection | ||||
|      */ | ||||
|     @FunctionalInterface | ||||
|     private interface SelectionActionListener<T> { | ||||
|         /** | ||||
|          * Triggered when the selection changes. | ||||
|          * | ||||
|          * @param selection the new selection | ||||
|          */ | ||||
|         void onSelectionChanged(T selection); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user