Skip to content

Commit

Permalink
Add AutoSave toggle option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rockdtben committed Feb 3, 2018
1 parent d514459 commit 48d19f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/java/com/github/monster860/fastdmm/FastDMM.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class FastDMM extends JFrame implements ActionListener, TreeSelectionList
private JMenuItem menuItemMapImage;
private JMenuItem menuItemUndo;
private JMenuItem menuItemRedo;

private JCheckBoxMenuItem menuItemAutoSave;

private JPopupMenu currPopup;

Expand Down Expand Up @@ -324,6 +326,13 @@ public void stateChanged(ChangeEvent e) {
menuItem.setActionCommand("change_filters");
menuItem.addActionListener(FastDMM.this);
menu.add(menuItem);

menuItemAutoSave = new JCheckBoxMenuItem("AutoSave", options.autoSave);
menuItemAutoSave.setActionCommand("autoSaveToggle");
menuItemAutoSave.addActionListener(FastDMM.this);
menuItemAutoSave.setSelected(options.autoSave);

menu.add(menuItemAutoSave);

menuItemExpand = new JMenuItem("Expand Map");
menuItemExpand.setActionCommand("expand");
Expand Down Expand Up @@ -432,6 +441,8 @@ public void actionPerformed(ActionEvent e) {
}
} else if ("open_dme".equals(e.getActionCommand())) {
openDME();
} else if ("autoSaveToggle".equals(e.getActionCommand())) {
autoSaveToggle();
} else if ("open".equals(e.getActionCommand())) {
openDMM();
} else if ("save".equals(e.getActionCommand())) {
Expand Down Expand Up @@ -613,6 +624,11 @@ private void openDME() {
openDME(fc.getSelectedFile());
}
}

private void autoSaveToggle() {
options.autoSave = !options.autoSave;
options.saveOptions();
}

private void openDMM(File filetoopen) {
synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static FastDMMOptionsModel createOrLoadOptions() {
}
}

private void saveOptions()
public void saveOptions()
{
File optionsFile = new File(optionsPath);
Gson gson = new Gson();
Expand Down

0 comments on commit 48d19f7

Please sign in to comment.