mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 01:10:58 +02:00
Compare commits
3 Commits
7f6011720c
...
8d087a8e84
Author | SHA1 | Date | |
---|---|---|---|
|
8d087a8e84 | ||
|
1715926c1c | ||
|
c8b69efca2 |
@ -0,0 +1,191 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
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");
|
||||
private final Button takeMortgageButton = new Button("Hypothek aufnehmen");
|
||||
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;
|
||||
|
||||
// Configure the main container
|
||||
mainContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
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 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(0, app.getCamera().getHeight(), 7); // Full screen
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the header section to the main container.
|
||||
*
|
||||
* @param title The title text for the header.
|
||||
*/
|
||||
private void addHeader(String title) {
|
||||
Container headerContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||
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));
|
||||
mainContainer.addChild(headerContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the main content, organized into columns for Overview, Build, and Mortgage management.
|
||||
*/
|
||||
private void addContent() {
|
||||
Container contentContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||
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(24);
|
||||
overviewColumn.addChild(createButtonContainer(overviewButton, "Übersicht", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handleOverview();
|
||||
}));
|
||||
overviewColumn.addChild(createButtonContainer(backButton, "Zurück", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handleBack();
|
||||
}));
|
||||
|
||||
// Build Column
|
||||
Container buildColumn = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
buildColumn.addChild(new Label("Bauen:")).setFontSize(24);
|
||||
buildColumn.addChild(createButtonContainer(buildButton, "Bauen", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handleBuild();
|
||||
}));
|
||||
buildColumn.addChild(createButtonContainer(demolishButton, "Abriss", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handleDemolish();
|
||||
}));
|
||||
|
||||
// Mortgage Column
|
||||
Container mortgageColumn = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
mortgageColumn.addChild(new Label("Hypotheken:")).setFontSize(24);
|
||||
mortgageColumn.addChild(createButtonContainer(takeMortgageButton, "Hypothek aufnehmen", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handleTakeMortgage();
|
||||
}));
|
||||
mortgageColumn.addChild(createButtonContainer(payMortgageButton, "Hypothek bezahlen", () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
handlePayMortgage();
|
||||
}));
|
||||
|
||||
|
||||
// Add all columns to the content container
|
||||
contentContainer.addChild(overviewColumn);
|
||||
contentContainer.addChild(buildColumn);
|
||||
contentContainer.addChild(mortgageColumn);
|
||||
|
||||
|
||||
mainContainer.addChild(contentContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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() {
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void escape() {
|
||||
handleBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
// Periodic updates if necessary
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import com.simsilica.lemur.style.ElementId;
|
||||
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.game.server.PlayerColor;
|
||||
import pp.monopoly.message.client.PlayerReady;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
@ -172,7 +173,7 @@ public class LobbyMenu extends Dialog {
|
||||
app.getGuiNode().attachChild(lowerRightMenu);
|
||||
|
||||
// Add a colored circle between the input field and the dropdown menu
|
||||
circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
|
||||
circle = createCircle(); // 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
|
||||
@ -206,19 +207,33 @@ public class LobbyMenu extends Dialog {
|
||||
app.getGuiNode().attachChild(background);
|
||||
}
|
||||
|
||||
private Geometry createCircle(ColorRGBA color) {
|
||||
private Geometry createCircle() {
|
||||
|
||||
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", color); // Set the desired color
|
||||
material.setColor("Color", idToColor()); // Set the desired color
|
||||
circleGeometry.setMaterial(material);
|
||||
|
||||
return circleGeometry;
|
||||
}
|
||||
|
||||
private ColorRGBA idToColor() {
|
||||
switch (app.getId()+1) {
|
||||
case 1: return PlayerColor.CYAN.getColor();
|
||||
case 2: return PlayerColor.YELLOW.getColor();
|
||||
case 3: return PlayerColor.RED.getColor();
|
||||
case 4: return PlayerColor.PINK.getColor();
|
||||
case 5: return PlayerColor.GREEN.getColor();
|
||||
case 6: return PlayerColor.PURPLE.getColor();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltet den "Bereit"-Status um.
|
||||
*/
|
||||
|
@ -162,7 +162,7 @@ public class Toolbar extends Dialog implements GameEventListener{
|
||||
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
//TODO open property dialog
|
||||
new BuildingAdminMenu(app).open();
|
||||
}));
|
||||
return propertyMenuButton;
|
||||
}
|
||||
|
@ -79,12 +79,12 @@ public class Player implements FieldVisitor<Void>{
|
||||
|
||||
public PlayerColor getColor() {
|
||||
switch ((id%6)+1) {
|
||||
case 1: return PlayerColor.BLUE;
|
||||
case 2: return PlayerColor.GREEN_DARK;
|
||||
case 3: return PlayerColor.GREEN_LIGHT;
|
||||
case 1: return PlayerColor.CYAN;
|
||||
case 2: return PlayerColor.YELLOW;
|
||||
case 3: return PlayerColor.RED;
|
||||
case 4: return PlayerColor.PINK;
|
||||
case 5: return PlayerColor.RED;
|
||||
case 6: return PlayerColor.YELLOW;
|
||||
case 5: return PlayerColor.GREEN;
|
||||
case 6: return PlayerColor.PURPLE;
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
@ -6,12 +6,12 @@ import com.jme3.math.ColorRGBA;
|
||||
* Enum representing six distinct colors for players in the game.
|
||||
*/
|
||||
public enum PlayerColor {
|
||||
GREEN_LIGHT(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)), // Hex: 00cc00
|
||||
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)), // Hex: ff0000
|
||||
BLUE(new ColorRGBA(0 / 255f, 0 / 255f, 204 / 255f, 1)), // Hex: 0000cc
|
||||
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)), // Hex: ff4da6
|
||||
GREEN_DARK(new ColorRGBA(0 / 255f, 102 / 255f, 0 / 255f, 1)), // Hex: 006600
|
||||
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)); // Hex: ffff00
|
||||
CYAN(new ColorRGBA(1 / 255f, 190 / 255f, 254 / 255f, 1)),
|
||||
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)),
|
||||
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)),
|
||||
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)),
|
||||
GREEN(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)),
|
||||
PURPLE(new ColorRGBA(143 / 255f, 0 / 255f, 255 / 255f, 1));
|
||||
|
||||
private final ColorRGBA color;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user