Merge remote-tracking branch 'origin/css' into css

main
hba56 9 years ago
commit f4eb03e79e

@ -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 */ }

Loading…
Cancel
Save