code:
//
//  汎用ポップアップコア ver1.04
//
// author yana
//

var Imported = Imported || {};
Imported['CommonPopupCore'] = 1.04;

/*:
 * @plugindesc ver1.04/汎用的なポップアップの仕組みを提供するためのベースプラグインです。
 * @author Yana
 *
 * @param Text Back Color
 * @desc ポップアップの背景カラーです。
 * rgba(red,green,blue,alpha)で設定してください。
 * @default rgba(0,0,0,0.6)
 *
 * @param Text Back FileName
 * @desc ポップアップの背景画像名です。
 * %dがインデックスに変換されます。
 * @default popup_back%d
 *
 * @help プラグインコマンド
 * CommonPopup add param1 param2 param3 ・・・
 *
 * 必要なパラメータのみを指定できます。
 *  例:プレイヤーの上にテストと240フレームポップアップさせる
 * CommonPopup add text:テスト count:240 eventId:-1
 *
 * パラメータ詳細:
 * text:表示テキスト
 * eventId:表示するイベントのID
 * count:表示時間
 * delay:表示遅延
 * moveX:目標地点X(相対座標)
 * moveY:目標地点Y(相対座標)
 * sx:表示位置補正X
 * sy:表示位置補正Y
 * pattern:表示パターン　0がフェード、-1が横ストレッチ、-2が縦ストレッチ
 * back:-1:透明背景,0:背景カラーで塗りつぶし,1以上:画像インデックス
 * bx:内容の表示位置補正X
 * by:内容の表示位置補正Y
 * extend:表示タイミングの調整用配列で指定。 例:extend:[20,50] 20フレーム掛けて出現し、50フレーム目から消え始める。
 * fixed:画面に固定するか？ true/falseで指定。
 * anchorX:
 * anchorY:
 * slideCount:新しいポップアップが発生した際、上にスライドさせる速度。
 *
 * ------------------------------------------------------
 * 利用規約：特になし。素材利用は自己責任でお願いします。
 * ------------------------------------------------------
 * このプラグインは、汎用的なポップアップの仕組みを提供するプラグインです。
 * このプラグイン単体ではプラグインコマンドを追加する以外の機能はありません。
 * 追加機能として、
 * ・\I[x]で描画されるアイコンのサイズが文字サイズに追従する。
 * ・文字サイズ変更の制御文字、\FS[x]が追加される。
 * の2点が追加されます。
 * ------------------------------------------------------
 * 更新履歴:
 * ver1.04
 * YEP_MessageCoreとの競合回避処理を追加。
 * 動作パターンに縦ストレッチと横ストレッチを追加。
 * ポップアップ用のプラグインパラメータが正常に動作していなかったバグを修正。
 * ver1.03:
 * backのパラメータにpicturesフォルダのファイル名を指定できるように変更。
 * ver1.02:
 * スライドに上から下に動作するようにする機能を追加。
 * ver1.01:
 * containerが作成されていない状態で、ポップアップが登録される可能性のあるバグを修正しました。
 * ver1.00:
 * 公開
 */

function Sprite_Popup() {
    this.initialize.apply(this, arguments);
};

function CommonPopupManager() {
    throw new Error('This is a static class');
};

(function(){
    var parameters = PluginManager.parameters('CommonPopupCore');
    var commonPopupTextBackColor = String(parameters['Text Back Color'] || 'rgba(0, 0, 0, 0.6)');
    var commonPopupTextBackFileName = String(parameters['Text Back FileName'] || 'popup_back%d');

    var _cPU_GInterpreter_pluginCommand =
            Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _cPU_GInterpreter_pluginCommand.call(this, command, args);
        if (command === 'CommonPopup' || command === 'ポップアップ') {
            switch (args[0]) {
                case 'add':
                case '表示':
                    this.addPopup(args);
                    break;
                case 'clear':
                case '消去':
                    CommonPopupManager.clearPopup();
                    break;
            }
        }
    };

    Array.prototype.setNullPos = function(object){
        for(var i=0; i < this.length; i++){
            if (this[i] === null || this[i] === undefined){
                this[i] = object;
                return i;
            }
        }
        this.push(object);
    };

    Array.prototype.compact = function() {
        var result = [];
        for (var i = 0; i < this.length; i++) {
            if (this[i] !== null && this[i] !== undefined) {
                result.push(this[i]);
            }
        }
        return result;
    };

    CommonPopupManager.initTempSprites = function(){
        this._tempCommonSprites = new Array(50);
        this._setedPopups = [];
        this._readyPopup = [];
    };

    CommonPopupManager.window = function(){
        if (this._window){return this._window }
        this._window = new Window_Base(0,0,Graphics.boxWidth,Graphics.boxHeight);
        return this._window;
    };

    CommonPopupManager.testBitmap = function(){
        if (this._testBitmap){return this._testBitmap }
        this._testBitmap = new Bitmap(1,1);
        return this._testBitmap;
    };

    Sprite_Popup.prototype = Object.create(Sprite.prototype);
    Sprite_Popup.prototype.constructor = Sprite_Popup;

    Sprite_Popup.prototype.initialize = function(index){
        Sprite.prototype.initialize.call(this);
        this._index = index;
        this._count = 0;
        this._enable = false;
        this.update();
    };

    Sprite_Popup.prototype.setMembers = function(arg){
        this._count = arg.count;
        this._arg = arg;
        this.anchor.x = arg.anchorX;
        this.anchor.y = arg.anchorY;
        this.x = arg.x;
        this.y = arg.y;
        this.z = 6;
        this.visible = true;
        this._enable = true;
        this.createBitmap();
        if (arg.slideCount){
            CommonPopupManager._setedPopups.push([this._index, this.height, this._arg.slideCount]);
        }
    };

    Sprite_Popup.prototype.createBitmap = function(){
        if (this._arg.bitmap){
            this.bitmap = this._arg.bitmap;
        }else{
            CommonPopupManager.window().resetFontSettings();
            var text = this._arg.text;
            var width = CommonPopupManager.window().textWidth(text);
            var height = CommonPopupManager.window().contents.fontSize + 8;
            var sh = 8;
            if (this._arg.back === 0){ sh = 2 }
            CommonPopupManager.window().createContents();
            this.bitmap = new Bitmap(width+24,height+sh);
            this.drawBackRect(width+24,height+sh);
            CommonPopupManager.window().drawTextEx(this._arg.text,12,4);
            this.bitmap.blt(CommonPopupManager.window().contents,0,0,width+24,height+sh,this._arg.bx,this._arg.by+2);
        }
    };

    Sprite_Popup.prototype.drawBackRect = function(width,height){
        switch (this._arg.back){
            case 0:
                var color1 = commonPopupTextBackColor;
                var color2 = 'rgba(0,0,0,0)';
                var dSize = width / 4;
                this.bitmap.gradientFillRect(0,0,dSize,height,color2,color1);
                this.bitmap.fillRect(dSize,0,dSize*2,height,color1);
                this.bitmap.gradientFillRect(dSize*3,0,dSize,height,color1,color2);
                break;
            case -1:
                break;
            default:
                var bitmap = CommonPopupManager.makeBitmap(this._arg);
                var w = this._bitmap.width;
                var h = this._bitmap.height;
                if (typeof this._arg.back === 'string') {
                    w = bitmap.width > this._bitmap.width ? bitmap.width : w;
                    h = bitmap.height > this._bitmap.height ? bitmap.height : h;
                    if (w > this._bitmap.width || h > this._bitmap.height){
                        this.bitmap = new Bitmap(w,h);
                    }
                }
                this.bitmap.blt(bitmap,0,0,bitmap.width,bitmap.height,0,0,w,h);
                bitmap.clear();
                bitmap = null;
        }
    };

    Sprite_Popup.prototype.update = function(){
        Sprite.prototype.update.call(this);
        if (CommonPopupManager._tempCommonSprites[this._index] && !this._enable){
            if (CommonPopupManager._tempCommonSprites[this._index].delay === 0){
                this.setMembers(CommonPopupManager._tempCommonSprites[this._index]);
            }else{
                CommonPopupManager._tempCommonSprites[this._index].delay--;
            }
        }
        if (this._count > 0){
            this._count--;
            if (!this._arg){
                this.terminate;
                return;
            }
            switch(this._arg.pattern){
                case 0:
                case '0':
                case 'Normal':
                    this.updateSlide();
                    break;
                case -1:
                case '-1':
                case 'Stretch':
                    this.updateTurn();
                    break;
                case -2:
                case '-2':
                case 'GrowUp':
                    this.updateGrowUp();
                    break;
                default:
                    this.updateAnime();
            }
            if (this._count == 0){ this.terminate() }
        }
        if (this._arg && this._arg.slideCount){ this.updateMoveSlide() }
    };

    Sprite_Popup.prototype.updateMoveSlide = function(){
        if (CommonPopupManager._setedPopups) {
            var array = CommonPopupManager._setedPopups.clone().reverse();
            var n = 0;
            for (var i = 0; i < array.length; i++) {
                if (this._index === array[i][0]) {
                    if (this._arg.slideAction === 'Down'){
                        this.y = this.y + n;
                    } else {
                        this.y = this.y - n;
                    }
                }
                var sprite = CommonPopupManager._tempCommonSprites[array[i][0]];
                if (sprite.pattern === -2 || sprite.pattern === 'GrowUp'){
                    n += (array[i][1] * sprite.rate);
                } else {
                    n += (array[i][1] * ((this._arg.slideCount - array[i][2]) / this._arg.slideCount));
                }
            }
            for (var i = 0; i < CommonPopupManager._setedPopups.length; i++) {
                CommonPopupManager._setedPopups[i][2]--;
                if (CommonPopupManager._setedPopups[i][2] < 0) {
                    CommonPopupManager._setedPopups[i][2] = 0
                }
            }
        }
    };

    Sprite_Popup.prototype.updateSlide = function(){
        var originalWait = this._arg.count;
        var cnt = originalWait - this._count;
        this.opacity = 255;
        var act = [originalWait / 4, (originalWait * 3) / 4];
        if (this._arg.extend !== ''){ act = this._arg.extend }
        var oa = Math.max(originalWait - act[1],1);
        var n1 = Math.max(originalWait / oa,0.1);
        var up = (this._arg.moveY / (originalWait / n1));
        var slide = (this._arg.moveX / (originalWait / n1));
        var opTime1 =  originalWait / 3.0;
        var moveX = 0;
        var moveY = 0;
        if (act[2]){ opTime1 = originalWait - act[2] }
        var opTime2 = originalWait / 3.0;
        if (act[3]){ opTime2 = act[3] }
        if (this._count >= act[1]){
            this.opacity = Math.floor(255 * (cnt / opTime1));
            moveY = Math.floor(up * cnt);
            moveX = Math.floor(slide * cnt);
        }else if (this._count < act[0]){
            this.opacity = Math.floor(255 * (this._count / opTime2));
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
        }else{
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
        }
        this._times = cnt;
        this.setPosition(moveX,moveY);
    };

    Sprite_Popup.prototype.updateTurn = function() {
        var originalWait = this._arg.count;
        var cnt = originalWait - this._count;
        var act = [originalWait * 0.25, originalWait * 0.75];
        if (this._arg.extend) act = this._arg.extend;
        if (this._count === 0) this.scale.x = 0;
        var oa = Math.max(originalWait - act[1],1);
        var n1 = Math.max(originalWait / oa,0.1);
        var up = (this._arg.moveY / (originalWait / n1));
        var slide = (this._arg.moveX / (originalWait / n1));
        var moveX = 0;
        var moveY = 0;
        if (this._count >= act[1]){
            var rate  = cnt / (originalWait - act[1]);
            this.scale.x = rate;
            moveY = Math.floor(up * cnt);
            moveX = Math.floor(slide * cnt);
        } else if (this._count < act[0]) {
            var rate = this._count / act[0];
            this.scale.x = rate;
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
        } else {
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
        }
        this._times = cnt;
        this.setPosition(moveX,moveY);
    };

    Sprite_Popup.prototype.updateGrowUp = function() {
        var originalWait = this._arg.count;
        var cnt = originalWait - this._count;
        var act = [originalWait * 0.25, originalWait * 0.75];
        if (this._arg.extend) act = this._arg.extend;
        if (this._count === 0) this.scale.y = 0;
        var oa = Math.max(originalWait - act[1],1);
        var n1 = Math.max(originalWait / oa,0.1);
        var up = (this._arg.moveY / (originalWait / n1));
        var slide = (this._arg.moveX / (originalWait / n1));
        var moveX = 0;
        var moveY = 0;
        if (this._count >= act[1]){
            var rate  = cnt / (originalWait - act[1]);
            this.scale.y = rate;
            moveY = Math.floor(up * cnt);
            moveX = Math.floor(slide * cnt);
            this._arg.rate = rate;
        } else if (this._count < act[0]) {
            var rate = this._count / act[0];
            this.scale.y = rate;
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
            this._arg.rate = rate;
        } else {
            moveY = Math.floor((originalWait / n1) * up);
            moveX = Math.floor((originalWait / n1) * slide);
        }
        this._times = cnt;
        this.setPosition(moveX,moveY);
    };

    Sprite_Popup.prototype.setPosition = function(x,y) {
        this.x = this._arg.x + x + this._arg.sx;
        this.y = this._arg.y + y + this._arg.sy;
        if (this._arg.battler){
            if ($gameParty.inBattle()) {
                this.x += this._arg.battler.x;
                this.y += this._arg.battler.y;
            } else {
                this.x += this._arg.battler._realX * $gameMap.tileWidth();
                this.y += this._arg.battler._realY * $gameMap.tileHeight();
            }
        }
        var xx = this.x;
        var yy = this.y;
        if (this._arg.fixed){
            var dx = $gameMap._displayX;
            var dy = $gameMap._displayY;
            xx = this.x - dx * $gameMap.tileWidth();
            yy = this.y - dy * $gameMap.tileHeight();
            if (xx < 0 || yy < 0){
                if (xx < 0 && $gameMap.isLoopHorizontal()) dx -= $dataMap.width;
                if (yy < 0 && $gameMap.isLoopVertical()) dy -= $dataMap.height;
                xx = this.x - dx * $gameMap.tileWidth();
                yy = this.y - dy * $gameMap.tileHeight();
            }
        }
        this.x = xx;
        this.y = yy;
    };

    Sprite_Popup.prototype.updateAnime = function(){
        var anime = $dataAnimations[Number(this._arg.pattern)];
        var frameId = Math.floor((anime.frames.length * (this._arg.count - this._count)) / this._arg.count);
        if (frameId !== anime.frames.length ){
            var array = anime.frames[frameId][0];
            var x = array[1];
            var y = array[2];
            this.x = this._arg.x + x + this._arg.sx;
            this.y = this._arg.y + y + this._arg.sy;
            this.scale = new Point(array[3]/100,array[3]/100);
            this.rotation = array[4];
            this.opacity = array[6];
            this.blendMode = array[7];
        }
    };

    Sprite_Popup.prototype.terminate = function(){
        this.bitmap = null;
        this.visible = false;
        this._enable = false;
        this._count = 0;
        this._arg = null;

        if (CommonPopupManager._tempCommonSprites[this._index]) {
            CommonPopupManager._tempCommonSprites[this._index].terminate = true;
        }
        if (CommonPopupManager._setedPopups) {
            for (var i = 0; i < CommonPopupManager._setedPopups.length; i++) {
                if (CommonPopupManager._setedPopups[i][0] === this._index) {
                    delete CommonPopupManager._setedPopups[i];
                }
            }
            CommonPopupManager._setedPopups = CommonPopupManager._setedPopups.compact();
        }
    };

    Game_Interpreter.prototype.addPopup = function(argParam){
        var eventId = 0;
        for (var i=0;i<argParam.length;i++){
            if (argParam[i].match(/^eventId:(.+)/g)){
                eventId = Number(RegExp.$1);
                break;
            }
        }
        var character = this.character(eventId);
        var arg = CommonPopupManager.setPopup(argParam,character);
        if (arg.back > 0 || typeof arg.back === 'string'){
            CommonPopupManager.bltCheck(CommonPopupManager.makeBitmap(arg));
            CommonPopupManager._readyPopup.push(arg);
        }else{
            CommonPopupManager._tempCommonSprites.setNullPos(arg);
        }
    };

    CommonPopupManager.setPopup = function(argParam,character){
        var arg = {
            x:null,
            y:null,
            text:'',                // 表示テキスト
            eventId:-1,             // 表示するイベントのID
            count:60,               // 表示時間
            delay:0,                // 表示遅延
            moveX:0,                // 目標地点X(相対座標)
            moveY:-48,              // 目標地点Y(相対座標)
            sx:0,                   // 表示位置補正X
            sy:0,                   // 表示位置補正Y
            pattern:0,              // 表示パターン
            back:-1,                // 背景に使う画像インデックス
            bx:0,                   // 内容の表示位置補正X
            by:0,                   // 内容の表示位置補正Y
            extend:'',              //
            fixed:true,             //
            anchorX:0.5,
            anchorY:0.5,
            battler:null
        };
        var array = ['x','y','text','eventId','count','delay','moveX','moveY',
                     'sx','sy','pattern','back','bx','by','extend','fixed',
                     'anchorX','anchorY', 'slideCount'];
        for (var i=0;i < argParam.length;i++){
            if (i > 0){
                for (var j=0;j < array.length;j++){
                    var r = new RegExp('^(' + array[j] + ')' + ':(.+)');
                    if (argParam[i].match(r)){
                        var code = RegExp.$1;
                        var value = RegExp.$2;
                        if (code === 'text' || code === 'extend'){
                            arg[code] = value;
                        }else if (code === 'fixed'){
                            arg[code] = value === 'true';
                        }else if (code === 'back'){
                            arg[code] = (Number(value) !== NaN) ? value : Number(value);
                        } else {
                            arg[code] = Number(value);
                        }
                    }
                }
            }
        }
        if (arg.x === null){
            if (character){
                var screenX = $gameParty.inBattle() ? 0 : character.screenX();
                var displayX = $gameParty.inBattle() ? 0 : $gameMap._displayX * 48;
                arg.x = screenX + displayX;
            } else {
                arg.x = 0;
            }
        }
        if (arg.y === null) {
            if (character) {
                var screenY = $gameParty.inBattle() ? 0 : character.screenY();
                var displayY = $gameParty.inBattle() ? 0 : $gameMap._displayY * 48;
                arg.y = screenY + displayY;
            } else {
                arg.y = 0;
            }
        }
        if (arg.extend) {
            arg.extend = eval(arg.extend);
        }

        arg.terminate = false;
        return arg;
    };

    CommonPopupManager.setPopUpdate = function(){
        if (this._readyPopup){
            for (var i=0;i<this._readyPopup.length;i++){
                if (this._readyPopup[i]){
                    var arg = this._readyPopup[i];
                    if(ImageManager.isReady()){
                        this.startPopup(arg);
                        delete this._readyPopup[i];
                        this._readyPopup.compact();
                        return;
                    }else{
                        this.bltCheck(this.makeBitmap(arg));
                    }
                }
            }
        }
    };

    CommonPopupManager.makeBitmap = function(arg){
        if (typeof arg.back === 'number'){
            var fileName = commonPopupTextBackFileName;
            fileName = fileName.replace(/%d/g,arg.back);
            return ImageManager.loadSystem(fileName);
        } else {
            var fileName = arg.back;
            return ImageManager.loadPicture(fileName);
        }
    };

    CommonPopupManager.bltCheck = function(bitmap){
        this.testBitmap().blt(bitmap,0,0,bitmap.width,bitmap.height,0,0);
        //this.testBitmap().clear();
        //bitmap.clear();
        bitmap = null;
    };

    CommonPopupManager.startPopup = function(arg){
        CommonPopupManager._tempCommonSprites.setNullPos(arg);
    };

    CommonPopupManager.clearPopup = function(tag) {
        if (!CommonPopupManager._tempCommonSprites){
            CommonPopupManager.initTempSprites();
        }

        for(var i=0;i<CommonPopupManager._tempCommonSprites.length;i++){
            if (CommonPopupManager._tempCommonSprites[i]){
                if (!tag || tag === CommonPopupManager._tempCommonSprites[i].tag) {
                    CommonPopupManager._tempCommonSprites[i].delay = 0;
                    CommonPopupManager._tempCommonSprites[i].count = 1;
                    var sprite = CommonPopupManager._tempCommonSprites[i].sprite;
                    if (sprite) sprite._count = 1;
                }
            }
        }
    };

    var _cPU_SsBase_initialize = Spriteset_Base.prototype.initialize;
    Spriteset_Base.prototype.initialize = function(){
        _cPU_SsBase_initialize.call(this);
        this.createSpritePopup();
    };

    var _cPU_SsBase_update = Spriteset_Base.prototype.update;
    Spriteset_Base.prototype.update = function(){
        _cPU_SsBase_update.call(this);
        if (this._popupContainer === undefined){ return }
        if(CommonPopupManager._tempCommonSprites){
            for(var i=0;i<CommonPopupManager._tempCommonSprites.length;i++){
                if (CommonPopupManager._tempCommonSprites[i]){
                    if (CommonPopupManager._tempCommonSprites[i].terminate){
                        var sprite = CommonPopupManager._tempCommonSprites[i].sprite;
                        this._popupContainer.removeChild(sprite);
                        delete CommonPopupManager._tempCommonSprites[i]
                    }else if (!CommonPopupManager._tempCommonSprites[i].sprite){
                        var sprite = new Sprite_Popup(i);
                        this._popupContainer.addChild(sprite);
                        CommonPopupManager._tempCommonSprites[i].sprite = sprite;
                    }
                }
            }
        }
    };

    var _cPU_SBase_update = Scene_Base.prototype.update;
    Scene_Base.prototype.update = function(){
        _cPU_SBase_update.call(this);
        if(CommonPopupManager){ CommonPopupManager.setPopUpdate() };
    };

    Spriteset_Base.prototype.createSpritePopup = function() {
        var width = Graphics.boxWidth;
        var height = Graphics.boxHeight;
        var x = (Graphics.width - width) / 2;
        var y = (Graphics.height - height) / 2;
        this._popupContainer = new Sprite();
        this._popupContainer.setFrame(x, y, width, height);
        this.addChild(this._popupContainer);
    };

    var _cPU_SBase_terminate = Scene_Base.prototype.terminate;
    Scene_Base.prototype.terminate = function(){
        _cPU_SBase_terminate.call(this);
        this.terminatePopup();
    };

    Scene_Base.prototype.terminatePopup = function(){
        if (!CommonPopupManager._tempCommonSprites){
            CommonPopupManager.initTempSprites();
        }
        for(var i=0;i<CommonPopupManager._tempCommonSprites.length;i++){
            if (CommonPopupManager._tempCommonSprites[i]){
                var sprite = CommonPopupManager._tempCommonSprites[i].sprite;
                if (sprite) sprite.terminate();
                delete CommonPopupManager._tempCommonSprites[i];
            }
        }
        CommonPopupManager._setedPopupss = [];
        CommonPopupManager._readyPopup = [];
    };

    var _cPU_SMap_launchBattle = Scene_Map.prototype.launchBattle;
    Scene_Map.prototype.launchBattle = function(){
        _cPU_SMap_launchBattle.call(this);
        this.terminatePopup();
    };

    // 再定義　文字サイズに合わせてアイコンのサイズを調整する
    Window_Base.prototype.drawIcon = function(iconIndex, x, y) {
        var bitmap = ImageManager.loadSystem('IconSet');
        var pw = Window_Base._iconWidth;
        var ph = Window_Base._iconHeight;
        var sx = iconIndex % 16 * pw;
        var sy = Math.floor(iconIndex / 16) * ph;
        var n = Math.floor((this.contents.fontSize / this.standardFontSize()) * Window_Base._iconWidth);
        var nn = (32 - n) / 2;
        this.contents.blt(bitmap, sx, sy, pw, ph, x, y, n, n);
    };

    // 再定義 processDrawIconをストレッチされた文字サイズに合わせたズレに調整する
    Window_Base.prototype.processDrawIcon = function(iconIndex, textState) {
        this.drawIcon(iconIndex, textState.x + 2, textState.y + 2);
        var n = Math.floor((this.contents.fontSize / this.standardFontSize()) * Window_Base._iconWidth);
        textState.x += n + 4;
    };

    if (!Imported.YEP_MessageCore) {
        // \FS[FontSize]の制御文字を追加する部分です。
        var _cPU_Window_Base_processEscapeCharacter = Window_Base.prototype.processEscapeCharacter;
        Window_Base.prototype.processEscapeCharacter = function (code, textState) {
            if (code === 'FS') {
                var param = this.obtainEscapeParam(textState);
                if (param != '') {
                    this.makeFontSize(param)
                }
            } else {
                _cPU_Window_Base_processEscapeCharacter.call(this, code, textState);
            }
        };
    }
    Window_Base.prototype.makeFontSize = function(fontSize) {
        this.contents.fontSize = fontSize;
    };
})();


code:
/*:
 * @plugindesc Plugin used to set basic parameters.
 * @author RM CoreScript team
 *
 * @help This plugin does not provide plugin commands.
 *
* @param cacheLimit
 * @desc For setting the upper limit of image memory cache. (MPix)
 * @default 10
 *
 * @param screenWidth
* @desc For setting the screen width.
 * @default 816
 *
 * @param screenHeight
 * @desc For setting the screen height.
 * @default 624
 *
 * @param changeWindowWidthTo
 * @desc If set, change window width to this value
 *
 * @param changeWindowHeightTo
 * @desc If set, change window height to this value
 *
 * @param renderingMode
 * @desc Rendering mode (canvas/webgl/auto)
 * @default auto
 *
 * @param alwaysDash
 * @desc To set initial value as to whether the player always dashes. (on/off)
 * @default off
 */

/*:ja
 * @plugindesc 基本的なパラメーターを設定するプラグインです。
 * @author RM CoreScript team
 *
 * @help このプラグインにはプラグインコマンドはありません。
 *
 * @param cacheLimit
 * @desc 画像のメモリへのキャッシュの上限値 (MPix)
 * @default 10
 *
 * @param screenWidth
 * @desc 画面サイズの幅
 * @default 816
 *
 * @param screenHeight
 * @desc 画面サイズの高さ
 * @default 624
 *
 * @param changeWindowWidthTo
 * @desc 値が設定された場合、ウインドウの幅を指定した値に変更
 *
 * @param changeWindowHeightTo
 * @desc 値が設定された場合、ウインドウの高さを指定した値に変更
 *
 * @param renderingMode
 * @desc レンダリングモード (canvas/webgl/auto)
 * @default auto
 *
 * @param alwaysDash
 * @desc プレイヤーが常時ダッシュするかどうかの初期値 (on/off)
 * @default off
 */

(function() {
    function toNumber(str, def) {
        return isNaN(str) ? def : +(str || def);
    }

    var parameters = PluginManager.parameters('Community_Basic');
    var cacheLimit = toNumber(parameters['cacheLimit'], 10);
    var screenWidth = toNumber(parameters['screenWidth'], 816);
    var screenHeight = toNumber(parameters['screenHeight'], 624);
    var renderingMode = parameters['renderingMode'].toLowerCase();
    var alwaysDash = parameters['alwaysDash'].toLowerCase() === 'on';
    var windowWidthTo = toNumber(parameters['changeWindowWidthTo'], 0);
    var windowHeightTo = toNumber(parameters['changeWindowHeightTo'], 0);

    var windowWidth;
    var windowHeight;

    if(windowWidthTo){
        windowWidth = windowWidthTo;
    }else if(screenWidth !== SceneManager._screenWidth){
        windowWidth = screenWidth;
    }

    if(windowHeightTo){
        windowHeight = windowHeightTo;
    }else if(screenHeight !== SceneManager._screenHeight){
        windowHeight = screenHeight;
    }

    ImageCache.limit = cacheLimit * 1000 * 1000;
    SceneManager._screenWidth = screenWidth;
    SceneManager._screenHeight = screenHeight;
    SceneManager._boxWidth = screenWidth;
    SceneManager._boxHeight = screenHeight;

    SceneManager.preferableRendererType = function() {
        if (Utils.isOptionValid('canvas')) {
            return 'canvas';
        } else if (Utils.isOptionValid('webgl')) {
            return 'webgl';
        } else if (renderingMode === 'canvas') {
            return 'canvas';
        } else if (renderingMode === 'webgl') {
            return 'webgl';
        } else {
            return 'auto';
        }
    };

    var _ConfigManager_applyData = ConfigManager.applyData;
    ConfigManager.applyData = function(config) {
        _ConfigManager_applyData.apply(this, arguments);
        if (config['alwaysDash'] === undefined) {
            this.alwaysDash = alwaysDash;
        }
    };

    var _SceneManager_initNwjs = SceneManager.initNwjs;
    SceneManager.initNwjs = function() {
        _SceneManager_initNwjs.apply(this, arguments);

        if (Utils.isNwjs() && windowWidth && windowHeight) {
            var dw = windowWidth - window.innerWidth;
            var dh = windowHeight - window.innerHeight;
            window.moveBy(-dw / 2, -dh / 2);
            window.resizeBy(dw, dh);
        }
    };
})();

license: unknown


code:
/*:
 * @plugindesc Writes all errors to a text file in a deployed game so that issues can be accurately reported. <ID: ze_trace_b4ucga>
 * @author Zalerinian
 *
 * @param level
 * @text Log Level
 * @desc The lowest level of events to log. Selecting None will effectively disable the log.
 * @type select
 * @option Error
 * @option Warning
 * @option Info
 * @option Debug
 * @option None
 * @default Error
 *
 * @param file
 * @text Log File
 * @desc The file to use for logging. This is relative to game.exe, NOT the game's content. Default: Log.txt
 * @type text
 * @default Log.txt
 *
 * @param truncate
 * @text Empty Log on Startup
 * @desc Clear the log file each time the game is run. Organizes log files, but results in old errors being cleared out.
 * @type boolean
 * @default true
 *
 * @help
 * ==============================================================================
 * * Overview
 * ==============================================================================
 * This plugin will write errors, warnings, and other messages to a log file for
 * desktop-deployed games. It will disable itself when deployed on the web, so
 * you don't have to worry about removing it for a web export.
 *
 * The types of messages logged by the plugin can be configured using the plugin
 * parameters.
 *
 * ==============================================================================
 * * Changing the behavior
 * ==============================================================================
 * The Trace plugin allows other plugins/developers to alter the logging level
 * After the game has started. The logging level will be stored in save files,
 * and will default to the value define by the plugin if the value is not present
 * in a save.
 *
 * To change the log level of the trace plugin, use the Zale.Trace.setTraceLevel
 * function. You should use one of the constants in the Zale.Trace._Levels
 * object, or you may receive an error. It also helps make your code clearer as
 * to what level you're setting.
 *
 * To change the log file we're using, use the Zale.Trace.setTraceFile function,
 * which will make sure to close the previous file and manage the file handles.
 */

var Zale = Zale || {};
Zale.Trace = {};

var Imported = Imported || {};
Imported["Zale_ConsoleTrace"] = "1.0.0";

(function() {
	'use strict'

	// The plugin is only available on desktop clients, as there is no file system access on the web,
	// and the console will always be available.
	if(Utils.isNwjs()) {
		Zale.Trace._Levels = {
			None: 5,
			Error: 4,
			Warning: 3,
			Info: 2,
			Debug: 1
		};

		Zale.Trace.Level = Zale.Trace._Levels.None;
		Zale.Trace._queue = [];
		Zale.Trace._queueIdx = 0;
		Zale.Trace._fileHandle = -1;
		Zale.Trace._fileHandleBackup = -1;
		Zale.Trace._writing = false;
		Zale.Trace._file = "";
		Zale.Trace._instanceID = Date.now();

		let fs = require('fs');
		let plugin = $plugins.filter(function(p) {
		  return p.description.contains('<ID: ze_trace_b4ucga>') && p.status
		})[0];

		if(plugin == null) {
			internalError("[Trace] Failed to load plugin parameters!");
			return;
		}

		// In order to prevent an infinite loop if there's an error in this plugin, we store the current
		// logging level, set the level to not log anything, log the error in the console as per usual,
		// and then reset the level so future calls to console.error go through the plugin.
		function internalError(message) {
			let level = Zale.Trace.Level;
			Zale.Trace.Level = Zale.Trace._Levels["None"];
			console.error(message);
			Zale.Trace.Level = level;
		}

		// Opens the specified path as the trace file, and store it so we
		// can keep trying to open it if it fails.
		function openTraceFile(path) {
			Zale.Trace._file = path;
			if(Zale.Trace._truncate) {
				fs.open(path, "w", 0o666, handleFileOpen);
			} else {
				fs.open(path, "a", 0o666, handleFileOpen);
			}
		}

		// If there was an error opening the file, try again in 5 seconds. Otherwise, set the
		// file handle, mark that we're no longer switching files, and if we're not writing,
		// write a message if we need to.
		function handleFileOpen(err, fd) {
			if(err != null) {
				internalError("[Trace] Failed to open file for logging. Trying again in 5 seconds.");
				internalError(err);
				setTimeout(function() { Zale.Trace.setTraceFile(Zale.Trace._file); }, 5000);
				return;
			}
			Zale.Trace._fileHandle = fd;
			if(!Zale.Trace._writing) {
				writeMessageIfNeeded();
			}
		}

		// IF we have a valid file handle and there are messages to be written, write them.
		// if the queue length and queue index are equal, then we clear the queue and set the
		// index back to 0, because we caught up with all our messages, and mark writing as false.
		// If we don't have any queued messages or a valid file handle, mark writing as false.
		// If we are writing, we're not done with the queue, and a valid file handle, write the next message!
		function writeMessageIfNeeded() {
			if(Zale.Trace._fileHandle >= 0) {
				if(Zale.Trace._queue.length > 0) {
					if(Zale.Trace._queue.length == Zale.Trace._queueIdx) {
						Zale.Trace._queue.length = 0;
						Zale.Trace._queueIdx = 0;
						Zale.Trace._writing = false;
						return;
					} else {
						Zale.Trace._writing = true;
						let msg = Zale.Trace._queue[Zale.Trace._queueIdx];
						let output = "";
						if(msg.type != null) {
							let rightNow = new Date();
							output = "[" + msg.type.toUpperCase();
							if(!Zale.Trace._truncate) {
								output += " (" + Zale.Trace._instanceID + ") ";
							}
							let hours = rightNow.getHours();
							let ampm = rightNow.getHours() >= 12 ? "pm" : "am";
							hours = hours == 0 ? 12 : hours;
							if(hours > 12) {
								hours -= 12;
							}
							let today = (rightNow.getMonth() + 1) + "/" + rightNow.getDate() + "/" + rightNow.getFullYear();
							let now = hours.padZero(2) + ":" + rightNow.getMinutes().padZero(2) + ":" + rightNow.getSeconds().padZero(2);
							output += " " + today + " " + now + ampm + "] ";
						}
						output += msg.message + "\r\n";
						fs.write(Zale.Trace._fileHandle, output, null, 'utf8', verifyWrite);
					}
				} else {
					Zale.Trace._writing = false;
				}
			} else {
				Zale.Trace._writing = false;
			}
		}

		// Makes sure that there was no error when writing a message to the log. If there was, report it,
		// wait a second, and then try again, without incrementing the queue index so we try that
		// same message again.
		// If it didn't have an error, increment the queue index and see if another message needs to be written.
		function verifyWrite(err, bytesWritten, string) {
			if(err != null) {
				internalError("There was an error writing a message to the log file.");
				internalError(err);
				setTimeout(function() { writeMessageIfNeeded(); }, 1000);
				return;
			}
			Zale.Trace._queueIdx++;
			writeMessageIfNeeded();
		}

		// Verifies that the given value is a valid trace level, and then puts the new level in effect.
		Zale.Trace.setTraceLevel = function(level) {
			if(typeof Zale.Trace._Levels[level] === "number") {
				Zale.Trace.Level = Zale.Trace._Levels[level];
			} else if(typeof level === "number") {
				let keys = Object.keys(Zale.Trace._Levels);
				for(let i = 0; i < keys.length; ++i) {
					if(Zale.Trace._Levels[keys[i]] == level) {
						Zale.Trace.setTraceLevel(keys[i]);
						return;
					}
				}
				internalError("[Trace] " + level + " is does not have a valid level mapping!");
			} else {
				internalError("[Trace] " + level + " is not a valid trace level!");
			}
		}

		// Sets the file we're writing to. If there's already one open, make note of its file handle
		// incase we can't open the new one, and then close and discard the current file handle so
		// that the system will stop writing, instead queueing up any more messages.
		// If the close had an error, we restore the current file, verify that the system has stopped,
		// and then begin writing again.
		// If no file was open, we have nothing to close, so we just open the new one.
		Zale.Trace.setTraceFile = function(filepath) {
			if(Zale.Trace._fileHandle >= 0) {
				if(filepath == Zale.Trace.file) {
					return;
				}
				Zale.Trace._fileHandleBackup = Zale.Trace._fileHandle;
				fs.close(Zale.Trace._fileHandle, function(error) {
					if(error != null) {
						internalError("[Trace] Failed to close old log file");
						internalError(error);
						Zale.Trace._fileHandle = Zale.Trace._fileHandleBackup;
						Zale.Trace._fileHandleBackup = -1;
						if(!Zale.Trace._writing) {
							writeMessageIfNeeded();
						}
						return;
					}
					Zale.Trace._fileHandleBackup = -1;
					openTraceFile(filepath);
				});
				Zale.Trace._fileHandle = -1;
			} else {
				openTraceFile(filepath);
			}
		}

		// If we're not currently writing messages to the queue, try to start it.
		// We need the writing check because this is async recursion. writeMessageIfNeeded has verifyWrite
		// called as it's IO callback, which will then call writeMessageIfNeeded to write the next message
		// in the queue, or to clear the queue and index to free up memory, and to mark that we're no longer
		// writing.
		// If we didn't have this check and called writeMessageIfNeeded multiple times, the callbacks would
		// be called too many times, and we'd try to write a message that doesn't exist, and we'd crash.
		Zale.Trace.logMessage = function(type, message) {
			Zale.Trace._queue.push({type: type, message: message});
			if(!Zale.Trace._writing) {
				writeMessageIfNeeded();
				return;
			}
		}

		// Set the trace level and file according to the plugin parameters.
		Zale.Trace.__params = plugin.parameters;
		Zale.Trace._truncate = plugin.parameters.truncate === "true";
		Zale.Trace.setTraceLevel(plugin.parameters.level);
		Zale.Trace.setTraceFile(plugin.parameters.file);
		if(!Zale.Trace._truncate) {
			//Zale.Trace.logMessage(null, "[Game Startup] Instance ID: " + Zale.Trace._instanceID);
		}

		// Alias the console methods so that they add messages to the queue
		let console_error = console.error;
		console.error = function(msg) {
			if(Zale.Trace.Level <= Zale.Trace._Levels.Error) {
				Zale.Trace.logMessage("error", msg);
			}
			console_error.apply(this, arguments);
		}

		let console_warn = console.warn;
		console.warn = function(msg) {
			if(Zale.Trace.Level <= Zale.Trace._Levels.Warning) {
				Zale.Trace.logMessage("warn", msg);
			}
			console_warn.apply(this, arguments);
		}

		let console_log = console.log;
		console.log = function(msg) {
			if(Zale.Trace.Level <= Zale.Trace._Levels.Info) {
				Zale.Trace.logMessage("info", msg);
			}
			console_log.apply(this, arguments);
		}

		let console_info = console.info;
		console.info = function(msg) {
			if(Zale.Trace.Level <= Zale.Trace._Levels.Info) {
				Zale.Trace.logMessage("info", msg);
			}
			console_info.apply(this, arguments);
		}

		let console_debug = console.debug;
		console.debug = function(msg) {
			if(Zale.Trace.Level <= Zale.Trace._Levels.Debug) {
				Zale.Trace.logMessage("debug", msg);
			}
			console_debug.apply(this, arguments);
		}

		let DataManager_msc = DataManager.makeSaveContents;
		DataManager.makeSaveContents = function() {
			let contents = DataManager_msc.apply(this, arguments);
			contents._zale_trace = {level: Zale.Trace.Level, file: Zale.Trace._file};
			return contents;
		}

		let DataManager_esc = DataManager.extractSaveContents;
		DataManager.extractSaveContents = function(contents) {
			DataManager_esc.apply(this, arguments);
			let settings = contents._zale_trace;
			if(settings == undefined) {
				settings = {level: plugin.parameters.level, file: plugin.parameters.file};
			}
			Zale.Trace.setTraceLevel(settings.level);
			Zale.Trace.setTraceFile(settings.file);
			//console.log("[ConsoleTrace] Set trace level " + settings.level + " in file " + settings.file);
		}

	}
})();


code:
//=============================================================================
// CustomizeErrorScreen.js
// ----------------------------------------------------------------------------
// Copyright (c) 2015 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.2.0 2016/11/10 連絡先のリンクを開く際に、既定のブラウザで開くよう変更
// 1.1.1 2016/07/13 表記方法を少しだけ変更
// 1.1.0 2016/07/13 ローカル実行時、エラー情報のパスを出力しないよう修正
// 1.0.1 2016/06/25 エラー発生時のリンク先を別画面で開くよう修正
// 1.0.0 2016/05/14 初版
// ----------------------------------------------------------------------------
// [Blog]   : http://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================

/*:
 * @plugindesc Customize Error Screen
 * @author triacontane
 *
 * @param MainMessage
 * @desc
 * @default !!Error!!
 *
 * @param HyperLink
 * @desc
 * @default
 *
 * @param OutputDetail
 * @desc
 * @default ON
 *
 * @help Visualize detail information for Error Screen.
 *
 * This plugin is released under the MIT License.
 */
/*:ja
 * @plugindesc エラー画面表示改善プラグイン
 * @author トリアコンタン
 *
 * @param メインメッセージ
 * @desc エラー画面に共通で表示されるメッセージ
 * @default 以下のエラーが発生しました。
 *
 * @param ハイパーリンク
 * @desc エラー画面に表示するリンク先URL
 * @default
 *
 * @param 詳細情報出力
 * @desc エラー情報の詳細(スタックトレース)を出力します。
 * @default ON
 *
 * @help エラー画面の表示を改善します。固定メッセージと連絡先のハイパーリンクを
 * 指定できるほか、エラーの詳細情報（スタックトレース）も表示されるようになります。
 * またURL用にエンコードされて表示される全角文字列をもとの文字列に
 * デコードして表示します。
 *
 * このプラグインにはプラグインコマンドはありません。
 *
 * 利用規約：
 *  作者に無断で改変、再配布が可能で、利用形態（商用、18禁利用等）
 *  についても制限はありません。
 *  このプラグインはもうあなたのものです。
 */

(function() {
    'use strict';
    var pluginName = 'CustomizeErrorScreen';

    var getParamString = function(paramNames) {
        var value = getParamOther(paramNames);
        return value === null ? '' : value;
    };

    var getParamBoolean = function(paramNames) {
        var value = getParamOther(paramNames);
        return (value || '').toUpperCase() === 'ON';
    };

    var getParamOther = function(paramNames) {
        if (!Array.isArray(paramNames)) paramNames = [paramNames];
        for (var i = 0; i < paramNames.length; i++) {
            var name = PluginManager.parameters(pluginName)[paramNames[i]];
            if (name) return name;
        }
        return null;
    };

    //=============================================================================
    // パラメータの取得と整形
    //=============================================================================
    var paramMainMessage  = getParamString(['MainMessage', 'メインメッセージ']);
	//var paramMainMessage  = TextManager.RemErrorMessage;
    var paramHyperLink    = getParamString(['HyperLink', 'ハイパーリンク']);
    var paramOutputDetail = getParamBoolean(['OutputDetail', '詳細情報出力']);

    //=============================================================================
    // SceneManager
    //  エラー情報の出力処理を追加します。
    //=============================================================================
    var _SceneManager_onError = SceneManager.onError;
    SceneManager.onError      = function(e) {
        _SceneManager_onError.apply(this, arguments);
        try {
            Graphics.printErrorDetail(e, decodeURIComponent(e.filename));
        } catch (e2) {
        }
    };

    var _SceneManager_catchException = SceneManager.catchException;
    SceneManager.catchException      = function(e) {
        _SceneManager_catchException.apply(this, arguments);
        Graphics.printErrorDetail(e);
    };

    //=============================================================================
    // Graphics
    //  エラー情報を出力します。
    //=============================================================================
    var _Graphics__makeErrorHtml = Graphics._makeErrorHtml;
    Graphics._makeErrorHtml      = function(name, message) {
        arguments[1] = decodeURIComponent(message);
        return _Graphics__makeErrorHtml.apply(this, arguments);
    };

    Graphics.printErrorDetail = function(e) {
        this.hideFps();
        this._setErrorPrinterStyle();
        if (this._errorPrinter) {
            this._makeMainMessage();
            if (paramHyperLink)    this._makeHyperLink();
            if (paramOutputDetail) {
                var stack = String(e.stack) || '';
                if (Utils.isNwjs()) {
                    stack = stack.replace(/file:.*js\//g, '');
                    stack = stack.replace(/ at /g, '
');
                }
                this._makeStackTrace(stack);
            }
        }
    };

    Graphics._makeMainMessage = function() {
        var mainMessage       = document.createElement('div');
        var style             = mainMessage.style;
        style.color           = 'white';
        style.textAlign       = 'left';
        style.fontSize        = '18px';
        //mainMessage.innerHTML = '
' + paramMainMessage;
		mainMessage.innerHTML = '
' + TextManager.RemErrorMessage;
        this._errorPrinter.appendChild(mainMessage);
    };

    Graphics._makeHyperLink = function() {
        var hyperLink            = document.createElement('a');
        var style                = hyperLink.style;
        style.color              = 'blue';
        style.textAlign          = 'left';
        style.fontSize           = '20px';
        style['text-decoration'] = 'underline';
        style.cursor             = 'pointer';
        hyperLink.addEventListener('click', this._openUrl.bind(this, paramHyperLink));
        hyperLink.innerHTML = paramHyperLink;
        this._errorPrinter.appendChild(hyperLink);
    };

    Graphics._openUrl = function(url) {
        if (!Utils.isNwjs()) {
            window.open(url);
            return;
        }
        var exec = require('child_process').exec;
        switch (process.platform) {
            case 'win32':
                exec('rundll32.exe url.dll,FileProtocolHandler "' + url + '"');
                break;
            default:
                exec('open "' + url + '"');
                break;
        }
    };

    Graphics._makeStackTrace = function(stack) {
        var stackTrace         = document.createElement('div');
        var style              = stackTrace.style;
        style.color            = 'white';
        style.textAlign        = 'left';
        style.fontSize         = '18px';
        style.userSelect       = 'text';
        style.webkitUserSelect = 'text';
        style.msUserSelect     = 'text';
        style.mozUserSelect    = 'text';
        stackTrace.innerHTML   = '

' + stack + '
';
        this._errorPrinter.appendChild(stackTrace);
    };

    Graphics._setErrorPrinterStyle = function() {
        this._errorPrinter.width  = this._width * 0.9;
        this._errorPrinter.height = this._height * 0.9;
        var style                 = this._errorPrinter.style;
        style.textAlign           = 'center';
        style.textShadow          = '1px 1px 3px #000';
        style.fontSize            = '22px';
        style.zIndex              = 99;
        this._centerElement(this._errorPrinter);
    };
})();


code:
//=============================================================================
// 🏤drowsepost Plugins - Map Camera Controller
// DP_MapZoom.js
// Version: 0.822
// https://github.com/drowsepost/rpgmaker-mv-plugins/blob/master/DP_MapZoom.js
//=============================================================================

var Imported = Imported || {};
Imported.DP_MapZoom = true;

var drowsepost = drowsepost || {};

//=============================================================================
/*:
 * @plugindesc Control the magnification of the map scene.
 * @author drowsepost
 *
 * @param Base Scale
 * @desc Set the basic magnification ratio.(Start up)
 * Default: 1 (0 or more)
 * @default 1
 *
 * @param Encount Effect
 * @desc Corrected code of encounter effect
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Camera Controll
 * @desc camera control during magnification processing
 * Default: true (ON: true / OFF: false / Minimum: minimum)
 * @default true
 * @type select
 * @option ON
 * @value true
 * @option OFF
 * @value false
 * @option Minimum
 * @value minimum
 *
 * @param Weather Patch
 * @desc Change weather sprite generation range
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Picture Size Fixation
 * @desc Exclude pictures from map zooming process
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Old Focus
 * @desc Use trackless focus similar to the old version.
 * Default: false (ON: true / OFF: false)
 * @default false
 * @type boolean
 *
 * @help
 * ============================================================================
 * About
 * ============================================================================
 * It controls the enlargement ratio of the map scene by
 * reflecting the calculation of the enlargement ratio
 * to various coordinate processing.
 * (sorry... english support is immature. by drowsepost)
 *
 * ============================================================================
 * How To Use
 * ============================================================================
 *
 * ◆ plugin command:
 * dpZoom {zoom ratio} {animate frames} {event id or "this" or "player"}
 * rename: mapSetZoom
 *
 * e.g.:
 * dpZoom 0.8 360 this
 * -> zoom out to 0.8x , animate 360 frames, centering to event of called
 *
 * dpZoom 1
 * -> zoom to 1x(reset), Immediate
 *
 * dpZoom 3 60 1
 * -> zoom to 3x , animate 60 frames, centering to Event id:001
 *
 * dpFocus {event id or "this" or "player"} {animate frames}
 * Place the specified event in the center of the screen without changing
 * the enlargement ratio of the screen.
 * The camera follows the movement of the event
 *
 * ◆ map meta:
 * if you need setting to Default Magnification on the map,
 * fill in the following in the "Note" field
 *
 * <zoomScale: {zoom ratio}>
 * Specify the enlargement ratio to be the basis for each map
 *
 * e.g.:
 * <zoomScale:0.5>
 * -> zoom out to 0.5x , Immediate
 *
 * if you need setting to Default Camera target on the map,
 * fill in the following in the "Note" field
 *
 * <camTarget: {event id or "player"}>
 * Events can be in the center of the screen.
 * The screen follows the movement of the event.
 *
 * e.g.:
 * <camTarget: 3>
 * -> set center of the screen Event ID "3"
 *
 * ============================================================================
 * Technical information
 * ============================================================================
 * If "screenX" or "screenY" used by another plugin is misaligned,
 * multiply "screenX" or "screenY" by "$gameScreen.zoomScale()".
 *
 * This plugin controls "$gameScreen"
 *
 * This plugin use savedata
 * "$gameMap._dp_scale", "$gameMap._dp_pan", "$gameMap._dp_target"
 *
 * license: MIT
 *
 */
 /*:ja
 * @plugindesc マップの拡大率を制御します。
 * @author drowsepost
 *
 * @param Base Scale
 * @desc 基本の拡大率を設定します。(0以上)
 * Default: 1
 * @default 1
 *
 * @param Encount Effect
 * @desc エンカウントエフェクトに拡大率を反映
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Camera Controll
 * @desc 拡大処理中のセンタリング制御をこのプラグインが行う
 * Default: true (ON: true / OFF: false / 最小: minimum)
 * @default true
 * @type select
 * @option ON
 * @value true
 * @option OFF
 * @value false
 * @option Minimum
 * @value minimum
 *
 * @param Weather Patch
 * @desc 天候スプライトの生成範囲を広げる修正を適用します。
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Picture Size Fixation
 * @desc ピクチャをマップの拡大処理から除外します
 * Default: true (ON: true / OFF: false)
 * @default true
 * @type boolean
 *
 * @param Old Focus
 * @desc 古いバージョンの追跡なしのフォーカスを使用します。
 * Default: false (ON: true / OFF: false)
 * @default false
 * @type boolean
 *
 * @help
 * ============================================================================
 * About
 * ============================================================================
 * 各種座標処理に拡大率の計算を反映し
 * マップシーンの拡大率を制御します。
 * また、指定したイベントをカメラが追うように指定します。
 * 標準のフォーカス対象は先頭のプレイヤーとなります。
 *
 * ============================================================================
 * How To Use
 * ============================================================================
 * ◆ マップメモ欄
 *
 * <zoomScale:0.5>
 * などと記述すると、マップごとに基準になる拡大率を指定することが出来ます。
 *
 * <camTarget: 3>
 * 等と記述すると、イベントID n番のイベントが画面中央になった状態にできます。
 * フォーカスはイベントの移動に画面が追従します。
 *
 * ◆ プラグインコマンド
 *
 * (1)ズーム機能
 * dpZoom {倍率} {変更にかけるフレーム数} {対象イベントID / this / player}
 * 指定したイベントにフォーカスを合わせつつ画面の拡大率を変更できます。
 * 第3引数に何も指定しない場合、画面中央に向かって拡大します。
 *
 * 例:
 * プラグインコマンドにおいて対象イベントの部分に
 * 「this」もしくは「このイベント」と指定すると、
 * イベント実行中のオブジェクトを指定します。
 * dpZoom 2 360 this
 * たとえば上記はそのイベントが中心になるように6秒かけて2倍の拡大率に変化します。
 * <非推奨> mapSetZoom は利用できますが、非推奨とします。
 *
 * (2)フォーカス機能
 * dpFocus {対象イベントID / this / player} {変更にかけるフレーム数}
 * 画面の拡大率を変更せずに指定したイベントにフォーカスを合わせます。
 *
 * ============================================================================
 * Settings
 * ============================================================================
 * Base Scale
 * ゲーム開始時の拡大倍率を指定します。
 * 倍率には0以上を指定してください。
 *
 * Encount Effect
 * エンカウントエフェクトを置き換えるかどうかを指定します。
 * オリジナルのエフェクトで置き換えている場合はこちらをfalseにしてください。
 * しかしその場合、画面の拡大率をそれぞれ反映できるように調整する必要があります。
 *
 * Camera Controll
 * falseの場合はイベントを指定した拡大を含む拡大中のカメラ制御は動作しません。
 * 別プラグインでカメラ制御を行う場合にご利用ください。
 *
 * Weather Patch
 * trueの場合、天候スプライトの生成範囲に関する修正を行い、
 * 拡大率変更後も天候スプライトをまんべんなく分布させます
 * 別プラグインで天候演出の制御を行っている場合等はfalseにしてください。
 *
 * Picture Size Fixation
 * trueの場合、ピクチャを拡大処理から除外します。
 *
 * Old Focus
 * trueの場合、古いDP_MapZoom.jsと同様のフォーカス処理を行います。
 * このフォーカス処理は対象イベントまでの座標のずれを基準にしているため、
 * イベントの移動を追尾しません。
 *
 * ============================================================================
 * Technical information
 * ============================================================================
 * 現在の画面の拡大率は$gameScreen.zoomScale()で取得できます。
 * これはプラグインの利用に関わらず元から存在する関数です。
 * 他のプラグインで利用する「screenX」や「screenY」がずれる場合は、
 * 「screenX」や「screenY」にそれぞれ$gameScreen.zoomScale()を掛けて下さい。
 *
 * このプラグインは$gameScreenを制御します。
 *
 * 指定された拡大率設定は$gameMap._dp_scaleが保持します。
 * シーン離脱時のスクロール量は$gameMap._dp_panが保持します。
 * マップのフォーカスイベントは$gameMap._dp_targetが保持します。
 *
 * ライセンス: MIT
 *
 */
(function() {
    "use strict";
    var parameters = PluginManager.parameters('DP_MapZoom');
    var user_scale = Number(parameters['Base Scale'] || 1);
    var user_fix_encount = Boolean(parameters['Encount Effect'] === 'true' || false);
    var user_use_camera = Boolean(parameters['Camera Controll'] === 'true' || false);
    var user_use_camera_transfer = Boolean(parameters['Camera Controll'] === 'minimum' || false);
    var user_fix_weather = Boolean(parameters['Weather Patch'] === 'true' || false);
    var user_fix_picture = Boolean(parameters['Picture Size Fixation'] === 'true' || false);
    var user_use_oldfocus = Boolean(parameters['Old Focus'] === 'true' || false);
    var user_map_marginright = 0;
    var user_map_marginbottom = 0;

    /*
    Main Functions
    =============================================================================
    実際の拡大処理
    */
    var camera = {};

    /*
    dp_renderSize
    タイル拡大率を保持および仮想的なレンダリング範囲を算出します。
    */
    var dp_renderSize = {
        _scale : undefined,
        width: undefined,
        height: undefined,

        /**
         * 拡大率からレンダリングするべきオブジェクトのサイズを設定します。
         * @param {number} scale
         */
        onChange: (function(scale){
            if(!('_scene' in SceneManager)) return;
            if(!('_spriteset' in SceneManager._scene)) return;
            var scale = scale || this._scale;
            var spriteset = SceneManager._scene._spriteset;

            //マップサイズ変更
            spriteset._tilemap.width = Math.ceil((Graphics.width + spriteset._tilemap._margin * 2) / scale);
            spriteset._tilemap.height = Math.ceil((Graphics.height + spriteset._tilemap._margin * 2) / scale);

            //パララックスサイズ変更
            spriteset._parallax.move(0, 0, Math.round(Graphics.width / scale), Math.round(Graphics.height / scale));

            // Foreground.js対応
            if (spriteset._foreground && spriteset._foreground instanceof TilingSprite) {
                spriteset._foreground.move(0, 0, Math.round(Graphics.width / scale), Math.round(Graphics.height / scale));
            }

            spriteset._tilemap.refresh();
        }),

        /**
         * scaleをリセットします
         */
        reset: (function(){
            this.scale = 1;
        })
    };

    Object.defineProperty(dp_renderSize, 'scale', {
        get: function() {
            return this._scale;
        },
        set: function(val) {
            if(val != this._scale) {
                this._scale = Number(val);
                this.width = Math.ceil(Graphics.boxWidth / this._scale);
                this.height = Math.ceil(Graphics.boxHeight / this._scale);
                this.onChange();
            }
        }
    });

    /**
     * ズームすべき座標を算出
     * @return {object} PIXI.Point
     */
    var dp_getZoomPos = function() {
        return new PIXI.Point(
            camera.target.screenX(),
            camera.target.screenY() - ($gameMap.tileHeight() / 2)
        );
    };

    /**
     * マップのレンダリング原点と表示位置のずれを取得します。
     * @return {object} PIXI.Point
     */
    var dp_getVisiblePos = function () {
        var screen = $gameScreen;
        var scale = screen.zoomScale();
        return new PIXI.Point(
            Math.round(screen.zoomX() * (scale - dp_renderSize.scale)),
            Math.round(screen.zoomY() * (scale - dp_renderSize.scale))
        );
    };

    /**
     * フォーカスされているキャラクターから画面の中心がどれだけずれているか取得します
     * @return {object} PIXI.Point
     */
    var dp_getpan = function() {
        var centerPosX = (($gameMap.screenTileX() - 1) / 2);
        var centerPosY = (($gameMap.screenTileY() - 1) / 2);

        var pan_x = ($gameMap.displayX() + centerPosX) - camera.target._realX;
        var pan_y = ($gameMap.displayY() + centerPosY) - camera.target._realY;

        return new PIXI.Point(
            ($gameMap.screenTileX() >= $dataMap.width )? 0 : pan_x,
            ($gameMap.screenTileY() >= $dataMap.height )? 0 : pan_y
        );
    };

    /**
     * 画面の拡大率を設定します。
     * @param {number} scale
     */
    var dp_setZoom = function(scale) {
        dp_renderSize.scale = scale;
        $gameMap._dp_scale = scale;

        $gameScreen.setZoom(0, 0, scale);
        camera.center();
    };

    /*
    Camera Object
    ===================================================================================
    */

    /**
     * カメラのアニメーションを制御するオブジェクト
     */
    camera.animation = (function(){
        //private
        var _active = false;
        var _duration, _target, _pan_target, _pan_prev;

        //public
        var r = {
            /**
             * アニメーションのスタート
             * @param {number} scale 目標とする拡大率
             * @param {object} pos 目標とする座標のズレ PIXI.Point
             * @param {number} dulation 変化にかけるフレーム
             */
            start : (function(scale, pos, duration) {
                var is_zoomout = ($gameScreen.zoomScale() > scale)? true : false;

                _target = scale || $gameScreen.zoomScale();
                _duration = duration || 0;
                _pan_target = pos || new PIXI.Point();
                _pan_prev = dp_getpan();

                if(is_zoomout) {
                    dp_renderSize.scale = scale;
                    camera.center(_pan_prev.x, _pan_prev.y);
                }

                _active = true;
            }),
            /**
             * アニメーションのアップデート
             * camera.animation.update
             */
            update: (function() {
                if(!_active) return;
                if(_duration <= 1) {
                    r.end();
                    return;
                }

                _pan_prev.x = ((_pan_prev.x * (_duration - 1) + _pan_target.x) / _duration);
                _pan_prev.y = ((_pan_prev.y * (_duration - 1) + _pan_target.y) / _duration);

                $gameScreen.setZoom(0, 0, (($gameScreen.zoomScale() * (_duration - 1) + _target) / _duration));
                camera.center(_pan_prev.x, _pan_prev.y);

                _duration--;
            }),
            /**
             * アニメーションの終了
             */
            end : (function() {
                if(!_active) return;
                _active = false;

                $gameMap._dp_pan = _pan_target;
                dp_setZoom(_target);
            })
        };

        return r;
    }());

    /**
     * カメラのズームを開始する関数
     * @param {number} ratio 拡大率
     * @param {number} duration 変化にかけるフレーム
     * @param {any} target フォーカスするイベントIDもしくはゲームイベントオブジェクト
     */
    camera.zoom = function(ratio, duration, target) {
        if((typeof ratio !== 'number') || (ratio < 0)){
            ratio = dp_renderSize.scale;
        }

        var target_pan = dp_getpan();
        if(typeof target !== 'undefined') {
            if(user_use_oldfocus) {
                target_pan = camera.targetPan(target);
            } else {
                camera.target = target;
                target_pan = new PIXI.Point();
            }
        }

        if(duration > 0){
            camera.animation.start(ratio, target_pan, duration);
        } else {
            $gameMap._dp_pan = target_pan;
            dp_setZoom(ratio);
        }
    };

    /**
     * 指定されたイベントIDをイベントインスタンスにして返却
     * @param {any} event イベントIDもしくはイベントオブジェクトもしくはプレイヤー
     * @return {object} Game_CharacterBase
     */
    camera.getEvent = function(event) {
        var _target;
        if(typeof event === 'object') {
            if('_eventId' in event) _target = $gameMap.event(event._eventId);
        }

        if(typeof event === 'number') {
            _target = $gameMap.event(event);
        }

        if(!(_target instanceof Game_CharacterBase)) {
            _target = $gamePlayer;
        }

        return _target;
    }

    /**
     * カメラターゲットから目標イベントまでのマップ上のズレ(x,y)を取得
     * @param {any} event イベントIDもしくはイベントオブジェクトもしくはプレイヤー
     * @return {object} PIXI.Point
     */
    camera.targetPan = function(event) {
        var _target = camera.getEvent(event);

        return new PIXI.Point(
            _target._realX - camera.target._realX,
            _target._realY - camera.target._realY
        );
    };

    /**
     * フォーカスしたターゲットをカメラ中央に配置
     * @param {number} panX 画面をずらすマスの数。横。
     * @param {number} panY 画面をずらすマスの数。縦。
     * @param {boolean} force_center カメラ制御無効でも実行
     */
    camera.center = function(panX, panY, force_center) {
        if((!user_use_camera) && (!force_center)) return;
        var px = Number(panX || $gameMap._dp_pan.x);
        var py = Number(panY || $gameMap._dp_pan.y);
        camera.target.center(camera.target._realX + px, camera.target._realY + py);
    };

    /**
     * カメラがフォーカスする対象
     * @param {any} event イベントIDもしくはゲームイベントもしくはプレイヤー
     * @return {object} ゲームイベントもしくはプレイヤー
     */
    Object.defineProperty(camera, 'target', {
        get: function() {
            if($gameMap._dp_target === 0) return $gamePlayer;
            return $gameMap.event($gameMap._dp_target);
        },
        set: function(event) {
            var _target = camera.getEvent(event);

            $gameMap._dp_target = 0;
            if(typeof _target === 'object') {
                if('_eventId' in _target) $gameMap._dp_target = _target._eventId;
            }
        }
    });

    //公開
    drowsepost.camera = camera;

    /*
    Command Entry
    ===================================================================================
    @param {array} args スペース区切りで指定したプラグインコマンドの引数(array<string>)
    */
    drowsepost.fn = drowsepost.fn || {};

    /**
     * 拡大率を変更せずにフォーカス変更
     * {target} {frame}
     */
    var _p_dpfocus = ('dpFocus' in drowsepost.fn)? drowsepost.fn.dpFocus : (function(){});
    drowsepost.fn.dpFocus = (function(_a){
        _p_dpfocus.call(this, _a);

        var _s = this;
        var _target;

        if(_a.length < 1) _a.push('player');

        if((_a[0] === 'this') || (_a[0] === 'このイベント')) _target = _s;
        else if((_a[0] === 'player') || (_a[0] === 'プレイヤー')) _target = $gamePlayer;
        else _target = parseInt(_a[0]);

        camera.zoom(dp_renderSize.scale, parseInt(_a[1]), _target);
    });

    /**
     * 画面拡大率を変更
     * 第三引数にターゲット指定でフォーカスも変更
     * {zoom} {frame} {target}
     */
    var _p_dpzoom = ('dpZoom' in drowsepost.fn)? drowsepost.fn.dpZoom : (function(){});
    drowsepost.fn.mapSetZoom = drowsepost.fn.dpZoom = (function(_a){
        _p_dpzoom.call(this, _a);

        var _s = this;
        var _target;

        if(_a.length > 2) {
            if((_a[2] === 'this') || (_a[2] === 'このイベント')) _target = _s;
            else if((_a[2] === 'player') || (_a[2] === 'プレイヤー')) _target = $gamePlayer;
            else _target = parseInt(_a[2]);
        }

        camera.zoom(parseFloat(_a[0]), parseInt(_a[1]), _target);
    });

    /*
    Game_Interpreter
    ===================================================================================
    コマンドパーサーの追加
    */
    (function(){
        //@override
        var _parent_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
            _parent_pluginCommand.call(this, command, args);

            if('DP_Basics' in Imported) return;
            if(!(command in drowsepost.fn)) return;
            if(typeof drowsepost.fn[command] === 'function') {
                drowsepost.fn[command].call(this, args);
            }
        };

    }());

    /*
    Game Map
    =============================================================================
    拡大率($gameScreen.zoomScale())の反映
    */
    (function(){
        //@override
        var _parent_initialize = Game_Map.prototype.initialize;
        Game_Map.prototype.initialize = function() {
            _parent_initialize.call(this);

            //保存用変数エントリー
            this._dp_scale = user_scale;
            this._dp_pan = new PIXI.Point();
            this._dp_target = 0;
        };

        //@override
        Game_Map.prototype.screenTileX = function() {
            return (Graphics.width - user_map_marginright) / (this.tileWidth() * $gameScreen.zoomScale());
        };

        //@override
        Game_Map.prototype.screenTileY = function() {
            return (Graphics.height - user_map_marginbottom) / (this.tileHeight() * $gameScreen.zoomScale());
        };

        //@override
        Game_Map.prototype.canvasToMapX = function(x) {
            var tileWidth = this.tileWidth() * $gameScreen.zoomScale();
            var originX = this._displayX * tileWidth;
            var mapX = Math.floor((originX + x) / tileWidth);
            return this.roundX(mapX);
        };

        //@override
        Game_Map.prototype.canvasToMapY = function(y) {
            var tileHeight = this.tileHeight() * $gameScreen.zoomScale();
            var originY = this._displayY * tileHeight;
            var mapY = Math.floor((originY + y) / tileHeight);
            return this.roundY(mapY);
        };

    }());

    /*
    Game Character
    =============================================================================
    Game Characterに注視する場合の処理を追加
    */
    (function(){
        Game_Character.prototype.centerX = function() {
            return ($gameMap.screenTileX() - 1) / 2.0;
        };

        Game_Character.prototype.centerY = function() {
            return ($gameMap.screenTileY() - 1) / 2.0;
        };

        Game_Character.prototype.center = function(x, y) {
            return $gameMap.setDisplayPos(x - this.centerX(), y - this.centerY());
        };

        Game_Character.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
            var x1 = lastScrolledX;
            var y1 = lastScrolledY;
            var x2 = this.scrolledX();
            var y2 = this.scrolledY();
            if (y2 > y1 && y2 > this.centerY()) {
                $gameMap.scrollDown(y2 - y1);
            }
            if (x2 < x1 && x2 < this.centerX()) {
                $gameMap.scrollLeft(x1 - x2);
            }
            if (x2 > x1 && x2 > this.centerX()) {
                $gameMap.scrollRight(x2 - x1);
            }
            if (y2 < y1 && y2 < this.centerY()) {
                $gameMap.scrollUp(y1 - y2);
            }
        };

    }());

    /*
    Game Player
    =============================================================================
    拡大率の反映
    */
    (function(){
        //@override
        Game_Player.prototype.centerX = function() {
            return ($gameMap.screenTileX() - 1) / 2.0;
        };

        //@override
        Game_Player.prototype.centerY = function() {
            return ($gameMap.screenTileY() - 1)  / 2.0;
        };

        //@override
        var _parent_updateScroll = Game_Player.prototype.updateScroll;
        Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
            if (typeof $gameMap !== 'object') return;
            if ($gameMap._dp_target !== 0) return;
            _parent_updateScroll.call(this, lastScrolledX, lastScrolledY);
        };

    }());

    /*
    Game Event
    =============================================================================
    Game Eventに注視する場合の処理を追加
    */
    (function(){
        //@override
        var _parent_update = Game_Event.prototype.update;
        Game_Event.prototype.update = function() {
            var lastScrolledX = this.scrolledX();
            var lastScrolledY = this.scrolledY();

            _parent_update.call(this);

            this.updateScroll(lastScrolledX, lastScrolledY);
        };

        Game_Event.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
            if (typeof $gameMap !== 'object') return;
            if ($gameMap._dp_target !== this._eventId) return;
            Game_Character.prototype.updateScroll.call(this, lastScrolledX, lastScrolledY);
        }

    }());

    /*
    Weather
    =============================================================================
    描画反映変更機能の追加
    */
    (function(){
        //天候スプライトの生成範囲をGraphic基準ではなく実際の描画範囲に合わせる
        if(!user_fix_weather) return;
        //@override
        var _parent_rebornSprite = Weather.prototype._rebornSprite;
        Weather.prototype._rebornSprite = function(sprite) {
            _parent_rebornSprite.call(this, sprite);
            sprite.ax = Math.randomInt(dp_renderSize.width + 100) - 50 + this.origin.x;
            sprite.ay = Math.randomInt(dp_renderSize.height + 200) - 100 + this.origin.y;
            sprite.opacity = 160 + Math.randomInt(60);
        };

    }());

    /*
    Sprite_Picture
    =============================================================================
    ピクチャdot by dot配置機能の追加
    */
    (function(){
        //ピクチャの配置と拡大率を、スクリーンの拡大率で打ち消す
        if(!user_fix_picture) return;

        //@override
        var _parent_updateScale = Sprite_Picture.prototype.updateScale;
        Sprite_Picture.prototype.updateScale = function() {
            _parent_updateScale.call(this);
            var picture = this.picture();
            this.scale.x = (1 / $gameScreen.zoomScale()) * (picture.scaleX() / 100);
            this.scale.y = (1 / $gameScreen.zoomScale()) * (picture.scaleY() / 100);
        };

        //@override
        var _parent_updatePosition = Sprite_Picture.prototype.updatePosition;
        Sprite_Picture.prototype.updatePosition = function() {
            _parent_updatePosition.call(this);
            var picture = this.picture();
            var map_s = dp_getVisiblePos();
            this.x = Math.floor((picture.x() + map_s.x) * (1 / $gameScreen.zoomScale()));
            this.y = Math.floor((picture.y() + map_s.y) * (1 / $gameScreen.zoomScale()));
        };
    }());

    /*
    Spriteset_Base
    =============================================================================
    拡大座標の調整
    */
    (function(){
        //@override
        var _parent_updatePosition = Spriteset_Base.prototype.updatePosition;
        Spriteset_Base.prototype.updatePosition = function() {
            _parent_updatePosition.call(this);

            var map_s = dp_getVisiblePos();
            this.x = map_s.x * -1;
            this.y = map_s.y * -1;

            this.x += Math.round($gameScreen.shake());
        };
    }());

    /*
    Scene_Map
    =============================================================================
    拡大率の引継ぎ
    */
    (function(){
        /*
        マップシーンの開始
        */
        //@override
        var _parent_start = Scene_Map.prototype.start;
        Scene_Map.prototype.start = function() {
            _parent_start.call(this);

            //移動後処理
            if(this._transfer) {
                //マップ設定情報で拡大率変更
                //イベントエディタからのテスト実行では$gameMap.metaが定義されない。
                $gameMap._dp_scale = ('meta' in $dataMap)
                    ? Number($dataMap.meta.zoomScale || $gameMap._dp_scale)
                    : $gameMap._dp_scale;

                //カメラターゲット
                //イベントエディタからのテスト実行では$gameMap.metaが定義されない。
                $gameMap._dp_target = ('meta' in $dataMap)
                    ? Number($dataMap.meta.camTarget || 0)
                    : 0;

                //パン
                $gameMap._dp_pan = new PIXI.Point();
            }

            //標準レンダリングサイズにリセット
            dp_renderSize.reset();

            //カメラターゲット設定
            camera.target = $gameMap._dp_target;

            //マップシーン開始時に拡大率変更をフック。
            dp_setZoom($gameMap._dp_scale);

            //画面中心を強制設定する
            if((!user_use_camera) && user_use_camera_transfer) camera.center(null, null, true);
        };

        /*
        マップシーンの終了
        */
        //@override
        var _parent_terminate = Scene_Map.prototype.terminate;
        Scene_Map.prototype.terminate = function() {
            //マップシーン終了時に拡大率情報を保存。
            camera.animation.end();

            var zoomPos = dp_getZoomPos();
            $gameScreen.setZoom(zoomPos.x, zoomPos.y, dp_renderSize.scale);
            $gameMap._dp_pan = dp_getpan();

            _parent_terminate.call(this);
        };

        /*
        エンカウントエフェクト
        */
        if(!user_fix_encount) return;
        //@override
        Scene_Map.prototype.updateEncounterEffect = function() {
            if (this._encounterEffectDuration > 0) {
                this._encounterEffectDuration--;
                var speed = this.encounterEffectSpeed();
                var n = speed - this._encounterEffectDuration;
                var p = n / speed;
                var q = ((p - 1) * 20 * p + 5) * p + 1;
                var zoomPos = dp_getZoomPos();

                if (n === 2) {
                    $gameScreen.setZoom(zoomPos.x, zoomPos.y, dp_renderSize.scale);
                    this.snapForBattleBackground();
                    this.startFlashForEncounter(speed / 2);
                }

                $gameScreen.setZoom(zoomPos.x, zoomPos.y, (q * dp_renderSize.scale));
                if (n === Math.floor(speed / 6)) {
                    this.startFlashForEncounter(speed / 2);
                }
                if (n === Math.floor(speed / 2)) {
                    BattleManager.playBattleBgm();
                    this.startFadeOut(this.fadeSpeed());
                }
            }
        };
        //エンカウントエフェクトここまで

    }());

    /*
    Game_Screen
    =============================================================================
    アニメーション処理のフック
    */
    (function(){
        //@override
        var _parent_update = Game_Screen.prototype.update;
        Game_Screen.prototype.update = function() {
            _parent_update.call(this);
            camera.animation.update();
        };

        //@override
        var _parent_initialize = Game_Screen.prototype.initialize;
        Game_Screen.prototype.initialize = function() {
            _parent_initialize.call(this);
            dp_renderSize.reset();
        };
    }());

}());