mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 03:09:46 +01:00
Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui
This commit is contained in:
commit
93b183254f
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
//TODO open property dialog
|
new BuildingAdminMenu(app).open();
|
||||||
}));
|
}));
|
||||||
return propertyMenuButton;
|
return propertyMenuButton;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user