mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 18:23:44 +01:00
added documentation for FoodFieldCard
This commit is contained in:
parent
160fff88ea
commit
3bfa7ff69f
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user