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
|
||||
|
||||
Reference in New Issue
Block a user