|
|
|
|
@@ -6,8 +6,15 @@ import javax.swing.*;
|
|
|
|
|
public class MenuCampagne extends JPanel {
|
|
|
|
|
|
|
|
|
|
public MenuCampagne(Jeu jeu) {
|
|
|
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
|
|
|
|
setBackground(new Color(45, 45, 45)); // Même gris foncé
|
|
|
|
|
setLayout(new BorderLayout());
|
|
|
|
|
setBackground(new Color(45, 45, 45));
|
|
|
|
|
|
|
|
|
|
CardLayout cartes = new CardLayout();
|
|
|
|
|
JPanel panneauCartes = new JPanel(cartes);
|
|
|
|
|
|
|
|
|
|
JPanel listeCampagnes = new JPanel();
|
|
|
|
|
listeCampagnes.setLayout(new BoxLayout(listeCampagnes, BoxLayout.Y_AXIS));
|
|
|
|
|
listeCampagnes.setBackground(new Color(45, 45, 45));
|
|
|
|
|
|
|
|
|
|
JLabel titre = new JLabel("CAMPAGNES");
|
|
|
|
|
titre.setForeground(Color.WHITE);
|
|
|
|
|
@@ -17,42 +24,74 @@ public class MenuCampagne extends JPanel {
|
|
|
|
|
JButton btnC1 = creerBouton("CAMPAGNE 1");
|
|
|
|
|
JButton btnC2 = creerBouton("CAMPAGNE 2");
|
|
|
|
|
JButton btnC3 = creerBouton("CAMPAGNE 3");
|
|
|
|
|
JButton btnC4 = creerBouton("CAMPAGNE 4");
|
|
|
|
|
|
|
|
|
|
JButton btnRetour = creerBouton("RETOUR");
|
|
|
|
|
|
|
|
|
|
btnC1.addActionListener(e -> System.out.println("Lancement Campagne 1..."));
|
|
|
|
|
listeCampagnes.add(Box.createVerticalGlue());
|
|
|
|
|
listeCampagnes.add(titre);
|
|
|
|
|
listeCampagnes.add(Box.createRigidArea(new Dimension(0, 40)));
|
|
|
|
|
|
|
|
|
|
btnC2.addActionListener(e -> {
|
|
|
|
|
CampagneAutoroute campagne = new CampagneAutoroute(jeu);
|
|
|
|
|
campagne.lancerNiveau1();
|
|
|
|
|
});
|
|
|
|
|
listeCampagnes.add(btnC1);
|
|
|
|
|
listeCampagnes.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
listeCampagnes.add(btnC2);
|
|
|
|
|
listeCampagnes.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
listeCampagnes.add(btnC3);
|
|
|
|
|
|
|
|
|
|
listeCampagnes.add(Box.createRigidArea(new Dimension(0, 30)));
|
|
|
|
|
listeCampagnes.add(btnRetour);
|
|
|
|
|
listeCampagnes.add(Box.createVerticalGlue());
|
|
|
|
|
|
|
|
|
|
// ---- Carte : sélection des niveaux ----
|
|
|
|
|
JPanel selectionNiveaux = new JPanel();
|
|
|
|
|
selectionNiveaux.setLayout(new BoxLayout(selectionNiveaux, BoxLayout.Y_AXIS));
|
|
|
|
|
selectionNiveaux.setBackground(new Color(45, 45, 45));
|
|
|
|
|
|
|
|
|
|
JLabel titreNiveaux = new JLabel("CHOISISSEZ UN NIVEAU");
|
|
|
|
|
titreNiveaux.setForeground(Color.WHITE);
|
|
|
|
|
titreNiveaux.setFont(new Font("SansSerif", Font.BOLD, 32));
|
|
|
|
|
titreNiveaux.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
|
|
|
|
|
|
|
|
JButton btnN1 = creerBouton("FACILE");
|
|
|
|
|
JButton btnN2 = creerBouton("MOYEN");
|
|
|
|
|
JButton btnN3 = creerBouton("DIFFICILE");
|
|
|
|
|
JButton btnRetourCampagnes = creerBouton("RETOUR AUX CAMPAGNES");
|
|
|
|
|
|
|
|
|
|
selectionNiveaux.add(Box.createVerticalGlue());
|
|
|
|
|
selectionNiveaux.add(titreNiveaux);
|
|
|
|
|
selectionNiveaux.add(Box.createRigidArea(new Dimension(0, 30)));
|
|
|
|
|
selectionNiveaux.add(btnN1);
|
|
|
|
|
selectionNiveaux.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
selectionNiveaux.add(btnN2);
|
|
|
|
|
selectionNiveaux.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
selectionNiveaux.add(btnN3);
|
|
|
|
|
selectionNiveaux.add(Box.createRigidArea(new Dimension(0, 30)));
|
|
|
|
|
selectionNiveaux.add(btnRetourCampagnes);
|
|
|
|
|
selectionNiveaux.add(Box.createVerticalGlue());
|
|
|
|
|
|
|
|
|
|
panneauCartes.add(listeCampagnes, "LISTE");
|
|
|
|
|
panneauCartes.add(selectionNiveaux, "NIVEAUX");
|
|
|
|
|
|
|
|
|
|
btnRetour.addActionListener(e -> jeu.afficherMenuPrincipal());
|
|
|
|
|
|
|
|
|
|
add(Box.createVerticalGlue());
|
|
|
|
|
add(titre);
|
|
|
|
|
add(Box.createRigidArea(new Dimension(0, 40)));
|
|
|
|
|
ActionListener ouvrirNiveaux = e -> cartes.show(panneauCartes, "NIVEAUX");
|
|
|
|
|
btnC1.addActionListener(ouvrirNiveaux);
|
|
|
|
|
btnC2.addActionListener(ouvrirNiveaux);
|
|
|
|
|
btnC3.addActionListener(ouvrirNiveaux);
|
|
|
|
|
btnC4.addActionListener(ouvrirNiveaux);
|
|
|
|
|
|
|
|
|
|
add(btnC1);
|
|
|
|
|
add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
add(btnC2);
|
|
|
|
|
add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
add(btnC3);
|
|
|
|
|
add(Box.createRigidArea(new Dimension(0, 10)));
|
|
|
|
|
add(btnC4);
|
|
|
|
|
btnRetourCampagnes.addActionListener(e -> cartes.show(panneauCartes, "LISTE"));
|
|
|
|
|
|
|
|
|
|
add(Box.createRigidArea(new Dimension(0, 30))); // Espace plus grand avant le retour
|
|
|
|
|
add(btnRetour);
|
|
|
|
|
btnN1.addActionListener(e -> jeu.lancerNiveau(1));
|
|
|
|
|
btnN2.addActionListener(e -> jeu.lancerNiveau(2));
|
|
|
|
|
btnN3.addActionListener(e -> jeu.lancerNiveau(3));
|
|
|
|
|
|
|
|
|
|
add(Box.createVerticalGlue());
|
|
|
|
|
add(panneauCartes, BorderLayout.CENTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JButton creerBouton(String texte) {
|
|
|
|
|
JButton b = new JButton(texte);
|
|
|
|
|
b.setFont(new Font("SansSerif", Font.PLAIN, 18)); // Légèrement plus petit si tu veux
|
|
|
|
|
b.setFont(new Font("SansSerif", Font.PLAIN, 18));
|
|
|
|
|
b.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
|
|
|
b.setMaximumSize(new Dimension(200, 45));
|
|
|
|
|
b.setMaximumSize(new Dimension(240, 45));
|
|
|
|
|
b.setFocusable(false);
|
|
|
|
|
return b;
|
|
|
|
|
}
|
|
|
|
|
|