Fin Menu et Makefile

This commit is contained in:
martins 2022-10-20 10:31:56 +02:00
parent 1a17541120
commit 029356f568
4 changed files with 60 additions and 31 deletions

View File

@ -98,15 +98,16 @@ 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
build/$(PACKAGE_PATH)/Controller/ResetGame.class \
build/$(PACKAGE_PATH)/View/Menu.class
javac $(JAVAC_OPT) $<
build/$(PACKAGE_PATH)/View/BoutonsMenu.class : src/$(PACKAGE_PATH)/View/BoutonsMenu.java
javac $(JAVAC_OPT) $<
build/$(PACKAGE_PATH)/View/Menu.class : src/$(PACKAGE_PATH)/View/Menu.java \
build/$(PACKAGE_PATH)/View/BoutonsMenu.class \
build/$(PACKAGE_PATH)/Controller/ObservateurMenuSouris.class
build/$(PACKAGE_PATH)/Controller/ObservateurMenuSouris.class \
build/$(PACKAGE_PATH)/View/BoutonsMenu.class
javac $(JAVAC_OPT) $<
@ -116,7 +117,9 @@ build/$(PACKAGE_PATH)/Main.class : src/$(PACKAGE_PATH)/Main.java
puissance4 : build/$(PACKAGE_PATH)/Main.class \
build/$(PACKAGE_PATH)/Puissance4Controller.class \
$(Model)
java -cp build $(PACKAGE_PATH).Main
# java -cp build $(PACKAGE_PATH).Main
jar cvfe Puissance4.jar $(PACKAGE_PATH).Main -C build fr -C res images
java -jar Puissance4.jar
clear :
rm -rf build/*

View File

@ -6,25 +6,30 @@ import javax.swing.JFrame;
import fr.iutfbleau.projetAgile.View.*;
public class ObservateurMenuSouris implements MouseListener{
private BoutonsMenu bout;
public ObservateurMenuSouris(BoutonsMenu boutons){
this.bout=boutons;
private Menu m;
public ObservateurMenuSouris(Menu m0){
this.m=m0;
}
public void mouseClicked(MouseEvent evenement){
if(this.bout.getPath()=="puissance4.png"){
//a paramétrer
BoutonsMenu bout=(BoutonsMenu) (evenement.getComponent());
if(bout.getPath()==Menu.PUISSANCE_4){
this.m.show(Menu.PUISSANCE_4);
}
} // un bouton cliqué
public void mouseEntered(MouseEvent evenement){
this.bout.setSurvol(true);
BoutonsMenu bout=(BoutonsMenu) (evenement.getComponent());
bout.setSurvol(true);
} // debut du survol
public void mouseExited(MouseEvent evenement){
this.bout.setSurvol(false);
BoutonsMenu bout=(BoutonsMenu) (evenement.getComponent());
bout.setSurvol(false);
} // fin du survol
public void mousePressed(MouseEvent evenement){
this.bout.setSurvol(false);
BoutonsMenu bout=(BoutonsMenu) (evenement.getComponent());
bout.setSurvol(false);
} // un bouton appuyé
public void mouseReleased(MouseEvent evenement){
this.bout.setSurvol(true);
BoutonsMenu bout=(BoutonsMenu) (evenement.getComponent());
bout.setSurvol(true);
} // un bouton relâché
}

View File

@ -6,17 +6,22 @@ import java.awt.*;
import fr.iutfbleau.projetAgile.Controller.Puissance4Controller;
import fr.iutfbleau.projetAgile.Model.GrilleModel;
import fr.iutfbleau.projetAgile.View.Grille;
import fr.iutfbleau.projetAgile.View.Menu;
public class Main {
public static void main(String[] args) {
Grille g = new Grille();
GrilleModel m = new GrilleModel();
Puissance4Controller p = new Puissance4Controller(g, m);
JFrame frame = new JFrame();
frame.add(p.getPanel());
frame.setLocation(200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(new Dimension(1280,720));
CardLayout cd=new CardLayout();
frame.setLayout(cd);
Menu menu=new Menu(cd, frame);
Grille g = new Grille();
GrilleModel m = new GrilleModel();
Puissance4Controller p = new Puissance4Controller(g, m);
frame.add(menu, "Menu");
frame.add(p.getPanel(), Menu.PUISSANCE_4);
frame.setVisible(true);
}
}

View File

@ -2,13 +2,18 @@ package fr.iutfbleau.projetAgile.View;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import fr.iutfbleau.projetAgile.Controller.*;
public class Menu extends JPanel{
public Menu(){
public static String PUISSANCE_4="puissance4.png";
private CardLayout cd;
private JFrame fenetre;
public Menu(CardLayout cd0, JFrame fenetre0){
super();
this.cd=cd0;
this.fenetre=fenetre0;
this.setBackground(new Color(31,31,31));
GridBagLayout gbl=new GridBagLayout();
this.setLayout(gbl);
@ -29,8 +34,8 @@ public class Menu extends JPanel{
titre.setFont(new Font("Serif" ,Font.BOLD, 50));
titre.setPreferredSize(new Dimension(400,200));
this.add(titre, gbc);
BoutonsMenu puissance_4=new BoutonsMenu("puissance4.png");
BoutonsMenu puissance_4=new BoutonsMenu(Menu.PUISSANCE_4);
BoutonsMenu echecs=new BoutonsMenu("echecs.png");
BoutonsMenu dames=new BoutonsMenu("dames.png");
@ -41,18 +46,18 @@ public class Menu extends JPanel{
BoutonsMenu CoD=new BoutonsMenu("CoD.png");
BoutonsMenu minecraft=new BoutonsMenu("minecraft.png");
BoutonsMenu puzzle=new BoutonsMenu("puzzle.png");
ObservateurMenuSouris obser=new ObservateurMenuSouris(this);
puissance_4.addMouseListener(obser);
echecs.addMouseListener(obser);
dames.addMouseListener(obser);
puissance_4.addMouseListener(new ObservateurMenuSouris(puissance_4));
echecs.addMouseListener(new ObservateurMenuSouris(echecs));
dames.addMouseListener(new ObservateurMenuSouris(dames));
demineur.addMouseListener(obser);
taquin.addMouseListener(obser);
morpion.addMouseListener(obser);
demineur.addMouseListener(new ObservateurMenuSouris(demineur));
taquin.addMouseListener(new ObservateurMenuSouris(taquin));
morpion.addMouseListener(new ObservateurMenuSouris(morpion));
CoD.addMouseListener(new ObservateurMenuSouris(CoD));
minecraft.addMouseListener(new ObservateurMenuSouris(minecraft));
puzzle.addMouseListener(new ObservateurMenuSouris(puzzle));
CoD.addMouseListener(obser);
minecraft.addMouseListener(obser);
puzzle.addMouseListener(obser);
this.add(puissance_4, Menu.GridBagConstraintsRetour(0, 1));
this.add(echecs, Menu.GridBagConstraintsRetour(1, 1));
@ -98,4 +103,15 @@ public class Menu extends JPanel{
gbc.insets=marge;
return gbc;
}
public void show(String g) throws IllegalArgumentException
{
if(g!=Menu.PUISSANCE_4){
throw new IllegalArgumentException();
}else{
if(g==Menu.PUISSANCE_4){
this.cd.show(fenetre.getContentPane(), g);
}
}
}
}