package visualiser.Controllers; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; import visualiser.app.VisualiserInput; import visualiser.model.VisualiserBoat; import visualiser.model.VisualiserRace; import java.net.Socket; import java.net.URL; import java.util.ResourceBundle; /** * Controller that everything is overlayed onto. This makes it so that changing scenes does not resize your stage. */ public class MainController extends Controller { @FXML private StartController startController; @FXML private RaceController raceController; @FXML private ConnectionController connectionController; @FXML private FinishController finishController; /** * Ctor. */ public MainController() { } /** * Transitions from the StartController screen (displays pre-race information) to the RaceController (displays the actual race). * @param visualiserInput The object used to read packets from the race server. * @param visualiserRace The object modelling the race. */ public void beginRace(VisualiserInput visualiserInput, VisualiserRace visualiserRace) { raceController.startRace(visualiserInput, visualiserRace); } /** * Transitions from the server selection screen to the pre-race lobby for a given server. * @param socket The server to read data from. */ public void enterLobby(Socket socket) { startController.enterLobby(socket); } /** * Transitions from the {@link RaceController} screen to the {@link FinishController} screen. * @param boats The boats to display on the finish screen. */ public void enterFinish(ObservableList boats) { finishController.enterFinish(boats); } /** * Main Controller for the applications will house the menu and the displayed pane. * * @param location of resources * @param resources bundle */ @Override public void initialize(URL location, ResourceBundle resources) { startController.setParent(this); raceController.setParent(this); connectionController.setParent(this); finishController.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(connectionController.startWrapper(), 0.0); AnchorPane.setBottomAnchor(connectionController.startWrapper(), 0.0); AnchorPane.setLeftAnchor(connectionController.startWrapper(), 0.0); AnchorPane.setRightAnchor(connectionController.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); } }