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


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author pospis
 */
public class MainPanel extends JPanel{
    
    static final int Main = 1;
    static final int Map = 6;
    static final int HeroesEditor = 2;
    static final int HeroesManagment = 3;
    static final int Battle = 4;
    static final int Creatures = 5;
    
    MainFrame frame;
    
    int width;
    int height;
    
    
    
        public MainPanel(MainFrame frame){
            
            this.frame=frame;
            Main();
        }
        
        private void Main(){
            width=frame.getWidth();
            height=frame.getHeight();
            
            BoxLayout layout = new BoxLayout(this,BoxLayout.Y_AXIS);
            this.setAlignmentX(CENTER_ALIGNMENT);
            setLayout(layout);
            setBackground(Color.red);
                        
            JButton button1 = new JButton("Map Editor");
            JButton button2 = new JButton("Heroes Editor");
            JButton button3 = new JButton("Heroes Managment");
            JButton button4 = new JButton("Battle");
            JButton button5 = new JButton("Exit");
            JButton button6 = new JButton("Creatures Editor");
            
            button1.setMaximumSize(new Dimension(width/8, height/25));
            button2.setMaximumSize(new Dimension(width/8, height/25));
            button3.setMaximumSize(new Dimension(width/8, height/25));
            button4.setMaximumSize(new Dimension(width/8, height/25));
            button5.setMaximumSize(new Dimension(width/8, height/25));
            button6.setMaximumSize(new Dimension(width/8, height/25));
            
            button1.setAlignmentX(CENTER_ALIGNMENT);
            button2.setAlignmentX(CENTER_ALIGNMENT);
            button3.setAlignmentX(CENTER_ALIGNMENT);
            button4.setAlignmentX(CENTER_ALIGNMENT);
            button5.setAlignmentX(CENTER_ALIGNMENT);
            button6.setAlignmentX(CENTER_ALIGNMENT);
            
            add(Box.createRigidArea(new Dimension(0,100)));
            add(button1);
            add(Box.createRigidArea(new Dimension(0,50)));
            add(button2);
            add(Box.createRigidArea(new Dimension(0,50)));
            add(button3);
            add(Box.createRigidArea(new Dimension(0,50)));
            add(button4);
            add(Box.createRigidArea(new Dimension(0,50)));
            add(button6);
            add(Box.createRigidArea(new Dimension(0,50)));
            add(button5);
                        
            button1.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    frame.ChangePanel(Map);
                }
            });
            
            button5.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    System.exit(0);
                }
            });
            
            button2.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    frame.ChangePanel(HeroesEditor);
                }
            });
            button3.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    frame.ChangePanel(HeroesManagment);
                }
            });
            button4.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    frame.ChangePanel(Battle);
                }
            });
            
            button6.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                frame.ChangePanel(Creatures);
            }
        });
            

        }
        
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(new ImageIcon("resources/wall.jpg").getImage(),0,0, this.getWidth(), this.getHeight(), null);
        }
        
    } 
