You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.7 KiB
134 lines
4.7 KiB
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;
|
|
|
|
import java.io.IOException;
|
|
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;
|
|
@FXML private TitleController titleController;
|
|
@FXML private HostController hostController;
|
|
@FXML private LobbyController lobbyController;
|
|
|
|
|
|
/**
|
|
* Ctor.
|
|
*/
|
|
public MainController() {
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Transitions from the StartController screen (displays pre-race information) to the RaceController (displays the actual race).
|
|
* @param visualiserRace The object modelling the race.
|
|
* @param controllerClient Socket Client that manipulates the controller.
|
|
*/
|
|
public void beginRace(VisualiserRaceEvent visualiserRace, ControllerClient controllerClient, Boolean isHost) {
|
|
raceController.startRace(visualiserRace, controllerClient, isHost);
|
|
}
|
|
|
|
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.
|
|
* @param isHost is connection a host
|
|
*/
|
|
public void enterLobby(Socket socket, Boolean isHost) {
|
|
startController.enterLobby(socket, isHost);
|
|
}
|
|
|
|
/**
|
|
* 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<VisualiserBoat> boats) {
|
|
finishController.enterFinish(boats);
|
|
}
|
|
|
|
// /**
|
|
// * Transitions into the title screen
|
|
// */
|
|
// public void enterTitle() {
|
|
// titleController.enterTitle();
|
|
// }
|
|
|
|
/**
|
|
* Transitions into lobby screen
|
|
*/
|
|
public void enterLobby(){ lobbyController.enterLobby(); }
|
|
|
|
/**
|
|
* Transitions into host game screen
|
|
*/
|
|
public void hostGame(){ hostController.hostGame(); }
|
|
|
|
/**
|
|
* Sets up the css for the start of the program
|
|
*/
|
|
public void startCss(){titleController.setDayMode();}
|
|
|
|
/**
|
|
* 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);
|
|
// titleController.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(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(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);
|
|
}
|
|
}
|