Compare commits

...

4 Commits

Author SHA1 Message Date
Johannes Schmelz
46d2dce372 Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui 2024-11-23 22:12:39 +01:00
Johannes Schmelz
c39f1f6d4c tweaked camera params 2024-11-23 22:12:34 +01:00
Yvonne Schmidt
738b04f2d9 oberfläche der lobby fertig 2024-11-23 21:29:14 +01:00
Simon Wilkening
ecba1c3135 GateField korrigiert 2024-11-23 21:22:54 +01:00
9 changed files with 187 additions and 114 deletions

View File

@ -24,10 +24,10 @@ overlay.top.color=1, 1, 1, 1
settings.show=false settings.show=false
# #
# Specifies the width of the application window in pixels. # Specifies the width of the application window in pixels.
settings.resolution.width=1200 settings.resolution.width=1920
# #
# Specifies the height of the application window in pixels. # Specifies the height of the application window in pixels.
settings.resolution.height=800 settings.resolution.height=1080
# #
# Determines whether the application runs in full-screen mode. # Determines whether the application runs in full-screen mode.
settings.full-screen=false settings.full-screen=false

View File

@ -160,17 +160,17 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
//logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen //logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen
private void handleB(boolean isPressed) { private void handleB(boolean isPressed) {
if (isPressed) { if (isPressed) {
if (foodField != null && isBuyCardPopupOpen) { if (gateField != null && isBuyCardPopupOpen) {
// Schließe das SettingsMenu // Schließe das SettingsMenu
System.out.println("Schließe BuyCardPopup..."); System.out.println("Schließe BuyCardPopup...");
foodField.close(); gateField.close();
foodField = null; gateField = null;
setBuyCardPopupOpen(false); setBuyCardPopupOpen(false);
} else { } else {
// Öffne das SettingsMenu // Öffne das SettingsMenu
System.out.println("Öffne BuyCardPopup..."); System.out.println("Öffne BuyCardPopup...");
foodField = new FoodFieldCard(this); gateField = new GateFieldCard(this);
foodField.open(); gateField.open();
setBuyCardPopupOpen(true); setBuyCardPopupOpen(true);
} }
} }

View File

@ -51,10 +51,10 @@ public class CameraController {
} }
private Vector3f fieldIdToVector(int fieldID) { private Vector3f fieldIdToVector(int fieldID) {
if (fieldID <= 10) return new Vector3f(4,height,0); if (fieldID <= 10) return new Vector3f(30,height,0);
if (fieldID <= 20) return new Vector3f(0, height, 4); if (fieldID <= 20) return new Vector3f(0, height, 30);
if (fieldID <= 30) return new Vector3f(-4, height, 0); if (fieldID <= 30) return new Vector3f(-30, height, 0);
if (fieldID <= 40) return new Vector3f(0, height, -4); if (fieldID <= 40) return new Vector3f(0, height, -30);
else throw new IllegalArgumentException(); else throw new IllegalArgumentException();
} }
} }

View File

@ -7,6 +7,7 @@ import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.jme3.scene.shape.Sphere;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.simsilica.lemur.Axis; import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button; import com.simsilica.lemur.Button;
@ -30,7 +31,6 @@ public class LobbyMenu {
private final MonopolyApp app; private final MonopolyApp app;
private final Container menuContainer; private final Container menuContainer;
private Geometry background; private Geometry background;
private final Selector<String> dropdown;
public LobbyMenu(MonopolyApp app) { public LobbyMenu(MonopolyApp app) {
this.app = app; this.app = app;
@ -50,11 +50,11 @@ public class LobbyMenu {
// Create a smaller horizontal container for the label, input field, and spacers // Create a smaller horizontal container for the label, input field, and spacers
Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y))); Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
horizontalContainer.setPreferredSize(new Vector3f(600, 50, 0)); // Adjust container size horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size
horizontalContainer.setBackground(null); horizontalContainer.setBackground(null);
Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold"))); Label title = horizontalContainer.addChild(new Label("Startkapital:", new ElementId("label-Bold")));
title.setFontSize(48); title.setFontSize(40);
// Add a spacer between the title and the input field // Add a spacer between the title and the input field
Label spacerBeforeInput = horizontalContainer.addChild(new Label("")); // Invisible spacer Label spacerBeforeInput = horizontalContainer.addChild(new Label("")); // Invisible spacer
@ -77,40 +77,81 @@ public class LobbyMenu {
); );
app.getGuiNode().attachChild(menuContainer); app.getGuiNode().attachChild(menuContainer);
// Spielerstatus anzeigen // Dropdowns and Labels
Container playerListContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X))); Container dropdownContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
playerListContainer.addChild(new Label("Spieler in der Lobby:")); dropdownContainer.setPreferredSize(new Vector3f(800, 200, 0));
playerListContainer.setBackground(null); dropdownContainer.setBackground(null);
Label playersLabel = playerListContainer.addChild(new Label("Noch keine Spieler verbunden.")); // Beispieltext dropdownContainer.setInsets(new Insets3f(10, 0, 0, 0));
// Player Input Field
VersionedList<String> items = new VersionedList<>(); Container playerInputContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
items.add("Alpha"); playerInputContainer.addChild(new Label("Spieler:"));
items.add("Beta"); playerInputContainer.setBackground(null);
items.add("Gamma");
items.add("Back");
dropdown = new Selector<>(items,"glass");
dropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
menuContainer.addChild(dropdown);
// Add the custom action listener
addSelectionActionListener(dropdown, this::onDropdownSelectionChanged);
TextField playerInputField = new TextField("");
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
playerInputContainer.addChild(playerInputField);
// Spacer (Center Circle Area)
Label spacer = dropdownContainer.addChild(new Label(""));
spacer.setPreferredSize(new Vector3f(200, 200, 0)); // Adjust this to fit the center graphic
// Figur Dropdown
Container figureDropdownContainer = dropdownContainer.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
figureDropdownContainer.addChild(new Label("Figur:"));
figureDropdownContainer.setBackground(null);
VersionedList<String> figures = new VersionedList<>();
figures.add("Hund");
figures.add("Katze");
figures.add("Panzer");
figures.add("Pot");
Selector<String> figureDropdown = new Selector<>(figures, "glass");
figureDropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.DarkGray));
figureDropdown.setPreferredSize(new Vector3f(100, 20, 0));
figureDropdownContainer.addChild(figureDropdown);
addSelectionActionListener(figureDropdown, this::onDropdownSelectionChanged);
// Buttons
Container buttonContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y))); Container buttonContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
buttonContainer.setPreferredSize(new Vector3f(400, 50, 0)); buttonContainer.setPreferredSize(new Vector3f(100, 40, 0));
buttonContainer.setInsets(new Insets3f(20, 0, 10, 0)); // Add spacing above the buttons
buttonContainer.setBackground(null);
// Lower-left container for "Abbrechen" button
Container lowerLeftMenu = new Container();
Button cancelButton = new Button("Abbrechen");
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
cancelButton.setFontSize(18); // Adjust font size
cancelButton.addClickCommands(source -> goBackToCreateGame()); // Add functionality
lowerLeftMenu.addChild(cancelButton);
// "Bereit"-Button // Position the container near the bottom-left corner
Button readyButton = buttonContainer.addChild(new Button("Bereit")); lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 3)); // Adjust X and Y to align with the bottom-left corner
readyButton.setPreferredSize(new Vector3f(120, 40, 0)); app.getGuiNode().attachChild(lowerLeftMenu);
readyButton.addClickCommands(source -> toggleReady(playersLabel));
// "Zurück"-Button // Lower-right container for "Bereit" button
Button backButton = buttonContainer.addChild(new Button("Zurück")); Container lowerRightMenu = new Container();
backButton.setPreferredSize(new Vector3f(120, 40, 0)); Button readyButton = new Button("Bereit");
backButton.addClickCommands(source -> goBackToCreateGame()); readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
readyButton.setFontSize(18); // Adjust font size
readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style
readyButton.addClickCommands(source -> toggleReady(null)); // Add functionality
lowerRightMenu.addChild(readyButton);
// Position the container near the bottom-right corner
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 3)); // X: 220px from the right, Y: 50px above the bottom
app.getGuiNode().attachChild(lowerRightMenu);
// Add a colored circle between the input field and the dropdown menu
Geometry circle = createCircle( ColorRGBA.Red); // 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
2 // Ensure it's in front of the background but behind the dropdown
));
app.getGuiNode().attachChild(circle); // Attach to the GUI node
// Zentrierung des Containers // Zentrierung des Containers
menuContainer.setLocalTranslation( menuContainer.setLocalTranslation(
@ -122,11 +163,12 @@ public class LobbyMenu {
app.getGuiNode().attachChild(menuContainer); app.getGuiNode().attachChild(menuContainer);
} }
/** /**
* Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu. * Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu.
*/ */
private void addBackgroundImage() { private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/lobby.png");
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
background = new Geometry("Background", quad); background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
@ -137,6 +179,19 @@ public class LobbyMenu {
app.getGuiNode().attachChild(background); app.getGuiNode().attachChild(background);
} }
private Geometry createCircle(ColorRGBA color) {
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
circleGeometry.setMaterial(material);
return circleGeometry;
}
/** /**
* Schaltet den "Bereit"-Status um. * Schaltet den "Bereit"-Status um.
*/ */

View File

@ -48,7 +48,7 @@ public class TestWorld {
app.getCamera(), // Die Kamera der App app.getCamera(), // Die Kamera der App
Vector3f.ZERO, // Fokus auf die Mitte des Spielfelds Vector3f.ZERO, // Fokus auf die Mitte des Spielfelds
4, // Radius des Kreises 4, // Radius des Kreises
2, // Höhe der Kamera 15, // Höhe der Kamera
0 // Geschwindigkeit der Bewegung 0 // Geschwindigkeit der Bewegung
); );
@ -82,7 +82,7 @@ public class TestWorld {
*/ */
private void createBoard() { private void createBoard() {
// Erstelle ein Quadrat // Erstelle ein Quadrat
Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur Box box = new Box(10, 0.1f, 10); // Dünnes Quadrat für die Textur
Geometry geom = new Geometry("Board", box); Geometry geom = new Geometry("Board", box);
// Setze das Material mit Textur // Setze das Material mit Textur

View File

@ -5,7 +5,6 @@ import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container; import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.QuadBackgroundComponent;
@ -22,15 +21,14 @@ import pp.monopoly.model.fields.BuildingProperty;
public class BuildingPropertyCard extends Dialog { public class BuildingPropertyCard extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Geometry overlayBackground; private final Geometry overlayBackground;
private final Container settingsContainer; private final Container buildingPropertyContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
private int index = 23; private int index = 39;
public BuildingPropertyCard(MonopolyApp app) { public BuildingPropertyCard(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
this.app = app; this.app = app;
// Titel
//Generate the corresponfing field //Generate the corresponfing field
BuildingProperty field = (BuildingProperty) app.getBoardManager().getFieldAtIndex(index); BuildingProperty field = (BuildingProperty) app.getBoardManager().getFieldAtIndex(index);
@ -43,22 +41,19 @@ public class BuildingPropertyCard extends Dialog {
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
app.getGuiNode().attachChild(backgroundContainer); app.getGuiNode().attachChild(backgroundContainer);
// Hauptcontainer für das Menü // Hauptcontainer für die Gebäudekarte
settingsContainer = new Container(); buildingPropertyContainer = new Container();
//settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1))); // hell buildingPropertyContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
settingsContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); //dunkel
Label settingsTitle = buildingPropertyContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
Label settingsTitle = settingsContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
settingsTitle.setFontSize(48); settingsTitle.setFontSize(48);
// Effekt-Sound: Slider und Checkbox // Text, der auf der Karte steht
Container propertyValuesContainer = settingsContainer.addChild(new Container()); // Die Preise werden dynamisch dem BoardManager entnommen
Container propertyValuesContainer = buildingPropertyContainer.addChild(new Container());
propertyValuesContainer.addChild(new Label("„Grundstückswert: " + field.getPrice() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Grundstückswert: " + field.getPrice() + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
propertyValuesContainer.addChild(new Label("„Miete allein: " + field.getAllRent().get(0)+ " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Miete allein: " + field.getAllRent().get(0)+ " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 1 Haus: " + field.getAllRent().get(1) + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„-mit 1 Haus: " + field.getAllRent().get(1) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 2 Häuser: " + field.getAllRent().get(2) + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„-mit 2 Häuser: " + field.getAllRent().get(2) + " EUR", new ElementId("label-Text")));
@ -66,34 +61,39 @@ public class BuildingPropertyCard extends Dialog {
propertyValuesContainer.addChild(new Label("„-mit 4 Häuser: " + field.getAllRent().get(4) + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„-mit 4 Häuser: " + field.getAllRent().get(4) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 1 Hotel: " + field.getAllRent().get(5) + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„-mit 1 Hotel: " + field.getAllRent().get(5) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-1 Haus kostet: " + field.getHousePrice()+ " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„-1 Haus kostet: " + field.getHousePrice()+ " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
propertyValuesContainer.addChild(new Label("„Hypothek: " + field.getHypo() + " EUR", new ElementId("label-Text"))); 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))); 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 // Beenden-Button
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32); quitButton.setFontSize(32);
// Kaufen-Button // Kaufen-Button
Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32); buyButton.setFontSize(32);
*/
float padding = 10; // Padding around the settingsContainer for the background float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); backgroundContainer.setPreferredSize(buildingPropertyContainer.getPreferredSize().addLocal(padding, padding, 0));
// Zentriere das Menü // Zentriere das Menü
settingsContainer.setLocalTranslation( buildingPropertyContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, (app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, (app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y) / 2,
8 8
); );
backgroundContainer.setLocalTranslation( backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x - padding) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, (app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y+ padding) / 2,
7 7
); );
app.getGuiNode().attachChild(settingsContainer); app.getGuiNode().attachChild(buildingPropertyContainer);
} }
/** /**
@ -118,7 +118,7 @@ public class BuildingPropertyCard extends Dialog {
@Override @Override
public void close() { public void close() {
System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe
app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü app.getGuiNode().detachChild(buildingPropertyContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
app.setSettingsMenuOpen(false); // Menü als geschlossen markieren app.setSettingsMenuOpen(false); // Menü als geschlossen markieren

View File

@ -16,12 +16,12 @@ import pp.monopoly.client.MonopolyApp;
import pp.monopoly.model.fields.FoodField; import pp.monopoly.model.fields.FoodField;
/** /**
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. * FoodFieldCard erstellt die Geböudekarte vom Brandl und der Truppenküche
*/ */
public class FoodFieldCard extends Dialog { public class FoodFieldCard extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Geometry overlayBackground; private final Geometry overlayBackground;
private final Container settingsContainer; private final Container foodFieldContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
private int index = 12; private int index = 12;
@ -41,52 +41,63 @@ public class FoodFieldCard extends Dialog {
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
app.getGuiNode().attachChild(backgroundContainer); app.getGuiNode().attachChild(backgroundContainer);
// Hauptcontainer für das Menü // Hauptcontainer für die Gebäudekarte
settingsContainer = new Container(); foodFieldContainer = new Container();
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f))); foodFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f)));
// Titel // Titel, bestehend aus dynamischen Namen anhand der ID und der Schriftfarbe/größe
Label settingsTitle = settingsContainer.addChild(new Label(field.getName(), new ElementId("settings-title"))); Label settingsTitle = foodFieldContainer.addChild(new Label(field.getName(), new ElementId("settings-title")));
settingsTitle.setFontSize(48); settingsTitle.setFontSize(48);
// Effekt-Sound: Slider und Checkbox // Text, der auf der Karte steht
Container propertyValuesContainer = settingsContainer.addChild(new Container()); Container propertyValuesContainer = foodFieldContainer.addChild(new Container());
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
propertyValuesContainer.addChild(new Label("„Wenn man Besitzer des\n" +field.getName()+" ist, so ist die\nMiete 40-mal so hoch, wie\nAugen auf den zwei Würfeln sind.", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Wenn man Besitzer des", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label(field.getName()+" ist, so ist die", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Miete 40-mal so hoch, wie", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Augen auf den zwei Würfeln sind.", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
propertyValuesContainer.addChild(new Label("„Wenn man Besitzer beider \nRestaurants ist, so ist die\nMiete 100-mal so hoch, wie\nAugen auf den zwei Würfeln sind.", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Wenn man Besitzer beider", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Restaurants ist, so ist die", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Miete 100-mal so hoch, wie", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Augen auf den zwei Würfeln sind.", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Leerzeile
propertyValuesContainer.addChild(new Label("„Hypothek: " + field.getHypo() + " EUR", new ElementId("label-Text"))); 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))); 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 // Beenden-Button
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32); quitButton.setFontSize(32);
// Kaufen-Button // Kaufen-Button
Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32); buyButton.setFontSize(32);
*/
float padding = 10; // Padding around the settingsContainer for the background float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); backgroundContainer.setPreferredSize(foodFieldContainer.getPreferredSize().addLocal(padding, padding, 0));
// Zentriere das Menü // Zentriere das Menü
settingsContainer.setLocalTranslation( foodFieldContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, (app.getCamera().getWidth() - foodFieldContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, (app.getCamera().getHeight() + foodFieldContainer.getPreferredSize().y) / 2,
8 8
); );
backgroundContainer.setLocalTranslation( backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getWidth() - foodFieldContainer.getPreferredSize().x - padding) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, (app.getCamera().getHeight() + foodFieldContainer.getPreferredSize().y+ padding) / 2,
7 7
); );
app.getGuiNode().attachChild(settingsContainer); app.getGuiNode().attachChild(foodFieldContainer);
} }
/** /**
@ -111,7 +122,7 @@ public class FoodFieldCard extends Dialog {
@Override @Override
public void close() { public void close() {
System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe
app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü app.getGuiNode().detachChild(foodFieldContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
app.setSettingsMenuOpen(false); // Menü als geschlossen markieren app.setSettingsMenuOpen(false); // Menü als geschlossen markieren

View File

@ -5,7 +5,6 @@ import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container; import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.QuadBackgroundComponent;
@ -20,9 +19,9 @@ import pp.monopoly.model.fields.GateField;
public class GateFieldCard extends Dialog { public class GateFieldCard extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Geometry overlayBackground; private final Geometry overlayBackground;
private final Container settingsContainer; private final Container gateFieldContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
private int index; private int index = 5;
public GateFieldCard(MonopolyApp app) { public GateFieldCard(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
@ -40,50 +39,58 @@ public class GateFieldCard extends Dialog {
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
app.getGuiNode().attachChild(backgroundContainer); app.getGuiNode().attachChild(backgroundContainer);
// Hauptcontainer für das Menü // Hauptcontainer für die Gebäudekarte
settingsContainer = new Container(); gateFieldContainer = new Container();
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0 / 255f, 0 / 255f, 0 / 255f, 1))); gateFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
// Titel // Titel
Label settingsTitle = settingsContainer.addChild(new Label(field.getName(), new ElementId("settings-title"))); // Die Namen werden dynamisch dem BoardManager entnommen
Label settingsTitle = gateFieldContainer.addChild(new Label(field.getName(), new ElementId("settings-title")));
settingsTitle.setFontSize(48); settingsTitle.setFontSize(48);
settingsTitle.setColor(ColorRGBA.Black); settingsTitle.setColor(ColorRGBA.Black);
// Text, der auf der Karte steht
// Effekt-Sound: Slider und Checkbox // Die Preise werden dynamisch dem BoardManager entnommen
Container propertyValuesContainer = settingsContainer.addChild(new Container()); Container propertyValuesContainer = gateFieldContainer.addChild(new Container());
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„Miete:", new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Wenn man 1 Bahnhof besitzt: 250 EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Wenn man 2 Bahnhöfe besitzt: 500 EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Wenn man 3 Bahnhöfe besitzt: 1000 EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("Wenn man 4 Bahnhöfe besitzt: 2000 EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„Hypothek: " + field.getHypo() + " EUR", new ElementId("label-Text"))); 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))); 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 // Beenden-Button
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button"))); Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32); quitButton.setFontSize(32);
// Kaufen-Button // Kaufen-Button
Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button"))); Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32); buyButton.setFontSize(32);
*/
float padding = 10; // Padding around the settingsContainer for the background float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0)); backgroundContainer.setPreferredSize(gateFieldContainer.getPreferredSize().addLocal(padding, padding, 0));
// Zentriere das Menü // Zentriere das Menü
settingsContainer.setLocalTranslation( gateFieldContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2, (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2, (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y) / 2,
8 8
); );
backgroundContainer.setLocalTranslation( backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2, (app.getCamera().getWidth() - gateFieldContainer.getPreferredSize().x - padding) / 2,
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2, (app.getCamera().getHeight() + gateFieldContainer.getPreferredSize().y+ padding) / 2,
7 7
); );
app.getGuiNode().attachChild(settingsContainer); app.getGuiNode().attachChild(gateFieldContainer);
} }
/** /**
@ -108,7 +115,7 @@ public class GateFieldCard extends Dialog {
@Override @Override
public void close() { public void close() {
System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe
app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü app.getGuiNode().detachChild(gateFieldContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
app.setSettingsMenuOpen(false); // Menü als geschlossen markieren app.setSettingsMenuOpen(false); // Menü als geschlossen markieren

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB