Merge remote-tracking branch 'remotes/origin/master' into story77
# Conflicts: # racevisionGame/src/main/java/mock/app/Event.java # racevisionGame/src/main/java/visualiser/Controllers/HostController.java # racevisionGame/src/main/java/visualiser/Controllers/LobbyController.java # racevisionGame/src/main/java/visualiser/Controllers/MainController.java # racevisionGame/src/main/resources/visualiser/scenes/main.fxml # settings/keyBindings.xml
This commit is contained in:
@@ -27,26 +27,15 @@ import java.util.ResourceBundle;
|
||||
* Controller for the Lobby for entering games
|
||||
*/
|
||||
public class LobbyController extends Controller {
|
||||
|
||||
@FXML
|
||||
private AnchorPane lobbyWrapper;
|
||||
@FXML
|
||||
private TableView<RaceConnection> lobbyTable;
|
||||
@FXML
|
||||
private TableColumn<RaceConnection, String> gameNameColumn;
|
||||
@FXML
|
||||
private TableColumn<RaceConnection, String> hostNameColumn;
|
||||
@FXML
|
||||
private TableColumn<RaceConnection, String> statusColumn;
|
||||
@FXML
|
||||
private Button joinGameBtn;
|
||||
@FXML
|
||||
private TextField addressFld;
|
||||
@FXML
|
||||
private TextField portFld;
|
||||
private @FXML TableView<RaceConnection> lobbyTable;
|
||||
private @FXML TableColumn<RaceConnection, String> gameNameColumn;
|
||||
private @FXML TableColumn<RaceConnection, String> hostNameColumn;
|
||||
private @FXML TableColumn<RaceConnection, String> statusColumn;
|
||||
private @FXML Button joinGameBtn;
|
||||
private @FXML TextField addressFld;
|
||||
private @FXML TextField portFld;
|
||||
|
||||
private ObservableList<RaceConnection> connections;
|
||||
|
||||
private ObservableList<RaceConnection> customConnections;
|
||||
|
||||
//the socket for match browser
|
||||
@@ -54,15 +43,13 @@ public class LobbyController extends Controller {
|
||||
|
||||
private MatchBrowserLobbyInterface matchBrowserLobbyInterface;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
public void initialize() {
|
||||
// set up the connection table
|
||||
connections = FXCollections.observableArrayList();
|
||||
customConnections = FXCollections.observableArrayList();
|
||||
//connections.add(new RaceConnection("localhost", 4942, "Local Game"));
|
||||
|
||||
lobbyTable.setItems(connections);
|
||||
|
||||
gameNameColumn.setCellValueFactory(cellData -> cellData.getValue().gamenameProperty());
|
||||
hostNameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
||||
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
|
||||
@@ -70,8 +57,7 @@ public class LobbyController extends Controller {
|
||||
lobbyTable.getSelectionModel().selectedItemProperty().addListener((obs, prev, curr) -> {
|
||||
if (curr != null && curr.statusProperty().getValue().equals("Ready")) {
|
||||
joinGameBtn.setDisable(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
joinGameBtn.setDisable(true);
|
||||
}
|
||||
});
|
||||
@@ -92,27 +78,22 @@ public class LobbyController extends Controller {
|
||||
} else {
|
||||
joinGameBtn.setDisable(true);
|
||||
}
|
||||
} catch (Exception e){}
|
||||
} catch (Exception ignored){}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a connection.
|
||||
*/
|
||||
public void connectSocket() {
|
||||
try{
|
||||
RaceConnection connection = lobbyTable.getSelectionModel().getSelectedItem();
|
||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||
lobbyWrapper.setVisible(false);
|
||||
parent.enterGameLobby(socket, false);
|
||||
} catch (IOException e) { /* Never reached */
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void connectSocket() throws IOException {
|
||||
RaceConnection connection = lobbyTable.getSelectionModel().getSelectedItem();
|
||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||
InGameLobbyController iglc = (InGameLobbyController)loadScene("gameLobby.fxml");
|
||||
iglc.enterGameLobby(socket, false);
|
||||
}
|
||||
|
||||
public void menuBtnPressed(){
|
||||
public void menuBtnPressed() throws IOException {
|
||||
matchBrowserLobbyInterface.closeSocket();
|
||||
lobbyWrapper.setVisible(false);
|
||||
parent.enterTitle();
|
||||
loadScene("title.fxml");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,26 +102,18 @@ public class LobbyController extends Controller {
|
||||
public void addConnectionPressed(){
|
||||
String hostName = addressFld.getText();
|
||||
String portString = portFld.getText();
|
||||
try{
|
||||
try {
|
||||
int port = Integer.parseInt(portString);
|
||||
customConnections.add(new RaceConnection(hostName, port, "Boat Game"));
|
||||
connections.addAll(customConnections);
|
||||
addressFld.clear();
|
||||
portFld.clear();
|
||||
}catch(NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Port number entered is not a number");
|
||||
}
|
||||
}
|
||||
|
||||
public AnchorPane startWrapper(){
|
||||
return lobbyWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter the lobby page.
|
||||
*/
|
||||
public void enterLobby(DatagramSocket udpSocket){
|
||||
lobbyWrapper.setVisible(true);
|
||||
public void setupSocket(DatagramSocket udpSocket){
|
||||
this.udpSocket = udpSocket;
|
||||
matchBrowserLobbyInterface = new MatchBrowserLobbyInterface();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user