mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 12:40:59 +02:00
Compare commits
No commits in common. "8d087a8e84b43948c638ea6c9e8678bc08c954d4" and "7f6011720ca7eac9004d34165881eecb83a16282" have entirely different histories.
8d087a8e84
...
7f6011720c
@ -1,191 +0,0 @@
|
|||||||
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,7 +25,6 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.game.server.PlayerColor;
|
|
||||||
import pp.monopoly.message.client.PlayerReady;
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
@ -173,7 +172,7 @@ public class LobbyMenu extends Dialog {
|
|||||||
app.getGuiNode().attachChild(lowerRightMenu);
|
app.getGuiNode().attachChild(lowerRightMenu);
|
||||||
|
|
||||||
// Add a colored circle between the input field and the dropdown menu
|
// Add a colored circle between the input field and the dropdown menu
|
||||||
circle = createCircle(); // 50 is the diameter, Red is the color
|
circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
|
||||||
circle.setLocalTranslation(new Vector3f(
|
circle.setLocalTranslation(new Vector3f(
|
||||||
(app.getCamera().getWidth()) / 2, // Center horizontally
|
(app.getCamera().getWidth()) / 2, // Center horizontally
|
||||||
(app.getCamera().getHeight() / 2) - 90, // Adjust Y position
|
(app.getCamera().getHeight() / 2) - 90, // Adjust Y position
|
||||||
@ -207,33 +206,19 @@ public class LobbyMenu extends Dialog {
|
|||||||
app.getGuiNode().attachChild(background);
|
app.getGuiNode().attachChild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Geometry createCircle() {
|
private Geometry createCircle(ColorRGBA color) {
|
||||||
|
|
||||||
Sphere sphere = new Sphere(90,90,60.0f);
|
Sphere sphere = new Sphere(90,90,60.0f);
|
||||||
Geometry circleGeometry = new Geometry("Circle", sphere);
|
Geometry circleGeometry = new Geometry("Circle", sphere);
|
||||||
|
|
||||||
// Create a material with a solid color
|
// Create a material with a solid color
|
||||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setColor("Color", idToColor()); // Set the desired color
|
material.setColor("Color", color); // Set the desired color
|
||||||
circleGeometry.setMaterial(material);
|
circleGeometry.setMaterial(material);
|
||||||
|
|
||||||
return circleGeometry;
|
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.
|
* 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.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
new BuildingAdminMenu(app).open();
|
//TODO open property dialog
|
||||||
}));
|
}));
|
||||||
return propertyMenuButton;
|
return propertyMenuButton;
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
public PlayerColor getColor() {
|
public PlayerColor getColor() {
|
||||||
switch ((id%6)+1) {
|
switch ((id%6)+1) {
|
||||||
case 1: return PlayerColor.CYAN;
|
case 1: return PlayerColor.BLUE;
|
||||||
case 2: return PlayerColor.YELLOW;
|
case 2: return PlayerColor.GREEN_DARK;
|
||||||
case 3: return PlayerColor.RED;
|
case 3: return PlayerColor.GREEN_LIGHT;
|
||||||
case 4: return PlayerColor.PINK;
|
case 4: return PlayerColor.PINK;
|
||||||
case 5: return PlayerColor.GREEN;
|
case 5: return PlayerColor.RED;
|
||||||
case 6: return PlayerColor.PURPLE;
|
case 6: return PlayerColor.YELLOW;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
@ -6,12 +6,12 @@ import com.jme3.math.ColorRGBA;
|
|||||||
* Enum representing six distinct colors for players in the game.
|
* Enum representing six distinct colors for players in the game.
|
||||||
*/
|
*/
|
||||||
public enum PlayerColor {
|
public enum PlayerColor {
|
||||||
CYAN(new ColorRGBA(1 / 255f, 190 / 255f, 254 / 255f, 1)),
|
GREEN_LIGHT(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)), // Hex: 00cc00
|
||||||
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)),
|
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)), // Hex: ff0000
|
||||||
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)),
|
BLUE(new ColorRGBA(0 / 255f, 0 / 255f, 204 / 255f, 1)), // Hex: 0000cc
|
||||||
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)),
|
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)), // Hex: ff4da6
|
||||||
GREEN(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)),
|
GREEN_DARK(new ColorRGBA(0 / 255f, 102 / 255f, 0 / 255f, 1)), // Hex: 006600
|
||||||
PURPLE(new ColorRGBA(143 / 255f, 0 / 255f, 255 / 255f, 1));
|
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)); // Hex: ffff00
|
||||||
|
|
||||||
private final ColorRGBA color;
|
private final ColorRGBA color;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user