diff options
Diffstat (limited to 'apps/plugins/puzzles/src/PuzzleApplet.java')
-rw-r--r-- | apps/plugins/puzzles/src/PuzzleApplet.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/apps/plugins/puzzles/src/PuzzleApplet.java b/apps/plugins/puzzles/src/PuzzleApplet.java index 512aede580..8455734dd1 100644 --- a/apps/plugins/puzzles/src/PuzzleApplet.java +++ b/apps/plugins/puzzles/src/PuzzleApplet.java | |||
@@ -61,19 +61,19 @@ public class PuzzleApplet extends JApplet implements Runtime.CallJavaCB { | |||
61 | JMenuBar menubar = new JMenuBar(); | 61 | JMenuBar menubar = new JMenuBar(); |
62 | JMenu jm; | 62 | JMenu jm; |
63 | menubar.add(jm = new JMenu("Game")); | 63 | menubar.add(jm = new JMenu("Game")); |
64 | addMenuItemWithKey(jm, "New", 'n'); | 64 | addMenuItemCallback(jm, "New", "jcallback_newgame_event"); |
65 | addMenuItemCallback(jm, "Restart", "jcallback_restart_event"); | 65 | addMenuItemCallback(jm, "Restart", "jcallback_restart_event"); |
66 | addMenuItemCallback(jm, "Specific...", "jcallback_config_event", CFG_DESC); | 66 | addMenuItemCallback(jm, "Specific...", "jcallback_config_event", CFG_DESC); |
67 | addMenuItemCallback(jm, "Random Seed...", "jcallback_config_event", CFG_SEED); | 67 | addMenuItemCallback(jm, "Random Seed...", "jcallback_config_event", CFG_SEED); |
68 | jm.addSeparator(); | 68 | jm.addSeparator(); |
69 | addMenuItemWithKey(jm, "Undo", 'u'); | 69 | addMenuItemCallback(jm, "Undo", "jcallback_undo_event"); |
70 | addMenuItemWithKey(jm, "Redo", 'r'); | 70 | addMenuItemCallback(jm, "Redo", "jcallback_redo_event"); |
71 | jm.addSeparator(); | 71 | jm.addSeparator(); |
72 | solveCommand = addMenuItemCallback(jm, "Solve", "jcallback_solve_event"); | 72 | solveCommand = addMenuItemCallback(jm, "Solve", "jcallback_solve_event"); |
73 | solveCommand.setEnabled(false); | 73 | solveCommand.setEnabled(false); |
74 | if (mainWindow != null) { | 74 | if (mainWindow != null) { |
75 | jm.addSeparator(); | 75 | jm.addSeparator(); |
76 | addMenuItemWithKey(jm, "Exit", 'q'); | 76 | addMenuItemCallback(jm, "Exit", "jcallback_quit_event"); |
77 | } | 77 | } |
78 | menubar.add(typeMenu = new JMenu("Type")); | 78 | menubar.add(typeMenu = new JMenu("Type")); |
79 | typeMenu.setVisible(false); | 79 | typeMenu.setVisible(false); |
@@ -126,7 +126,12 @@ public class PuzzleApplet extends JApplet implements Runtime.CallJavaCB { | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | public void keyTyped(KeyEvent e) { | 128 | public void keyTyped(KeyEvent e) { |
129 | runtimeCall("jcallback_key_event", new int[] {0, 0, e.getKeyChar()}); | 129 | int key = e.getKeyChar(); |
130 | if (key == 26 && e.isShiftDown() && e.isControlDown()) { | ||
131 | runtimeCall("jcallback_redo_event", new int[0]); | ||
132 | return; | ||
133 | } | ||
134 | runtimeCall("jcallback_key_event", new int[] {0, 0, key}); | ||
130 | } | 135 | } |
131 | }); | 136 | }); |
132 | pp.addMouseListener(new MouseAdapter() { | 137 | pp.addMouseListener(new MouseAdapter() { |
@@ -217,10 +222,6 @@ public class PuzzleApplet extends JApplet implements Runtime.CallJavaCB { | |||
217 | runtimeCall("jcallback_resize", new int[] {pp.getWidth(), pp.getHeight()}); | 222 | runtimeCall("jcallback_resize", new int[] {pp.getWidth(), pp.getHeight()}); |
218 | } | 223 | } |
219 | 224 | ||
220 | private void addMenuItemWithKey(JMenu jm, String name, int key) { | ||
221 | addMenuItemCallback(jm, name, "jcallback_menu_key_event", key); | ||
222 | } | ||
223 | |||
224 | private JMenuItem addMenuItemCallback(JMenu jm, String name, final String callback, final int arg) { | 225 | private JMenuItem addMenuItemCallback(JMenu jm, String name, final String callback, final int arg) { |
225 | return addMenuItemCallback(jm, name, callback, new int[] {arg}, false); | 226 | return addMenuItemCallback(jm, name, callback, new int[] {arg}, false); |
226 | } | 227 | } |