Skip to content

Commit

Permalink
Show warning before quit if recording hasn't been exported yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels-NTG committed Jan 12, 2025
1 parent a5592ff commit bf34e61
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/nl/nielspoldervaart/ftlav/ui/FTLFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,17 @@ public void windowClosing(WindowEvent e) {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent w) {
int exitWarning = JOptionPane.showConfirmDialog(
boolean hasUnsavedRecording =
FTLAdventureVisualiser.hasRecords() && (
FTLAdventureVisualiser.recordsExportFile == null || !FTLAdventureVisualiser.recordsExportFile.exists()
);
int exitWarningResponse = JOptionPane.showConfirmDialog(
null,
"Are you sure you want to quit FTLAV?",
String.format("Are you sure you want to quit FTLAV?%s", hasUnsavedRecording ? " Your recording hasn't been saved to a file yet!" : ""),
"Confirm before quiting FTLAV…",
JOptionPane.YES_NO_OPTION
);
if (exitWarning == JOptionPane.YES_OPTION) {
if (exitWarningResponse == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
Expand Down

0 comments on commit bf34e61

Please sign in to comment.