mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 00:49:46 +01:00
finished PropertyOverviewMenu
This commit is contained in:
parent
e000dcfc51
commit
12e859edd5
@ -81,6 +81,7 @@ public class BuildingAdminMenu extends Dialog {
|
||||
overviewButton.setPreferredSize(new Vector3f(200, 50, 0));
|
||||
overviewButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
new PropertyOverviewMenu(app).open();
|
||||
}));
|
||||
overviewColumn.addChild(overviewButton);
|
||||
|
||||
|
@ -12,8 +12,16 @@ import com.simsilica.lemur.style.ElementId;
|
||||
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.Field;
|
||||
import pp.monopoly.model.fields.FoodField;
|
||||
import pp.monopoly.model.fields.GateField;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -35,6 +43,10 @@ public class PropertyOverviewMenu extends Dialog {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
// Assign 10 random buildings to the player
|
||||
//TODO Aufruf für Demo löschen
|
||||
assignRandomPropertiesToPlayer();
|
||||
|
||||
// Make the menu fullscreen
|
||||
Vector3f screenSize = new Vector3f(app.getCamera().getWidth(), app.getCamera().getHeight(), 0);
|
||||
|
||||
@ -50,15 +62,13 @@ public class PropertyOverviewMenu extends Dialog {
|
||||
// Central display container (to hold the "Gebäude" cards)
|
||||
displayContainer = mainContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Even, FillMode.None))); // Horizontal layout
|
||||
displayContainer.setPreferredSize(new Vector3f(screenSize.x - 300, 550, 0)); // Take up the remaining width
|
||||
displayContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
|
||||
displayContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.White));
|
||||
displayContainer.setLocalTranslation(0, 0, 11);
|
||||
|
||||
// Add some placeholder "Gebäude" cards to the display container
|
||||
cards = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Container card = createGebäudeCard("Gebäude " + (i + 1), 320, 28);
|
||||
cards.add(card); // Keep track of cards for scrolling
|
||||
}
|
||||
populatePlayerProperties();
|
||||
|
||||
|
||||
// Initially add only visible cards to the displayContainer
|
||||
refreshVisibleCards(0);
|
||||
@ -85,23 +95,114 @@ public class PropertyOverviewMenu extends Dialog {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a "Gebäude" card container with the given information.
|
||||
*
|
||||
* @param title The title of the card (e.g., "Gebäude 1").
|
||||
* @param propertyValue The property value.
|
||||
* @param rent The rent amount.
|
||||
* @return A styled container representing a "Gebäude" card.
|
||||
* Fetches the player's properties and populates them into the cards list.
|
||||
*/
|
||||
private Container createGebäudeCard(String title, int propertyValue, int rent) {
|
||||
Container card = new Container();
|
||||
card.setPreferredSize(new Vector3f(150, 200, 2)); // Increase width and height for better visibility
|
||||
card.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
|
||||
private void populatePlayerProperties() {
|
||||
// Fetch the current player
|
||||
Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0);
|
||||
|
||||
card.addChild(new Label(title, new ElementId("card-label"))).setFontSize(14);
|
||||
card.addChild(new Label("Grundstückswert: €" + propertyValue, new ElementId("card-label"))).setFontSize(12);
|
||||
card.addChild(new Label("Miete allein: €" + rent, new ElementId("card-label"))).setFontSize(12);
|
||||
card.addChild(new Label("1 Haus: €50", new ElementId("card-label"))).setFontSize(12);
|
||||
card.addChild(new Label("Hypothekenwert: €160", new ElementId("card-label"))).setFontSize(12);
|
||||
// Iterate through the player's properties
|
||||
for (PropertyField property : currentPlayer.getProperties()) {
|
||||
if (property instanceof BuildingProperty) {
|
||||
BuildingProperty building = (BuildingProperty) property;
|
||||
cards.add(createBuildingCard(building));
|
||||
} else if (property instanceof FoodField) {
|
||||
FoodField foodField = (FoodField) property;
|
||||
cards.add(createFoodFieldCard(foodField));
|
||||
} else if (property instanceof GateField) {
|
||||
GateField gateField = (GateField) property;
|
||||
cards.add(createGateFieldCard(gateField));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a card for BuildingProperty with detailed rent and cost information.
|
||||
*/
|
||||
private Container createBuildingCard(BuildingProperty field) {
|
||||
Container card = new Container();
|
||||
card.setPreferredSize(new Vector3f(200, 300, 2)); // Match the size of the BuildingPropertyCard
|
||||
card.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||
card.setInsets(new Insets3f(5, 5, 5, 5)); // Add 5-pixel inset
|
||||
|
||||
card.addChild(new Label(field.getName(), new ElementId("label-Bold"))).setFontSize(25);
|
||||
|
||||
// Add property details
|
||||
Container propertyValuesContainer = card.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("Grundstückswert: €" + field.getPrice(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Miete allein: €" + field.getAllRent().get(0), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- mit 1 Haus: €" + field.getAllRent().get(1), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- mit 2 Häuser: €" + field.getAllRent().get(2), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- mit 3 Häuser: €" + field.getAllRent().get(3), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- mit 4 Häuser: €" + field.getAllRent().get(4), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- mit 1 Hotel: €" + field.getAllRent().get(5), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("- 1 Haus kostet: €" + field.getHousePrice(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Hypothek: €" + field.getHypo(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a card for FoodField with dynamic pricing and rent details.
|
||||
*/
|
||||
private Container createFoodFieldCard(FoodField field) {
|
||||
Container card = new Container();
|
||||
card.setPreferredSize(new Vector3f(200, 300, 2)); // Adjust card size
|
||||
card.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f))); // Dark background for card
|
||||
card.setInsets(new Insets3f(5, 5, 5, 5)); // Add 5-pixel inset
|
||||
|
||||
// Title Section
|
||||
Label title = card.addChild(new Label(field.getName(), new ElementId("label-Bold")));
|
||||
title.setFontSize(30);
|
||||
title.setColor(ColorRGBA.White); // Ensure readability on dark background
|
||||
|
||||
// Property Values Section
|
||||
Container propertyValuesContainer = card.addChild(new Container());
|
||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Grey background
|
||||
propertyValuesContainer.addChild(new Label("Preis: €" + field.getPrice(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Wenn man Besitzer des", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label(field.getName() + " ist,", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("so ist die Miete", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("40x Würfelwert.", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Besitzer beider", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("Restaurants zahlt", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("100x Würfelwert.", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Hypothek: €" + field.getHypo(), new ElementId("label-Text"))).setFontSize(14);
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a card for GateField with rent details for owning multiple gates.
|
||||
*/
|
||||
private Container createGateFieldCard(GateField field) {
|
||||
Container card = new Container();
|
||||
card.setPreferredSize(new Vector3f(200, 300, 2)); // Adjust card size
|
||||
card.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light grey background
|
||||
card.setInsets(new Insets3f(5, 5, 5, 5)); // Add 5-pixel inset
|
||||
|
||||
// Title Section
|
||||
Label title = card.addChild(new Label(field.getName(), new ElementId("label-Bold")));
|
||||
title.setFontSize(30);
|
||||
title.setColor(ColorRGBA.Black);
|
||||
|
||||
// Property Values Section
|
||||
Container propertyValuesContainer = card.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("Preis: €" + field.getPrice(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("1 Bahnhof: €250", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("2 Bahnhöfe: €500", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("3 Bahnhöfe: €1000", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("4 Bahnhöfe: €2000", new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("Hypothek: €" + field.getHypo(), new ElementId("label-Text"))).setFontSize(14);
|
||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Dark grey background
|
||||
|
||||
return card;
|
||||
}
|
||||
@ -119,6 +220,7 @@ public class PropertyOverviewMenu extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom listener for slider value changes.
|
||||
*/
|
||||
@ -145,4 +247,27 @@ public class PropertyOverviewMenu extends Dialog {
|
||||
app.getGuiNode().detachChild(mainContainer);
|
||||
super.close();
|
||||
}
|
||||
//TODO Demo Funktion nach implementierung löschen
|
||||
private void assignRandomPropertiesToPlayer() {
|
||||
// Get the board from the BoardManager
|
||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||
List<Field> fields = boardManager.getBoard();
|
||||
|
||||
// Filter for BuildingProperty, FoodField, and GateField
|
||||
List<PropertyField> propertyFields = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
if (field instanceof PropertyField) {
|
||||
propertyFields.add((PropertyField) field);
|
||||
}
|
||||
}
|
||||
|
||||
// Shuffle and select up to 10 properties (mix of BuildingProperty, FoodField, GateField)
|
||||
Collections.shuffle(propertyFields);
|
||||
List<PropertyField> randomProperties = propertyFields.subList(0, Math.min(10, propertyFields.size()));
|
||||
|
||||
// Assign the properties to the current player
|
||||
Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0);
|
||||
currentPlayer.getProperties().clear();
|
||||
currentPlayer.getProperties().addAll(randomProperties);
|
||||
}
|
||||
}
|
@ -132,7 +132,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
propertyMenuButton.setFontSize(30);
|
||||
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
new PropertyOverviewMenu(app).open();
|
||||
new BuildingAdminMenu(app).open();
|
||||
}));
|
||||
return propertyMenuButton;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user