Tutorial text now displays on screen when in tutorial. #story[1189]
This commit is contained in:
@@ -34,10 +34,7 @@ import visualiser.utils.GPSConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -66,6 +63,8 @@ public class RaceController extends Controller {
|
||||
|
||||
private boolean isTutorial = false;
|
||||
|
||||
private String keyToPress;
|
||||
|
||||
|
||||
/**
|
||||
* state of the info table
|
||||
@@ -84,6 +83,8 @@ public class RaceController extends Controller {
|
||||
|
||||
@FXML private SplitPane racePane;
|
||||
|
||||
@FXML private Label tutorialText;
|
||||
|
||||
|
||||
/**
|
||||
* This is the pane we place the actual arrow control inside of.
|
||||
@@ -469,12 +470,19 @@ public class RaceController extends Controller {
|
||||
//Check if the game is a tutorial
|
||||
if (parent.getGameType()==2){
|
||||
isTutorial = true;
|
||||
tutorialText.setVisible(true);
|
||||
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
||||
System.out.println(tutorialStates);
|
||||
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
System.out.println("Welcome to tutorial. Exit at anytime with ESC. Turn upwind.");
|
||||
|
||||
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();
|
||||
@@ -574,43 +582,69 @@ public class RaceController extends Controller {
|
||||
infoTableShow = !infoTableShow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next tutorial state
|
||||
*/
|
||||
private void updateTutorialState(){
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search key map for key given string of command
|
||||
* @param command the command of the key
|
||||
*/
|
||||
private void searchMapForKey(String command){
|
||||
for (Map.Entry<String, ControlKey> entry: keyFactory.getKeyState().entrySet()){
|
||||
if(entry.getValue().toString().equals(command)){
|
||||
keyToPress = entry.getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates tutorial state and gui display for tutorial text
|
||||
* @throws Exception Exception thrown
|
||||
*/
|
||||
private void checkTutorialState() throws Exception {
|
||||
switch (currentState){
|
||||
case UPWIND:
|
||||
System.out.println("You turned upwind. Now go downwind.");
|
||||
searchMapForKey("Downwind");
|
||||
tutorialText.setText("Nice! To turn downwind press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case DOWNWIND:
|
||||
System.out.println("You turned downwind. Now go tack/gybe.");
|
||||
searchMapForKey("Tack/Gybe");
|
||||
tutorialText.setText("Nice! To tack or gybe press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case TACKGYBE:
|
||||
System.out.println("You tack/gybe. Now go VMG.");
|
||||
searchMapForKey("VMG");
|
||||
tutorialText.setText("Nice! To use VMG press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case VMG:
|
||||
System.out.println("You VMG. Now sails-in.");
|
||||
searchMapForKey("Toggle Sails");
|
||||
tutorialText.setText("Nice! To sails in press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case SAILSIN:
|
||||
System.out.println("You sails-in. Now sails-out.");
|
||||
searchMapForKey("Toggle Sails");
|
||||
tutorialText.setText("Nice! To sails out press " + keyToPress + " again.");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case SAILSOUT:
|
||||
System.out.println("You sails-out. Now zoom in.");
|
||||
searchMapForKey("Zoom In");
|
||||
tutorialText.setText("Nice! To zoom in press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case ZOOMIN:
|
||||
System.out.println("You zoomed in. Now zoom out.");
|
||||
searchMapForKey("Zoom Out");
|
||||
tutorialText.setText("Nice! To zoom out press " + keyToPress + ".");
|
||||
updateTutorialState();
|
||||
break;
|
||||
case ZOOMOUT:
|
||||
System.out.println("You zoomed out. Tutorial finished. Well done!");
|
||||
tutorialText.setText("Congratulations! You're done!");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Finished Tutorial");
|
||||
alert.setHeaderText("You have finished the tutorial.");
|
||||
@@ -624,8 +658,6 @@ public class RaceController extends Controller {
|
||||
break;
|
||||
default:
|
||||
System.out.println("Something went wrong.");
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
<fx:include fx:id="arrow" source="arrow.fxml" />
|
||||
</children>
|
||||
</StackPane>
|
||||
<Label fx:id="tutorialText" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" style="-fx-border-color: orange; -fx-border-radius: 5px; -fx-background-color: #ffffcc; -fx-text-fill: #3399ff; -fx-border-width: 3; -fx-border-insets: -3;" text="This is the tutorial text" visible="false" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="100.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<Font name="Comic Sans MS Bold" size="16.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Label fx:id="tutorialLabel" layoutX="94.0" layoutY="223.0" onMouseClicked="#tutorialStartPressed" prefHeight="167.0" prefWidth="206.0" style="-fx-shape: "M 45.673,0 C 67.781,0 85.703,12.475 85.703,27.862 C 85.703,43.249 67.781,55.724 45.673,55.724 C 38.742,55.724 32.224,54.497 26.539,52.34 C 15.319,56.564 0,64.542 0,64.542 C 0,64.542 9.989,58.887 14.107,52.021 C 15.159,50.266 15.775,48.426 16.128,46.659 C 9.618,41.704 5.643,35.106 5.643,27.862 C 5.643,12.475 23.565,0 45.673,0 M 45.673,2.22 C 24.824,2.22 7.862,13.723 7.862,27.863 C 7.862,34.129 11.275,40.177 17.472,44.893 L 18.576,45.734 L 18.305,47.094 C 17.86,49.324 17.088,51.366 16.011,53.163 C 15.67,53.73 15.294,54.29 14.891,54.837 C 18.516,53.191 22.312,51.561 25.757,50.264 L 26.542,49.968 L 27.327,50.266 C 32.911,52.385 39.255,53.505 45.673,53.505 C 66.522,53.505 83.484,42.002 83.484,27.862 C 83.484,13.722 66.522,2.22 45.673,2.22 L 45.673,2.22 z "; -fx-background-color: black, white; -fx-background-insets: 0,1; -fx-padding: 50;" text="How do I play this game?" />
|
||||
<Label fx:id="tutorialLabel" alignment="CENTER" layoutX="94.0" layoutY="223.0" onMouseClicked="#tutorialStartPressed" prefHeight="167.0" prefWidth="206.0" style="-fx-shape: "M 45.673,0 C 67.781,0 85.703,12.475 85.703,27.862 C 85.703,43.249 67.781,55.724 45.673,55.724 C 38.742,55.724 32.224,54.497 26.539,52.34 C 15.319,56.564 0,64.542 0,64.542 C 0,64.542 9.989,58.887 14.107,52.021 C 15.159,50.266 15.775,48.426 16.128,46.659 C 9.618,41.704 5.643,35.106 5.643,27.862 C 5.643,12.475 23.565,0 45.673,0 M 45.673,2.22 C 24.824,2.22 7.862,13.723 7.862,27.863 C 7.862,34.129 11.275,40.177 17.472,44.893 L 18.576,45.734 L 18.305,47.094 C 17.86,49.324 17.088,51.366 16.011,53.163 C 15.67,53.73 15.294,54.29 14.891,54.837 C 18.516,53.191 22.312,51.561 25.757,50.264 L 26.542,49.968 L 27.327,50.266 C 32.911,52.385 39.255,53.505 45.673,53.505 C 66.522,53.505 83.484,42.002 83.484,27.862 C 83.484,13.722 66.522,2.22 45.673,2.22 L 45.673,2.22 z "; -fx-background-color: black, white; -fx-background-insets: 0,1; -fx-padding: 50;" text="How do you play this game? Click here!" textAlignment="CENTER" />
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user