From b7ed03f7e82bf59a56ef5ff92050566fc105c1c1 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 25 Nov 2024 03:55:06 +0100 Subject: [PATCH] resolve merge conflicts --- .../pp/monopoly/client/gui/LobbyMenu.java | 99 +++---------------- .../gui/popups/BuildingPropertyCard.java | 10 +- .../monopoly/client/gui/popups/BuyCard.java | 14 ++- .../monopoly/client/gui/popups/EventCard.java | 15 +-- .../client/gui/popups/FoodFieldCard.java | 11 ++- .../client/gui/popups/GateFieldCard.java | 11 ++- 6 files changed, 49 insertions(+), 111 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java index 2368699..9e60d9f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java @@ -38,13 +38,6 @@ public class LobbyMenu extends Dialog { private Geometry circle; private Container lowerLeftMenu; private Container lowerRightMenu; - private ColorRGBA playerColor= ColorRGBA.Gray; - - private PlayerHandler playerHandler; - private TextField startingCapital; - private TextField playerInputField; - private Selector figureDropdown; - private TextField playerInputField = new TextField("Spieler 1"); private TextField startingCapital = new TextField("15000"); @@ -54,20 +47,19 @@ public class LobbyMenu extends Dialog { super(app.getDialogManager()); this.app = app; - app.getGuiNode().detachAllChildren(); // Entfernt das CreateGameMenu (inklusive Hintergrund) - - addBackgroundImage();// Hintergrundbild laden und hinzufügen + // Hintergrundbild laden und hinzufügen + addBackgroundImage(); QuadBackgroundComponent translucentWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); menuContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X)); - menuContainer.setPreferredSize(new Vector3f(1000, 600, 0)); + menuContainer.setPreferredSize(new Vector3f(1000, 600, 0)); // Fixed size of the container menuContainer.setBackground(translucentWhiteBackground); // Create a smaller horizontal container for the label, input field, and spacers Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y))); - horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); + horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size horizontalContainer.setBackground(null); Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold"))); @@ -106,16 +98,15 @@ public class LobbyMenu extends Dialog { playerInputField.setPreferredSize(new Vector3f(100, 20, 0)); - playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); + playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black)); playerInputContainer.addChild(playerInputField); // Spacer (Center Circle Area) Label spacer = dropdownContainer.addChild(new Label("")); - spacer.setPreferredSize(new Vector3f(200, 200, 0)); + spacer.setPreferredSize(new Vector3f(200, 200, 0)); // Adjust this to fit the center graphic // Figur Dropdown Container figureDropdownContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X))); - figureDropdownContainer.setPreferredSize(new Vector3f(150, 80, 0)); figureDropdownContainer.addChild(new Label("Figur:")); figureDropdownContainer.setBackground(null); @@ -129,11 +120,7 @@ public class LobbyMenu extends Dialog { Selector figureDropdown = new Selector<>(figures, "glass"); figureDropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.DarkGray)); - figureDropdown.setPreferredSize(new Vector3f(150, 140, 0)); - Vector3f dimens = figureDropdownContainer.getPreferredSize(); - Vector3f dimens2 = figureDropdown.getPopupContainer().getPreferredSize(); - dimens2.setX( dimens.getX() ); - figureDropdown.getPopupContainer().setPreferredSize( dimens2 ); + figureDropdown.setPreferredSize(new Vector3f(100, 20, 0)); figureDropdownContainer.addChild(figureDropdown); addSelectionActionListener(figureDropdown, this::onDropdownSelectionChanged); @@ -168,14 +155,13 @@ public class LobbyMenu extends Dialog { app.getGameLogic().playSound(Sound.BUTTON); })); lowerRightMenu.addChild(readyButton); - //TODO aktivieren des Spielers in den ready Status und Sprung in den nächsten Menüzustand // Position the container near the bottom-right corner lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 3)); // X: 220px from the right, Y: 50px above the bottom app.getGuiNode().attachChild(lowerRightMenu); // Add a colored circle between the input field and the dropdown menu - circle = createCircle(); // 50 is the diameter, Red is the color + circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color circle.setLocalTranslation(new Vector3f( (app.getCamera().getWidth()) / 2, // Center horizontally (app.getCamera().getHeight() / 2) - 90, // Adjust Y position @@ -192,59 +178,7 @@ public class LobbyMenu extends Dialog { app.getGuiNode().attachChild(menuContainer); } - /** - * Apply the starting capital only if the current player is the host. - */ - private void applyStartingCapital(int playerID) { - Player currentPlayer = playerHandler.getPlayerById(playerID); - // Check if the current player is the host - if (currentPlayer.equals(playerHandler.getHostPlayer())) { - try { - // Parse and validate starting capital - int startBalance = Integer.parseInt(startingCapital.getText().replaceAll("[^\\d]", "")); - if (startBalance < 0) throw new NumberFormatException("Starting capital must be positive."); - - // Apply the starting balance to all players - playerHandler.setStartBalance(startBalance); - System.out.println("Starting balance set to: " + startBalance); - } catch (NumberFormatException e) { - System.err.println("Invalid starting capital: " + e.getMessage()); - } - } else { - System.out.println("Only the host can set the starting balance."); - } - } - - /** - * Apply the player name from the input field. - */ - private void applyPlayerName(int playerID) { - Player currentPlayer = playerHandler.getPlayerById(playerID); - - String playerName = playerInputField.getText().trim(); - if (!playerName.isEmpty()) { - currentPlayer.setName(playerName); - System.out.println("Player name set to: " + playerName); - } else { - System.err.println("Invalid player name: Name cannot be empty."); - } - } - - /** - * Apply the selected figure to the player. - */ - private void applyFigure(int playerID) { - Player currentPlayer = playerHandler.getPlayerById(playerID); - - String selectedFigure = figureDropdown.getSelectedItem(); - if (selectedFigure != null && !selectedFigure.isEmpty()) { - currentPlayer.setFigure(new Figure(0, 0, 0, Rotation.RIGHT, "selectedFigure")); - System.out.println("Player figure set to: " + selectedFigure); - } else { - System.err.println("Invalid figure selection."); - } - } /** * Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu. @@ -261,32 +195,21 @@ public class LobbyMenu extends Dialog { app.getGuiNode().attachChild(background); } - private Geometry createCircle() { + private Geometry createCircle(ColorRGBA color) { Sphere sphere = new Sphere(90,90,60.0f); Geometry circleGeometry = new Geometry("Circle", sphere); // Create a material with a solid color Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - material.setColor("Color", playerColor); // Set the desired color + material.setColor("Color", color); // Set the desired color circleGeometry.setMaterial(material); return circleGeometry; } - public void setPlayerColor(ColorRGBA newColor) { - this.playerColor = newColor; - // Update the circle's color - if (circle != null) { - Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - material.setColor("Color", playerColor); - circle.setMaterial(material); - } - } /** - * Assigns a color to the player based on their ID. - * - * @param playerID the player's ID + * Schaltet den "Bereit"-Status um. */ private void toggleReady() { app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText()))); 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 39e948f..300f4aa 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 @@ -12,6 +12,7 @@ import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.model.fields.BuildingProperty; /** @@ -117,17 +118,18 @@ public class BuildingPropertyCard extends Dialog { */ @Override public void close() { - System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe app.getGuiNode().detachChild(buildingPropertyContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay - app.setSettingsMenuOpen(false); // Menü als geschlossen markieren TODO passt diese Variable noch (zu finden unter den Temps in MonopolyApp - app.unblockInputs(); // Eingaben wieder aktivieren - System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + super.close(); } public void setIndex(int index) { this.index = index; } + @Override + public void escape() { + new SettingsMenu(app).open(); + } } 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 bfae0f6..8a65d6a 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 @@ -12,6 +12,8 @@ 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; +import pp.monopoly.model.fields.BoardManager; import pp.monopoly.model.fields.BuildingProperty; /** @@ -30,7 +32,7 @@ public class BuyCard extends Dialog { this.app = app; //Generate the corresponfing field - BuildingProperty field = (BuildingProperty) app.getBoardManager().getFieldAtIndex(index); + BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Halbtransparentes Overlay hinzufügen overlayBackground = createOverlayBackground(); @@ -113,12 +115,14 @@ public class BuyCard extends Dialog { */ @Override public void close() { - System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay - app.setSettingsMenuOpen(false); // Menü als geschlossen markieren TODO passt diese Variable noch (zu finden unter den Temps in MonopolyApp - app.unblockInputs(); // Eingaben wieder aktivieren - System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + super.close(); + } + + @Override + public void escape() { + new SettingsMenu(app).open(); } } 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/EventCard.java index 2736b54..37fa654 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/EventCard.java @@ -12,8 +12,9 @@ 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; import pp.monopoly.model.card.Card; // TODO für den Import der Queue notwendig +import pp.monopoly.model.card.DeckHelper; /** * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. */ @@ -29,7 +30,7 @@ public class EventCard extends Dialog { this.app = app; //Generate the corresponfing field - Card card = app.getDeckHelper().drawCard(); // TODO nimmt die Karten gerade unabhängig aus dem DeckHelper + Card card = new DeckHelper().drawCard(); // TODO nimmt die Karten gerade unabhängig aus dem DeckHelper // Halbtransparentes Overlay hinzufügen overlayBackground = createOverlayBackground(); @@ -107,12 +108,14 @@ public class EventCard extends Dialog { */ @Override public void close() { - System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe app.getGuiNode().detachChild(eventCardContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay - app.setBuyCardPopupOpen(false); // Menü als geschlossen markieren TODO passt diese Variable noch (zu finden unter den Temps in MonopolyApp - app.unblockInputs(); // Eingaben wieder aktivieren - System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + super.close(); + } + + @Override + public void escape() { + new SettingsMenu(app).open(); } } \ No newline at end of file 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 8b55a4d..2880416 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 @@ -12,6 +12,7 @@ import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.model.fields.FoodField; /** @@ -120,17 +121,19 @@ public class FoodFieldCard extends Dialog { */ @Override public void close() { - System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe app.getGuiNode().detachChild(foodFieldContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay - app.setSettingsMenuOpen(false); // Menü als geschlossen markieren TODO passt diese Variable noch (zu finden unter den Temps in MonopolyApp - app.unblockInputs(); // Eingaben wieder aktivieren - System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + super.close(); } public void setIndex(int index) { this.index = index; } + @Override + public void escape() { + new SettingsMenu(app).open(); + } + } 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 a736662..c1d9561 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 @@ -11,6 +11,7 @@ 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; import pp.monopoly.model.fields.GateField; /** @@ -114,16 +115,18 @@ public class GateFieldCard extends Dialog { */ @Override public void close() { - System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe app.getGuiNode().detachChild(gateFieldContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay - app.setSettingsMenuOpen(false); // Menü als geschlossen markieren TODO passt diese Variable noch (zu finden unter den Temps in MonopolyApp - app.unblockInputs(); // Eingaben wieder aktivieren - System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe + super.close(); } public void setIndex(int index) { this.index = index; } + + @Override + public void escape() { + new SettingsMenu(app).open(); + } }