Minor changes preparing to merge in 3D
#story[1261]
This commit is contained in:
@@ -6,6 +6,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import visualiser.model.RaceConnection;
|
import visualiser.model.RaceConnection;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -13,7 +14,7 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
//TODO it appears this view/controller was replaced by Lobby.fxml. Remove?
|
//TODO it appears this view/controller was replaced by Lobby.fxml. Remove?
|
||||||
/**
|
/**
|
||||||
* Controls the connection that the VIsualiser can connect to.
|
* Controls the connection that the Visualiser can connect to.
|
||||||
*/
|
*/
|
||||||
public class ConnectionController extends Controller {
|
public class ConnectionController extends Controller {
|
||||||
@FXML AnchorPane connectionWrapper;
|
@FXML AnchorPane connectionWrapper;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package visualiser.Controllers;
|
package visualiser.Controllers;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
@@ -49,7 +48,7 @@ public class KeyBindingsController extends Controller {
|
|||||||
* Sets up table before populating it.
|
* Sets up table before populating it.
|
||||||
* Set up includes headings, CSS styling and modifying default properties.
|
* Set up includes headings, CSS styling and modifying default properties.
|
||||||
*/
|
*/
|
||||||
public void initializeTable(){
|
private void initializeTable(){
|
||||||
// set the headings for each column
|
// set the headings for each column
|
||||||
lstKey.getItems().add("Key");
|
lstKey.getItems().add("Key");
|
||||||
lstControl.getItems().add("Command");
|
lstControl.getItems().add("Command");
|
||||||
@@ -67,15 +66,15 @@ public class KeyBindingsController extends Controller {
|
|||||||
|
|
||||||
// stop the columns from being selectable, so only the buttons are
|
// stop the columns from being selectable, so only the buttons are
|
||||||
lstKey.getSelectionModel().selectedItemProperty()
|
lstKey.getSelectionModel().selectedItemProperty()
|
||||||
.addListener((observable, oldvalue, newValue) ->
|
.addListener((observable, oldValue, newValue) ->
|
||||||
Platform.runLater(() ->
|
Platform.runLater(() ->
|
||||||
lstKey.getSelectionModel().select(0)));
|
lstKey.getSelectionModel().select(0)));
|
||||||
lstDescription.getSelectionModel().selectedItemProperty()
|
lstDescription.getSelectionModel().selectedItemProperty()
|
||||||
.addListener((observable, oldvalue, newValue) ->
|
.addListener((observable, oldValue, newValue) ->
|
||||||
Platform.runLater(() ->
|
Platform.runLater(() ->
|
||||||
lstDescription.getSelectionModel().select(0)));
|
lstDescription.getSelectionModel().select(0)));
|
||||||
lstControl.getSelectionModel().selectedItemProperty()
|
lstControl.getSelectionModel().selectedItemProperty()
|
||||||
.addListener((observable, oldvalue, newValue) ->
|
.addListener((observable, oldValue, newValue) ->
|
||||||
Platform.runLater(() ->
|
Platform.runLater(() ->
|
||||||
lstControl.getSelectionModel().select(0)));
|
lstControl.getSelectionModel().select(0)));
|
||||||
}
|
}
|
||||||
@@ -83,7 +82,7 @@ public class KeyBindingsController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Populates the table with commands and their key binding details.
|
* Populates the table with commands and their key binding details.
|
||||||
*/
|
*/
|
||||||
public void populateTable(){
|
private void populateTable(){
|
||||||
// add each command to the table
|
// add each command to the table
|
||||||
for (Map.Entry<String, ControlKey> entry : newKeyFactory.getKeyState().entrySet()) {
|
for (Map.Entry<String, ControlKey> entry : newKeyFactory.getKeyState().entrySet()) {
|
||||||
// create button for command
|
// create button for command
|
||||||
@@ -100,9 +99,9 @@ public class KeyBindingsController extends Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a copy of the {@link KeyFactory} that does not modify the original.
|
* Makes a copy of the {@link KeyFactory} that does not modify the original.
|
||||||
* @return new keyfactory to be modified
|
* @return new keyFactory to be modified
|
||||||
*/
|
*/
|
||||||
public KeyFactory copyExistingFactory(){
|
private KeyFactory copyExistingFactory(){
|
||||||
newKeyFactory = new KeyFactory();
|
newKeyFactory = new KeyFactory();
|
||||||
Map<String, ControlKey> oldKeyState = existingKeyFactory.getKeyState();
|
Map<String, ControlKey> oldKeyState = existingKeyFactory.getKeyState();
|
||||||
Map<String, ControlKey> newKeyState = new HashMap<>();
|
Map<String, ControlKey> newKeyState = new HashMap<>();
|
||||||
@@ -118,18 +117,16 @@ public class KeyBindingsController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Creates a listener for when a user tries to close the current window.
|
* Creates a listener for when a user tries to close the current window.
|
||||||
*/
|
*/
|
||||||
public void setClosedListener(){
|
private void setClosedListener(){
|
||||||
anchor.sceneProperty().addListener((obsS, oldS, newS) -> {
|
anchor.sceneProperty().addListener((obsS, oldS, newS) -> {
|
||||||
if (newS != null) {
|
if (newS != null) {
|
||||||
newS.windowProperty().addListener((obsW, oldW, newW) -> {
|
newS.windowProperty().addListener((obsW, oldW, newW) -> {
|
||||||
if (newW != null) {
|
if (newW != null) {
|
||||||
Stage stage = (Stage)newW;
|
Stage stage = (Stage)newW;
|
||||||
// WE is processed by onExit method
|
// WE is processed by onExit method
|
||||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
stage.setOnCloseRequest(we -> {
|
||||||
public void handle(WindowEvent we) {
|
if (we.getEventType() == WindowEvent.WINDOW_CLOSE_REQUEST) {
|
||||||
if (we.getEventType() == WindowEvent.WINDOW_CLOSE_REQUEST) {
|
onExit(we);
|
||||||
onExit(we);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -139,11 +136,11 @@ public class KeyBindingsController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a listener for the base anchorpane for key presses.
|
* Creates a listener for the base anchorPane for key presses.
|
||||||
* It updates the current key bindings of the {@link KeyFactory} if
|
* It updates the current key bindings of the {@link KeyFactory} if
|
||||||
* required.
|
* required.
|
||||||
*/
|
*/
|
||||||
public void setKeyListener(){
|
private void setKeyListener(){
|
||||||
anchor.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
anchor.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||||
// if esc, cancel current button click
|
// if esc, cancel current button click
|
||||||
if (event.getCode() == KeyCode.ESCAPE){
|
if (event.getCode() == KeyCode.ESCAPE){
|
||||||
@@ -218,10 +215,10 @@ public class KeyBindingsController extends Controller {
|
|||||||
* commands are missing a key binding.
|
* commands are missing a key binding.
|
||||||
* @return True if valid, false if invalid
|
* @return True if valid, false if invalid
|
||||||
*/
|
*/
|
||||||
public Boolean isFactoryValid(){
|
private Boolean isFactoryValid(){
|
||||||
for (Map.Entry<String, ControlKey> entry : newKeyFactory.getKeyState().entrySet
|
for (Map.Entry<String, ControlKey> entry : newKeyFactory.getKeyState().entrySet
|
||||||
()) {
|
()) {
|
||||||
if (entry.getKey().toString()==entry.getValue().toString()){
|
if (entry.getKey().toString().equals(entry.getValue().toString())){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +231,7 @@ public class KeyBindingsController extends Controller {
|
|||||||
* @param we {@link WindowEvent} close request to be consumed if settings
|
* @param we {@link WindowEvent} close request to be consumed if settings
|
||||||
* have not been successfully saved.
|
* have not been successfully saved.
|
||||||
*/
|
*/
|
||||||
public void onExit(WindowEvent we){
|
private void onExit(WindowEvent we){
|
||||||
// if modified KeyFactory hasn't been saved
|
// if modified KeyFactory hasn't been saved
|
||||||
if (changed){
|
if (changed){
|
||||||
loadNotification("Please cancel or save your changes before exiting" +
|
loadNotification("Please cancel or save your changes before exiting" +
|
||||||
@@ -248,7 +245,7 @@ public class KeyBindingsController extends Controller {
|
|||||||
* @param message the message to be displayed to the user
|
* @param message the message to be displayed to the user
|
||||||
* @param warning true if the message to be displayed is due to user error
|
* @param warning true if the message to be displayed is due to user error
|
||||||
*/
|
*/
|
||||||
public void loadNotification(String message, Boolean warning){
|
private void loadNotification(String message, Boolean warning){
|
||||||
try {
|
try {
|
||||||
NotificationController nc = (NotificationController)
|
NotificationController nc = (NotificationController)
|
||||||
loadPopupScene("notification.fxml",
|
loadPopupScene("notification.fxml",
|
||||||
|
|||||||
@@ -112,8 +112,6 @@ public class LobbyHostingController extends Controller {
|
|||||||
alert.setHeaderText("You are about to quit the race");
|
alert.setHeaderText("You are about to quit the race");
|
||||||
Optional<ButtonType> result = alert.showAndWait();
|
Optional<ButtonType> result = alert.showAndWait();
|
||||||
if(result.get() == ButtonType.OK){
|
if(result.get() == ButtonType.OK){
|
||||||
// getStage().close();
|
|
||||||
// App.app.loadTitleScreen();
|
|
||||||
loadTitleScreen();
|
loadTitleScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ public class RaceViewController extends Controller {
|
|||||||
loadTitleScreen();
|
loadTitleScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user