package de.jaujau.gui;


import javax.swing.JFrame;
import javax.swing.JPanel;
import de.jaujau.daten.Spielerverwaltung;
import de.jaujau.daten.Texturenpakete;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;



/**
 * Class GUI
 */
public class GUI extends JFrame{

  //
  // Fields
  //
	private static final long serialVersionUID = 1L;
	private Spielerverwaltung spielerverwaltung;
	private boolean menuehidden = false;
	Hilfe_GUI frame = new Hilfe_GUI();
	
  
  //
  // Constructors
  //
  public GUI (Spielerverwaltung speicherung) {
  	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  		setTitle("JauJau");
  		setPreferredSize(new Dimension(800, 500));
  		setSize(982, 642);
		this.spielerverwaltung = speicherung;
		getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel Menue = new JPanel();
		Menue.setPreferredSize(new Dimension(270, 450));
		getContentPane().add(Menue, BorderLayout.WEST);
		Menue.setLayout(new BoxLayout(Menue, BoxLayout.X_AXIS));
		
		JPanel MenueIcon = new JPanel();
		MenueIcon.setPreferredSize(new Dimension(50, 450));
		MenueIcon.setBackground(new Color(15, 19, 52));
		Menue.add(MenueIcon);
		MenueIcon.setLayout(null);
		
		JPanel help = new JPanel();
		help.setBounds(0, 0, 50, 50);
		help.setBackground(new Color(15, 19, 52));
		MenueIcon.add(help);
		
		JLabel helplable = new JLabel("");
		helplable.setHorizontalTextPosition(SwingConstants.CENTER);
		helplable.setHorizontalAlignment(SwingConstants.CENTER);
		helplable.setIcon(new ImageIcon(GUI.class.getResource("/img/help.png")));
		help.add(helplable);
		
		JPanel menuebtn = new JPanel();
		menuebtn.setBounds(0, 50, 50, 50);
		MenueIcon.add(menuebtn);
		menuebtn.setLayout(new BorderLayout(0, 0));
		
		JLabel menuelabel = new JLabel("");
		menuelabel.setHorizontalTextPosition(SwingConstants.CENTER);
		menuelabel.setHorizontalAlignment(SwingConstants.CENTER);
		menuelabel.setIcon(new ImageIcon(GUI.class.getResource("/img/menue.png")));
		menuebtn.add(menuelabel);
		menuebtn.setBackground(new Color(15, 19, 52));
		
		JPanel menuhide = new JPanel();
		menuhide.setPreferredSize(new Dimension(220, 200));
		menuhide.setBackground(new Color(25, 29, 74));
		Menue.add(menuhide);
		menuhide.setLayout(new BorderLayout(0, 0));
		
		JPanel dashboard = new JPanel();
		dashboard.setBackground(new Color(73, 128, 242));
		getContentPane().add(dashboard, BorderLayout.CENTER);
		dashboard.setLayout(new BorderLayout(0, 0));
		
		Spiel_GUI Spiel_GUI = new Spiel_GUI();
		dashboard.add(Spiel_GUI);
	  
		
		menuebtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if(menuehidden == true) {
					menuhide.setVisible(false);
					Menue.setPreferredSize(new Dimension(50, Menue.getHeight()));
					menuehidden = false;
				}else{
					menuhide.setVisible(true);
					Menue.setPreferredSize(new Dimension(270, Menue.getHeight()));
					menuehidden = true;
				}
				
			}
		});
		
		
		help.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if(frame.isShowing() == true) {
					frame.setVisible(false);
				}else{
					frame.setVisible(true);
				}
				
			}
		});
		
  }
  
  //
  // Methods
  //

  
}
