Skip to content

Commit

Permalink
Don't show safety prompt twice when resetting new unit
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbraginskiy committed Jan 11, 2025
1 parent 6561f8e commit 3062c09
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions megameklab/src/megameklab/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private JMenu createFileMenu() {
final JMenuItem miResetCurrentUnit = new JMenuItem(resources.getString("miResetCurrentUnit.text"));
miResetCurrentUnit.setName("miResetCurrentUnit");
miResetCurrentUnit.setMnemonic(KeyEvent.VK_R);
miResetCurrentUnit.addActionListener(this::resetEntity);
miResetCurrentUnit.addActionListener(event -> resetEntity(false));
miResetCurrentUnit.setEnabled(isUnitGui());
fileMenu.add(miResetCurrentUnit);

Expand Down Expand Up @@ -1084,8 +1084,8 @@ private void recordSheetImagesAction() {
dlg.setVisible(true);
}

private void resetEntity(ActionEvent event) {
if (!owner.safetyPrompt() || !isUnitGui()) {
private void resetEntity(boolean skipSafetyPrompt) {
if (skipSafetyPrompt || !owner.safetyPrompt() || !isUnitGui()) {
return;
}

Expand Down Expand Up @@ -1130,13 +1130,13 @@ public void dropChanges() {

var filename = editor.getFileName();
if (filename == null || filename.isBlank()) {
resetEntity(null);
resetEntity( true);
return;
}

var file = new File(filename);
if (!file.isFile()) {
resetEntity(null);
logger.error("Could not discard changed to unit because the original file no longer exists!", "Reset error");
} else {
try {
var entity = new MekFileParser(file).getEntity();
Expand Down

0 comments on commit 3062c09

Please sign in to comment.