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 87e082e..cff72f5 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 @@ -38,18 +38,7 @@ import static pp.monopoly.Resources.lookup; import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.StartMenu; import pp.monopoly.client.gui.TestWorld; -import pp.monopoly.client.gui.popups.Bankrupt; -import pp.monopoly.client.gui.popups.BuildingPropertyCard; -import pp.monopoly.client.gui.popups.BuyCard; -import pp.monopoly.client.gui.popups.BuyHouse; -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; -import pp.monopoly.client.gui.popups.RepayMortage; -import pp.monopoly.client.gui.popups.SellHouse; -import pp.monopoly.client.gui.popups.TakeMortage; -import pp.monopoly.client.gui.popups.TimeOut; +import pp.monopoly.client.gui.popups.*; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -139,7 +128,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private BuildingPropertyCard buildingProperty; private FoodFieldCard foodField; private GateFieldCard gateField; - private BuyCard buyCard; private LooserPopUp looserpopup; private Bankrupt bankrupt; private TimeOut timeOut; @@ -291,7 +279,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 FoodFieldCard(this); + Dialog tmp = new Gulag(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 1946792..49878dc 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 @@ -10,13 +10,7 @@ import com.jme3.renderer.ViewPort; import com.jme3.scene.control.AbstractControl; import pp.monopoly.client.MonopolyApp; -import pp.monopoly.client.gui.popups.BuyCard; -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; -import pp.monopoly.client.gui.popups.TimeOut; -import pp.monopoly.client.gui.popups.WinnerPopUp; +import pp.monopoly.client.gui.popups.*; import pp.monopoly.game.server.Player; import pp.monopoly.game.server.PlayerHandler; import pp.monopoly.model.fields.BuildingProperty; @@ -281,7 +275,7 @@ public class TestWorld implements GameEventListener { Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field); if (fieldObject instanceof BuildingProperty) { - new BuyCard(app).open(); + new BuildingPropertyCard(app).open(); } else if (fieldObject instanceof GateField) { new GateFieldCard(app).open(); } else if (fieldObject instanceof FoodField) { 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 858c32c..03bdb18 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 @@ -1,10 +1,7 @@ package pp.monopoly.client.gui.popups; -import com.jme3.material.Material; -import com.jme3.material.RenderState.BlendMode; import com.jme3.math.ColorRGBA; -import com.jme3.scene.Geometry; -import com.jme3.scene.shape.Quad; +import com.simsilica.lemur.Button; import com.simsilica.lemur.Container; import com.simsilica.lemur.Label; import com.simsilica.lemur.component.QuadBackgroundComponent; @@ -13,33 +10,31 @@ import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.gui.SettingsMenu; +import pp.monopoly.message.client.BuyPropertyResponse; +import pp.monopoly.model.fields.BoardManager; import pp.monopoly.model.fields.BuildingProperty; +import pp.monopoly.notification.Sound; /** * BuildingPropertyCard creates the popup for field information */ public class BuildingPropertyCard extends Dialog { private final MonopolyApp app; - private final Geometry overlayBackground; private final Container buildingPropertyContainer; private final Container backgroundContainer; - private int index = 37; public BuildingPropertyCard(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - //Generate the corresponfing field - BuildingProperty field = (BuildingProperty) app.getGameLogic().getBoardManager().getFieldAtIndex(index); - - // Halbtransparentes Overlay hinzufügen - overlayBackground = createOverlayBackground(); - app.getGuiNode().attachChild(overlayBackground); + //Generate the corresponding field + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).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 - app.getGuiNode().attachChild(backgroundContainer); + attachChild(backgroundContainer); // Hauptcontainer für die Gebäudekarte buildingPropertyContainer = new Container(); @@ -48,8 +43,9 @@ public class BuildingPropertyCard extends Dialog { 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"))); + //Titel + Label settingsTitle = buildingPropertyContainer.addChild(new Label( field.getName(), new ElementId("label-Bold"))); + settingsTitle.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); settingsTitle.setFontSize(48); // Text, der auf der Karte steht @@ -68,6 +64,23 @@ 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))); + // Beenden-Button + Button quitButton = buildingPropertyContainer.addChild(new Button("Beenden", new ElementId("button"))); + quitButton.setFontSize(32); + quitButton.addClickCommands(s -> ifTopDialog(() -> { + System.err.println("Button does something?"); + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); + // Kaufen-Button + Button buyButton = buildingPropertyContainer.addChild(new Button("Kaufen", new ElementId("button"))); + buyButton.setFontSize(32); + buyButton.addClickCommands(s -> ifTopDialog( () -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + app.getGameLogic().send(new BuyPropertyResponse()); + })); + // Zentriere das Popup buildingPropertyContainer.setLocalTranslation( (app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x) / 2, @@ -85,22 +98,6 @@ public class BuildingPropertyCard extends Dialog { app.getGuiNode().attachChild(buildingPropertyContainer); } - /** - * Erstellt einen halbtransparenten Hintergrund für das Menü. - * - * @return Geometrie des Overlays - */ - private Geometry createOverlayBackground() { - Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); - Geometry overlay = new Geometry("Overlay", quad); - Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent - material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); - overlay.setMaterial(material); - overlay.setLocalTranslation(0, 0, 0); - return overlay; - } - /** * Schließt das Menü und entfernt die GUI-Elemente. */ @@ -108,16 +105,11 @@ public class BuildingPropertyCard extends Dialog { public void close() { app.getGuiNode().detachChild(buildingPropertyContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand - app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay super.close(); } - - public void setIndex(int index) { - this.index = index; - } @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/BuyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java deleted file mode 100644 index 7e363e0..0000000 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java +++ /dev/null @@ -1,115 +0,0 @@ -package pp.monopoly.client.gui.popups; - -import com.jme3.math.ColorRGBA; -import com.simsilica.lemur.Button; -import com.simsilica.lemur.Container; -import com.simsilica.lemur.Label; -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.message.client.BuyPropertyResponse; -import pp.monopoly.model.fields.BoardManager; -import pp.monopoly.model.fields.BuildingProperty; -import pp.monopoly.notification.Sound; - -/** - * 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; - private final Container buyCardContainer; - private final Container backgroundContainer; - - - public BuyCard(MonopolyApp app) { - super(app.getDialogManager()); - this.app = app; - - //Generate the corresponding field - int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).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 - buyCardContainer = new Container(); - buyCardContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); // Ändert den Rahmen und die Hintergrundfarbe der Karten - - 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 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"))); - propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile - propertyValuesContainer.addChild(new Label("„Miete allein: " + field.getAllRent().get(0)+ " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-mit 1 Haus: " + field.getAllRent().get(1) + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-mit 2 Häuser: " + field.getAllRent().get(2) + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-mit 3 Häuser: " + field.getAllRent().get(3) + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-mit 4 Häuser: " + field.getAllRent().get(4) + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-mit 1 Hotel: " + field.getAllRent().get(5) + " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("„-1 Haus kostet: " + field.getHousePrice()+ " EUR", new ElementId("label-Text"))); - propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile - 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))); - - // Beenden-Button - Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button"))); - quitButton.setFontSize(32); - quitButton.addClickCommands(s -> ifTopDialog(() -> { - System.err.println("Button does something?"); - app.getGameLogic().playSound(Sound.BUTTON); - close(); - })); - // Kaufen-Button - Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button"))); - buyButton.setFontSize(32); - buyButton.addClickCommands(s -> ifTopDialog( () -> { - app.getGameLogic().playSound(Sound.BUTTON); - close(); - app.getGameLogic().send(new BuyPropertyResponse()); - })); - - // Zentriere das Popup - buyCardContainer.setLocalTranslation( - (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x) / 2, - (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y) / 2, - 10 - ); - - // Zentriere das Popup - backgroundContainer.setLocalTranslation( - (app.getCamera().getWidth() - buyCardContainer.getPreferredSize().x - padding) / 2, - (app.getCamera().getHeight() + buyCardContainer.getPreferredSize().y+ padding) / 2, - 9 - ); - - app.getGuiNode().attachChild(buyCardContainer); - } - - /** - * Schließt das Menü und entfernt die GUI-Elemente. - */ - @Override - public void close() { - app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü - app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand - super.close(); - } - - @Override - public void escape() { - new SettingsMenu(app).open(); - } -} 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 d35a2e7..e0146c4 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 @@ -42,7 +42,7 @@ public class FoodFieldCard extends Dialog { // Create the background container backgroundContainer = new Container(); backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background - app.getGuiNode().attachChild(backgroundContainer); + attachChild(backgroundContainer); // Hauptcontainer für die Gebäudekarte foodFieldContainer = new Container(); @@ -52,11 +52,12 @@ public class FoodFieldCard extends Dialog { 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"))); + Label settingsTitle = foodFieldContainer.addChild(new Label(field.getName(), new ElementId("label-Bold"))); settingsTitle.setFontSize(48); settingsTitle.setColor(ColorRGBA.White); // Text, der auf der Karte steht + // Die Preise werden dynamisch dem BoardManager entnommen Container propertyValuesContainer = foodFieldContainer.addChild(new Container()); propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile 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 2e4c2b3..cb81049 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 @@ -22,7 +22,6 @@ import pp.monopoly.notification.Sound; */ public class GateFieldCard extends Dialog { private final MonopolyApp app; - private final Geometry overlayBackground; private final Container gateFieldContainer; private final Container backgroundContainer; @@ -34,14 +33,10 @@ public class GateFieldCard extends Dialog { int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); GateField field = (GateField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); - // Halbtransparentes Overlay hinzufügen - overlayBackground = createOverlayBackground(); - app.getGuiNode().attachChild(overlayBackground); - // Create the background container backgroundContainer = new Container(); backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background - app.getGuiNode().attachChild(backgroundContainer); + attachChild(backgroundContainer); // Hauptcontainer für die Gebäudekarte gateFieldContainer = new Container(); @@ -51,9 +46,9 @@ public class GateFieldCard extends Dialog { backgroundContainer.setPreferredSize(gateFieldContainer.getPreferredSize().addLocal(padding, padding, 0)); // Titel, bestehend aus dynamischen Namen anhand der ID und der Schriftfarbe/größe - Label gateFieldTitle = gateFieldContainer.addChild(new Label(field.getName(), new ElementId("settings-title"))); + Label gateFieldTitle = gateFieldContainer.addChild(new Label(field.getName(), new ElementId("label-Bold"))); gateFieldTitle.setFontSize(48); - gateFieldTitle.setColor(ColorRGBA.White); + gateFieldTitle.setColor(ColorRGBA.Black); // Text, der auf der Karte steht // Die Preise werden dynamisch dem BoardManager entnommen @@ -89,9 +84,9 @@ public class GateFieldCard extends Dialog { // Zentriere das Popup gateFieldContainer.setLocalTranslation( - (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x) / 2, - (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y) / 2, - 8 + (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x) / 2, + (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y) / 2, + 8 ); // Zentriere das Popup @@ -127,7 +122,6 @@ public class GateFieldCard extends Dialog { public void close() { app.getGuiNode().detachChild(gateFieldContainer); // Entferne das Menü app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand - app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay super.close(); }