Compare commits

...

8 Commits

Author SHA1 Message Date
Johannes Schmelz
88409dcc99 Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui 2024-11-25 05:42:49 +01:00
Johannes Schmelz
5cacff39b7 refactor typo 2024-11-25 05:42:45 +01:00
Yvonne Schmidt
093723a9d0 added outline for ChoosePartner Menu 2024-11-25 05:40:49 +01:00
Johannes Schmelz
dfdbcdc9f3 board visible again 2024-11-25 05:16:24 +01:00
Johannes Schmelz
bd725e2dc4 refactor 2024-11-25 04:54:35 +01:00
Johannes Schmelz
dd9d9144dd Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui 2024-11-25 04:52:56 +01:00
Johannes Schmelz
1a429e4bb6 fixed settings in toolbar 2024-11-25 04:52:53 +01:00
Yvonne Schmidt
ad6fb5e926 added dice containers 2024-11-25 04:52:34 +01:00
4 changed files with 126 additions and 69 deletions

View File

@ -136,6 +136,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
private boolean isBuyCardPopupOpen = false;
private final ActionListener BListener = (name, isPressed, tpf) -> handleB(isPressed);
private final ActionListener TListener = (name, isPressed, tpf) -> handleT(isPressed);
private TestWorld testWorld;
static {
// Configure logging
@ -296,8 +297,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
//logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen
private void handleT(boolean isPressed) {
if (isPressed) {
TestWorld tmp = new TestWorld(this);
tmp.initializeScene();
testWorld = new TestWorld(this);
testWorld.initializeScene();
}
}
@ -350,6 +351,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
super.simpleUpdate(tpf);
dialogManager.update(tpf);
logic.update(tpf);
//TODO testing replace later
if (testWorld != null) {
testWorld.update(tpf);
}
}
/**

View File

@ -0,0 +1,64 @@
package pp.monopoly.client.gui;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.TextField;
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;
public class ChoosePartner extends Dialog {
private final MonopolyApp app;
private final Container menuContainer;
private Geometry background;
public ChoosePartner(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Hintergrundbild laden und hinzufügen
addBackgroundImage();
QuadBackgroundComponent translucentWhiteBackground =
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
menuContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
menuContainer.setPreferredSize(new Vector3f(1000, 600, 0)); // Fixed size of the container
menuContainer.setBackground(translucentWhiteBackground);
// Create a smaller horizontal container for the label, input field, and spacers
Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size
horizontalContainer.setBackground(null);
Label title = horizontalContainer.addChild(new Label("Wähle deinen Handelspartner:", new ElementId("label-Bold")));
title.setFontSize(40);
}
/**
* Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu.
*/
private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, -1); // Hintergrundebene
app.getGuiNode().attachChild(background);
}
}

View File

@ -6,11 +6,16 @@ import java.util.Random;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.simsilica.lemur.*;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.Panel;
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;
@ -81,11 +86,41 @@ public class Toolbar extends Dialog {
// Menü-Container: Ein Container für Würfel
Container diceContainer = toolbarContainer.addChild(new Container());
diceContainer.setLayout(new SpringGridLayout(Axis.X, Axis.Y));
// Create a horizontal container to align leftContainer and rightContainer side by side
Container horizontalContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
horizontalContainer.setPreferredSize(new Vector3f(200, 150, 0)); // Adjust size as needed
// Create the first container (leftContainer)
Container leftContainer = new Container();
leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
leftContainer.addChild(new Label("Left Container", new ElementId("label")));
leftContainer.addChild(new Button("Button 1"));
// Create the second container (rightContainer)
Container rightContainer = new Container();
rightContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
rightContainer.addChild(new Label("Right Container", new ElementId("label")));
rightContainer.addChild(new Button("Button 2"));
// Add leftContainer and rightContainer to the horizontal container
horizontalContainer.addChild(leftContainer);
horizontalContainer.addChild(rightContainer);
// Add the horizontalContainer to the diceContainer (top section)
diceContainer.addChild(horizontalContainer);
// Add the Würfeln button directly below the horizontalContainer
Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
diceContainer.addChild(diceButton);
diceContainer.setPreferredSize(new Vector3f(400, 150, 0));
diceContainer.addChild(new Label("Wo Würfel?", new ElementId("label")));
diceContainer.addChild(addDiceRollButton());
diceContainer.setBackground(null);
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
@ -144,12 +179,15 @@ public class Toolbar extends Dialog {
private void addTradeMenuButton() {
Button diceButton = new Button("Handeln");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> ifTopDialog(() -> {
diceButton.addClickCommands(s -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
this.close();
System.out.println("test");
new ChoosePartner(app).open();
});
toolbarContainer.addChild(diceButton);
}
}// TODO Funktion der Buttons Überarbeiten und prüfen
private void addEndTurnButton() {
Button diceButton = new Button("Grundstücke");
@ -223,11 +261,15 @@ public class Toolbar extends Dialog {
positionText.setText("Feld-ID: " + currentPosition);
}
/**
* Entfernt die Toolbar.
*/
public void remove() {
@Override
public void close() {
app.getGuiNode().detachChild(toolbarContainer);
app.getGuiNode().detachChild(positionText);
super.close();
}
@Override
public void escape() {
new SettingsMenu(app).open();
}
}

View File

@ -1,55 +0,0 @@
package pp.monopoly.client.gui.popups;
import com.jme3.asset.TextureKey;
import com.jme3.math.Vector2f;
import com.jme3.texture.Texture;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.IconComponent;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
public class LoserPopUp extends Dialog {
private final MonopolyApp app;
/**
* Constructs a new NetworkDialog.
*
* @param network The NetworkSupport instance to be used for network operations.
*/
public LoserPopUp(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
initializeDialog();
}
/**
* Initializes the dialog with input fields and connection buttons.
*/
private void initializeDialog() {
Container inputContainer = new Container();
// Titel und Eingabefelder für Host und Port
inputContainer.addChild(new Label("Schade, du hast leider verloren!"));
inputContainer.addChild(new Label("Die nächste Runde wird besser!"));
Label imageLabel = new Label("");
TextureKey key = new TextureKey("Pictures/MonopolyLoser.png", true);
Texture texture = app.getAssetManager().loadTexture(key);
IconComponent icon = new IconComponent(texture.toString()); // Icon mit Textur erstellen
icon.setIconSize(new Vector2f(155f, 120f)); // Skalierung des Bildes
imageLabel.setIcon(icon); // Setze das Icon im Label
inputContainer.addChild(imageLabel);
Button cancelButton = inputContainer.addChild(new Button("Spiel beenden"));
cancelButton.addClickCommands(source -> ifTopDialog(app::closeApp));
inputContainer.setLocalTranslation(300,500,0);
attachChild(inputContainer);
}
}