From 3bfa7ff69fad77efb7788e8dd0b82faf6857a6ec Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Mon, 2 Dec 2024 08:26:08 +0100 Subject: [PATCH] added documentation for FoodFieldCard --- .../client/gui/popups/FoodFieldCard.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java index 79a54a1..c84e967 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java @@ -22,42 +22,47 @@ import pp.monopoly.notification.Sound; * FoodFieldCard creates the popup for field information */ public class FoodFieldCard extends Dialog { + /** Reference to the Monopoly application instance. */ private final MonopolyApp app; + + /** Semi-transparent overlay background for the popup. */ private final Geometry overlayBackground; + + /** Main container for the food field information. */ private final Container foodFieldContainer; + + /** Background container providing a border for the popup. */ private final Container backgroundContainer; + /** + * Constructs a FoodFieldCard popup displaying details about a food field. + * + * @param app the Monopoly application instance + */ public FoodFieldCard(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - //Generate the corresponfing field int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); - // Halbtransparentes Overlay hinzufügen overlayBackground = createOverlayBackground(); app.getGuiNode().attachChild(overlayBackground); - // Create the background container backgroundContainer = new Container(); backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background attachChild(backgroundContainer); - // Hauptcontainer für die Gebäudekarte foodFieldContainer = new Container(); foodFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f))); - float padding = 10; // Passt den backgroundContainer an die Größe des foodFieldContainers an + float padding = 10; backgroundContainer.setPreferredSize(foodFieldContainer.getPreferredSize().addLocal(padding, padding, 0)); - // Titel, bestehend aus dynamischen Namen anhand der ID und der Schriftfarbe/größe Label settingsTitle = foodFieldContainer.addChild(new Label(field.getName(), new ElementId("label-Bold"))); settingsTitle.setFontSize(48); settingsTitle.setColor(ColorRGBA.White); - // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen Container propertyValuesContainer = foodFieldContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile @@ -108,9 +113,9 @@ public class FoodFieldCard extends Dialog { } /** - * Erstellt einen halbtransparenten Hintergrund für das Menü. + * Creates a semi-transparent background overlay for the popup. * - * @return Geometrie des Overlays + * @return the geometry of the overlay */ private Geometry createOverlayBackground() { Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); @@ -124,7 +129,7 @@ public class FoodFieldCard extends Dialog { } /** - * Schließt das Menü und entfernt die GUI-Elemente. + * Closes the popup and removes its associated GUI elements. */ @Override public void close() { @@ -134,6 +139,9 @@ public class FoodFieldCard extends Dialog { super.close(); } + /** + * Opens the settings menu when the escape key is pressed. + */ @Override public void escape() { new SettingsMenu(app).open();