/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package d.d;

import java.awt.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

/**
 *
 * @author pospis
 */
public class MainFrame extends JFrame{
    
    static final int Main = 1;
    static final int HeroesEditor = 2;
    static final int HeroesManagment = 3;
    static final int Battle = 4;
    static final int Creatures = 5;
    static final int Map = 6;
    
    JPanel panel;
    boolean isMenu=false;
    int width;
    int height;
    
    public MainFrame(){
        width = Toolkit.getDefaultToolkit().getScreenSize().width;
        height = Toolkit.getDefaultToolkit().getScreenSize().height;
        
    }
    
    public void initFrame(){
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        setMinimumSize(new Dimension(800,600));
        ChangePanel(Main);
        
    }
    
    public void ChangePanel(int type){
        try {
            if(isMenu)this.setJMenuBar(null);
            
            switch(type){
                case Main:  panel=new MainPanel(this);  
                            isMenu=false;
                            break;
                case Map:   
                            panel = new MapPanel(this);
                            isMenu=true;
                            break;
                case HeroesEditor:
                    
                            Hedit Hedit= new Hedit(this);
                            panel=Hedit.getPanel();
                            isMenu=false;
                            break;
                case HeroesManagment:
                    
                            HManagment HManagment= new HManagment(this);
                            panel=HManagment.getPanel();
                            isMenu=true;
                            break;
                case Battle:
                        Battle battle = new Battle(this);
                        panel = battle.getPanel();
                        isMenu=true;
                        break;
                    
                case Creatures:
                        Creature creature = new Creature(this);
                        panel=creature.getPanel();
                    isMenu=true;
                    break;
                            
            }
                getContentPane().removeAll();        
                getContentPane().add(panel);
                repaint();
                setVisible(true);
                
        } catch (FileNotFoundException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
         
    
    @Override
    public int getWidth(){
        return width;
    }
    @Override
    public int getHeight(){
        return height;
    }
    
    
}
