From ed27e0aaf11d616403f6f21bf1e67fccd9e1665d Mon Sep 17 00:00:00 2001
From: Johannes Schmelz
Date: Mon, 9 Dec 2024 23:57:45 +0100
Subject: [PATCH] popUp
---
.../main/java/pp/dialog/DialogManager.java | 42 ++++
.../src/main/java/pp/dialog/PopupDialog.java | 5 +
.../pp/monopoly/client/BoardAppState.java | 4 +
.../java/pp/monopoly/client/PopUpManager.java | 2 +-
.../pp/monopoly/client/gui/FigureControl.java | 26 ++-
.../java/pp/monopoly/client/gui/Toolbar.java | 3 +-
.../client/gui/popups/AcceptTrade.java | 181 ++++++++++--------
.../monopoly/client/gui/popups/Bankrupt.java | 162 +++++++++-------
.../gui/popups/BuildingPropertyCard.java | 126 +++++++-----
.../client/gui/popups/ConfirmTrade.java | 96 ++++++----
.../client/gui/popups/EventCardPopup.java | 151 ++++++++-------
.../client/gui/popups/FoodFieldCard.java | 143 +++++++-------
.../client/gui/popups/GateFieldCard.java | 86 +++++----
.../pp/monopoly/client/gui/popups/Gulag.java | 117 +++++------
.../monopoly/client/gui/popups/GulagInfo.java | 138 +++++++------
.../client/gui/popups/NoMoneyWarning.java | 155 ++++++++-------
.../client/gui/popups/ReceivedRent.java | 107 +++++------
.../client/gui/popups/RejectTrade.java | 162 +++++++++-------
.../pp/monopoly/client/gui/popups/Rent.java | 83 ++------
.../monopoly/model/fields/BoardManager.java | 2 +-
20 files changed, 990 insertions(+), 801 deletions(-)
create mode 100644 Projekte/jme-common/src/main/java/pp/dialog/PopupDialog.java
diff --git a/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java b/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java
index f84b6e7..ab4ea16 100644
--- a/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java
+++ b/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java
@@ -19,6 +19,8 @@ import java.util.Deque;
import static java.lang.Math.max;
+import java.lang.System.Logger;
+
/**
* Manages dialog boxes within the application, handling their display, positioning, and focus.
*/
@@ -28,11 +30,15 @@ public class DialogManager {
*/
private final SimpleApplication app;
+
+ private final static Logger LOGGER = System.getLogger(DialogManager.class.getName());
/**
* A stack to keep track of the dialogs.
*/
private final Deque
*/
-public class Gulag extends Dialog {
+public class Gulag extends Dialog implements PopupDialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
/** Semi-transparent overlay background for the popup. */
- private final Geometry overlayBackground;
+ private Geometry overlayBackground;
/** Main container for the Gulag warning message. */
- private final Container gulagContainer;
+ private Container gulagContainer;
/** Background container providing a border for the popup. */
- private final Container backgroundContainer;
+ private Container backgroundContainer;
/**
- * Constructs the Gulag popup, displaying a warning when a player lands on the "Wache" field.
+ * Constructs the Gulag popup.
*
* @param app the Monopoly application instance
*/
@@ -43,90 +45,97 @@ public class Gulag extends Dialog {
super(app.getDialogManager());
this.app = app;
+ // Initialize UI elements
+ createOverlayBackground();
+ createBackgroundContainer();
+ createGulagContainer();
+ }
- // Halbtransparentes Overlay hinzufügen
- overlayBackground = createOverlayBackground();
- app.getGuiNode().attachChild(overlayBackground);
+ /**
+ * Creates the semi-transparent overlay background for the popup.
+ */
+ private void createOverlayBackground() {
+ Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
+ overlayBackground = new Geometry("Overlay", quad);
+ Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
+ material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black
+ material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
+ overlayBackground.setMaterial(material);
+ overlayBackground.setLocalTranslation(0, 0, 0);
+ }
- // Create the background container
+ /**
+ * Creates the background container providing a border for the popup.
+ */
+ private void createBackgroundContainer() {
backgroundContainer = new Container();
- backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
- app.getGuiNode().attachChild(backgroundContainer);
+ backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
+ }
-
-
- // Hauptcontainer für die Warnung
+ /**
+ * Creates the main container for the Gulag warning message.
+ */
+ private void createGulagContainer() {
gulagContainer = new Container();
gulagContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
- gulagContainer.setPreferredSize(new Vector3f(550,250,10));
+ gulagContainer.setPreferredSize(new Vector3f(550, 250, 10));
- float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
- backgroundContainer.setPreferredSize(gulagContainer.getPreferredSize().addLocal(padding, padding, 0));
+ // Title
+ Label title = gulagContainer.addChild(new Label("Du kommst ins Gulag!", new ElementId("warning-title")));
+ title.setFontSize(48);
+ title.setColor(ColorRGBA.Black);
- // Titel
- Label gateFieldTitle = gulagContainer.addChild(new Label("Du kommst ins Gulag!", new ElementId("warning-title")));
- gateFieldTitle.setFontSize(48);
- gateFieldTitle.setColor(ColorRGBA.Black);
-
- // Beenden-Button
- Button quitButton = gulagContainer.addChild(new Button("Jawohl Gulag", new ElementId("button")));
- quitButton.setFontSize(32);
- quitButton.addClickCommands(source -> ifTopDialog(() -> {
+ // Confirmation Button
+ Button confirmButton = gulagContainer.addChild(new Button("Jawohl Gulag", new ElementId("button")));
+ confirmButton.setFontSize(32);
+ confirmButton.addClickCommands(source -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
+ }
+ /**
+ * Displays the popup by attaching its elements to the GUI.
+ */
+ @Override
+ public void show() {
+ float padding = 10;
- // Zentriere das Popup
+ // Adjust and position the containers
+ backgroundContainer.setPreferredSize(gulagContainer.getPreferredSize().addLocal(padding, padding, 0));
gulagContainer.setLocalTranslation(
(app.getCamera().getWidth() - gulagContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + gulagContainer.getPreferredSize().y) / 2,
8
);
-
- // Zentriere das Popup
backgroundContainer.setLocalTranslation(
- (app.getCamera().getWidth() - gulagContainer.getPreferredSize().x - padding) / 2,
- (app.getCamera().getHeight() + gulagContainer.getPreferredSize().y+ padding) / 2,
- 7
+ (app.getCamera().getWidth() - gulagContainer.getPreferredSize().x - padding) / 2,
+ (app.getCamera().getHeight() + gulagContainer.getPreferredSize().y + padding) / 2,
+ 7
);
+ // Attach components to the GUI
+ app.getGuiNode().attachChild(overlayBackground);
+ app.getGuiNode().attachChild(backgroundContainer);
app.getGuiNode().attachChild(gulagContainer);
}
- /**
- * Creates a semi-transparent overlay background for the popup.
- *
- * @return the geometry of the overlay
- */
- private Geometry createOverlayBackground() {
- Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
- Geometry overlay = new Geometry("Overlay", quad);
- Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
- material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
- material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
- overlay.setMaterial(material);
- overlay.setLocalTranslation(0, 0, 0);
- return overlay;
- }
-
/**
* Closes the popup and removes its associated GUI elements.
*/
@Override
public void close() {
- app.getGuiNode().detachChild(gulagContainer); // Entferne das Menü
- app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
- app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
+ app.getGuiNode().detachChild(overlayBackground);
+ app.getGuiNode().detachChild(gulagContainer);
+ app.getGuiNode().detachChild(backgroundContainer);
super.close();
}
/**
- * Handles the escape action to close the popup.
+ * Handles the escape action by closing the popup.
*/
@Override
public void escape() {
close();
}
-
-}
\ No newline at end of file
+}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java
index 83396fd..b00e84c 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java
@@ -7,112 +7,138 @@ import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
+import pp.dialog.PopupDialog;
import pp.monopoly.client.MonopolyApp;
-import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.message.client.NotificationAnswer;
import pp.monopoly.notification.Sound;
/**
* GulagInfo is a popup that provides options for a player who is stuck in the "Gulag" (jail) field.
- *
* This dialog offers multiple actions, including paying a bribe, using a "Get Out of Jail" card, or waiting.
- *
*/
-public class GulagInfo extends Dialog {
+public class GulagInfo extends Dialog implements PopupDialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
/** Main container for the Gulag information dialog. */
- private final Container gulagInfoContainer;
+ private Container gulagInfoContainer;
/** Background container providing a styled border around the dialog. */
- private final Container backgroundContainer;
+ private Container backgroundContainer;
/**
* Constructs a GulagInfo popup that provides the player with options for getting out of the "Gulag" field.
*
- * @param app the Monopoly application instance
+ * @param app the Monopoly application instance
* @param trys the number of failed attempts to roll doubles for release
*/
public GulagInfo(MonopolyApp app, int trys) {
super(app.getDialogManager());
this.app = app;
- // Create the background container
+ // Initialize UI components
+ createBackgroundContainer();
+ createGulagInfoContainer(trys);
+ }
+
+ /**
+ * Creates the background container providing a border for the dialog.
+ */
+ private void createBackgroundContainer() {
backgroundContainer = new Container();
- backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
- attachChild(backgroundContainer);
+ backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
+ }
- // Hauptcontainer für das Bestätigungspopup
+ /**
+ * Creates the main container for the Gulag information dialog.
+ *
+ * @param trys the number of failed attempts to roll doubles for release
+ */
+ private void createGulagInfoContainer(int trys) {
gulagInfoContainer = new Container();
+ gulagInfoContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
- float padding = 10; // Passt den backgroundContainer an die Größe des confirmTradeContainer an
- backgroundContainer.setPreferredSize(gulagInfoContainer.getPreferredSize().addLocal(padding, padding, 0));
-
- // Titel
- Label title = gulagInfoContainer.addChild(new Label( "Gulag", new ElementId("warning-title")));
+ // Title
+ Label title = gulagInfoContainer.addChild(new Label("Gulag", new ElementId("warning-title")));
title.setFontSize(48);
title.setColor(ColorRGBA.Black);
- // Text, der auf der Karte steht
- // Die Werte werden dem Handel entnommen (Iwas auch immer da dann ist)
- Container propertyValuesContainer = gulagInfoContainer.addChild(new Container());
- propertyValuesContainer.addChild(new Label("„Du sitzt im Gefänginis und kommst nicht raus ...", new ElementId("label-Text")));
- propertyValuesContainer.addChild(new Label("Es sei denn, du ...", new ElementId("label-Text")));// Leerzeile
- propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
- propertyValuesContainer.addChild(new Label("- bestichst die Wache mit 500 EUR", new ElementId("label-Text")));
- propertyValuesContainer.addChild(new Label("- löst eine Gulag-Frei-Karte ein", new ElementId("label-Text")));
- propertyValuesContainer.addChild(new Label("- wartest 3 Runden und bezahlst dann", new ElementId("label-Text")));// Leerzeile
- propertyValuesContainer.addChild(new Label("- oder du würfelst einen Pasch", new ElementId("label-Text")));
- propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
+ // Text Description
+ Container textContainer = gulagInfoContainer.addChild(new Container());
+ textContainer.addChild(new Label("„Du sitzt im Gefängnis und kommst nicht raus ...", new ElementId("label-Text")));
+ textContainer.addChild(new Label("Es sei denn, du ...", new ElementId("label-Text")));
+ textContainer.addChild(new Label("- bestichst die Wache mit 500 EUR", new ElementId("label-Text")));
+ textContainer.addChild(new Label("- löst eine Gulag-Frei-Karte ein", new ElementId("label-Text")));
+ textContainer.addChild(new Label("- wartest 3 Runden und bezahlst dann", new ElementId("label-Text")));
+ textContainer.addChild(new Label("- oder du würfelst einen Pasch", new ElementId("label-Text")));
+ textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
+ // Action Buttons
+ addActionButtons(trys);
+ }
- // Bezahlen-Button
+ /**
+ * Adds action buttons to the dialog.
+ *
+ * @param trys the number of failed attempts to roll doubles for release
+ */
+ private void addActionButtons(int trys) {
+ // Bribe Button
Button payButton = gulagInfoContainer.addChild(new Button("Bestechungsgeld bezahlen", new ElementId("button")));
payButton.setFontSize(32);
- payButton.addClickCommands(s -> ifTopDialog( () -> {
+ payButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new NotificationAnswer("PayJail"));
close();
}));
- // Ereigniskarte-Button
+
+ // Use Jail-Free Card Button
Button eventCardButton = gulagInfoContainer.addChild(new Button("Ereigniskarte nutzen", new ElementId("button")));
eventCardButton.setFontSize(32);
- eventCardButton.addClickCommands(s -> ifTopDialog( () -> {
+ eventCardButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new NotificationAnswer("UseJailCard"));
close();
}));
- // Schließen-Button
+
+ // Close Button
Button closeButton = gulagInfoContainer.addChild(new Button("Schließen", new ElementId("button")));
closeButton.setFontSize(32);
- closeButton.addClickCommands(s -> ifTopDialog(() -> {
- app.getGameLogic().playSound(Sound.BUTTON);
- close();
- }));
+ closeButton.addClickCommands(s -> ifTopDialog(this::close));
- // Zentriere das Menü
+ // Disable options based on conditions
+ if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getNumJailCard() == 0) {
+ eventCardButton.setEnabled(false);
+ }
+ if (trys == 3) {
+ closeButton.setEnabled(false);
+ }
+ }
+
+ /**
+ * Displays the popup by attaching its elements to the GUI.
+ */
+ @Override
+ public void show() {
+ float padding = 10;
+
+ // Adjust the background size
+ backgroundContainer.setPreferredSize(gulagInfoContainer.getPreferredSize().addLocal(padding, padding, 0));
+
+ // Center the dialog and background
gulagInfoContainer.setLocalTranslation(
(app.getCamera().getWidth() - gulagInfoContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + gulagInfoContainer.getPreferredSize().y) / 2,
8
);
-
- // Zentriere das Menü
backgroundContainer.setLocalTranslation(
- (app.getCamera().getWidth() - gulagInfoContainer.getPreferredSize().x - padding) / 2,
- (app.getCamera().getHeight() + gulagInfoContainer.getPreferredSize().y+ padding) / 2,
- 7
+ (app.getCamera().getWidth() - gulagInfoContainer.getPreferredSize().x - padding) / 2,
+ (app.getCamera().getHeight() + gulagInfoContainer.getPreferredSize().y + padding) / 2,
+ 7
);
- if(app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getNumJailCard() == 0) {
- eventCardButton.setEnabled(false);
- }
-
- if(trys == 3) {
- closeButton.setEnabled(false);
- }
-
+ // Attach containers to the GUI
+ app.getGuiNode().attachChild(backgroundContainer);
app.getGuiNode().attachChild(gulagInfoContainer);
}
@@ -121,16 +147,8 @@ public class GulagInfo extends Dialog {
*/
@Override
public void close() {
- app.getGuiNode().detachChild(gulagInfoContainer); // Entferne das Menü
- app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
+ app.getGuiNode().detachChild(gulagInfoContainer); // Remove dialog
+ app.getGuiNode().detachChild(backgroundContainer); // Remove background
super.close();
}
-
- /**
- * Handles the escape action to close the GulagInfo dialog.
- */
- @Override
- public void escape() {
- new SettingsMenu(app).open();
- }
}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java
index eb28a0d..1c1547c 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java
@@ -12,19 +12,14 @@ import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
+import pp.dialog.PopupDialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
/**
- * NoMoneyWarning is a warning popup that appears when a player tries to perform
- * an action they cannot afford due to insufficient funds, such as attempting
- * to purchase a property or building.
- *
- * This dialog notifies the player of their lack of funds and provides a single
- * confirmation button to close the dialog.
- *
+ * NoMoneyWarning is a warning popup that informs the player they lack sufficient funds to proceed with an action.
*/
-public class NoMoneyWarning extends Dialog {
+public class NoMoneyWarning extends Dialog implements PopupDialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
@@ -46,66 +41,15 @@ public class NoMoneyWarning extends Dialog {
super(app.getDialogManager());
this.app = app;
-
- // Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground();
- app.getGuiNode().attachChild(overlayBackground);
+ backgroundContainer = createBackgroundContainer();
+ noMoneyWarningContainer = createNoMoneyWarningContainer();
- // Create the background container
- backgroundContainer = new Container();
- backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
- app.getGuiNode().attachChild(backgroundContainer);
-
-
- // Hauptcontainer für die Warnung
- noMoneyWarningContainer = new Container();
- noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
- noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10));
-
- float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
- backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
-
- // Titel
- Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Na, schon wieder Pleite?", new ElementId("warning-title")));
- gateFieldTitle.setFontSize(38);
- gateFieldTitle.setColor(ColorRGBA.Black);
-
- // Text, der im Popup steht
- Container textContainer = noMoneyWarningContainer.addChild(new Container());
- textContainer.addChild(new Label("Du hast nicht genug Geld, um dieses Gebäude zu kaufen", new ElementId("label-Text")));
- textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
-
- // Passt den textContainer an die Größe des bankruptContainers an
- textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0));
-
- // Bestätigen-Button
- Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
- quitButton.setFontSize(32);
- quitButton.addClickCommands(source -> ifTopDialog(() -> {
- app.getGameLogic().playSound(Sound.BUTTON);
- close();
- }));
-
-
- // Zentriere das Popup
- noMoneyWarningContainer.setLocalTranslation(
- (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
- (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
- 8
- );
-
- // Zentriere das Popup
- backgroundContainer.setLocalTranslation(
- (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2,
- (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2,
- 7
- );
-
- app.getGuiNode().attachChild(noMoneyWarningContainer);
+ adjustPaddingAndCenter();
}
/**
- * Creates a semi-transparent overlay background for the dialog.
+ * Creates the semi-transparent overlay background.
*
* @return The geometry representing the overlay background.
*/
@@ -113,7 +57,7 @@ public class NoMoneyWarning extends Dialog {
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry overlay = new Geometry("Overlay", quad);
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
- material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
+ material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
overlay.setMaterial(material);
overlay.setLocalTranslation(0, 0, 0);
@@ -121,13 +65,86 @@ public class NoMoneyWarning extends Dialog {
}
/**
- * Closes the menu and removes the GUI elements.
+ * Creates the background container for the dialog.
+ *
+ * @return A styled container for the dialog background.
+ */
+ private Container createBackgroundContainer() {
+ Container container = new Container();
+ container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray
+ return container;
+ }
+
+ /**
+ * Creates the main container for the NoMoneyWarning dialog UI.
+ *
+ * @return The container for the dialog content.
+ */
+ private Container createNoMoneyWarningContainer() {
+ Container container = new Container();
+ container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
+ container.setPreferredSize(new Vector3f(550, 250, 10));
+
+ // Title
+ Label title = container.addChild(new Label("Na, schon wieder Pleite?", new ElementId("warning-title")));
+ title.setFontSize(38);
+ title.setColor(ColorRGBA.Black);
+
+ // Warning message
+ Container textContainer = container.addChild(new Container());
+ textContainer.addChild(new Label("Du hast nicht genug Geld, um dieses Gebäude zu kaufen", new ElementId("label-Text")));
+ textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
+ textContainer.setPreferredSize(container.getPreferredSize().addLocal(-250, -200, 0));
+
+ // Confirmation button
+ Button confirmButton = container.addChild(new Button("Bestätigen", new ElementId("button")));
+ confirmButton.setFontSize(32);
+ confirmButton.addClickCommands(source -> ifTopDialog(() -> {
+ app.getGameLogic().playSound(Sound.BUTTON);
+ close();
+ }));
+
+ return container;
+ }
+
+ /**
+ * Adjusts the padding and centers the dialog on the screen.
+ */
+ private void adjustPaddingAndCenter() {
+ float padding = 10;
+ backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
+
+ noMoneyWarningContainer.setLocalTranslation(
+ (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
+ (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
+ 8
+ );
+
+ backgroundContainer.setLocalTranslation(
+ (app.getCamera().getWidth() - backgroundContainer.getPreferredSize().x) / 2,
+ (app.getCamera().getHeight() + backgroundContainer.getPreferredSize().y) / 2,
+ 7
+ );
+ }
+
+ /**
+ * Displays the dialog by attaching its components to the GUI node.
+ */
+ @Override
+ public void show() {
+ app.getGuiNode().attachChild(overlayBackground);
+ app.getGuiNode().attachChild(backgroundContainer);
+ app.getGuiNode().attachChild(noMoneyWarningContainer);
+ }
+
+ /**
+ * Closes the dialog and removes its components from the GUI node.
*/
@Override
public void close() {
- app.getGuiNode().detachChild(noMoneyWarningContainer); // Entferne das Menü
- app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
- app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
+ app.getGuiNode().detachChild(overlayBackground);
+ app.getGuiNode().detachChild(backgroundContainer);
+ app.getGuiNode().detachChild(noMoneyWarningContainer);
super.close();
}
@@ -138,4 +155,4 @@ public class NoMoneyWarning extends Dialog {
public void escape() {
close();
}
-}
\ No newline at end of file
+}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java
index bd26a29..5553c8c 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java
@@ -12,115 +12,95 @@ import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
+import pp.dialog.PopupDialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
/**
- * Rent is a popup that is triggered when a player lands on a property owned by another player
- * and needs to pay rent in the Monopoly application.
- *
- * Displays the rent amount and the recipient player's name, with an option to confirm the payment.
- *
+ * ReceivedRent is a popup that informs a player about rent they have received.
*/
-public class ReceivedRent extends Dialog {
+public class ReceivedRent extends Dialog implements PopupDialog {
+
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
/** Semi-transparent overlay background for the popup. */
- private final Geometry overlayBackground;
+ private Geometry overlayBackground;
/** Main container for the rent information and action. */
- private final Container rentContainer;
+ private Container rentContainer;
/** Background container providing a border for the rent popup. */
- private final Container backgroundContainer;
+ private Container backgroundContainer;
/**
- * Constructs the Rent popup displaying the rent amount and recipient player.
+ * Constructs the ReceivedRent popup displaying the rent amount and payer.
*
* @param app the Monopoly application instance
- * @param playerName the name of the player to whom the rent is owed
- * @param amount the amount of rent to be paid
+ * @param playerName the name of the player who paid the rent
+ * @param amount the amount of rent received
*/
public ReceivedRent(MonopolyApp app, String playerName, int amount) {
super(app.getDialogManager());
this.app = app;
- // Create the overlay
- overlayBackground = createOverlayBackground();
- app.getGuiNode().attachChild(overlayBackground);
-
- // Create and position the background container
- backgroundContainer = createBackgroundContainer();
- app.getGuiNode().attachChild(backgroundContainer);
-
- // Create and position the rent container
- rentContainer = createRentContainer(playerName, amount);
- app.getGuiNode().attachChild(rentContainer);
-
- centerContainers();
+ // Initialize GUI elements
+ createOverlayBackground();
+ createBackgroundContainer();
+ createRentContainer(playerName, amount);
}
/**
* Creates a semi-transparent overlay background.
- *
- * @return the overlay geometry
*/
- private Geometry createOverlayBackground() {
+ private void createOverlayBackground() {
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
- Geometry overlay = new Geometry("Overlay", quad);
+ overlayBackground = new Geometry("Overlay", quad);
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
- overlay.setMaterial(material);
- overlay.setLocalTranslation(0, 0, 0);
- return overlay;
+ overlayBackground.setMaterial(material);
+ overlayBackground.setLocalTranslation(0, 0, 0);
}
/**
* Creates the background container with styling.
- *
- * @return the styled background container
*/
- private Container createBackgroundContainer() {
- Container container = new Container();
- container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
- return container;
+ private void createBackgroundContainer() {
+ backgroundContainer = new Container();
+ backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
}
/**
* Creates the main rent container with title, text, and button.
*
- * @param playerName the name of the player to whom the rent is owed
+ * @param playerName the name of the player who paid the rent
* @param amount the rent amount
- * @return the rent container
*/
- private Container createRentContainer(String playerName, int amount) {
- Container container = new Container();
- container.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
- container.setPreferredSize(new Vector3f(550, 250, 10));
+ private void createRentContainer(String playerName, int amount) {
+ rentContainer = new Container();
+ rentContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
+ rentContainer.setPreferredSize(new Vector3f(550, 250, 10));
// Title
- Label title = container.addChild(new Label("Miete!", new ElementId("warning-title")));
+ Label title = rentContainer.addChild(new Label("Miete!", new ElementId("warning-title")));
title.setFontSize(48);
title.setColor(ColorRGBA.Black);
// Rent message
- Container textContainer = container.addChild(new Container());
- textContainer.addChild(new Label(playerName+ " zahlt dir " + amount + " EUR Miete",
+ Container textContainer = rentContainer.addChild(new Container());
+ textContainer.addChild(new Label(playerName + " zahlt dir " + amount + " EUR Miete",
new ElementId("label-Text")));
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
- textContainer.setPreferredSize(container.getPreferredSize().addLocal(-250, -200, 0));
+ textContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(-250, -200, 0));
- // Payment button
- Button payButton = container.addChild(new Button("Bestätigen", new ElementId("button")));
- payButton.setFontSize(32);
- payButton.addClickCommands(s -> ifTopDialog( () -> {
- app.getGameLogic().playSound(Sound.BUTTON);
- close();
+ // Confirmation button
+ Button confirmButton = rentContainer.addChild(new Button("Bestätigen", new ElementId("button")));
+ confirmButton.setFontSize(32);
+ confirmButton.addClickCommands(s -> ifTopDialog(() -> {
+ app.getGameLogic().playSound(Sound.BUTTON);
+ close();
}));
-
- return container;
}
/**
@@ -145,14 +125,25 @@ public class ReceivedRent extends Dialog {
);
}
+ /**
+ * Displays the popup by attaching it to the GUI through the DialogManager.
+ */
+ @Override
+ public void show() {
+ app.getGuiNode().attachChild(overlayBackground);
+ app.getGuiNode().attachChild(backgroundContainer);
+ app.getGuiNode().attachChild(rentContainer);
+ centerContainers();
+ }
+
/**
* Closes the popup and removes GUI elements.
*/
@Override
public void close() {
- app.getGuiNode().detachChild(rentContainer);
- app.getGuiNode().detachChild(backgroundContainer);
app.getGuiNode().detachChild(overlayBackground);
+ app.getGuiNode().detachChild(backgroundContainer);
+ app.getGuiNode().detachChild(rentContainer);
super.close();
}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java
index fc98bf6..f38f9dc 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java
@@ -12,19 +12,16 @@ import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
+import pp.dialog.PopupDialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.message.server.TradeReply;
import pp.monopoly.notification.Sound;
/**
- * RejectTrade is a popup that appears when a trade proposal is rejected by another player
- * in the Monopoly application.
- *
- * Displays a message indicating that the proposed trade has been declined, along with
- * details of the involved players and provides an option to close the popup.
- *
+ * RejectTrade is a popup that appears when a trade proposal is rejected by another player.
+ * Displays a message indicating the rejection and provides an option to close the popup.
*/
-public class RejectTrade extends Dialog {
+public class RejectTrade extends Dialog implements PopupDialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
@@ -32,12 +29,11 @@ public class RejectTrade extends Dialog {
private final Geometry overlayBackground;
/** Main container for the rejection message content. */
- private final Container noMoneyWarningContainer;
+ private final Container rejectTradeContainer;
/** Background container providing a border for the popup. */
private final Container backgroundContainer;
-
/**
* Constructs the RejectTrade popup displaying the rejection of a trade proposal.
*
@@ -48,68 +44,15 @@ public class RejectTrade extends Dialog {
super(app.getDialogManager());
this.app = app;
-
- // Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground();
- app.getGuiNode().attachChild(overlayBackground);
+ backgroundContainer = createBackgroundContainer();
+ rejectTradeContainer = createRejectTradeContainer(msg);
- // Create the background container
- backgroundContainer = new Container();
- backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
- app.getGuiNode().attachChild(backgroundContainer);
-
-
- // Hauptcontainer für die Warnung
- noMoneyWarningContainer = new Container();
- noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
- noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10));
-
- float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
- backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
-
- // Titel
- Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Handel abgelehnt!", new ElementId("warning-title")));
- gateFieldTitle.setFontSize(48);
- gateFieldTitle.setColor(ColorRGBA.Black);
-
- // Text, der im Popup steht
- Container textContainer = noMoneyWarningContainer.addChild(new Container());
- textContainer.addChild(new Label("Du hast Spieler"+ " " + msg.getTradeHandler().getReceiver().getName() + " " + "einen Handel vorgeschlagen", new ElementId("label-Text")));
- textContainer.addChild(new Label("", new ElementId("label-Text")));
- textContainer.addChild(new Label("Der Handel wurde abgelehnt", new ElementId("label-Text")));
- textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
-
- // Passt den textContainer an die Größe des bankruptContainers an
- textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0));
-
- // Beenden-Button
- Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
- quitButton.setFontSize(32);
- quitButton.addClickCommands(source -> ifTopDialog(() -> {
- app.getGameLogic().playSound(Sound.BUTTON);
- close();
- }));
-
-
- // Zentriere das Popup
- noMoneyWarningContainer.setLocalTranslation(
- (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
- (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
- 8
- );
-
- // Zentriere das Popup
- backgroundContainer.setLocalTranslation(
- (app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2,
- (app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2,
- 7
- );
-
- app.getGuiNode().attachChild(noMoneyWarningContainer);
+ adjustPaddingAndCenter();
}
/**
- * Creates a semi-transparent background overlay for the popup.
+ * Creates the semi-transparent background overlay for the popup.
*
* @return the geometry of the overlay
*/
@@ -117,21 +60,98 @@ public class RejectTrade extends Dialog {
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry overlay = new Geometry("Overlay", quad);
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
- material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
+ material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
overlay.setMaterial(material);
overlay.setLocalTranslation(0, 0, 0);
return overlay;
}
+ /**
+ * Creates the background container for the dialog.
+ *
+ * @return A styled container for the dialog background.
+ */
+ private Container createBackgroundContainer() {
+ Container container = new Container();
+ container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
+ return container;
+ }
+
+ /**
+ * Creates the main container for the RejectTrade dialog UI.
+ *
+ * @param msg the trade reply message containing details about the rejected trade
+ * @return The container for the rejection message and action button
+ */
+ private Container createRejectTradeContainer(TradeReply msg) {
+ Container container = new Container();
+ container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
+ container.setPreferredSize(new Vector3f(550, 250, 10));
+
+ // Title
+ Label title = container.addChild(new Label("Handel abgelehnt!", new ElementId("warning-title")));
+ title.setFontSize(48);
+ title.setColor(ColorRGBA.Black);
+
+ // Rejection message
+ Container textContainer = container.addChild(new Container());
+ textContainer.addChild(new Label("Du hast Spieler " + msg.getTradeHandler().getReceiver().getName()
+ + " einen Handel vorgeschlagen.", new ElementId("label-Text")));
+ textContainer.addChild(new Label("", new ElementId("label-Text")));
+ textContainer.addChild(new Label("Der Handel wurde abgelehnt.", new ElementId("label-Text")));
+ textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
+ textContainer.setPreferredSize(container.getPreferredSize().addLocal(-250, -200, 0));
+
+ // Confirmation button
+ Button confirmButton = container.addChild(new Button("Bestätigen", new ElementId("button")));
+ confirmButton.setFontSize(32);
+ confirmButton.addClickCommands(source -> ifTopDialog(() -> {
+ app.getGameLogic().playSound(Sound.BUTTON);
+ close();
+ }));
+
+ return container;
+ }
+
+ /**
+ * Adjusts the padding and centers the dialog on the screen.
+ */
+ private void adjustPaddingAndCenter() {
+ float padding = 10;
+ backgroundContainer.setPreferredSize(rejectTradeContainer.getPreferredSize().addLocal(padding, padding, 0));
+
+ rejectTradeContainer.setLocalTranslation(
+ (app.getCamera().getWidth() - rejectTradeContainer.getPreferredSize().x) / 2,
+ (app.getCamera().getHeight() + rejectTradeContainer.getPreferredSize().y) / 2,
+ 8
+ );
+
+ backgroundContainer.setLocalTranslation(
+ (app.getCamera().getWidth() - backgroundContainer.getPreferredSize().x) / 2,
+ (app.getCamera().getHeight() + backgroundContainer.getPreferredSize().y) / 2,
+ 7
+ );
+ }
+
+ /**
+ * Displays the popup by attaching its elements to the GUI node.
+ */
+ @Override
+ public void show() {
+ app.getGuiNode().attachChild(overlayBackground);
+ app.getGuiNode().attachChild(backgroundContainer);
+ app.getGuiNode().attachChild(rejectTradeContainer);
+ }
+
/**
* Closes the menu and removes the GUI elements.
*/
@Override
public void close() {
- app.getGuiNode().detachChild(noMoneyWarningContainer); // Entferne das Menü
- app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
- app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
+ app.getGuiNode().detachChild(overlayBackground);
+ app.getGuiNode().detachChild(backgroundContainer);
+ app.getGuiNode().detachChild(rejectTradeContainer);
super.close();
}
@@ -142,4 +162,4 @@ public class RejectTrade extends Dialog {
public void escape() {
close();
}
-}
\ No newline at end of file
+}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java
index ce77774..e559f96 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java
@@ -12,6 +12,7 @@ import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
+import pp.dialog.PopupDialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
@@ -22,122 +23,77 @@ import pp.monopoly.notification.Sound;
* Displays the rent amount and the recipient player's name, with an option to confirm the payment.
*
*/
-public class Rent extends Dialog {
- /** Reference to the Monopoly application instance. */
+public class Rent extends Dialog implements PopupDialog {
private final MonopolyApp app;
- /** Semi-transparent overlay background for the popup. */
private final Geometry overlayBackground;
-
- /** Main container for the rent information and action. */
private final Container rentContainer;
-
- /** Background container providing a border for the rent popup. */
private final Container backgroundContainer;
- /**
- * Constructs the Rent popup displaying the rent amount and recipient player.
- *
- * @param app the Monopoly application instance
- * @param playerName the name of the player to whom the rent is owed
- * @param amount the amount of rent to be paid
- */
public Rent(MonopolyApp app, String playerName, int amount) {
super(app.getDialogManager());
this.app = app;
- // Create the overlay
+ // Create the overlay and containers
overlayBackground = createOverlayBackground();
- app.getGuiNode().attachChild(overlayBackground);
-
- // Create and position the background container
backgroundContainer = createBackgroundContainer();
- app.getGuiNode().attachChild(backgroundContainer);
-
- // Create and position the rent container
rentContainer = createRentContainer(playerName, amount);
- app.getGuiNode().attachChild(rentContainer);
+ // Center containers (positioning logic only, no GUI attachment)
centerContainers();
}
- /**
- * Creates a semi-transparent overlay background.
- *
- * @return the overlay geometry
- */
private Geometry createOverlayBackground() {
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry overlay = new Geometry("Overlay", quad);
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
- material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Semi-transparent black
+ material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f));
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
overlay.setMaterial(material);
overlay.setLocalTranslation(0, 0, 0);
return overlay;
}
- /**
- * Creates the background container with styling.
- *
- * @return the styled background container
- */
private Container createBackgroundContainer() {
Container container = new Container();
- container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
+ container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
return container;
}
- /**
- * Creates the main rent container with title, text, and button.
- *
- * @param playerName the name of the player to whom the rent is owed
- * @param amount the rent amount
- * @return the rent container
- */
private Container createRentContainer(String playerName, int amount) {
Container container = new Container();
container.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
container.setPreferredSize(new Vector3f(550, 250, 10));
- // Title
Label title = container.addChild(new Label("Miete!", new ElementId("warning-title")));
title.setFontSize(48);
title.setColor(ColorRGBA.Black);
- // Rent message
Container textContainer = container.addChild(new Container());
- textContainer.addChild(new Label("Du musst " + amount + " EUR Miete an " + playerName + " zahlen",
+ textContainer.addChild(new Label("Du musst " + amount + " EUR Miete an " + playerName + " zahlen",
new ElementId("label-Text")));
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
textContainer.setPreferredSize(container.getPreferredSize().addLocal(-250, -200, 0));
- // Payment button
Button payButton = container.addChild(new Button("Überweisen", new ElementId("button")));
payButton.setFontSize(32);
- payButton.addClickCommands(s -> ifTopDialog( () -> {
- app.getGameLogic().playSound(Sound.BUTTON);
- close();
-
+ payButton.addClickCommands(s -> ifTopDialog(() -> {
+ app.getGameLogic().playSound(Sound.BUTTON);
+ close();
}));
return container;
}
- /**
- * Centers the rent and background containers on the screen.
- */
private void centerContainers() {
float padding = 10;
- // Center rent container
rentContainer.setLocalTranslation(
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2,
8
);
- // Center background container with padding
backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0));
backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - backgroundContainer.getPreferredSize().x) / 2,
@@ -146,22 +102,25 @@ public class Rent extends Dialog {
);
}
- /**
- * Closes the popup and removes GUI elements.
- */
+ @Override
+ public void show() {
+ // Attach components to GUI only when the dialog is displayed via DialogManager
+ app.getGuiNode().attachChild(overlayBackground);
+ app.getGuiNode().attachChild(backgroundContainer);
+ app.getGuiNode().attachChild(rentContainer);
+ }
+
@Override
public void close() {
- app.getGuiNode().detachChild(rentContainer);
- app.getGuiNode().detachChild(backgroundContainer);
app.getGuiNode().detachChild(overlayBackground);
+ app.getGuiNode().detachChild(backgroundContainer);
+ app.getGuiNode().detachChild(rentContainer);
super.close();
}
- /**
- * Handles the escape action to close the dialog.
- */
@Override
public void escape() {
close();
}
}
+
diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java
index 0caaa67..b50cfdd 100644
--- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java
+++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java
@@ -54,7 +54,7 @@ public class BoardManager {
fields.add(new EventField("Üvas", 22));
fields.add(new BuildingProperty("StudFBer B", 23, 2200, 180, 1500, FieldColor.RED));
fields.add(new BuildingProperty("StudFBer A", 24, 2400, 200, 1500, FieldColor.RED));
- fields.add(new GateField("Nordtor", 25));
+ fields.add(new GateField("Spießtor", 25));
fields.add(new BuildingProperty("Cascada", 26, 2600, 220, 1500, FieldColor.YELLOW));
fields.add(new BuildingProperty("Fakultätsgebäude", 27, 2600, 220, 1500, FieldColor.YELLOW));
fields.add(new FoodField("Truppenküche", 28));