mirror of
				https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
				synced 2025-11-03 23:25:52 +01:00 
			
		
		
		
	BuyHouse, RepayMortage und TakeMortage erstellt
This commit is contained in:
		@@ -131,6 +131,12 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
 | 
				
			|||||||
    private BuyCard buyCard;
 | 
					    private BuyCard buyCard;
 | 
				
			||||||
    private LooserPopUp looserpopup;
 | 
					    private LooserPopUp looserpopup;
 | 
				
			||||||
    private Bankrupt bankrupt;
 | 
					    private Bankrupt bankrupt;
 | 
				
			||||||
 | 
					    private TimeOut timeOut;
 | 
				
			||||||
 | 
					    private SellHouse sellHouse;
 | 
				
			||||||
 | 
					    private BuyHouse buyHouse;
 | 
				
			||||||
 | 
					    private TakeMortage takeMortage;
 | 
				
			||||||
 | 
					    private RepayMortage repayMortage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isBuyCardPopupOpen = false;
 | 
					    private boolean isBuyCardPopupOpen = false;
 | 
				
			||||||
    private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed);
 | 
					    private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed);
 | 
				
			||||||
    private TestWorld testWorld;
 | 
					    private TestWorld testWorld;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,155 @@
 | 
				
			|||||||
 | 
					package pp.monopoly.client.gui.popups;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.math.ColorRGBA;
 | 
				
			||||||
 | 
					import com.jme3.math.Vector3f;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Button;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Container;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Label;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.ListBox;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.core.VersionedList;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.style.ElementId;
 | 
				
			||||||
 | 
					import pp.dialog.Dialog;
 | 
				
			||||||
 | 
					import pp.monopoly.client.MonopolyApp;
 | 
				
			||||||
 | 
					import pp.monopoly.client.gui.SettingsMenu;
 | 
				
			||||||
 | 
					import pp.monopoly.game.server.Player;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BoardManager;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BuildingProperty;
 | 
				
			||||||
 | 
					import pp.monopoly.notification.Sound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * BuyHouse is a popup which appears when a player clicks on the "Buy House"-button in the BuildingAdminMenu
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class BuyHouse extends Dialog {
 | 
				
			||||||
 | 
					    private final MonopolyApp app;
 | 
				
			||||||
 | 
					    private final Container buyHouseContainer;
 | 
				
			||||||
 | 
					    private final Container backgroundContainer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public BuyHouse(MonopolyApp app) {
 | 
				
			||||||
 | 
					        super(app.getDialogManager());
 | 
				
			||||||
 | 
					        this.app = app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 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 das Menü
 | 
				
			||||||
 | 
					        buyHouseContainer = new Container();
 | 
				
			||||||
 | 
					        buyHouseContainer.setPreferredSize(new Vector3f(800, 600, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float padding = 10; // Passt den backgroundContainer an die Größe des sellhouseContainers an
 | 
				
			||||||
 | 
					        backgroundContainer.setPreferredSize(buyHouseContainer.getPreferredSize().addLocal(padding, padding, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Titel
 | 
				
			||||||
 | 
					        Label title = buyHouseContainer.addChild(new Label( "Gebäude Kaufen", new ElementId("warining-Bold")));
 | 
				
			||||||
 | 
					        title.setFontSize(48);
 | 
				
			||||||
 | 
					        title.setColor(ColorRGBA.Black);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Unterteilund des sellHouseContainer in drei "Untercontainer"
 | 
				
			||||||
 | 
					        Container upContainer = buyHouseContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container middleContainer = buyHouseContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container downContainer = buyHouseContainer.addChild(new Container());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Text, der auf der Karte steht
 | 
				
			||||||
 | 
					        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<BuildingProperty> listModel = new VersionedList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Retrieve current player and their properties //TODO hier Prüfen, ob abweichungen zur SellHouse-Klasse beachtet werden müssen
 | 
				
			||||||
 | 
					        Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
 | 
				
			||||||
 | 
					        BoardManager boardManager = app.getGameLogic().getBoardManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<BuildingProperty> playerProperties = boardManager.getPropertyFields(
 | 
				
			||||||
 | 
					                                                                      currentPlayer.getProperties()).stream()
 | 
				
			||||||
 | 
					                                                              .filter(property -> property instanceof BuildingProperty)
 | 
				
			||||||
 | 
					                                                              .map(property -> (BuildingProperty) property)
 | 
				
			||||||
 | 
					                                                              .filter(property -> property.getHouses() > 0 || property.getHotel() == 1)
 | 
				
			||||||
 | 
					                                                              .collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Populate the list model
 | 
				
			||||||
 | 
					        listModel.addAll(playerProperties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Create a ListBox with the "glass" style and the model
 | 
				
			||||||
 | 
					        ListBox<BuildingProperty> listBox = new ListBox<>(listModel, "glass");
 | 
				
			||||||
 | 
					        listBox.setPreferredSize(new Vector3f(300, 200, 0)); // Adjust size as needed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add selection listener
 | 
				
			||||||
 | 
					        listBox.addClickCommands(item -> {
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem(); // Correct method to retrieve the selected item
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Selected property: " + selected.getName());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add the ListBox to the middle container
 | 
				
			||||||
 | 
					        middleContainer.addChild(listBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Erstattung:", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Hier die tätsächliche Erstattung", new ElementId("label-Text")));
 | 
				
			||||||
 | 
					        downContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Beenden-Button
 | 
				
			||||||
 | 
					        Button cancelButton = buyHouseContainer.addChild(new Button("Abbrechen", new ElementId("button")));
 | 
				
			||||||
 | 
					        cancelButton.setFontSize(32);
 | 
				
			||||||
 | 
					        cancelButton.addClickCommands(s -> ifTopDialog(() -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            close();
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					        // Kaufen-Button
 | 
				
			||||||
 | 
					        Button confirmButton = buyHouseContainer.addChild(new Button("Bestätigen", new ElementId("button")));
 | 
				
			||||||
 | 
					        confirmButton.setFontSize(32);
 | 
				
			||||||
 | 
					        confirmButton.addClickCommands(s -> ifTopDialog( () -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem();
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Confirmed property: " + selected.getName());
 | 
				
			||||||
 | 
					                // Send the "alter building" message to the server
 | 
				
			||||||
 | 
					               //app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        buyHouseContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					            (app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x) / 2,
 | 
				
			||||||
 | 
					            (app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y) / 2,
 | 
				
			||||||
 | 
					            8
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        backgroundContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					                (app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x - padding) / 2,
 | 
				
			||||||
 | 
					                (app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y+ padding) / 2,
 | 
				
			||||||
 | 
					                7
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        app.getGuiNode().attachChild(buyHouseContainer);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Schließt das Menü und entfernt die GUI-Elemente.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void close() {
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(buyHouseContainer);  // Entferne das Menü
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
 | 
				
			||||||
 | 
					        super.close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void escape() {
 | 
				
			||||||
 | 
					        new SettingsMenu(app).open();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,155 @@
 | 
				
			|||||||
 | 
					package pp.monopoly.client.gui.popups;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.math.ColorRGBA;
 | 
				
			||||||
 | 
					import com.jme3.math.Vector3f;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Button;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Container;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Label;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.ListBox;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.core.VersionedList;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.style.ElementId;
 | 
				
			||||||
 | 
					import pp.dialog.Dialog;
 | 
				
			||||||
 | 
					import pp.monopoly.client.MonopolyApp;
 | 
				
			||||||
 | 
					import pp.monopoly.client.gui.SettingsMenu;
 | 
				
			||||||
 | 
					import pp.monopoly.game.server.Player;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BoardManager;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BuildingProperty;
 | 
				
			||||||
 | 
					import pp.monopoly.notification.Sound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * RepayMortage is a popup which appears when a player clicks on the "Repay Mortage"-button in the BuildingAdminMenu
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class RepayMortage extends Dialog {
 | 
				
			||||||
 | 
					    private final MonopolyApp app;
 | 
				
			||||||
 | 
					    private final Container repayMortageContainer;
 | 
				
			||||||
 | 
					    private final Container backgroundContainer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RepayMortage(MonopolyApp app) {
 | 
				
			||||||
 | 
					        super(app.getDialogManager());
 | 
				
			||||||
 | 
					        this.app = app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 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 das Menü
 | 
				
			||||||
 | 
					        repayMortageContainer = new Container();
 | 
				
			||||||
 | 
					        repayMortageContainer.setPreferredSize(new Vector3f(800, 600, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float padding = 10; // Passt den backgroundContainer an die Größe des sellhouseContainers an
 | 
				
			||||||
 | 
					        backgroundContainer.setPreferredSize(repayMortageContainer.getPreferredSize().addLocal(padding, padding, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Titel
 | 
				
			||||||
 | 
					        Label title = repayMortageContainer.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 = repayMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container middleContainer = repayMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container downContainer = repayMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Text, der auf der Karte steht
 | 
				
			||||||
 | 
					        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<BuildingProperty> listModel = new VersionedList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Retrieve current player and their properties //TODO hier Prüfen, ob abweichungen zur SellHouse-Klasse beachtet werden müssen
 | 
				
			||||||
 | 
					        Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
 | 
				
			||||||
 | 
					        BoardManager boardManager = app.getGameLogic().getBoardManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<BuildingProperty> playerProperties = boardManager.getPropertyFields(
 | 
				
			||||||
 | 
					                                                                      currentPlayer.getProperties()).stream()
 | 
				
			||||||
 | 
					                                                              .filter(property -> property instanceof BuildingProperty)
 | 
				
			||||||
 | 
					                                                              .map(property -> (BuildingProperty) property)
 | 
				
			||||||
 | 
					                                                              .filter(property -> property.getHouses() > 0 || property.getHotel() == 1)
 | 
				
			||||||
 | 
					                                                              .collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Populate the list model
 | 
				
			||||||
 | 
					        listModel.addAll(playerProperties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Create a ListBox with the "glass" style and the model
 | 
				
			||||||
 | 
					        ListBox<BuildingProperty> listBox = new ListBox<>(listModel, "glass");
 | 
				
			||||||
 | 
					        listBox.setPreferredSize(new Vector3f(300, 200, 0)); // Adjust size as needed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add selection listener
 | 
				
			||||||
 | 
					        listBox.addClickCommands(item -> {
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem(); // Correct method to retrieve the selected item
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Selected property: " + selected.getName());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add the ListBox to the middle container
 | 
				
			||||||
 | 
					        middleContainer.addChild(listBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Erstattung:", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Hier die tätsächliche Erstattung", new ElementId("label-Text")));
 | 
				
			||||||
 | 
					        downContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Beenden-Button
 | 
				
			||||||
 | 
					        Button cancelButton = repayMortageContainer.addChild(new Button("Abbrechen", new ElementId("button")));
 | 
				
			||||||
 | 
					        cancelButton.setFontSize(32);
 | 
				
			||||||
 | 
					        cancelButton.addClickCommands(s -> ifTopDialog(() -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            close();
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					        // Kaufen-Button
 | 
				
			||||||
 | 
					        Button confirmButton = repayMortageContainer.addChild(new Button("Bestätigen", new ElementId("button")));
 | 
				
			||||||
 | 
					        confirmButton.setFontSize(32);
 | 
				
			||||||
 | 
					        confirmButton.addClickCommands(s -> ifTopDialog( () -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem();
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Confirmed property: " + selected.getName());
 | 
				
			||||||
 | 
					                // Send the "alter building" message to the server
 | 
				
			||||||
 | 
					               //app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        repayMortageContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					            (app.getCamera().getWidth() - repayMortageContainer.getPreferredSize().x) / 2,
 | 
				
			||||||
 | 
					            (app.getCamera().getHeight() + repayMortageContainer.getPreferredSize().y) / 2,
 | 
				
			||||||
 | 
					            8
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        backgroundContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					                (app.getCamera().getWidth() - repayMortageContainer.getPreferredSize().x - padding) / 2,
 | 
				
			||||||
 | 
					                (app.getCamera().getHeight() + repayMortageContainer.getPreferredSize().y+ padding) / 2,
 | 
				
			||||||
 | 
					                7
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        app.getGuiNode().attachChild(repayMortageContainer);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Schließt das Menü und entfernt die GUI-Elemente.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void close() {
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(repayMortageContainer);  // Entferne das Menü
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
 | 
				
			||||||
 | 
					        super.close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void escape() {
 | 
				
			||||||
 | 
					        new SettingsMenu(app).open();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -25,7 +25,7 @@ import java.util.List;
 | 
				
			|||||||
import java.util.stream.Collectors;
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * SellHouse is a popup which appears when a player clicks on the demolish-button in the BuildingAdminMenu
 | 
					 * SellHouse is a popup which appears when a player clicks on the "demolish"-button in the BuildingAdminMenu
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class SellHouse extends Dialog {
 | 
					public class SellHouse extends Dialog {
 | 
				
			||||||
    private final MonopolyApp app;
 | 
					    private final MonopolyApp app;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,155 @@
 | 
				
			|||||||
 | 
					package pp.monopoly.client.gui.popups;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.math.ColorRGBA;
 | 
				
			||||||
 | 
					import com.jme3.math.Vector3f;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Button;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Container;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Label;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.ListBox;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.core.VersionedList;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.style.ElementId;
 | 
				
			||||||
 | 
					import pp.dialog.Dialog;
 | 
				
			||||||
 | 
					import pp.monopoly.client.MonopolyApp;
 | 
				
			||||||
 | 
					import pp.monopoly.client.gui.SettingsMenu;
 | 
				
			||||||
 | 
					import pp.monopoly.game.server.Player;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BoardManager;
 | 
				
			||||||
 | 
					import pp.monopoly.model.fields.BuildingProperty;
 | 
				
			||||||
 | 
					import pp.monopoly.notification.Sound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * TakeMortage is a popup which appears when a player clicks on the "TakeMortage"-button in the BuildingAdminMenu
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TakeMortage extends Dialog {
 | 
				
			||||||
 | 
					    private final MonopolyApp app;
 | 
				
			||||||
 | 
					    private final Container takeMortageContainer;
 | 
				
			||||||
 | 
					    private final Container backgroundContainer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public TakeMortage(MonopolyApp app) {
 | 
				
			||||||
 | 
					        super(app.getDialogManager());
 | 
				
			||||||
 | 
					        this.app = app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 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 das Menü
 | 
				
			||||||
 | 
					        takeMortageContainer = new Container();
 | 
				
			||||||
 | 
					        takeMortageContainer.setPreferredSize(new Vector3f(800, 600, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float padding = 10; // Passt den backgroundContainer an die Größe des sellhouseContainers an
 | 
				
			||||||
 | 
					        backgroundContainer.setPreferredSize(takeMortageContainer.getPreferredSize().addLocal(padding, padding, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Titel
 | 
				
			||||||
 | 
					        Label title = takeMortageContainer.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 = takeMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container middleContainer = takeMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					        Container downContainer = takeMortageContainer.addChild(new Container());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Text, der auf der Karte steht
 | 
				
			||||||
 | 
					        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<BuildingProperty> listModel = new VersionedList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Retrieve current player and their properties //TODO hier Prüfen, ob abweichungen zur SellHouse-Klasse beachtet werden müssen
 | 
				
			||||||
 | 
					        Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
 | 
				
			||||||
 | 
					        BoardManager boardManager = app.getGameLogic().getBoardManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<BuildingProperty> playerProperties = boardManager.getPropertyFields(
 | 
				
			||||||
 | 
					                                                                      currentPlayer.getProperties()).stream()
 | 
				
			||||||
 | 
					                                                              .filter(property -> property instanceof BuildingProperty)
 | 
				
			||||||
 | 
					                                                              .map(property -> (BuildingProperty) property)
 | 
				
			||||||
 | 
					                                                              .filter(property -> property.getHouses() > 0 || property.getHotel() == 1)
 | 
				
			||||||
 | 
					                                                              .collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Populate the list model
 | 
				
			||||||
 | 
					        listModel.addAll(playerProperties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Create a ListBox with the "glass" style and the model
 | 
				
			||||||
 | 
					        ListBox<BuildingProperty> listBox = new ListBox<>(listModel, "glass");
 | 
				
			||||||
 | 
					        listBox.setPreferredSize(new Vector3f(300, 200, 0)); // Adjust size as needed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add selection listener
 | 
				
			||||||
 | 
					        listBox.addClickCommands(item -> {
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem(); // Correct method to retrieve the selected item
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Selected property: " + selected.getName());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Add the ListBox to the middle container
 | 
				
			||||||
 | 
					        middleContainer.addChild(listBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Erstattung:", new ElementId("label-Text")));// Leerzeile
 | 
				
			||||||
 | 
					        downContainer.addChild(new Label("Hier die tätsächliche Erstattung", new ElementId("label-Text")));
 | 
				
			||||||
 | 
					        downContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Beenden-Button
 | 
				
			||||||
 | 
					        Button cancelButton = takeMortageContainer.addChild(new Button("Abbrechen", new ElementId("button")));
 | 
				
			||||||
 | 
					        cancelButton.setFontSize(32);
 | 
				
			||||||
 | 
					        cancelButton.addClickCommands(s -> ifTopDialog(() -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            close();
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					        // Kaufen-Button
 | 
				
			||||||
 | 
					        Button confirmButton = takeMortageContainer.addChild(new Button("Bestätigen", new ElementId("button")));
 | 
				
			||||||
 | 
					        confirmButton.setFontSize(32);
 | 
				
			||||||
 | 
					        confirmButton.addClickCommands(s -> ifTopDialog( () -> {
 | 
				
			||||||
 | 
					            app.getGameLogic().playSound(Sound.BUTTON);
 | 
				
			||||||
 | 
					            BuildingProperty selected = listBox.getSelectedItem();
 | 
				
			||||||
 | 
					            if (selected != null) {
 | 
				
			||||||
 | 
					                System.out.println("Confirmed property: " + selected.getName());
 | 
				
			||||||
 | 
					                // Send the "alter building" message to the server
 | 
				
			||||||
 | 
					               //app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        takeMortageContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					            (app.getCamera().getWidth() - takeMortageContainer.getPreferredSize().x) / 2,
 | 
				
			||||||
 | 
					            (app.getCamera().getHeight() + takeMortageContainer.getPreferredSize().y) / 2,
 | 
				
			||||||
 | 
					            8
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Zentriere das Popup
 | 
				
			||||||
 | 
					        backgroundContainer.setLocalTranslation(
 | 
				
			||||||
 | 
					                (app.getCamera().getWidth() - takeMortageContainer.getPreferredSize().x - padding) / 2,
 | 
				
			||||||
 | 
					                (app.getCamera().getHeight() + takeMortageContainer.getPreferredSize().y+ padding) / 2,
 | 
				
			||||||
 | 
					                7
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        app.getGuiNode().attachChild(takeMortageContainer);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Schließt das Menü und entfernt die GUI-Elemente.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void close() {
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(takeMortageContainer);  // Entferne das Menü
 | 
				
			||||||
 | 
					        app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
 | 
				
			||||||
 | 
					        super.close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void escape() {
 | 
				
			||||||
 | 
					        new SettingsMenu(app).open();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user