From 4fdd34dca27941cf06ab3d50e02587c0b7d02a17 Mon Sep 17 00:00:00 2001 From: dagorne Date: Tue, 18 Oct 2022 13:52:42 +0200 Subject: [PATCH] MAJ boutons P4 --- projetAgile/Makefile | 6 ++++ .../Controller/GrilleMouseListener.java | 7 ----- .../projetAgile/Controller/ResetGame.java | 29 +++++++++++++++++++ .../projetAgile/View/Puissance4Panel.java | 23 +++++++++++---- 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 projetAgile/src/fr/iutfbleau/projetAgile/Controller/ResetGame.java diff --git a/projetAgile/Makefile b/projetAgile/Makefile index 1efad1b..ad1d038 100644 --- a/projetAgile/Makefile +++ b/projetAgile/Makefile @@ -41,6 +41,11 @@ build/$(PACKAGE_PATH)/Event/AbstractGridInitiater.class : src/$(PACKAGE_PATH)/Ev #------- Controleur ------ +build/$(PACKAGE_PATH)/Controller/ResetGame.class : src/$(PACKAGE_PATH)/Controller/ResetGame.java \ + build/$(PACKAGE_PATH)/View/Grille.class \ + build/$(PACKAGE_PATH)/Model/GrilleModel.class + javac $(JAVAC_OPT) $< + build/$(PACKAGE_PATH)/Controller/GrilleMouseListener.class : src/$(PACKAGE_PATH)/Controller/GrilleMouseListener.java \ build/$(PACKAGE_PATH)/View/Grille.class \ build/$(PACKAGE_PATH)/Model/GrilleModel.class \ @@ -83,6 +88,7 @@ build/$(PACKAGE_PATH)/View/Grille.class : src/$(PACKAGE_PATH)/View/Grille.java \ build/$(PACKAGE_PATH)/View/Puissance4Panel.class : src/$(PACKAGE_PATH)/View/Puissance4Panel.java \ build/$(PACKAGE_PATH)/View/Pion.class \ build/$(PACKAGE_PATH)/View/Grille.class \ + build/$(PACKAGE_PATH)/Controller/ResetGame.class \ $(Controller) javac $(JAVAC_OPT) $< diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/Controller/GrilleMouseListener.java b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/GrilleMouseListener.java index 69c42ae..83a867b 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/Controller/GrilleMouseListener.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/GrilleMouseListener.java @@ -29,12 +29,5 @@ public class GrilleMouseListener extends MouseInputAdapter{ this.modele.verifyColumn(column); } } - //Seulement pour cas de test (Doit être modifié) - else { - this.modele.reset(); - this.grille.reset(); - } - } - } diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ResetGame.java b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ResetGame.java new file mode 100644 index 0000000..45204c3 --- /dev/null +++ b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ResetGame.java @@ -0,0 +1,29 @@ +package fr.iutfbleau.projetAgile.Controller; + +import javax.swing.*; +import java.awt.event.*; +import fr.iutfbleau.projetAgile.Model.GrilleModel; +import fr.iutfbleau.projetAgile.View.Grille; + + + +public class ResetGame implements ActionListener { + + /** + * obligatoire car test implémente l'interface ActionListener + */ + private Grille grille; + private GrilleModel modele; + + public ResetGame(Grille grille, GrilleModel modele){ + + this.grille = grille; + this.modele = modele; + } + + @Override + public void actionPerformed(ActionEvent e) { + this.modele.reset(); + this.grille.reset(); + } +} diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java b/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java index 37c4f0f..44fc26d 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java @@ -1,9 +1,12 @@ package fr.iutfbleau.projetAgile.View; import javax.swing.*; +import javax.swing.border.EmptyBorder; + import java.awt.*; import fr.iutfbleau.projetAgile.Controller.GrilleMouseListener; import fr.iutfbleau.projetAgile.Controller.ModelEventListener; +import fr.iutfbleau.projetAgile.Controller.ResetGame; import fr.iutfbleau.projetAgile.Model.GrilleModel; public class Puissance4Panel extends JPanel{ @@ -15,13 +18,15 @@ public class Puissance4Panel extends JPanel{ public Puissance4Panel() { super(); - this.reset = new JButton("recommencer"); - this.menu = new JButton("Accueil"); + this.reset = new JButton("RECOMMENCER"); + this.menu = new JButton("ACCUEIL"); this.label = new JLabel("TOUR DU JOUEUR 1"); this.grille = new Grille(); GrilleModel gm = new GrilleModel(); GrilleMouseListener listener = new GrilleMouseListener(this.grille, gm); + ResetGame resetGame = new ResetGame(grille, gm); + reset.addActionListener(resetGame); ModelEventListener mel = new ModelEventListener(this.grille); this.grille.addMouseListener(listener); gm.addGridListener(mel); @@ -39,7 +44,7 @@ public class Puissance4Panel extends JPanel{ gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.CENTER; + gbc.anchor = GridBagConstraints.WEST; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0; @@ -51,6 +56,7 @@ public class Puissance4Panel extends JPanel{ JLabel titre = new JLabel("PUISSANCE 4"); titre.setForeground(Color.WHITE); + titre.setFont(new Font("",Font.BOLD, 40)); gbc.gridx = 1; gbc.gridy = 0; @@ -83,19 +89,24 @@ public class Puissance4Panel extends JPanel{ gbc.gridy = 2; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; - gbc.gridwidth = 1; + gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; - gbc.insets = new Insets(0, 0, 0, 0); + gbc.insets = new Insets(50, 0, 0, 0); panneauBas.setOpaque(false); label.setForeground(Color.WHITE); + label.setFont(new Font("",Font.BOLD, 20)); this.add(panneauBas, gbc); reset.setBackground(new Color(255,64,64)); reset.setForeground(Color.WHITE); - reset.setBorder(BorderFactory.createEmptyBorder(5,10,5,10)); + reset.setBorder(new EmptyBorder(5,10,5,10)); + + menu.setBackground(new Color(255,64,64)); + menu.setForeground(Color.WHITE); + menu.setBorder(new EmptyBorder(5,10,5,10)); } public Grille getGrille() {