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