From 30822e3f4da193e5899ef1e5146d8678910dc7bd Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Mon, 2 Dec 2024 09:02:41 +0100 Subject: [PATCH 1/8] Java Docs --- .../pp/monopoly/game/client/ActiveState.java | 14 +++++++-- .../pp/monopoly/game/client/ClientState.java | 31 ++++++++++--------- .../pp/monopoly/game/client/LobbyState.java | 11 ++++++- .../game/client/WaitForTurnState.java | 11 ++++++- 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ActiveState.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ActiveState.java index 78dfed1..ff6702e 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ActiveState.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ActiveState.java @@ -1,8 +1,18 @@ package pp.monopoly.game.client; -public class ActiveState extends ClientState{ +/** + * Represents the active client state in the Monopoly game. + * Extends {@link ClientState}. + */ +public class ActiveState extends ClientState { + /** + * Constructs an ActiveState with the specified game logic. + * + * @param logic the client-side game logic associated with this state + * used to manage game interactions and transitions + */ ActiveState(ClientGameLogic logic) { super(logic); } -} +} \ No newline at end of file diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientState.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientState.java index 4bd64db..b9f2361 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientState.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientState.java @@ -6,24 +6,25 @@ //////////////////////////////////////// package pp.monopoly.game.client; -import pp.monopoly.model.IntPoint; import java.io.File; import java.io.IOException; import java.lang.System.Logger.Level; +import pp.monopoly.model.IntPoint; + /** - * Defines the behavior and state transitions for the client-side game logic. - * Different states of the game logic implement this interface to handle various game events and actions. + * Defines the behavior and state transitions for the client-side game logic in Monopoly. + * Different states of the game logic implement this abstract class to handle various game events and actions. */ abstract class ClientState { /** - * The game logic object. + * The game logic object managing the client-side state. */ final ClientGameLogic logic; /** - * Constructs a client state of the specified game logic. + * Constructs a client state for the specified game logic. * * @param logic the game logic */ @@ -49,16 +50,16 @@ abstract class ClientState { } /** - * Checks if the battle state should be shown. + * Checks if the player's turn should be shown in the current state. * - * @return true if the battle state should be shown, false otherwise + * @return true if the player's turn should be shown, false otherwise */ boolean showTurn() { return false; } /** - * Moves the preview figure to the specified position. + * Moves the preview figure to the specified position on the game board. * * @param pos the new position for the preview figure */ @@ -67,13 +68,13 @@ abstract class ClientState { } /** - * Loads a map from the specified file. + * Loads a game configuration from the specified file. * - * @param file the file to load the map from - * @throws IOException if the map cannot be loaded in the current state + * @param file the file to load the game configuration from + * @throws IOException if the configuration cannot be loaded in the current state */ - void loadMap(File file) throws IOException { - throw new IOException("You are not allowed to load a map in this state of the game"); + void loadGameConfig(File file) throws IOException { + throw new IOException("You are not allowed to load a game configuration in this state of the game."); } /** @@ -81,5 +82,7 @@ abstract class ClientState { * * @param delta time in seconds since the last update call */ - void update(float delta) { /* do nothing by default */ } + void update(float delta) { + // Default implementation does nothing + } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/LobbyState.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/LobbyState.java index 5fc6bd0..f2db68b 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/LobbyState.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/LobbyState.java @@ -1,7 +1,16 @@ package pp.monopoly.game.client; -public class LobbyState extends ClientState{ +/** + * Represents the lobby state of the client in the Monopoly game. + * Extends {@link ClientState}. + */ +public class LobbyState extends ClientState { + /** + * Constructs a LobbyState with the specified game logic. + * + * @param logic the client-side game logic + */ LobbyState(ClientGameLogic logic) { super(logic); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/WaitForTurnState.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/WaitForTurnState.java index d6c6407..0575966 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/WaitForTurnState.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/WaitForTurnState.java @@ -1,7 +1,16 @@ package pp.monopoly.game.client; -public class WaitForTurnState extends ClientState{ +/** + * Represents the state where the client is waiting for their turn in the Monopoly game. + * Extends {@link ClientState}. + */ +public class WaitForTurnState extends ClientState { + /** + * Constructs a WaitForTurnState with the specified game logic. + * + * @param logic the client-side game logic + */ WaitForTurnState(ClientGameLogic logic) { super(logic); } From 49b9972adef76703b17db385a2fa24a3203f53fb Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Wed, 4 Dec 2024 01:10:12 +0100 Subject: [PATCH 2/8] replaced textinput with dynamic label --- .../pp/monopoly/client/gui/TradeMenu.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 f94c04a..f45d287 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 @@ -23,6 +23,7 @@ import pp.monopoly.notification.Sound; import java.util.HashSet; import java.util.Set; + /** * Represents the trade menu dialog in the Monopoly application. *

@@ -45,7 +46,7 @@ public class TradeMenu extends Dialog { private Geometry background; private Selector leftBuildingSelector, leftSpecialCardSelector; private Selector rightBuildingSelector, rightSpecialCardSelector; - private TextField leftSelectionsField, rightSelectionsField; + private Label leftSelectionsLabel, rightSelectionsLabel; private TextField leftCurrencyInput, rightCurrencyInput; private VersionedReference> leftBuildingRef, rightBuildingRef; @@ -221,8 +222,8 @@ public class TradeMenu extends Dialog { middleLabelTop.setFontSize(24); middleLabelTop.setInsets(new Insets3f(5, 5, 5, 5)); - leftSelectionsField = middleSection.addChild(new TextField("")); - leftSelectionsField.setPreferredSize(new Vector3f(600, 50, 0)); + leftSelectionsLabel = middleSection.addChild(new Label("")); + leftSelectionsLabel.setPreferredSize(new Vector3f(600, 50, 0)); Container buttons = middleSection.addChild(new Container(new SpringGridLayout())); Button cancel = new Button("Abbrechen"); @@ -246,8 +247,8 @@ public class TradeMenu extends Dialog { middleLabelBottom.setFontSize(24); middleLabelBottom.setInsets(new Insets3f(5, 5, 5, 5)); - rightSelectionsField = middleSection.addChild(new TextField("")); - rightSelectionsField.setPreferredSize(new Vector3f(600, 50, 0)); + rightSelectionsLabel = middleSection.addChild(new Label("")); + rightSelectionsLabel.setPreferredSize(new Vector3f(600, 50, 0)); return middleSection; } @@ -322,11 +323,11 @@ public class TradeMenu extends Dialog { @Override public void update(float delta) { if (leftBuildingRef.update() || leftCardRef.update() || leftCurrencyRef.update()) { - updateSelections(leftSelectionsField, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true); + updateSelections(leftSelectionsLabel, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true); } if (rightBuildingRef.update() || rightCardRef.update() || rightCurrencyRef.update()) { - updateSelections(rightSelectionsField, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false); + updateSelections(rightSelectionsLabel, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false); } } @@ -339,7 +340,7 @@ public class TradeMenu extends Dialog { * @param card the special card selector * @param isLeft true if updating the left column; false otherwise */ - private void updateSelections(TextField target, Selector building, TextField currency, Selector card, boolean isLeft) { + private void updateSelections(Label target, Selector building, TextField currency, Selector card, boolean isLeft) { StringBuilder buildingText = new StringBuilder(); if (isLeft) { if (leftselBuildings.contains(building.getSelectedItem())) { @@ -347,8 +348,8 @@ public class TradeMenu extends Dialog { } else { leftselBuildings.add(building.getSelectedItem()); // Add if not already selected } - for (String property : leftselBuildings) { - buildingText.append(property); + for (String property : leftselBuildings) { + buildingText.append(property).append(", "); } } else { if (rightselBuildings.contains(building.getSelectedItem())) { @@ -356,14 +357,14 @@ public class TradeMenu extends Dialog { } else { rightselBuildings.add(building.getSelectedItem()); // Add if not already selected } - for (String property : rightselBuildings) { - buildingText.append(property); + for (String property : rightselBuildings) { + buildingText.append(property).append(", "); } } String currencyText = currency.getText() != null ? currency.getText().trim() : ""; String cardText = card.getSelectedItem() != null ? card.getSelectedItem() : ""; - target.setText(String.join(" | ", buildingText, currencyText, cardText)); + target.setText(String.join(" | ", buildingText.toString().replaceAll(", $", ""), currencyText, cardText)); } /** Opens the settings menu when the escape key is pressed. */ From 9ee1b5b81b8f77efd39e566ff831cbcc8ce279ec Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Wed, 4 Dec 2024 01:48:18 +0100 Subject: [PATCH 3/8] simplified representation of trade --- .../pp/monopoly/client/gui/TradeMenu.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 f45d287..cb4a3d9 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 @@ -218,8 +218,10 @@ public class TradeMenu extends Dialog { Container middleSection = new Container(new SpringGridLayout(Axis.Y, Axis.X)); middleSection.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f))); - Label middleLabelTop = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:")); + Label middleLabelTop = middleSection.addChild(new Label("Meine Gebäude:")); middleLabelTop.setFontSize(24); + middleLabelTop.setTextVAlignment(VAlignment.Center); + middleLabelTop.setTextHAlignment(HAlignment.Center); middleLabelTop.setInsets(new Insets3f(5, 5, 5, 5)); leftSelectionsLabel = middleSection.addChild(new Label("")); @@ -243,8 +245,10 @@ public class TradeMenu extends Dialog { buttons.addChild(cancel); buttons.addChild(trade); - Label middleLabelBottom = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:")); + Label middleLabelBottom = middleSection.addChild(new Label("Gebäude des Gegenspielers:")); middleLabelBottom.setFontSize(24); + middleLabelBottom.setTextVAlignment(VAlignment.Center); + middleLabelBottom.setTextHAlignment(HAlignment.Center); middleLabelBottom.setInsets(new Insets3f(5, 5, 5, 5)); rightSelectionsLabel = middleSection.addChild(new Label("")); @@ -322,25 +326,23 @@ public class TradeMenu extends Dialog { */ @Override public void update(float delta) { - if (leftBuildingRef.update() || leftCardRef.update() || leftCurrencyRef.update()) { - updateSelections(leftSelectionsLabel, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true); + if (leftBuildingRef.update() || leftCardRef.update()) { + updateSelections(leftSelectionsLabel, leftBuildingSelector, true); } - if (rightBuildingRef.update() || rightCardRef.update() || rightCurrencyRef.update()) { - updateSelections(rightSelectionsLabel, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false); + if (rightBuildingRef.update() || rightCardRef.update()) { + updateSelections(rightSelectionsLabel, rightBuildingSelector, false); } } /** - * Updates the displayed selections for properties, currency, and cards. + * Updates the displayed selections for properties. * - * @param target the target text field to update + * @param target the target label to update * @param building the building selector - * @param currency the currency input field - * @param card the special card selector * @param isLeft true if updating the left column; false otherwise */ - private void updateSelections(Label target, Selector building, TextField currency, Selector card, boolean isLeft) { + private void updateSelections(Label target, Selector building, boolean isLeft) { StringBuilder buildingText = new StringBuilder(); if (isLeft) { if (leftselBuildings.contains(building.getSelectedItem())) { @@ -362,9 +364,7 @@ public class TradeMenu extends Dialog { } } - String currencyText = currency.getText() != null ? currency.getText().trim() : ""; - String cardText = card.getSelectedItem() != null ? card.getSelectedItem() : ""; - target.setText(String.join(" | ", buildingText.toString().replaceAll(", $", ""), currencyText, cardText)); + target.setText(buildingText.toString().replaceAll(", $", "")); } /** Opens the settings menu when the escape key is pressed. */ From eaff7b6c5db6cad3b626351e48d002432bc201bd Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Wed, 4 Dec 2024 01:52:30 +0100 Subject: [PATCH 4/8] fixed formating error in RejectTrade --- .../main/java/pp/monopoly/client/gui/popups/RejectTrade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 92f1d07..fc98bf6 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 @@ -74,7 +74,7 @@ public class RejectTrade extends Dialog { // 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("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))); From 4c40b447a5ba77599b6465313934a424e68d73e9 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Wed, 4 Dec 2024 12:16:04 +0100 Subject: [PATCH 5/8] fixed formating errors --- .../java/pp/monopoly/client/gui/popups/AcceptTrade.java | 2 +- .../java/pp/monopoly/client/gui/popups/ConfirmTrade.java | 6 +++--- .../java/pp/monopoly/client/gui/popups/ReceivedRent.java | 2 +- .../src/main/java/pp/monopoly/client/gui/popups/Rent.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java index 6a6795d..067cd65 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java @@ -73,7 +73,7 @@ public class AcceptTrade extends Dialog { // 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("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 angenommen", new ElementId("label-Text"))); textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); 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 db1f065..1c5be3b 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 @@ -72,17 +72,17 @@ public class ConfirmTrade extends Dialog { // Text, der auf der Karte steht // Die Werte werden dem Handel entnommen (Iwas auch immer da dann ist) Container propertyValuesContainer = confirmTradeContainer.addChild(new Container()); - propertyValuesContainer.addChild(new Label("„Spieler " + tradeHandler.getSender().getName() + " möchte:", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("„Spieler " + " " + tradeHandler.getSender().getName() + " " +" möchte:", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile propertyValuesContainer.addChild(new Label("- " + offeredProperties, new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("- " + tradeHandler.getOfferedAmount() + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("- " + tradeHandler.getOfferedJailCards() +" Sonderkaten", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- " + tradeHandler.getOfferedJailCards() +" Sonderkarten", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile propertyValuesContainer.addChild(new Label("gegen:", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile propertyValuesContainer.addChild(new Label("- "+ requestedProperties, new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("- "+ tradeHandler.getRequestedAmount() +" EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("- "+ tradeHandler.getRequestedJailCards() +" Sonderkaten", new ElementId("label-Text"))); + propertyValuesContainer.addChild(new Label("- "+ tradeHandler.getRequestedJailCards() +" Sonderkarten", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile 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))); 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 83e8784..178e104 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 @@ -107,7 +107,7 @@ public class ReceivedRent extends Dialog { // Rent message Container textContainer = container.addChild(new Container()); - textContainer.addChild(new Label("Du bekommst von Spieler " + playerName + " " + amount + " EUR Miete", + textContainer.addChild(new Label("Du bekommst von Spieler " + " " + playerName + " " + 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)); 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 21653d5..bd87b39 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 @@ -107,7 +107,7 @@ public class Rent extends Dialog { // Rent message Container textContainer = container.addChild(new Container()); - textContainer.addChild(new Label("Du musst Spieler " + playerName + " " + amount + " EUR Miete zahlen", + textContainer.addChild(new Label("Du musst Spieler " + " " + playerName + " " + amount + " EUR Miete 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)); From 02cfc1d21a29d80867e449400944d8aa559f8c39 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Wed, 4 Dec 2024 16:00:24 +0100 Subject: [PATCH 6/8] fixed formating errors --- .../main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java | 1 - 1 file changed, 1 deletion(-) 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 1c5be3b..438c39e 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 @@ -70,7 +70,6 @@ public class ConfirmTrade extends Dialog { } // Text, der auf der Karte steht - // Die Werte werden dem Handel entnommen (Iwas auch immer da dann ist) Container propertyValuesContainer = confirmTradeContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label("„Spieler " + " " + tradeHandler.getSender().getName() + " " +" möchte:", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile From b477077b9b5bd3d9e398bb62b4193d1125e24300 Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Wed, 4 Dec 2024 16:39:32 +0100 Subject: [PATCH 7/8] Kamera Teil1 --- .../client/gui/CameraInputHandler.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java new file mode 100644 index 0000000..bbfeca2 --- /dev/null +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java @@ -0,0 +1,59 @@ +package pp.monopoly.client.gui; + +import com.jme3.input.InputManager; +import com.jme3.input.KeyInput; +import com.jme3.input.controls.ActionListener; +import com.jme3.input.controls.KeyTrigger; + +/** + * Handhabt die Eingaben für die Kamera. + */ +public class CameraInputHandler { + + private CameraController cameraController; // Kamera-Controller + + /** + * Konstruktor für den CameraInputHandler. + * + * @param cameraController Der Kamera-Controller, der gesteuert werden soll. + * @param inputManager Der InputManager, um Eingaben zu registrieren. + */ + public CameraInputHandler(CameraController cameraController, InputManager inputManager) { + if (cameraController == null || inputManager == null) { + throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein"); + } + this.cameraController = cameraController; + + // Mappings für Kamerasteuerung + inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1 + inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2 + inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3 + + // Listener für die Kameramodi + inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam"); + } + + /** + * ActionListener für die Kamerasteuerung. + */ + private final ActionListener actionListener = (name, isPressed, tpf) -> { + if (!isPressed) return; + + // Umschalten der Kamera-Modi basierend auf der Eingabe + switch (name) { + case "FocusCurrentPlayer" -> { + cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER); + System.out.println("Kameramodus: Fokus auf aktuellen Spieler"); + } + case "FocusSelf" -> { + cameraController.setMode(CameraController.CameraMode.FOCUS_SELF); + System.out.println("Kameramodus: Fokus auf eigene Figur"); + } + case "FreeCam" -> { + cameraController.setMode(CameraController.CameraMode.FREECAM); + System.out.println("Kameramodus: Freie Kamera"); + } + default -> System.err.println("Unbekannter Kameramodus: " + name); + } + }; +} From 8821602728a7fe246878c5a931a0c40931dd22a9 Mon Sep 17 00:00:00 2001 From: Luca Puderbach Date: Wed, 4 Dec 2024 16:44:26 +0100 Subject: [PATCH 8/8] kamera --- .../client/gui/CameraInputHandler.java | 119 +++++++++--------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java index bbfeca2..d494b76 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java @@ -1,59 +1,60 @@ -package pp.monopoly.client.gui; - -import com.jme3.input.InputManager; -import com.jme3.input.KeyInput; -import com.jme3.input.controls.ActionListener; -import com.jme3.input.controls.KeyTrigger; - -/** - * Handhabt die Eingaben für die Kamera. - */ -public class CameraInputHandler { - - private CameraController cameraController; // Kamera-Controller - - /** - * Konstruktor für den CameraInputHandler. - * - * @param cameraController Der Kamera-Controller, der gesteuert werden soll. - * @param inputManager Der InputManager, um Eingaben zu registrieren. - */ - public CameraInputHandler(CameraController cameraController, InputManager inputManager) { - if (cameraController == null || inputManager == null) { - throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein"); - } - this.cameraController = cameraController; - - // Mappings für Kamerasteuerung - inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1 - inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2 - inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3 - - // Listener für die Kameramodi - inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam"); - } - - /** - * ActionListener für die Kamerasteuerung. - */ - private final ActionListener actionListener = (name, isPressed, tpf) -> { - if (!isPressed) return; - - // Umschalten der Kamera-Modi basierend auf der Eingabe - switch (name) { - case "FocusCurrentPlayer" -> { - cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER); - System.out.println("Kameramodus: Fokus auf aktuellen Spieler"); - } - case "FocusSelf" -> { - cameraController.setMode(CameraController.CameraMode.FOCUS_SELF); - System.out.println("Kameramodus: Fokus auf eigene Figur"); - } - case "FreeCam" -> { - cameraController.setMode(CameraController.CameraMode.FREECAM); - System.out.println("Kameramodus: Freie Kamera"); - } - default -> System.err.println("Unbekannter Kameramodus: " + name); - } - }; -} +//package pp.monopoly.client.gui; +// +//import com.jme3.input.InputManager; +//import com.jme3.input.KeyInput; +//import com.jme3.input.controls.ActionListener; +//import com.jme3.input.controls.KeyTrigger; +// +///** +// * Handhabt die Eingaben für die Kamera. +// */ +//public class CameraInputHandler { +// +// private CameraController cameraController; // Kamera-Controller +// +// /** +// * Konstruktor für den CameraInputHandler. +// * +// * @param cameraController Der Kamera-Controller, der gesteuert werden soll. +// * @param inputManager Der InputManager, um Eingaben zu registrieren. +// */ +// public CameraInputHandler(CameraController cameraController, InputManager inputManager) { +// if (cameraController == null || inputManager == null) { +// throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein"); +// } +// this.cameraController = cameraController; +// +// // Mappings für Kamerasteuerung +// inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1 +// inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2 +// inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3 +// +// // Listener für die Kameramodi +// inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam"); +// } +// +// /** +// * ActionListener für die Kamerasteuerung. +// */ +// private final ActionListener actionListener = (name, isPressed, tpf) -> { +// if (!isPressed) return; +// +// // Umschalten der Kamera-Modi basierend auf der Eingabe +// switch (name) { +// case "FocusCurrentPlayer" -> { +// cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER); +// System.out.println("Kameramodus: Fokus auf aktuellen Spieler"); +// } +// case "FocusSelf" -> { +// cameraController.setMode(CameraController.CameraMode.FOCUS_SELF); +// System.out.println("Kameramodus: Fokus auf eigene Figur"); +// } +// case "FreeCam" -> { +// cameraController.setMode(CameraController.CameraMode.FREECAM); +// System.out.println("Kameramodus: Freie Kamera"); +// } +// default -> System.err.println("Unbekannter Kameramodus: " + name); +// } +// }; +//} +// \ No newline at end of file