Skip to content

Commit 11ad004

Browse files
committed
Adding a functioning settings menu
1 parent 10a0e3f commit 11ad004

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/main/java/com/commonwealthrobotics/MainController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,17 @@ void onHoleButton(ActionEvent event) {
485485
void onHome(ActionEvent event) {
486486
com.neuronrobotics.sdk.common.Log.error("Open the Project Select UI");
487487
// session.setKeyBindingFocus();
488-
homeButton.setDisable(true);
488+
if (holeButton!=null)
489+
homeButton.setDisable(true);
489490
Runnable onFinish = () -> {
491+
if(session!=null)
490492
session.setKeyBindingFocus();
491493
com.neuronrobotics.sdk.common.Log.error("ProjectManager Close");
492494
BowlerStudio.runLater(() -> homeButton.setDisable(false));
493495
};
494496
Runnable onClear = () -> {
497+
if(session==null)
498+
return;
495499
session.clearScreen();
496500
session.clearSelection();
497501
};

src/main/java/com/commonwealthrobotics/SettingsManager.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class SettingsManager {
5858
private TextField workingDirPath; // Value injected by FXMLLoader
5959

6060
private static MainController mc;
61+
private static boolean changedDir=false;
6162

6263
@FXML
6364
void onAdvancedMode(ActionEvent event) {
@@ -121,9 +122,13 @@ void onBrowse(ActionEvent event) {
121122
File selectedDirectory = directoryChooser.showDialog(stage);
122123

123124
if (selectedDirectory != null) {
124-
System.out.println("Selected directory: " + selectedDirectory.getAbsolutePath());
125-
ConfigurationDatabase.put("CaDoodle", "CaDoodleWorkspace", selectedDirectory.getAbsolutePath());
126-
workingDirPath.setText(selectedDirectory.getAbsolutePath());
125+
String absolutePath = selectedDirectory.getAbsolutePath();
126+
System.out.println("Selected directory: " + absolutePath);
127+
ConfigurationDatabase.put("CaDoodle", "CaDoodleWorkspace", absolutePath);
128+
if(!absolutePath.contentEquals(workingDirPath.getText())) {
129+
changedDir=true;
130+
}
131+
workingDirPath.setText(absolutePath);
127132
ConfigurationDatabase.save();
128133
}
129134
}
@@ -152,6 +157,7 @@ void initialize() {
152157
boolean advanced = Boolean.parseBoolean(ConfigurationDatabase.get("CaDoodle", "CaDoodleAdvancedMode", ""+true).toString());
153158
mc.setAdvancedMode(advanced);
154159
advancedSelector.setSelected(advanced);
160+
changedDir=false;
155161
}
156162

157163
public static void main(String[] args) {
@@ -176,6 +182,11 @@ public static void launch(MainController mc) {
176182
// Set the scene
177183
Scene scene = new Scene(root);
178184
stage.setScene(scene);
185+
stage.setOnCloseRequest(event -> {
186+
if(changedDir) {
187+
mc.onHome(null);
188+
}
189+
});
179190
// Show the new window
180191
stage.show();
181192
} catch (IOException e) {

0 commit comments

Comments
 (0)