mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-28 18:59:47 +01:00
fixed server join
This commit is contained in:
parent
c124a99901
commit
6b78733a5d
@ -12,6 +12,7 @@ import java.lang.System.Logger.Level;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
@ -40,6 +41,8 @@ public class CreateGameMenu extends SimpleDialog {
|
||||
private final TextField port = new TextField(DEFAULT_PORT);
|
||||
// private final Button serverButton = new Button(lookup("client.server-star"));
|
||||
private final Button serverButton = new Button(lookup("client.server-start"));
|
||||
private final Button cancelButton = addChild(new Button("Abbrechen"));
|
||||
private final Button joinButton = addChild(new Button("Beitreten"));
|
||||
private String hostname;
|
||||
private int portNumber;
|
||||
private Future<Object> connectionFuture;
|
||||
@ -64,17 +67,20 @@ public class CreateGameMenu extends SimpleDialog {
|
||||
input.addChild(new Label(lookup("port.number") + ": "));
|
||||
input.addChild(port, 1);
|
||||
|
||||
DialogBuilder.simple(app.getDialogManager())
|
||||
.setTitle(lookup("server.dialog"))
|
||||
.setExtension(d -> d.addChild(input))
|
||||
.setOkButton(lookup("button.connect"), d -> connect())
|
||||
.setNoButton(lookup("button.cancel"), app::closeApp)
|
||||
.setOkClose(false)
|
||||
.setNoClose(false)
|
||||
.build(this);
|
||||
addChild(input);
|
||||
// "Abbrechen"-Button
|
||||
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
cancelButton.addClickCommands(source -> new StartMenu(app).open());
|
||||
addChild(cancelButton);
|
||||
cancelButton.addClickCommands(s -> new StartMenu(app));
|
||||
|
||||
//Add the button to start the sever
|
||||
addChild(serverButton).addClickCommands(s -> ifTopDialog(this::startServerInThread));
|
||||
// "Selber hosten"-Button
|
||||
addChild(serverButton).addClickCommands(s -> startServerInThread());
|
||||
|
||||
// "Beitreten"-Button
|
||||
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
addChild(joinButton);
|
||||
joinButton.addClickCommands(s -> connect());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,6 +175,7 @@ public class CreateGameMenu extends SimpleDialog {
|
||||
Thread serverThread = new Thread(() -> {
|
||||
try {
|
||||
MonopolyServer.main(null);
|
||||
connect();
|
||||
} catch (Exception e) {
|
||||
serverButton.setEnabled(true);
|
||||
LOGGER.log(Level.ERROR, "Server could not be started", e);
|
||||
|
@ -38,6 +38,9 @@ public class LobbyMenu extends Dialog {
|
||||
private Container lowerLeftMenu;
|
||||
private Container lowerRightMenu;
|
||||
|
||||
private TextField playerInputField = new TextField("Spieler 1");
|
||||
private TextField startingCapital = new TextField("15000");
|
||||
|
||||
public LobbyMenu(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
@ -68,7 +71,7 @@ public class LobbyMenu extends Dialog {
|
||||
spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer
|
||||
|
||||
// Add an input field (TextField)
|
||||
TextField startingCapital = horizontalContainer.addChild(new TextField("15000"));
|
||||
horizontalContainer.addChild(startingCapital);
|
||||
startingCapital.setPreferredWidth(100); // Set the width of the input field
|
||||
startingCapital.setPreferredSize(new Vector3f(150, 50, 0));
|
||||
startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field
|
||||
@ -95,7 +98,6 @@ public class LobbyMenu extends Dialog {
|
||||
playerInputContainer.setBackground(null);
|
||||
|
||||
|
||||
TextField playerInputField = new TextField("Spieler 1");
|
||||
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
|
||||
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
|
||||
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
||||
|
Loading…
Reference in New Issue
Block a user