From c0102b71161146ae902b54a61f1c83d6bc81ebba Mon Sep 17 00:00:00 2001 From: gabrielshiraishi Date: Mon, 12 May 2025 10:22:36 +0200 Subject: [PATCH] Option game over --- .../src/windowInterface/MyInterface.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/OOP_2B1_Project/src/windowInterface/MyInterface.java b/OOP_2B1_Project/src/windowInterface/MyInterface.java index bb13336..7b17413 100644 --- a/OOP_2B1_Project/src/windowInterface/MyInterface.java +++ b/OOP_2B1_Project/src/windowInterface/MyInterface.java @@ -51,10 +51,18 @@ public class MyInterface extends JFrame { private JLabel whiteTimerLabel; private JLabel blackTimerLabel; public TimerManager timerManager; + + + /** * Create the frame. */ public MyInterface() { + + + + + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(10, 10, 800, 800); contentPane = new JPanel(); @@ -295,11 +303,25 @@ public class MyInterface extends JFrame { } public void showGameOverMessage(String message) { - JOptionPane.showMessageDialog(this, message, "Game Over", JOptionPane.INFORMATION_MESSAGE); - game.toggleAI(false); + game.toggleAI(false); game.toggleAI(true); chckbxWhiteAI.setSelected(false); chckbxBlackAI.setSelected(false); + Object[] options = {"YES", "NO"}; + int choice = JOptionPane.showOptionDialog(this, "GAME OVER \nDo you want to exit? ", + "Game Over", + JOptionPane.DEFAULT_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[1] // default: Medium + ); + switch (choice) { + case 0: System.exit(0);; // Easy + case 1: ; // Medium + + } + } private int askDifficulty() { @@ -326,8 +348,8 @@ public class MyInterface extends JFrame { Object[] options = {"1 min", "2 Min", "5 Min", "10 Min"}; int choice = JOptionPane.showOptionDialog( this, - "Select Difficulty Level:", - "Difficulty", + "Select the duration of the game:", + "Duration", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null,