package seng302.Controllers;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
import seng302.Model.Boat;
import seng302.Model.RaceClock;
import seng302.VisualiserInput;

import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * Created by fwy13 on 15/03/2017.
 */
public class MainController extends Controller {
    @FXML private StartController startController;
    @FXML private RaceController raceController;
    @FXML private ConnectionController connectionController;
    @FXML private FinishController finishController;

    public void beginRace(VisualiserInput visualiserInput, RaceClock raceClock) {
        raceController.startRace(visualiserInput, raceClock);
    }

    public void enterLobby(Socket socket) {
        startController.enterLobby(socket);
    }

    public void enterFinish(ObservableList<Boat> 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);
    }
}
