package vue;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.io.File;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import controleur.GLOBAL;
import modele.Mur;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

public class Arene extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField textField;
	private JPanel jpnMur;
	public JPanel jpnJeu;

	/**
	 * Launch the application.
	 */

	/**
	 * Create the frame.
	 */
	public Arene() {
		setTitle("Arene");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setPreferredSize(new Dimension(800, 729));
		this.pack();
		this.setResizable(false);
		setBounds(100, 100, 808, 757);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("");
		String chemin = GLOBAL.cheminFonds + "fondarene.jpg";
		URL ressourceURL = getClass().getClassLoader().getResource(chemin);

		if (ressourceURL != null) {
		    String ressource = URLDecoder.decode(ressourceURL.getPath(), StandardCharsets.UTF_8);
		    lblNewLabel.setIcon(new ImageIcon(ressource));
		} else {
		    System.out.println("❌ Image non trouvée !");
		}
		
		jpnJeu = new JPanel();
		jpnJeu.setBounds(0, 0, 800, 590);
		contentPane.add(jpnJeu);
		jpnJeu.setOpaque(false);
		jpnJeu.setLayout(null);
		
		jpnMur = new JPanel();
		jpnMur.setOpaque(false);
		jpnMur.setBounds(0, 0, 800, 590);
		contentPane.add(jpnMur);
		jpnMur.setLayout(null);

		

		
		lblNewLabel.setBounds(0, 0, 792, 590);
		contentPane.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setBounds(0, 591, 800, 30);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setBounds(0, 620, 800, 98);
		contentPane.add(scrollPane);
		
		JTextArea textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
	}
	public void ajoutMurs(Object portougal) {
		jpnMur.add((JLabel)portougal);
		jpnMur.repaint();
	}
	public JPanel jpnMurs() {
		return jpnMur;
	}
	
	public void setJpnMurs(JPanel jpnMurs) {
		this.jpnMur.add(jpnMurs);
		this.jpnMur.repaint();
	}
	
	public void ajoutLabelJeu(JLabel object) {
		this.jpnJeu.add(object);
		this.jpnJeu.repaint();
	}
	
	public JPanel getJpnJeu() {
		return jpnJeu;
	}
	
	public void setJpnJeu(JPanel jpnJeu) {
		this.jpnJeu.removeAll();
		this.jpnJeu.add(jpnJeu);
		this.jpnJeu.repaint();
	}
}
