diff --git a/Banniere.java b/Banniere.java index 882cb0f..393ebfa 100644 --- a/Banniere.java +++ b/Banniere.java @@ -4,10 +4,12 @@ import java.awt.event.*; public class Banniere extends JPanel { private FrameJeu fenetre; + private FrameMenu menu; // Définition du constructeur - public Banniere(int mines, FrameJeu fenetre) { + public Banniere(int mines, FrameJeu fenetre, FrameMenu menu) { super(); this.fenetre=fenetre; + this.menu=menu; // On défini un style à la bannière this.setBackground( new Color(0, 236, 96)); @@ -26,7 +28,7 @@ public class Banniere extends JPanel { public void setVictoire(){ this.add(new Fin("Victoire !",this.getSize())); this.repaint(); - ActionListener backToMenu = new MenuListener(this.fenetre); + ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); Timer timerMenu = new Timer(5000, backToMenu); timerMenu.setRepeats(false); timerMenu.start(); @@ -36,7 +38,7 @@ public class Banniere extends JPanel { public void setDefaite(){ this.add(new Fin("Défaite !",this.getSize())); this.repaint(); - ActionListener backToMenu = new MenuListener(this.fenetre); + ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); Timer timerMenu = new Timer(5000, backToMenu); timerMenu.setRepeats(false); timerMenu.start(); diff --git a/FrameJeu.java b/FrameJeu.java index 738f240..766ad7d 100644 --- a/FrameJeu.java +++ b/FrameJeu.java @@ -3,7 +3,7 @@ import java.awt.*; // Cette classe à pour but d'afficher un menu et de réagir aux directives de l'utilisateur (lancer le jeu, le quitter...) public class FrameJeu extends JFrame{ - public FrameJeu(int lignes, int colonnes, int mines) { + public FrameJeu(int lignes, int colonnes, int mines, FrameMenu menu) { // On récupère les dimensions de l'écran pour adapter la taille par défaut de notre fenêtre Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -17,7 +17,7 @@ public class FrameJeu extends JFrame{ GridBagConstraints miseEnPage = new GridBagConstraints(); // Création de la grille de Jeu - Grille grille=new Grille(lignes,colonnes,mines,this); + Grille grille=new Grille(lignes,colonnes,mines,this, menu); // Récupération de la bannière Banniere banniere = grille.getBanniere(); diff --git a/FrameMenu.java b/FrameMenu.java index bc61a6b..9d603c2 100644 --- a/FrameMenu.java +++ b/FrameMenu.java @@ -61,7 +61,7 @@ public class FrameMenu extends JFrame{ this.add(showColumns); this.add(showMines); - JButton newGame = new JButton("New Game"); + JButton newGame = new JButton("Jouer"); newGame.addActionListener(new NewGameListener(this)); newGame.setBounds(frameSize.width*3/5, frameSize.height*12/15, frameSize.width/5, frameSize.height/15);; diff --git a/Grille.java b/Grille.java index 9f6fe52..6e8da60 100644 --- a/Grille.java +++ b/Grille.java @@ -17,7 +17,7 @@ public class Grille extends JPanel{ // TODO : Recréer un tableau avec les cases minees // Définition du constructeur qui correspond à une grille de jeu - public Grille(int lignes, int colonnes, int mines, FrameJeu fenetre){ + public Grille(int lignes, int colonnes, int mines, FrameJeu fenetre, FrameMenu menu){ super(); this.colonnes=colonnes; this.taille=lignes*colonnes; @@ -30,7 +30,7 @@ public class Grille extends JPanel{ this.grilleSize = new Dimension(((screenSize.height*3/4)/lignes)*colonnes, screenSize.height*3/4 ); Dimension caseSize = new Dimension(this.grilleSize.height/lignes,this.grilleSize.height/lignes); GridLayout damier = new GridLayout(lignes,colonnes); - Banniere banniere = new Banniere(mines,this.fenetre); + Banniere banniere = new Banniere(mines,this.fenetre, menu); this.banniere=banniere; banniere.setSize(grilleSize.width,grilleSize.height/8); this.setLayout(damier); diff --git a/Makefile b/Makefile index 63f0c51..c6077ec 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ MineLeft.class : MineLeft.java Fin.class : Fin.java ${JC} ${JCFLAGS} Fin.java -MenuListener.class : MenuListener.java FrameMenu.class +MenuListener.class : MenuListener.java ${JC} ${JCFLAGS} MenuListener.java ListenerCase.class : ListenerCase.java Etoile.class Doute.class diff --git a/MenuListener.java b/MenuListener.java index 04b2c0b..a3aaef1 100644 --- a/MenuListener.java +++ b/MenuListener.java @@ -1,11 +1,13 @@ import java.awt.event.*; public class MenuListener implements ActionListener{ private FrameJeu fenetre; - public MenuListener(FrameJeu fenetre){ + private FrameMenu menu; + public MenuListener(FrameJeu fenetre, FrameMenu menu){ this.fenetre=fenetre; + this.menu=menu; } public void actionPerformed(ActionEvent event){ - new FrameMenu(); + this.menu.setVisible(true); this.fenetre.dispose(); } } \ No newline at end of file diff --git a/NewGameListener.java b/NewGameListener.java index 00b5059..ebfc47e 100644 --- a/NewGameListener.java +++ b/NewGameListener.java @@ -6,7 +6,7 @@ public class NewGameListener implements ActionListener{ } public void actionPerformed(ActionEvent event){ int[] settings =this.menu.getSettings(); - new FrameJeu(settings[0], settings[1], settings[2]); + new FrameJeu(settings[0], settings[1], settings[2], this.menu); this.menu.dispose(); } }