Merged with multi visualiser branch so now multiple visualisers can connect to the same host.
#story[1087]
This commit is contained in:
@@ -5,12 +5,17 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import mock.app.App;
|
||||
import mock.app.Event;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
@@ -33,10 +38,20 @@ public class HostController extends Controller {
|
||||
}
|
||||
|
||||
public void hostGamePressed() throws IOException{
|
||||
new App().start(new Stage());
|
||||
System.out.println("Run mock");
|
||||
connectSocket();
|
||||
}
|
||||
try {
|
||||
Event game = Event.getEvent();
|
||||
game.start();
|
||||
connectSocket();
|
||||
} catch (InvalidRaceDataException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XMLReaderException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidBoatDataException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidRegattaDataException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}}
|
||||
|
||||
public void connectSocket() {
|
||||
try{
|
||||
|
||||
@@ -32,28 +32,12 @@ public class TitleController extends Controller {
|
||||
* @throws IOException if main has problems
|
||||
*/
|
||||
public void hostAGame() throws IOException {
|
||||
// load up the main window
|
||||
/*Stage stage = new Stage();
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||
Parent root = loader.load();
|
||||
Scene scene = new Scene(root, 1200, 800);
|
||||
scene.getStylesheets().add("/css/nightMode.css");
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("RaceVision - Team 7");
|
||||
stage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/SailIcon.png")));
|
||||
stage.show();
|
||||
|
||||
// close title screen
|
||||
Stage stageOld = (Stage)btnJoin.getScene().getWindow();
|
||||
stageOld.close();*/
|
||||
titleWrapper.setVisible(false);
|
||||
parent.hostGame();
|
||||
|
||||
}
|
||||
|
||||
public void enterTitle(){
|
||||
|
||||
titleWrapper.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,12 @@ public class App extends Application {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource
|
||||
("/visualiser/scenes/main.fxml"));
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||
Parent root = loader.load();
|
||||
stage.setResizable(false);
|
||||
MainController mc = (MainController) loader.getController();
|
||||
mc.enterTitle();
|
||||
Scene scene = new Scene(root);
|
||||
System.out.println(scene.getHeight());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("RaceVision - Team 7");
|
||||
|
||||
@@ -16,13 +16,13 @@ public class RaceConnection {
|
||||
private final StringProperty status;
|
||||
private final StringProperty gamename;
|
||||
|
||||
public RaceConnection(String hostname, int port, String gamename) {
|
||||
|
||||
/**
|
||||
* Constructor for remote host connections.
|
||||
* @param hostname URL for remote host
|
||||
* @param port port for game feed
|
||||
*/
|
||||
public RaceConnection(String hostname, int port) {
|
||||
public RaceConnection(String hostname, int port, String gamename) {
|
||||
this.hostname = new SimpleStringProperty(hostname);
|
||||
this.port = port;
|
||||
this.status = new SimpleStringProperty("");
|
||||
@@ -34,7 +34,6 @@ public class RaceConnection {
|
||||
* Tries to create a socket to hostname and port, indicates status after test.
|
||||
* @return true if socket can connect
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public boolean check() {
|
||||
//TODO the connection needs to be moved to its own thread, so it doesn't block fx thread.
|
||||
InetSocketAddress i = new InetSocketAddress(hostname.get(), port);
|
||||
|
||||
Reference in New Issue
Block a user