package jatek0001;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import customize.Custom;


import jatek.JatekPanel;

public class Jatek0001Panel extends JatekPanel {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8466616319395899266L;
	protected JPanel inputPanel=new JPanel();
	protected JPanel outputPanel=new JPanel();
	protected JScrollPane js;
	
	protected JLabel description = new JLabel("");
	protected JLabel gameInputContent = new JLabel("");
	protected JLabel gameResults=new JLabel("");
	
	public Jatek0001Panel(){
		super();
		this.setLayout(new FlowLayout());

		//inputPanel tartalma
	    Box box = Box.createVerticalBox();
	    box.setPreferredSize(new Dimension(550,500));	    
        JLabel gameDescription=new JLabel("<html><p>Inputok</p><p>A játék leírása</p>");
        JLabel gameInput=new JLabel("A játék inputja");
        gameDescription.setForeground(Color.decode(Custom.getBaseTextColor()));
        gameInput.setForeground(Color.decode(Custom.getBaseTextColor()));
        box.add(gameDescription);     
        box.add(Box.createVerticalStrut(10));
        box.add(description);
        description.setForeground(Color.decode(Custom.getBaseTextColor()));
        box.add(Box.createVerticalStrut(10));
        box.add(gameInput);
        box.add(Box.createVerticalStrut(10));
        box.add(gameInputContent);
        gameInputContent.setForeground(Color.decode(Custom.getBaseTextColor()));
	    inputPanel.add(box);
	    inputPanel.setBorder(BorderFactory.createLineBorder(Color.decode(Custom.getBorderColor()),Custom.getBorderThickness()));

	    //outputPanel tartalma
	    Box box2 = Box.createVerticalBox();
	    box2.setPreferredSize(new Dimension(550,500));
        gameResults=new JLabel("A számított eredmények");
        js=new JScrollPane(gameResults);
        box2.add(js);
        box2.add(Box.createVerticalStrut(10));
        outputPanel.add(box2);
        outputPanel.setBorder(BorderFactory.createLineBorder(Color.decode(Custom.getBorderColor()),Custom.getBorderThickness()));
        gameResults.setForeground(Color.decode(Custom.getBaseTextColor()));
        
	    this.add(inputPanel);
	    this.add(outputPanel);
	    setPanel("input");
	}

	/**
	 * Egy JoptionPane-t jelenítünk meg, adott szöveggel. A paraméter az
	 * üzenet típusára vonatkozik.
	 * @param messageType String
	 */
	public void showMessage(String messageType){
		if("loaded".equals(messageType)){
			JOptionPane.showMessageDialog(this,"Sikeres betöltés. Kattintson az OK gombra!",
		         "Betöltés",JOptionPane.INFORMATION_MESSAGE);
		}else if("toExcelProblem".equals(messageType)){
			JOptionPane.showMessageDialog(this,"Az eredményeket addig nem lehet elmenteni, amíg a játék véget nem ért!",
			         "Figyelmeztetés",JOptionPane.WARNING_MESSAGE);
		}else if("notValid".equals(messageType)){
			JOptionPane.showMessageDialog(this,"Hibás formátumú fájl!",
			         "Hiba",JOptionPane.ERROR_MESSAGE);
		}
	}
	
	public JPanel getOutputPanel() {
		return outputPanel;
	}

	public void setOutputPanel(JPanel outputPanel) {
		this.outputPanel = outputPanel;
	}

	public JLabel getGameResults() {
		return gameResults;
	}

	public void setGameResults(JLabel gameResults) {
		this.gameResults = gameResults;
	}
	
	public JLabel getDescription() {
		return description;
	}

	public void setDescription(JLabel description) {
		this.description = description;
	}

	public JLabel getGameInputContent() {
		return gameInputContent;
	}

	public void setGameInputContent(JLabel gameInputContent) {
		this.gameInputContent = gameInputContent;
	}
	
	@Override
	public void setPanel(String s){
		if(s.equals("input")) {
			//true
			inputPanel.setVisible(true);
			//false
			outputPanel.setVisible(false);
			js.setVisible(false);
		}
		else if(s.equals("output")) {
			//true
			outputPanel.setVisible(true);
			js.setVisible(true);
			//false
			inputPanel.setVisible(false);
		}
	}
	
}
