|
|
|
@ -6,6 +6,7 @@ import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.TableColumn;
|
|
|
|
import javafx.scene.control.TableColumn;
|
|
|
|
import javafx.scene.control.TableView;
|
|
|
|
import javafx.scene.control.TableView;
|
|
|
|
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import seng302.RaceConnection;
|
|
|
|
import seng302.RaceConnection;
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,16 +32,21 @@ public class ConnectionController extends Controller {
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private Button connectButton;
|
|
|
|
private Button connectButton;
|
|
|
|
|
|
|
|
|
|
|
|
private List<RaceConnection> connections;
|
|
|
|
@FXML
|
|
|
|
|
|
|
|
private TextField urlField;
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
|
|
|
private TextField portField;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableList<RaceConnection> connections;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
|
// TODO - replace with config file
|
|
|
|
// TODO - replace with config file
|
|
|
|
connections = new ArrayList<>();
|
|
|
|
connections = FXCollections.observableArrayList();
|
|
|
|
connections.add(new RaceConnection("livedata.americascup.com", 4941));
|
|
|
|
connections.add(new RaceConnection("livedata.americascup.com", 4941));
|
|
|
|
connections.add(new RaceConnection("localhost", 4942));
|
|
|
|
connections.add(new RaceConnection("localhost", 4942));
|
|
|
|
|
|
|
|
|
|
|
|
connectionTable.setItems(FXCollections.observableArrayList(connections));
|
|
|
|
connectionTable.setItems(connections);
|
|
|
|
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
|
|
|
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
|
|
|
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
|
|
|
|
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
|
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +66,10 @@ public class ConnectionController extends Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AnchorPane startWrapper(){
|
|
|
|
|
|
|
|
return connectionWrapper;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Connects to host currently selected in table. Button enabled only if host is ready.
|
|
|
|
* Connects to host currently selected in table. Button enabled only if host is ready.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -71,4 +81,19 @@ public class ConnectionController extends Controller {
|
|
|
|
parent.enterLobby(socket);
|
|
|
|
parent.enterLobby(socket);
|
|
|
|
} catch (IOException e) { /* Never reached */ }
|
|
|
|
} catch (IOException e) { /* Never reached */ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* adds a new connection
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void addConnection(){
|
|
|
|
|
|
|
|
String hostName = urlField.getText();
|
|
|
|
|
|
|
|
String portString = portField.getText();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
int port = Integer.parseInt(portString);
|
|
|
|
|
|
|
|
connections.add(new RaceConnection(hostName, port));
|
|
|
|
|
|
|
|
}catch(NumberFormatException e){
|
|
|
|
|
|
|
|
System.err.println("Port number entered is not a number");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|