From b6b5aa2c90f816951f7f90783a03e43e1fc76baa Mon Sep 17 00:00:00 2001 From: Joshua Skelton Date: Fri, 13 Mar 2020 15:54:20 -0700 Subject: [PATCH] Reordering file menu --- .../src/com/interrupt/dungeoneer/editor/Editor.java | 11 ++++++++++- .../com/interrupt/dungeoneer/editor/ui/EditorUi.java | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java b/DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java index 61fd6e04..a97cd977 100644 --- a/DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java +++ b/DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java @@ -21,6 +21,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; import java.io.File; import java.io.FileFilter; import java.util.Timer; @@ -38,6 +39,8 @@ public enum EditorMode { Carve, Paint }; public ActionListener saveAction; public ActionListener saveAsAction; public ActionListener openAction; + public ActionListener exitAction; + public ActionListener rotateLeftAction; public ActionListener rotateRightAction; public ActionListener playAction; @@ -89,7 +92,7 @@ public enum EditorMode { Carve, Paint }; public Editor() { frame = new JFrame("DelvEdit"); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE | JFrame.EXIT_ON_CLOSE); Graphics.DisplayMode defaultMode = LwjglApplicationConfiguration.getDesktopDisplayMode(); @@ -302,6 +305,12 @@ else if(file.endsWith(".bin")) { } }; + exitAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); + } + }; + rotateLeftAction = new ActionListener() { public void actionPerformed(ActionEvent event) { editorFrame.level.rotate90(); diff --git a/DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java b/DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java index ae54c4f2..5e4bbad0 100644 --- a/DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java +++ b/DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java @@ -216,10 +216,13 @@ public void actionPerformed(ActionEvent event) { // make the menu bar menuBar = new Scene2dMenuBar(smallSkin); menuBar.addItem(new MenuItem("File", smallSkin) - .addItem(new MenuItem("Save", smallSkin, editor.saveAction).setAccelerator(new MenuAccelerator(Keys.S, true, false))) - .addItem(new MenuItem("Save As...", smallSkin, editor.saveAsAction).setAccelerator(new MenuAccelerator(Keys.S, true, true))) .addItem(new MenuItem("New", smallSkin, newWindowAction).setAccelerator(new MenuAccelerator(Keys.N, true, false))) .addItem(new MenuItem("Open", smallSkin, editor.openAction).setAccelerator(new MenuAccelerator(Keys.O, true, false))) + .addSeparator() + .addItem(new MenuItem("Save", smallSkin, editor.saveAction).setAccelerator(new MenuAccelerator(Keys.S, true, false))) + .addItem(new MenuItem("Save As...", smallSkin, editor.saveAsAction).setAccelerator(new MenuAccelerator(Keys.S, true, true))) + .addSeparator() + .addItem(new MenuItem("Exit", smallSkin, editor.exitAction)) ); menuBar.addItem(new MenuItem("Edit", smallSkin)