From f4cddbc87fac01ce0aac9a2cd388da7df6d0ee43 Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Fri, 29 Nov 2024 06:20:23 +0100 Subject: [PATCH 1/9] Bankrott-Warnung und Timeout-Warning kommentiert und richtig benannt --- .../monopoly/client/gui/popups/Bankrupt.java | 27 +++++++++---------- .../monopoly/client/gui/popups/TimeOut.java | 20 +++++++------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 28f1b24..5ad93d1 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -15,7 +15,7 @@ import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; /** - * Bankrupt ist ein Overlay-Menü, welches aufgerufen werden kann, wenn man mit einem negativen Kontostand den Zug beenden möchte. // TODO welche menü-Klasse + * Bankrupt is a Warning-Popup, which appears, if the balance is negative at the end of a player´s turn // TODO welche menü-Klasse */ public class Bankrupt extends Dialog { private final MonopolyApp app; @@ -40,26 +40,26 @@ public class Bankrupt extends Dialog { app.getGuiNode().attachChild(backgroundContainer); - // Hauptcontainer für die Gebäudekarte + // Hauptcontainer für die Warnung bankruptContainer = new Container(); bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); bankruptContainer.setPreferredSize(new Vector3f(550,250,10)); - float padding = 10; // Padding around the settingsContainer for the background + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - // Die Namen werden dynamisch dem BoardManager entnommen Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); - // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen - Container Container = bankruptContainer.addChild(new Container()); - Container.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", new ElementId("label-Text"))); - Container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); - Container.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(-250,-200,0)); + // Text, der im Popup steht + Container textContainer = bankruptContainer.addChild(new Container()); + textContainer.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", 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(bankruptContainer.getPreferredSize().addLocal(-250,-200,0)); // Beenden-Button Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button"))); @@ -67,14 +67,14 @@ public class Bankrupt extends Dialog { quitButton.addClickCommands(source -> close()); - // Zentriere das Menü + // Zentriere den Container bankruptContainer.setLocalTranslation( (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2, 8 ); - + // Zentriere den Container backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2, @@ -101,7 +101,7 @@ public class Bankrupt extends Dialog { } /** - * Schließt das Menü und entfernt die GUI-Elemente. + * Closes the menu and removes the GUI elements. */ @Override public void close() { @@ -115,5 +115,4 @@ public class Bankrupt 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/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java index 7f72153..0b208f4 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -17,7 +17,7 @@ import pp.monopoly.notification.Sound; import static pp.monopoly.Resources.lookup; /** - * TimeOut ist ein Overlay-Menü, welches aufgerufen wird, wenn die Verbindung zum Server unterbrochen wurde. + * TimeOut is a warning popup that is triggered when the connection to the server is interrupted. */ public class TimeOut extends Dialog { private final MonopolyApp app; @@ -43,26 +43,24 @@ public class TimeOut extends Dialog { - // Hauptcontainer für die Gebäudekarte + // Hauptcontainer für die Warnung timeOutContainer = new Container(); timeOutContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); timeOutContainer.setPreferredSize(new Vector3f(550,250,10)); - float padding = 10; // Padding around the settingsContainer for the background + float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - // Die Namen werden dynamisch dem BoardManager entnommen Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen - Container propertyValuesContainer = timeOutContainer.addChild(new Container()); - propertyValuesContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text"))); - propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); - propertyValuesContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0)); + Container textContainer = timeOutContainer.addChild(new Container()); + textContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text"))); + textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); + textContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0)); // Beenden-Button Button quitButton = timeOutContainer.addChild(new Button("Bestätigen", new ElementId("button"))); @@ -70,14 +68,14 @@ public class TimeOut extends Dialog { quitButton.addClickCommands(source -> close()); - // Zentriere das Menü + // Zentriere den Container timeOutContainer.setLocalTranslation( (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2, 8 ); - + // Zentriere den Container backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2, From b0c21dfcb89fd2ccb3c0ccd8a0b8c0d725f704bd Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Fri, 29 Nov 2024 06:23:08 +0100 Subject: [PATCH 2/9] added trigger for winner looser popup --- .../main/java/pp/monopoly/client/gui/TestWorld.java | 10 ++++++++-- .../java/pp/monopoly/game/client/ClientGameLogic.java | 8 +++----- .../main/java/pp/monopoly/notification/PopUpEvent.java | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index 04bdc2a..06612bf 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -7,6 +7,8 @@ import pp.monopoly.client.gui.popups.BuyCard; import pp.monopoly.client.gui.popups.EventCard; import pp.monopoly.client.gui.popups.FoodFieldCard; import pp.monopoly.client.gui.popups.GateFieldCard; +import pp.monopoly.client.gui.popups.LooserPopUp; +import pp.monopoly.client.gui.popups.WinnerPopUp; import pp.monopoly.game.server.Player; import pp.monopoly.model.fields.BuildingProperty; import pp.monopoly.model.fields.FoodField; @@ -130,8 +132,7 @@ public class TestWorld implements GameEventListener{ @Override public void receivedEvent(PopUpEvent event) { - System.err.println("Trigger ?"); - // if (event.desc() == "BuyCard") { + if(event.msg().equals("Buy")) { int field = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field); @@ -142,6 +143,11 @@ public class TestWorld implements GameEventListener{ } else if (fieldObject instanceof FoodField) { new FoodFieldCard(app).open(); } + } else if(event.msg().equals("Winner")) { + new WinnerPopUp(app).open(); + } else if(event.msg().equals("Looser")) { + new LooserPopUp(app).open(); + } } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 1b817c3..31c97d1 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -226,12 +226,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(GameOver msg) { if (msg.isWinner()) { - - //Winner popup + notifyListeners(new PopUpEvent("Winner")); playSound(Sound.WINNER); } else { - - // Looser popup + notifyListeners(new PopUpEvent("Looser")); playSound(Sound.LOSER); } } @@ -333,6 +331,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(BuyPropertyRequest msg) { - notifyListeners(new PopUpEvent()); + notifyListeners(new PopUpEvent("Buy")); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java index 85febde..a808eed 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java @@ -1,6 +1,6 @@ package pp.monopoly.notification; -public record PopUpEvent() implements GameEvent{ +public record PopUpEvent(String msg) implements GameEvent{ @Override public void notifyListener(GameEventListener listener) { From 1438ae5e4ff0d283b2a7491b3184dfc5527e3e7f Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Fri, 29 Nov 2024 06:26:09 +0100 Subject: [PATCH 3/9] improve position calc --- .../client/src/main/java/pp/monopoly/client/gui/TestWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index 06612bf..3bc64bf 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -133,7 +133,7 @@ public class TestWorld implements GameEventListener{ @Override public void receivedEvent(PopUpEvent event) { if(event.msg().equals("Buy")) { - int field = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int field = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field); if (fieldObject instanceof BuildingProperty) { From 67f6649242e9a9aea9b553343d2b567a56ac5255 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Fri, 29 Nov 2024 06:34:42 +0100 Subject: [PATCH 4/9] added selector with no integration --- .../pp/monopoly/client/gui/TradeMenu.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java index 7affb71..74b2ead 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java @@ -16,6 +16,7 @@ import com.simsilica.lemur.core.VersionedList; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.game.server.Player; import pp.monopoly.model.TradeHandler; import pp.monopoly.model.fields.PropertyField; import pp.monopoly.notification.Sound; @@ -99,6 +100,7 @@ public class TradeMenu extends Dialog { column.addChild(new Label("Gebäude:")); Selector buildingSelector = createPropertySelector(isLeft); + buildingSelector.getPopupContainer().setBackground(new QuadBackgroundComponent(ColorRGBA.Orange)); column.addChild(buildingSelector); column.addChild(new Label("Währung:")); @@ -107,6 +109,7 @@ public class TradeMenu extends Dialog { column.addChild(new Label("Sonderkarten:")); Selector specialCardSelector = createSpecialCardSelector(); + specialCardSelector.getPopupContainer().setBackground(new QuadBackgroundComponent(ColorRGBA.Orange)); styleSelector(specialCardSelector); column.addChild(specialCardSelector); @@ -253,4 +256,24 @@ public class TradeMenu extends Dialog { app.getGuiNode().detachChild(mainContainer); super.close(); } + + /** + * Handles dropdown selection changes and updates the trade handler. + * + * @param selected The selected item from the dropdown. + */ + private void onDropdownSelectionChanged(String selected) { + app.getGameLogic().playSound(Sound.BUTTON); + int idStart = selected.indexOf("(ID: ") + 5; // Find start of the ID + int idEnd = selected.indexOf(")", idStart); // Find end of the ID + String idStr = selected.substring(idStart, idEnd); // Extract the ID as a string + int playerId = Integer.parseInt(idStr); // Convert the ID to an integer + + // Find the player by ID + Player selectedPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(playerId); + + if (selectedPlayer != null) { + tradeHandler.setReceiver(selectedPlayer); // Set the receiver in TradeHandler + } + } } From 5845254caa371f310b716e53fe1bcc8906c531a6 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Fri, 29 Nov 2024 06:47:26 +0100 Subject: [PATCH 5/9] added new label styling --- .../main/resources/Interface/Lemur/pp-styles.groovy | 10 ++++++++++ .../src/main/java/pp/monopoly/client/MonopolyApp.java | 2 +- .../java/pp/monopoly/client/gui/popups/TimeOut.java | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy b/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy index e761640..749dfdb 100644 --- a/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy +++ b/Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy @@ -262,6 +262,16 @@ selector("settings-title", "pp") { textHAlignment = HAlignment.Center textVAlignment = VAlignment.Center } +selector("warning-title", "pp") { + def outerBackground = new QuadBackgroundComponent(color(1, 0.5, 0, 1)) // Grey inner border + def innerBackground = new QuadBackgroundComponent(buttonBgColor) // White outer border background + font = font("Interface/Fonts/Metropolis/Metropolis-Bold-42.fnt") + background = outerBackground + fontSize = 40 + insets = new Insets3f(3, 3, 3, 3) + textHAlignment = HAlignment.Center + textVAlignment = VAlignment.Center +} selector("menu-button", "pp") { fontSize = 40 // Set font size diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 1c129e3..92788d7 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -274,7 +274,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - Dialog tmp = new Bankrupt(this); + Dialog tmp = new TimeOut(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java index 0b208f4..02dad1c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -52,7 +52,7 @@ public class TimeOut extends Dialog { backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift + Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); From 77da6679ef8042e8b424fcc3df54aed486d46cb6 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Fri, 29 Nov 2024 06:55:59 +0100 Subject: [PATCH 6/9] added another label styling --- .../client/src/main/java/pp/monopoly/client/MonopolyApp.java | 2 +- .../src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 92788d7..1c129e3 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -274,7 +274,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - Dialog tmp = new TimeOut(this); + Dialog tmp = new Bankrupt(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 5ad93d1..4083aef 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -49,7 +49,7 @@ public class Bankrupt extends Dialog { backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift + Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); From 0d8240381e6ebc65bfa56447c49253484c126caa Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Fri, 29 Nov 2024 07:11:20 +0100 Subject: [PATCH 7/9] fixed some mistakes --- .../client/gui/BuildingAdminMenu.java | 23 ++++++++----------- .../client/gui/PropertyOverviewMenu.java | 2 +- .../java/pp/monopoly/client/gui/Toolbar.java | 8 +++++++ .../monopoly/client/gui/popups/BuyCard.java | 2 +- .../client/gui/popups/ConfirmTrade.java | 3 --- .../client/gui/popups/FoodFieldCard.java | 2 +- .../client/gui/popups/GateFieldCard.java | 2 +- .../monopoly/client/gui/popups/SellHouse.java | 6 +---- .../monopoly/game/client/ClientGameLogic.java | 1 + .../monopoly/game/server/ServerGameLogic.java | 13 ++++++++--- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java index 6ff0998..4a77ec0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java @@ -24,6 +24,7 @@ public class BuildingAdminMenu extends Dialog { private final Button takeMortgageButton = new Button("Hypothek aufnehmen"); private final Button payMortgageButton = new Button("Hypothek bezahlen"); private final Button overviewButton = new Button("Übersicht"); + private Geometry background; public BuildingAdminMenu(MonopolyApp app) { super(app.getDialogManager()); @@ -42,7 +43,7 @@ public class BuildingAdminMenu extends Dialog { // Add content mainContainer.addChild(createContent()); // Attach main container to GUI node - app.getGuiNode().attachChild(mainContainer); + attachChild(mainContainer); mainContainer.setLocalTranslation( (app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2, @@ -146,29 +147,23 @@ public class BuildingAdminMenu extends Dialog { private void addBackgroundImage() { Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); - Geometry background = new Geometry("Background", quad); + background = new Geometry("Background", quad); Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); backgroundMaterial.setTexture("ColorMap", backgroundImage); background.setMaterial(backgroundMaterial); background.setLocalTranslation(0, 0, 6); // Position behind other GUI elements - app.getGuiNode().attachChild(background); - } - - /** - * Handles the "Zurück" action. - */ - private void handleBack() { - app.getGameLogic().playSound(Sound.BUTTON); - close(); + attachChild(background); } @Override public void escape() { - handleBack(); + new SettingsMenu(app).open(); } @Override - public void update(float delta) { - // Periodic updates if necessary + public void close() { + detachChild(background); + detachChild(mainContainer); + super.close(); } } \ No newline at end of file diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java index be513a5..a6dd56d 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java @@ -93,7 +93,7 @@ public class PropertyOverviewMenu extends Dialog { */ private void populatePlayerProperties() { // Fetch the current player - Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0); + Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); // Iterate through the player's properties for (PropertyField property : currentPlayer.getPropertyFields()) { diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index d3e82fc..7958d33 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -220,6 +220,8 @@ public class Toolbar extends Dialog implements GameEventListener { @Override public void receivedEvent(UpdatePlayerView event) { + + System.out.println("Update Player View"); accountContainer.clearChildren(); overviewContainer.clearChildren(); @@ -266,4 +268,10 @@ public class Toolbar extends Dialog implements GameEventListener { public void escape() { new SettingsMenu(app).open(); } + + @Override + public void update() { + receivedEvent(new UpdatePlayerView()); + super.update(); + } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java index 4277c27..d558ac0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java @@ -28,7 +28,7 @@ public class BuyCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Create the background container diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java index 89b47af..4211dbf 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java @@ -24,9 +24,6 @@ public class ConfirmTrade extends Dialog { super(app.getDialogManager()); this.app = app; - //Generate the corresponfing field - //int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; - // BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Create the background container backgroundContainer = new Container(); 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 90e4d24..05abb85 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 @@ -32,7 +32,7 @@ public class FoodFieldCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); // Halbtransparentes Overlay hinzufügen diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java index 7eb1eb0..85e60ad 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java @@ -31,7 +31,7 @@ public class GateFieldCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); GateField field = (GateField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); // Halbtransparentes Overlay hinzufügen diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 51627d3..7069637 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -36,10 +36,6 @@ public class SellHouse extends Dialog { public SellHouse(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - - //Generate the corresponfing field - //int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; - // BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Create the background container backgroundContainer = new Container(); @@ -94,7 +90,7 @@ public class SellHouse extends Dialog { VersionedList listModel = new VersionedList<>(); // Retrieve current player and their properties - Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0); + Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); BoardManager boardManager = app.getGameLogic().getBoardManager(); List playerProperties = boardManager.getPropertyFields( diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 31c97d1..3a275bf 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -269,6 +269,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(PlayerStatusUpdate msg) { playerHandler = msg.getPlayerHandler(); + System.out.println("Update Player"); notifyListeners(new UpdatePlayerView()); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index 00066fd..21e1c4d 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -152,6 +152,7 @@ public class ServerGameLogic implements ClientInterpreter { System.out.println("Properties:" +player.getProperties().toString()); LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName()); } + updateAllPlayers(); } /** @@ -173,6 +174,7 @@ public class ServerGameLogic implements ClientInterpreter { send(player, new PlayerStatusUpdate(playerHandler)); } } + updateAllPlayers(); } /** @@ -218,6 +220,7 @@ public class ServerGameLogic implements ClientInterpreter { if (player != null) { send(player, player.rollDice()); } + updateAllPlayers(); } /** @@ -266,9 +269,13 @@ public class ServerGameLogic implements ClientInterpreter { if (sender != null) { LOGGER.log(Level.DEBUG, "Processing ViewAssetsRequest for player {0}", sender.getName()); send(sender, new ViewAssetsResponse(boardManager)); - for (Player player : playerHandler.getPlayers()) { - send(player, new PlayerStatusUpdate(playerHandler)); - } + updateAllPlayers(); + } + } + + private void updateAllPlayers() { + for (Player player : playerHandler.getPlayers()) { + send(player, new PlayerStatusUpdate(playerHandler)); } } From aef2ef34fb06828d51402f45f6491dc6cd150824 Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Fri, 29 Nov 2024 07:14:44 +0100 Subject: [PATCH 8/9] Verschiedene Popups kommentiert und richtig benannt --- .../java/pp/monopoly/client/MonopolyApp.java | 4 +- .../pp/monopoly/client/gui/TestWorld.java | 4 +- .../monopoly/client/gui/popups/Bankrupt.java | 8 +-- .../gui/popups/BuildingPropertyCard.java | 24 +++------ .../monopoly/client/gui/popups/BuyCard.java | 16 +++--- .../client/gui/popups/ConfirmTrade.java | 38 ++++++------- .../{EventCard.java => EventCardPopup.java} | 23 ++++---- .../client/gui/popups/FoodFieldCard.java | 11 ++-- .../client/gui/popups/GateFieldCard.java | 15 +++--- .../monopoly/client/gui/popups/SellHouse.java | 54 +++++-------------- .../monopoly/client/gui/popups/TimeOut.java | 6 +-- 11 files changed, 79 insertions(+), 124 deletions(-) rename Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/{EventCard.java => EventCardPopup.java} (89%) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 1c129e3..baf2bc7 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -124,7 +124,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private final ActionListener escapeListener = (name, isPressed, tpf) -> escape(isPressed); //TODO temp for testing - private EventCard eventCard; + private EventCardPopup eventCard; private BuildingPropertyCard buildingProperty; private FoodFieldCard foodField; private GateFieldCard gateField; @@ -274,7 +274,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - Dialog tmp = new Bankrupt(this); + Dialog tmp = new SellHouse(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index 3bc64bf..2b4801b 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -4,7 +4,7 @@ import java.util.List; import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.gui.popups.BuyCard; -import pp.monopoly.client.gui.popups.EventCard; +import pp.monopoly.client.gui.popups.EventCardPopup; import pp.monopoly.client.gui.popups.FoodFieldCard; import pp.monopoly.client.gui.popups.GateFieldCard; import pp.monopoly.client.gui.popups.LooserPopUp; @@ -152,6 +152,6 @@ public class TestWorld implements GameEventListener{ @Override public void receivedEvent(EventCardEvent event) { - new EventCard(app, event.description()).open(); + new EventCardPopup(app, event.description()).open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 4083aef..175800c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -15,7 +15,7 @@ import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; /** - * Bankrupt is a Warning-Popup, which appears, if the balance is negative at the end of a player´s turn // TODO welche menü-Klasse + * Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn */ public class Bankrupt extends Dialog { private final MonopolyApp app; @@ -49,7 +49,7 @@ public class Bankrupt extends Dialog { backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); + Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("warning-label"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); @@ -67,14 +67,14 @@ public class Bankrupt extends Dialog { quitButton.addClickCommands(source -> close()); - // Zentriere den Container + // Zentriere das Popup bankruptContainer.setLocalTranslation( (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2, 8 ); - // Zentriere den Container + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java index 300f4aa..858c32c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java @@ -16,8 +16,7 @@ import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.model.fields.BuildingProperty; /** - * TODO Kommentare fixen - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * BuildingPropertyCard creates the popup for field information */ public class BuildingPropertyCard extends Dialog { private final MonopolyApp app; @@ -46,6 +45,9 @@ public class BuildingPropertyCard extends Dialog { buildingPropertyContainer = new Container(); buildingPropertyContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); + float padding = 10; // Passt den backgroundContainer an die Größe des buildingPropertyContainer an + backgroundContainer.setPreferredSize(buildingPropertyContainer.getPreferredSize().addLocal(padding, padding, 0)); + Label settingsTitle = buildingPropertyContainer.addChild(new Label( field.getName(), new ElementId("settings-title"))); settingsTitle.setFontSize(48); @@ -66,28 +68,14 @@ public class BuildingPropertyCard extends Dialog { propertyValuesContainer.addChild(new Label("„Hypothek: " + field.getHypo() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); - //TODO eventuell diese Stelle löschen, da nur die BuyCard Kaufen und beenden hat - - /* - // Beenden-Button - Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button"))); - quitButton.setFontSize(32); - // Kaufen-Button - Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button"))); - buyButton.setFontSize(32); - */ - - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(buildingPropertyContainer.getPreferredSize().addLocal(padding, padding, 0)); - - - // Zentriere das Menü + // Zentriere das Popup buildingPropertyContainer.setLocalTranslation( (app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java index 4277c27..df976b0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java @@ -15,7 +15,7 @@ import pp.monopoly.model.fields.BuildingProperty; import pp.monopoly.notification.Sound; /** - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * BuyCard is a popup that appears when a player lands on a field that is still available for purchase. */ public class BuyCard extends Dialog { private final MonopolyApp app; @@ -38,13 +38,16 @@ public class BuyCard extends Dialog { // Hauptcontainer für die Gebäudekarte buyCardContainer = new Container(); + + float padding = 10; // Passt den backgroundContainer an die Größe des buyCardContainers an + backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0)); - + // Titel Label title = buyCardContainer.addChild(new Label( field.getName(), new ElementId("label-Bold"))); title.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); title.setFontSize(48); - // Text, der auf der Karte steht + // Text, der auf dem Popup steht // Die Preise werden dynamisch dem BoardManager entnommen Container propertyValuesContainer = buyCardContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label("„Grundstückswert: " + field.getPrice() + " EUR", new ElementId("label-Text"))); @@ -77,17 +80,14 @@ public class BuyCard extends Dialog { app.getGameLogic().send(new BuyPropertyResponse()); })); - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0)); - - - // Zentriere das Menü + // Zentriere das Popup buyCardContainer.setLocalTranslation( (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java index 89b47af..b75202f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java @@ -12,7 +12,7 @@ import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.notification.Sound; /** - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * ConfirmTrade is a popup which appears when a trade is proposed to this certain player. */ public class ConfirmTrade extends Dialog { private final MonopolyApp app; @@ -23,26 +23,25 @@ public class ConfirmTrade extends Dialog { public ConfirmTrade(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - - //Generate the corresponfing field - //int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; - // BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // 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 + // Hauptcontainer für das Bestätigungspopup confirmTradeContainer = new Container(); + + float padding = 10; // Passt den backgroundContainer an die Größe des confirmTradeContainer an + backgroundContainer.setPreferredSize(confirmTradeContainer.getPreferredSize().addLocal(padding, padding, 0)); - - Label title = confirmTradeContainer.addChild(new Label( "Handel", new ElementId("label-Bold"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + // Titel + Label title = confirmTradeContainer.addChild(new Label( "Handel", new ElementId("label-Bold"))); title.setFontSize(48); title.setColor(ColorRGBA.Black); // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen + // Die Werte werden dem Handel entnommen (Iwas auch immer da dann ist) Container propertyValuesContainer = confirmTradeContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label("„Spieler XXX möchte:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile @@ -59,30 +58,26 @@ public class ConfirmTrade extends Dialog { propertyValuesContainer.addChild(new Label("tauschen, willst du das Angebot annehmen?", new ElementId("label-Text"))); propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); - // Beenden-Button - Button declineButton = confirmTradeContainer.addChild(new Button("Ablehnen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + // Ablehnen-Button + Button declineButton = confirmTradeContainer.addChild(new Button("Ablehnen", new ElementId("button"))); declineButton.setFontSize(32); - declineButton.addClickCommands(s -> ifTopDialog(() -> { + declineButton.addClickCommands(s -> ifTopDialog(() -> { //TODO Buttonfunktion prüfen app.getGameLogic().playSound(Sound.BUTTON); close(); })); - // Kaufen-Button - Button negotiateButton = confirmTradeContainer.addChild(new Button("Verhandeln", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + // Verhandeln-Button + Button negotiateButton = confirmTradeContainer.addChild(new Button("Verhandeln", new ElementId("button"))); negotiateButton.setFontSize(32); negotiateButton.addClickCommands(s -> ifTopDialog( () -> { //TODO Buttonfunktion prüfen app.getGameLogic().playSound(Sound.BUTTON); })); - // Kaufen-Button - Button confirmButton = confirmTradeContainer.addChild(new Button("Bestätigen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + // Confirm-Button + Button confirmButton = confirmTradeContainer.addChild(new Button("Bestätigen", new ElementId("button"))); confirmButton.setFontSize(32); - confirmButton.addClickCommands(s -> ifTopDialog( () -> { + confirmButton.addClickCommands(s -> ifTopDialog( () -> { //TODO Buttonfunktion prüfen app.getGameLogic().playSound(Sound.BUTTON); })); - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(confirmTradeContainer.getPreferredSize().addLocal(padding, padding, 0)); - - // Zentriere das Menü confirmTradeContainer.setLocalTranslation( (app.getCamera().getWidth() - confirmTradeContainer.getPreferredSize().x) / 2, @@ -90,6 +85,7 @@ public class ConfirmTrade extends Dialog { 8 ); + // Zentriere das Menü backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - confirmTradeContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + confirmTradeContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java similarity index 89% rename from Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCard.java rename to Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java index 3b8a1f6..71f2c80 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java @@ -13,11 +13,11 @@ import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; -import pp.monopoly.client.gui.SettingsMenu; + /** - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * EventCardPopup is a popup which appears when a certain EventCard is triggered by entering a EventCardField */ -public class EventCard extends Dialog { +public class EventCardPopup extends Dialog { private final MonopolyApp app; private final Geometry overlayBackground; private final Container eventCardContainer; @@ -25,7 +25,7 @@ public class EventCard extends Dialog { private final String description; - public EventCard(MonopolyApp app, String description) { + public EventCardPopup(MonopolyApp app, String description) { super(app.getDialogManager()); this.app = app; this.description = description; @@ -39,19 +39,21 @@ public class EventCard extends Dialog { backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background app.getGuiNode().attachChild(backgroundContainer); - // Hauptcontainer für die Gebäudekarte + // Hauptcontainer für die Eventcard eventCardContainer = new Container(); eventCardContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); eventCardContainer.setPreferredSize(new Vector3f(550,400,10)); + float padding = 10; // Passt den backgroundContainer an die Größe des eventCardContainers an + backgroundContainer.setPreferredSize(eventCardContainer.getPreferredSize().addLocal(padding, padding, 0)); + // Titel - // Die Namen werden dynamisch dem BoardManager entnommen Label gateFieldTitle = eventCardContainer.addChild(new Label("Ereigniskarte", new ElementId("settings-title"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen + // Die Erklärungsfelder werden automatisch den descriptions der Message entnommen Container propertyValuesContainer = eventCardContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label(description, new ElementId("label-Text"))); propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); @@ -62,17 +64,14 @@ public class EventCard extends Dialog { quitButton.setFontSize(32); quitButton.addClickCommands(source -> close()); - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(eventCardContainer.getPreferredSize().addLocal(padding, padding, 0)); - - - // Zentriere das Menü + // Zentriere das Popup eventCardContainer.setLocalTranslation( (app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2, 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 90e4d24..c7b75b6 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 @@ -19,7 +19,7 @@ import pp.monopoly.model.fields.FoodField; import pp.monopoly.notification.Sound; /** - * FoodFieldCard erstellt die Geböudekarte vom Brandl und der Truppenküche + * FoodFieldCard creates the popup for field information */ public class FoodFieldCard extends Dialog { private final MonopolyApp app; @@ -48,7 +48,8 @@ public class FoodFieldCard extends Dialog { 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 + 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("settings-title"))); @@ -86,16 +87,14 @@ public class FoodFieldCard extends Dialog { app.getGameLogic().send(new BuyPropertyResponse()); })); - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(foodFieldContainer.getPreferredSize().addLocal(padding, padding, 0)); - - // Zentriere das Menü + // Zentriere das Popup foodFieldContainer.setLocalTranslation( (app.getCamera().getWidth() - foodFieldContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + foodFieldContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - foodFieldContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + foodFieldContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java index 7eb1eb0..413cefa 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java @@ -18,7 +18,7 @@ import pp.monopoly.model.fields.GateField; import pp.monopoly.notification.Sound; /** - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * GateFieldCard creates the popup for field information */ public class GateFieldCard extends Dialog { private final MonopolyApp app; @@ -47,6 +47,10 @@ public class GateFieldCard extends Dialog { gateFieldContainer = new Container(); gateFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); + float padding = 10; // Passt den backgroundContainer an die Größe des gateFieldContainers an + backgroundContainer.setPreferredSize(gateFieldContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel // Die Namen werden dynamisch dem BoardManager entnommen Label gateFieldTitle = gateFieldContainer.addChild(new Label(field.getName(), new ElementId("settings-title"))); @@ -80,19 +84,16 @@ public class GateFieldCard extends Dialog { app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().send(new BuyPropertyResponse()); close(); - })); + })); - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(gateFieldContainer.getPreferredSize().addLocal(padding, padding, 0)); - - - // Zentriere das Menü + // Zentriere das Popup gateFieldContainer.setLocalTranslation( (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 51627d3..872eed0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.stream.Collectors; /** - * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. + * SellHouse is a popup which appears when a player clicks on the demolish-button in the BuildingAdminMenu */ public class SellHouse extends Dialog { private final MonopolyApp app; @@ -36,59 +36,36 @@ public class SellHouse extends Dialog { public SellHouse(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - - //Generate the corresponfing field - //int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; - // BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // 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 + // Hauptcontainer für das Menü sellhouseContainer = new Container(); sellhouseContainer.setPreferredSize(new Vector3f(800, 600, 0)); - - - Label title = sellhouseContainer.addChild(new Label( "Gebäude Abreißen", new ElementId("label-Bold"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + + float padding = 10; // Passt den backgroundContainer an die Größe des sellhouseContainers an + backgroundContainer.setPreferredSize(sellhouseContainer.getPreferredSize().addLocal(padding, padding, 0)); + + // Titel + Label title = sellhouseContainer.addChild(new Label( "Gebäude Abreißen", new ElementId("warining-Bold"))); title.setFontSize(48); title.setColor(ColorRGBA.Black); + //Unterteilund des sellHouseContainer in drei "Untercontainer" Container upContainer = sellhouseContainer.addChild(new Container()); Container middleContainer = sellhouseContainer.addChild(new Container()); Container downContainer = sellhouseContainer.addChild(new Container()); // Text, der auf der Karte steht - // Die Preise werden dynamisch dem BoardManager entnommen upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); middleContainer.setPreferredSize(new Vector3f(100, 150, 0)); middleContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange)); - /* - // Create a VersionedList for the ListBox model - VersionedList checkboxListModel = new VersionedList<>(); - for (int i = 1; i <= 10; i++) { - checkboxListModel.add("Option " + i); // Add items to the list - } - - // Create a ListBox with the "glass" style and the model - ListBox checkboxListBox = new ListBox<>(checkboxListModel, "glass"); - checkboxListBox.setPreferredSize(new Vector3f(300, 200, 0)); // Adjust size as needed - - // Add the ListBox to the middle container - middleContainer.addChild(checkboxListBox); - - // If you need separate checkboxes (optional), render them separately - for (String option : checkboxListModel) { - Checkbox checkbox = new Checkbox(option); - checkbox.setFontSize(16); // Optional: adjust font size - middleContainer.addChild(checkbox); // Add it to the middle container - } - // Add the ListBox to the middle container - middleContainer.addChild(checkboxListBox); */ // Create a VersionedList for the ListBox model VersionedList listModel = new VersionedList<>(); @@ -129,14 +106,14 @@ public class SellHouse extends Dialog { downContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Beenden-Button - Button cancelButton = sellhouseContainer.addChild(new Button("Abbrechen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + Button cancelButton = sellhouseContainer.addChild(new Button("Abbrechen", new ElementId("button"))); cancelButton.setFontSize(32); cancelButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); close(); })); // Kaufen-Button - Button confirmButton = sellhouseContainer.addChild(new Button("Bestätigen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen + Button confirmButton = sellhouseContainer.addChild(new Button("Bestätigen", new ElementId("button"))); confirmButton.setFontSize(32); confirmButton.addClickCommands(s -> ifTopDialog( () -> { app.getGameLogic().playSound(Sound.BUTTON); @@ -148,19 +125,14 @@ public class SellHouse extends Dialog { } })); - - - float padding = 10; // Padding around the settingsContainer for the background - backgroundContainer.setPreferredSize(sellhouseContainer.getPreferredSize().addLocal(padding, padding, 0)); - - - // Zentriere das Menü + // Zentriere das Popup sellhouseContainer.setLocalTranslation( (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y) / 2, 8 ); + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - sellhouseContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + sellhouseContainer.getPreferredSize().y+ padding) / 2, diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java index 02dad1c..18f69a5 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -52,7 +52,7 @@ public class TimeOut extends Dialog { backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); + Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("warining-label"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); @@ -68,14 +68,14 @@ public class TimeOut extends Dialog { quitButton.addClickCommands(source -> close()); - // Zentriere den Container + // Zentriere das Popup timeOutContainer.setLocalTranslation( (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2, 8 ); - // Zentriere den Container + // Zentriere das Popup backgroundContainer.setLocalTranslation( (app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2, From b05eabbbf8e377d4004df592d975f593737c90ab Mon Sep 17 00:00:00 2001 From: Simon Wilkening Date: Fri, 29 Nov 2024 07:21:28 +0100 Subject: [PATCH 9/9] Verschiedene Popups kommentiert und richtig benannt --- .../client/src/main/java/pp/monopoly/client/MonopolyApp.java | 2 +- .../src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java | 2 +- .../src/main/java/pp/monopoly/client/gui/popups/TimeOut.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index baf2bc7..fdc0e1f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -274,7 +274,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen private void handleB(boolean isPressed) { if (isPressed) { - Dialog tmp = new SellHouse(this); + Dialog tmp = new TimeOut(this); tmp.open(); } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 175800c..70e8cf8 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -49,7 +49,7 @@ public class Bankrupt extends Dialog { backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("warning-label"))); + Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java index 18f69a5..dbf23e1 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TimeOut.java @@ -52,7 +52,7 @@ public class TimeOut extends Dialog { backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel - Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("warining-label"))); + Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("warning-title"))); gateFieldTitle.setFontSize(48); gateFieldTitle.setColor(ColorRGBA.Black);