/**
 * 
 */
package gui;

import java.awt.BorderLayout;
import java.awt.Color;

import gui.Boutton;
import modeles.Labyrinthe;
import modeles.Marche;
import modeles.Menu;
import modeles.Objet;
import modeles.Personnage;
import gui.Background;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GraphicsConfiguration;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.attribute.AclEntry.Builder;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.eclipse.swt.SWT;

/**
 * @author nicolas
 *
 */
public class jeu extends JFrame implements ActionListener {
	JButton continuer =new JButton("Continuer");
	JButton nouvelle = new JButton("Nouvelle Partie");
	public JeuSalle salle; 
	public JPanel panel;
	public jeu() throws IOException {
		super();
		build();
	}

	public void build() throws IOException{
		setTitle("Jeu"); 
		setSize(593,283); 
		setLocationRelativeTo(null); 
		setResizable(false); 
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	
		JLabel container = new JLabel(new ImageIcon(this.image()));
		
	
		container.setLayout(new GridBagLayout());
	
	
		nouvelle.addActionListener(this);
		continuer.addActionListener(this);
		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 0;
		container.add(nouvelle);
		
		c.gridx = 1;
		c.gridy=0;
		container.add(continuer);
		
		this.setContentPane(container);
		this.setVisible(true);
		
	}
	public void buildContentPane() {
		
		
	}
	public BufferedImage image() throws IOException {
		BufferedImage image = ImageIO.read(new File("/home/nicolas/eclipse-workspace/Projet_Java/JAVA/PROJET-PMT_STRI1A/test.jpg"));
		return image;
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	
	public void actionPerformed(ActionEvent arg0) {
		Object source=arg0.getSource();
		choix(source);
		if(source==nouvelle) {
		//JPanel panel = new JPanel();
		Menu menu = new Menu();
		Labyrinthe lab=menu.nouvellePartie();
		JeuSalle salle = new JeuSalle();
		Marche marche= (Marche) lab.listePorte.get(0).getSalle1();
		panel =salle.ecrire(marche.creerObjetsAVendre(lab));
		repaint();
		//Bug
		//Personnage perso = menu.menuSelection(lab);
		//System.out.println();
		panel =salle.ecrire(menu.textePerso(lab));
		//salle.cacher(panel);
		//menu.menuSelection(lab);
		
		}
		if(source==continuer) {
			Menu menu = new Menu();
			Labyrinthe lab = menu.continuer();
		}
	}
	public Labyrinthe choix(Object source) {
		if(source==nouvelle) {
			Menu menu = new Menu();
			Labyrinthe lab=menu.nouvellePartie();
			return lab;
		}
		if(source==nouvelle) {
			Menu menu = new Menu();
			Labyrinthe lab = menu.continuer();
			return lab;
		}
		return null;
		
	}
	
	}

	