Changed host menu. Will update soon.
#story[1087]
This commit is contained in:
@@ -33,6 +33,12 @@ public class HostController extends Controller {
|
|||||||
@FXML
|
@FXML
|
||||||
AnchorPane hostWrapper;
|
AnchorPane hostWrapper;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
TextField gameAddressFld;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
TextField gamePortFld;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
}
|
}
|
||||||
@@ -40,8 +46,12 @@ public class HostController extends Controller {
|
|||||||
public void hostGamePressed() throws IOException{
|
public void hostGamePressed() throws IOException{
|
||||||
try {
|
try {
|
||||||
Event game = Event.getEvent();
|
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();
|
game.start();
|
||||||
connectSocket();
|
connectSocket(gameAddressFld.textProperty().getValue(), Integer.parseInt(gamePortFld.textProperty().getValue()));
|
||||||
} catch (InvalidRaceDataException e) {
|
} catch (InvalidRaceDataException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (XMLReaderException e) {
|
} catch (XMLReaderException e) {
|
||||||
@@ -50,12 +60,14 @@ public class HostController extends Controller {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InvalidRegattaDataException e) {
|
} catch (InvalidRegattaDataException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}}
|
public void connectSocket(String address, int port) {
|
||||||
|
|
||||||
public void connectSocket() {
|
|
||||||
try{
|
try{
|
||||||
Socket socket = new Socket("localhost", 4942);
|
Socket socket = new Socket(address, port);
|
||||||
hostWrapper.setVisible(false);
|
hostWrapper.setVisible(false);
|
||||||
parent.enterLobby(socket);
|
parent.enterLobby(socket);
|
||||||
} catch (IOException e) { /* Never reached */ }
|
} catch (IOException e) { /* Never reached */ }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?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>
|
<children>
|
||||||
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="gameNameField" promptText="Enter game name [DOES NOTHING ATM]" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.valignment="TOP" />
|
<TextField fx:id="gameAddressFld" promptText="Enter Address" 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="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">
|
<Button fx:id="hostGameBtn" mnemonicParsing="false" onAction="#hostGamePressed" text="Host Game" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2">
|
||||||
<font>
|
<font>
|
||||||
<Font size="20.0" />
|
<Font size="20.0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user