package xyz.thastertyn.UserInterface.Dialogs;

import java.util.Arrays;

import com.googlecode.lanterna.gui2.Button;
import com.googlecode.lanterna.gui2.CheckBox;
import com.googlecode.lanterna.gui2.Direction;
import com.googlecode.lanterna.gui2.EmptySpace;
import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.LocalizedString;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.DialogWindow;


public class HelpDialog extends DialogWindow {

	CheckBox box = new CheckBox("Znovu nezobrazovat");

	public HelpDialog(boolean startupScreen)
	{
		super("Napoveda");

		Panel mainPanel = new Panel(new GridLayout(1)
				.setLeftMarginSize(1)
				.setRightMarginSize(1));

		new Panel(new LinearLayout(Direction.VERTICAL))
		.addComponent(new Label("- Pro pohyb mezi okny pouzij 'Tab' a 'Shift + Tab'."))
		.addComponent(new Label("- Pokud je pritomen posuvnik, pouzij sipky pro posun."))
		.addComponent(new Label("- Stiskni 'Space' pro specifikaci, napr skolniho roku, nebo pololeti."))
		.addComponent(new Label("- Stiskni 'Escape' pro odhlaseni, smazani udaju a konec."))
		.addComponent(new Label("- Nema smysl klikat mysi, vse je v terminalu."))
		.addComponent(new EmptySpace())
		.addComponent(new Label("Kdykoliv stiskni F1 pro zobrazeni tohoto okna."))
		.addTo(mainPanel);

		if(startupScreen)
		{
			mainPanel.addComponent(box);
		}

		new Panel()
			.addComponent(
				new Button(LocalizedString.OK.toString(), this::onOK)
					.setLayoutData(GridLayout.createLayoutData(
						GridLayout.Alignment.CENTER,
						GridLayout.Alignment.CENTER,
						true,
						false)))
				.addTo(mainPanel);

		setHints(Arrays.asList(Window.Hint.CENTERED));
		setComponent(mainPanel);
	}

	public void onOK()
	{
		close();
	}

	@Override
	public Boolean showDialog(WindowBasedTextGUI textGUI) {
		super.showDialog(textGUI);
		return box.isChecked();
	}
}
