This commit is contained in:
Johannes Schmelz 2024-11-30 15:15:35 +01:00
commit a70295f1ff
5 changed files with 213 additions and 58 deletions

View File

@ -71,6 +71,14 @@ selector("label-Text", "pp") {
color = buttonEnabledColor
}
selector("label-account", "pp") {
insets = new Insets3f(2, 2, 2, 2)
fontSize = 25
color = buttonEnabledColor
textHAlignment = HAlignment.Center
textVAlignment = VAlignment.Center
}
selector("card-label", "pp") {
insets = new Insets3f(2, 2, 2, 2)
color = ColorRGBA.Black

View File

@ -280,7 +280,7 @@ 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 handleB(boolean isPressed) {
if (isPressed) {
Dialog tmp = new Rent(this);
Dialog tmp = new LooserPopUp(this);
tmp.open();
}
}

View File

@ -245,12 +245,12 @@ public class Toolbar extends Dialog implements GameEventListener {
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR",
new ElementId("label-Text")
new ElementId("label-account")
));
accountContainer.addChild(new Label("Gulag Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getNumJailCard() + "",
new ElementId("label-Text")
new ElementId("label-account")
));
accountContainer.setBackground(createBackground());

View File

@ -1,52 +1,125 @@
package pp.monopoly.client.gui.popups;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
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.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.IconComponent;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
public class LooserPopUp extends Dialog {
private final MonopolyApp app;
private final Geometry overlayBackground;
private final Container LooserContainer;
private final Container backgroundContainer;
/**
* Constructs a new NetworkDialog.
* Constructs a new WinnerPopUp dialog.
*
* @param network The NetworkSupport instance to be used for network operations.
* @param app The MonopolyApp instance.
*/
public LooserPopUp(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
initializeDialog();
// 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 die Warnung
LooserContainer = new Container();
LooserContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
LooserContainer.setPreferredSize(new Vector3f(355,600,10));
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
backgroundContainer.setPreferredSize(LooserContainer.getPreferredSize().addLocal(padding, padding, 0));
// Titel
Label looserTitle = LooserContainer.addChild(new Label("Schade, du hast leider verloren, die nächste Runde wird besser!", new ElementId("header")));
looserTitle.setFontSize(25);
// looserTitle.setColor(ColorRGBA.Black);
// Create the image container
Container imageContainer = LooserContainer.addChild(new Container());
imageContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Dark gray background
imageContainer.setPreferredSize(LooserContainer.getPreferredSize().addLocal(-250, -200, 0)); // Adjust size for layout
// Add the image to the container
Label imageLabel = new Label(""); // Create a label for the image
IconComponent icon = new IconComponent("Pictures/MonopolyLooser.png"); // Load the image as an icon
icon.setIconScale(0.7f); // Scale the image appropriately
imageLabel.setIcon(icon);
imageContainer.addChild(imageLabel); // Add the image label to the container
// Beenden-Button
Button quitButton = LooserContainer.addChild(new Button("Spiel beenden", new ElementId("button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(source -> close());
// Zentriere das Popup
LooserContainer.setLocalTranslation(
(app.getCamera().getWidth() - LooserContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + LooserContainer.getPreferredSize().y) / 2,
8
);
// Zentriere das Popup
backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - LooserContainer.getPreferredSize().x - padding) / 2,
(app.getCamera().getHeight() + LooserContainer.getPreferredSize().y+ padding) / 2,
7
);
app.getGuiNode().attachChild(LooserContainer);
}
/**
* Initializes the dialog with input fields and connection buttons.
* Erstellt einen halbtransparenten Hintergrund für das Menü.
*
* @return Geometrie des Overlays
*/
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("");
IconComponent icon = new IconComponent("Pictures/MonopolyLooser.png"); // Icon mit Textur erstellen
icon.setIconScale(1); // 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, 800, 10);
app.getGuiNode().attachChild(inputContainer);
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(RenderState.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() {
app.getGuiNode().detachChild(LooserContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
super.close();
}
@Override
public void escape() {
close();
}
}

View File

@ -1,51 +1,125 @@
package pp.monopoly.client.gui.popups;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
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.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.IconComponent;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
public class WinnerPopUp extends Dialog {
private final MonopolyApp app;
private final Geometry overlayBackground;
private final Container WinnerContainer;
private final Container backgroundContainer;
/**
* Constructs a new NetworkDialog.
* Constructs a new WinnerPopUp dialog.
*
* @param app The NetworkSupport instance to be used for network operations.
* @param app The MonopolyApp instance.
*/
public WinnerPopUp(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
initializeDialog();
// 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 die Warnung
WinnerContainer = new Container();
WinnerContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
WinnerContainer.setPreferredSize(new Vector3f(440,600,10));
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
backgroundContainer.setPreferredSize(WinnerContainer.getPreferredSize().addLocal(padding, padding, 0));
// Titel
Label winnerTitle = WinnerContainer.addChild(new Label("Herlichen Glückwunsch, du bist der neue Monopoly Champion!", new ElementId("header")));
winnerTitle.setFontSize(25);
// winnerTitle.setColor(ColorRGBA.Black);
// Create the image container
Container imageContainer = WinnerContainer.addChild(new Container());
imageContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); // Dark gray background
imageContainer.setPreferredSize(WinnerContainer.getPreferredSize().addLocal(-250, -200, 0)); // Adjust size for layout
// Add the image to the container
Label imageLabel = new Label(""); // Create a label for the image
IconComponent icon = new IconComponent("Pictures/MonopolyWinner.png"); // Load the image as an icon
icon.setIconScale(1); // Scale the image appropriately
imageLabel.setIcon(icon);
imageContainer.addChild(imageLabel); // Add the image label to the container
// Beenden-Button
Button quitButton = WinnerContainer.addChild(new Button("Spiel beenden", new ElementId("button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(source -> close());
// Zentriere das Popup
WinnerContainer.setLocalTranslation(
(app.getCamera().getWidth() - WinnerContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + WinnerContainer.getPreferredSize().y) / 2,
8
);
// Zentriere das Popup
backgroundContainer.setLocalTranslation(
(app.getCamera().getWidth() - WinnerContainer.getPreferredSize().x - padding) / 2,
(app.getCamera().getHeight() + WinnerContainer.getPreferredSize().y+ padding) / 2,
7
);
app.getGuiNode().attachChild(WinnerContainer);
}
/**
* Initializes the dialog with input fields and connection buttons.
* Erstellt einen halbtransparenten Hintergrund für das Menü.
*
* @return Geometrie des Overlays
*/
private void initializeDialog() {
Container inputContainer = new Container();
// Titel und Eingabefelder für Host und Port
inputContainer.addChild(new Label("Herlichen Glückwunsch!"));
inputContainer.addChild(new Label("Du,bist der Monopoly Champion!!!"));
Label imageLabel = new Label("");
IconComponent icon = new IconComponent("Pictures/MonopolyWinner.png"); // Icon mit Textur erstellen
icon.setIconScale(1); // 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, 800, 0);
app.getGuiNode().attachChild(inputContainer);
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(RenderState.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() {
app.getGuiNode().detachChild(WinnerContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
super.close();
}
@Override
public void escape() {
close();
}
}