diff --git a/src/main/java/seng302/App.java b/src/main/java/seng302/App.java index f97a3ef8..0ccc18e7 100644 --- a/src/main/java/seng302/App.java +++ b/src/main/java/seng302/App.java @@ -77,7 +77,7 @@ public class App extends Application { @Override public void start(Stage primaryStage) throws Exception { - ViewManager.getInstance().initialStartView(primaryStage); + ViewManager.getInstance().initialiseSplashScreen(primaryStage); } private static void runDiscoveryServer(){ diff --git a/src/main/java/seng302/utilities/Sounds.java b/src/main/java/seng302/utilities/Sounds.java index f8257b1f..b7db0439 100644 --- a/src/main/java/seng302/utilities/Sounds.java +++ b/src/main/java/seng302/utilities/Sounds.java @@ -101,6 +101,10 @@ public class Sounds { musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); musicPlayer.setVolume(0.3); musicPlayer.play(); + musicPlayer.setMute(musicMuted); + if (soundEffect != null) { + soundEffect.stop(); + } } diff --git a/src/main/java/seng302/visualiser/GameClient.java b/src/main/java/seng302/visualiser/GameClient.java index d9763a9f..bfcb599f 100644 --- a/src/main/java/seng302/visualiser/GameClient.java +++ b/src/main/java/seng302/visualiser/GameClient.java @@ -284,12 +284,13 @@ public class GameClient { ClientYacht player = allBoatsMap.get(socketThread.getClientId()); raceView.loadRace(allBoatsMap, courseData, raceState, player); - + raceView.showView(); raceView.getSendPressedProperty().addListener((obs, old, isPressed) -> { if (isPressed) { formatAndSendChatMessage(raceView.readChatInput()); } }); + } } diff --git a/src/main/java/seng302/visualiser/controllers/RaceViewController.java b/src/main/java/seng302/visualiser/controllers/RaceViewController.java index 2eb44101..4b683a72 100644 --- a/src/main/java/seng302/visualiser/controllers/RaceViewController.java +++ b/src/main/java/seng302/visualiser/controllers/RaceViewController.java @@ -25,12 +25,8 @@ import javafx.scene.SubScene; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart.Series; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ComboBox; -import javafx.scene.control.Label; -import javafx.scene.control.Slider; -import javafx.scene.control.TextField; +import javafx.scene.control.*; +import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; @@ -74,6 +70,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel private static final Double ICON_BLINK_TIMEOUT_RATIO = 0.6; private static final Integer ICON_BLINK_PERIOD = 500; + @FXML + private AnchorPane loadingScreenPane; + @FXML + private ImageView loadingScreen; @FXML private Pane basePane; @FXML @@ -143,6 +143,24 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel private ImageView iconToDisplay; public void initialize() { + contentStackPane.setVisible(false); + Image loadingImage = new Image("PP.png"); + loadingScreen.setImage(loadingImage); + //Centers the Image within the image view + double w = 0; + double h = 0; + double ratioX = loadingScreen.getFitWidth() / loadingImage.getWidth(); + double ratioY = loadingScreen.getFitHeight() / loadingImage.getHeight(); + double reduceRatio = 0; + if(ratioX >= ratioY) { + reduceRatio = ratioY; + } else { + reduceRatio = ratioX; + } + w = loadingImage.getWidth() * reduceRatio; + h = loadingImage.getHeight() * reduceRatio; + loadingScreen.setX((loadingScreen.getFitWidth() - w) / 2); + loadingScreen.setY((loadingScreen.getFitHeight() - h) / 2); Sounds.stopMusic(); Sounds.playRaceMusic(); @@ -179,6 +197,18 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel createFinishDialog(finishedBoats); } + public void showView(){ + loadingScreenPane.setVisible(false); + contentStackPane.setVisible(true); + + Platform.runLater(new Runnable() { + @Override + public void run() { + contentStackPane.requestFocus(); + } + }); + } + /** * Create finishScreenDialog and set up finishDialogController. */ diff --git a/src/main/java/seng302/visualiser/controllers/SplashScreenController.java b/src/main/java/seng302/visualiser/controllers/SplashScreenController.java new file mode 100644 index 00000000..442d4083 --- /dev/null +++ b/src/main/java/seng302/visualiser/controllers/SplashScreenController.java @@ -0,0 +1,58 @@ +package seng302.visualiser.controllers; + +import com.jfoenix.controls.JFXDecorator; +import com.jfoenix.controls.JFXSnackbar; +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.SceneAntialiasing; +import javafx.scene.image.Image; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; +import seng302.gameServer.ServerAdvertiser; +import seng302.utilities.Sounds; +import seng302.visualiser.GameClient; + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +/** + * Created by Kusal on 26-Sep-17. + */ +public class SplashScreenController implements Initializable{ + + @FXML + private StackPane rootPane; + + @Override + public void initialize(URL location, ResourceBundle resources) { + new SplashScreen().start(); + } + + + class SplashScreen extends Thread { + public void run(){ + try { + Thread.sleep(2000); + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + Stage stage = new Stage(); + ViewManager.getInstance().initialStartView(stage); + } catch (Exception e) { + e.printStackTrace(); + } + rootPane.getScene().getWindow().hide(); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/seng302/visualiser/controllers/ViewManager.java b/src/main/java/seng302/visualiser/controllers/ViewManager.java index 38d21ae5..45dfb069 100644 --- a/src/main/java/seng302/visualiser/controllers/ViewManager.java +++ b/src/main/java/seng302/visualiser/controllers/ViewManager.java @@ -15,6 +15,7 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; +import javafx.stage.StageStyle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import seng302.gameServer.ServerAdvertiser; @@ -52,10 +53,18 @@ public class ViewManager { if (instance == null) { instance = new ViewManager(); } - return instance; } + public void initialiseSplashScreen(Stage stage) throws IOException { + this.stage = stage; + Parent root = FXMLLoader.load(getClass().getResource("/views/SplashScreen.fxml")); + Scene scene = new Scene(root); + stage.setScene(scene); + stage.initStyle(StageStyle.UNDECORATED); + stage.show(); + } + /** * Initialize the start view in the given stage. */ @@ -63,7 +72,6 @@ public class ViewManager { this.stage = stage; Parent root = FXMLLoader.load(getClass().getResource("/views/StartScreenView.fxml")); stage.setTitle("Party Parrots At Sea"); - JFXDecorator decorator = new JFXDecorator(stage, root, false, true, true); decorator.setCustomMaximize(true); decorator.applyCss(); diff --git a/src/main/resources/css/SplashScreenView.css b/src/main/resources/css/SplashScreenView.css new file mode 100644 index 00000000..a4d1d68d --- /dev/null +++ b/src/main/resources/css/SplashScreenView.css @@ -0,0 +1,10 @@ +#background { + -fx-background-color: #E7F1F8; +} + +#headText { + -fx-background-color: transparent; + -fx-font-size: 52px; + -fx-text-fill: -fx-pp-light-text-color; + -fx-effect: -fx-pp-dropshadow-headers; +} \ No newline at end of file diff --git a/src/main/resources/views/RaceView.fxml b/src/main/resources/views/RaceView.fxml index 2d0769af..56ca5ad5 100644 --- a/src/main/resources/views/RaceView.fxml +++ b/src/main/resources/views/RaceView.fxml @@ -23,275 +23,284 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/views/SplashScreen.fxml b/src/main/resources/views/SplashScreen.fxml new file mode 100644 index 00000000..31449b7e --- /dev/null +++ b/src/main/resources/views/SplashScreen.fxml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +