package engine;

import javax.swing.*;
import java.awt.*;

import static engine.GraphicalInterface.f;

public class MenuPanel {

    private static boolean lancementpartie = false;
    private JButton button;



    public static void setLancementpartie(boolean lancementpartie) {
        MenuPanel.lancementpartie = lancementpartie;
    }

    private Panel gameMenu;

    public boolean isLancementpartie() {
        return lancementpartie;
    }

    public MenuPanel(){
        f=new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setLayout(new BorderLayout());
        f.setPreferredSize(new Dimension(jeu.Painter.getWidth(), jeu.Painter.getHeight()));

    }
    public void menudebut(){
        gameMenu = new Panel();
        button = new JButton("Nouvelle partie");
        gameMenu.add(button,BorderLayout.CENTER);

        f.getContentPane().add(gameMenu);
        f.pack();
        f.setVisible(true);
        f.getContentPane().setFocusable(true);
    }

    public void menufin(){
        gameMenu = new Panel(new FlowLayout(FlowLayout.CENTER));
        JLabel label = new JLabel("Game Over");
        label.setFont(new Font("Arial", Font.BOLD, 24));
        label.setForeground(Color.RED);
        gameMenu.add(label);
        f.getContentPane().add(gameMenu);
        f.pack();
        f.setVisible(true);
        f.getContentPane().setFocusable(true);
    }


    public void waitlancementpartie(){
        button.addActionListener(e -> lancementpartie = true);
    }
}
