code:
//=============================================================================
// MOG_TitlePictureCom.js
//=============================================================================

/*:
 * @plugindesc (v1.6 *) Adiciona comandos em imagens no lugar da janela.
 * @author Moghunter
 *
 * @param -> Main <<<<<<<<<<<<<<<<<<<<<<<
 * @desc
 *
 * @param Animation Mode
 * @desc Definição do tipo de animação.
 * 0 - None     1 - Pulse    2 - Shake
 * @default 2
 * @type select
 * @option None
 * @value 0
 * @option Pulse Effect
 * @value 1
 * @option Shake Effect
 * @value 2
 * @parent -> Main <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Left & Right Input
 * @desc Ativar a seleção de comandos com as teclas Right/Left.
 * @default true
 * @type boolean
 * @parent -> Main <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Com Fade-In Duration
 * @text Fade-In Duration
 * @desc Faz os comandos aparecerem gradualmente.
 * @default 13
 * @type number
 * @parent -> Main <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Slide X-Axis
 * @desc Faz os comandos deslizarem na horizontal.
 * @default -100
 * @type number
 * @parent -> Main <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Slide Y-Axis
 * @desc Faz os comandos deslizarem na vertical.
 * @default 0
 * @type number
 * @parent -> Main <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param
 *
 * @param -> Smart Background  <<<<<<<<<<<<<<<<<<<<<<<
 * @desc
 *
 * @param Smart Background
 * @text Visible
 * @desc Ativar a imagem de fundo baseado na seleção de comando.
 * @default true
 * @type boolean
 * @parent -> Smart Background  <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Background X-Axis
 * @text X-Axis
 * @desc Definição X-Axis da imagem de fundo.
 * @default 0
 * @type number
 * @parent -> Smart Background  <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Background Y-Axis
 * @text Y-Axis
 * @desc Definição Y-Axis da imagem de fundo.
 * @default 0
 * @type number
 * @parent -> Smart Background  <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Background Fade-In Duration
 * @text Fade-In Duration
 * @desc Definição do tempo para apresentar a imagem.
 * @default 90
 * @type number
 * @parent -> Smart Background  <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param
 *
 * @param -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 * @desc
 *
 * @param Title Sprite
 * @text Visible
 * @desc Ativar o nome do título em sprite.
 * É necessário ter o arquivo Title.png na pasta img/titles2/
 * @default true
 * @type boolean
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Title Sprite X-Axis
 * @text X-Axis
 * @desc Definição X-axis.
 * @default 300
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Title Sprite Y-Axis
 * @text Y-Axis
 * @desc Definição Y-axis.
 * @default 150
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Fade-In Duration
 * @desc Define o tempo para fazer o título aparecer.
 * @default 40
 * @type number
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Zoom Effect
 * @desc Ativar o efeito de zoom.
 * @default true
 * @type boolean
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Zoom Speed
 * @desc Definição do tempo de zoom.
 * @default 40
 * @type number
 * @parent -> Title Sprite <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param
 *
 * @param -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 * @desc
 *
 * @param Cursor X-Axis
 * @text X-Axis
 * @desc Definição X-axis do cursor.
 * @default 0
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Cursor Y-Axis
 * @text Y-Axis
 * @desc Definição Y-axis do cursor.
 * @default 5
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Cursor Visible
 * @text Visible
 * @desc Ativar cursor.
 * @default true
 * @type boolean
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Cursor Wave Animation
 * @text Wave Animation
 * @desc Ativar animação de deslize.
 * @default true
 * @type boolean
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Cursor Rotation Animation
 * @text Rotation Animation
 * @desc Ativar animação de rotação.
 * @default true
 * @type boolean
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Cursor Rotation Speed
 * @text Rotation Speed
 * @desc Definição da velociade de rotação.
 * @default 0.05
 * @parent -> Cursor <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param
 *
 * @param -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 * @desc
 *
 * @param Command Pos 1
 * @desc Definição da posição do comando 1.
 * E.g -     32,32
 * @default 650,460
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 2
 * @desc Definição da posição do comando 2.
 * E.g -     32,32
 * @default 660,490
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 3
 * @desc Definição da posição do comando 3.
 * E.g -     32,32
 * @default 665,520
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 4
 * @desc Definição da posição do comando 4.
 * E.g -     32,32
 * @default 670,550
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 5
 * @desc Definição da posição do comando 5.
 * E.g -     32,32
 * @default 345,498
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 6
 * @desc Definição da posição do comando 6.
 * E.g -     32,32
 * @default 345,530
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 7
 * @desc Definição da posição do comando 7.
 * E.g -     32,32
 * @default 0,192
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 8
 * @desc Definição da posição do comando 8.
 * E.g -     32,32
 * @default 0,224
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 9
 * @desc Definição da posição do comando 9.
 * E.g -     32,32
 * @default 0,256
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @param Command Pos 10
 * @desc Definição da posição do comando 10.
 * E.g -     32,32
 * @default 0,288
 * @parent -> Commands <<<<<<<<<<<<<<<<<<<<<<<
 *
 * @help
 * =============================================================================
 * +++ MOG - Title Picture Commands (v1.6) +++
 * By Moghunter
 * https://atelierrgss.wordpress.com/
 * =============================================================================
 * Adiciona comandos em imagens no lugar da janela.
 * É necessário ter os arquivos:
 *
 * Command_0.png, Command_1.png, Command_2.png , Command_3.png ...
 *
 * Grave as imagens na pasta:
 *
 * img/titles2/
 * =============================================================================
 * Será necessário também uma imagem representando o cursor.
 *
 * Cursor.png
 *
 * ============================================================================
 * - WHAT'S  NEW (version 1.6)
 * ============================================================================
 * (BUG FIX) - Correção de alguns plugin parameters não funcionarem.
 *
 */

//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
var Imported = Imported || {};
Imported.MOG_Picture_Command = true;
var Moghunter = Moghunter || {};

Moghunter.parameters = PluginManager.parameters("MOG_TitlePictureCom");
Moghunter.title_sprite = Moghunter.parameters["Title Sprite"] || false;
Moghunter.title_x = Number(Moghunter.parameters["Title Sprite X-Axis"] || 300);
Moghunter.title_y = Number(Moghunter.parameters["Title Sprite Y-Axis"] || 150);
Moghunter.title_zoomEffect = String(
  Moghunter.parameters["Zoom Effect"] || "true"
);
Moghunter.title_zoomDuration = Number(Moghunter.parameters["Zoom Speed"] || 40);
Moghunter.title_FadeInDuration = Number(
  Moghunter.parameters["Fade-In Duration"] || 40
);
Moghunter.title_comMode = Number(Moghunter.parameters["Animation Mode"] || 2);
Moghunter.title_ComFadeInDuration = Number(
  Moghunter.parameters["Com Fade-In Duration"] || 13
);
Moghunter.title_sideInput = String(
  Moghunter.parameters["Left & Right Input"] || "true"
);
Moghunter.title_subPicture = String(
  Moghunter.parameters["Smart Background"] || "true"
);
Moghunter.title_slideXaxis = Number(
  Moghunter.parameters["Slide X-Axis"] || -100
);
Moghunter.title_slideYaxis = Number(Moghunter.parameters["Slide Y-Axis"] || 0);
Moghunter.title_subPictureX = Number(
  Moghunter.parameters["Background X-Axis"] || 0
);
Moghunter.title_subPictureY = Number(
  Moghunter.parameters["Background Y-Axis"] || 0
);
Moghunter.title_subFadeInDuration = Number(
  Moghunter.parameters["Background Fade-In Duration"] || 90
);
Moghunter.title_cursorVisible = String(
  Moghunter.parameters["Cursor Visible"] || "true"
);
Moghunter.title_cursorSlide = String(
  Moghunter.parameters["Cursor Wave Animation"] || "true"
);
Moghunter.title_cursorX = Number(Moghunter.parameters["Cursor X-Axis"] || 8);
Moghunter.title_cursorY = Number(Moghunter.parameters["Cursor Y-Axis"] || -10);
Moghunter.title_cursorRot = String(
  Moghunter.parameters["Cursor Rotation Animation"] || "true"
);
Moghunter.title_cursorRotSpeed = Number(
  Moghunter.parameters["Cursor Rotation Speed"] || 0.05
);
Moghunter.title_com_pos = [];
for (var i = 0; i < 10; i++) {
  Moghunter.title_com_pos[i] =
    Moghunter.parameters["Command Pos " + String(i + 1)] || null;
}

//=============================================================================
// ** Window_TitleCommand
//=============================================================================

//==============================
// * updatePlacement
//==============================
var _alias_mog_title_picture_commands_updatePlacement =
  Scene_Title.prototype.updatePlacement;
Window_TitleCommand.prototype.updatePlacement = function () {
  this.x = -Graphics.boxWidth;
  this.y = -Graphics.boxheight;
  this.visible = false;
};

//=============================================================================
// ** Scene Base
//=============================================================================

//==============================
// ** create Hud Field
//==============================
Scene_Base.prototype.createHudField = function () {
  this._hudField = new Sprite();
  this._hudField.z = 10;
  this.addChild(this._hudField);
};

//==============================
// ** sort MZ
//==============================
Scene_Base.prototype.sortMz = function () {
  this._hudField.children.sort(function (a, b) {
    return a.mz - b.mz;
  });
};

//=============================================================================
// ** Scene Title
//=============================================================================

//==============================
// * Create
//==============================
var _mog_title_picture_commands_create = Scene_Title.prototype.create;
Scene_Title.prototype.create = function () {
  _mog_title_picture_commands_create.call(this);
  if (!this._hudField) {
    this.createHudField();
  }
  this._sideInput = String(Moghunter.title_sideInput) == "true" ? true : false;
  this._comSave = this._commandWindow.isContinueEnabled();
  this._comInitVis = true;
  this.createComSprites();
  this.sortMz();
};

//==============================
// * set tcp
//==============================
Scene_Title.prototype.set_tcp = function (value) {
  if (!value) {
    return null;
  }
  var s = value.split(",");
  if (!s[0] || !s[1]) {
    return null;
  }
  return [Number(s[0]), Number(s[1])];
};

//==============================
// * create Com Sprites
//==============================
Scene_Title.prototype.createComSprites = function (value) {
  if (Moghunter.title_comMode == 1) {
    this._com_pulse = true;
    this._comshake = false;
  } else if (Moghunter.title_comMode == 2) {
    this._com_pulse = false;
    this._comshake = true;
  } else {
    this._com_pulse = false;
    this._comshake = false;
  }
  this.createPictureCommands();
  if (String(Moghunter.title_subPicture) == "true") {
    this.createSubPicture();
  }
  if (String(Moghunter.title_cursorVisible) == "true") {
    this.createCursorCommand();
  }
  if (String(Moghunter.title_sprite) == "true") {
    this.createTitleSprite();
  }
};

//==============================
// * Create Cursor Command
//==============================
Scene_Title.prototype.createCursorCommand = function () {
  this._cursorSlide = [0, 0, 0, false];
  if (String(Moghunter.title_cursorSlide) == "true") {
    this._cursorSlide[3] = true;
  }
  this._cursor = new Sprite(ImageManager.loadTitle2("Cursor"));
  this._cursor.anchor.x = 0.5;
  this._cursor.anchor.y = 0.5;
  this._cursor.org = [Moghunter.title_cursorX, Moghunter.title_cursorY];
  if (this._cursorSlide[3]) {
    this._cursor.org[0] -= 5;
  }
  this._cursor.opacity = 0;
  this._cursor.mz = 500;
  this._cursor.rot = [true, 0.05];
  this._cursor.rot[0] =
    String(Moghunter.title_cursorRot) == "true" ? true : false;
  this._cursor.rot[1] = Moghunter.title_cursorRotSpeed;
  this._hudField.addChild(this._cursor);
};

//==============================
// * Com Sprite
//==============================
Scene_Title.prototype.comSprite = function () {
  return this._com_sprites[this._commandWindow._index];
};

//==============================
// * update Cursor
//==============================
Scene_Title.prototype.updateCursor = function () {
  if (!this._comInitVis) {
    return;
  }
  if (this._cursorSlide[3]) {
    this.updateCursorSlide();
  }
  if (this._cursor.rot[0]) {
    this.updateCursorRotation();
  }
  this._cursor.opacity += 5;
  var nx =
    this.comSprite().x -
    this.comSprite().bitmap.width / 2 -
    this._cursor.width / 2 +
    this._cursorSlide[0] -
    this.comSprite().shake[0] +
    this._cursor.org[0]; //+ (this._cursor.width / 2)  + this._cursorSlide[0];
  var ny =
    this.comSprite().y -
    this.comSprite().bitmap.height / 2 +
    this._cursor.height / 2 +
    this._cursor.org[1];
  this._cursor.x = this.cursorMoveto(this._cursor.x, nx, 10);
  this._cursor.y = this.cursorMoveto(this._cursor.y, ny, 10);
};

//==============================
// * Uodate Cursor Rotation
//==============================
Scene_Title.prototype.updateCursorRotation = function () {
  this._cursor.rotation += this._cursor.rot[1];
};

//==============================
// * update Cursor Slide
//==============================
Scene_Title.prototype.updateCursorSlide = function () {
  this._cursorSlide[1]++;
  if (this._cursorSlide[1] < 3) {
    return;
  }
  this._cursorSlide[1] = 0;
  this._cursorSlide[2]++;
  if (this._cursorSlide[2] < 15) {
    this._cursorSlide[0]++;
  } else if (this._cursorSlide[2] < 30) {
    this._cursorSlide[0]--;
  } else {
    this._cursorSlide[0] = 0;
    this._cursorSlide[2] = 0;
  }
};

//==============================
// * Sprite Move To
//==============================
Scene_Title.prototype.cursorMoveto = function (value, real_value, speed) {
  if (value == real_value) {
    return value;
  }
  var dnspeed = 3 + Math.abs(value - real_value) / speed;
  if (value > real_value) {
    value -= dnspeed;
    if (value < real_value) {
      value = real_value;
    }
  } else if (value < real_value) {
    value += dnspeed;
    if (value > real_value) {
      value = real_value;
    }
  }
  return Math.floor(value);
};

//==============================
// * Create Picture Commands
//==============================
Scene_Title.prototype.createPictureCommands = function () {
  this._com_position = [];
  for (var i = 0; i < 10; i++) {
    this._com_position[i] = this.set_tcp(Moghunter.title_com_pos[i]);
  }
  var _com_index_old = -2;
  if (this._subPic) {
    this.createSubPicture();
  }
  this._csel = false;
  this._com_int = true;
  this._com_pictures = [];
  this._com_sprites = [];
  this._com_pictures_data = [];
  for (i = 0; i < this._commandWindow._list.length; i++) {
    this._com_pictures[i] = ImageManager.loadTitle2("Command_" + i);
    this._com_sprites[i] = new Sprite(this._com_pictures[i]);
    this._com_sprites[i].org = [0, 0];
    this._com_sprites[i].shake = [0, 0, 0];
    this._com_sprites[i].pulse = [0, 0, 0];
    this._com_sprites[i].mz = i + 200;
    this._com_sprites[i].wait = 0;
    this._com_sprites[i].enabled = true;
    this._com_sprites[i].anchor.x = 0.5;
    this._com_sprites[i].anchor.y = 0.5;
    this._com_sprites[i].size = [0, 0];
    this._hudField.addChild(this._com_sprites[i]);
  }
};

//==============================
// * Create Sub Picture
//==============================
Scene_Title.prototype.createSubPicture = function () {
  this._subPictures = [];
  for (i = 0; i < this._commandWindow._list.length; i++) {
    this._subPictures[i] = ImageManager.loadTitle2("Sub_" + i);
  }
  this._subPic = new Sprite();
  this._subPic.x = Moghunter.title_subPictureX;
  this._subPic.y = Moghunter.title_subPictureY;
  this._subPic.mz = 130;
  this._subPic.index = -1;
  this._subPic.opacity = 0;
  this._subPic.wait = Moghunter.title_subFadeInDuration;
  this._hudField.addChild(this._subPic);
};

//==============================
// * Refresh Com Sub Pic
//==============================
Scene_Title.prototype.refreshComSubPic = function () {
  this._subPic.index = this._commandWindow._index;
  this._subPic.opacity = 0;
  this._subPic.bitmap = this._subPictures[this._subPic.index];
};

//==============================
// * update ComSubPic
//==============================
Scene_Title.prototype.updateComSubPic = function () {
  if (this._subPic.index != this._commandWindow._index) {
    this.refreshComSubPic();
  }
  if (this._subPic.wait > 0) {
    this._subPic.wait--;
    return;
  }
  this._subPic.opacity += 2;
};

//==============================
// * Refresh Picture Command
//==============================
Scene_Title.prototype.refresh_picture_command = function () {
  this._com_index_old = this._commandWindow._index;
  for (i = 0; i < this._com_sprites.length; i++) {
    if (this._commandWindow._index != i) {
      var chr = this._com_pictures[i].height / 2;
      this._com_sprites[i].shake = [0, 0, 0];
    } else {
      var chr = 0;
      this._com_sprites[i].shake = [0, 10, 0];
    }
    this.cpsx = [this._com_position[i][0], this._com_position[i][1]];
    if (this._commandWindow._list[i].symbol == "continue" && !this._comSave) {
      this._com_sprites[i].enabled = false;
    }
    var cw = this._com_sprites[i].bitmap.width / 2;
    var ch = this._com_sprites[i].bitmap.height / 2;
    this._com_sprites[i].size = [cw, ch];
    this._com_sprites[i].setFrame(
      0,
      chr,
      this._com_pictures[i].width,
      this._com_pictures[i].height / 2
    );
    this._com_sprites[i].x = this.cpsx[0] + cw;
    this._com_sprites[i].y = this.cpsx[1] + ch;
    this._com_sprites[i].org = [this._com_sprites[i].x, this._com_sprites[i].y];
    this._com_pictures_data[i] = [];
    this._com_pictures_data[i][0] = this._com_sprites[i].x - cw;
    this._com_pictures_data[i][1] = this._com_sprites[i].x + cw;
    this._com_pictures_data[i][2] = this._com_sprites[i].y - ch / 2;
    this._com_pictures_data[i][3] = this._com_sprites[i].y + ch / 2;
    this._com_sprites[i].pulse = [0, 0, 0];
    if (!this._comshake) {
      this._com_sprites[i].shake[1] = 0;
    }
    if (this._com_int) {
      this._com_sprites[i].x += Moghunter.title_slideXaxis;
      this._com_sprites[i].y += Moghunter.title_slideYaxis;
      this._com_sprites[i].shake[1] = 0;
      this._com_sprites[i].wait = 10 + Moghunter.title_ComFadeInDuration * i;
      this._com_sprites[i].opacity = 0;
    }
  }
  this._com_int = false;
};

//==============================
// * Update Com Input
//==============================
Scene_Title.prototype.updateComInput = function () {
  if (TouchInput.isTriggered()) {
    for (i = 0; i < this._com_sprites.length; i++) {
      if (this.on_picture_com(i) && !this._csel) {
        this._commandWindow._index = i;
        this._commandWindow.processOk();
        if (this._commandWindow.isCommandEnabled(i)) {
          this._csel = true;
        }
      }
    }
  }
  if (this._sideInput) {
    this.updateComSideInput();
  }
};

//==============================
// * Update Com Side Inout
//==============================
Scene_Title.prototype.updateComSideInput = function () {
  if (Input.isRepeated("right")) {
    this.addTitleComIndex(1);
  } else if (Input.isRepeated("left")) {
    this.addTitleComIndex(-1);
  }
};

//==============================
// * add Title ComIndex
//==============================
Scene_Title.prototype.addTitleComIndex = function (value) {
  SoundManager.playCursor();
  var maxIndex = this._commandWindow._list.length - 1;
  this._commandWindow._index += value;
  if (this._commandWindow._index < 0) {
    this._commandWindow._index = maxIndex;
  } else if (this._commandWindow._index > maxIndex) {
    this._commandWindow._index = 0;
  }
};

//==============================
// * Update Com Shake
//==============================
Scene_Title.prototype.updateComShake = function (sprite) {
  sprite.shake[2]++;
  if (sprite.shake[2] < 2) {
    return;
  }
  sprite.shake[2] = 0;
  sprite.shake[1]--;
  sprite.shake[0] = -2 + Math.randomInt(4);
  if (sprite.shake[1] == 0) {
    sprite.shake[0] = 0;
  }
};

//==============================
// * Update Com Pulse
//==============================
Scene_Title.prototype.updateComPulse = function (sprite, enable) {
  if (enable) {
    if (sprite.pulse[0] == 0) {
      sprite.scale.x += 0.01;
      if (sprite.scale.x >= 1.25) {
        sprite.scale.x = 1.25;
        sprite.pulse[0] = 1;
      }
    } else {
      sprite.scale.x -= 0.01;
      if (sprite.scale.x <= 1.0) {
        sprite.scale.x = 1.0;
        sprite.pulse[0] = 0;
      }
    }
  } else {
    if (sprite.scale.x > 1.0) {
      sprite.scale.x -= 0.01;
    }
  }
  sprite.scale.y = sprite.scale.x;
};

//==============================
// * Update Picture Commands
//==============================
Scene_Title.prototype.updateCommandsPic = function (sprite, enable) {
  if (sprite.wait > 0) {
    sprite.wait--;
    return;
  }
  if (this._subPic) {
    this.updateComSubPic();
  }
  if (sprite.shake[1] > 0) {
    this.updateComShake(sprite);
  }
  if (this._com_pulse) {
    this.updateComPulse(sprite, enable);
  }
  var nx = sprite.org[0] + sprite.shake[0];
  var ny = sprite.org[1];
  sprite.x = this.cursorMoveto(sprite.x, nx, 60);
  sprite.y = this.cursorMoveto(sprite.y, ny, 60);
  sprite.opacity += 5;
  if (!sprite.enabled && sprite.opacity > 160) {
    sprite.opacity = 160;
  }
};

//==============================
// * On Picture Com
//==============================
Scene_Title.prototype.on_picture_com = function (index) {
  if (TouchInput.x < this._com_pictures_data[index][0]) {
    return false;
  }
  if (TouchInput.x > this._com_pictures_data[index][1]) {
    return false;
  }
  if (TouchInput.y < this._com_pictures_data[index][2]) {
    return false;
  }
  if (TouchInput.y > this._com_pictures_data[index][3]) {
    return false;
  }
  return true;
};

//==============================
// * Create Title Sprite
//==============================
Scene_Title.prototype.createTitleSprite = function () {
  if (this._gameTitleSprite) {
    this.removeChild(this._gameTitleSprite);
  }
  this._gameTitleSprite = new Sprite(ImageManager.loadTitle2("Title"));
  this._hudField.addChild(this._gameTitleSprite);
  this._gameTitleSprite.mz = 250;
  this._gameTitleSprite.x = Moghunter.title_x;
  this._gameTitleSprite.y = Moghunter.title_y;
  this._gameTitleSprite.anchor.x = 0.5;
  this._gameTitleSprite.anchor.y = 0.5;
  this._gameTitleSprite.wait = 30;
  this._gameTitleSprite.opacity = 0;
  this._gameTitleSprite.zoomEffect =
    Moghunter.title_zoomEffect == "true" ? true : false;
  this._gameTitleSprite.fadeInDuration = Moghunter.title_zoomDuration;
  this._gameTitleSprite.zoomSpd = 0.5 / this._gameTitleSprite.fadeInDuration;
  this._gameTitleSprite.opcSpd = 150 / this._gameTitleSprite.fadeInDuration;
  if (this._gameTitleSprite.zoomEffect) {
    this._gameTitleSprite.scale.x = 1.5;
    this._gameTitleSprite.scale.y = this._gameTitleSprite.scale.x;
  }
};

//==============================
// * update Title Sprite
//==============================
Scene_Title.prototype.updateTitleSprite = function () {
  if (this._gameTitleSprite.wait > 0) {
    this._gameTitleSprite.wait--;
    return;
  }
  this._gameTitleSprite.opacity += this._gameTitleSprite.opcSpd;
  if (this._gameTitleSprite.scale.x > 1.0) {
    this._gameTitleSprite.scale.x -= this._gameTitleSprite.zoomSpd;
    if (this._gameTitleSprite.scale.x <= 1.0) {
      this._gameTitleSprite.scale.x = 1.0;
    }
  }
  this._gameTitleSprite.scale.y = this._gameTitleSprite.scale.x;
};

//==============================
// * Update Picture Commands
//==============================
Scene_Title.prototype.updatePictureCommands = function () {
  this._comInitVis = true;
  for (i = 0; i < this._com_sprites.length; i++) {
    var sprite = this._com_sprites[i];
    var enable = i == this._commandWindow._index ? true : false;
    this.updateCommandsPic(sprite, enable);
  }
  if (!this._comInitVis) {
    return;
  }
  if (this._com_index_old != this._commandWindow._index) {
    this.refresh_picture_command();
  }
  this.updateComInput();
  this.updateTitleSprite();
  if (this._cursor) {
    this.updateCursor();
  }
};

//==============================
// * Update
//==============================
var _mog_title_picture_commands_update = Scene_Title.prototype.update;
Scene_Title.prototype.update = function () {
  _mog_title_picture_commands_update.call(this);
  this.updatePictureCommands();
};


code:
//=============================================================================
// MOG_TitleSplashScreen.js
//=============================================================================

/*:
 * @plugindesc (v1.1 *) Adiciona logos antes da tela de título.
 * @author Moghunter
 *
 * @param Number of Logos
 * @desc Quantidade de logos.
 * (Default = 1)
 * @default 1
 * @type number
 *
 * @param Slash Duration
 * @desc Duração do logo.
 * (Default = 60)
 * @default 60
 * @type number
 *
 * @param Splash Fade Duration
 * @desc Velocidade do fade.
 * (Default = 2)
 * @default 2
 * @type number
 *
 * @param Full Screen Mode
 * @desc Ativar o modo em tela cheia. (true  / false)
 * (Default = false)
 * @default false
 * @type boolean
 *
 * @help
 * =============================================================================
 * +++ MOG - Title Splash Screen (v1.1) +++
 * By Moghunter
 * https://atelierrgss.wordpress.com/
 * =============================================================================
 * Adiciona multiplos logos antes da tela de título.
 * Serâo necessários os arquivos.
 *
 * Splash_INDEX.png
 *
 * no lugar da INDEX coloque a numeração da imagem.
 *
 * Splash_0.png
 * Splash_1.png
 * Splash_2.png
 * ...
 *
 * Coloque as imagens na pasta:
 *
 * img/titles2/
 *
 * ============================================================================
 * - WHAT'S  NEW (version 1.1)
 * ============================================================================
 * - (NEW) - Plugins parameters compatíveis com RM1.5+
 */

//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
var Imported = Imported || {};
Imported.MOG_TitleSplashScreen = true;
var Moghunter = Moghunter || {};

Moghunter.parameters = PluginManager.parameters("MOG_TitleSplashScreen");
Moghunter.title_splash_number = Number(
  Moghunter.parameters["Number of Logos"] || 1
);
Moghunter.title_splash_duration = Number(
  Moghunter.parameters["Slash Duration"] || 60
);
Moghunter.title_splash_fade_speed = Number(
  Moghunter.parameters["Splash Fade Duration"] || 2
);
Moghunter.title_full_screen_mode =
  Moghunter.parameters["Full Screen Mode"] || false;

//=============================================================================
// ** Scene Boot
//=============================================================================

//==============================
// * Start
//==============================
var _alias_mog_title_splash_screen_boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function () {
  if (Moghunter.title_full_screen_mode == "true") {
    Graphics._requestFullScreen();
  }
  if (!DataManager.isBattleTest() && !DataManager.isEventTest()) {
    SceneManager.goto(Scene_Splash_Screen);
    return;
  }
  _alias_mog_title_splash_screen_boot_start.call(this);
};

//=============================================================================
// ** Scene Splash Screen
//=============================================================================
function Scene_Splash_Screen() {
  this.initialize.apply(this, arguments);
}
Scene_Splash_Screen.prototype = Object.create(Scene_Base.prototype);
Scene_Splash_Screen.prototype.constructor = Scene_Splash_Screen;

//==============================
// * Initialize
//==============================
Scene_Splash_Screen.prototype.initialize = function () {
  Scene_Base.prototype.initialize.call(this);
};

//==============================
// * Create
//==============================
Scene_Splash_Screen.prototype.create = function () {
  Scene_Base.prototype.create.call(this);
  this._splash_data = [
    0,
    0,
    Math.max(Moghunter.title_splash_duration, 1),
    Math.max(Moghunter.title_splash_fade_speed, 1),
  ];
  this._splash_img = [];
  this._splash_sprite = new Sprite();
  this._splash_sprite.anchor.x = 0.5;
  this._splash_sprite.anchor.y = 0.5;
  this._splash_sprite.x = Graphics.boxWidth / 2;
  this._splash_sprite.y = Graphics.boxHeight / 2;
  this.addChild(this._splash_sprite);
  for (i = 0; i < Moghunter.title_splash_number; i++) {
    this._splash_img.push(ImageManager.loadTitle2("Splash_" + i));
  }
  this.refresh_splash_screen();
};

//==============================
// * Refresh Splash Screen
//==============================
Scene_Splash_Screen.prototype.refresh_splash_screen = function () {
  if (this._splash_data[0] >= this._splash_img.length) {
    AudioManager.stopMe();
    DataManager.setupNewGame();
    SceneManager.goto(Scene_Title);
    Window_TitleCommand.initCommandPosition();
    return;
  }
  this._splash_sprite.bitmap = this._splash_img[this._splash_data[0]];
  this._splash_sprite.opacity = 0;
  this._splash_data[0] += 1;
  this._splash_data[1] = this._splash_data[2];
};

//==============================
// * Start
//==============================
Scene_Splash_Screen.prototype.start = function () {
  Scene_Base.prototype.start.call(this);
  this.startFadeIn(this.fadeSpeed(), false);
};

//==============================
// * Update
//==============================
Scene_Splash_Screen.prototype.update = function () {
  Scene_Base.prototype.update.call(this);
  if (this._splash_data[1] <= 0) {
    this._splash_sprite.opacity -= this._splash_data[3];
    if (Input.isTriggered("ok") || TouchInput.isTriggered()) {
      this._splash_data[0] = this._splash_img.length;
    }
    if (this._splash_sprite.opacity <= 0) {
      this.refresh_splash_screen();
    }
  } else {
    this._splash_sprite.opacity += this._splash_data[3];
    if (
      (Input.isTriggered("ok") || TouchInput.isTriggered()) &&
      this._splash_sprite.opacity > 60
    ) {
      this._splash_data[1] = 0;
      this._splash_data[0] = this._splash_img.length;
    }
    if (this._splash_sprite.opacity >= 255) {
      this._splash_data[1] -= 1;
    }
  }
};

repo_name: dazed/translations

license: unknown


code:
//===========================================================================
// MPI_PictureOnWindow.js
//===========================================================================

/*:
 * @plugindesc 指定のピクチャをウインドウより手前に表示します。
 * @author 奏ねこま（おとぶき ねこま）
 *
 * @param ピクチャ番号
 * @desc ウインドウよりも手前に表示するピクチャの番号を指定して下さい。カンマ区切りで複数指定できます。
 * @default
 *
 * @help
 * [ 概要 ] ...
 *  プラグインパラメータで指定した番号のピクチャが、ウインドウよりも手前に表示さ
 *  れるようになります。
 *
 * [ プラグインコマンド ] ...
 *  プラグインコマンドはありません。
 *
 * [ 利用規約 ] ................................................................
 *  ・本プラグインの利用は、RPGツクールMV/RPGMakerMVの正規ユーザーに限られます。
 *  ・商用、非商用、有償、無償、一般向け、成人向けを問わず、利用可能です。
 *  ・利用の際、連絡や報告は必要ありません。また、製作者名の記載等も不要です。
 *  ・プラグインを導入した作品に同梱する形以外での再配布、転載はご遠慮ください。
 *  ・不具合対応以外のサポートやリクエストは、基本的に受け付けておりません。
 *  ・本プラグインにより生じたいかなる問題についても、一切の責任を負いかねます。
 * [ 改訂履歴 ] ................................................................
 *   Version 1.00  2017/01/15  First edition.
 * -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 *  Web Site: http://makonet.sakura.ne.jp/rpg_tkool/
 *  Twitter : https://twitter.com/koma_neko
 *  Copylight (c) 2017 Nekoma Otobuki
 */

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

var Makonet = Makonet || {};
Makonet.POW = {};

(function () {
  "use strict";

  var MPD = Makonet.POW;
  MPD.product = "MPI_PictureOnWindow";
  MPD.parameters = PluginManager.parameters(MPD.product);
  MPD.pictureId = MPD.parameters["ピクチャ番号"]
    .trim()
    .split(/ *, */)
    .map(function (value) {
      return +value;
    });

  var _ = MPD.product;

  //==============================================================================
  // Spriteset_Base
  //==============================================================================

  (function (o, p) {
    var f = o[p];
    o[p] = function () {
      f.apply(this, arguments);
      this._pictureContainer.children.forEach(function (picture) {
        if (~MPD.pictureId.indexOf(picture._pictureId)) {
          this._pictureContainer.removeChild(picture);
        }
      }, this);
    };
  })(Spriteset_Base.prototype, "createPictures");

  //==============================================================================
  // Scene_Base
  //==============================================================================

  (function (o, p) {
    var f = o[p];
    o[p] = function () {
      f.apply(this, arguments);
      var width = Graphics.boxWidth;
      var height = Graphics.boxHeight;
      var x = (Graphics.width - width) / 2;
      var y = (Graphics.height - height) / 2;
      var sprite = new Sprite();
      sprite.setFrame(x, y, width, height);
      MPD.pictureId.forEach(function (id) {
        sprite.addChild(new Sprite_Picture(id));
      });
      this.addChild(sprite);
    };
  })(Scene_Base.prototype, "createWindowLayer");
})();


code:
//=============================================================================
// MPP_ChoiceEX.js
//=============================================================================
// Copyright (c) 2015-2019 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
 * @plugindesc 【ver.3.11】選択肢の機能拡張
 * @author 木星ペンギン
 *
 * @help ※[]内は未設定でも動作します。
 * プラグインコマンド:
 *   ChoicePos x y[ row]    # 選択肢の位置(x,y)と行数(row)指定
 *   ChoiceVariableId n     # 選択肢のデフォルト位置を変数n番にする
 *   ChoiceRect x y width height
 *                          # 選択肢の座標とサイズを指定
 *   ChoiceUnderMessage     # 選択肢をメッセージの下に表示
 *
 * ※ プラグインコマンドにて指定する値には変数が使用できます。
 *    v[n] と記述することでn番の変数の値を参照します。
 *
 * 注釈:
 *   選択肢ヘルプ             # 各項目の下に設定することでヘルプを表示させる
 *
 * 選択肢テキスト:
 *   if(条件)                # 条件が偽になると項目が表示されなくなる
 *   en(条件)                # 条件が偽になると項目が選択不可
 *
 * ================================================================
 * ▼ 使い方
 * --------------------------------
 *  〇 選択肢を増やす
 *   イベントコマンド『選択肢の表示』を続けて配置すると
 *   一つの選択肢にまとめられます。
 *   まとめたくない場合は、間に注釈などを入れることで
 *   通常通り分けることができます。
 *
 *   『デフォルト』の処理は、なし以外を設定したものが適用されます。
 *   『デフォルト』の処理が複数ある場合、
 *   後に設定された選択肢のものが適用されます。
 *
 *   『キャンセル』の処理は、禁止以外を設定したものが適用されます。
 *   『キャンセル』の処理が複数ある場合、
 *   後に設定された選択肢のものが適用されます。
 *
 *  『背景』と『ウィンドウ位置』は後の選択肢のものが適用されます。
 *
 *
 * ================================================================
 * ▼ プラグインコマンド 詳細
 * --------------------------------
 *  〇 ChoicePos x y[ row]
 *      x   : 選択肢ウィンドウのX座標
 *      y   : 選択肢ウィンドウのY座標
 *      row : 選択肢ウィンドウの行数。未設定の場合はすべて表示
 *
 *   次に表示する選択肢の位置(x,y)と行数(row)指定します。
 *
 * --------------------------------
 *  〇 ChoiceVariableId n
 *      n : 変数番号
 *
 *   次に表示する選択肢のデフォルト位置を変数の値にします。
 *   さらに現在のカーソル位置を変数に入れます。
 *
 *   カーソル位置は最初の選択肢が上から0～5、次の選択肢は10～15と、
 *   選択肢毎に+10されます。
 *
 *   変数に入った値の項目が表示されない場合、なしと同じ処理をします。
 *
 * --------------------------------
 *  〇 ChoiceRect x y width height
 *      x      : X座標
 *      y      : Y座標
 *      width  : 幅
 *      height : 高さ
 *
 *   次に表示する選択肢の座標とサイズを指定します。
 *
 *   各項目、未設定もしくは-1を指定した場合、通常の値が適用されます。
 *
 * --------------------------------
 *  〇 ChoiceUnderMessage
 *
 *   次に表示する選択肢をメッセージウィンドウ内に表示させます。
 *
 *   この機能は[文章の表示]と併用しなければ機能しません。
 *   [文章の表示]の前に実行してください。
 *
 *   選択肢ウィンドウの[背景]は設定したものが適用されます。
 *
 *
 * ================================================================
 * ▼ 選択肢テキスト 詳細
 * --------------------------------
 *  〇 項目が表示される条件の設定
 *   選択肢の文章中に
 *     if(条件)
 *   と入れ、その条件が偽になると項目が表示されなくなります。
 *
 *   『デフォルト』の項目が表示されない場合の動作は、
 *   プラグインパラメータの[Disabled Index]にて設定できます。
 *
 *   『キャンセル』の項目が表示されない場合、禁止と同じ処理をします。
 *
 *   条件内では s でスイッチ、v で変数を参照できます。
 *
 *     例：if(s[1]) とした場合
 *          => スイッチ１番がONで表示、OFFで非表示。
 *        if(!s[2]) とした場合
 *          => スイッチ２番がOFFで表示、ONで非表示。
 *        if(v[5]>0) とした場合
 *          => 変数５番が0より大きければ表示、0以下で非表示。
 *
 *     変数で使える不等号
 *       === : 等しい
 *       !== : 等しくない
 *       <   : より小さい
 *       <=  : より小さいまたは等しい
 *       >   : より大きい
 *       >=  : より大きいまたは等しい
 *
 *     条件式はeval関数で処理されているため、他演算子も使用できます。
 *
 * --------------------------------
 *  〇 項目を半透明で表示する条件の設定
 *   選択肢の文章中に
 *     en(条件)
 *   と入れ、その条件が偽になると項目が半透明で表示されます。
 *   半透明となった項目は選択できなくなります。
 *
 *   条件は上の『項目が表示される条件の設定』と同じです。
 *
 *   『キャンセル』の項目が半透明の場合、ブザーが鳴ります。
 *
 *
 * ================================================================
 * ▼ プラグインパラメータ 詳細
 * --------------------------------
 *  〇 Disabled Index
 *
 *   [デフォルト]となる項目がif(条件)により非表示となった場合、
 *   デフォルト位置をどこにするかを設定します。
 *
 *     none : [なし]と同じ
 *     top  : 先頭の項目
 *
 * --------------------------------
 *  〇 Plugin Commands / Event Comment
 *
 *   プラグインコマンドや注釈で使用するコマンドは、
 *   プラグインパラメータから変更できます。
 *
 *   コマンドを短くしたり日本語にしたりなどして、
 *   自分が使いやすいようにしてください。
 *
 *   プラグインコマンドのみ、変更後もデフォルトのコマンドでも動作します。
 *
 *
 * ================================================================
 * ▼ その他
 * --------------------------------
 *  〇 プラグインコマンドの実行タイミング
 *   プラグインコマンドを使用する場合、[選択肢の表示]の前に実行するのが
 *   好ましいです。
 *   ただし、メッセージウィンドウを表示したまま選択肢の処理を実行したい場合、
 *   [文章の表示]より前にプラグインコマンドを実行してください。
 *
 * --------------------------------
 *  〇 ヘルプメッセージの表示
 *   各選択肢項目の下に注釈で以下の文字列を入れると、
 *   続きの文章をヘルプメッセージとしてカーソルを合わせたときに
 *   標示させることができます。
 *
 *     選択肢ヘルプ
 *
 *   ※注意点
 *    ヘルプメッセージは[文章の表示]と同じ機能を使っているため、
 *    制御文字が使用できます。
 *    ただし、\!と\^は使用できません。
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param maxPageRow
 * @type number
 * @desc 1ページに表示される行数
 * @default 6
 *
 * @param Disabled Index
 * @type select
 * @option none
 * @option top
 * @desc [デフォルト]となる選択肢が表示されない場合のデフォルト位置
 * @default none
 *
 *
 * @param === Command ===
 *
 * @param Plugin Commands
 * @type struct<Plugin>
 * @desc プラグインコマンド名
 * @default {"ChoicePos":"ChoicePos","ChoiceVariableId":"ChoiceVariableId","ChoiceRect":"ChoiceRect","ChoiceUnderMessage":"ChoiceUnderMessage"}
 * @parent === Command ===
 *
 * @param Event Comment
 * @type struct<EventComment>
 * @desc イベントの注釈で使うコマンド名
 * @default {"ChoiceHelp":"選択肢ヘルプ"}
 * @parent === Command ===
 *
 */

/*~struct~Plugin:
 * @param ChoicePos
 * @desc 選択肢の位置(x,y)と行数(row)指定
 * @default ChoicePos
 *
 * @param ChoiceVariableId
 * @desc 選択肢のデフォルト位置を変数n番にする
 * @default ChoiceVariableId
 *
 * @param ChoiceRect
 * @desc 選択肢の座標とサイズ(x,y,width,height)指定
 * @default ChoiceRect
 *
 * @param ChoiceUnderMessage
 * @desc 選択肢をメッセージの下に表示
 * @default ChoiceUnderMessage
 *
 */

/*~struct~EventComment:
 * @param ChoiceHelp
 * @desc 各項目の下に設定することでヘルプを表示させる
 * @default 選択肢ヘルプ
 */

(function () {
  const MPPlugin = {};

  {
    let parameters = PluginManager.parameters("MPP_ChoiceEX");

    MPPlugin.maxPageRow = Number(parameters["maxPageRow"]);
    MPPlugin.DisabledIndex = parameters["Disabled Index"];

    MPPlugin.PluginCommands = JSON.parse(parameters["Plugin Commands"]);
    MPPlugin.EventComment = JSON.parse(parameters["Event Comment"]);
  }

  const Alias = {};

  //-----------------------------------------------------------------------------
  // Game_Message

  //15
  Alias.GaMe_clear = Game_Message.prototype.clear;
  Game_Message.prototype.clear = function () {
    Alias.GaMe_clear.apply(this, arguments);
    this._choiceEnables = [];
    this._choiceResults = [];
    this._helpTexts = [];
    this._choiceX = -1;
    this._choiceY = -1;
    this._choiceWidth = -1;
    this._choiceHeight = -1;
    this._choiceMaxRow = MPPlugin.maxPageRow;
    this._choiceVariableId = 0;
    this.choiceUnderMes = false;
  };

  Game_Message.prototype.setChoiceEnables = function (enables) {
    this._choiceEnables = enables;
  };

  Game_Message.prototype.choiceEnables = function () {
    return this._choiceEnables;
  };

  Game_Message.prototype.setChoiceResults = function (results) {
    this._choiceResults = results;
  };

  Game_Message.prototype.setChoiceHelpTexts = function (texts) {
    this._helpTexts = texts;
  };

  Game_Message.prototype.isHelp = function () {
    return this._helpTexts.length > 0;
  };

  Game_Message.prototype.setChoicePos = function (x, y, row) {
    this._choiceX = x;
    this._choiceY = y;
    this._choiceWidth = -1;
    this._choiceHeight = -1;
    this._choiceMaxRow = row;
  };

  Game_Message.prototype.setChoiceRect = function (x, y, width, height) {
    this._choiceX = x;
    this._choiceY = y;
    this._choiceWidth = width;
    this._choiceHeight = height;
  };

  Game_Message.prototype.setChoiceVariableId = function (id) {
    this._choiceVariableId = id;
  };

  Game_Message.prototype.shiftLine = function (height) {
    this._choiceY += height;
    this._choiceHeight -= height;
  };

  //-----------------------------------------------------------------------------
  // Game_Interpreter

  //336
  Game_Interpreter.prototype.setupChoices = function (params) {
    var data = {
      choices: [],
      enables: [],
      results: [],
      helpTexts: [],
      cancelType: -1,
      defaultType: -1,
      positionType: 0,
      background: 0,
    };
    data = this.addChoices(params, this._index, data, 0);
    if (data.choices.length > 0) {
      var helpTexts = [];
      if (data.helpTexts.length > 0) {
        helpTexts = data.results.map((i) => data.helpTexts[i]);
      }
      var cancelType = -1;
      if (
        data.cancelType.mod(10) === 8 ||
        data.results.contains(data.cancelType)
      ) {
        data.results.push(data.cancelType);
        cancelType = data.choices.length;
      }
      var index = data.defaultType;
      if ($gameMessage._choiceVariableId > 0) {
        index = $gameVariables.value($gameMessage._choiceVariableId);
      }
      var defaultType = data.results.indexOf(index);
      if (index >= 0 && defaultType < 0 && MPPlugin.DisabledIndex === "top") {
        defaultType = 0;
      }
      $gameMessage.setChoices(data.choices, defaultType, cancelType);
      $gameMessage.setChoiceEnables(data.enables);
      $gameMessage.setChoiceResults(data.results);
      $gameMessage.setChoiceHelpTexts(helpTexts);
      $gameMessage.setChoiceBackground(data.background);
      $gameMessage.setChoicePositionType(data.positionType);
      $gameMessage.setChoiceCallback(
        (n) => (this._branch[this._indent] = data.results[n])
      );
    } else {
      this._branch[this._indent] = -1;
    }
  };

  Game_Interpreter.prototype.addChoices = function (params, i, data, d) {
    var regIf = /\s*if\((.+?)\)/;
    var regEn = /\s*en\((.+?)\)/;
    for (var n = 0; n < params[0].length; n++) {
      var str = params[0][n];
      if (regIf.test(str)) {
        str = str.replace(regIf, "");
        if (RegExp.$1 && !this.evalChoice(RegExp.$1)) continue;
      }
      var enable = true;
      if (regEn.test(str)) {
        str = str.replace(regEn, "");
        enable = this.evalChoice(RegExp.$1);
      }
      data.choices.push(str);
      data.enables.push(enable);
      data.results.push(n + d);
    }
    var cancelType = params[1];
    if (cancelType !== -1) {
      data.cancelType = cancelType + d;
    }
    var defaultType = params.length > 2 ? params[2] : 0;
    if (defaultType >= 0) {
      data.defaultType = defaultType + d;
    }
    data.positionType = params.length > 3 ? params[3] : 2;
    data.background = params.length > 4 ? params[4] : 0;
    var command;
    for (;;) {
      i++;
      command = this._list[i];
      if (!command) break;
      if (command.indent === this._indent) {
        if (command.code === 402) {
          this.getHelpText(command.parameters[0] + d, i + 1, data);
        } else if (command.code === 404) {
          break;
        }
      }
    }
    command = this._list[i + 1];
    if (command && command.code === 102) {
      this.addChoices(command.parameters, i + 1, data, d + 10);
    }
    return data;
  };

  Game_Interpreter.prototype.getHelpText = function (c, i, data) {
    var command = MPPlugin.EventComment.ChoiceHelp || "選択肢ヘルプ";
    if (this._list[i].code === 108 && this._list[i].parameters[0] === command) {
      var texts = [];
      while (this._list[i + 1].code === 408) {
        i++;
        texts.push(this._list[i].parameters[0]);
      }
      data.helpTexts[c] = texts;
    }
  };

  Game_Interpreter.prototype.evalChoice = function (formula) {
    try {
      var s = $gameSwitches._data;
      var formula2 = formula.replace(/v\[(\d+)\]/g, (match, p1) =>
        $gameVariables.value(parseInt(p1))
      );
      return !!eval(formula2);
    } catch (e) {
      alert("条件エラー \n\n " + formula);
      return true;
    }
  };

  //362
  Game_Interpreter.prototype.command403 = function () {
    if (this._branch[this._indent] !== -2) {
      this.skipBranch();
    }
    return true;
  };

  Game_Interpreter.prototype.command404 = function () {
    if (this.nextEventCode() === 102) {
      this._branch[this._indent] -= 10;
      this._index++;
    }
    return true;
  };

  //1739
  Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    Alias.GaIn_pluginCommand.apply(this, arguments);
    var args2 = this.mppPluginCommandArgs(args);
    switch (command) {
      case MPPlugin.PluginCommands.ChoicePos:
      case "ChoicePos":
        var x = args2[0];
        var y = args2[1];
        var row = args2[2] || 99;
        $gameMessage.setChoicePos(x, y, row);
        break;
      case MPPlugin.PluginCommands.ChoiceVariableId:
      case "ChoiceVariableId":
        $gameMessage.setChoiceVariableId(args2[0]);
        break;
      case MPPlugin.PluginCommands.ChoiceRect:
      case "ChoiceRect":
        var x = args2[0] === undefined ? -1 : args2[0];
        var y = args2[1] === undefined ? -1 : args2[1];
        var width = args2[2] === undefined ? -1 : args2[2];
        var height = args2[3] === undefined ? -1 : args2[3];
        $gameMessage.setChoiceRect(x, y, width, height);
        break;
      case MPPlugin.PluginCommands.ChoiceUnderMessage:
      case "ChoiceUnderMessage":
        $gameMessage.choiceUnderMes = true;
        break;
    }
    return true;
  };

  Game_Interpreter.prototype.mppPluginCommandArgs = function (args) {
    var v = $gameVariables._data;
    return args.map(function (arg) {
      try {
        return eval(arg) || 0;
      } catch (e) {
        return arg;
      }
    });
  };

  //-----------------------------------------------------------------------------
  // Window

  Window.prototype.isClearWindowRect = function () {
    return true;
  };

  //-----------------------------------------------------------------------------
  // WindowLayer

  //7100
  Alias.WiLa__canvasClearWindowRect =
    WindowLayer.prototype._canvasClearWindowRect;
  WindowLayer.prototype._canvasClearWindowRect = function (
    renderSession,
    window
  ) {
    if (window.isClearWindowRect())
      Alias.WiLa__canvasClearWindowRect.apply(this, arguments);
  };

  //7162
  Alias.WiLa__maskWindow = WindowLayer.prototype._maskWindow;
  WindowLayer.prototype._maskWindow = function (window, shift) {
    Alias.WiLa__maskWindow.apply(this, arguments);
    if (!window.isClearWindowRect()) {
      var rect = this._windowRect;
      rect.x = 0;
      rect.y = 0;
      rect.width = 0;
      rect.height = 0;
    }
  };

  //-----------------------------------------------------------------------------
  // Window_ChoiceList

  Window_ChoiceList.prototype.isClearWindowRect = function () {
    return !this._underMessage;
  };

  if (Window_ChoiceList.prototype.hasOwnProperty("close")) {
    Alias.WiChLi_close = Window_ChoiceList.prototype.close;
  }
  Window_ChoiceList.prototype.close = function () {
    if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
    var _super = Alias.WiChLi_close || Window_Command.prototype.close;
    _super.apply(this, arguments);
  };

  if (Window_ChoiceList.prototype.hasOwnProperty("select")) {
    Alias.WiChli_select = Window_ChoiceList.prototype.select;
  }
  Window_ChoiceList.prototype.select = function (index) {
    var variableId = $gameMessage._choiceVariableId;
    if (index !== this.index() && variableId > 0) {
      var results = $gameMessage._choiceResults;
      $gameVariables.setValue(variableId, results[index]);
    }
    var _super = (Alias.WiChli_select = Window_Command.prototype.select);
    _super.apply(this, arguments);
  };

  //34
  Alias.WiChLi_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
  Window_ChoiceList.prototype.updatePlacement = function () {
    Alias.WiChLi_updatePlacement.apply(this, arguments);
    if ($gameMessage._choiceWidth >= 0) {
      this.width = Math.min($gameMessage._choiceWidth, Graphics.boxWidth);
    }
    if ($gameMessage._choiceHeight >= 0) {
      this.height = Math.min($gameMessage._choiceHeight, Graphics.boxHeight);
    }
    if ($gameMessage._choiceX >= 0) {
      this.x = Math.min($gameMessage._choiceX, Graphics.boxWidth - this.width);
    }
    if ($gameMessage._choiceY >= 0) {
      this.y = Math.min(
        $gameMessage._choiceY,
        Graphics.boxHeight - this.height
      );
    }
    this._underMessage = $gameMessage.choiceUnderMes;
  };

  //67
  Window_ChoiceList.prototype.numVisibleRows = function () {
    return Math.min($gameMessage.choices().length, $gameMessage._choiceMaxRow);
  };

  //103
  Window_ChoiceList.prototype.makeCommandList = function () {
    var choices = $gameMessage.choices();
    var enables = $gameMessage._choiceEnables;
    for (var i = 0; i < choices.length; i++) {
      this.addCommand(choices[i], "choice", enables[i]);
    }
  };

  //110
  Alias.WiChLi_drawItem = Window_ChoiceList.prototype.drawItem;
  Window_ChoiceList.prototype.drawItem = function (index) {
    this.changePaintOpacity(this.isCommandEnabled(index));
    Alias.WiChLi_drawItem.apply(this, arguments);
  };

  //123
  Alias.WiChLi_callOkHandler = Window_ChoiceList.prototype.callOkHandler;
  Window_ChoiceList.prototype.callOkHandler = function () {
    Alias.WiChLi_callOkHandler.apply(this, arguments);
    this._messageWindow.forceClear();
  };

  //129
  Alias.WiChLi_callCancelHandler =
    Window_ChoiceList.prototype.callCancelHandler;
  Window_ChoiceList.prototype.callCancelHandler = function () {
    Alias.WiChLi_callCancelHandler.apply(this, arguments);
    this._messageWindow.forceClear();
  };

  if (Window_ChoiceList.prototype.hasOwnProperty("processCancel")) {
    Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel;
  }
  Window_ChoiceList.prototype.processCancel = function () {
    var type = $gameMessage.choiceCancelType();
    var results = $gameMessage._choiceResults;
    var index = results.indexOf(results[type]);
    if (
      this.isCancelEnabled() &&
      index !== type &&
      !this.isCommandEnabled(index)
    ) {
      this.playBuzzerSound();
    } else {
      var _super =
        Alias.WiChLi_processCancel || Window_Command.prototype.processCancel;
      _super.apply(this, arguments);
    }
  };

  Window_ChoiceList.prototype.callUpdateHelp = function () {
    if (this.active && this._messageWindow && $gameMessage.isHelp())
      this.updateHelp();
  };

  Window_ChoiceList.prototype.updateHelp = function () {
    this._messageWindow.forceClear();
    var texts = $gameMessage._helpTexts[this.index()];
    $gameMessage._texts = texts ? texts.clone() : [""];
    this._messageWindow.startMessage();
  };

  //-----------------------------------------------------------------------------
  // Window_Message

  //109
  Alias.WiMe_updatePlacement = Window_Message.prototype.updatePlacement;
  Window_Message.prototype.updatePlacement = function () {
    Alias.WiMe_updatePlacement.apply(this, arguments);
    this.clearUnderChoice();
  };

  Window_Message.prototype.clearUnderChoice = function () {
    if ($gameMessage.choiceUnderMes) {
      var x = this.x + this.standardPadding();
      x += this._textState.left || 0;
      var y = this.y + 4;
      var height = this.windowHeight();
      $gameMessage.setChoiceRect(x, y, -1, height);
    }
  };

  if (Window_Message.prototype.hasOwnProperty("processNewLine")) {
    Alias.WiMe_processNewLine = Window_Message.prototype.processNewLine;
  }
  Window_Message.prototype.processNewLine = function (textState) {
    if ($gameMessage.choiceUnderMes) $gameMessage.shiftLine(textState.height);
    var _super =
      Alias.WiMe_processNewLine || Window_Base.prototype.processNewLine;
    _super.apply(this, arguments);
  };

  //149
  Alias.WiMe_updateInput = Window_Message.prototype.updateInput;
  Window_Message.prototype.updateInput = function () {
    if ($gameMessage.isHelp() && this._textState) return false;
    return Alias.WiMe_updateInput.apply(this, arguments);
  };

  //196
  Alias.WiMe_onEndOfText = Window_Message.prototype.onEndOfText;
  Window_Message.prototype.onEndOfText = function () {
    if ($gameMessage.isHelp() && !this._choiceWindow.active) {
      this.startInput();
    } else {
      Alias.WiMe_onEndOfText.apply(this, arguments);
    }
  };

  //207
  Alias.WiMe_startInput = Window_Message.prototype.startInput;
  Window_Message.prototype.startInput = function () {
    if (this._choiceWindow.active) return true;
    if (
      $gameMessage.isChoice() &&
      $gameMessage.choiceUnderMes &&
      this._textState.x !== this._textState.left
    ) {
      $gameMessage.shiftLine(this._textState.height);
    }
    return Alias.WiMe_startInput.apply(this, arguments);
  };

  Window_Message.prototype.forceClear = function () {
    this._textState = null;
    this.close();
    this._goldWindow.close();
  };

  Window_Message.prototype.onShowFast = function () {
    this._showFast = true;
  };

  //243
  Alias.WiMe_newPage = Window_Message.prototype.newPage;
  Window_Message.prototype.newPage = function (textState) {
    Alias.WiMe_newPage.apply(this, arguments);
    this.clearUnderChoice();
  };
})();


code:
//=============================================================================
// MPP_OriginalMenu.js
//=============================================================================
// Copyright (c) 2019 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
 * @plugindesc 【ver.2.3】コモンイベントによるオリジナルのサブメニュー画面が作成できます。
 * @author 木星ペンギン
 * @help []内は表記しなくても動作します。
 * プラグインコマンド:
 *   AddMenuCommand name c1[ c2]      # メニューコマンド name を追加
 *   RemoveMenuCommand name           # メニューコマンド name を削除
 *   SetMenuCommandEnabled name bool  # メニューコマンド name の有効/無効化
 *
 *   AddMenuCommandId c1[ c2]         # コモンイベントをメニューコマンドに追加
 *   RemoveMenuCommandId c1           # メインコモンイベントID c1 を削除
 *   SetMenuCommandIdEnabled c1 bool  # メインコモンイベントID c1 の有効/無効化
 *
 *   CreateMiniMap        # ミニマップを表示(ミニマッププラグインと併用時のみ)
 *   EraceMiniMap         # ミニマップを非表示(ミニマッププラグインと併用時のみ)
 *
 * ================================================================
 * ▼ プラグインコマンド 詳細
 * --------------------------------
 *  〇 AddMenuCommand name c1[ c2]
 *       name : メニューコマンド名
 *       c1   : メインコモンイベントID
 *       c2   : サブコモンイベントID
 *
 *   メニューコマンドを追加します。
 *
 * --------------------------------
 *  〇 SetMenuCommandEnabled name bool
 *       name : メニューコマンド名
 *       bool : trueで有効、falseで無効
 *
 *   メニューコマンド name の有効/無効化を変更します。
 *
 *   無効化するとメニューコマンドが半透明で表示され、選択してもブザー音が鳴り、
 *   選択できなくなります。
 *
 * --------------------------------
 *  〇 AddMenuCommandId c1[ c2]
 *       c1 : メインコモンイベントID
 *       c2 : サブコモンイベントID
 *
 *   メニューコマンドを追加します。
 *   コマンド名はメインコモンイベントの名前となります。
 *
 * ================================================================
 * ▼ その他
 * --------------------------------
 *  〇 コマンドは【並び替え】の下に追加されます。
 *
 *  〇 サブメニューの処理はイベントコマンドで実行されます。
 *   ・メインのコモンイベントの処理が終了した時点で、前の画面に戻ります。
 *   ・サブのコモンイベントは処理が終了しても最初から繰り返しません。
 *
 *  〇 『イベントの移動』などを実行した場合、新しくメニュー画面用のイベントが
 *    生成されます。
 *   ・座標 X:0 Y:0 にグラフィックを設定していない状態で生成されます。
 *
 *  〇 『スクリプトコマンド』で SceneManager.goto(Scene_Map) と実行することで
 *    マップ画面まで戻ることが出来ます。
 *   ・サブメニューで実行中のイベントは中断されます。
 *
 *  〇 『場所移動』を実行した場合、強制的にマップ画面まで戻されます。
 *   ・サブメニューで実行中のイベントは中断されます。
 *
 *  〇 メニューコマンドは後から追加できます。
 *   ・追加するコマンドは、プラグインパラメータに設定しておく必要はありません。
 *   ・ただし、同じ名前または同じメインコモンイベントIDのコマンドは追加できません。
 *
 * ================================
 * ●ミニマッププラグイン[MPP_MiniMap]との併用について
 *  ・ミニマップはキャラクターより上、ピクチャより下に表示されます。
 *  ・ミニマップの表示位置や可視状態の設定は、マップ画面と共用です。
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param Commands
 * @type struct<Command>[]
 * @desc メインメニューで表示されるコマンドの配列
 * @default []
 *
 */

/*~struct~Command:
 * @param Name
 * @desc コマンド名
 * (空の場合はコモンイベント名)
 * @default
 *
 * @param Main Event ID
 * @type common_event
 * @desc メインで実行されるコモンイベントのID
 * @default 0
 *
 * @param Sub Event ID
 * @type common_event
 * @desc サブで実行されるコモンイベントのID
 * @default 0
 *
 */

(function () {
  var MPPlugin = {};

  (function () {
    var parameters = PluginManager.parameters("MPP_OriginalMenu");

    MPPlugin.contains = {};
    MPPlugin.contains["Minimap"] = $plugins.some(function (plugin) {
      return plugin.name === "MPP_MiniMap" && plugin.status;
    });

    function reviverEval(key, value) {
      try {
        return eval(value);
      } catch (e) {
        return value;
      }
    }

    var commands = JSON.parse(parameters["Commands"] || "[]");
    for (var i = 0; i < commands.length; i++) {
      commands[i] = JSON.parse(commands[i], reviverEval);
    }
    MPPlugin.commands = commands;
  })();

  var Alias = {};

  var MenuData = {
    index: -1,
    events: [],
    mainInterpreter: null,
    subInterpreter: null,
    create: function () {
      if (!this.mainInterpreter) {
        this.events = [];
        this.mainInterpreter = new Game_Interpreter();
        this.subInterpreter = new Game_Interpreter();
        var command = $gameParty._mppMenuCommands[this.index];
        var event = $dataCommonEvents[command.mainId];
        if (event) this.mainInterpreter.setup(event.list);
        event = $dataCommonEvents[command.subId];
        if (event) this.subInterpreter.setup(event.list);
      }
    },
    update: function () {
      this.mainInterpreter.update();
      this.subInterpreter.update();
      this.events.forEach(function (event) {
        if (event) event.update();
      });
    },
    clear: function () {
      this.index = -1;
      this.events = [];
      this.mainInterpreter = null;
      this.subInterpreter = null;
    },
    reset: function () {
      var events = this.events;
      for (var i = 0; i < events.length; i++) {
        if (events[i]) events[i].requestSprite = true;
      }
    },
  };

  //-----------------------------------------------------------------------------
  // Game_SubMenu_Character

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

  Game_SubMenu_Character.prototype = Object.create(Game_Character.prototype);
  Game_SubMenu_Character.prototype.constructor = Game_SubMenu_Character;

  Game_SubMenu_Character.prototype.initialize = function () {
    Game_Character.prototype.initialize.call(this);
    this.requestSprite = true;
  };

  Game_SubMenu_Character.prototype.canPass = function () {
    return true;
  };

  Game_SubMenu_Character.prototype.canPassDiagonally = function () {
    return true;
  };

  Game_SubMenu_Character.prototype.scrolledX = function () {
    return this._realX;
  };

  Game_SubMenu_Character.prototype.scrolledY = function () {
    return this._realY;
  };

  Game_SubMenu_Character.prototype.updateJump = function () {
    this._jumpCount--;
    this._realX =
      (this._realX * this._jumpCount + this._x) / (this._jumpCount + 1.0);
    this._realY =
      (this._realY * this._jumpCount + this._y) / (this._jumpCount + 1.0);
    this.refreshBushDepth();
    if (this._jumpCount === 0) {
      this._realX = this._x;
      this._realY = this._y;
    }
  };

  Game_SubMenu_Character.prototype.isOnLadder = function () {
    return false;
  };

  Game_SubMenu_Character.prototype.isOnBush = function () {
    return false;
  };

  Game_SubMenu_Character.prototype.terrainTag = function () {
    return 0;
  };

  Game_SubMenu_Character.prototype.regionId = function () {
    return 0;
  };

  Game_SubMenu_Character.prototype.moveStraight = function (d) {
    this.setMovementSuccess(this.canPass(this._x, this._y, d));
    if (this.isMovementSucceeded()) {
      this.setDirection(d);
      this._x += d === 6 ? 1 : d === 4 ? -1 : 0;
      this._y += d === 2 ? 1 : d === 8 ? -1 : 0;
      this.increaseSteps();
    } else {
      this.setDirection(d);
    }
  };

  Game_SubMenu_Character.prototype.moveDiagonally = function (horz, vert) {
    this.setMovementSuccess(
      this.canPassDiagonally(this._x, this._y, horz, vert)
    );
    if (this.isMovementSucceeded()) {
      this._x += horz === 6 ? 1 : horz === 4 ? -1 : 0;
      this._y += vert === 2 ? 1 : vert === 8 ? -1 : 0;
      this.increaseSteps();
    }
    if (this._direction === this.reverseDir(horz)) {
      this.setDirection(horz);
    }
    if (this._direction === this.reverseDir(vert)) {
      this.setDirection(vert);
    }
  };

  Game_SubMenu_Character.prototype.deltaXFrom = function (x) {
    return this.x - x;
  };

  Game_SubMenu_Character.prototype.deltaYFrom = function (y) {
    return this.y - y;
  };

  //-----------------------------------------------------------------------------
  // Game_Screen

  //74
  Alias.GaSc_realPictureId = Game_Screen.prototype.realPictureId;
  Game_Screen.prototype.realPictureId = function (pictureId) {
    if (!$gameParty.inBattle() && MenuData.index >= 0) {
      return pictureId + this.maxPictures() * 2;
    } else {
      return Alias.GaSc_realPictureId.call(this, pictureId);
    }
  };

  //-----------------------------------------------------------------------------
  // Game_Party

  //21
  Alias.GaPa_initialize = Game_Party.prototype.initialize;
  Game_Party.prototype.initialize = function () {
    Alias.GaPa_initialize.call(this);
    this._mppMenuCommands = [];
    var commands = MPPlugin.commands;
    for (var i = 0; i < commands.length; i++) {
      var name = commands.Name;
      var mainId = commands["Main Event ID"] || 0;
      var subId = commands["Sub Event ID"] || 0;
      this.addMenuCommand(name, mainId, subId);
    }
  };

  Game_Party.prototype.addMenuCommand = function (name, mainId, subID) {
    var commands = this._mppMenuCommands;
    for (var i = 0; i < commands.length; i++) {
      if (name && commands[i].name === name) return;
      if (!name && commands[i].mainId === mainId) return;
    }
    this._mppMenuCommands.push({
      name: name,
      mainId: mainId || 0,
      subID: subID || 0,
      enabled: true,
    });
  };

  Game_Party.prototype.removeMenuCommand = function (name) {
    this._mppMenuCommands = this._mppMenuCommands.filter(function (cmd) {
      return cmd.name !== name;
    });
  };

  Game_Party.prototype.setMenuCommandEnabled = function (name, enabled) {
    var commands = this._mppMenuCommands;
    for (var i = 0; i < commands.length; i++) {
      if (commands[i].name === name) {
        commands[i].enabled = enabled;
        return;
      }
    }
  };

  Game_Party.prototype.removeMenuCommandId = function (id) {
    this._mppMenuCommands = this._mppMenuCommands.filter(function (cmd) {
      return cmd.mainId !== id;
    });
  };

  Game_Party.prototype.setMenuCommandIdEnabled = function (id, enabled) {
    var commands = this._mppMenuCommands;
    for (var i = 0; i < commands.length; i++) {
      if (commands[i].mainId === id) {
        commands[i].enabled = enabled;
        return;
      }
    }
  };

  //-----------------------------------------------------------------------------
  // Game_Interpreter

  //266
  Alias.GaIn_character = Game_Interpreter.prototype.character;
  Game_Interpreter.prototype.character = function (param) {
    if (MenuData.index < 0) {
      return Alias.GaIn_character.call(this, param);
    } else if (param > 0) {
      if (!MenuData.events[param]) {
        MenuData.events[param] = new Game_SubMenu_Character();
      }
      return MenuData.events[param];
    } else {
      return null;
    }
  };

  //1722
  Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    Alias.GaIn_pluginCommand.call(this, command, args);
    switch (command) {
      case "AddMenuCommand":
        $gameParty.addMenuCommand(args[0], Number(args[1]), Number(args[2]));
        break;
      case "RemoveMenuCommand":
        $gameParty.removeMenuCommand(args[0]);
        break;
      case "SetMenuCommandEnabled":
        $gameParty.setMenuCommandEnabled(args[0], !!eval(args[1]));
        break;
      case "AddMenuCommandId":
        $gameParty.addMenuCommand(null, Number(args[0]), Number(args[1]));
        break;
      case "RemoveMenuCommandId":
        $gameParty.removeMenuCommandId(args[0]);
        break;
      case "SetMenuCommandIdEnabled":
        $gameParty.setMenuCommandIdEnabled(args[0], !!eval(args[1]));
        break;
      case "CreateMiniMap":
        if (MPPlugin.contains["Minimap"]) {
          var spriteset = SceneManager._scene._spriteset;
          if (spriteset) spriteset.createMinimap();
        }
        break;
      case "EraceMiniMap":
        if (MPPlugin.contains["Minimap"]) {
          var spriteset = SceneManager._scene._spriteset;
          if (spriteset) spriteset.eraseMinimap();
        }
        break;
    }
  };

  //-----------------------------------------------------------------------------
  // Window_MenuCommand

  //64
  Alias.WiMeCo_addOriginalCommands =
    Window_MenuCommand.prototype.addOriginalCommands;
  Window_MenuCommand.prototype.addOriginalCommands = function () {
    Alias.WiMeCo_addOriginalCommands.call(this);
    var commands = $gameParty._mppMenuCommands;
    for (var i = 0; i < commands.length; i++) {
      var name = commands[i].name;
      if (!name) {
        var event = $dataCommonEvents[commands[i].mainId];
        name = event ? event.name : "";
      }
      if (name) this.addCommand(name, "mppCommand" + i, commands[i].enabled);
    }
  };

  //-----------------------------------------------------------------------------
  // Spriteset_SubMenu

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

  Spriteset_SubMenu.prototype = Object.create(Spriteset_Base.prototype);
  Spriteset_SubMenu.prototype.constructor = Spriteset_SubMenu;

  Spriteset_SubMenu.prototype.initialize = function () {
    Spriteset_Base.prototype.initialize.call(this);
    this._blackScreen.opacity = 0;
  };

  Spriteset_SubMenu.prototype.createLowerLayer = function () {
    Spriteset_Base.prototype.createLowerLayer.call(this);
    this._characterContainer = new Sprite();
    this.addChild(this._characterContainer);
  };

  Spriteset_SubMenu.prototype.createPictures = function () {
    var width = Graphics.boxWidth;
    var height = Graphics.boxHeight;
    var x = (Graphics.width - width) / 2;
    var y = (Graphics.height - height) / 2;
    this._pictureContainer = new Sprite();
    this._pictureContainer.setFrame(x, y, width, height);
    for (var i = 1; i <= $gameScreen.maxPictures(); i++) {
      this._pictureContainer.addChild(new Sprite_Picture(i));
    }
    this.addChild(this._pictureContainer);
  };

  Spriteset_SubMenu.prototype.createMinimap = function () {
    if (!this._minimap) {
      this._minimap = new Sprite_MiniMap();
      var index = this.children.indexOf(this._pictureContainer);
      this.addChildAt(this._minimap, index);
    }
  };

  Spriteset_SubMenu.prototype.eraseMinimap = function () {
    if (this._minimap) {
      this.removeChild(this._minimap);
      this._minimap = null;
    }
  };

  Spriteset_SubMenu.prototype.update = function () {
    Spriteset_Base.prototype.update.call(this);
    this.updateCharacters();
  };

  Spriteset_SubMenu.prototype.hideCharacters = function () {
    this._characterContainer.visible = false;
  };

  Spriteset_SubMenu.prototype.updateCharacters = function () {
    var events = MenuData.events;
    for (var i = 0; i < events.length; i++) {
      var event = events[i];
      if (event && event.requestSprite) {
        var sprite = new Sprite_Character(event);
        this._characterContainer.addChild(sprite);
        event.requestSprite = false;
      }
    }
    this._characterContainer.children.sort(this._compareChildOrder.bind(this));
  };

  Spriteset_SubMenu.prototype._compareChildOrder = function (a, b) {
    if (a.z !== b.z) {
      return a.z - b.z;
    } else if (a.y !== b.y) {
      return a.y - b.y;
    } else {
      return a.spriteId - b.spriteId;
    }
  };

  //-----------------------------------------------------------------------------
  // Scene_Menu

  //29
  Alias.ScMe_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  Scene_Menu.prototype.createCommandWindow = function () {
    Alias.ScMe_createCommandWindow.call(this);
    var commands = $gameParty._mppMenuCommands;
    for (var i = 0; i < commands.length; i++) {
      this._commandWindow.setHandler(
        "mppCommand" + i,
        this.commandSubMenu.bind(this, i)
      );
    }
  };

  Scene_Menu.prototype.commandSubMenu = function (index) {
    MenuData.index = index;
    SceneManager.push(Scene_MppSubMenu);
  };

  //-----------------------------------------------------------------------------
  // Scene_MppSubMenu

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

  Scene_MppSubMenu.prototype = Object.create(Scene_MenuBase.prototype);
  Scene_MppSubMenu.prototype.constructor = Scene_MppSubMenu;

  Scene_MppSubMenu.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
    this._encounterEffectDuration = 0;
  };
  Scene_Base.prototype.isOriMenu = function () {
    return false;
  };
  Scene_MppSubMenu.prototype.isOriMenu = function () {
    return true;
  };

  Scene_MppSubMenu.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    MenuData.create();
    this.createSpriteset();
    this.createMessageWindow();
    this.createScrollTextWindow();
  };

  Scene_MppSubMenu.prototype.createSpriteset = function () {
    this._spriteset = new Spriteset_SubMenu();
    var index = this.children.indexOf(this._backgroundSprite);
    this.addChildAt(this._spriteset, index + 1);
  };

  Scene_MppSubMenu.prototype.createMessageWindow = function () {
    this._messageWindow = new Window_Message();
    this.addWindow(this._messageWindow);
    this._messageWindow.subWindows().forEach(function (window) {
      this.addWindow(window);
    }, this);
  };

  Scene_MppSubMenu.prototype.createScrollTextWindow = function () {
    this._scrollTextWindow = new Window_ScrollText();
    this.addWindow(this._scrollTextWindow);
  };

  Scene_MppSubMenu.prototype.update = function () {
    if (this.isActive()) {
      this.updateMain();
    }
    if (this.isSceneChangeOk()) {
      this.updateScene();
    } else if (SceneManager.isNextScene(Scene_Battle)) {
      Scene_Map.prototype.updateEncounterEffect.call(this);
    }
    Scene_MenuBase.prototype.update.call(this);
  };

  Scene_MppSubMenu.prototype.updateMain = function () {
    MenuData.update();
    if (!MenuData.mainInterpreter.isRunning()) {
      this.popScene();
      return;
    }
    $gameScreen.update();
  };

  Scene_MppSubMenu.prototype.stop = function () {
    Scene_MenuBase.prototype.stop.call(this);
    if (this.needsSlowFadeOut()) {
      this.startFadeOut(this.slowFadeSpeed(), false);
    } else if (SceneManager.isNextScene(Scene_Map)) {
      this.fadeOutForTransfer();
    } else if (SceneManager.isNextScene(Scene_Battle)) {
      this.launchBattle.call(this);
    }
  };

  Scene_MppSubMenu.prototype.isBusy = function () {
    return (
      (this._messageWindow && this._messageWindow.isClosing()) ||
      this._encounterEffectDuration > 0 ||
      Scene_MenuBase.prototype.isBusy.call(this)
    );
  };

  Scene_MppSubMenu.prototype.terminate = function () {
    Scene_MenuBase.prototype.terminate.call(this);
    if (
      SceneManager.isNextScene(Scene_Menu) ||
      SceneManager.isNextScene(Scene_Map)
    ) {
      MenuData.clear();
      $gameScreen.eraseBattlePictures();
    } else {
      MenuData.reset();
    }
    $gameScreen.clearZoom();
  };

  Scene_MppSubMenu.prototype.needsSlowFadeOut = function () {
    return (
      SceneManager.isNextScene(Scene_Title) ||
      SceneManager.isNextScene(Scene_Gameover)
    );
  };

  Scene_MppSubMenu.prototype.launchBattle = function () {
    BattleManager.saveBgmAndBgs();
    Scene_Map.prototype.stopAudioOnBattleStart.call(this);
    SoundManager.playBattleStart();
    Scene_Map.prototype.startEncounterEffect.call(this);
  };

  Scene_MppSubMenu.prototype.isSceneChangeOk = function () {
    return this.isActive() && !$gameMessage.isBusy();
  };

  Scene_MppSubMenu.prototype.updateScene = function () {
    this.checkGameover();
    if (!SceneManager.isSceneChanging()) {
      this.updateTransferPlayer();
    }
  };

  Scene_MppSubMenu.prototype.updateTransferPlayer =
    Scene_Map.prototype.updateTransferPlayer;

  Scene_MppSubMenu.prototype.fadeOutForTransfer =
    Scene_Map.prototype.fadeOutForTransfer;

  Scene_MppSubMenu.prototype.snapForBattleBackground = function () {};

  Scene_MppSubMenu.prototype.startFlashForEncounter =
    Scene_Map.prototype.startFlashForEncounter;

  Scene_MppSubMenu.prototype.encounterEffectSpeed =
    Scene_Map.prototype.encounterEffectSpeed;
})();


code:
//=============================================================================
// MPP_TouchCommand.js
//=============================================================================
// Copyright (c) 2015 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
 * @plugindesc 【ver.1.0】左クリック（タッチ）時の情報を取得するイベントコマンドを追加します。
 * @author 木星ペンギン
 *
 * @help プラグインコマンド:
 *   TouchInfo type n             # type : 取得する情報タイプ
 *                                # n    : 情報を入れる変数の番号
 *   WaitTouch                    # 画面をタッチするまでウェイト
 *
 * ●情報タイプ(type)
 *  realX  : 画面 X
 *  realY  : 画面 Y
 *  mapX   : マップのX座標
 *  mapY   : マップのY座標
 *  tag    : 地形タグ (低いレイヤーから判定して0以上のものを取得)
 *  event  : イベントID (無ければ0 / プレイヤーは対象外 / 低いID優先)
 *  reg    : リージョンID
 *  pic    : ピクチャ番号(無ければ0 / 回転には非対応 / 高い番号優先)
 *  dir4   : 画面中央からタッチした方向を取得(2,4,6,8の4方向)
 *  dir8   : 画面中央からタッチした方向を取得(1,2,3,4,6,7,8,9の8方向)
 *
 * ●制御文字
 *  [情報を入れる変数の番号(n)]には変数が使用できます。
 *  (例:v[3]で変数3番を参照)
 *
 * ●情報を取得する座標について
 *  TouchInfoでは最後にタッチした画面上の位置から情報を取得します。
 *  タッチしてからプラグインコマンドが実行されるまでの間に
 *  マップをスクロールしたりピクチャを移動させた場合、
 *  正確な情報が得られないことがあります。
 *
 * ●画面をタッチするまでウェイト
 *  画面を左クリック(タッチ)するまでイベントの処理を一時停止します。
 *  右クリックやゲームパッド、キーボードからの入力では一時停止は解除されません。
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 */

(function () {
  var Alias = {};

  var TouchCommand = {
    processTouch: function (type, varId) {
      if (!type || varId === 0) return;
      var value = 0;
      var realX = TouchInput.x;
      var realY = TouchInput.y;
      var mapX = $gameMap.canvasToMapX(realX);
      var mapY = $gameMap.canvasToMapY(realY);
      switch (type) {
        case "realX":
          value = realX;
          break;
        case "realY":
          value = realY;
          break;
        case "mapX":
          value = mapX;
          break;
        case "mapY":
          value = mapY;
          break;
        case "tag":
          value = $gameMap.terrainTag(mapX, mapY);
          break;
        case "event":
          value = $gameMap.eventIdXy(mapX, mapY);
          break;
        case "reg":
          value = $gameMap.regionId(mapX, mapY);
          break;
        case "pic":
          value = this.pictureId(realX, realY);
          break;
        case "dir4":
          var angle = ((this.angle(realX, realY) + 45) % 360) / 90;
          if (angle < 1) {
            value = 8;
          } else if (angle < 2) {
            value = 6;
          } else if (angle < 3) {
            value = 2;
          } else {
            value = 4;
          }
          break;
        case "dir8":
          var angle = ((this.angle(realX, realY) + 22.5) % 360) / 45;
          if (angle < 1) {
            value = 8;
          } else if (angle < 2) {
            value = 9;
          } else if (angle < 3) {
            value = 6;
          } else if (angle < 4) {
            value = 3;
          } else if (angle < 5) {
            value = 2;
          } else if (angle < 6) {
            value = 1;
          } else if (angle < 7) {
            value = 4;
          } else {
            value = 7;
          }
          break;
      }
      $gameVariables.setValue(varId, value);
    },
    pictureId: function (x, y) {
      var pictures = SceneManager._scene._spriteset._pictureContainer.children;
      for (var i = pictures.length - 1; i >= 0; i--) {
        if (pictures[i].isPosInside(x, y)) {
          return pictures[i]._pictureId;
        }
      }
    },
    angle: function (tx, ty) {
      var cx = Graphics.width / 2;
      var cy = Graphics.height / 2;
      return ((180 * Math.atan2(cy - ty, cx - tx)) / Math.PI - 90).mod(360);
    },
  };

  //-----------------------------------------------------------------------------
  // Game_Interpreter

  //109
  Alias.GaIn_updateWaitMode = Game_Interpreter.prototype.updateWaitMode;
  Game_Interpreter.prototype.updateWaitMode = function () {
    if (this._waitMode === "TouchTrigger") {
      if (TouchInput.isTriggered()) {
        this._waitMode = "";
        return false;
      }
      return true;
    }
    return Alias.GaIn_updateWaitMode.call(this);
  };

  //1722
  Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    Alias.GaIn_pluginCommand.call(this, command, args);
    if (command === "TouchInfo") {
      var v = $gameVariables._data;
      TouchCommand.processTouch(args[0], eval(args[1]) || 0);
    } else if (command === "WaitTouch") {
      this._waitMode = "TouchTrigger";
    }
  };

  //-----------------------------------------------------------------------------
  // Sprite_Picture

  Sprite_Picture.prototype.isPosInside = function (x, y) {
    if (!this._pictureName) return false;
    var lx = this.canvasToLocalX(x);
    var ly = this.canvasToLocalY(y);
    var width = (this.width || 0) * this.scale.x;
    var height = (this.height || 0) * this.scale.y;
    var x1 = -width * this.anchor.x;
    var y1 = -height * this.anchor.y;
    var left = Math.min(x1, x1 + width);
    var top = Math.min(y1, y1 + height);
    var right = Math.max(x1, x1 + width);
    var bottom = Math.max(y1, y1 + height);
    return lx >= left && ly >= top && lx < right && ly < bottom;
  };

  Sprite_Picture.prototype.canvasToLocalX = function (x) {
    var node = this;
    while (node) {
      x -= node.x;
      node = node.parent;
    }
    return x;
  };

  Sprite_Picture.prototype.canvasToLocalY = function (y) {
    var node = this;
    while (node) {
      y -= node.y;
      node = node.parent;
    }
    return y;
  };
})();


code:
//=============================================================================
// MT_ChangeMoveSpeed.js
// 移動速度を補正するプラグイン
// ----------------------------------------------------------------------------
// (C) 2019 Moooty
//=============================================================================

/*:
 * @plugindesc Change Move Speed.
 * @author Moooty
 *
 * @param playerWalkSpeedRate
 * @desc Player(and Follower)'s move speed rate(default：1)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle1MoveSpeedRate
 * @desc Vehicle1(Boat)'s move speed rate.(default: 1)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle2MoveSpeedRate
 * @desc Vehicle2(Ship)'s move speed rate.(default: 1)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle3MoveSpeedRate
 * @desc Vehicle3(Airship)'s move speed rate.(default: 1)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param eventSpeedRate
 * @desc Map Event's move speed rate.(default: 1)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @help
 * === Description ===
 * Multiply move speed by plagin paramter.
 *
 * Nothing plugin commnad this plugin.
 *
 *
 * === Change Log ===
 * Apr 18, 2019 ver1.00 Initial release.
 * Nov 24, 2019 ver1.10 Rename plugin file.（ChangeMoveSpeed → MT_ChangeMoveSpeed.js）
 *
 * === Manual & License(Japanese) ===
 * https://www.5ing-myway.com/rpgmaker-plugin-change-move-speed/
 *
 */

/*:ja
 * @plugindesc 移動速度を補正
 * @author むーてぃ
 *
 * @param playerWalkSpeedRate
 * @text プレイヤーの移動速度補正
 * @desc プレイヤーとフォロワー(仲間)の移動速度補正(デフォルト：1倍)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle1MoveSpeedRate
 * @text 乗り物1の移動速度補正
 * @desc 乗り物1の移動速度補正(デフォルト: 1倍)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle2MoveSpeedRate
 * @text 乗り物2の移動速度補正
 * @desc 乗り物2の移動速度補正(デフォルト: 1倍)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param vehicle3MoveSpeedRate
 * @text 乗り物3の移動速度補正
 * @desc 乗り物3の移動速度補正(デフォルト: 1倍)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @param eventSpeedRate
 * @text マップイベントの移動速度補正
 * @desc マップイベントの移動速度補正(デフォルト:1倍)
 * @type number
 * @decimals 2
 * @default 1.00
 *
 * @help
 * === 説明 ===
 * 移動速度を変更できるプラグインです。
 *
 * このプラグインにはプラグインコマンドはありません。
 *
 * === 更新履歴 ===
 * 2019/04/18 ver1.00 初版
 * 2019/11/24 ver1.10 ファイル名変更（ChangeMoveSpeed → MT_ChangeMoveSpeed.js）
 *
 * === マニュアル＆ライセンス ===
 * https://www.5ing-myway.com/rpgmaker-plugin-change-move-speed/
 *
 */

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

(function () {
  "use strict";

  const PLUGIN_NAME = "MT_ChangeMoveSpeed";
  var parameters = PluginManager.parameters(PLUGIN_NAME);

  var playerMoveSpeedRate = getParameterValue(
    parameters["playerWalkSpeedRate"],
    1
  );
  var vehiclesSpeedRate = [];
  vehiclesSpeedRate.push(
    getParameterValue(parameters["vehicle1MoveSpeedRate"], 1)
  );
  vehiclesSpeedRate.push(
    getParameterValue(parameters["vehicle2MoveSpeedRate"], 1)
  );
  vehiclesSpeedRate.push(
    getParameterValue(parameters["vehicle3MoveSpeedRate"], 1)
  );

  var eventSpeedRate = getParameterValue(parameters["eventSpeedRate"], 1);

  // ---------- rpg_object.js の変更ここから ----------
  // Game_CharacterBase
  // 元の式に移動速度補正をかける
  var _Game_CharacterBase_distancePerFrame =
    Game_CharacterBase.prototype.distancePerFrame;
  Game_CharacterBase.prototype.distancePerFrame = function () {
    return (
      _Game_CharacterBase_distancePerFrame.call(this) * this.moveSpeedRate()
    );
  };

  // メソッド追加(速度補正取得)
  Game_CharacterBase.prototype.moveSpeedRate = function () {
    return this._moveSpeedRate;
  };

  // Game_Player
  var _Game_Player_initialize = Game_Player.prototype.initialize;
  Game_Player.prototype.initialize = function () {
    _Game_Player_initialize.call(this);
    this._moveSpeedRate = playerMoveSpeedRate;
  };

  // メソッド追加(速度補正取得)
  Game_Player.prototype.moveSpeedRate = function () {
    if ($gamePlayer.vehicle() != null) {
      if ($gamePlayer.vehicle()._driving) {
        return $gamePlayer.vehicle()._moveSpeedRate;
      }
    }

    return this._moveSpeedRate;
  };

  // Game_Follower
  var _Game_Follower_initialize = Game_Follower.prototype.initialize;
  Game_Follower.prototype.initialize = function (memberIndex) {
    _Game_Follower_initialize.call(this, memberIndex);
    this._moveSpeedRate = playerMoveSpeedRate;
  };

  // Game_Vehicle
  var _Game_Vehicle_initialze = Game_Vehicle.prototype.initialize;
  Game_Vehicle.prototype.initialize = function (type) {
    _Game_Vehicle_initialze.call(this, type);

    if (this.isBoat()) {
      this._moveSpeedRate = vehiclesSpeedRate[0];
    } else if (this.isShip()) {
      this._moveSpeedRate = vehiclesSpeedRate[1];
    } else if (this.isAirship()) {
      this._moveSpeedRate = vehiclesSpeedRate[2];
    }
  };

  // Game_Event
  var _Game_Event_initialize = Game_Event.prototype.initialize;
  Game_Event.prototype.initialize = function (mapId, eventId) {
    this._moveSpeedRate = eventSpeedRate;
    _Game_Event_initialize.call(this, mapId, eventId);
  };
  // ---------- rpg_object.js の変更ここまで ----------

  // ---------- パラメータ取得用関数ここから ----------
  // @type numberのパラメータでも文字列を入れることができてしまう対策
  function getParameterValue(param, defaultValue) {
    var result = Number(param || defaultValue);

    if (Number.isNaN(result)) {
      result = defaultValue;
    }

    return result;
  }
  // ---------- パラメータ取得用関数ここまで ----------
})();


code:
/*:
 * NOTE: Images are stored in the img/system folder.
 *
 * @plugindesc Show a Splash Screen "Made with MV" and/or a Custom Splash Screen before going to main screen.
 * @author Dan "Liquidize" Deptula
 *
 * @help This plugin does not provide plugin commands.
 *
 * @param Show Made With MV
 * @desc Enabled/Disables showing the "Made with MV" splash screen.
 * OFF - false     ON - true
 * Default: ON
 * @default true
 *
 * @param Made with MV Image
 * @desc The image to use when showing "Made with MV"
 * Default: MadeWithMv
 * @default MadeWithMv
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Show Custom Splash
 * @desc Enabled/Disables showing the "Made with MV" splash screen.
 * OFF - false     ON - true
 * Default: OFF
 * @default false
 *
 * @param Custom Image
 * @desc The image to use when showing "Made with MV"
 * Default:
 * @default
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Fade Out Time
 * @desc The time it takes to fade out, in frames.
 * Default: 120
 * @default 120
 *
 * @param Fade In Time
 * @desc The time it takes to fade in, in frames.
 * Default: 120
 * @default 120
 *
 * @param Wait Time
 * @desc The time between fading in and out, in frames.
 * Default: 160
 * @default 160
 *
 */
/*:ja
 * メモ: イメージはimg／systemフォルダ内に保存されます。
 *
 * @plugindesc メイン画面へ進む前に、"Made with MV"のスプラッシュ画面もしくはカスタマイズされたスプラッシュ画面を表示します。
 * @author Dan "Liquidize" Deptula
 *
 * @help  このプラグインにはプラグインコマンドはありません。
 *
 * @param Show Made With MV
 * @desc "Made with MV"のスプラッシュ画面を表示できる/できないようにします。
 * OFF - false     ON - true
 * デフォルト: ON
 * @default true
 *
 * @param Made with MV Image
 * @desc "Made with MV"を表示する際に使用する画像
 * デフォルト: MadeWithMv
 * @default MadeWithMv
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Show Custom Splash
 * @desc "Made with MV"のスプラッシュ画面を表示できる/できないようにします。
 * OFF - false     ON - true
 * デフォルト: OFF
 * @default false
 *
 * @param Custom Image
 * @desc "Made with MV"を表示する際に使用する画像
 * デフォルト:
 * @default
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Fade Out Time
 * @desc フェードアウトに要する時間（フレーム数）
 * デフォルト: 120
 * @default 120
 *
 * @param Fade In Time
 * @desc フェードインに要する時間（フレーム数）
 * デフォルト: 120
 * @default 120
 *
 * @param Wait Time
 * @desc フェードインからフェードアウトまでに要する時間（フレーム数）
 * デフォルト: 160
 * @default 160
 *
 */
var Liquidize = Liquidize || {};
Liquidize.MadeWithMV = {};
Liquidize.MadeWithMV.Parameters = PluginManager.parameters("MadeWithMv");

Liquidize.MadeWithMV.ShowMV = JSON.parse(
  Liquidize.MadeWithMV.Parameters["Show Made With MV"]
);
Liquidize.MadeWithMV.MVImage = String(
  Liquidize.MadeWithMV.Parameters["Made with MV Image"]
);
Liquidize.MadeWithMV.ShowCustom = JSON.parse(
  Liquidize.MadeWithMV.Parameters["Show Custom Splash"]
);
Liquidize.MadeWithMV.CustomImage = String(
  Liquidize.MadeWithMV.Parameters["Custom Image"]
);
Liquidize.MadeWithMV.FadeOutTime =
  Number(Liquidize.MadeWithMV.Parameters["Fade Out Time"]) || 120;
Liquidize.MadeWithMV.FadeInTime =
  Number(Liquidize.MadeWithMV.Parameters["Fade In Time"]) || 120;
Liquidize.MadeWithMV.WaitTime =
  Number(Liquidize.MadeWithMV.Parameters["Wait Time"]) || 160;

//-----------------------------------------------------------------------------
// Scene_Splash
//
// This is a constructor, implementation is done in the inner scope.

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

(function () {
  //-----------------------------------------------------------------------------
  // Scene_Boot
  //
  // The scene class for dealing with the game boot.

  var _Scene_Boot_loadSystemImages = Scene_Boot.prototype.loadSystemImages;
  Scene_Boot.prototype.loadSystemImages = function () {
    _Scene_Boot_loadSystemImages.call(this);
    if (Liquidize.MadeWithMV.ShowMV) {
      ImageManager.loadSystem(Liquidize.MadeWithMV.MVImage);
    }
    if (Liquidize.MadeWithMV.ShowCustom) {
      ImageManager.loadSystem(Liquidize.MadeWithMV.CustomImage);
    }
  };

  var _Scene_Boot_start = Scene_Boot.prototype.start;
  Scene_Boot.prototype.start = function () {
    if (
      (Liquidize.MadeWithMV.ShowMV || Liquidize.MadeWithMV.ShowCustom) &&
      !DataManager.isBattleTest() &&
      !DataManager.isEventTest()
    ) {
      SceneManager.goto(Scene_Splash);
    } else {
      _Scene_Boot_start.call(this);
    }
  };

  //-----------------------------------------------------------------------------
  // Scene_Splash
  //
  // The scene class for dealing with the splash screens.

  Scene_Splash.prototype = Object.create(Scene_Base.prototype);
  Scene_Splash.prototype.constructor = Scene_Splash;

  Scene_Splash.prototype.initialize = function () {
    Scene_Base.prototype.initialize.call(this);
    this._mvSplash = null;
    this._customSplash = null;
    this._mvWaitTime = Liquidize.MadeWithMV.WaitTime;
    this._customWaitTime = Liquidize.MadeWithMV.WaitTime;
    this._mvFadeOut = false;
    this._mvFadeIn = false;
    this._customFadeOut = false;
    this._customFadeIn = false;
  };

  Scene_Splash.prototype.create = function () {
    Scene_Base.prototype.create.call(this);
    this.createSplashes();
  };

  Scene_Splash.prototype.start = function () {
    Scene_Base.prototype.start.call(this);
    SceneManager.clearStack();
    if (this._mvSplash != null) {
      this.centerSprite(this._mvSplash);
    }
    if (this._customSplash != null) {
      this.centerSprite(this._customSplash);
    }
  };

  Scene_Splash.prototype.update = function () {
    if (Liquidize.MadeWithMV.ShowMV) {
      if (!this._mvFadeIn) {
        this.startFadeIn(Liquidize.MadeWithMV.FadeInTime, false);
        this._mvFadeIn = true;
      } else {
        if (this._mvWaitTime > 0 && this._mvFadeOut == false) {
          this._mvWaitTime--;
        } else {
          if (this._mvFadeOut == false) {
            this._mvFadeOut = true;
            this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime, false);
          }
        }
      }
    }

    if (Liquidize.MadeWithMV.ShowCustom) {
      if (Liquidize.MadeWithMV.ShowMV && this._mvFadeOut == true) {
        if (!this._customFadeIn && this._fadeDuration == 0) {
          this._customSplash.opacity = 255;
          this._customWaitTime = Liquidize.MadeWithMV.WaitTime;
          this.startFadeIn(Liquidize.MadeWithMV.FadeInTime, false);
          this._customFadeIn = true;
        } else {
          if (this._customWaitTime > 0 && this._customFadeOut == false) {
            this._customWaitTime--;
          } else {
            if (this._customFadeOut == false) {
              this._customFadeOut = true;
              this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime, false);
            }
          }
        }
      } else if (!Liquidize.MadeWithMV.ShowMV) {
        if (!this._customFadeIn) {
          this._customSplash.opacity = 255;
          this.startFadeIn(Liquidize.MadeWithMV.FadeInTime, false);
          this._customFadeIn = true;
        } else {
          if (this._customWaitTime > 0 && this._customFadeOut == false) {
            this._customWaitTime--;
          } else {
            if (this._customFadeOut == false) {
              this._customFadeOut = true;
              this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime, false);
            }
          }
        }
      }
    }

    if (Liquidize.MadeWithMV.ShowCustom) {
      if (
        Liquidize.MadeWithMV.ShowMV &&
        this._mvFadeOut == true &&
        this._customFadeOut == true
      ) {
        this.gotoTitleOrTest();
      } else if (!Liquidize.MadeWithMV.ShowMV && this._customFadeOut == true) {
        this.gotoTitleOrTest();
      }
    } else {
      if (this._mvFadeOut == true) {
        this.gotoTitleOrTest();
      }
    }

    Scene_Base.prototype.update.call(this);
  };

  Scene_Splash.prototype.createSplashes = function () {
    if (Liquidize.MadeWithMV.ShowMV) {
      this._mvSplash = new Sprite(
        ImageManager.loadSystem(Liquidize.MadeWithMV.MVImage)
      );
      this.addChild(this._mvSplash);
    }
    if (Liquidize.MadeWithMV.ShowCustom) {
      this._customSplash = new Sprite(
        ImageManager.loadSystem(Liquidize.MadeWithMV.CustomImage)
      );
      this._customSplash.opacity = 0;
      this.addChild(this._customSplash);
    }
  };

  Scene_Splash.prototype.centerSprite = function (sprite) {
    sprite.x = Graphics.width / 2;
    sprite.y = Graphics.height / 2;
    sprite.anchor.x = 0.5;
    sprite.anchor.y = 0.5;
  };

  Scene_Splash.prototype.gotoTitleOrTest = function () {
    Scene_Base.prototype.start.call(this);
    SoundManager.preloadImportantSounds();
    if (DataManager.isBattleTest()) {
      DataManager.setupBattleTest();
      SceneManager.goto(Scene_Battle);
    } else if (DataManager.isEventTest()) {
      DataManager.setupEventTest();
      SceneManager.goto(Scene_Map);
    } else {
      this.checkPlayerLocation();
      DataManager.setupNewGame();
      SceneManager.goto(Scene_Title);
      Window_TitleCommand.initCommandPosition();
    }
    this.updateDocumentTitle();
  };

  Scene_Splash.prototype.updateDocumentTitle = function () {
    document.title = $dataSystem.gameTitle;
  };

  Scene_Splash.prototype.checkPlayerLocation = function () {
    if ($dataSystem.startMapId === 0) {
      throw new Error("Player's starting position is not set");
    }
  };
})();