//
// Core Program for TETDM
// ChapterPanel Version 1.00
// Copyright(C) 2017-2018 TETDM CORE MEMBER ALL RIGHTS RESERVED.
// This program is provided under the license.
//

package source.Tutorial;


import source.*;
import source.TextData.*;
import source.Utility.*;
import source.GameMode.*;

import java.io.File;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.GroupLayout.Alignment;



public class ChapterPanel extends JPanel implements ActionListener
{
    //ExpPanel exppanel;
    
    JPanel allTopPanel;
    JPanel middlePanel;
    
    JPanel checkPanel;
    JPanel labelPanel;
    
    //Top
    JLabel message;
    
    //Middle
    JScrollPane scroll[];
    
    JPanel checkBoxPanel;
    


    //Buttom
    JButton button[];
    int buttonNumber[] = new int[13];
//    int buttonNumber[] = {0, 13,9,13,  10,3,7,  9,11,10,  7,18,10};

    int verticalNumber;
    boolean autoSet = false;
    
    int fontsize = 16;
    
    JButton button0;//Button for Chapter0
    
    String menuInJapanese[];
    
    ImageIcon Icon[];
    ImageIcon smallIcon[];
    Image smallImg;
    
    Control control;
    int number;
    
    StoryControl storyControl;
    int flag = 0;
    
    String clearChecker[];
    int clearChecker2[];
    
    ChapterPanel(Control control, int number)
    {
        setLayout(new BorderLayout());
        this.control = control;
        this.number = number;
        
        int number1 = 0;
        if(number == 1)
            number1 = 1;
        
        for(int i=0;i<13;i++)
        {
            if(i == 0)
                buttonNumber[i] = 0;
            else if(i == 1)
                buttonNumber[i] = StoryControl.subMissionNumber[i] + 2;
            else
                buttonNumber[i] = StoryControl.subMissionNumber[i] + 1;
        }

        button = new JButton[buttonNumber[number]];

        
        clearChecker2 = new int[StoryControl.subMissionNumber[number]];
        
        if(number%3 == 1)
        {
            clearChecker = FILEIO.TextFileAllReadCodeArray(new File(control.absolutePath + "source" + File.separator + "Tutorial" + File.separator + "serif" + File.separator+ "ClearCheckOperation.txt"));
            clearChecker2[0] = Integer.parseInt(clearChecker[(int)(number/3)]);
        }
        
        if(number%3 == 2)
        {
            clearChecker = FILEIO.TextFileAllReadCodeArray(new File(control.absolutePath + "source" + File.separator + "Tutorial" + File.separator + "serif" + File.separator+ "ClearCheckTool.txt"));
            String clearChecker2Temp[] = clearChecker[(int)(number/3)].split(",");
            for(int i=0;i<StoryControl.subMissionNumber[number];i++)
                clearChecker2[i] = Integer.parseInt(clearChecker2Temp[i]);
        }

        if(number%3 == 0)
        {
            clearChecker = FILEIO.TextFileAllReadCodeArray(new File(control.absolutePath + "source" + File.separator + "Tutorial" + File.separator + "serif" + File.separator+ "ClearCheckMining.txt"));
            clearChecker2[0] = Integer.parseInt(clearChecker[(int)(number/3)-1]);
        }
        
        
        


        
        menuInJapanese = FILEIO.TextFileAllReadCodeArray(new File(control.absolutePath + "source" + File.separator + "Tutorial" + File.separator+ "Chapter"+number+".txt"));
        
        //ALL
        allTopPanel = new JPanel();
        allTopPanel.setBackground(Color.blue);
        add(allTopPanel, BorderLayout.NORTH);
        
        message = new JLabel();
        message.setFont(new Font(control.sp1.fontName, Font.BOLD, fontsize+2));
        message.setForeground(Color.white);
        
        setTitleNames();
        allTopPanel.add(message);
        
        
        
        
        //MIDDLE
        middlePanel = new JPanel();
        middlePanel.setLayout(new GridLayout(1,1));
        add(middlePanel);
        scroll = new JScrollPane[2];
        
        //MIDDLE-INSIDE
        
        if(number % 3 == 2)
        {
            verticalNumber = buttonNumber[number];
        }
        else
        {
            verticalNumber = clearChecker2[0]+2+number1;

            if(verticalNumber > buttonNumber[number])
                verticalNumber = buttonNumber[number];
        }
        
        checkPanel = new JPanel(new GridLayout(verticalNumber,1));
        checkPanel.setBackground(Color.blue);
        
        labelPanel = new JPanel(new GridLayout(verticalNumber,1));
        labelPanel.setBackground(Color.green);

        
        int iconSize = 50;
        String imagePath = control.absolutePath+"source"+ File.separator + "Tutorial" +File.separator+"image"+File.separator;

        Icon = new ImageIcon[buttonNumber[number]-1-number1];
        smallIcon = new ImageIcon[buttonNumber[number]-1-number1];
        
        if(number % 3 == 2)
        {
            for(int i=0;i<verticalNumber-1;i++)
            {
                if(clearChecker2[i] == 1)
                    Icon[i] = new ImageIcon(imagePath +"clear.png");
                else
                    Icon[i] = new ImageIcon(imagePath +"notclear.png");
                
                smallImg = Icon[i].getImage().getScaledInstance(iconSize, iconSize, Image.SCALE_SMOOTH);
                smallIcon[i] = new ImageIcon(smallImg);
                
                button[i] = new JButton("",smallIcon[i]);
                button[i].setBackground(Color.white);
                
                if(number % 3 == 2)
                    button[i].setText("   "+StoryControl.moduleNameInJapanese[(int)(number/3)][i]);
                else
                    button[i].setText("   "+menuInJapanese[i+1]);

                button[i].addActionListener(this);
            }
        }
        else
        {
            for(int i=0; i < verticalNumber-1-number1;i++)
            {
                if(i < clearChecker2[0])
                    Icon[i] = new ImageIcon(imagePath +"clear.png");
                else
                    Icon[i] = new ImageIcon(imagePath +"notclear.png");
                
                smallImg = Icon[i].getImage().getScaledInstance(iconSize, iconSize, Image.SCALE_SMOOTH);
                smallIcon[i] = new ImageIcon(smallImg);
                
                button[i] = new JButton("",smallIcon[i]);
                button[i].setBackground(Color.white);
                button[i].setText("   "+i+":"+menuInJapanese[i+1]);
                button[i].addActionListener(this);
            }
        }
        
        button0 = new JButton();
        if(number==1)        //chapter0 button
        {
            button0.setBackground(Color.white);
            button0.setText(menuInJapanese[buttonNumber[number]-1]);
            button0.addActionListener(this);
        }
        
        //back button
        button[verticalNumber-1] = new JButton();
        button[verticalNumber-1].setBackground(Color.white);
        if(number % 3 == 2)
            button[verticalNumber-1].setText(menuInJapanese[1]);
        else
            button[verticalNumber-1].setText(menuInJapanese[buttonNumber[number]]);
        button[verticalNumber-1].addActionListener(this);
        
        if(number % 3 == 2)
            for(int i=0;i<verticalNumber-1;i++)
                labelPanel.add(button[i]);      //mission button
        else
            for(int i=verticalNumber-2-number1;i>=0;i--)
                labelPanel.add(button[i]);      //mission button
        
        if(number==1)
            labelPanel.add(button0);                     //chapter0 button

        labelPanel.add(button[verticalNumber-1]);     //back button
        
        
        checkBoxPanel = new JPanel(new BorderLayout());
        checkBoxPanel.setBackground(Color.green);
        checkBoxPanel.add(labelPanel);
        checkBoxPanel.add(checkPanel, BorderLayout.WEST);
        
        scroll[0] = new JScrollPane(checkBoxPanel);
        middlePanel.add(scroll[0]);

    }

    public void setTitleNames()
    {
        if(control.sp1.inJapanese)
            message.setText(menuInJapanese[0]);
        else
        {
            if(number >= 1 && number <= 3)
                message.setText("Super Light Mode");
            if(number >= 4 && number <= 6)
                message.setText("Light Mode");
            if(number >= 7 && number <= 9)
                message.setText("Normal Mode");
            if(number >= 10 && number <= 12)
                message.setText("Advanced Mode");
        }
    }
    
    
    public void componentWindowClose(Component c)
    {
        Window w = SwingUtilities.getWindowAncestor(c);
        w.dispose();
    }
    
    int backStory[] = {0,3,3,4,5,5,4,6,6,4,7,7,4};
    
    //Action listener
    public void actionPerformed(ActionEvent e)
    {
        if(autoSet == true)
            return;
        
        if(flag==1)
            StoryControl.CloseAllSmallChapterWindow();
        
        StoryControl.SelectMode = number;
        StoryControl.fromModule = false;        
        
        if(e.getSource() == button[verticalNumber-1])       //back button
        {
            StoryControl.PopPanel(control, backStory[number]);
            componentWindowClose((Component)e.getSource());
        }

        control.last_original_file = control.text.sourceFilename.substring(0, control.text.sourceFilename.length()-1);
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>BACKUP CURRENT TEXT = "+control.last_original_file);
        
        if(number == 1)
        {
            if(e.getSource() == button0)        //chapter 0
            {
                storyControl.ImagePop(control, 1);
                componentWindowClose((Component)e.getSource());
            }
            
            for(int i=0; i < verticalNumber-2;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"SL",1,i+1);

                    int mining[]={40,19,1};
                    int visual[]={3,3,1};
                    int text[]={0,0,0};
                    int size[]={1,2,2};
                    control.panelSet(mining,visual,text,size);
                    
                    if(i==9)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"SegmentPractice.txt");
                    else
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");

                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 4)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"L",4,i+1);

                    int mining[]={40,19,1};
                    int visual[]={3,3,1};
                    int text[]={0,0,0};
                    int size[]={1,2,2};
                    control.panelSet(mining,visual,text,size);
                    
                    
                    if(i==9)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"pra1.txt");
                    else if(i==5)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                    else if(i==6)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"pra2.txt");
                    else if(i==7)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"pra3.txt");
                    else
                       control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 7)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"N",7,i+1);
                    
                    int mining[]={40,19,1};
                    int visual[]={3,3,1};
                    int text[]={0,0,0};
                    int size[]={1,2,2};
                    control.panelSet(mining,visual,text,size);
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 10)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"A",10,i+1);
                    
                    int mining[]={40,19,1};
                    int visual[]={3,3,1};
                    int text[]={0,0,0};
                    int size[]={1,2,2};
                    control.panelSet(mining,visual,text,size);
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        
        if(number % 3 == 2)
        {
            String mode[] = {"SL2","L2","N2","A2"};
            
            
            int buttonCheck = -1;
            for(int i=0;i<verticalNumber-1;i++)
            {
                if(e.getSource() == button[i] )
                    buttonCheck = i;
            }

            if(buttonCheck >= 0)
            {
                storyControl = new StoryControl(control, mode[(int)(number/3)], number, buttonCheck+1);
                
                int mining[]={control.readModuleData.moduleIDs[StoryControl.moduleTutorialIndex[(int)(number/3)][buttonCheck]]};
                int visual[]={0};
                int text[]={0};
                int size[]={1};
                
                control.panelSet(mining,visual,text,size);
                

                
                MiningModule min = control.getPanel0Mining();
                
                control.panelSet(min.defaultSetPanelModuleID, min.defaultSetPanelVisualizationID, min.defaultSetPanelTextID, min.defaultBalancedPanelSizeX);
            
//                if(number == 8)
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                
                storyControl.SerifControl(0, true);
                componentWindowClose((Component)e.getSource());
                /*
                int m0[] = {40,19,1};
                int v0[] = {3,3,1};
                int t0[] = {1,1,1};
                int s0[] = {1,2,2};
                control.panelSet(m0,m0,t0,s0);
                 */
            }
        }
        /*
        if(number == 2)
        {

            
            if(buttonCheck >= 0)
            {
                storyControl = new StoryControl(control,"SL2",2,buttonCheck+1);

                switch(buttonCheck)
                {
                    case 0:{
                        int mining[]={40,19,1};
                        int visual[]={3,3,1};
                        int text[]={0,0,0};
                        int size[]={1,2,2};
                        control.panelSet(mining,visual,text,size);
                        break;}

         

         



                }
                control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                storyControl.SerifControl(0, true);
                componentWindowClose((Component)e.getSource());
         
         
         case 3:{
         int mining[]={40,5};
         int visual[]={3,2};
         int text[]={0,0};
         int size[]={1,2};
         control.panelSet(mining,visual,text,size);
         break;}
         case 4:{
         int mining[]={40,13};
         int visual[]={3,12};
         int text[]={0,0};
         int size[]={1,2};
         control.panelSet(mining,visual,text,size);
         break;}
         case 5:{
         int mining[]={40,2,2};
         int visual[]={3,3,5};
         int text[]={0,0,0};
         int size[]={1,2,2};
         control.panelSet(mining,visual,text,size);
         break;}
         case 6:{
         int mining[]={40,16};
         int visual[]={3,3};
         int text[]={0,0};
         int size[]={1,2};
         control.panelSet(mining,visual,text,size);
         break;}
         case 7:{
         int mining[]={40,26,26};
         int visual[]={3,3,2};
         int text[]={0,0,0};
         int size[]={1,2,2};
         control.panelSet(mining,visual,text,size);
         break;}
         case 2:{
         int mining[]={40,12,12,12};
         int visual[]={3,2,4,1102};
         int text[]={0,0,0,0};
         int size[]={1,3,3,3};
         control.panelSet(mining,visual,text,size);
         break;}
         case 1:{
         int mining[]={40,11,11};
         int visual[]={3,1,8};
         int text[]={0,0,0};
         int size[]={1,2,2};
         control.panelSet(mining,visual,text,size);
         break;}
         
            }
        }
        if(number == 5)
        {

         
            if(buttonCheck >= 0)
            {
                storyControl = new StoryControl(control,"L2",5,buttonCheck+1);

                int mining[]={control.readModuleData.moduleIDs[StoryControl.moduleTutorialIndex[(int)(number/3)][buttonCheck]]};
                int visual[]={0};
                int text[]={0};
                int size[]={1};
                
                control.panelSet(mining,visual,text,size);
                
                MiningModule min = control.getPanel0Mining();
                
                control.panelSet(min.defaultSetPanelModuleID, min.defaultSetPanelVisualizationID, min.defaultSetPanelTextID, min.defaultBalancedPanelSizeX);
                
         
                switch(buttonCheck)
                {
                    case 0:{
                        int mining[]={28,29,0};
                        int visual[]={3,3,1102};
                        int text[]={0,0,0};
                        int size[]={1,1,1};
                        control.panelSet(mining,visual,text,size);
                        break;}
                    case 1:{
                        int mining[]={20003,20001,0};
                        int visual[]={0,20001,17};
                        int text[]={0,0,0};
                        int size[]={1,4,4};
                        control.panelSet(mining,visual,text,size);
                        break;}
                }
         
                
                control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                storyControl.SerifControl(0, true);
                componentWindowClose((Component)e.getSource());
            }
        }
        if(number == 8)
        {

            
            if(buttonCheck >= 0)
            {
                storyControl = new StoryControl(control,"N2",8,buttonCheck+1);
                
                switch(buttonCheck)
                {








                    case 9:{
                        int mining[]={14};
                        int visual[]={14};
                        int text[]={0};
                        int size[]={1};
                        control.panelSet(mining,visual,text,size);
                        break;}
         
         
         
         
         case 0:{
         int mining[]={35,35};
         int visual[]={24,4};
         int text[]={0,0};
         int size[]={1,1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 1:{
         int mining[]={37,37};
         int visual[]={24,4};
         int text[]={0,0};
         int size[]={1,1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 2:{
         int mining[]={36,36};
         int visual[]={24,4};
         int text[]={0,0};
         int size[]={1,1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 3:{
         int mining[]={21};
         int visual[]={15};
         int text[]={0};
         int size[]={1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 4:{
         int mining[]={10,10};
         int visual[]={1,7};
         int text[]={0,0};
         int size[]={1,1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 5:{
         int mining[]={31};
         int visual[]={2};
         int text[]={0};
         int size[]={1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 6:{
         int mining[]={30};
         int visual[]={2};
         int text[]={0};
         int size[]={1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 7:{
         int mining[]={6};
         int visual[]={9};
         int text[]={0};
         int size[]={1};
         control.panelSet(mining,visual,text,size);
         break;}
         case 8:{
         int mining[]={34};
         int visual[]={1};
         int text[]={0};
         int size[]={1};
         control.panelSet(mining,visual,text,size);
         break;}
                }
                if(buttonCheck==6)
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"Practice.txt");
                else
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                storyControl.SerifControl(0, true);
                componentWindowClose((Component)e.getSource());
            }
        }
        if(number == 11)
        {

            
            if(buttonCheck >= 0)
            {
                storyControl = new StoryControl(control,"A2",11,buttonCheck+1);
                
//                MiningModule mining = control.readModuleData.mining[StoryControl.moduleTutorialIndex[3][buttonCheck]];
                
                int mining[]={control.readModuleData.moduleIDs[StoryControl.moduleTutorialIndex[(int)(number/3)][buttonCheck]]};
                int visual[]={0};
                int text[]={0};
                int size[]={1};
                
                control.panelSet(mining,visual,text,size);
                
                MiningModule min = control.getPanel0Mining();
                
                control.panelSet(min.defaultSetPanelModuleID, min.defaultSetPanelVisualizationID, min.defaultSetPanelTextID, min.defaultBalancedPanelSizeX);
                

                switch(buttonCheck)
                {

                 
                 
                 case 5:{   // NO mining module  creating partial text application
                 int mining[]={40,19,0,0};
                 int visual[]={3,3,1100,1101};
                 int text[]={0,0,0,0};
                 int size[]={1,3,3,3};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 
                 case 8:{           //NO mining module
                 int mining[]={0};
                 int visual[]={1005};
                 int text[]={0};
                 int size[]={1};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 case 9:{           //NO mining module
                 int mining[]={0};
                 int visual[]={1015};
                 int text[]={0};
                 int size[]={1};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 
                 
                 case 0:{
                 int mining[]={39,1};
                 int visual[]={3,1};
                 int text[]={0,0};
                 int size[]={1,1};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 case 1:{       ///////////////////////////subset of case0: 1-5
                 int mining[]={39,6,0};
                 int visual[]={3,9,1016};
                 int text[]={0,0,0};
                 int size[]={1,2,2};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 case 2:{
                 int mining[]={39,0,0,0,17};
                 int visual[]={3,1013,1016,1016,3};
                 int text[]={0,0,0,0,0};
                 int size[]={1,3,3,3,3};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 case 3:{
                 int mining[]={39,0,0,36,17};
                 int visual[]={3,1013,1016,24,3};
                 int text[]={0,0,0,0,0};
                 int size[]={1,3,3,3,3};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 case 4:{
                 int mining[]={39,22,0,0,36};
                 int visual[]={3,6,1013,1016,24};
                 int text[]={0,0,0,0,0};
                 int size[]={1,3,3,3,3};
                 control.panelSet(mining,visual,text,size);
                 break;}
                 
                 case 10:{
                 int mining[]={38,1};
                 int visual[]={3,1};
                 int text[]={0,0};
                 int size[]={1,1};
                 control.panelSet(mining,visual,text,size);
                 break;}
                }

                control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                storyControl.SerifControl(0, true);
                componentWindowClose((Component)e.getSource());
            }
        }
*/

        if(number == 3)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"SL3",3,i);
                    if(i==2 || i==3)
                    {
                        int mining[]={40,19,1};
                        int visual[]={3,3,1};
                        int text[]={0,0,0};
                        int size[]={1,2,2};
                        control.panelSet(mining,visual,text,size);
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima0.txt");
                    }
                    if(i>=4)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");

                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 6)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"L3",6,i);

                    int mining[]={40,19,1};
                    int visual[]={3,3,1};
                    int text[]={0,0,0};
                    int size[]={1,2,2};
                    control.panelSet(mining,visual,text,size);
                    control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"urashima.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 9)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"N3",9,i);
                    if(i==0)
                    {
                        int mining[]={40,19,1};
                        int visual[]={3,3,1};
                        int text[]={0,0,0};
                        int size[]={1,2,2};
                        control.panelSet(mining,visual,text,size);
                    }
                    if(i>=3)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"Practice.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
        if(number == 12)
        {
            for(int i=0; i < verticalNumber-1;i++)
                if(e.getSource() == button[i] )
                {
                    storyControl = new StoryControl(control,"A3",12,i);
                    if(i==0)
                    {
                        int mining[]={40,19,1};
                        int visual[]={3,3,1};
                        int text[]={0,0,0};
                        int size[]={1,2,2};
                        control.panelSet(mining,visual,text,size);
                    }
                    if(i>=2)
                        control.autoTextLoading(control.absolutePath+File.separator+"text"+File.separator+"Practice.txt");
                    
                    storyControl.SerifControl(0, true);
                    componentWindowClose((Component)e.getSource());
                }
        }
       
        flag=1;
         
    }
}
