buttons now work as intended

This commit is contained in:
Johannes Schmelz 2024-11-25 01:51:27 +01:00
parent c87406f60e
commit 1a75d6d6a8
4 changed files with 19 additions and 10 deletions

View File

@ -434,4 +434,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
.build()
.open();
}
public void disconnect() {
serverConnection.disconnect();
}
}

View File

@ -68,17 +68,20 @@ public class CreateGameMenu extends Dialog {
addChild(input);
// "Abbrechen"-Button
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
cancelButton.addClickCommands(source -> close());
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
this.close();
new StartMenu(network.getApp()).open();
}));
addChild(cancelButton);
cancelButton.addClickCommands(s -> new StartMenu(app));
// "Selber hosten"-Button
addChild(serverButton).addClickCommands(s -> startServerInThread());
serverButton.addClickCommands(s -> ifTopDialog(this::startServerInThread));
addChild(serverButton);
// "Beitreten"-Button
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
joinButton.addClickCommands(s -> ifTopDialog(this::connect));
addChild(joinButton);
joinButton.addClickCommands(s -> connect());
}
/**
@ -125,7 +128,7 @@ public class CreateGameMenu extends Dialog {
@Override
public void escape() {
close();
new SettingsMenu(network.getApp()).open();
}
/**

View File

@ -130,10 +130,12 @@ public class LobbyMenu extends Dialog {
buttonContainer.setBackground(null);
// Lower-left container for "Abbrechen" button
lowerLeftMenu = new Container();
Button cancelButton = new Button("Abbrechen");
Button cancelButton = new Button("Beenden");
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
cancelButton.setFontSize(18); // Adjust font size
cancelButton.addClickCommands(source -> close()); // Add functionality
cancelButton.addClickCommands(source -> ifTopDialog( () -> {
app.closeApp();
})); // Add functionality
lowerLeftMenu.addChild(cancelButton);
// Position the container near the bottom-left corner
@ -146,7 +148,7 @@ public class LobbyMenu extends Dialog {
readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
readyButton.setFontSize(18); // Adjust font size
readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style
readyButton.addClickCommands(source -> toggleReady()); // Add functionality
readyButton.addClickCommands(source -> ifTopDialog(this::toggleReady)); // Add functionality
lowerRightMenu.addChild(readyButton);
// Position the container near the bottom-right corner
@ -210,7 +212,7 @@ public class LobbyMenu extends Dialog {
@Override
public void escape() {
super.close();
new SettingsMenu(app).open();
}
/**

View File

@ -117,7 +117,7 @@ public class StartMenu extends Dialog {
@Override
public void escape() {
super.close();
new SettingsMenu(app).open();
}
@Override