fixed Buttons

This commit is contained in:
Yvonne Schmidt 2024-11-25 02:11:05 +01:00
parent b1ed571950
commit 853c32a5b8

View File

@ -12,7 +12,11 @@ import java.lang.System.Logger.Level;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import com.jme3.material.Material;
import com.jme3.math.Vector3f; 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.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.Label;
@ -60,6 +64,21 @@ public class CreateGameMenu extends Dialog {
port.setSingleLine(true); port.setSingleLine(true);
final MonopolyApp app = network.getApp(); final MonopolyApp app = network.getApp();
int screenWidth = app.getContext().getSettings().getWidth();
int screenHeight = app.getContext().getSettings().getHeight();
// Set up the background image
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(screenWidth, screenHeight);
Geometry 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); // Ensure it is behind other GUI elements
app.getGuiNode().attachChild(background);
final Container input = new Container(new SpringGridLayout()); final Container input = new Container(new SpringGridLayout());
input.addChild(new Label(lookup("host.name") + ": ")); input.addChild(new Label(lookup("host.name") + ": "));
input.addChild(host, 1); input.addChild(host, 1);
@ -72,6 +91,7 @@ public class CreateGameMenu extends Dialog {
cancelButton.addClickCommands(source -> close()); cancelButton.addClickCommands(source -> close());
addChild(cancelButton); addChild(cancelButton);
cancelButton.addClickCommands(s -> ifTopDialog(() -> { cancelButton.addClickCommands(s -> ifTopDialog(() -> {
this.close();
new StartMenu(app); new StartMenu(app);
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
})); }));
@ -86,7 +106,7 @@ public class CreateGameMenu extends Dialog {
joinButton.setPreferredSize(new Vector3f(120, 40, 0)); joinButton.setPreferredSize(new Vector3f(120, 40, 0));
addChild(joinButton); addChild(joinButton);
joinButton.addClickCommands(s -> ifTopDialog(() -> { joinButton.addClickCommands(s -> ifTopDialog(() -> {
app.connect(); connect();
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
})); }));
} }