Compare commits

..

No commits in common. "45a43d6998cf164e0296ab1320bffee994007361" and "8d087a8e84b43948c638ea6c9e8678bc08c954d4" have entirely different histories.

7 changed files with 156 additions and 115 deletions

View File

@ -1,11 +1,7 @@
package pp.monopoly.client.gui;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.*;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
@ -14,10 +10,15 @@ import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
/**
* Represents a dialog for managing properties in the Monopoly game.
* Allows users to view properties, build, demolish, and manage mortgages.
*/
public class BuildingAdminMenu extends Dialog {
private final MonopolyApp app;
private final Container mainContainer;
// Buttons
private final Button backButton = new Button("Zurück");
private final Button buildButton = new Button("Bauen");
private final Button demolishButton = new Button("Abriss");
@ -25,135 +26,156 @@ public class BuildingAdminMenu extends Dialog {
private final Button payMortgageButton = new Button("Hypothek bezahlen");
private final Button overviewButton = new Button("Übersicht");
/**
* Constructs the BuildingAdminMenu dialog.
*
* @param app The Monopoly application instance.
*/
public BuildingAdminMenu(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Background Image
addBackgroundImage();
// Main container for the UI components
// Configure the main container
mainContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
mainContainer.setPreferredSize(new Vector3f(800, 600, 0));
mainContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), app.getCamera().getHeight(), 0));
mainContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 0.7f))); // Translucent white background
// Add header
mainContainer.addChild(createHeaderContainer());
// Add content
mainContainer.addChild(createContent());
// Attach main container to GUI node
// Add the header
addHeader("Grundstücke Verwalten");
// Add content (Overview, Build, and Mortgage columns)
addContent();
// Attach main container to the GUI node
app.getGuiNode().attachChild(mainContainer);
mainContainer.setLocalTranslation(
(app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2,
7
);
mainContainer.setLocalTranslation(0, app.getCamera().getHeight(), 7); // Full screen
}
/**
* Creates the header container.
* Adds the header section to the main container.
*
* @return The header container.
* @param title The title text for the header.
*/
private Container createHeaderContainer() {
private void addHeader(String title) {
Container headerContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
headerContainer.setPreferredSize(new Vector3f(800, 100, 0));
Label headerLabel = headerContainer.addChild(new Label("Grundstücke Verwalten", new ElementId("header")));
headerLabel.setFontSize(45);
headerContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 100, 0));
Label headerLabel = headerContainer.addChild(new Label(title, new ElementId("header")));
headerLabel.setFontSize(40);
headerLabel.setInsets(new Insets3f(10, 10, 10, 10));
return headerContainer;
mainContainer.addChild(headerContainer);
}
/**
* Creates the main content container with columns for Overview, Build, and Mortgage.
*
* @return The content container.
* Adds the main content, organized into columns for Overview, Build, and Mortgage management.
*/
private Container createContent() {
private void addContent() {
Container contentContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
contentContainer.setPreferredSize(new Vector3f(800, 500, 0));
contentContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), app.getCamera().getHeight() - 100, 0));
// Overview Column
Container overviewColumn = new Container(new SpringGridLayout(Axis.Y, Axis.X));
overviewColumn.addChild(new Label("Übersicht:")).setFontSize(30);
overviewButton.setPreferredSize(new Vector3f(200, 50, 0));
overviewButton.addClickCommands(s -> ifTopDialog(() -> {
overviewColumn.addChild(new Label("Übersicht:")).setFontSize(24);
overviewColumn.addChild(createButtonContainer(overviewButton, "Übersicht", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
handleOverview();
}));
overviewColumn.addChild(overviewButton);
// Back Button
backButton.setPreferredSize(new Vector3f(200, 50, 0));
backButton.addClickCommands(s -> ifTopDialog(() -> {
overviewColumn.addChild(createButtonContainer(backButton, "Zurück", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
this.close();
handleBack();
}));
overviewColumn.addChild(backButton);
contentContainer.addChild(overviewColumn);
// Build Column
Container buildColumn = new Container(new SpringGridLayout(Axis.Y, Axis.X));
buildColumn.addChild(new Label("Bauen:")).setFontSize(30);
buildButton.setPreferredSize(new Vector3f(200, 50, 0));
buildButton.addClickCommands(s -> ifTopDialog(() -> {
buildColumn.addChild(new Label("Bauen:")).setFontSize(24);
buildColumn.addChild(createButtonContainer(buildButton, "Bauen", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
handleBuild();
}));
buildColumn.addChild(buildButton);
demolishButton.setPreferredSize(new Vector3f(200, 50, 0));
demolishButton.addClickCommands(s -> ifTopDialog(() -> {
buildColumn.addChild(createButtonContainer(demolishButton, "Abriss", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
handleDemolish();
}));
buildColumn.addChild(demolishButton);
contentContainer.addChild(buildColumn);
// Mortgage Column
Container mortgageColumn = new Container(new SpringGridLayout(Axis.Y, Axis.X));
mortgageColumn.addChild(new Label("Hypotheken:")).setFontSize(30);
takeMortgageButton.setPreferredSize(new Vector3f(200, 50, 0));
takeMortgageButton.addClickCommands(s -> ifTopDialog(() -> {
mortgageColumn.addChild(new Label("Hypotheken:")).setFontSize(24);
mortgageColumn.addChild(createButtonContainer(takeMortgageButton, "Hypothek aufnehmen", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
handleTakeMortgage();
}));
mortgageColumn.addChild(takeMortgageButton);
payMortgageButton.setPreferredSize(new Vector3f(200, 50, 0));
payMortgageButton.addClickCommands(s -> ifTopDialog(() -> {
mortgageColumn.addChild(createButtonContainer(payMortgageButton, "Hypothek bezahlen", () -> {
app.getGameLogic().playSound(Sound.BUTTON);
handlePayMortgage();
}));
mortgageColumn.addChild(payMortgageButton);
// Add all columns to the content container
contentContainer.addChild(overviewColumn);
contentContainer.addChild(buildColumn);
contentContainer.addChild(mortgageColumn);
return contentContainer;
mainContainer.addChild(contentContainer);
}
/**
* Adds a background image to the dialog.
* Creates a button within a dedicated container.
*
* @param button The button to configure.
* @param label The button label.
* @param action The action to perform when the button is clicked.
* @return The container containing the button.
*/
private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, 6); // Position behind other GUI elements
app.getGuiNode().attachChild(background);
private Container createButtonContainer(Button button, String label, Runnable action) {
Container buttonContainer = new Container();
button.setText(label);
button.setPreferredSize(new Vector3f(200, 60, 0));
button.setFontSize(30); // Larger font size for better visibility
button.addClickCommands(source -> ifTopDialog(action));
buttonContainer.setPreferredSize(new Vector3f(200, 60, 0)); // Ensuring container matches button size
buttonContainer.addChild(button);
return buttonContainer;
}
/**
* Handles the "Bauen" action.
*/
private void handleBuild() {
// Implement build logic
}
/**
* Handles the "Abriss" action.
*/
private void handleDemolish() {
// Implement demolish logic
}
/**
* Handles the "Hypothek aufnehmen" action.
*/
private void handleTakeMortgage() {
// Implement take mortgage logic
}
/**
* Handles the "Hypothek bezahlen" action.
*/
private void handlePayMortgage() {
// Implement pay mortgage logic
}
/**
* Handles the "Übersicht" action.
*/
private void handleOverview() {
// Implement overview logic
}
/**
* Handles the "Zurück" action.
*/
private void handleBack() {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}
@ -166,4 +188,4 @@ public class BuildingAdminMenu extends Dialog {
public void update(float delta) {
// Periodic updates if necessary
}
}
}

View File

@ -66,7 +66,7 @@ public class CreateGameMenu extends Dialog {
final MonopolyApp app = network.getApp();
int screenWidth = app.getContext().getSettings().getWidth();
int screenWidth = app.getContext().getSettings().getWidth();
int screenHeight = app.getContext().getSettings().getHeight();
// Set up the background image

View File

@ -1,6 +1,10 @@
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;
@ -9,7 +13,6 @@ 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.BuyPropertyRequest;
import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.model.fields.BuildingProperty;
import pp.monopoly.notification.Sound;
@ -22,13 +25,13 @@ public class BuyCard extends Dialog {
private final Container buyCardContainer;
private final Container backgroundContainer;
private int index = 37;
public BuyCard(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
//Generate the corresponfing field
int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index);
// Create the background container
@ -72,7 +75,7 @@ public class BuyCard extends Dialog {
buyButton.setFontSize(32);
buyButton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new BuyPropertyRequest());
//TODO send buy property request
}));
float padding = 10; // Padding around the settingsContainer for the background

View File

@ -65,6 +65,11 @@ public class EventCard extends Dialog {
quitButton.setFontSize(32);
quitButton.addClickCommands(source -> close());
// TODO Kaufen-Button wird nicht mehr benötigt, prüfen ob weg kann
//Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button")));
//buyButton.setFontSize(32);
float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(eventCardContainer.getPreferredSize().addLocal(padding, padding, 0));

View File

@ -5,7 +5,6 @@ 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;
@ -14,9 +13,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.message.client.BuyPropertyRequest;
import pp.monopoly.model.fields.FoodField;
import pp.monopoly.notification.Sound;
/**
* FoodFieldCard erstellt die Geböudekarte vom Brandl und der Truppenküche
@ -26,13 +23,13 @@ public class FoodFieldCard extends Dialog {
private final Geometry overlayBackground;
private final Container foodFieldContainer;
private final Container backgroundContainer;
private int index = 12;
public FoodFieldCard(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
//Generate the corresponfing field
int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
// Halbtransparentes Overlay hinzufügen
@ -71,24 +68,22 @@ public class FoodFieldCard 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)));
//TODO eventuell diese Stelle löschen, da nur die BuyCard Kaufen und beenden hat
/*
// Beenden-Button
Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
// Kaufen-Button
Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32);
buyButton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new BuyPropertyRequest());
}));
*/
float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(foodFieldContainer.getPreferredSize().addLocal(padding, padding, 0));
// Zentriere das Menü
foodFieldContainer.setLocalTranslation(
(app.getCamera().getWidth() - foodFieldContainer.getPreferredSize().x) / 2,
@ -132,6 +127,10 @@ public class FoodFieldCard extends Dialog {
super.close();
}
public void setIndex(int index) {
this.index = index;
}
@Override
public void escape() {
new SettingsMenu(app).open();

View File

@ -5,7 +5,6 @@ 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,9 +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.message.client.BuyPropertyRequest;
import pp.monopoly.model.fields.GateField;
import pp.monopoly.notification.Sound;
/**
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
@ -25,13 +22,13 @@ public class GateFieldCard extends Dialog {
private final Geometry overlayBackground;
private final Container gateFieldContainer;
private final Container backgroundContainer;
private int index = 5;
public GateFieldCard(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
//Generate the corresponfing field
int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
GateField field = (GateField) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
// Halbtransparentes Overlay hinzufügen
@ -66,21 +63,16 @@ public class GateFieldCard 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)));
//TODO eventuell diese Stelle löschen, da nur die BuyCard Kaufen und beenden hat
/*
// Beenden-Button
Button quitButton = gateFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
// Kaufen-Button
Button buyButton = gateFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32);
buyButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new BuyPropertyRequest());
close();
}));
*/
float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(gateFieldContainer.getPreferredSize().addLocal(padding, padding, 0));
@ -129,6 +121,10 @@ public class GateFieldCard extends Dialog {
super.close();
}
public void setIndex(int index) {
this.index = index;
}
@Override
public void escape() {
new SettingsMenu(app).open();

View File

@ -7,14 +7,30 @@ import com.jme3.network.serializing.Serializable;
*/
@Serializable
public class BuyPropertyRequest extends ClientMessage{
private int propertyId;
/**
* Default constructor for serialization purposes.
*/
private BuyPropertyRequest() { /* empty */ }
/**
* Constructs a BuyPropertyRequest with the specified property ID.
*
* @param propertyId the ID of the property to buy
*/
public BuyPropertyRequest() {}
public BuyPropertyRequest(int propertyId) {
this.propertyId = propertyId;
}
/**
* Gets the ID of the property to buy.
*
* @return the property ID
*/
public int getPropertyId() {
return propertyId;
}
@Override
public void accept(ClientInterpreter interpreter, int from) {