Added the ability to hide and show info table with a key press

-the wind arrow also scales with the new size of the screen
This commit is contained in:
hba56
2017-08-16 02:04:07 +12:00
parent 3d953362a6
commit fdd0b30a51
2 changed files with 29 additions and 7 deletions
@@ -10,7 +10,6 @@ import javafx.collections.transformation.SortedList;
import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
@@ -23,7 +22,6 @@ import visualiser.gameController.ControllerClient;
import visualiser.gameController.Keys.ControlKey;
import visualiser.gameController.Keys.KeyFactory;
import visualiser.model.*;
import visualiser.network.ServerConnection;
import java.net.URL;
import java.util.ResourceBundle;
@@ -62,6 +60,11 @@ public class RaceController extends Controller {
*/
private Sparkline sparkline;
/**
* state of the info table
*/
private boolean infoTableShow;
/**
* The arrow controller.
*/
@@ -106,10 +109,14 @@ public class RaceController extends Controller {
@Override
public void initialize(URL location, ResourceBundle resources) {
KeyFactory keyFactory = KeyFactory.getFactory();
infoTableShow = true;
// Initialise keyboard handler
race.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
String codeString = event.getCode().toString();
if (codeString.equals("TAB")){toggleTable();}
ControlKey controlKey = keyFactory.getKey(codeString);
if(controlKey != null) {
try {
@@ -437,4 +444,23 @@ public class RaceController extends Controller {
}.start();
}
private void toggleTable() {
if (infoTableShow){
race.setDividerPositions(0.4);
arrowPane.setScaleX(0.5);
arrowPane.setScaleY(0.5);
arrowPane.setTranslateX(0 + (arrowPane.getScene().getWidth()/4)*0.4);
arrowPane.setTranslateY(0 - arrowPane.getScene().getHeight()/4);
}else{
race.setDividerPositions(1);
arrowPane.setScaleX(1);
arrowPane.setScaleY(1);
arrowPane.setTranslateX(0);
arrowPane.setTranslateY(0);
}
infoTableShow = !infoTableShow;
}
}