Updated host to show the hosted address and port. Fixed css issue with lobby text field.
#story[1087]
This commit is contained in:
@@ -6,6 +6,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.model.RaceConnection;
|
||||
@@ -32,6 +33,10 @@ public class LobbyController extends Controller {
|
||||
private TableColumn<RaceConnection, String> statusColumn;
|
||||
@FXML
|
||||
private Button joinGameBtn;
|
||||
@FXML
|
||||
private TextField addressFld;
|
||||
@FXML
|
||||
private TextField portFld;
|
||||
|
||||
private ObservableList<RaceConnection> connections;
|
||||
|
||||
@@ -39,7 +44,7 @@ public class LobbyController extends Controller {
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
connections = FXCollections.observableArrayList();
|
||||
connections.add(new RaceConnection("localhost", 4942, "Local Game"));
|
||||
//connections.add(new RaceConnection("localhost", 4942, "Local Game"));
|
||||
|
||||
lobbyTable.setItems(connections);
|
||||
|
||||
@@ -62,8 +67,12 @@ public class LobbyController extends Controller {
|
||||
public void refreshBtnPressed(){
|
||||
for(RaceConnection connection: connections) {
|
||||
connection.check();
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (lobbyTable.getSelectionModel().getSelectedItem().statusProperty().getValue().equals("Ready")) {
|
||||
joinGameBtn.setDisable(false);
|
||||
@@ -84,6 +93,22 @@ public class LobbyController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a new connection
|
||||
*/
|
||||
public void addConnectionPressed(){
|
||||
String hostName = addressFld.getText();
|
||||
String portString = portFld.getText();
|
||||
try{
|
||||
int port = Integer.parseInt(portString);
|
||||
connections.add(new RaceConnection(hostName, port, "Boat Game"));
|
||||
addressFld.clear();
|
||||
portFld.clear();
|
||||
}catch(NumberFormatException e){
|
||||
System.err.println("Port number entered is not a number");
|
||||
}
|
||||
}
|
||||
|
||||
public AnchorPane startWrapper(){
|
||||
return lobbyWrapper;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user