Finished Arrow, Title and StartController scene splitting
- scenes do not load in at the same time - scenes do not rely upon previous abstract controller class - scenes are not a part of previous main controller class - unecessary functions and code removed #story[1261]
This commit is contained in:
@@ -3,6 +3,7 @@ package shared.model;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import visualiser.Controllers2.StartController;
|
||||
import visualiser.model.ResizableRaceCanvas;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -16,7 +17,7 @@ import java.util.Date;
|
||||
* displays times relevant to a race. This is displayed on the
|
||||
* {@link ResizableRaceCanvas} via the
|
||||
* {@link visualiser.Controllers.RaceController} and the
|
||||
* {@link visualiser.Controllers.StartController}.
|
||||
* {@link StartController}.
|
||||
*/
|
||||
public class RaceClock {
|
||||
|
||||
|
||||
@@ -7,16 +7,14 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.Controllers2.Controller2;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
/**
|
||||
* Finish Screen for when the race finishes.
|
||||
*/
|
||||
public class FinishController extends Controller {
|
||||
public class FinishController extends Controller2 {
|
||||
|
||||
@FXML
|
||||
AnchorPane finishWrapper;
|
||||
@@ -40,19 +38,6 @@ public class FinishController extends Controller {
|
||||
private ObservableList<VisualiserBoat> boats;
|
||||
|
||||
|
||||
/**
|
||||
* Ctor.
|
||||
*/
|
||||
public FinishController() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the finish table
|
||||
* @param boats Boats to display
|
||||
|
||||
@@ -2,9 +2,14 @@ package visualiser.Controllers;
|
||||
|
||||
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.SplitPane;
|
||||
@@ -12,8 +17,13 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import mock.app.Event;
|
||||
import mock.exceptions.EventConstructionException;
|
||||
import visualiser.Controllers2.Controller2;
|
||||
import visualiser.Controllers2.StartController;
|
||||
import visualiser.app.App;
|
||||
import visualiser.layout.Subject3D;
|
||||
import visualiser.layout.View3D;
|
||||
|
||||
@@ -21,46 +31,24 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Controller for Hosting a game.
|
||||
*/
|
||||
public class HostController extends Controller {
|
||||
|
||||
|
||||
// @FXML
|
||||
// TextField gameNameField;
|
||||
//
|
||||
// @FXML
|
||||
// TextField hostNameField;
|
||||
|
||||
@FXML
|
||||
private ImageView imageView;
|
||||
|
||||
@FXML
|
||||
AnchorPane hostWrapper;
|
||||
|
||||
@FXML
|
||||
AnchorPane imagePane;
|
||||
|
||||
@FXML
|
||||
SplitPane splitPane;
|
||||
|
||||
@FXML
|
||||
AnchorPane specPane;
|
||||
|
||||
@FXML
|
||||
GridPane playerContainer;
|
||||
|
||||
public class HostController extends Controller2 {
|
||||
private @FXML ImageView imageView;
|
||||
private @FXML AnchorPane hostWrapper;
|
||||
private @FXML AnchorPane imagePane;
|
||||
private @FXML SplitPane splitPane;
|
||||
private @FXML AnchorPane specPane;
|
||||
private @FXML GridPane playerContainer;
|
||||
private Event game;
|
||||
|
||||
private View3D view3D;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
public void initialize() {
|
||||
hostGame();
|
||||
ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||
|
||||
view3D = new View3D();
|
||||
@@ -114,15 +102,12 @@ public class HostController extends Controller {
|
||||
public void connectSocket(String address, int port) {
|
||||
try{
|
||||
Socket socket = new Socket(address, port);
|
||||
hostWrapper.setVisible(false);
|
||||
parent.enterLobby(socket, true);
|
||||
StartController sc = (StartController)loadScene
|
||||
("start.fxml");
|
||||
sc.enterLobby(socket, true);
|
||||
} catch (IOException e) { /* Never reached */ }
|
||||
}
|
||||
|
||||
public AnchorPane startWrapper(){
|
||||
return hostWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts a game.
|
||||
*/
|
||||
@@ -131,21 +116,34 @@ public class HostController extends Controller {
|
||||
splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> div.setMouseTransparent(true));
|
||||
imageView.fitWidthProperty().bind(imagePane.widthProperty());
|
||||
imageView.fitHeightProperty().bind(imagePane.heightProperty());
|
||||
hostWrapper.setVisible(true);
|
||||
// hostWrapper.setVisible(true); tick
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu button pressed. Prompt alert then return to menu
|
||||
*/
|
||||
public void menuBtnPressed(){
|
||||
public void menuBtnPressed() throws IOException {
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
alert.setTitle("Quitting race");
|
||||
alert.setContentText("Do you wish to quit the race?");
|
||||
alert.setHeaderText("You are about to quit the race");
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if(result.get() == ButtonType.OK){
|
||||
hostWrapper.setVisible(false);
|
||||
parent.enterTitle();
|
||||
// hostWrapper.setVisible(false);
|
||||
Stage stage = App.getStage();
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||
Parent root = loader.load();
|
||||
stage.setResizable(false);
|
||||
Scene scene = new Scene(root);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override public void handle(WindowEvent event) {
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
// parent.enterTitle(); tick
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import visualiser.Controllers2.Controller;
|
||||
import visualiser.Controllers2.Controller2;
|
||||
import visualiser.gameController.Keys.ControlKey;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
|
||||
@@ -27,7 +27,7 @@ import static visualiser.app.App.keyFactory;
|
||||
/**
|
||||
* Controller for the scene used to display and update current key bindings.
|
||||
*/
|
||||
public class KeyBindingsController extends Controller{
|
||||
public class KeyBindingsController extends Controller2 {
|
||||
private @FXML Button btnSave;
|
||||
private @FXML Button btnCancel;
|
||||
private @FXML Button btnReset;
|
||||
|
||||
@@ -8,17 +8,17 @@ import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.Controllers2.Controller2;
|
||||
import visualiser.Controllers2.StartController;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Controller for the Lobby for entering games
|
||||
*/
|
||||
public class LobbyController extends Controller {
|
||||
public class LobbyController extends Controller2 {
|
||||
|
||||
@FXML
|
||||
private AnchorPane lobbyWrapper;
|
||||
@@ -40,8 +40,8 @@ public class LobbyController extends Controller {
|
||||
private ObservableList<RaceConnection> connections;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
// @Override
|
||||
public void initialize() {
|
||||
connections = FXCollections.observableArrayList();
|
||||
//connections.add(new RaceConnection("localhost", 4942, "Local Game"));
|
||||
|
||||
@@ -86,15 +86,18 @@ public class LobbyController extends Controller {
|
||||
RaceConnection connection = lobbyTable.getSelectionModel().getSelectedItem();
|
||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||
lobbyWrapper.setVisible(false);
|
||||
parent.enterLobby(socket, false);
|
||||
// parent.enterLobby(socket, false);
|
||||
StartController sc = (StartController)loadScene(
|
||||
"/visualiser/scenes/start.fxml");
|
||||
sc.enterLobby(socket, false);
|
||||
} catch (IOException e) { /* Never reached */
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void menuBtnPressed(){
|
||||
lobbyWrapper.setVisible(false);
|
||||
parent.enterTitle();
|
||||
public void menuBtnPressed() throws IOException {
|
||||
// parent.enterTitle();
|
||||
loadScene("titleScreen.fxml");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,8 @@ package visualiser.Controllers;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.Controllers2.StartController;
|
||||
import visualiser.Controllers2.TitleController;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
@@ -63,12 +65,12 @@ public class MainController extends Controller {
|
||||
finishController.enterFinish(boats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions into the title screen
|
||||
*/
|
||||
public void enterTitle() {
|
||||
titleController.enterTitle();
|
||||
}
|
||||
// /**
|
||||
// * Transitions into the title screen
|
||||
// */
|
||||
// public void enterTitle() {
|
||||
// titleController.enterTitle();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Transitions into lobby screen
|
||||
@@ -94,38 +96,38 @@ public class MainController extends Controller {
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
startController.setParent(this);
|
||||
raceController.setParent(this);
|
||||
connectionController.setParent(this);
|
||||
finishController.setParent(this);
|
||||
// startController.setParent(this);
|
||||
// raceController.setParent(this);
|
||||
// connectionController.setParent(this);
|
||||
// finishController.setParent(this);
|
||||
// titleController.setParent(this);
|
||||
hostController.setParent(this);
|
||||
lobbyController.setParent(this);
|
||||
// hostController.setParent(this);
|
||||
// lobbyController.setParent(this);
|
||||
|
||||
|
||||
AnchorPane.setTopAnchor(startController.startWrapper(), 0.0);
|
||||
AnchorPane.setBottomAnchor(startController.startWrapper(), 0.0);
|
||||
AnchorPane.setLeftAnchor(startController.startWrapper(), 0.0);
|
||||
AnchorPane.setRightAnchor(startController.startWrapper(), 0.0);
|
||||
// AnchorPane.setTopAnchor(startController.startWrapper(), 0.0);
|
||||
// AnchorPane.setBottomAnchor(startController.startWrapper(), 0.0);
|
||||
// AnchorPane.setLeftAnchor(startController.startWrapper(), 0.0);
|
||||
// AnchorPane.setRightAnchor(startController.startWrapper(), 0.0);
|
||||
|
||||
AnchorPane.setTopAnchor(lobbyController.startWrapper(), 0.0);
|
||||
AnchorPane.setBottomAnchor(lobbyController.startWrapper(), 0.0);
|
||||
AnchorPane.setLeftAnchor(lobbyController.startWrapper(), 0.0);
|
||||
AnchorPane.setRightAnchor(lobbyController.startWrapper(), 0.0);
|
||||
|
||||
AnchorPane.setTopAnchor(hostController.startWrapper(), 0.0);
|
||||
AnchorPane.setBottomAnchor(hostController.startWrapper(), 0.0);
|
||||
AnchorPane.setLeftAnchor(hostController.startWrapper(), 0.0);
|
||||
AnchorPane.setRightAnchor(hostController.startWrapper(), 0.0);
|
||||
// AnchorPane.setTopAnchor(hostController.startWrapper(), 0.0);
|
||||
// AnchorPane.setBottomAnchor(hostController.startWrapper(), 0.0);
|
||||
// AnchorPane.setLeftAnchor(hostController.startWrapper(), 0.0);
|
||||
// AnchorPane.setRightAnchor(hostController.startWrapper(), 0.0);
|
||||
|
||||
AnchorPane.setTopAnchor(finishController.finishWrapper, 0.0);
|
||||
AnchorPane.setBottomAnchor(finishController.finishWrapper, 0.0);
|
||||
AnchorPane.setLeftAnchor(finishController.finishWrapper, 0.0);
|
||||
AnchorPane.setRightAnchor(finishController.finishWrapper, 0.0);
|
||||
|
||||
AnchorPane.setTopAnchor(titleController.titleWrapper, 0.0);
|
||||
AnchorPane.setBottomAnchor(titleController.titleWrapper, 0.0);
|
||||
AnchorPane.setLeftAnchor(titleController.titleWrapper, 0.0);
|
||||
AnchorPane.setRightAnchor(titleController.titleWrapper, 0.0);
|
||||
// AnchorPane.setTopAnchor(titleController.titleWrapper, 0.0);
|
||||
// AnchorPane.setBottomAnchor(titleController.titleWrapper, 0.0);
|
||||
// AnchorPane.setLeftAnchor(titleController.titleWrapper, 0.0);
|
||||
// AnchorPane.setRightAnchor(titleController.titleWrapper, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,15 @@ import javafx.scene.layout.StackPane;
|
||||
import javafx.util.Callback;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import shared.model.Leg;
|
||||
import visualiser.app.App;
|
||||
import visualiser.Controllers2.ArrowController;
|
||||
import visualiser.Controllers2.Controller2;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.gameController.Keys.ControlKey;
|
||||
import visualiser.model.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -38,7 +37,7 @@ import static visualiser.app.App.keyFactory;
|
||||
/**
|
||||
* Controller used to display a running race.
|
||||
*/
|
||||
public class RaceController extends Controller {
|
||||
public class RaceController extends Controller2 {
|
||||
|
||||
|
||||
/**
|
||||
@@ -103,16 +102,7 @@ public class RaceController extends Controller {
|
||||
@FXML private LineChart<Number, Number> sparklineChart;
|
||||
@FXML private AnchorPane annotationPane;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Ctor.
|
||||
*/
|
||||
public RaceController() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
public void initialize() {
|
||||
// KeyFactory keyFactory = KeyFactory.getFactory();
|
||||
infoTableShow = true;
|
||||
|
||||
@@ -142,9 +132,12 @@ public class RaceController extends Controller {
|
||||
alert.setContentText("Do you wish to quit the race? You are the host");
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if (result.get() == ButtonType.OK) {
|
||||
parent.endEvent();
|
||||
// parent.endEvent();
|
||||
HostController hc = (HostController)loadScene(
|
||||
"/visualiser/scenes/hostgame.fxml");
|
||||
hc.endEvent();
|
||||
race.setVisible(false);
|
||||
App.app.showMainStage(App.getStage());
|
||||
// App.app.showMainStage(App.getStage());
|
||||
}
|
||||
} else {
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
@@ -153,7 +146,7 @@ public class RaceController extends Controller {
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if (result.get() == ButtonType.OK) {
|
||||
race.setVisible(false);
|
||||
App.app.showMainStage(App.getStage());
|
||||
// App.app.showMainStage(App.getStage());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -434,7 +427,16 @@ public class RaceController extends Controller {
|
||||
*/
|
||||
public void finishRace(ObservableList<VisualiserBoat> boats) {
|
||||
race.setVisible(false);
|
||||
parent.enterFinish(boats);
|
||||
|
||||
// parent.enterFinish(boats);
|
||||
try {
|
||||
FinishController fc = (FinishController)loadScene
|
||||
("/visualiser/scenes/finish.fxml");
|
||||
fc.enterFinish(boats);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -482,9 +484,9 @@ public class RaceController extends Controller {
|
||||
race.setVisible(false);
|
||||
//parent.enterTitle();
|
||||
try {
|
||||
App.app.showMainStage(App.getStage());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// App.app.showMainStage(App.getStage());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import mock.model.commandFactory.CompositeCommand;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RequestToJoinEnum;
|
||||
import network.Messages.LatestMessages;
|
||||
import shared.dataInput.*;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.model.VisualiserRaceState;
|
||||
import visualiser.network.ServerConnection;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* Controller to for waiting for the race to start.
|
||||
*/
|
||||
public class StartController extends Controller {
|
||||
|
||||
@FXML private GridPane start;
|
||||
@FXML private AnchorPane startWrapper;
|
||||
|
||||
/**
|
||||
* The name of the race/regatta.
|
||||
*/
|
||||
@FXML private Label raceTitleLabel;
|
||||
|
||||
/**
|
||||
* The time the race starts at.
|
||||
*/
|
||||
@FXML private Label raceStartLabel;
|
||||
|
||||
/**
|
||||
* The current time at the race location.
|
||||
*/
|
||||
@FXML private Label timeZoneTime;
|
||||
|
||||
/**
|
||||
* Time until the race starts.
|
||||
*/
|
||||
@FXML private Label timer;
|
||||
|
||||
@FXML private TableView<VisualiserBoat> boatNameTable;
|
||||
@FXML private TableColumn<VisualiserBoat, String> boatNameColumn;
|
||||
@FXML private TableColumn<VisualiserBoat, String> boatCodeColumn;
|
||||
|
||||
/**
|
||||
* The status of the race.
|
||||
*/
|
||||
@FXML private Label raceStatusLabel;
|
||||
|
||||
|
||||
/**
|
||||
* The race + connection to server.
|
||||
*/
|
||||
private VisualiserRaceEvent visualiserRaceEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Writes BoatActions to outgoing message queue.
|
||||
*/
|
||||
private ControllerClient controllerClient;
|
||||
|
||||
private boolean isHost;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Ctor.
|
||||
*/
|
||||
public StartController() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts the race.
|
||||
*/
|
||||
private void startRace() {
|
||||
|
||||
//Initialise the boat table.
|
||||
initialiseBoatTable(this.visualiserRaceEvent.getVisualiserRaceState());
|
||||
|
||||
//Initialise the race name.
|
||||
initialiseRaceName(this.visualiserRaceEvent.getVisualiserRaceState());
|
||||
|
||||
//Initialises the race clock.
|
||||
initialiseRaceClock(this.visualiserRaceEvent.getVisualiserRaceState());
|
||||
|
||||
//Starts the race countdown timer.
|
||||
countdownTimer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public AnchorPane startWrapper(){
|
||||
return startWrapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the boat table that is to be shown on the pane.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseBoatTable(VisualiserRaceState visualiserRace) {
|
||||
|
||||
//Get the boats.
|
||||
ObservableList<VisualiserBoat> boats = visualiserRace.getBoats();
|
||||
|
||||
//Populate table.
|
||||
boatNameTable.setItems(boats);
|
||||
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
|
||||
boatCodeColumn.setCellValueFactory(cellData -> cellData.getValue().countryProperty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the race name which is shown on the pane.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseRaceName(VisualiserRaceState visualiserRace) {
|
||||
|
||||
raceTitleLabel.setText(visualiserRace.getRegattaName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the race clock/timer labels for the start time, current time, and remaining time.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseRaceClock(VisualiserRaceState visualiserRace) {
|
||||
|
||||
//Start time.
|
||||
initialiseRaceClockStartTime(visualiserRace);
|
||||
|
||||
//Current time.
|
||||
initialiseRaceClockCurrentTime(visualiserRace);
|
||||
|
||||
//Remaining time.
|
||||
initialiseRaceClockDuration(visualiserRace);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the race current time label.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseRaceClockStartTime(VisualiserRaceState visualiserRace) {
|
||||
|
||||
raceStartLabel.setText(visualiserRace.getRaceClock().getStartingTimeString());
|
||||
|
||||
visualiserRace.getRaceClock().startingTimeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
raceStartLabel.setText(newValue);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the race current time label.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseRaceClockCurrentTime(VisualiserRaceState visualiserRace) {
|
||||
|
||||
visualiserRace.getRaceClock().currentTimeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timeZoneTime.setText(newValue);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the race duration label.
|
||||
* @param visualiserRace The race to get data from.
|
||||
*/
|
||||
private void initialiseRaceClockDuration(VisualiserRaceState visualiserRace) {
|
||||
|
||||
visualiserRace.getRaceClock().durationProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timer.setText(newValue);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Countdown timer until race starts.
|
||||
*/
|
||||
private void countdownTimer() {
|
||||
new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long arg0) {
|
||||
|
||||
//Get the current race status.
|
||||
RaceStatusEnum raceStatus = visualiserRaceEvent.getVisualiserRaceState().getRaceStatusEnum();
|
||||
|
||||
//Display it.
|
||||
raceStatusLabel.setText("Race Status: " + raceStatus.name());
|
||||
|
||||
|
||||
//If the race has reached the preparatory phase, or has started...
|
||||
if (raceStatus == RaceStatusEnum.PREPARATORY || raceStatus == RaceStatusEnum.STARTED) {
|
||||
//Stop this timer.
|
||||
stop();
|
||||
|
||||
//Hide this, and display the race controller.
|
||||
startWrapper.setVisible(false);
|
||||
//start.setVisible(false);//TODO is this needed?
|
||||
|
||||
parent.beginRace(visualiserRaceEvent, controllerClient, isHost);
|
||||
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show starting information for a race given a socket.
|
||||
* @param socket network source of information
|
||||
* @param isHost is user a host
|
||||
*/
|
||||
public void enterLobby(Socket socket, Boolean isHost) {
|
||||
try {
|
||||
|
||||
this.isHost = isHost;
|
||||
|
||||
this.visualiserRaceEvent = new VisualiserRaceEvent(socket, RequestToJoinEnum.PARTICIPANT);
|
||||
|
||||
this.controllerClient = visualiserRaceEvent.getControllerClient();
|
||||
|
||||
|
||||
startWrapper.setVisible(true);
|
||||
|
||||
startRace();
|
||||
|
||||
} catch (IOException e) {
|
||||
//TODO should probably let this propagate, so that we only enter this scene if everything works
|
||||
Logger.getGlobal().log(Level.WARNING, "Could not connect to server.", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
-64
@@ -1,65 +1,31 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
package visualiser.Controllers2;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.shape.Circle;
|
||||
import shared.model.Bearing;
|
||||
import shared.model.Wind;
|
||||
|
||||
/**
|
||||
* Controller for the arrow.fxml view.
|
||||
* Controller for the wind direction arrow on the race screen.
|
||||
*/
|
||||
public class ArrowController {
|
||||
|
||||
|
||||
@FXML
|
||||
private Pane compass;
|
||||
|
||||
@FXML
|
||||
private StackPane arrowStackPane;
|
||||
|
||||
@FXML
|
||||
private ImageView arrowImage;
|
||||
|
||||
@FXML
|
||||
private Circle circle;
|
||||
|
||||
@FXML
|
||||
private Label northLabel;
|
||||
|
||||
@FXML
|
||||
private Label windLabel;
|
||||
|
||||
@FXML
|
||||
private Label speedLabel;
|
||||
|
||||
|
||||
/**
|
||||
* This is the property our arrow control binds to.
|
||||
*/
|
||||
private Property<Wind> wind;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ArrowController() {
|
||||
}
|
||||
|
||||
private @FXML StackPane arrowStackPane;
|
||||
private @FXML ImageView arrowImage;
|
||||
private @FXML Label speedLabel;
|
||||
private final static Integer MIN_KNOTS = 2; // knots for min_height
|
||||
private final static Integer MAX_KNOTS = 30; // knots for max_height
|
||||
private final static Integer MIN_HEIGHT = 25; // min arrow height
|
||||
private final static Integer MAX_HEIGHT = 75; // max arrow height
|
||||
|
||||
/**
|
||||
* Sets which wind property the arrow control should bind to.
|
||||
* @param wind The wind property to bind to.
|
||||
*/
|
||||
public void setWindProperty(Property<Wind> wind) {
|
||||
this.wind = wind;
|
||||
|
||||
wind.addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
Platform.runLater(() -> updateWind(newValue));
|
||||
@@ -67,7 +33,6 @@ public class ArrowController {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the control to use the new wind value.
|
||||
* This updates the arrow direction (due to bearing), arrow length (due to speed), and label (due to speed).
|
||||
@@ -78,7 +43,6 @@ public class ArrowController {
|
||||
updateWindSpeed(wind.getWindSpeed());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the control to account for the new wind speed.
|
||||
* This changes the length (height) of the wind arrow, and updates the speed label.
|
||||
@@ -94,29 +58,22 @@ public class ArrowController {
|
||||
* @param speedKnots Wind speed, in knots.
|
||||
*/
|
||||
private void updateWindArrowLength(double speedKnots) {
|
||||
|
||||
//At 2 knots, the arrow reaches its minimum height, and at 30 knots it reaches its maximum height.
|
||||
double minKnots = 2;
|
||||
double maxKnots = 30;
|
||||
double deltaKnots = maxKnots - minKnots;
|
||||
|
||||
double minHeight = 25;
|
||||
double maxHeight = 75;
|
||||
double deltaHeight = maxHeight - minHeight;
|
||||
double deltaKnots = MAX_KNOTS - MIN_KNOTS;
|
||||
double deltaHeight = MAX_HEIGHT - MIN_HEIGHT;
|
||||
|
||||
//Clamp speed.
|
||||
if (speedKnots > maxKnots) {
|
||||
speedKnots = maxKnots;
|
||||
} else if (speedKnots < minKnots) {
|
||||
speedKnots = minKnots;
|
||||
if (speedKnots > MAX_KNOTS) {
|
||||
speedKnots = MAX_KNOTS;
|
||||
} else if (speedKnots < MIN_KNOTS) {
|
||||
speedKnots = MIN_KNOTS;
|
||||
}
|
||||
|
||||
//How far between the knots bounds is the current speed?
|
||||
double currentDeltaKnots = speedKnots - minKnots;
|
||||
double currentDeltaKnots = speedKnots - MIN_KNOTS;
|
||||
double currentKnotsScalar = currentDeltaKnots / deltaKnots;
|
||||
|
||||
//Thus, how far between the pixel height bounds should the arrow height be?
|
||||
double newHeight = minHeight + (currentKnotsScalar * deltaHeight);
|
||||
double newHeight = MIN_HEIGHT + (currentKnotsScalar * deltaHeight);
|
||||
|
||||
arrowImage.setFitHeight(newHeight);
|
||||
}
|
||||
@@ -129,7 +86,6 @@ public class ArrowController {
|
||||
speedLabel.setText(String.format("%.1fkn", speedKnots));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the control to account for a new wind bearing.
|
||||
* This rotates the arrow according to the bearing.
|
||||
@@ -140,7 +96,4 @@ public class ArrowController {
|
||||
arrowStackPane.setRotate(bearing.degrees());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+22
-6
@@ -7,14 +7,13 @@ import javafx.scene.image.Image;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Abstract controller class to give each subclass the functionality to load
|
||||
* a new scene into the existing stage, or create a new popup window.
|
||||
*/
|
||||
public abstract class Controller {
|
||||
public class Controller2 {
|
||||
|
||||
/**
|
||||
* Used to load a new scene in the currently open stage.
|
||||
@@ -22,15 +21,27 @@ public abstract class Controller {
|
||||
* @return the controller of the new scene
|
||||
* @throws IOException if there is an issue with the fxmlUrl
|
||||
*/
|
||||
protected Controller loadScene(String fxmlUrl) throws IOException {
|
||||
protected Controller2 loadScene(String fxmlUrl) throws IOException {
|
||||
// load the correct fxml file
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(getClass().getResource(fxmlUrl));
|
||||
loader.setLocation(getClass().getResource
|
||||
("/visualiser/scenes/"+fxmlUrl));
|
||||
Parent root = loader.load();
|
||||
|
||||
// reuse previous stage and it's window size
|
||||
Stage stage = App.getStage();
|
||||
Double stageHeight = stage.getHeight();
|
||||
Double stageWidth = stage.getWidth();
|
||||
|
||||
// set new scene into existing window
|
||||
Scene scene = new Scene(root);
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(true);
|
||||
stage.show();
|
||||
stage.setHeight(stageHeight);
|
||||
stage.setWidth(stageWidth);
|
||||
|
||||
// return controller for the loaded fxml scene
|
||||
return loader.getController();
|
||||
}
|
||||
|
||||
@@ -42,11 +53,15 @@ public abstract class Controller {
|
||||
* @return the controller of the new scene
|
||||
* @throws IOException if there is an issue with the fxmlUrl
|
||||
*/
|
||||
protected Controller loadPopupScene(String fxmlUrl, String title, Modality
|
||||
protected Controller2 loadPopupScene(String fxmlUrl, String title, Modality
|
||||
modality) throws IOException {
|
||||
// load the correct fxml scene
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(getClass().getResource(fxmlUrl));
|
||||
loader.setLocation(getClass().getResource(
|
||||
"/visualiser/scenes/" + fxmlUrl));
|
||||
Parent root = loader.load();
|
||||
|
||||
// create a new 'pop-up' window
|
||||
Stage stage = new Stage();
|
||||
stage.initModality(modality);
|
||||
stage.setTitle(title);
|
||||
@@ -56,6 +71,7 @@ public abstract class Controller {
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
// return controller for the loaded fxml scene
|
||||
return loader.getController();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package visualiser.Controllers2;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RequestToJoinEnum;
|
||||
import visualiser.Controllers.RaceController;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
import visualiser.model.VisualiserRaceState;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Controller to for waiting for the race to start.
|
||||
*/
|
||||
public class StartController extends Controller2 {
|
||||
private @FXML Label raceTitleLabel;
|
||||
private @FXML Label raceStartLabel;
|
||||
private @FXML Label timeZoneTime;
|
||||
private @FXML Label timer;
|
||||
private @FXML TableView<VisualiserBoat> boatNameTable;
|
||||
private @FXML TableColumn<VisualiserBoat, String> boatNameColumn;
|
||||
private @FXML TableColumn<VisualiserBoat, String> boatCodeColumn;
|
||||
private @FXML Label raceStatusLabel;
|
||||
|
||||
private VisualiserRaceEvent visualiserRaceEvent;
|
||||
private VisualiserRaceState raceState;
|
||||
private ControllerClient controllerClient;
|
||||
private boolean isHost;
|
||||
|
||||
/**
|
||||
* Show starting information for a race given a socket.
|
||||
* Intended to be called on loading the scene.
|
||||
* @param socket network source of information
|
||||
* @param isHost is user a host
|
||||
*/
|
||||
public void enterLobby(Socket socket, Boolean isHost) {
|
||||
try {
|
||||
this.isHost = isHost;
|
||||
this.visualiserRaceEvent = new VisualiserRaceEvent(socket, RequestToJoinEnum.PARTICIPANT);
|
||||
this.controllerClient = visualiserRaceEvent.getControllerClient();
|
||||
this.raceState = visualiserRaceEvent.getVisualiserRaceState();
|
||||
showRaceDetails();
|
||||
} catch (IOException e) {
|
||||
//TODO should probably let this propagate, so that we only enter this scene if everything works
|
||||
Logger.getGlobal()
|
||||
.log(Level.WARNING, "Could not connect to server.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays details and starts the timer for the race being started
|
||||
*/
|
||||
private void showRaceDetails() {
|
||||
raceTitleLabel.setText(this.raceState.getRegattaName());
|
||||
initialiseBoatTable();
|
||||
initialiseRaceClock();
|
||||
countdownTimer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the boat table that is to be shown on the pane.
|
||||
*/
|
||||
private void initialiseBoatTable() {
|
||||
//Get the boats.
|
||||
ObservableList<VisualiserBoat> boats =
|
||||
this.raceState.getBoats();
|
||||
|
||||
//Populate table.
|
||||
boatNameTable.setItems(boats);
|
||||
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
|
||||
boatCodeColumn.setCellValueFactory(cellData -> cellData.getValue().countryProperty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the race clock/timer labels for the start time, current time, and remaining time.
|
||||
*/
|
||||
private void initialiseRaceClock() {
|
||||
raceStartLabel.setText(
|
||||
this.raceState.getRaceClock().getStartingTimeString());
|
||||
|
||||
// init clock start time
|
||||
this.raceState.getRaceClock().startingTimeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
raceStartLabel.setText(newValue);
|
||||
});
|
||||
});
|
||||
|
||||
// init clock current time
|
||||
this.raceState.getRaceClock().currentTimeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timeZoneTime.setText(newValue);
|
||||
});
|
||||
});
|
||||
|
||||
// init clock remaining time
|
||||
this.raceState.getRaceClock().durationProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timer.setText(newValue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Countdown timer until race starts.
|
||||
*/
|
||||
private void countdownTimer() {
|
||||
new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long arg0) {
|
||||
// display current race status
|
||||
RaceStatusEnum raceStatus = raceState.getRaceStatusEnum();
|
||||
raceStatusLabel.setText("Race Status: " + raceStatus.name());
|
||||
|
||||
// if race is in PREPARATORY or STARTED status
|
||||
if (raceStatus == RaceStatusEnum.PREPARATORY || raceStatus == RaceStatusEnum.STARTED) {
|
||||
stop(); // stop this timer
|
||||
// load up the race scene
|
||||
try {
|
||||
RaceController rc = (RaceController)loadScene("race.fxml");
|
||||
rc.startRace(visualiserRaceEvent, controllerClient, isHost);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
}
|
||||
+9
-37
@@ -1,16 +1,10 @@
|
||||
package visualiser.Controllers;
|
||||
package visualiser.Controllers2;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Modality;
|
||||
import visualiser.Controllers2.Controller;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Controller for the opening title window.
|
||||
@@ -18,16 +12,9 @@ import java.util.ResourceBundle;
|
||||
* burger-boat and comic sans styling to allure and entice users into playing
|
||||
* the game.
|
||||
*/
|
||||
public class TitleController extends Controller {
|
||||
//FXML stuff
|
||||
@FXML
|
||||
Button btnJoin;
|
||||
@FXML
|
||||
AnchorPane titleWrapper;
|
||||
@FXML
|
||||
RadioButton dayModeRD;
|
||||
@FXML
|
||||
RadioButton nightModeRD;
|
||||
public class TitleController extends Controller2 {
|
||||
private @FXML RadioButton dayModeRD;
|
||||
private @FXML RadioButton nightModeRD;
|
||||
|
||||
/**
|
||||
* Method called when the 'host a game' button is pressed.
|
||||
@@ -36,26 +23,15 @@ public class TitleController extends Controller {
|
||||
* @throws IOException if main has problems
|
||||
*/
|
||||
public void hostAGame() throws IOException {
|
||||
titleWrapper.setVisible(false);
|
||||
// parent.hostGame();
|
||||
App.getStage().setResizable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the scene to the title page.
|
||||
*/
|
||||
public void enterTitle(){
|
||||
titleWrapper.setVisible(true);
|
||||
loadScene("hostLobby.fxml");
|
||||
}
|
||||
|
||||
/**
|
||||
* To be implemented at a later date- will open the next scene displaying
|
||||
* games a player can join. Place holder method for now!
|
||||
*/
|
||||
public void joinAGame() {
|
||||
titleWrapper.setVisible(false);
|
||||
// parent.enterLobby();
|
||||
App.getStage().setResizable(true);
|
||||
public void joinAGame() throws IOException {
|
||||
loadScene("lobby.fxml");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,16 +52,12 @@ public class TitleController extends Controller {
|
||||
dayModeRD.setSelected(false);
|
||||
}
|
||||
|
||||
// @Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when control button is pressed. New pop up window displaying controls
|
||||
*/
|
||||
public void controlBtnPressed(){
|
||||
public void showControls(){
|
||||
try {
|
||||
loadPopupScene("/visualiser/scenes/keyBindings.fxml",
|
||||
loadPopupScene("keyBindings.fxml",
|
||||
"Game Controls", Modality.WINDOW_MODAL);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -26,7 +26,6 @@ import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.WindowEvent;
|
||||
import javafx.util.Duration;
|
||||
import visualiser.Controllers.MainController;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
|
||||
public class App extends Application {
|
||||
@@ -42,7 +41,6 @@ public class App extends Application {
|
||||
|
||||
/**
|
||||
* Entry point for running the programme
|
||||
*
|
||||
* @param args for starting the programme
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -79,10 +77,10 @@ public class App extends Application {
|
||||
|
||||
/**
|
||||
* Method that sets up and displays the splash screen
|
||||
* @param initStage the inital stage
|
||||
* @param stage the inital stage
|
||||
* @throws Exception if something wrong with title screen.
|
||||
*/
|
||||
public void start(Stage initStage) throws Exception {
|
||||
public void start(Stage stage) throws Exception {
|
||||
final Task<ObservableList<String>> boatTask = new Task<ObservableList<String>>() {
|
||||
@Override
|
||||
protected ObservableList<String> call() throws InterruptedException {
|
||||
@@ -111,11 +109,11 @@ public class App extends Application {
|
||||
};
|
||||
|
||||
showSplash(
|
||||
initStage,
|
||||
stage,
|
||||
boatTask,
|
||||
() -> {
|
||||
try {
|
||||
showMainStage(new Stage());
|
||||
loadTitleScreen();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -126,45 +124,26 @@ public class App extends Application {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get main stage
|
||||
* @return main stage
|
||||
* Get the main stage to be shared for all regular game play scenes.
|
||||
* @return shared stage
|
||||
*/
|
||||
public static Stage getStage() {
|
||||
return App.stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set main stage
|
||||
* @param stage stage to set main stage
|
||||
*/
|
||||
public static void setStage(Stage stage) {
|
||||
App.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the main stage after the splash screen
|
||||
* @param stage main stage for application
|
||||
* @throws Exception Throws an exception on error
|
||||
*/
|
||||
public void showMainStage(Stage stage) throws Exception {
|
||||
App.stage = stage;
|
||||
App.app = this;
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||
public void loadTitleScreen() throws Exception {
|
||||
stage = new Stage();
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource
|
||||
("/visualiser/scenes/titleScreen.fxml"));
|
||||
Parent root = loader.load();
|
||||
stage.setResizable(false);
|
||||
MainController mc = (MainController) loader.getController();
|
||||
mc.enterTitle();
|
||||
Scene scene = new Scene(root);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("RaceVision - Team 7");
|
||||
stage.setTitle("The Boat Game - Burgers & Boats");
|
||||
stage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/SailIcon.png")));
|
||||
mc.startCss();
|
||||
setStage(stage);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(WindowEvent event) {
|
||||
@Override public void handle(WindowEvent event) {
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<GridPane fx:id="arrowGridPane" maxHeight="-Infinity" maxWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ArrowController">
|
||||
<GridPane fx:id="arrowGridPane" maxHeight="-Infinity" maxWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers2.ArrowController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||
</columnConstraints>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<fx:include fx:id="start" source="start.fxml" />
|
||||
<fx:include fx:id="connection" source="connect.fxml" />
|
||||
<fx:include fx:id="finish" source="finish.fxml" />
|
||||
<fx:include fx:id="host" source="hostlobby.fxml" />
|
||||
<fx:include fx:id="host" source="hostLobby.fxml" />
|
||||
<fx:include fx:id="title" source="titleScreen.fxml" />
|
||||
<fx:include fx:id="lobby" source="lobby.fxml" />
|
||||
</children>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.StartController">
|
||||
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers2.StartController">
|
||||
<children>
|
||||
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<AnchorPane fx:id="titleWrapper" maxHeight="600.0" maxWidth="800.0" minHeight="600.0" minWidth="800.0" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.TitleController">
|
||||
<AnchorPane fx:id="titleWrapper" maxHeight="600.0" maxWidth="800.0" minHeight="600.0" minWidth="800.0" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers2.TitleController">
|
||||
<children>
|
||||
<GridPane layoutY="39.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
@@ -37,7 +37,7 @@
|
||||
</Text>
|
||||
<RadioButton fx:id="nightModeRD" layoutX="681.0" layoutY="168.0" mnemonicParsing="false" onAction="#setNightMode" text="Night Mode" />
|
||||
<RadioButton fx:id="dayModeRD" layoutX="574.0" layoutY="168.0" mnemonicParsing="false" onAction="#setDayMode" selected="true" text="Day Mode" />
|
||||
<Button layoutX="28.0" layoutY="152.0" mnemonicParsing="false" onAction="#controlBtnPressed" text="Controls" />
|
||||
<Button layoutX="28.0" layoutY="152.0" mnemonicParsing="false" onAction="#showControls" text="Controls" />
|
||||
</children>
|
||||
</Pane>
|
||||
<Pane prefHeight="20.0" prefWidth="20.0" style="-fx-background-color: #6be6ff;" GridPane.columnSpan="4" GridPane.rowSpan="4">
|
||||
|
||||
Reference in New Issue
Block a user