mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +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
|
* FoodFieldCard creates the popup for field information
|
||||||
*/
|
*/
|
||||||
public class FoodFieldCard extends Dialog {
|
public class FoodFieldCard extends Dialog {
|
||||||
|
/** Reference to the Monopoly application instance. */
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
|
|
||||||
|
/** Semi-transparent overlay background for the popup. */
|
||||||
private final Geometry overlayBackground;
|
private final Geometry overlayBackground;
|
||||||
|
|
||||||
|
/** Main container for the food field information. */
|
||||||
private final Container foodFieldContainer;
|
private final Container foodFieldContainer;
|
||||||
|
|
||||||
|
/** Background container providing a border for the popup. */
|
||||||
private final Container backgroundContainer;
|
private final Container backgroundContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a FoodFieldCard popup displaying details about a food field.
|
||||||
|
*
|
||||||
|
* @param app the Monopoly application instance
|
||||||
|
*/
|
||||||
public FoodFieldCard(MonopolyApp app) {
|
public FoodFieldCard(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
//Generate the corresponfing field
|
|
||||||
int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID();
|
int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID();
|
||||||
FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
|
FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
|
||||||
overlayBackground = createOverlayBackground();
|
overlayBackground = createOverlayBackground();
|
||||||
app.getGuiNode().attachChild(overlayBackground);
|
app.getGuiNode().attachChild(overlayBackground);
|
||||||
|
|
||||||
// Create the background container
|
|
||||||
backgroundContainer = new Container();
|
backgroundContainer = new Container();
|
||||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
||||||
attachChild(backgroundContainer);
|
attachChild(backgroundContainer);
|
||||||
|
|
||||||
// Hauptcontainer für die Gebäudekarte
|
|
||||||
foodFieldContainer = new Container();
|
foodFieldContainer = new Container();
|
||||||
foodFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f)));
|
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));
|
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")));
|
Label settingsTitle = foodFieldContainer.addChild(new Label(field.getName(), new ElementId("label-Bold")));
|
||||||
settingsTitle.setFontSize(48);
|
settingsTitle.setFontSize(48);
|
||||||
settingsTitle.setColor(ColorRGBA.White);
|
settingsTitle.setColor(ColorRGBA.White);
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
|
||||||
// Die Preise werden dynamisch dem BoardManager entnommen
|
|
||||||
Container propertyValuesContainer = foodFieldContainer.addChild(new Container());
|
Container propertyValuesContainer = foodFieldContainer.addChild(new Container());
|
||||||
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
|
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
|
||||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
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() {
|
private Geometry createOverlayBackground() {
|
||||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
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
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
@ -134,6 +139,9 @@ public class FoodFieldCard extends Dialog {
|
|||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the settings menu when the escape key is pressed.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void escape() {
|
public void escape() {
|
||||||
new SettingsMenu(app).open();
|
new SettingsMenu(app).open();
|
||||||
|
Loading…
Reference in New Issue
Block a user