Added confirm button in keybinding dialog.

-  clicking confirm button will exit the dialog
- [WIP] exit without clicking confirm button will still save changes, which should be fixed in the future

tags: #story[1273]
This commit is contained in:
Haoming Yin
2017-09-28 13:58:25 +13:00
parent f02208ba3a
commit 9795083d4d
4 changed files with 28 additions and 25 deletions
@@ -1,24 +1,12 @@
package seng302.visualiser.controllers; package seng302.visualiser.controllers;
import com.jfoenix.controls.JFXDecorator;
import com.jfoenix.controls.JFXSnackbar;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.SceneAntialiasing;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import seng302.gameServer.ServerAdvertiser;
import seng302.utilities.Sounds;
import seng302.visualiser.GameClient;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/** /**
* Created by Kusal on 26-Sep-17. * Created by Kusal on 26-Sep-17.
@@ -37,7 +25,7 @@ public class SplashScreenController implements Initializable{
class SplashScreen extends Thread { class SplashScreen extends Thread {
public void run(){ public void run(){
try { try {
Thread.sleep(2000); Thread.sleep(3000);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -27,7 +27,7 @@ public class KeyBindingDialogController implements Initializable {
@FXML @FXML
private Label closeLabel; private Label closeLabel;
@FXML @FXML
private JFXButton zoomInbtn; private JFXButton zoomInBtn;
@FXML @FXML
private JFXButton zoomOutBtn; private JFXButton zoomOutBtn;
@FXML @FXML
@@ -43,6 +43,8 @@ public class KeyBindingDialogController implements Initializable {
@FXML @FXML
private JFXButton resetBtn; private JFXButton resetBtn;
@FXML @FXML
private JFXButton confirmBtn;
@FXML
private Label upwindLabel; private Label upwindLabel;
@FXML @FXML
private Label downwindLabel; private Label downwindLabel;
@@ -70,7 +72,7 @@ public class KeyBindingDialogController implements Initializable {
gameKeyBind = GameKeyBind.getInstance(); gameKeyBind = GameKeyBind.getInstance();
buttons = new ArrayList<>(); buttons = new ArrayList<>();
Collections.addAll(buttons, Collections.addAll(buttons,
zoomInbtn, zoomOutBtn, vmgBtn, sailInOutBtn, tackGybeBtn, upwindBtn, downwindBtn, zoomInBtn, zoomOutBtn, vmgBtn, sailInOutBtn, tackGybeBtn, upwindBtn, downwindBtn,
viewButton, rightButton, leftButton, forwardButton, backwardButton); viewButton, rightButton, leftButton, forwardButton, backwardButton);
bindButtonWithAction(); bindButtonWithAction();
loadKeyBind(); loadKeyBind();
@@ -91,6 +93,7 @@ public class KeyBindingDialogController implements Initializable {
}); });
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog()); closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
confirmBtn.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
} }
/** /**
@@ -35,14 +35,14 @@ JFXToggleButton {
-fx-text-fill: -fx-pp-theme-color; -fx-text-fill: -fx-pp-theme-color;
} }
#resetBtn { #resetBtn, #confirmBtn {
-fx-background-color: -fx-pp-theme-color; -fx-background-color: -fx-pp-theme-color;
-fx-text-fill: -fx-pp-front-color; -fx-text-fill: -fx-pp-front-color;
-fx-effect: -fx-pp-dropshadow-light; -fx-effect: -fx-pp-dropshadow-light;
-fx-font-size: 18; -fx-font-size: 18;
} }
#resetBtn:hover { #resetBtn:hover, #confirmBtn:hover {
-fx-font-size: 20; -fx-font-size: 20;
} }
@@ -23,6 +23,7 @@
<GridPane> <GridPane>
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="60.0" <RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="60.0"
@@ -112,7 +113,7 @@
<Insets/> <Insets/>
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<JFXButton id="ZOOM IN" fx:id="zoomInbtn" buttonType="RAISED" <JFXButton id="ZOOM IN" fx:id="zoomInBtn" buttonType="RAISED"
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="35.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="35.0"
minWidth="-Infinity" prefWidth="120.0" text="Z" minWidth="-Infinity" prefWidth="120.0" text="Z"
GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.columnIndex="1" GridPane.halignment="CENTER"
@@ -223,8 +224,19 @@
GridPane.valignment="TOP"/> GridPane.valignment="TOP"/>
<JFXButton fx:id="resetBtn" buttonType="RAISED" maxHeight="-Infinity" <JFXButton fx:id="resetBtn" buttonType="RAISED" maxHeight="-Infinity"
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="140.0" text="RESET" GridPane.columnSpan="2" GridPane.halignment="LEFT"
GridPane.rowIndex="2" GridPane.valignment="CENTER"/> GridPane.rowIndex="2" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets left="60.0"/>
</GridPane.margin>
</JFXButton>
<JFXButton fx:id="confirmBtn" buttonType="RAISED" maxHeight="-Infinity"
maxWidth="-Infinity" minHeight="45.0" minWidth="140.0" prefHeight="45.0"
prefWidth="140.0" text="CONFIRM" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="60.0"/>
</GridPane.margin>
</JFXButton>
</children> </children>
</GridPane> </GridPane>
</children> </children>