

//
// Core Program for TETDM 
// PopUpForMoveCharacter.java 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.GameMode.*;
import source.TextData.*;
import source.Utility.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.image.*;
import javax.imageio.ImageIO;


import java.awt.geom.RoundRectangle2D;

import static java.awt.BorderLayout.* ;

public class PopUpForMoveCharacter extends JFrame implements MouseListener
{
    Container pane;
    MoveCharacterPanel moveCharacterPanel;

    public int windowSizeX, windowSizeY;

    String imagePath;
    ImageIcon icon;
    public Image image;
    		
    public PopUpForMoveCharacter(int X, int Y, String absolutePath)
    {
        imagePath = absolutePath+"source"+ File.separator + "Tutorial" +File.separator+"image"+File.separator;
        icon = new ImageIcon(imagePath +"moon.png");
        image = icon.getImage();

        pane = getContentPane();
        pane.setLayout(new BorderLayout());
        pane.addMouseListener(this);



        setAlwaysOnTop(true);
        setUndecorated(true);
        setVisible(true);
        
        moveCharacterPanel = new MoveCharacterPanel();
        pane.add(moveCharacterPanel);

        setBounds(X,Y,50,50);
        
        JFrame.setDefaultLookAndFeelDecorated(true);
        setBackground(new Color(0,0,0,0));
    }

    ///
    public void mouseEntered(MouseEvent e)
    {
        StoryControl.characterMoveReverse();
    }
    public void mouseExited(MouseEvent e){}
    public void mouseClicked(MouseEvent e){}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    ///
    
	class MoveCharacterPanel extends JPanel
	{
	    int sizeX,sizeY;
        
	    MoveCharacterPanel(){}
		
	    public void getLocalSize()
	    {
            sizeX = getWidth();
            sizeY = getHeight();
	    }
        
	    public void update(Graphics g)		//Avoid from blinking
	    {
            paintComponent(g);
	    }
		
	    public void paintComponent(Graphics g)
	    {
            Graphics2D g2 = (Graphics2D)g;
            
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);// Anti aliasing
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            
            getLocalSize();
            
            g2.drawImage(image,0,0,sizeX,sizeY,this);
	    }
	}
}


