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
|
* @return true if successfully bind
|
||||||
*/
|
*/
|
||||||
public boolean bindKeyToAction(KeyCode keyCode, KeyAction keyAction) {
|
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
|
// if the key has been bound to other action, return false
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class ViewManager {
|
|||||||
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private JFXSnackbar jfxSnackbar;
|
private JFXSnackbar jfxSnackbar;
|
||||||
|
private JFXDialog keyBindingDialog;
|
||||||
|
|
||||||
private ViewManager() {
|
private ViewManager() {
|
||||||
properties = new HashMap<>();
|
properties = new HashMap<>();
|
||||||
@@ -123,13 +124,14 @@ public class ViewManager {
|
|||||||
HBox btns = (HBox) decorator.getChildren().get(0);
|
HBox btns = (HBox) decorator.getChildren().get(0);
|
||||||
|
|
||||||
//Create settings button -- [WIP]
|
//Create settings button -- [WIP]
|
||||||
JFXButton btnSettings = new JFXButton();
|
JFXButton btnKeyBinding = new JFXButton();
|
||||||
btnSettings.setText(" Key Bindings");
|
btnKeyBinding.setText(" Key Bindings");
|
||||||
btnSettings.setStyle("-fx-text-fill:#fff");
|
btnKeyBinding.setStyle("-fx-text-fill:#fff");
|
||||||
btnSettings.getStyleClass().add("jfx-decorator-button");
|
btnKeyBinding.getStyleClass().add("jfx-decorator-button");
|
||||||
btnSettings.setCursor(Cursor.HAND);
|
btnKeyBinding.setCursor(Cursor.HAND);
|
||||||
|
btnKeyBinding.setFocusTraversable(false);
|
||||||
|
|
||||||
btnSettings.setOnMouseClicked(event -> Platform.runLater(() -> {
|
btnKeyBinding.setOnMouseClicked(event -> Platform.runLater(() -> {
|
||||||
try {
|
try {
|
||||||
if (!checkDialogOpened(decorator.getChildren())) {
|
if (!checkDialogOpened(decorator.getChildren())) {
|
||||||
showKeyBindingDialog();
|
showKeyBindingDialog();
|
||||||
@@ -145,6 +147,7 @@ public class ViewManager {
|
|||||||
btnMute.setStyle("-fx-text-fill:#fff");
|
btnMute.setStyle("-fx-text-fill:#fff");
|
||||||
btnMute.getStyleClass().add("jfx-decorator-button");
|
btnMute.getStyleClass().add("jfx-decorator-button");
|
||||||
btnMute.setCursor(Cursor.HAND);
|
btnMute.setCursor(Cursor.HAND);
|
||||||
|
btnMute.setFocusTraversable(false);
|
||||||
|
|
||||||
//Create Graphics
|
//Create Graphics
|
||||||
SVGGlyph spacer = new SVGGlyph(0, "SPACER", "", Color.WHITE);
|
SVGGlyph spacer = new SVGGlyph(0, "SPACER", "", Color.WHITE);
|
||||||
@@ -169,12 +172,12 @@ public class ViewManager {
|
|||||||
btnMute.setGraphic(volumeOn);
|
btnMute.setGraphic(volumeOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
btnSettings.setGraphic(keyBindingGlyph);
|
btnKeyBinding.setGraphic(keyBindingGlyph);
|
||||||
|
|
||||||
// Add Buttons
|
// Add Buttons
|
||||||
btns.getChildren().add(0, spacer);
|
btns.getChildren().add(0, spacer);
|
||||||
btns.getChildren().add(0, btnMute);
|
btns.getChildren().add(0, btnMute);
|
||||||
btns.getChildren().add(0, btnSettings);
|
btns.getChildren().add(0, btnKeyBinding);
|
||||||
btnMute.setOnAction((action) -> {
|
btnMute.setOnAction((action) -> {
|
||||||
Sounds.toggleAllSounds();
|
Sounds.toggleAllSounds();
|
||||||
if (btnMute.getGraphic().equals(volumeOff)) {
|
if (btnMute.getGraphic().equals(volumeOff)) {
|
||||||
@@ -209,18 +212,23 @@ public class ViewManager {
|
|||||||
"/views/dialogs/KeyBindingDialog.fxml"));
|
"/views/dialogs/KeyBindingDialog.fxml"));
|
||||||
for (Node node : decorator.getChildren()) {
|
for (Node node : decorator.getChildren()) {
|
||||||
if (node instanceof StackPane) {
|
if (node instanceof StackPane) {
|
||||||
JFXDialog dialog = new JFXDialog((StackPane) node,
|
keyBindingDialog = new JFXDialog((StackPane) node,
|
||||||
dialogContent.load(),
|
dialogContent.load(),
|
||||||
DialogTransition.CENTER);
|
DialogTransition.CENTER);
|
||||||
|
|
||||||
KeyBindingDialogController keyBindingDialogController = dialogContent
|
KeyBindingDialogController keyBindingDialogController = dialogContent
|
||||||
.getController();
|
.getController();
|
||||||
keyBindingDialogController.setGameClient(this.gameClient);
|
keyBindingDialogController.setGameClient(this.gameClient);
|
||||||
dialog.show();
|
keyBindingDialog.show();
|
||||||
Sounds.playButtonClick();
|
Sounds.playButtonClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void closeKeyBindingDialog() {
|
||||||
|
keyBindingDialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a snackbar at the bottom of the app for 1 second.
|
* Show a snackbar at the bottom of the app for 1 second.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public class KeyBindingDialogController implements Initializable {
|
|||||||
|
|
||||||
//--------FXML BEGIN--------//
|
//--------FXML BEGIN--------//
|
||||||
@FXML
|
@FXML
|
||||||
|
private Label closeLabel;
|
||||||
|
@FXML
|
||||||
private JFXButton zoomInbtn;
|
private JFXButton zoomInbtn;
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton zoomOutBtn;
|
private JFXButton zoomOutBtn;
|
||||||
@@ -73,6 +75,8 @@ public class KeyBindingDialogController implements Initializable {
|
|||||||
gameKeyBind.setToDefault();
|
gameKeyBind.setToDefault();
|
||||||
loadKeyBind();
|
loadKeyBind();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,4 +175,5 @@ public class KeyBindingDialogController implements Initializable {
|
|||||||
public void setGameClient(GameClient gameClient) {
|
public void setGameClient(GameClient gameClient) {
|
||||||
this.gameClient = gameClient;
|
this.gameClient = gameClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@
|
|||||||
-fx-border-color: -fx-decorator-color;
|
-fx-border-color: -fx-decorator-color;
|
||||||
-fx-border-width: 0 4 4 4;
|
-fx-border-width: 0 4 4 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jfx-decorator-button {
|
||||||
|
-fx-focus-traversable: false; /* so decorator button will not be focused */
|
||||||
|
}
|
||||||
|
|
||||||
/********* customised scroll bar for scroll pane ***********/
|
/********* customised scroll bar for scroll pane ***********/
|
||||||
|
|
||||||
/* The main scrollbar **track** CSS class */
|
/* The main scrollbar **track** CSS class */
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
-fx-font-size: 20px;
|
-fx-font-size: 20px;
|
||||||
-fx-text-fill: -fx-pp-light-text-color;
|
-fx-text-fill: -fx-pp-light-text-color;
|
||||||
-fx-background-color: -fx-pp-theme-color;
|
-fx-background-color: -fx-pp-theme-color;
|
||||||
|
-fx-focus-traversable: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jfx-rippler {
|
.jfx-rippler {
|
||||||
|
|||||||
@@ -3,6 +3,16 @@
|
|||||||
-fx-text-fill: -fx-pp-dark-text-color;
|
-fx-text-fill: -fx-pp-dark-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#closeLabel {
|
||||||
|
-fx-font-size: 30;
|
||||||
|
-fx-text-fill: -fx-pp-dark-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#closeLabel:hover {
|
||||||
|
-fx-text-fill: -fx-pp-theme-color;
|
||||||
|
-fx-font-size: 33;
|
||||||
|
}
|
||||||
|
|
||||||
JFXButton {
|
JFXButton {
|
||||||
-fx-background-color: -fx-pp-light-text-color;
|
-fx-background-color: -fx-pp-light-text-color;
|
||||||
-fx-text-fill: -fx-pp-theme-color;
|
-fx-text-fill: -fx-pp-theme-color;
|
||||||
|
|||||||
@@ -110,6 +110,8 @@
|
|||||||
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="45.0"
|
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="45.0"
|
||||||
prefWidth="150.0" text="RESET" GridPane.columnSpan="2" GridPane.halignment="CENTER"
|
prefWidth="150.0" text="RESET" GridPane.columnSpan="2" GridPane.halignment="CENTER"
|
||||||
GridPane.rowIndex="9" GridPane.valignment="CENTER"/>
|
GridPane.rowIndex="9" GridPane.valignment="CENTER"/>
|
||||||
|
<Label fx:id="closeLabel" text="✖" translateY="-5.0" GridPane.columnIndex="1"
|
||||||
|
GridPane.halignment="RIGHT" GridPane.valignment="TOP"/>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user