@ -38,10 +38,7 @@ import visualiser.gameController.ControllerClient;
import visualiser.gameController.Keys.ControlKey ;
import visualiser.gameController.Keys.ControlKey ;
import visualiser.gameController.Keys.KeyFactory ;
import visualiser.gameController.Keys.KeyFactory ;
import visualiser.layout.* ;
import visualiser.layout.* ;
import visualiser.model.Sparkline ;
import visualiser.model.* ;
import visualiser.model.VisualiserBoat ;
import visualiser.model.VisualiserRaceEvent ;
import visualiser.model.VisualiserRaceState ;
import visualiser.utils.GPSConverter ;
import visualiser.utils.GPSConverter ;
import java.io.IOException ;
import java.io.IOException ;
@ -70,6 +67,8 @@ public class RaceViewController extends Controller {
private FGauge fGauge ;
private FGauge fGauge ;
private long positionDelay = 1000 ;
private long positionDelay = 1000 ;
private long positionTime = 0 ;
private long positionTime = 0 ;
private ResizableRaceCanvas raceCanvas ;
private boolean mapToggle = true ;
/ * *
/ * *
* Arrow pointing to next mark in third person
* Arrow pointing to next mark in third person
@ -83,6 +82,7 @@ public class RaceViewController extends Controller {
// note: it says it's not used but it is! do not remove :)
// note: it says it's not used but it is! do not remove :)
private @FXML ArrowController arrowController ;
private @FXML ArrowController arrowController ;
private @FXML GridPane canvasBase ;
private @FXML GridPane canvasBase ;
private @FXML GridPane canvasBase1 ;
private @FXML SplitPane racePane ;
private @FXML SplitPane racePane ;
private @FXML StackPane arrowPane ;
private @FXML StackPane arrowPane ;
private @FXML Label timer ;
private @FXML Label timer ;
@ -119,6 +119,7 @@ public class RaceViewController extends Controller {
tutorialCheck ( ) ;
tutorialCheck ( ) ;
initKeypressHandler ( ) ;
initKeypressHandler ( ) ;
initialiseRaceVisuals ( ) ;
initialiseRaceVisuals ( ) ;
initialiseRaceCanvas ( ) ;
}
}
/ * *
/ * *
@ -154,6 +155,9 @@ public class RaceViewController extends Controller {
// tab key
// tab key
if ( codeString . equals ( "TAB" ) ) { toggleTable ( ) ; }
if ( codeString . equals ( "TAB" ) ) { toggleTable ( ) ; }
//map key
if ( codeString . equals ( "M" ) ) { bigMap ( ) ; }
// any key pressed
// any key pressed
ControlKey controlKey = keyFactory . getKey ( codeString ) ;
ControlKey controlKey = keyFactory . getKey ( codeString ) ;
if ( controlKey ! = null ) {
if ( controlKey ! = null ) {
@ -411,8 +415,25 @@ public class RaceViewController extends Controller {
viewSubjects . add ( markModel ) ;
viewSubjects . add ( markModel ) ;
}
}
for ( VisualiserBoat boat : race . getVisualiserRaceState ( ) . getBoats ( ) ) {
if ( boat . isClientBoat ( ) ) {
Shockwave boatHighlight = new Shockwave ( 10 ) ;
boatHighlight . getMesh ( ) . setMaterial ( new PhongMaterial ( new Color ( 1 , 1 , 0 , 0.1 ) ) ) ;
viewSubjects . add ( boatHighlight ) ;
AnimationTimer highlightTrack = new AnimationTimer ( ) {
@Override
public void handle ( long now ) {
boatHighlight . setX ( gpsConverter . convertGPS ( boat . getPosition ( ) ) . getX ( ) ) ;
boatHighlight . setZ ( gpsConverter . convertGPS ( boat . getPosition ( ) ) . getY ( ) ) ;
}
} ;
highlightTrack . start ( ) ;
}
}
// Position and add each boat to view
// Position and add each boat to view
for ( VisualiserBoat boat : race . getVisualiserRaceState ( ) . getBoats ( ) ) {
for ( VisualiserBoat boat : race . getVisualiserRaceState ( ) . getBoats ( ) ) {
MeshView mesh ;
MeshView mesh ;
if ( boat . getSourceID ( ) = = race . getVisualiserRaceState ( ) . getPlayerBoatID ( ) ) {
if ( boat . getSourceID ( ) = = race . getVisualiserRaceState ( ) . getPlayerBoatID ( ) ) {
mesh = new MeshView ( importer . getImport ( ) ) ;
mesh = new MeshView ( importer . getImport ( ) ) ;
@ -724,18 +745,9 @@ public class RaceViewController extends Controller {
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
}
}
} else {
} else {
raceCanvas . drawRace ( ) ;
boatInfoTable . sort ( ) ;
boatInfoTable . sort ( ) ;
// try {
// System.out.println(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
// gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
// for (VisualiserBoat boat : boatInfoTable.getItems()){
// if(raceState.getPlayerBoatID()==boat.getSourceID()){
// gauge.setTitle("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
// }
// }
// } catch (BoatNotFoundException e) {
// e.printStackTrace();
// }
}
}
//Return to main screen if we lose connection.
//Return to main screen if we lose connection.
@ -890,4 +902,48 @@ public class RaceViewController extends Controller {
}
}
}
}
/ * *
* Initialises the map
* /
private void initialiseRaceCanvas ( ) {
//Create canvas.
raceCanvas = new ResizableRaceCanvas ( raceState ) ;
//Set properties.
raceCanvas . setMouseTransparent ( true ) ;
raceCanvas . widthProperty ( ) . bind ( canvasBase1 . widthProperty ( ) ) ;
raceCanvas . heightProperty ( ) . bind ( canvasBase1 . heightProperty ( ) ) ;
//Draw it and show it.
raceCanvas . draw ( ) ;
raceCanvas . setVisible ( true ) ;
//Add to scene.
canvasBase1 . getChildren ( ) . add ( 0 , raceCanvas ) ;
}
private void bigMap ( ) {
if ( mapToggle ) {
raceCanvas . widthProperty ( ) . bind ( canvasBase . widthProperty ( ) ) ;
raceCanvas . heightProperty ( ) . bind ( canvasBase . heightProperty ( ) ) ;
raceCanvas . setFullScreen ( true ) ;
raceCanvas . setOpacity ( 0.6 ) ;
canvasBase1 . getChildren ( ) . remove ( raceCanvas ) ;
canvasBase . getChildren ( ) . add ( 1 , raceCanvas ) ;
} else {
raceCanvas . widthProperty ( ) . bind ( canvasBase1 . widthProperty ( ) ) ;
raceCanvas . heightProperty ( ) . bind ( canvasBase1 . heightProperty ( ) ) ;
raceCanvas . setFullScreen ( false ) ;
canvasBase . getChildren ( ) . remove ( raceCanvas ) ;
canvasBase1 . getChildren ( ) . add ( 0 , raceCanvas ) ;
}
mapToggle = ! mapToggle ;
}
}
}