Merge remote-tracking branch 'remotes/origin/temp77' into story77
# Conflicts: # racevisionGame/src/main/java/visualiser/Controllers/InGameLobbyController.java # racevisionGame/src/main/resources/visualiser/scenes/gameLobby.fxml # racevisionGame/src/main/resources/visualiser/scenes/hostgame.fxml
This commit is contained in:
@@ -9,7 +9,11 @@ import javafx.scene.image.ImageView;
|
||||
import mock.app.Event;
|
||||
import mock.exceptions.EventConstructionException;
|
||||
import visualiser.app.App;
|
||||
import visualiser.app.MatchBrowserSingleton;
|
||||
import visualiser.network.MatchBrowserInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -24,11 +28,17 @@ public class HostGameController extends Controller {
|
||||
private @FXML ImageView mapImage;
|
||||
private ArrayList<Image> listOfMaps;
|
||||
private int currentMapIndex = 0;
|
||||
private DatagramSocket udpSocket;
|
||||
private MatchBrowserInterface matchBrowserInterface;
|
||||
|
||||
public void initialize() {
|
||||
loadMaps();
|
||||
this.udpSocket = MatchBrowserSingleton.getInstance().getUdpSocket();
|
||||
this.matchBrowserInterface = MatchBrowserSingleton.getInstance().getMatchBrowserInterface();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Loads in the list of playable maps to be selected from.
|
||||
*/
|
||||
@@ -55,6 +65,8 @@ public class HostGameController extends Controller {
|
||||
App.game = new Event(false, currentMapIndex);
|
||||
App.gameType = currentMapIndex;
|
||||
connectSocket("localhost", 4942);
|
||||
alertMatchBrowser();
|
||||
|
||||
} catch (EventConstructionException e) {
|
||||
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
|
||||
throw new RuntimeException(e);
|
||||
@@ -63,6 +75,17 @@ public class HostGameController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends info to the match browser so clients can see it
|
||||
*/
|
||||
public void alertMatchBrowser(){
|
||||
try{
|
||||
matchBrowserInterface.startSendingHostData(App.game.getHostedGameData(), udpSocket);
|
||||
}catch (IOException e){
|
||||
System.err.println("failed to send out hosted game info");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a socket
|
||||
* @param address address of the server
|
||||
|
||||
@@ -9,6 +9,7 @@ import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import network.Messages.HostGame;
|
||||
import visualiser.app.MatchBrowserSingleton;
|
||||
import visualiser.model.RaceConnection;
|
||||
import visualiser.network.MatchBrowserClientRunnable;
|
||||
import visualiser.network.MatchBrowserInterface;
|
||||
@@ -40,9 +41,9 @@ public class LobbyController extends Controller {
|
||||
|
||||
//the socket for match browser
|
||||
private DatagramSocket udpSocket;
|
||||
|
||||
private MatchBrowserLobbyInterface matchBrowserLobbyInterface;
|
||||
|
||||
|
||||
public void initialize() {
|
||||
// set up the connection table
|
||||
connections = FXCollections.observableArrayList();
|
||||
@@ -62,6 +63,9 @@ public class LobbyController extends Controller {
|
||||
}
|
||||
});
|
||||
joinGameBtn.setDisable(true);
|
||||
|
||||
this.udpSocket = MatchBrowserSingleton.getInstance().getUdpSocket();
|
||||
receiveMatchData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,8 +117,7 @@ public class LobbyController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public void setupSocket(DatagramSocket udpSocket){
|
||||
this.udpSocket = udpSocket;
|
||||
public void receiveMatchData(){
|
||||
matchBrowserLobbyInterface = new MatchBrowserLobbyInterface();
|
||||
try {
|
||||
matchBrowserLobbyInterface.startReceivingHostData(new DatagramSocket(4941));
|
||||
|
||||
@@ -11,6 +11,8 @@ import mock.exceptions.EventConstructionException;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Controller for the opening title window.
|
||||
|
||||
Reference in New Issue
Block a user