mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 23:59:44 +01:00
Compare commits
3 Commits
559afcaffd
...
65a7958b66
Author | SHA1 | Date | |
---|---|---|---|
|
65a7958b66 | ||
|
91e4df7478 | ||
|
399606d9a0 |
@ -1,6 +1,8 @@
|
||||
// Styling of Lemur components
|
||||
// For documentation, see:
|
||||
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
||||
|
||||
import com.jme3.math.ColorRGBA
|
||||
import com.simsilica.lemur.*
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||
import com.simsilica.lemur.Button
|
||||
@ -34,6 +36,7 @@ def gradient = TbtQuadBackgroundComponent.create(
|
||||
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
||||
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
||||
generateMips: false)
|
||||
//doubleGradient.color = color(0, 0, 0, 1)
|
||||
|
||||
def orangeBorder = TbtQuadBackgroundComponent.create(
|
||||
texture(name: "/com/simsilica/lemur/icons/border.png", // Replace with an appropriate texture if needed
|
||||
@ -51,6 +54,21 @@ selector("label", "pp") {
|
||||
color = buttonEnabledColor
|
||||
}
|
||||
|
||||
selector("label-Bold", "pp") {
|
||||
insets = new Insets3f(2, 2, 2, 2)
|
||||
font = font("Interface/Fonts/Metropolis/Metropolis-Bold-32.fnt")
|
||||
fontSize = 30
|
||||
color = buttonEnabledColor
|
||||
textHAlignment = HAlignment.Center
|
||||
textVAlignment = VAlignment.Center
|
||||
|
||||
}
|
||||
selector("label-Text", "pp") {
|
||||
insets = new Insets3f(2, 2, 2, 2)
|
||||
fontSize = 25
|
||||
color = buttonEnabledColor
|
||||
}
|
||||
|
||||
selector("header", "pp") {
|
||||
font = font("Interface/Fonts/Metropolis/Metropolis-Bold-42.fnt")
|
||||
insets = new Insets3f(2, 2, 2, 2)
|
||||
@ -65,20 +83,10 @@ selector("container", "pp") {
|
||||
}
|
||||
|
||||
selector("toolbar") {
|
||||
// Set the grey background
|
||||
background = new QuadBackgroundComponent(greyBackground)
|
||||
background = gradient.clone()
|
||||
background.setColor(bgColor)
|
||||
//color = (new ColorRGBA(0.4157f, 0.4235f, 0.4392f, 1.0f))
|
||||
|
||||
// Add a red border using a TbtQuadBackgroundComponent
|
||||
def redBorder = TbtQuadBackgroundComponent.create(
|
||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
||||
generateMips: false),
|
||||
1, 1, 1, 1, 1,
|
||||
1f, false)
|
||||
redBorder.color = redBorderColor
|
||||
background = greyBackground
|
||||
|
||||
// Optional: Set padding inside the toolbar
|
||||
insets = new Insets3f(10, 10, 10, 10)
|
||||
}
|
||||
selector("slider", "pp") {
|
||||
background = gradient.clone()
|
||||
@ -239,15 +247,14 @@ selector("tab.button", "pp") {
|
||||
}
|
||||
selector("settings-title", "pp") {
|
||||
fontSize = 48 // Set font size
|
||||
background = new QuadBackgroundComponent(color(0.4157f, 0.4235f, 0.4392f, 1.0f)) // Grey background
|
||||
textHAlignment = HAlignment.Center
|
||||
textVAlignment = VAlignment.Center
|
||||
}
|
||||
|
||||
selector("menu-button", "pp") {
|
||||
fontSize = 40 // Set font size
|
||||
background = new QuadBackgroundComponent(color(0.4157f, 0.4235f, 0.4392f, 1.0f)) // Grey background
|
||||
textHAlignment = HAlignment.Center
|
||||
textVAlignment = VAlignment.Center
|
||||
buttonCommands = stdButtonCommands
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import pp.dialog.DialogManager;
|
||||
import pp.graphics.Draw;
|
||||
import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.client.gui.TestWorld;
|
||||
import pp.monopoly.client.gui.popups.BuyCard;
|
||||
import pp.monopoly.game.client.ClientGameLogic;
|
||||
import pp.monopoly.game.client.MonopolyClient;
|
||||
import pp.monopoly.game.client.ServerConnection;
|
||||
@ -42,6 +43,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
private MonopolyServer monopolyServer;
|
||||
private NetworkSupport networkSupport;
|
||||
|
||||
|
||||
private BuyCard buyCard;
|
||||
private boolean isBuyCardPopupOpen = false;
|
||||
private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed);
|
||||
|
||||
/**
|
||||
* Path to the styles script for GUI elements.
|
||||
*/
|
||||
@ -114,6 +120,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
inputManager.setCursorVisible(true);
|
||||
inputManager.addMapping("ESC", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||
inputManager.addListener(escapeListener, "ESC");
|
||||
|
||||
inputManager.addMapping("B", new KeyTrigger(KeyInput.KEY_B));
|
||||
inputManager.addListener(BListener, "B");
|
||||
}
|
||||
|
||||
private void handleEscape(boolean isPressed) {
|
||||
@ -134,6 +143,25 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
}
|
||||
}
|
||||
|
||||
//logik zum wechselnden erscheinen und verschwinden beim drücken von B
|
||||
private void handleB(boolean isPressed) {
|
||||
if (isPressed) {
|
||||
if (buyCard != null && isBuyCardPopupOpen) {
|
||||
// Schließe das SettingsMenu
|
||||
System.out.println("Schließe BuyCardPopup...");
|
||||
buyCard.close();
|
||||
buyCard = null;
|
||||
setBuyCardPopupOpen(false);
|
||||
} else {
|
||||
// Öffne das SettingsMenu
|
||||
System.out.println("Öffne BuyCardPopup...");
|
||||
buyCard = new BuyCard(this);
|
||||
buyCard.open();
|
||||
setBuyCardPopupOpen(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void blockInputs() {
|
||||
if (!inputBlocked) {
|
||||
System.out.println("Blockiere Eingaben...");
|
||||
@ -196,6 +224,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
this.isSettingsMenuOpen = isOpen;
|
||||
}
|
||||
|
||||
public void setBuyCardPopupOpen(boolean isOpen) {
|
||||
this.isBuyCardPopupOpen = isOpen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
if (testWorld != null) {
|
||||
@ -209,6 +241,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
testWorld.initializeScene(); // Initialisiere die Szene
|
||||
}
|
||||
|
||||
public void startBuyCard() {
|
||||
|
||||
}
|
||||
|
||||
public void returnToMenu() {
|
||||
guiNode.detachAllChildren(); // Entferne die GUI
|
||||
StartMenu.createStartMenu(this); // Zeige das Startmenü erneut
|
||||
|
@ -110,6 +110,16 @@ public class CreateGameMenu {
|
||||
}
|
||||
}, "OpenTestWorld");
|
||||
|
||||
app.getInputManager().addMapping("OpenBuyCard", new com.jme3.input.controls.KeyTrigger(com.jme3.input.KeyInput.KEY_B));
|
||||
app.getInputManager().addListener(new com.jme3.input.controls.ActionListener() {
|
||||
@Override
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if (name.equals("OpenBuyCard") && isPressed) {
|
||||
app.startBuyCard(); // Öffnet die TestWorld
|
||||
}
|
||||
}
|
||||
}, "OpenBuyCard");
|
||||
|
||||
app.getGuiNode().attachChild(menuContainer);
|
||||
}
|
||||
|
||||
|
@ -64,30 +64,6 @@ public class SettingsMenu extends Dialog {
|
||||
backgroundMusicContainer.addChild(new Checkbox("Musik an")).setChecked(true);
|
||||
backgroundMusicContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
/*Selector<String> dropdown = new Selector<>();
|
||||
backgroundMusicContainer.addChild(dropdown);
|
||||
|
||||
Vector3f dimens = settingsContainer.getPreferredSize();
|
||||
Vector3f dimens2 = dropdown.getPopupContainer().getPreferredSize();
|
||||
dimens2.setX(dimens.getX());
|
||||
dropdown.getPopupContainer().setPreferredSize(dimens2);*/
|
||||
// Create the dropdown menu
|
||||
Selector<String> dropdown = new Selector<>();
|
||||
|
||||
// Generate and add numbered examples to the dropdown
|
||||
for (int i = 1; i <= 10; i++) { // Generate 10 examples
|
||||
dropdown.getModel().add("Example " + i);
|
||||
}
|
||||
|
||||
|
||||
// Add the dropdown to the container
|
||||
backgroundMusicContainer.addChild(dropdown);
|
||||
|
||||
// Adjust the dropdown's popup container size if necessary
|
||||
Vector3f dimens = settingsContainer.getPreferredSize();
|
||||
Vector3f dimens2 = dropdown.getPopupContainer().getPreferredSize();
|
||||
dimens2.setX(dimens.getX());
|
||||
dropdown.getPopupContainer().setPreferredSize(dimens2);
|
||||
// Beenden-Button
|
||||
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("menu-button")));
|
||||
quitButton.setFontSize(32);
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import java.util.Random;
|
||||
@ -42,7 +43,7 @@ public class Toolbar extends Dialog {
|
||||
this.cube = cube;
|
||||
|
||||
// Erstelle die Toolbar
|
||||
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "toolbar");
|
||||
|
||||
// Setze die Position am unteren Rand und die Breite
|
||||
toolbarContainer.setLocalTranslation(
|
||||
@ -52,8 +53,6 @@ public class Toolbar extends Dialog {
|
||||
);
|
||||
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
|
||||
|
||||
// Hintergrund Grau
|
||||
toolbarContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
||||
|
||||
// Füge Buttons zur Toolbar hinzu
|
||||
//initializeButtons();
|
||||
@ -61,20 +60,35 @@ public class Toolbar extends Dialog {
|
||||
|
||||
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
|
||||
Container accountContainer = toolbarContainer.addChild(new Container());
|
||||
accountContainer.addChild(new Label("Kontostand", new ElementId("label")));
|
||||
accountContainer.addChild(new Label("Gulag Frei Karten", new ElementId("label")));
|
||||
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
|
||||
accountContainer.addChild(new Label("6666€", new ElementId("label-Text"))); //TODO Variable hier einsetzen
|
||||
accountContainer.addChild(new Label("Gulag Frei Karten", new ElementId("label-Bold")));
|
||||
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
// Add a spacer between accountContainer and overviewContainer
|
||||
Panel spacer = new Panel(); // Create an empty panel as a spacer
|
||||
spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
|
||||
spacer.setBackground(null);
|
||||
toolbarContainer.addChild(spacer);
|
||||
|
||||
// Menü-Container: Ein Container für Übersicht
|
||||
Container overviewContainer = toolbarContainer.addChild(new Container());
|
||||
overviewContainer.addChild(new Label("Übersicht", new ElementId("label")));
|
||||
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
|
||||
overviewContainer.addChild(new Label("„Spieler 1“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
overviewContainer.addChild(new Label("„Spieler 2“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
overviewContainer.addChild(new Label("„Spieler 3“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
overviewContainer.addChild(new Label("„Spieler 4“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
overviewContainer.addChild(new Label("„Spieler 5“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
// Menü-Container: Ein Container für Würfel
|
||||
Container diceContainer = toolbarContainer.addChild(new Container());
|
||||
|
||||
diceContainer.setPreferredSize(new Vector3f(400, 150, 0));
|
||||
diceContainer.addChild(new Label("Wo Würfel?", new ElementId("label")));
|
||||
diceContainer.addChild(addDiceRollButton());
|
||||
diceContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
diceContainer.setBackground(null);
|
||||
|
||||
|
||||
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
|
||||
Container menuContainer = toolbarContainer.addChild(new Container());
|
||||
@ -120,7 +134,7 @@ public class Toolbar extends Dialog {
|
||||
*/
|
||||
private Button addDiceRollButton() {
|
||||
Button diceButton = new Button("Würfeln");
|
||||
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
diceButton.setPreferredSize(new Vector3f(50, 20, 0));
|
||||
diceButton.addClickCommands(source -> rollDice());
|
||||
toolbarContainer.addChild(diceButton);
|
||||
return diceButton;
|
||||
|
@ -0,0 +1,112 @@
|
||||
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.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
|
||||
/**
|
||||
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
|
||||
*/
|
||||
public class BuyCard extends Dialog {
|
||||
private final MonopolyApp app;
|
||||
private final Geometry overlayBackground;
|
||||
private final Container settingsContainer;
|
||||
private final Container backgroundContainer;
|
||||
|
||||
public BuyCard(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
// Halbtransparentes Overlay hinzufügen
|
||||
overlayBackground = createOverlayBackground();
|
||||
app.getGuiNode().attachChild(overlayBackground);
|
||||
|
||||
// Create the background container
|
||||
backgroundContainer = new Container();
|
||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
||||
app.getGuiNode().attachChild(backgroundContainer);
|
||||
|
||||
// Hauptcontainer für das Menü
|
||||
settingsContainer = new Container();
|
||||
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f)));
|
||||
|
||||
|
||||
|
||||
// Titel
|
||||
Label settingsTitle = settingsContainer.addChild(new Label("Gebäude XX", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen
|
||||
settingsTitle.setFontSize(48);
|
||||
|
||||
// Effekt-Sound: Slider und Checkbox
|
||||
Container propertyValuesContainer = settingsContainer.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("„Preis: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
propertyValuesContainer.addChild(new Label("„Miete: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
propertyValuesContainer.addChild(new Label("„Hypothek: XXXX", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
// Beenden-Button
|
||||
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
// Kaufen-Button
|
||||
Button buyButton = settingsContainer.addChild(new Button("Kaufen", new ElementId("button")));
|
||||
buyButton.setFontSize(32);
|
||||
|
||||
float padding = 10; // Padding around the settingsContainer for the background
|
||||
backgroundContainer.setPreferredSize(settingsContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||
|
||||
|
||||
// Zentriere das Menü
|
||||
settingsContainer.setLocalTranslation(
|
||||
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2,
|
||||
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2,
|
||||
8
|
||||
);
|
||||
|
||||
backgroundContainer.setLocalTranslation(
|
||||
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x - padding) / 2,
|
||||
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y+ padding) / 2,
|
||||
7
|
||||
);
|
||||
|
||||
app.getGuiNode().attachChild(settingsContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen halbtransparenten Hintergrund für das Menü.
|
||||
*
|
||||
* @return Geometrie des Overlays
|
||||
*/
|
||||
private Geometry createOverlayBackground() {
|
||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
||||
Geometry overlay = new Geometry("Overlay", quad);
|
||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||
overlay.setMaterial(material);
|
||||
overlay.setLocalTranslation(0, 0, 0);
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schließt das Menü und entfernt die GUI-Elemente.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
System.out.println("Schließe SettingsMenu..."); // Debugging-Ausgabe
|
||||
app.getGuiNode().detachChild(settingsContainer); // Entferne das Menü
|
||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
||||
app.setSettingsMenuOpen(false); // Menü als geschlossen markieren
|
||||
app.unblockInputs(); // Eingaben wieder aktivieren
|
||||
System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user