mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added close button for keyBindingDialog.
- fixed that you cannot bind the key you are using. #story[1278] #pair[hyi25, zyt10]
This commit is contained in:
@@ -53,7 +53,8 @@ public class GameKeyBind {
|
||||
* @return true if successfully bind
|
||||
*/
|
||||
public boolean bindKeyToAction(KeyCode keyCode, KeyAction keyAction) {
|
||||
if (instance.keyToActionMap.containsKey(keyCode)) {
|
||||
if (instance.keyToActionMap.containsKey(keyCode) && !(instance.keyToActionMap.get(keyCode)
|
||||
== keyAction)) {
|
||||
// if the key has been bound to other action, return false
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -39,6 +39,7 @@ public class ViewManager {
|
||||
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
||||
private Stage stage;
|
||||
private JFXSnackbar jfxSnackbar;
|
||||
private JFXDialog keyBindingDialog;
|
||||
|
||||
private ViewManager() {
|
||||
properties = new HashMap<>();
|
||||
@@ -123,13 +124,14 @@ public class ViewManager {
|
||||
HBox btns = (HBox) decorator.getChildren().get(0);
|
||||
|
||||
//Create settings button -- [WIP]
|
||||
JFXButton btnSettings = new JFXButton();
|
||||
btnSettings.setText(" Key Bindings");
|
||||
btnSettings.setStyle("-fx-text-fill:#fff");
|
||||
btnSettings.getStyleClass().add("jfx-decorator-button");
|
||||
btnSettings.setCursor(Cursor.HAND);
|
||||
JFXButton btnKeyBinding = new JFXButton();
|
||||
btnKeyBinding.setText(" Key Bindings");
|
||||
btnKeyBinding.setStyle("-fx-text-fill:#fff");
|
||||
btnKeyBinding.getStyleClass().add("jfx-decorator-button");
|
||||
btnKeyBinding.setCursor(Cursor.HAND);
|
||||
btnKeyBinding.setFocusTraversable(false);
|
||||
|
||||
btnSettings.setOnMouseClicked(event -> Platform.runLater(() -> {
|
||||
btnKeyBinding.setOnMouseClicked(event -> Platform.runLater(() -> {
|
||||
try {
|
||||
if (!checkDialogOpened(decorator.getChildren())) {
|
||||
showKeyBindingDialog();
|
||||
@@ -145,6 +147,7 @@ public class ViewManager {
|
||||
btnMute.setStyle("-fx-text-fill:#fff");
|
||||
btnMute.getStyleClass().add("jfx-decorator-button");
|
||||
btnMute.setCursor(Cursor.HAND);
|
||||
btnMute.setFocusTraversable(false);
|
||||
|
||||
//Create Graphics
|
||||
SVGGlyph spacer = new SVGGlyph(0, "SPACER", "", Color.WHITE);
|
||||
@@ -169,12 +172,12 @@ public class ViewManager {
|
||||
btnMute.setGraphic(volumeOn);
|
||||
}
|
||||
|
||||
btnSettings.setGraphic(keyBindingGlyph);
|
||||
btnKeyBinding.setGraphic(keyBindingGlyph);
|
||||
|
||||
// Add Buttons
|
||||
btns.getChildren().add(0, spacer);
|
||||
btns.getChildren().add(0, btnMute);
|
||||
btns.getChildren().add(0, btnSettings);
|
||||
btns.getChildren().add(0, btnKeyBinding);
|
||||
btnMute.setOnAction((action) -> {
|
||||
Sounds.toggleAllSounds();
|
||||
if (btnMute.getGraphic().equals(volumeOff)) {
|
||||
@@ -209,18 +212,23 @@ public class ViewManager {
|
||||
"/views/dialogs/KeyBindingDialog.fxml"));
|
||||
for (Node node : decorator.getChildren()) {
|
||||
if (node instanceof StackPane) {
|
||||
JFXDialog dialog = new JFXDialog((StackPane) node,
|
||||
keyBindingDialog = new JFXDialog((StackPane) node,
|
||||
dialogContent.load(),
|
||||
DialogTransition.CENTER);
|
||||
|
||||
KeyBindingDialogController keyBindingDialogController = dialogContent
|
||||
.getController();
|
||||
keyBindingDialogController.setGameClient(this.gameClient);
|
||||
dialog.show();
|
||||
keyBindingDialog.show();
|
||||
Sounds.playButtonClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeKeyBindingDialog() {
|
||||
keyBindingDialog.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a snackbar at the bottom of the app for 1 second.
|
||||
*
|
||||
|
||||
@@ -23,6 +23,8 @@ public class KeyBindingDialogController implements Initializable {
|
||||
|
||||
//--------FXML BEGIN--------//
|
||||
@FXML
|
||||
private Label closeLabel;
|
||||
@FXML
|
||||
private JFXButton zoomInbtn;
|
||||
@FXML
|
||||
private JFXButton zoomOutBtn;
|
||||
@@ -73,6 +75,8 @@ public class KeyBindingDialogController implements Initializable {
|
||||
gameKeyBind.setToDefault();
|
||||
loadKeyBind();
|
||||
});
|
||||
|
||||
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,4 +175,5 @@ public class KeyBindingDialogController implements Initializable {
|
||||
public void setGameClient(GameClient gameClient) {
|
||||
this.gameClient = gameClient;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user