Changed host menu. Will update soon.

#story[1087]
main
David Wu 9 years ago
parent 8bb66bc5e4
commit 90f9ec2b98

@ -33,6 +33,12 @@ public class HostController extends Controller {
@FXML
AnchorPane hostWrapper;
@FXML
TextField gameAddressFld;
@FXML
TextField gamePortFld;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
@ -40,8 +46,12 @@ public class HostController extends Controller {
public void hostGamePressed() throws IOException{
try {
Event game = Event.getEvent();
gameAddressFld.textProperty().set(game.getAddress());
gamePortFld.textProperty().set(Integer.toString(game.getPort()));
System.out.println(gameAddressFld.textProperty().getValue());
System.out.println(gamePortFld.textProperty().getValue());
game.start();
connectSocket();
connectSocket(gameAddressFld.textProperty().getValue(), Integer.parseInt(gamePortFld.textProperty().getValue()));
} catch (InvalidRaceDataException e) {
e.printStackTrace();
} catch (XMLReaderException e) {
@ -50,12 +60,14 @@ public class HostController extends Controller {
e.printStackTrace();
} catch (InvalidRegattaDataException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}}
public void connectSocket() {
public void connectSocket(String address, int port) {
try{
Socket socket = new Socket("localhost", 4942);
Socket socket = new Socket(address, port);
hostWrapper.setVisible(false);
parent.enterLobby(socket);
} catch (IOException e) { /* Never reached */ }

@ -7,7 +7,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="hostWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.HostController">
<AnchorPane fx:id="hostWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.HostController">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
@ -21,8 +21,8 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="gameNameField" promptText="Enter game name [DOES NOTHING ATM]" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="TOP" />
<TextField fx:id="hostNameField" promptText="Enter host name [DOES NOTHING ATM]" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="BOTTOM" />
<TextField fx:id="gameAddressFld" promptText="Enter Address" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="TOP" />
<TextField fx:id="gamePortFld" promptText="Enter Port" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="BOTTOM" />
<Button fx:id="hostGameBtn" mnemonicParsing="false" onAction="#hostGamePressed" text="Host Game" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2">
<font>
<Font size="20.0" />

Loading…
Cancel
Save