package de.stoermer.xxx.client;

import java.awt.Dimension;

import javax.swing.JFrame;

import de.stoermer.xxx.domain.Session;
import de.stoermer.xxx.domain.xml.XmlAufgabenProvider;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private XmlAufgabenProvider provider;

	public MainFrame(XmlAufgabenProvider provider) {
		this.provider = provider;
		this.setTitle("XXX-Game");
		this.setPreferredSize(new Dimension(800, 600));
		StartupPanel contentPane = new StartupPanel(this, provider);
		contentPane.init();
		this.setContentPane(contentPane);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setVisible(true);
		this.pack();
		this.setLocationRelativeTo(null);
	}
	
	public void hauptMenu() {
		StartupPanel contentPane = new StartupPanel(this, provider);
		contentPane.init();
		this.setContentPane(contentPane);
		revalidate();
	}
	
	public void startGame(Session session) {
		IngamePanel ingamePanel = new IngamePanel(this, session);
		ingamePanel.init();
		this.setContentPane(ingamePanel);
		revalidate();
	}
	
	public static void main(String[] args) {
		XmlAufgabenProvider provider = new XmlAufgabenProvider();
		provider.initSchablonen();
		new MainFrame(provider);
	}
}
