Issue 19 changes.
This commit is contained in:
@@ -36,6 +36,8 @@ public class HostController extends Controller {
|
||||
@FXML
|
||||
AnchorPane hostWrapper;
|
||||
|
||||
private Event game;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
@@ -47,7 +49,7 @@ public class HostController extends Controller {
|
||||
*/
|
||||
public void hostGamePressed() throws IOException{
|
||||
try {
|
||||
Event game = new Event(false);
|
||||
this.game = new Event(false);
|
||||
game.start();
|
||||
connectSocket("localhost", 4942);
|
||||
} catch (EventConstructionException e) {
|
||||
@@ -56,6 +58,10 @@ public class HostController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public void endEvent() throws IOException {
|
||||
game.endEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a socket
|
||||
* @param address address of the server
|
||||
|
||||
@@ -3,10 +3,12 @@ package visualiser.Controllers;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.app.App;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
@@ -43,6 +45,8 @@ public class MainController extends Controller {
|
||||
raceController.startRace(visualiserRace, controllerClient);
|
||||
}
|
||||
|
||||
public void endEvent() throws IOException { hostController.endEvent(); }
|
||||
|
||||
/**
|
||||
* Transitions from the server selection screen to the pre-race lobby for a given server.
|
||||
* @param socket The server to read data from.
|
||||
@@ -62,7 +66,13 @@ public class MainController extends Controller {
|
||||
/**
|
||||
* Transitions into the title screen
|
||||
*/
|
||||
public void enterTitle(){ titleController.enterTitle(); }
|
||||
public void enterTitle() {
|
||||
try {
|
||||
App.loadStart(App.getStage());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions into lobby screen
|
||||
|
||||
@@ -11,6 +11,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
@@ -25,6 +26,7 @@ import visualiser.gameController.Keys.KeyFactory;
|
||||
import visualiser.model.*;
|
||||
import visualiser.network.ServerConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
@@ -121,6 +123,15 @@ public class RaceController extends Controller {
|
||||
Logger.getGlobal().log(Level.WARNING, "RaceController was interrupted on thread: " + Thread.currentThread() + "while sending: " + controlKey, e);
|
||||
}
|
||||
}
|
||||
if(event.getCode() == KeyCode.ESCAPE){
|
||||
race.setVisible(false);
|
||||
try {
|
||||
parent.endEvent();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
parent.enterTitle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user