1
0
Fork 0
mirror of https://gitlab.com/kauron/jstudy synced 2025-09-30 21:01:10 +02:00

Show feedback setting

This commit is contained in:
Carlos Galindo 2016-06-12 13:37:45 +02:00
commit e8111c0714
Signed by: kauron
GPG key ID: 83E68706DEE119A3
5 changed files with 30 additions and 16 deletions

View file

@ -10,16 +10,14 @@ import java.util.ResourceBundle;
public class SettingsController implements Initializable {
@FXML
private JFXCheckBox repeatMistakes;
private JFXCheckBox repeatMistakes, showFeedback;
@Override
public void initialize(URL location, ResourceBundle resources) {
System.err.println(AppConfig.printValues());
repeatMistakes.setSelected(AppConfig.repeatWrong);
repeatMistakes.selectedProperty().addListener((change, o, n) -> {
AppConfig.repeatWrong = n;
System.err.println(AppConfig.printValues());
});
repeatMistakes.selectedProperty().addListener((observable, old, value) -> AppConfig.repeatWrong = value);
showFeedback.setSelected(AppConfig.showFeedback);
showFeedback.selectedProperty().addListener((observable, old, value) -> AppConfig.showFeedback = value);
}

View file

@ -8,6 +8,7 @@ import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import java.net.URL;
import java.util.List;
@ -20,13 +21,15 @@ public class TestController implements Initializable {
private JFXTextField answer;
@FXML
private ProgressBar progress;
@FXML
private HBox feedback;
private List<TestItem> list;
private int total, current;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
feedback.setVisible(AppConfig.showFeedback);
}
void setList(List<TestItem> list) {
@ -64,6 +67,7 @@ public class TestController implements Initializable {
@FXML
private void onSkipAction(ActionEvent event) {
feedback.setVisible(AppConfig.showFeedback);
answer.setText("");
current = (int) (Math.random() * list.size());
question.setText(list.get(current).getQuestion());

View file

@ -7,12 +7,13 @@ import java.util.Scanner;
public class AppConfig {
private static final String FILE = "./config.ini";
public static boolean repeatWrong;
public static boolean repeatWrong, showFeedback;
public static void save() {
try {
PrintWriter pw = new PrintWriter(new File(FILE));
pw.print("repeatWrong=" + repeatWrong);
pw.println("repeatWrong=" + repeatWrong);
pw.println("showFeedback=" + showFeedback);
pw.flush();
pw.close();
} catch (FileNotFoundException e) {
@ -25,9 +26,11 @@ public class AppConfig {
Scanner in = new Scanner(new File(FILE));
while (in.hasNextLine()) {
String line = in.nextLine();
if (line.matches("repeatWrong=.*")) {
repeatWrong = Boolean.parseBoolean(line.substring(line.indexOf('=') + 1));
}
String value = line.substring(line.indexOf('=') + 1);
if (line.matches("repeatWrong=.*"))
repeatWrong = Boolean.parseBoolean(value);
else if (line.matches("showFeedback=.*"))
showFeedback = Boolean.parseBoolean(value);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
@ -35,6 +38,6 @@ public class AppConfig {
}
public static String printValues() {
return "repeatWrong=" + repeatWrong;
return String.format("repeatWrong=%b\nshowFeedback=%b", repeatWrong, showFeedback);
}
}