

//
// Core Program for TETDM 
// PopUpForChapter.java Version 1.04
// 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.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;

public class PopUpForChapter extends JFrame
{
    ChapterPanel chapterPanel[] = new ChapterPanel[13];
    
	Container pane = getContentPane();
    
    Control control;
    
    int number;
		
	public PopUpForChapter(int X, int Y, int width, int height, Control control, int number)
	{
		super("Chapter"+number);
		pane.setLayout(new BorderLayout());
        
        this.control = control;
        
        this.number = number;
        
        if(height < 80*(StoryControl.subMissionNumber[number]+1))
            height = 80*(StoryControl.subMissionNumber[number]+1);
        
        try{
            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            DisplayMode displayMode = env.getDefaultScreenDevice().getDisplayMode();
            
            int displayHeight = displayMode.getHeight();
            
            if(height > displayHeight - 140)
                height = displayHeight - 140;
        }
        catch(Exception e)
        {
            height = 400;
        }
		
		setBounds(X, Y, width, height);
//		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		setAlwaysOnTop(true);
		pane.setBackground(Color.white);
//		setUndecorated(true);
        
		this.addWindowListener(new MyWindowListener());
		
        setVisible(true);
        
        chapterPanel[number] = new ChapterPanel(control,number);
        pane.add(chapterPanel[number]);
	}
    
    class MyWindowListener extends WindowAdapter {
        public void windowClosing(WindowEvent e)
        {
            control.btTutorial.setSelected(false);
            control.characterTutorial = 0;
            control.setCharacterTutorialButton();
        }
    }
}
