package de.jaujau.gui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;

import javax.swing.BoxLayout;
import java.awt.Component;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;

import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;


public class Navigation_GUI
extends JPanel
implements ActionListener {
	private JPanel panel;
	private Menue_GUI Menue_GUI;
	
	// Konstruktor
	public Navigation_GUI(Menue_GUI menue_GUI) {
		this.Menue_GUI = menue_GUI;
		
		// Hiermit bekommst du Zugriff auf das übergebene Objekt mainPanel
		setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
		
		panel = new JPanel();
		panel.setBackground(new Color(102, 153, 204));
		add(panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_side = new JPanel();
		panel_side.setBackground(new Color(100, 149, 237));
		panel_side.setPreferredSize(new Dimension(200, 400));
		panel.add(panel_side, BorderLayout.CENTER);
		panel_side.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_buttons = new JPanel();
		panel_buttons.setBackground(new Color(0, 0, 128));
		panel_buttons.setPreferredSize(new Dimension(50, 200));
		panel_side.add(panel_buttons, BorderLayout.WEST);
		panel_buttons.setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();

		panel.setBackground(new Color(0, 0, 153));
		panel.setPreferredSize(new Dimension(50, 50));
		panel_buttons.add(panel, BorderLayout.NORTH);
		panel.setLayout(new BorderLayout(0, 0));
		

		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setPreferredSize(new Dimension(50, 50));
		lblNewLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
		lblNewLabel.setHorizontalTextPosition(SwingConstants.CENTER);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		ImageIcon imageIcon = new ImageIcon(new ImageIcon("C:\\Users\\Elmar\\Pictures\\exit.png").getImage().getScaledInstance(40, 40, Image.SCALE_DEFAULT));
		lblNewLabel.setIcon(imageIcon);
		panel.add(lblNewLabel, BorderLayout.CENTER);
		
		JPanel panel_1 = new JPanel();
		panel_side.add(panel_1, BorderLayout.CENTER);
		
		JPanel panel_2 = new JPanel();
		panel_2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Menue_GUI.showPanel("Start");
			}
		});
		panel_2.setBackground(new Color(0, 102, 204));
		
		JLabel lblNewLabel_1 = new JLabel("Start");
		lblNewLabel_1.setBackground(new Color(0, 102, 204));
		lblNewLabel_1.setForeground(Color.WHITE);
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
		panel_2.add(lblNewLabel_1);
		
		JLabel label = new JLabel("");
		
		JPanel panel_3 = new JPanel();
		panel_3.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Menue_GUI.showPanel("Highscore");
			}
		});
		panel_3.setBackground(new Color(0, 102, 204));
		
		JLabel lblNewLabel_2 = new JLabel("Highscore");
		lblNewLabel_2.setForeground(new Color(255, 255, 255));
		lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
		panel_3.add(lblNewLabel_2);
		panel_1.setLayout(new GridLayout(0, 1, 0, 0));
		panel_1.add(panel_2);
		
		JLabel label_1 = new JLabel("");
		panel_1.add(label_1);
		
		JLabel label_2 = new JLabel("");
		panel_1.add(label_2);
		panel_1.add(label);
		panel_1.add(panel_3);

		
		//Schließe Button Panel
		panel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_1.setVisible(false);
			}
		});
	}

	// In dieser Methode änderst du das anzuzeigende Panel
	// über die showPanel-Methode in mainPanel
	public void actionPerformed(ActionEvent e) {
			
		
		if(e.getActionCommand().equals("Highscore"))
			Menue_GUI.showPanel("Highscore");
		
		if(e.getActionCommand().equals("Spiel"))
			Menue_GUI.showPanel("Spiel");
		
		if(e.getActionCommand().equals("Einstellungen"))
			Menue_GUI.showPanel("Einstellungen");
	}
}