Fix pause menu bug

master
John 2022-06-19 18:39:40 -07:00
parent 99439bd4b2
commit 751126c598
2 changed files with 3 additions and 3 deletions

View File

@ -177,7 +177,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
try { try {
if (isDialogue || isPaused) { if (isDialogue || isPaused) {
mouseAlreadyTranslated = true; mouseAlreadyTranslated = true;
keyPressed(new KeyEvent(new Component() {}, 0, 0, 0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER)); keyPressed(new KeyEvent(new Component() {}, 0, -1, 0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER));
} else { } else {
player.mousePressed(e); player.mousePressed(e);
} }
@ -553,7 +553,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
isPaused = !isPaused; isPaused = !isPaused;
System.out.println(isPaused); System.out.println(isPaused);
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) { } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (isPaused && (e.getSource() == null)) { if (isPaused && (e.getWhen() != -1)) {
((CardLayout)gameFrame.getLayout()).show(gameFrame, "menu"); ((CardLayout)gameFrame.getLayout()).show(gameFrame, "menu");
} else if (!waitForDialogue) { } else if (!waitForDialogue) {
waitForDialogue = true; waitForDialogue = true;

View File

@ -75,7 +75,7 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (hoverCheck(e)) { if (hoverCheck(e)) {
keyPressed(new KeyEvent(new Component() { keyPressed(new KeyEvent(new Component() {
}, 0, 0, 0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER)); }, 0, -1, 0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER));
} }
} }
}); });