diff --git a/OOP_2B1_Project/image_OOP.png b/OOP_2B1_Project/image_OOP.png new file mode 100644 index 0000000..b3a674b Binary files /dev/null and b/OOP_2B1_Project/image_OOP.png differ diff --git a/OOP_2B1_Project/src/windowInterface/MyInterface.java b/OOP_2B1_Project/src/windowInterface/MyInterface.java index e661bdb..c152742 100644 --- a/OOP_2B1_Project/src/windowInterface/MyInterface.java +++ b/OOP_2B1_Project/src/windowInterface/MyInterface.java @@ -28,9 +28,12 @@ import java.awt.event.ActionEvent; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.AbstractListModel; +import javax.swing.ImageIcon; import javax.swing.JToggleButton; import javax.swing.JRadioButton; import javax.swing.JCheckBox; +import javax.swing.*; +import java.awt.*; public class MyInterface extends JFrame { @@ -161,14 +164,15 @@ public class MyInterface extends JFrame { } } + public void clicButtonStart() { this.instantiateSimu(); + int introduction = introduction(); int depth = askDifficulty(); int time=askTime(); game.setAutoPlayerDepth(depth); game.setDefaultSetup(); } - public void clickButtonAdder() { panelDraw.toggleAdderMode(); } @@ -326,4 +330,37 @@ public class MyInterface extends JFrame { default: return 4; // 10 min } } + private int introduction() { + + int boardWidth = 600; + int boardHeight = 600; + String imagePath = "image_OOP.png"; // replace with your actual image path + ImageIcon originalIcon = new ImageIcon(imagePath); + + // Check if the image was loaded successfully + if (originalIcon.getImageLoadStatus() != MediaTracker.COMPLETE) { + JOptionPane.showMessageDialog(this, "Error loading image: " + imagePath, "Image Error", JOptionPane.ERROR_MESSAGE); + return 0; // Return or handle the error as needed + } + + Image originalImage = originalIcon.getImage(); + Image resizedImage = originalImage.getScaledInstance(boardWidth, boardHeight, Image.SCALE_SMOOTH); + ImageIcon resizedIcon = new ImageIcon(resizedImage); + + Object[] options = {"Start"}; + + int choice = JOptionPane.showOptionDialog( + this, + " ", + " ", + JOptionPane.DEFAULT_OPTION, + JOptionPane.PLAIN_MESSAGE, + resizedIcon, + options, + options[0] + ); + + return 1; + } + }