diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java index f6505c0..8f584b6 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java @@ -14,6 +14,7 @@ import com.simsilica.lemur.component.SpringGridLayout; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.notification.Sound; /** * Constructs the startup menu dialog for the Monopoly application. @@ -54,7 +55,11 @@ public class StartMenu extends Dialog { startButton.setFontSize(40); // Set the font size for the button text startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally - startButton.addClickCommands(s -> app.connect()); + startButton.addClickCommands(s -> ifTopDialog(() -> { + this.close(); // Close the StartMenu dialog + app.connect(); // Perform the connection logic + app.getGameLogic().playSound(Sound.BUTTON); + })); centerMenu.addChild(startButton); // Position the center container in the middle of the screen @@ -114,4 +119,10 @@ public class StartMenu extends Dialog { public void escape() { close(); } + + @Override + public void close() { + app.getGuiNode().detachAllChildren(); + super.close(); + } } \ No newline at end of file