Merge branch 'master' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into controllerSplit
# Conflicts: # racevisionGame/src/main/java/visualiser/Controllers/HostController.java # racevisionGame/src/main/java/visualiser/Controllers/MainController.java # racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java # racevisionGame/src/main/java/visualiser/Controllers/StartController.java # racevisionGame/src/main/java/visualiser/Controllers/TitleController.java # racevisionGame/src/main/resources/visualiser/scenes/raceView.fxml # racevisionGame/src/main/resources/visualiser/scenes/titleScreen.fxml
This commit is contained in:
@@ -57,7 +57,7 @@ public class LobbyController extends Controller {
|
||||
} else {
|
||||
joinGameBtn.setDisable(true);
|
||||
}
|
||||
} catch (Exception e){}
|
||||
} catch (Exception ignored){}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@ import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.shape.MeshView;
|
||||
@@ -27,6 +26,7 @@ import visualiser.app.App;
|
||||
import visualiser.enums.TutorialState;
|
||||
import visualiser.gameController.ControllerClient;
|
||||
import visualiser.gameController.Keys.ControlKey;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
import visualiser.layout.Subject3D;
|
||||
import visualiser.layout.View3D;
|
||||
import visualiser.model.Sparkline;
|
||||
@@ -34,9 +34,12 @@ import visualiser.model.VisualiserBoat;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
import visualiser.model.VisualiserRaceState;
|
||||
import visualiser.utils.GPSConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -73,7 +76,6 @@ public class RaceViewController extends Controller {
|
||||
private @FXML TableColumn<VisualiserBoat, Leg> boatMarkColumn;
|
||||
private @FXML TableColumn<VisualiserBoat, Number> boatSpeedColumn;
|
||||
private @FXML LineChart<Number, Number> sparklineChart;
|
||||
|
||||
private @FXML Label tutorialText;
|
||||
|
||||
|
||||
@@ -91,10 +93,35 @@ public class RaceViewController extends Controller {
|
||||
this.isHost = isHost;
|
||||
keyFactory.load();
|
||||
|
||||
tutorialCheck();
|
||||
initKeypressHandler();
|
||||
initialiseRaceVisuals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current game is a tutorial race and sets up initial
|
||||
* tutorial displays if it is.
|
||||
*/
|
||||
private void tutorialCheck(){
|
||||
if (App.gameType == 4) {
|
||||
isTutorial = true;
|
||||
tutorialText.setVisible(true);
|
||||
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
||||
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
searchMapForKey("Upwind");
|
||||
|
||||
tutorialText.setText(
|
||||
"Welcome to the tutorial! Exit at anytime with ESC. \nWe will first learn how to turn upwind. Press " +
|
||||
keyToPress + " to turn upwind.");
|
||||
|
||||
} else {
|
||||
isTutorial = false;
|
||||
tutorialText.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the listener and actions that occur when a key is pressed.
|
||||
*/
|
||||
@@ -167,7 +194,6 @@ public class RaceViewController extends Controller {
|
||||
initialiseFps();
|
||||
initialiseInfoTable();
|
||||
initialiseView3D();
|
||||
initialiseArrow();
|
||||
initialiseRaceClock();
|
||||
raceTimer(); // start the timer
|
||||
new Sparkline(this.raceState, this.sparklineChart);
|
||||
@@ -374,45 +400,6 @@ public class RaceViewController extends Controller {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Displays a specified race.
|
||||
* @param visualiserRace Object modelling the race.
|
||||
* @param controllerClient Socket Client that manipulates the controller.
|
||||
* @param isHost is user a host
|
||||
*/
|
||||
public void startRace(VisualiserRaceEvent visualiserRace, ControllerClient controllerClient, Boolean isHost) {
|
||||
|
||||
this.visualiserRace = visualiserRace;
|
||||
this.controllerClient = controllerClient;
|
||||
this.isHost = isHost;
|
||||
|
||||
|
||||
//Check if the game is a tutorial
|
||||
if (parent.getGameType()==4){
|
||||
isTutorial = true;
|
||||
tutorialText.setVisible(true);
|
||||
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
||||
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
|
||||
searchMapForKey("Upwind");
|
||||
|
||||
tutorialText.setText("Welcome to the tutorial! Exit at anytime with ESC. \nWe will first learn how to turn upwind. Press " + keyToPress + " to turn upwind.");
|
||||
|
||||
} else {
|
||||
isTutorial = false;
|
||||
tutorialText.setVisible(false);
|
||||
}
|
||||
|
||||
initialiseRace();
|
||||
|
||||
//Display this controller.
|
||||
racePane.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transition from the race view to the finish view.
|
||||
*/
|
||||
@@ -422,16 +409,6 @@ public class RaceViewController extends Controller {
|
||||
fc.loadFinish(raceState.getBoats());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the arrow controller with data from the race to observe.
|
||||
* @param race The race to observe.
|
||||
*/
|
||||
private void initialiseArrow(VisualiserRaceEvent race) {
|
||||
arrowController.setWindProperty(race.getVisualiserRaceState().windProperty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Timer which monitors the race.
|
||||
*/
|
||||
@@ -581,19 +558,16 @@ public class RaceViewController extends Controller {
|
||||
alert.setContentText("Now you know the controls you are ready to race!");
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if (result.get() == ButtonType.OK) {
|
||||
parent.endEvent();
|
||||
racePane.setVisible(false);
|
||||
App.app.showMainStage(App.getStage());
|
||||
App.game.endEvent();
|
||||
loadTitleScreen();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//State not found. Exit tutorial to title menu
|
||||
parent.endEvent();
|
||||
racePane.setVisible(false);
|
||||
App.app.showMainStage(App.getStage());
|
||||
App.game.endEvent();
|
||||
loadTitleScreen();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,15 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import mock.app.Event;
|
||||
import mock.exceptions.EventConstructionException;
|
||||
import javafx.stage.WindowEvent;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Controller for the opening title window.
|
||||
@@ -93,12 +80,10 @@ public class TitleController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void tutorialStartPressed() throws IOException {
|
||||
titleWrapper.setVisible(false);
|
||||
parent.setGameType(4);
|
||||
parent.beginGame();
|
||||
|
||||
public void tutorialStartPressed() {
|
||||
App.gameType = 4;
|
||||
HostGameController hgc = new HostGameController();
|
||||
hgc.hostGamePressed();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user