/**
 * Created with JetBrains WebStorm.
 * User: gravis_ihara
 * Date: 14/09/09
 * Time: 18:29
 * To change this template use File | Settings | File Templates.
 */
gravis.ResultWindow = enchant.Class.create(enchant.Group, {
    initialize: function(w, h, buttonDraw) {
        enchant.Group.call(this);

        var myObj = this;

        this.pushButton = 0;

        this.window_width = w;
        this.window_height = h;
        this.offset = 300;
        this.buttonDraw = buttonDraw;

        this.drawGradation = new enchant.Sprite(480, 397);
        this.drawGradation.image = gravis.Utility.getImage('gradation.png');
        this.addChild(this.drawGradation);

        this.drawNext = new enchant.Sprite(217, 95);
        this.drawNext.image = gravis.Utility.getImage('next_quit.png');
        this.drawNext.frame = 2;
        this.drawNext.addEventListener('touchstart', function(){
            this.frame = 0;
        });
        this.drawNext.addEventListener('touchend', function(e){
            this.frame = 2;
            if( gravis.Utility.isTap(this, e) ) {
                myObj.pushButton = 1;
            }
        });
        this.addChild(this.drawNext);

        this.drawQuit = new enchant.Sprite(217, 95);
        this.drawQuit.image = gravis.Utility.getImage('next_quit.png');
        this.drawQuit.frame = 3;
        this.drawQuit.addEventListener('touchstart', function(){
            this.frame = 1;
        });
        this.drawQuit.addEventListener('touchend', function(e){
            this.frame = 3;
            if( gravis.Utility.isTap(this, e) ) {
                myObj.pushButton = 2;
            }
        });
        this.addChild(this.drawQuit);
    },

    proc: function() {
        this.offset -= 30;
        if( this.offset < 0 ) this.offset = 0;

        if( this.offset == 0 ) {
            var ret = this.pushButton;
            this.pushButton = false;
            return ret;
            /*
            if( this.buttonDraw ) {
                return this.pushButton;
            } else {
                return this.pushButton;
            }
            */
        }
        return 0;
    },

    draw: function() {
        this.drawGradation.moveTo(0, this.window_height-397+this.offset);

        this.drawNext.moveTo(24, this.window_height-95+this.offset);
        this.drawQuit.moveTo(240, this.window_height-95+this.offset);
        /*
        cv.drawImage(Game.imgGradation, 0, window_height-397+offset, 480, 397, 0 ,0 );

        //継続・終了ボタン
        if( buttonDraw ) {
            if( button[0].mode == GameButton.MODE_ACTIVE ) {
                cv.drawImage(Game.imgNextQuit, 24, window_height-95+offset, 217, 95, 0, 95);
            } else {
                cv.drawImage(Game.imgNextQuit, 24, window_height-95+offset, 217, 95, 0, 0);
            }
            if( button[1].mode == GameButton.MODE_ACTIVE ) {
                cv.drawImage(Game.imgNextQuit, 240, window_height-95+offset, 217, 95, 218, 95);
            } else {
                cv.drawImage(Game.imgNextQuit, 240, window_height-95+offset, 217, 95, 218, 0);
            }
        }
        */
    }
});