From a9f837eaebb41cc3e608a2dd83d273375d1b3419 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 May 2022 23:02:19 +0200 Subject: [PATCH] menu ok --- Banniere.java | 15 ++++++--------- FrameMenu.java | 23 +++++++++++++++-------- Makefile | 5 +---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Banniere.java b/Banniere.java index 393ebfa..7fdfe98 100644 --- a/Banniere.java +++ b/Banniere.java @@ -1,6 +1,5 @@ import javax.swing.*; import java.awt.*; -import java.awt.event.*; public class Banniere extends JPanel { private FrameJeu fenetre; @@ -12,7 +11,7 @@ public class Banniere extends JPanel { this.menu=menu; // On défini un style à la bannière - this.setBackground( new Color(0, 236, 96)); + this.setBackground(new Color(0, 236, 96)); // TODO : Bouton sauver et quitter } @@ -20,26 +19,24 @@ public class Banniere extends JPanel { // Méthode pour afficher le nombre de mines restantes public void setMinesLeft(int minesLeft){ this.removeAll(); - this.add(new MineLeft(minesLeft,this.getSize())); + this.add(new JLabel("Mines restantes : "+Integer.toString(minesLeft))); this.repaint(); } // Méthode pour indiquer au joueur sa Victoire public void setVictoire(){ - this.add(new Fin("Victoire !",this.getSize())); + this.add(new Fin("Victoire ! Retour au menu...",this.getSize())); this.repaint(); - ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); - Timer timerMenu = new Timer(5000, backToMenu); + Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu)); timerMenu.setRepeats(false); timerMenu.start(); } // Méthode pour indiquer au joueur sa Défaite public void setDefaite(){ - this.add(new Fin("Défaite !",this.getSize())); + this.add(new Fin("Défaite ! Retour au menu...",this.getSize())); this.repaint(); - ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); - Timer timerMenu = new Timer(5000, backToMenu); + Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu)); timerMenu.setRepeats(false); timerMenu.start(); } diff --git a/FrameMenu.java b/FrameMenu.java index 9d603c2..71cabdf 100644 --- a/FrameMenu.java +++ b/FrameMenu.java @@ -15,6 +15,7 @@ public class FrameMenu extends JFrame{ private JLabel showMines; public FrameMenu() { + super(); // On récupère les dimensions de l'écran pour adapter la taille de notre fenêtre Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -26,9 +27,15 @@ public class FrameMenu extends JFrame{ this.setLocation(screenSize.width * 3/10, screenSize.height * 1/6); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(null); + this.getContentPane().setBackground( new Color(0, 236, 96)); + // Ajout du titre + JLabel titre = new JLabel("Démineur"); + titre.setFont(new Font("Rockwell", Font.PLAIN, 45)); + titre.setBounds((frameSize.width/3), frameSize.height/15,frameSize.width/2,frameSize.height*2/15); + this.add(titre); - // On créer les zones de textes de saisie + // On créer les sliders et les JLabel qui afficheront leur valeur this.sliderLignes = new JSlider(4,30,20); this.sliderColonnes = new JSlider(4,30,25); this.sliderMines = new JSlider(1,900, 50); @@ -41,9 +48,9 @@ public class FrameMenu extends JFrame{ this.colonnes=sliderColonnes.getValue(); this.mines=sliderMines.getValue(); - sliderLignes.setBounds(frameSize.width*3/5, frameSize.height*6/15, frameSize.width/3, frameSize.height/20); - sliderColonnes.setBounds(frameSize.width*3/5, frameSize.height*8/15, frameSize.width/3, frameSize.height/20); - sliderMines.setBounds(frameSize.width*3/5, frameSize.height*10/15, frameSize.width/3, frameSize.height/20); + sliderLignes.setBounds(frameSize.width/3, frameSize.height*5/15, frameSize.width/3, frameSize.height/20); + sliderColonnes.setBounds(frameSize.width/3, frameSize.height*7/15, frameSize.width/3, frameSize.height/20); + sliderMines.setBounds(frameSize.width/3, frameSize.height*9/15, frameSize.width/3, frameSize.height/20); this.add(sliderLignes); this.add(sliderColonnes); @@ -53,9 +60,9 @@ public class FrameMenu extends JFrame{ this.showColumns= new JLabel("Colonnes : 25"); this.showMines= new JLabel("Mines : 50"); - this.showLines.setBounds(frameSize.width*3/5, frameSize.height*5/15, frameSize.width/3, frameSize.height/20); - this.showColumns.setBounds(frameSize.width*3/5, frameSize.height*7/15, frameSize.width/3, frameSize.height/20); - this.showMines.setBounds(frameSize.width*3/5, frameSize.height*9/15, frameSize.width/3, frameSize.height/20); + this.showLines.setBounds(frameSize.width/3, frameSize.height*4/15, frameSize.width/3, frameSize.height/20); + this.showColumns.setBounds(frameSize.width/3, frameSize.height*6/15, frameSize.width/3, frameSize.height/20); + this.showMines.setBounds(frameSize.width/3, frameSize.height*8/15, frameSize.width/3, frameSize.height/20); this.add(showLines); this.add(showColumns); @@ -64,7 +71,7 @@ public class FrameMenu extends JFrame{ 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);; + newGame.setBounds(frameSize.width*10/15, frameSize.height*12/15, frameSize.width/5, frameSize.height/15);; this.add(newGame); JButton exit = new JButton("Quitter"); diff --git a/Makefile b/Makefile index c6077ec..198cb94 100644 --- a/Makefile +++ b/Makefile @@ -26,15 +26,12 @@ FrameJeu.class : FrameJeu.java Grille.class Grille.class : Grille.java Banniere.class Case.class ${JC} ${JCFLAGS} Grille.java -Banniere.class : Banniere.java MineLeft.class MenuListener.class Fin.class +Banniere.class : Banniere.java MenuListener.class Fin.class ${JC} ${JCFLAGS} Banniere.java Case.class : Case.java ListenerCase.class Entourage.class ${JC} ${JCFLAGS} Case.java -MineLeft.class : MineLeft.java - ${JC} ${JCFLAGS} MineLeft.java - Fin.class : Fin.java ${JC} ${JCFLAGS} Fin.java