mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 00:06:16 +01:00
resized WinnerPopUp
This commit is contained in:
parent
05680af726
commit
119284f256
@ -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 WinnerPopUp(this);
|
||||
tmp.open();
|
||||
}
|
||||
}
|
||||
|
@ -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("Bestätigen", 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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user