mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 02:19:45 +01:00
Verbesserung SettingsMenu
This commit is contained in:
parent
f2fd283d06
commit
ed87a6167d
@ -8,7 +8,6 @@ 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;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
@ -51,9 +50,9 @@ public class StartMenu extends Dialog {
|
|||||||
|
|
||||||
// Center container for title and play button
|
// Center container for title and play button
|
||||||
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||||
Label titleLabel = new Label("Hauptmenü");
|
// Label titleLabel = new Label("Hauptmenü");
|
||||||
titleLabel.setFontSize(48);
|
//titleLabel.setFontSize(48);
|
||||||
centerMenu.addChild(titleLabel);
|
//centerMenu.addChild(titleLabel);
|
||||||
|
|
||||||
Button startButton = new Button("Spielen");
|
Button startButton = new Button("Spielen");
|
||||||
startButton.addClickCommands(source -> startGame(app));
|
startButton.addClickCommands(source -> startGame(app));
|
||||||
|
@ -27,8 +27,8 @@ public class CreateGameMenu {
|
|||||||
Label title = createGameContainer.addChild(new Label("Neues Spiel", new ElementId("title")));
|
Label title = createGameContainer.addChild(new Label("Neues Spiel", new ElementId("title")));
|
||||||
|
|
||||||
// Fügt zwei Eingabefelder unter dem Titel hinzu
|
// Fügt zwei Eingabefelder unter dem Titel hinzu
|
||||||
TextField inputField1 = createGameContainer.addChild(new TextField("Eingabefeld 1"));
|
TextField inputField1 = createGameContainer.addChild(new TextField("Host"));
|
||||||
TextField inputField2 = createGameContainer.addChild(new TextField("Eingabefeld 2"));
|
TextField inputField2 = createGameContainer.addChild(new TextField("Port"));
|
||||||
|
|
||||||
// Erstellt einen Container mit einem Rasterlayout, um die Buttons nebeneinander anzuordnen
|
// Erstellt einen Container mit einem Rasterlayout, um die Buttons nebeneinander anzuordnen
|
||||||
Container buttonContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
Container buttonContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package pp.monopoly.client.gui;
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.shape.Quad;
|
||||||
|
import com.jme3.texture.Texture;
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Checkbox;
|
import com.simsilica.lemur.Checkbox;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
@ -15,15 +19,23 @@ import pp.monopoly.client.MonopolyApp;
|
|||||||
public class SettingsMenu extends Dialog {
|
public class SettingsMenu extends Dialog {
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final Container settingsContainer;
|
private final Container settingsContainer;
|
||||||
|
private Geometry blockLayer;
|
||||||
|
private final Node savedGuiNodeContent = new Node("SavedGuiNodeContent");
|
||||||
|
|
||||||
public SettingsMenu(MonopolyApp app) {
|
public SettingsMenu(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
|
// Blockierungsebene hinzufügen
|
||||||
|
addBlockLayer();
|
||||||
|
|
||||||
|
// Hintergrundbild
|
||||||
|
addBackgroundImage();
|
||||||
|
|
||||||
settingsContainer = new Container();
|
settingsContainer = new Container();
|
||||||
|
|
||||||
// Hintergrundfarbe für das Container-Element setzen, um es undurchsichtig zu machen
|
// Hintergrundfarbe für das Container-Element setzen, um es undurchsichtig zu machen
|
||||||
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1f))); // Dunkelgrauer, undurchsichtiger Hintergrund
|
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.8f))); // Teiltransparent, falls gewünscht
|
||||||
|
|
||||||
// Titel "Einstellungen"
|
// Titel "Einstellungen"
|
||||||
Label settingsTitle = settingsContainer.addChild(new Label("Einstellungen", new ElementId("settings-title")));
|
Label settingsTitle = settingsContainer.addChild(new Label("Einstellungen", new ElementId("settings-title")));
|
||||||
@ -64,15 +76,62 @@ public class SettingsMenu extends Dialog {
|
|||||||
settingsContainer.setLocalTranslation(
|
settingsContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - settingsContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + settingsContainer.getPreferredSize().y) / 2,
|
||||||
0
|
1 // Höhere Z-Ebene für den Vordergrund
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(settingsContainer);
|
app.getGuiNode().attachChild(settingsContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addBlockLayer() {
|
||||||
|
// Sichern des aktuellen GUI-Inhalts
|
||||||
|
for (var child : app.getGuiNode().getChildren()) {
|
||||||
|
savedGuiNodeContent.attachChild(child);
|
||||||
|
}
|
||||||
|
app.getGuiNode().detachAllChildren();
|
||||||
|
|
||||||
|
// Blockierungsebene erstellen und hinzufügen
|
||||||
|
blockLayer = new Geometry("BlockLayer", new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()));
|
||||||
|
blockLayer.setMaterial(createTransparentMaterial());
|
||||||
|
blockLayer.setLocalTranslation(0, 0, 0); // Platzierung unterhalb des SettingsMenu
|
||||||
|
app.getGuiNode().attachChild(blockLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private com.jme3.material.Material createTransparentMaterial() {
|
||||||
|
com.jme3.material.Material material = new com.jme3.material.Material(
|
||||||
|
app.getAssetManager(),
|
||||||
|
"Common/MatDefs/Misc/Unshaded.j3md"
|
||||||
|
);
|
||||||
|
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
||||||
|
material.getAdditionalRenderState().setBlendMode(com.jme3.material.RenderState.BlendMode.Alpha);
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBackgroundImage() {
|
||||||
|
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
|
||||||
|
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
||||||
|
Geometry background = new Geometry("Background", quad);
|
||||||
|
com.jme3.material.Material backgroundMaterial = new com.jme3.material.Material(
|
||||||
|
app.getAssetManager(),
|
||||||
|
"Common/MatDefs/Misc/Unshaded.j3md"
|
||||||
|
);
|
||||||
|
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
||||||
|
background.setMaterial(backgroundMaterial);
|
||||||
|
background.setLocalTranslation(0, 0, -1); // Platzierung hinter dem SettingsMenu
|
||||||
|
app.getGuiNode().attachChild(background);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
// Entfernt das SettingsMenu und die Blockierungsebene
|
||||||
app.getGuiNode().detachChild(settingsContainer);
|
app.getGuiNode().detachChild(settingsContainer);
|
||||||
|
app.getGuiNode().detachChild(blockLayer);
|
||||||
|
|
||||||
|
// Stellt die ursprüngliche GUI wieder her
|
||||||
|
for (var child : savedGuiNodeContent.getChildren()) {
|
||||||
|
app.getGuiNode().attachChild(child);
|
||||||
|
}
|
||||||
|
savedGuiNodeContent.detachAllChildren();
|
||||||
|
|
||||||
app.setSettingsMenuOpen(false);
|
app.setSettingsMenuOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user