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

/*:
 * @plugindesc 【ver.3.19】マウスやタッチ操作を変更します。
 * @author 木星ペンギン
 *
 * @help プラグインコマンド:
 *   CancelOff           # 次の[選択肢の表示]でキャンセルSEを鳴らさない
 *
 * ================================
 *  本プラグインを導入した場合、以下のように機能が変更・追加されます
 *
 * --------------------------------
 * ●カーソル移動
 *  プラグインパラメータ[Select Type Default]にて、
 *  [カーソル移動]方法を変更できます。
 *  この設定はゲーム内のオプションからでも変更可能です。
 *
 *  ▽0 (タッチ)
 *   項目をタッチした時点でカーソル移動を行います。
 *
 *  ▽1 (追従)
 *   常にマウスの位置にカーソルが移動します。
 *
 * --------------------------------
 * ●決定操作
 *  プラグインパラメータ[Ok Type Default]にて、[決定操作]方法を変更できます。
 *  この設定はゲーム内のオプションからでも変更可能です。
 *
 *  ▽0 (デフォルト)
 *   カーソルとタッチした項目が一致していれば【決定】、
 *   そうでなければ【カーソル移動】のみとなります。
 *
 *   ツクールＭＶのデフォルト操作と似ていますが、
 *   【決定】は短くタッチした際に行われ、長押しでは何も行いません。
 *
 *  ▽1 (シングル)
 *   項目を短くタッチすると【決定】を行います。
 *   長押しでは何も行いません。
 *
 *  ▽2 (ダブル)
 *   同じ項目で短いタッチを二度行うと【決定】を行います。
 *   長押しでは何も行いません。
 *
 * --------------------------------
 * ●スクロール
 *  ウィンドウをタッチしたまま上下にスライドすると、スクロールを行います。
 *  フリック操作でしばらく自動でスクロールを行います。
 *
 *  プラグインパラメータ[Scroll Warp?]を有効にした場合、
 *  最初の項目が表示されている状態で下にスクロールすると最後の項目に、
 *  最後の項目が表示されている状態で上にスクロールすると最初の項目に移動します。
 *
 * --------------------------------
 * ●キャンセル操作
 *  ▽プラグインパラメータ[Cancel Enabled?]により、
 *    右クリックや二本指タップによるウィンドウのキャンセルを
 *    無効にすることができます。
 *
 *  ▽プラグインパラメータ[Outside Tap Default]により、
 *    ウィンドウの外側をタップした際に【キャンセル】を行う機能を追加できます。
 *    この設定はゲーム内のオプションからでも変更可能です。
 *
 * --------------------------------
 * ●ページ切り替え
 *  画面をタッチした後、左右にスワイプすると【ページ切り替え】を行います。
 *
 *  この操作は【外側タップ】の【キャンセル】操作より優先されているため、
 *  ウィンドウの外側でスワイプしても機能します。
 *
 * --------------------------------
 * ●その他補足
 *  ステータス画面で画面をタッチすると【キャンセル】を行います。
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param Cancel Enabled?
 * @type boolean
 * @desc 右クリックまたは二本指タップによるキャンセルの有効/無効
 * @default true
 *
 * @param Double Tap Interval
 * @type number
 * @desc ダブルタップの間隔
 * @default 30
 *
 * @param Cursor SE Always?
 * @type boolean
 * @desc タッチした際、常にカーソルSEを鳴らすかどうか
 * @default false
 *
 * @param Scroll Warp?
 * @type boolean
 * @desc スクロールワープの有効/無効
 * @default false
 *
 * @param Scroll Warp SE
 * @type struct<SE>
 * @desc スクロールワープ時のSE
 * @default {"Name":"","Volume":"90","Pitch":"100","Pan":"0"}
 * @parent Scroll Warp?
 *
 * @param Smooth Scroll?
 * @type boolean
 * @desc スクロールのスムーズな動作
 * @default true
 *
 *
 * @param === Default ===
 *
 * @param Long Press Time
 * @type number
 * @desc 決定を取り消すまでの長押しの時間 (フレーム数)
 * @default 12
 * @parent === Default ===
 *
 * @param Select Type Default
 * @type number
 * @max 1
 * @desc [カーソル移動]のデフォルト値
 * (0:タッチ, 1:追従)
 * @default 1
 * @parent === Default ===
 *
 * @param Ok Type Default
 * @type number
 * @max 2
 * @desc [決定操作]のデフォルト値
 * (0:デフォルト, 1:シングル, 2:ダブル)
 * @default 0
 * @parent === Default ===
 *
 * @param Outside Tap Default
 * @type number
 * @max 1
 * @desc [外側タップ]のデフォルト値
 * (0:無効, 1:キャンセル)
 * @default 1
 * @parent === Default ===
 *
 *
 * @param === Option ===
 *
 * @param Long Press Name
 * @desc オプション画面に表示する[長押し時間]の名前
 * (空の場合は表示しない)
 * @default
 * @parent === Option ===
 *
 * @param Select Type Name
 * @desc オプション画面に表示する[カーソル移動]の名前
 * (空の場合は表示しない)
 * @default
 * @parent === Option ===
 *
 * @param Select Type Status
 * @type string[]
 * @desc オプション画面に表示する[カーソル移動]のステータス名
 * @default ["タッチ","追従"]
 * @parent Select Type Name
 *
 * @param Ok Type Name
 * @desc オプション画面に表示する[決定操作]の名前
 * (空の場合は表示しない)
 * @default 決定操作
 * @parent === Option ===
 *
 * @param Ok Type Status _v3
 * @type string[]
 * @desc オプション画面に表示する[決定操作]のステータス名
 * (カンマで区切ってください)
 * @default ["デフォルト","シングル","ダブル"]
 * @parent Ok Type Name
 *
 * @param Outside Tap Name
 * @desc オプション画面に表示する[外側タップ]の名前
 * (空の場合は表示しない)
 * @default
 * @parent === Option ===
 *
 * @param Outside Tap Status _v3
 * @type string[]
 * @desc オプション画面に表示する[外側タップ]のステータス名
 * (カンマで区切ってください)
 * @default ["無効","キャンセル"]
 * @parent Outside Tap Name
 *
 * @param === Command ===
 *
 * @param Plugin Commands
 * @type struct<Plugin>
 * @desc プラグインコマンド名
 * @default {"CancelOff":"CancelOff"}
 * @parent === Command ===
 *
 *
 *
 */

/*~struct~SE:
 * @param Name
 * @desc ファイル名
 * @default
 * @require 1
 * @dir audio/se
 * @type file
 *
 * @param Volume
 * @type number
 * @max 100
 * @desc 音量
 * @default 90
 *
 * @param Pitch
 * @type number
 * @min 50
 * @max 150
 * @desc ピッチ
 * @default 100
 *
 * @param Pan
 * @type number
 * @min -100
 * @max 100
 * @desc 位相
 * @default 0
 *
 */

/*~struct~Plugin:
 * @param CancelOff
 * @desc 次の[選択肢の表示]でキャンセルSEを鳴らさない
 * @default CancelOff
 *
 */

//=============================================================================
// Main
//=============================================================================

(function (exports) {
  "use strict";

  const Params = {};

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

    Params.CancelEnabled = !!eval(parameters["Cancel Enabled?"]);
    Params.LongPressTime = Number(parameters["Long Press Time"] || 15);
    Params.DoubleTapInterval = Number(parameters["Double Tap Interval"] || 30);
    Params.CursorSeAlways = !!eval(parameters["Cursor SE Always?"]);
    Params.ScrollWarp = !!eval(parameters["Scroll Warp?"]);
    let param = JSON.parse(parameters["Scroll Warp SE"]);
    Params.ScrollWarpSE = {
      name: param.Name || "",
      volume: Number(param.Volume || 90),
      pitch: Number(param.Pitch || 100),
      pan: Number(param.Pan || 0),
    };
    Params.SmoothScroll = !!eval(parameters["Smooth Scroll?"] || "true");

    // === Default ===
    Params.SelectTypeDefault = Number(parameters["Select Type Default"] || 1);
    Params.OkTypeDefault = Number(parameters["Ok Type Default"] || 0);
    Params.OutsideTapDefault = Number(parameters["Outside Tap Default"] || 1);

    // === Option ===
    Params.LongPressName = parameters["Long Press Name"] || "";
    Params.SelectTypeName = parameters["Select Type Name"] || "";
    Params.SelectTypeStatus = JSON.parse(
      parameters["Select Type Status"] || "[]"
    );
    Params.OkTypeName = parameters["Ok Type Name"] || "";
    Params.OkTypeStatus = JSON.parse(parameters["Ok Type Status _v3"] || "[]");
    Params.OutsideTapName = parameters["Outside Tap Name"] || "";
    Params.OutsideTapStatus = JSON.parse(
      parameters["Outside Tap Status _v3"] || "[]"
    );

    // === Command ===
    Params.PluginCommands = JSON.parse(parameters["Plugin Commands"]);
  }

  const Alias = {};
  const Method = {};

  //=============================================================================
  // Option
  //=============================================================================

  //-----------------------------------------------------------------------------
  // MppOptions

  function MppOptions() {
    throw new Error("This is a static class");
  }

  MppOptions.params = [];
  MppOptions.params.push(
    {
      symbol: "mppLongPress",
      name: Params.LongPressName,
      status: [],
      def: Params.LongPressTime,
    },
    {
      symbol: "mppSelectType",
      name: Params.SelectTypeName,
      status: Params.SelectTypeStatus,
      def: Params.SelectTypeDefault,
    },
    {
      symbol: "mppOkType",
      name: Params.OkTypeName,
      status: Params.OkTypeStatus,
      def: Params.OkTypeDefault,
    },
    {
      symbol: "mppOutsideTap",
      name: Params.OutsideTapName,
      status: Params.OutsideTapStatus,
      def: Params.OutsideTapDefault,
    }
  );

  Object.defineProperties(MppOptions, {
    longPress: {
      get: function () {
        return this.getter("mppLongPress");
      },
    },
    selectType: {
      get: function () {
        return this.getter("mppSelectType");
      },
    },
    okType: {
      get: function () {
        return this.getter("mppOkType");
      },
    },
    outsideTap: {
      get: function () {
        return this.getter("mppOutsideTap");
      },
    },
  });

  MppOptions.isSymbol = function (symbol) {
    return this.params.some((param) => param.symbol === symbol);
  };

  MppOptions.getStatus = function (symbol) {
    for (var i = 0; i < this.params.length; i++) {
      if (this.params[i].symbol === symbol) return this.params[i].status;
    }
    return [];
  };

  MppOptions.getter = function (symbol) {
    for (var i = 0; i < this.params.length; i++) {
      var param = this.params[i];
      if (param.symbol === symbol) {
        return param.name ? ConfigManager[param.symbol] : param.def;
      }
    }
    return 0;
  };

  //-----------------------------------------------------------------------------
  // ConfigManager

  for (let i = 0; i < MppOptions.params.length; i++) {
    let param = MppOptions.params[i];
    ConfigManager[param.symbol] = param.def;
  }

  //71
  Alias.CoMa_makeData = ConfigManager.makeData;
  ConfigManager.makeData = function () {
    var config = Alias.CoMa_makeData.call(this);
    var params = MppOptions.params;
    for (var i = 0; i < params.length; i++) {
      var symbol = params[i].symbol;
      config[symbol] = this[symbol];
    }
    return config;
  };

  //82
  Alias.CoMa_applyData = ConfigManager.applyData;
  ConfigManager.applyData = function (config) {
    Alias.CoMa_applyData.call(this, config);
    var params = MppOptions.params;
    for (var i = 0; i < params.length; i++) {
      var symbol = params[i].symbol;
      if (typeof config[symbol] === "number") this[symbol] = config[symbol];
    }
  };

  //-----------------------------------------------------------------------------
  // Window_Options

  //31
  Alias.WiOp_makeCommandList = Window_Options.prototype.makeCommandList;
  Window_Options.prototype.makeCommandList = function () {
    var params = MppOptions.params;
    for (var i = 0; i < params.length; i++) {
      if (params[i].name) this.addCommand(params[i].name, params[i].symbol);
    }
    Alias.WiOp_makeCommandList.call(this);
  };

  //62
  Alias.WiOp_statusText = Window_Options.prototype.statusText;
  Window_Options.prototype.statusText = function (index) {
    var symbol = this.commandSymbol(index);
    if (symbol === "mppLongPress") {
      return this.getConfigValue(symbol);
    } else if (MppOptions.isSymbol(symbol)) {
      var status = MppOptions.getStatus(symbol);
      var value = this.getConfigValue(symbol);
      return status[value];
    } else {
      return Alias.WiOp_statusText.call(this, index);
    }
  };

  //84
  Alias.WiOp_processOk = Window_Options.prototype.processOk;
  Window_Options.prototype.processOk = function () {
    var index = this.index();
    var symbol = this.commandSymbol(index);
    if (symbol === "mppLongPress") {
      var value = this.getConfigValue(symbol);
      value += 3;
      if (value > 30) value = 6;
      this.changeValue(symbol, value);
    } else if (MppOptions.isSymbol(symbol)) {
      var status = MppOptions.getStatus(symbol);
      var value = this.getConfigValue(symbol);
      value++;
      if (value >= status.length) value = 0;
      value = value.clamp(0, status.length - 1);
      this.changeValue(symbol, value);
    } else {
      Alias.WiOp_processOk.call(this);
    }
  };

  //100
  Alias.WiOp_cursorRight = Window_Options.prototype.cursorRight;
  Window_Options.prototype.cursorRight = function (wrap) {
    var index = this.index();
    var symbol = this.commandSymbol(index);
    if (symbol === "mppLongPress") {
      var value = this.getConfigValue(symbol);
      value += 3;
      if (value > 30) value = 6;
      this.changeValue(symbol, value);
    } else if (MppOptions.isSymbol(symbol)) {
      var status = MppOptions.getStatus(symbol);
      var value = this.getConfigValue(symbol);
      value++;
      value = value.clamp(0, status.length - 1);
      this.changeValue(symbol, value);
    } else {
      Alias.WiOp_cursorRight.call(this, wrap);
    }
  };

  //113
  Alias.WiOp_cursorLeft = Window_Options.prototype.cursorLeft;
  Window_Options.prototype.cursorLeft = function (wrap) {
    var index = this.index();
    var symbol = this.commandSymbol(index);
    if (symbol === "mppLongPress") {
      var value = this.getConfigValue(symbol);
      value -= 3;
      if (value < 6) value = 30;
      this.changeValue(symbol, value);
    } else if (MppOptions.isSymbol(symbol)) {
      var status = MppOptions.getStatus(symbol);
      var value = this.getConfigValue(symbol);
      value--;
      value = value.clamp(0, status.length - 1);
      this.changeValue(symbol, value);
    } else {
      Alias.WiOp_cursorLeft.call(this, wrap);
    }
  };

  //=============================================================================
  // Main
  //=============================================================================

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

  //6718
  var _alias_WCCC_Window_refreshCursor = Window.prototype._refreshCursor;
  Window.prototype._refreshCursor = function () {
    var w = this._cursorRect.width;
    var h = this._cursorRect.height;
    var m = 4;
    var bitmap = new Bitmap(w, h);

    this._windowCursorSprite.bitmap = bitmap;
    _alias_WCCC_Window_refreshCursor.call(this);

    if (w > 0 && h > 0 && this._windowskin) {
      var skin = this._windowskin;
      var p = 96;
      var q = 48;
      bitmap.blt(
        skin,
        p + m,
        p + m,
        q - m * 2,
        q - m * 2,
        m,
        m,
        w - m * 2,
        h - m * 2
      );
      bitmap.blt(skin, p + m, p + 0, q - m * 2, m, m, 0, w - m * 2, m);
      bitmap.blt(skin, p + m, p + q - m, q - m * 2, m, m, h - m, w - m * 2, m);
      bitmap.blt(skin, p + 0, p + m, m, q - m * 2, 0, m, m, h - m * 2);
      bitmap.blt(skin, p + q - m, p + m, m, q - m * 2, w - m, m, m, h - m * 2);
      bitmap.blt(skin, p + 0, p + 0, m, m, 0, 0, m, m);
      bitmap.blt(skin, p + q - m, p + 0, m, m, w - m, 0, m, m);
      bitmap.blt(skin, p + 0, p + q - m, m, m, 0, h - m, m, m);
      bitmap.blt(skin, p + q - m, p + q - m, m, m, w - m, h - m, m, m);
    }
    this._updateCursorPos();
  };

  //6804
  Alias.Wi_updateCursor = Window.prototype._updateCursor;
  Window.prototype._updateCursor = function () {
    Alias.Wi_updateCursor.call(this);
    this._updateCursorPos();
  };

  Window.prototype._updateCursorPos = function () {
    var pad = this._padding;
    var x = this._cursorRect.x + pad - this.origin.x;
    var y = this._cursorRect.y + pad - this.origin.y;
    var w = this._cursorRect.width;
    var h = this._cursorRect.height;
    var x2 = Math.max(x, pad);
    var y2 = Math.max(y, pad);
    var ox = x2 - x;
    var oy = y2 - y;
    var w2 = Math.min(w, this._width - pad - x2);
    var h2 = Math.min(h, this._height - pad - y2);

    this._windowCursorSprite.setFrame(ox, oy, w2, h2);
    this._windowCursorSprite.move(x2, y2);
  };

  //-----------------------------------------------------------------------------
  // TouchInput

  //3487
  Alias.ToIn_clear = TouchInput.clear;
  TouchInput.clear = function () {
    Alias.ToIn_clear.call(this);
    this.mppStartX = 0;
    this.mppStartY = 0;
    this._mppLeftSwipe = false;
    this._mppRightSwipe = false;
    this._mppOk = false;
    this._mppDoubleTap = false;
    this._mppInterval = -1;
  };

  //3515
  Alias.ToIn_update = TouchInput.update;
  TouchInput.update = function () {
    Alias.ToIn_update.call(this);
    if (this.isReleased()) {
      if (this._pressedTime >= 6) {
        var sx = (this._x - this.mppStartX) / this._pressedTime;
        this._mppLeftSwipe = sx < -6;
        this._mppRightSwipe = sx > 6;
      } else {
        this._mppLeftSwipe = false;
        this._mppRightSwipe = false;
      }
      if (
        !this._mppLeftSwipe &&
        !this._mppRightSwipe &&
        this._pressedTime <= MppOptions.longPress
      ) {
        this._mppOk = true;
        var i = this._mppInterval;
        this._mppDoubleTap = i >= 0 && i < Params.DoubleTapInterval;
        this._mppInterval = 0;
      } else {
        this._mppOk = false;
        this._mppDoubleTap = false;
        this._mppInterval = -1;
      }
    } else {
      this._mppLeftSwipe = false;
      this._mppRightSwipe = false;
      this._mppOk = false;
      this._mppDoubleTap = false;
      if (this._mppInterval >= 0) this._mppInterval++;
    }
  };

  TouchInput.isMppLeftSwipe = function () {
    return this._mppLeftSwipe;
  };

  TouchInput.isMppRightSwipe = function () {
    return this._mppRightSwipe;
  };

  TouchInput.isMppOk = function () {
    return this._mppOk;
  };

  TouchInput.isMppDoubleTap = function () {
    return this._mppDoubleTap;
  };

  //3763
  Alias.ToIn__onMouseMove = TouchInput._onMouseMove;
  TouchInput._onMouseMove = function (event) {
    if (MppOptions.selectType === 0) {
      Alias.ToIn__onMouseMove.apply(this, arguments);
    } else {
      var x = Graphics.pageToCanvasX(event.pageX);
      var y = Graphics.pageToCanvasY(event.pageY);
      if (Graphics.isInsideCanvas(x, y)) {
        this._onMove(x, y);
        this._date = Date.now();
      }
    }
  };

  //3891
  Alias.ToIn__onTrigger = TouchInput._onTrigger;
  TouchInput._onTrigger = function (x, y) {
    Alias.ToIn__onTrigger.apply(this, arguments);
    this.mppStartX = x;
    this.mppStartY = y;
  };

  TouchInput.clearMppInterval = function () {
    this._mppInterval = -1;
  };

  //-----------------------------------------------------------------------------
  // SoundManager

  //37
  Alias.SoMa_playCancel = SoundManager.playCancel;
  SoundManager.playCancel = function () {
    if (!$gameMessage.cancelOff) Alias.SoMa_playCancel.call(this);
  };

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

  //15
  Alias.GaMe_clear = Game_Message.prototype.clear;
  Game_Message.prototype.clear = function () {
    Alias.GaMe_clear.call(this);
    this.cancelOff = false;
  };

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

  //1739
  Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    Alias.GaIn_pluginCommand.call(this, command, args);
    switch (command) {
      case Params.PluginCommands.CancelOff:
      case "CancelOff":
        $gameMessage.cancelOff = true;
    }
  };

  //-----------------------------------------------------------------------------
  // Window_Selectable

  //13
  Alias.WiSe_initialize = Window_Selectable.prototype.initialize;
  Window_Selectable.prototype.initialize = function (x, y, width, height) {
    Alias.WiSe_initialize.apply(this, arguments);
    this._originYSpeed = [];
    this._scrollOyDuration = 0;
    this._targetOy = 0;
    this._cursorMoveDuration = 0;
    this._cursorX = -1;
    this._cursorY = -1;
    this._targetCursorX = -1;
    this._targetCursorY = -1;
  };

  //
  if (Window_Selectable.prototype.hasOwnProperty("contentsHeight")) {
    Alias.WiSe_contentsHeight = Window_Selectable.prototype.contentsHeight;
  }
  Window_Selectable.prototype.contentsHeight = function () {
    if (Alias.WiSe_contentsHeight) {
      return Alias.WiSe_contentsHeight.call(this) + this.itemHeight();
    } else {
      return (
        Window_Base.prototype.contentsHeight.call(this) + this.itemHeight()
      );
    }
  };

  //110
  Alias.WiSe_setTopRow = Window_Selectable.prototype.setTopRow;
  Window_Selectable.prototype.setTopRow = function (row) {
    if (this.isSmoothScroll()) {
      this.startScrollOy(row * this.itemHeight());
    } else {
      Alias.WiSe_setTopRow.apply(this, arguments);
      this.resetOy();
    }
  };

  Window_Selectable.prototype.isSmoothScroll = function () {
    return Params.SmoothScroll && this.visible && this.isOpen();
  };

  Window_Selectable.prototype.isTouchFollowing = function () {
    return TouchInput.date > Input.date && MppOptions.selectType === 1;
  };

  Window_Selectable.prototype.skipSmoothScroll = function () {
    if (this._scrollOyDuration > 0) {
      this._scrollOyDuration = 0;
      this.gainOy(this._targetOy - this._scrollY - this.origin.y);
    }
    if (this._cursorMoveDuration > 0) {
      this._cursorMoveDuration = 0;
      this._cursorX = this._targetCursorX;
      this._cursorY = this._targetCursorY;
      this.refreshSmoothCursor();
    }
  };

  Window_Selectable.prototype.startScrollOy = function (oy) {
    this._scrollOyDuration = 6;
    this._targetOy = oy.clamp(0, this.maxTopRow() * this.itemHeight());
  };

  //119
  Alias.WiSe_resetScroll = Window_Selectable.prototype.resetScroll;
  Window_Selectable.prototype.resetScroll = function () {
    Alias.WiSe_resetScroll.call(this);
    this.resetOy();
  };

  //140
  Window_Selectable.prototype.setBottomRow = function (row) {
    var oy = (row + 1) * this.itemHeight() - this.height + this.padding * 2;
    if (this.isSmoothScroll()) {
      this.startScrollOy(oy);
    } else {
      this.setOy(oy - this._scrollY);
    }
  };

  Window_Selectable.prototype.resetOy = function () {
    this.origin.y = 0;
    this._originYSpeed = [];
    this._scrollOyDuration = 0;
  };

  Window_Selectable.prototype.setOy = function (oy) {
    var sr = Math.floor(oy / this.itemHeight());
    var topRow = this.topRow();
    if (sr !== 0) Alias.WiSe_setTopRow.call(this, topRow + sr);
    if (
      (topRow <= 0 && oy < 0) ||
      (this.topRow() >= this.maxTopRow() && oy > 0)
    ) {
      this.resetOy();
    } else {
      this.origin.y = oy.mod(this.itemHeight());
    }
  };

  Window_Selectable.prototype.gainOy = function (amount) {
    this.setOy(Math.floor(this.origin.y + amount));
  };

  //258
  Alias.WiSe_scrollDown = Window_Selectable.prototype.scrollDown;
  Window_Selectable.prototype.scrollDown = function () {
    if (this.isSmoothScroll()) {
      this.setTopRow(this.targetTopRow() + 1);
    } else {
      Alias.WiSe_scrollDown.call(this);
      this.resetOy();
    }
  };

  //264
  Alias.WiSe_scrollUp = Window_Selectable.prototype.scrollUp;
  Window_Selectable.prototype.scrollUp = function () {
    if (this.isSmoothScroll()) {
      if (this._scrollOyDuration === 0 && this.origin.y > 0) {
        this.setTopRow(this.topRow());
      } else {
        this.setTopRow(this.targetTopRow() - 1);
      }
    } else if (this.origin.y > 0) {
      this.resetOy();
    } else {
      Alias.WiSe_scrollUp.call(this);
      this.resetOy();
    }
  };

  Window_Selectable.prototype.targetTopRow = function () {
    if (this._scrollOyDuration > 0) {
      return Math.floor(this._targetOy / this.itemHeight());
    } else {
      return this.topRow();
    }
  };

  //270
  Alias.WiSe_update = Window_Selectable.prototype.update;
  Window_Selectable.prototype.update = function () {
    Alias.WiSe_update.call(this);
    this.updateSmoothScroll();
    this.updateSmoothCursor();
  };

  //280
  Alias.WiSe_updateArrows = Window_Selectable.prototype.updateArrows;
  Window_Selectable.prototype.updateArrows = function () {
    Alias.WiSe_updateArrows.call(this);
    var bottomY = this.maxRows() * this.itemHeight();
    var realY = this._scrollY + this.origin.y + this.height - this.padding * 2;
    this.downArrowVisible = this.downArrowVisible && bottomY > realY;
    this.upArrowVisible = this.upArrowVisible || this.origin.y > 0;
  };

  //340
  Window_Selectable.prototype.processTouch = function () {
    if (this.isOpenAndActive()) {
      if (TouchInput.isTriggered()) {
        this._touching = true;
        this._selecting = true;
        this._touchLastY = TouchInput.y;
        this._touchInsided = this.isTouchedInsideFrame();
        this._touchWarpUp = false;
        this._touchWarpDown = false;
        if (
          Params.ScrollWarp &&
          this._touchInsided &&
          this.origin.y === 0 &&
          this.maxRows() > this.maxPageRows()
        ) {
          this._touchWarpUp = this.topRow() === 0;
          this._touchWarpDown = this.topRow() === this.maxTopRow();
        }
        this._originYSpeed = [];
      } else if (TouchInput.isCancelled()) {
        if (Params.CancelEnabled && this.isCancelEnabled()) {
          this.processCancel();
        }
      }
      if (this._touching) {
        if (TouchInput.isTriggered()) {
          this.onTouch(false);
        } else if (TouchInput.isPressed()) {
          if (this.touchScroll()) {
            this._selecting = false;
          }
        } else {
          this.touchSwipe();
          if (this._selecting && TouchInput.isMppOk()) {
            this.onTouch(true);
          } else {
            TouchInput.clearMppInterval();
          }
          this._touching = false;
          this._selecting = false;
        }
      }
      if (!this._touching) {
        if (this._originYSpeed.length > 0) {
          this.addOriginYSpeed(this._originYSpeed[0] * 0.9);
          if (Math.abs(this.originYSpeed()) < 2) this._originYSpeed = [];
        } else if (this.isTouchFollowing() && TouchInput.isMoved()) {
          this.onTouch(false);
        }
      }
      this.updateTouchScroll();
    } else {
      this._touching = false;
      this._selecting = false;
      this._touchInside = false;
      this._touchWarpUp = false;
      this._touchWarpDown = false;
    }
  };

  Window_Selectable.prototype.addOriginYSpeed = function (speed) {
    this._originYSpeed.push(speed);
    if (this._originYSpeed.length > 3) {
      this._originYSpeed.shift();
    }
  };

  Window_Selectable.prototype.originYSpeed = function () {
    if (this._touching) {
      return this._originYSpeed[this._originYSpeed.length - 1] || 0;
    }
    var speed = 0;
    for (var i = 0; i < this._originYSpeed.length; i++) {
      speed += this._originYSpeed[i];
    }
    return speed / (this._originYSpeed.length || 1);
  };

  Window_Selectable.prototype.touchScroll = function () {
    if (this._touchInsided) {
      this.addOriginYSpeed(this._touchLastY - TouchInput.y);
      this._touchLastY = TouchInput.y;
      return Math.abs(TouchInput.y - TouchInput.mppStartY) > 12;
    }
    return false;
  };

  Window_Selectable.prototype.touchSwipe = function () {
    if (TouchInput.isMppLeftSwipe()) {
      if (this.isHandled("pageup")) this.processPageup();
    } else if (TouchInput.isMppRightSwipe()) {
      if (this.isHandled("pagedown")) this.processPagedown();
    }
  };

  Window_Selectable.prototype.updateTouchScroll = function () {
    if (this._touchWarpUp || this._touchWarpDown) {
      var height = this.itemHeight();
      if (TouchInput.mppStartY - TouchInput.y < -height) {
        if (this._touchWarpUp) {
          AudioManager.playStaticSe(Params.ScrollWarpSE);
          this.setTopRow(this.maxTopRow());
          this._touching = false;
          this._originYSpeed = [];
          if (!this.isSmoothScroll()) this.resetOy();
        }
        this._touchWarpUp = false;
        this._touchWarpDown = false;
      } else if (TouchInput.mppStartY - TouchInput.y > height) {
        if (this._touchWarpDown) {
          AudioManager.playStaticSe(Params.ScrollWarpSE);
          this.setTopRow(0);
          this._touching = false;
          this._originYSpeed = [];
          if (!this.isSmoothScroll()) this.resetOy();
        }
        this._touchWarpUp = false;
        this._touchWarpDown = false;
      }
    }
    if (this._touchInsided && this._originYSpeed.length > 0) {
      this.gainOy(this.originYSpeed());
    }
  };

  //368
  Alias.WiSe_onTouch = Window_Selectable.prototype.onTouch;
  Window_Selectable.prototype.onTouch = function (triggered) {
    if (triggered) {
      if (
        MppOptions.outsideTap === 1 &&
        !this._touchInsided &&
        !this.isTouchedInsideFrame()
      ) {
        if (this.isCancelEnabled()) this.processCancel();
      } else if (MppOptions.okType < 2 || TouchInput.isMppDoubleTap()) {
        TouchInput.clearMppInterval();
        this._stayCount = 0;
        Alias.WiSe_onTouch.call(this, triggered);
      }
    } else {
      var lastIndex = this.index();
      this._stayCount = 0;
      Alias.WiSe_onTouch.call(this, triggered);
      if (this.index() !== lastIndex) {
        TouchInput.clearMppInterval();
        if (MppOptions.okType === 0) {
          this._selecting = false;
        }
      } else if (Params.CursorSeAlways) {
        var x = this.canvasToLocalX(TouchInput.x);
        var y = this.canvasToLocalY(TouchInput.y);
        if (this.isContentsArea(x, y)) {
          SoundManager.playCursor();
        }
      }
    }
  };

  //393
  Window_Selectable.prototype.hitTest = function (x, y) {
    if (this.isContentsArea(x, y)) {
      var cx = x - this.padding;
      var cy = y - this.padding + this.origin.y;
      var topIndex = this.topIndex();
      var maxPageItems = this.maxPageItems() + this.maxCols();
      for (var i = 0; i < maxPageItems; i++) {
        var index = topIndex + i;
        if (index < this.maxItems()) {
          var rect = this.itemRect(index);
          var right = rect.x + rect.width;
          var bottom = rect.y + rect.height;
          if (cx >= rect.x && cy >= rect.y && cx < right && cy < bottom) {
            return index;
          }
        }
      }
    }

    return -1;
  };

  //494
  Alias.WiSe_updateCursor = Window_Selectable.prototype.updateCursor;
  Window_Selectable.prototype.updateCursor = function () {
    Alias.WiSe_updateCursor.call(this);
    if (!this._cursorAll) {
      var rect = this.itemRect(this.index());
      this._targetCursorX = rect.x + this._scrollX;
      this._targetCursorY = rect.y + this._scrollY;
      if (
        this.isSmoothScroll() &&
        this._cursorX >= 0 &&
        this._cursorY >= 0 &&
        this.index() >= 0
      ) {
        this._cursorMoveDuration = 6;
      } else {
        this._cursorX = this._targetCursorX;
        this._cursorY = this._targetCursorY;
      }
      this.refreshSmoothCursor();
    } else {
      this.resetOy();
    }
  };

  //507
  Window_Selectable.prototype.isCursorVisible = function () {
    var row = this.row();
    return row >= this.topRow() && row <= this.bottomRow() + 1;
  };

  Window_Selectable.prototype.updateSmoothScroll = function () {
    if (this._scrollOyDuration > 0) {
      var d = this._scrollOyDuration;
      var realOy = this._scrollY + this.origin.y;
      this.gainOy(((this._targetOy - realOy) * d) / Method.tri(d));
      this._scrollOyDuration--;
      if (this._scrollOyDuration === 0 && this.isTouchFollowing()) {
        this.onTouch(false);
      }
    }
  };
  Method.tri = function (n) {
    return (n * (n + 1)) / 2;
  };

  Window_Selectable.prototype.updateSmoothCursor = function () {
    if (this._cursorMoveDuration > 0) {
      var d = this._cursorMoveDuration;
      this._cursorX +=
        ((this._targetCursorX - this._cursorX) * d) / Method.tri(d);
      this._cursorY +=
        ((this._targetCursorY - this._cursorY) * d) / Method.tri(d);
      this._cursorMoveDuration--;
      this.refreshSmoothCursor();
    }
  };

  Window_Selectable.prototype.refreshSmoothCursor = function () {
    var rect = this.itemRect(this.index());
    var cy = this._cursorY - this._scrollY;
    var pageHeight = this.height - this.padding * 2;
    if (cy + rect.height >= 0 && cy < pageHeight + rect.height) {
      var cx = this._cursorX - this._scrollX;
      this.setCursorRect(cx, cy, rect.width, rect.height);
    } else {
      this.setCursorRect(0, 0, 0, 0);
    }
  };

  //512
  Alias.WiSe_ensureCursorVisible =
    Window_Selectable.prototype.ensureCursorVisible;
  Window_Selectable.prototype.ensureCursorVisible = function () {
    Alias.WiSe_ensureCursorVisible.call(this);
    if (this.row() === this.topRow()) {
      this.setTopRow(this.targetTopRow());
    }
  };

  //541
  Alias.WiSe_drawAllItems = Window_Selectable.prototype.drawAllItems;
  Window_Selectable.prototype.drawAllItems = function () {
    Alias.WiSe_drawAllItems.call(this);
    var topIndex = this.topIndex() + this.maxPageItems();
    for (var i = 0; i < this.maxCols(); i++) {
      var index = topIndex + i;
      if (index < this.maxItems()) {
        this.drawItem(index);
      }
    }
  };

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

  //99
  Alias.WiChLi_contentsHeight = Window_ChoiceList.prototype.contentsHeight;
  Window_ChoiceList.prototype.contentsHeight = function () {
    return Alias.WiChLi_contentsHeight.call(this) + this.itemHeight();
  };

  //
  if (Window_ChoiceList.prototype.hasOwnProperty("processCancel")) {
    Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel;
  }
  Window_ChoiceList.prototype.processCancel = function () {
    SoundManager.cancelOff = $gameMessage.cancelOff;
    if (Alias.WiChLi_processCancel) {
      Alias.WiChLi_processCancel.call(this);
    } else {
      Window_Command.prototype.processCancel.call(this);
    }
    SoundManager.cancelOff = false;
  };

  //-----------------------------------------------------------------------------
  // Window_Status

  Window_Status.prototype.isTouchedInsideFrame = function () {
    return false;
  };

  //-----------------------------------------------------------------------------
  // Window_ShopStatus

  //48
  Alias.WiShSt_changePage = Window_ShopStatus.prototype.changePage;
  Window_ShopStatus.prototype.changePage = function () {
    Alias.WiShSt_changePage.call(this);
    Input.update();
    TouchInput.update();
  };

  //-----------------------------------------------------------------------------
  // Scene_Base

  //96
  Alias.ScBa_start = Scene_Base.prototype.start;
  Scene_Base.prototype.start = function () {
    Alias.ScBa_start.apply(this, arguments);
    if (this._windowLayer) {
      this._windowLayer.children.forEach((window) => {
        if (typeof window.skipSmoothScroll === "function") {
          window.skipSmoothScroll();
        }
      });
    }
  };
})(this);


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

/*:
 * @plugindesc 【ver.1.0】戦闘ログの表示方法や動作を変更し、戦闘の進行を早くしたりします。
 * @author 木星ペンギン
 *
 * @help ▼ 動作詳細
 * --------------------------------
 *  〇 戦闘ログの表示方法を蓄積型にすることで、ログ進行が早くても
 *    文章がすぐに消ることがなくなります。
 *
 *  〇 通常、敵を倒した際の演出が終了するまでキャラクターは動きませんが、
 *    演出の終了を待たずにキャラクターが元の位置に戻ります。
 *
 *  〇 通常、前に行動したキャラクターが元の位置に戻らないと
 *    次のキャラクターは行動しませんが、
 *    前のキャラクターが行動を終了した時点で次のキャラクターが行動します。
 *
 *  〇 アニメーションの終了待ちの時間を短縮します。
 *    短縮する時間はプラグインパラメータ[Animation Short Count]にて変更可能です。
 *
 *  〇 パーティコマンドから戦闘過去ログを確認することができます。
 *
 * ================================================================
 * ▼ プラグインパラメータ 詳細
 * --------------------------------
 *  〇 Fast Forward Enabled? (戦闘ログの高速表示の有効/無効)
 *   「戦闘ログの高速表示」はツクールＭＶのデフォルトの機能です。
 *   決定キー長押しや長押しタッチなどでログ表示が早くなる機能の有無を
 *   変更します。
 *
 * --------------------------------
 *  〇 Log Type (戦闘ログの消去タイプ)
 *   0:まとめて消去
 *    最後のログが表示されてから一定時間がたつと戦闘ログウィンドウが
 *    非表示となります。
 *
 *   1:一行ずつ消去
 *    表示されてから一定時間経過したログから順に消去されます。
 *
 * --------------------------------
 *  〇 Not Display Skils (ログに表示しないスキルIDの配列)
 *   n-m と表記することで、nからmまでの数値を指定できます。
 *   (例 : 1-4,8 => 1,2,3,4,8)
 *
 * --------------------------------
 *  〇 Log Command (戦闘過去ログを表示するコマンド名)
 *   コマンドはパーティコマンドに追加されます。
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param === Base ===
 * @default 【基本的な設定】
 *
 * @param Fast Forward Enabled?
 * @type boolean
 * @desc 戦闘ログの高速表示の有効/無効
 * @default false
 * @parent === Base ===
 *
 * @param Log Type
 * @type number
 * @max 1
 * @desc 戦闘ログの消去タイプ
 * (0:まとめて消去, 1:一行ずつ消去)
 * @default 1
 * @parent === Base ===
 *
 * @param Message Speed
 * @type number
 * @desc 戦闘ログの表示速度
 * @default 8
 * @parent === Base ===
 *
 * @param View Duration
 * @type number
 * @desc 戦闘ログの表示時間
 * (0:常時表示)
 * @default 150
 * @parent === Base ===
 *
 * @param Start Messages On Log?
 * @type boolean
 * @desc 戦闘開始メッセージをログに表示するかどうか
 * @default false
 * @parent === Base ===
 *
 * @param Log Command
 * @desc 戦闘過去ログを表示するコマンド名
 * @default 戦闘ログ
 * @parent === Base ===
 *
 * @param Log Max Size
 * @type number
 * @desc 戦闘ログを保持する数
 * @default 100
 * @parent === Base ===
 *
 * @param Item Name Only?
 * @type boolean
 * @desc アイテム/スキル名のみ表示
 * @default false
 * @parent === Base ===
 *
 * @param Not Display Skils
 * @desc ログに表示しないスキルIDの配列
 * (範囲指定可)
 * @default 1,2
 * @parent === Base ===
 *
 *
 * @param === Window ===
 * @default 【ログウィンドウ】
 *
 * @param Log Window Y
 * @type number
 * @min -1000
 * @desc ログウィンドウのY座標
 * @default 0
 * @parent === Window ===
 *
 * @param Log Window Width
 * @type number
 * @desc ログウィンドウの幅
 * @default 816
 * @parent === Window ===
 *
 * @param Line Height
 * @type number
 * @desc 戦闘ログの一行の高さ
 * @default 30
 * @parent === Window ===
 *
 * @param Font Size
 * @type number
 * @desc 戦闘ログの文字サイズ
 * @default 24
 * @parent === Window ===
 *
 * @param Max Lines
 * @type number
 * @min 1
 * @desc 戦闘ログの最大表示行数
 * @default 6
 * @parent === Window ===
 *
 *
 * @param === Advanced ===
 * @default 【高度な設定】
 *
 * @param Indent Width
 * @type number
 * @desc インデント(字下げ)の幅
 * @default 12
 * @parent === Advanced ===
 *
 * @param Animation Next Delay
 * @type number
 * @desc 複数の対象にアニメーションを表示する際の間隔
 * @default 12
 * @parent === Advanced ===
 *
 * @param Animation Short Count
 * @type number
 * @desc アニメーション待ちを短縮する時間
 * @default 16
 * @parent === Advanced ===
 *
 *
 *
 *
 *
 *
 *
 */

(function () {
  var MPPlugin = {};

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

    function convertParam(name) {
      var param = parameters[name];
      var result = [];
      if (param) {
        var data = param.split(",");
        for (var i = 0; i < data.length; i++) {
          if (/(\d+)\s*-\s*(\d+)/.test(data[i])) {
            for (var n = Number(RegExp.$1); n <= Number(RegExp.$2); n++) {
              result.push(n);
            }
          } else {
            result.push(Number(data[i]));
          }
        }
      }
      return result;
    }

    MPPlugin.FastForwardEnabled = !!eval(parameters["Fast Forward Enabled?"]);
    MPPlugin.LogType = Number(parameters["Log Type"] || 1);
    MPPlugin.MaxLines = Number(parameters["Max Lines"] || 6);
    MPPlugin.MessageSpeed = Number(parameters["Message Speed"] || 8);
    MPPlugin.ViewDuration = Number(parameters["View Duration"] || 150);
    MPPlugin.StartMessagesOnLog = !!eval(parameters["Start Messages On Log?"]);
    MPPlugin.LogCommand = parameters["Log Command"] || "";
    MPPlugin.LogMaxSize = Number(parameters["Log Max Size"] || 100);
    MPPlugin.ItemNameOnly = !!eval(parameters["Item Name Only?"]);
    MPPlugin.NotDisplaySkils = convertParam("Not Display Skils");

    MPPlugin.LogWindowY = Number(parameters["Log Window Y"] || 0);
    MPPlugin.LogWindowWidth = Number(parameters["Log Window Width"] || 816);
    MPPlugin.LineHeight = Number(parameters["Line Height"] || 30);
    MPPlugin.FontSize = Number(parameters["Font Size"] || 24);

    MPPlugin.IndentWidth = Number(parameters["Indent Width"] || 32);
    MPPlugin.AnimationNextDelay = Number(
      parameters["Animation Next Delay"] || 12
    );
    MPPlugin.AnimationShortCount = Number(
      parameters["Animation Short Count"] || 12
    );
  })();

  var Alias = {};

  //-----------------------------------------------------------------------------
  // BattleManager

  //164
  Alias.BaMa_isBusy = BattleManager.isBusy;
  BattleManager.isBusy = function () {
    if (Alias.BaMa_isBusy.apply(this, arguments)) {
      return true;
    }
    if (this.isBattleEnd() && this.waitBattleEnd()) {
      return true;
    }
    return false;
  };

  BattleManager.isBattleEnd = function () {
    return $gameParty.isAllDead() || $gameTroop.isAllDead();
  };

  BattleManager.waitBattleEnd = function () {
    return this._spriteset.isEffecting() || this._spriteset.isAnyoneMoving();
  };

  //229
  Alias.BaMa_displayStartMessages = BattleManager.displayStartMessages;
  BattleManager.displayStartMessages = function () {
    if (!MPPlugin.StartMessagesOnLog)
      Alias.BaMa_displayStartMessages.apply(this, arguments);
  };

  BattleManager.displayStartMessagesOnLog = function () {
    $gameTroop.enemyNames().forEach(function (name) {
      this._logWindow.push("addText", TextManager.emerge.format(name));
    }, this);
    if (this._preemptive) {
      this._logWindow.push("wait");
      this._logWindow.push(
        "addText",
        TextManager.preemptive.format($gameParty.name())
      );
    } else if (this._surprise) {
      this._logWindow.push("wait");
      this._logWindow.push(
        "addText",
        TextManager.surprise.format($gameParty.name())
      );
    }
    this._logWindow.push("clear");
  };

  //480
  Alias.BaMa_checkBattleEnd = BattleManager.checkBattleEnd;
  BattleManager.checkBattleEnd = function () {
    var result = Alias.BaMa_checkBattleEnd.apply(this, arguments);
    if (result) {
      this._logWindow.clear_mppSBL();
      this._logWindow.endSelect();
    }
    return result;
  };

  //-----------------------------------------------------------------------------
  // Window_Base

  //303
  Alias.WiBa_processEscapeCharacter =
    Window_Base.prototype.processEscapeCharacter;
  Window_Base.prototype.processEscapeCharacter = function (code, textState) {
    if (code === "PX") {
      textState.x += this.obtainEscapeParam(textState);
    } else {
      Alias.WiBa_processEscapeCharacter.apply(this, arguments);
    }
  };

  //-----------------------------------------------------------------------------
  // Window_BattleLog

  //14
  Alias.WiBaLo_initialize = Window_BattleLog.prototype.initialize;
  Window_BattleLog.prototype.initialize = function () {
    this._clearDuration = 0;
    this._logScrollYDuration = 0;
    this._logScrollY = this.lineHeight();
    this._logs = [];
    Alias.WiBaLo_initialize.apply(this, arguments);
    this.createLogSprites();
  };

  //34
  Window_BattleLog.prototype.windowWidth = function () {
    return MPPlugin.LogWindowWidth;
  };

  //
  Window_BattleLog.prototype.lineHeight = function () {
    return MPPlugin.LineHeight;
  };

  //
  Window_BattleLog.prototype.standardFontSize = function () {
    return MPPlugin.FontSize;
  };

  //
  Window_BattleLog.prototype.maxItems = function () {
    return this._logs.length;
  };

  //42
  Window_BattleLog.prototype.maxLines = function () {
    return MPPlugin.MaxLines;
  };

  //46
  Window_BattleLog.prototype.createBackBitmap = function () {
    this._backBitmap = new Bitmap(this.width, this.contentsHeight());
  };

  Window_BattleLog.prototype.createLogSprites = function () {
    this._logMainSprite = new Sprite();
    this.addChild(this._logMainSprite);
    this._logSprites = [];
    var max = this.maxLines() + 1;
    for (var i = 0; i < max; i++) {
      var sprite = new Sprite();
      sprite.bitmap = new Bitmap(this.contentsWidth(), this.lineHeight());
      this._logSprites[i] = sprite;
      this._logMainSprite.addChild(sprite);
    }
  };

  //61
  Window_BattleLog.prototype.messageSpeed = function () {
    return MPPlugin.MessageSpeed;
  };

  //
  if (Window_Message.prototype.hasOwnProperty("itemRectForText")) {
    Alias.WiBaLo_itemRectForText = Window_BattleLog.prototype.itemRectForText;
  }
  Window_BattleLog.prototype.itemRectForText = function (index) {
    var _super =
      Alias.WiBaLo_itemRectForText ||
      Window_Selectable.prototype.itemRectForText;
    var rect = _super.apply(this, arguments);
    if (!this.active) rect.y = 0;
    return rect;
  };

  //69
  Alias.WiBaLo_update = Window_BattleLog.prototype.update;
  Window_BattleLog.prototype.update = function () {
    Window_Selectable.prototype.update.call(this);
    Alias.WiBaLo_update.apply(this, arguments);
    this.updateLogSprites();
  };

  //
  if (Window_Selectable.prototype.hasOwnProperty("updateArrows")) {
    Alias.WiSe_updateArrows = Window_Selectable.prototype.updateArrows;
  }
  Window_BattleLog.prototype.updateArrows = function () {
    if (Alias.WiSe_updateArrows) {
      Alias.WiSe_updateArrows.apply(this, arguments);
    } else {
      Window_Selectable.prototype.updateArrows.apply(this, arguments);
    }
    if (!this.active) {
      this.downArrowVisible = false;
      this.upArrowVisible = false;
    }
  };

  Window_BattleLog.prototype.updateLogSprites = function () {
    var lineHeight = this.lineHeight();
    if (this._logScrollYDuration > 0) {
      this._logScrollYDuration--;
      this._logScrollY = this.step(
        this._logScrollYDuration,
        lineHeight,
        this._logScrollY
      );
    }
    for (var i = 0; i < this._logSprites.length; i++) {
      var sprite = this._logSprites[i];
      var rect = this.itemRect(i);
      rect.y = i * lineHeight - this._logScrollY;
      if (sprite.logScrollXDuration > 0) sprite.logScrollXDuration--;
      sprite.x = Math.round(Math.pow(sprite.logScrollXDuration, 2) / 2);
      sprite.y = rect.y.clamp(0, (this.maxLines() - 1) * lineHeight);
      var y = Math.max(-rect.y, 0);
      sprite.setFrame(0, y, rect.width, rect.height - y);
      sprite.opacity = 255 - sprite.logScrollXDuration * 20;
      if (sprite.viewDuration > 0) sprite.viewDuration--;
    }
    if (this._clearDuration > 0) {
      this._clearDuration--;
      var max = Math.min(16, MPPlugin.ViewDuration);
      if (this._clearDuration < max) {
        this._logMainSprite.opacity = (255 * this._clearDuration) / max;
        this._backSprite.opacity = (255 * this._clearDuration) / max;
      }
      if (this._clearDuration === 0) this.clear_mppSBL();
    } else if (this.numLines() > 0) {
      if (this._logSprites[1].viewDuration === 0) this.shiftLine();
    }
    this._logMainSprite.x = this.padding;
    this._logMainSprite.y = this.padding;
    this._backSprite.y = this.padding;
    var height = (this.numLines() + 1) * lineHeight - this._logScrollY;
    height = Math.min(height, this.maxLines() * lineHeight);
    var y = this.maxLines() * lineHeight - height;
    this._backSprite.setFrame(0, y, this.width, height);
  };

  Window_BattleLog.prototype.step = function (d, t, n) {
    return Math.round(t + ((n - t) * Math.pow(d, 2)) / Math.pow(d + 1, 2));
  };

  Window_BattleLog.prototype.shiftLine = function () {
    this._lines.shift();
    var sprite = this._logSprites.shift();
    sprite.bitmap.clear();
    this._logSprites.push(sprite);
    this._logScrollY -= this.lineHeight();
    this._logScrollYDuration = 16;
  };

  //121
  Alias.WiBaLo_isFastForward = Window_BattleLog.prototype.isFastForward;
  Window_BattleLog.prototype.isFastForward = function () {
    return (
      MPPlugin.FastForwardEnabled &&
      Alias.WiBaLo_isFastForward.apply(this, arguments)
    );
  };

  //131
  Alias.WiBaLo_clear = Window_BattleLog.prototype.clear;
  Window_BattleLog.prototype.clear = function () {
    if (MPPlugin.ItemNameOnly) {
      this.clear_mppSBL();
      return;
    }
    this._baseLineStack = [];
    if (MPPlugin.LogType === 0) this._clearDuration = MPPlugin.ViewDuration;
  };
  Window_BattleLog.prototype.clear_mppSBL = function () {
    Alias.WiBaLo_clear.call(this);
    for (var i = 0; i < this._logSprites.length; i++) {
      this._logSprites[i].bitmap.clear();
    }
    this._logScrollYDuration = 0;
    this._logScrollY = this.lineHeight();
  };

  //141
  Window_BattleLog.prototype.waitForEffect = function () {
    //this.setWaitMode('effect');
  };

  //149
  Window_BattleLog.prototype.addText = function (text) {
    var indent = this._baseLineStack.length;
    if (indent > 0) {
      text = "\\px[%1]".format(indent * MPPlugin.IndentWidth) + text;
    }
    if (!MPPlugin.ItemNameOnly) {
      this._lines.push(text);
      if (this.numLines() > this.maxLines()) this.shiftLine();
    }
    this._logs.push(text);
    if (this.maxItems() > MPPlugin.LogMaxSize) this._logs.shift();

    if (this.active) {
      this.refresh();
    } else if (!MPPlugin.ItemNameOnly) {
      var index = this.numLines() - 1;
      var sprite = this._logSprites[index + 1];
      sprite.logScrollXDuration = 12;
      if (MPPlugin.LogType === 1)
        sprite.viewDuration = MPPlugin.ViewDuration || -1;

      this.drawLineText(index);
    }
    this.wait();
    this._clearDuration = 0;
    this._logMainSprite.opacity = 255;
    this._backSprite.opacity = 255;
  };

  Window_BattleLog.prototype.addItemName = function (name) {
    this._lines.push(name);
    var index = this.numLines() - 1;
    var sprite = this._logSprites[index + 1];
    sprite.logScrollXDuration = 0;
    sprite.viewDuration = -1;

    this.drawLineText(index);
  };

  //159
  Window_BattleLog.prototype.popBaseLine = function () {
    var baseLine = this._baseLineStack.pop();
    //    while (this._lines.length > baseLine) {
    //        this._lines.pop();
    //    }
  };

  //269
  Window_BattleLog.prototype.animationNextDelay = function () {
    return MPPlugin.AnimationNextDelay;
  };

  //273
  Alias.WiBaLo_refresh = Window_BattleLog.prototype.refresh;
  Window_BattleLog.prototype.refresh = function () {
    if (this.active) {
      Window_Selectable.prototype.refresh.apply(this, arguments);
    } else {
      Alias.WiBaLo_refresh.apply(this, arguments);
    }
  };

  //290
  Window_BattleLog.prototype.backRect = function () {
    return {
      x: 0,
      y: 0,
      width: this.width,
      height: this.contentsHeight(),
    };
  };

  //307
  Alias.WiBaLo_drawLineText = Window_BattleLog.prototype.drawLineText;
  Window_BattleLog.prototype.drawLineText = function (index) {
    var sprite = this._logSprites[index + 1];
    var baseContents = this.contents;
    this.contents = sprite.bitmap;

    if (MPPlugin.ItemNameOnly) {
      var rect = this.itemRectForText(index);
      this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
      this.drawText(this._lines[index], rect.x, rect.y, rect.width, "center");
    } else {
      Alias.WiBaLo_drawLineText.apply(this, arguments);
    }

    this.contents = baseContents;
  };

  //326
  Window_BattleLog.prototype.endAction = function (subject) {
    //this.push('waitForNewLine');
    this.push("clear");
    this.push("performActionEnd", subject);
  };

  //345
  Alias.WiBaLo_displayAction = Window_BattleLog.prototype.displayAction;
  Window_BattleLog.prototype.displayAction = function (subject, item) {
    if (MPPlugin.ItemNameOnly) {
      if (
        !DataManager.isSkill(item) ||
        !MPPlugin.NotDisplaySkils.contains(item.id)
      ) {
        this.push("addItemName", item.name);
      }
    }
    Alias.WiBaLo_displayAction.apply(this, arguments);
  };

  Window_BattleLog.prototype.drawItem = function (index) {
    var rect = this.itemRectForText(index);
    this.drawTextEx(this._logs[index], rect.x, rect.y, rect.width);
  };

  Window_BattleLog.prototype.startSelect = function (height) {
    this.activate();
    this.opacity = 255;
    this.height = height;
    this.createContents();
    this.openness = 0;
    this.open();
    this._logMainSprite.visible = false;
    this._backSprite.visible = false;
    this.select(Math.max(this.maxItems() - 1, 0));
    this.refresh();
  };

  //
  Window_BattleLog.prototype.endSelect = function () {
    this.deactivate();
    this.opacity = 0;
    this.height = this.windowHeight();
    this._logMainSprite.visible = true;
    this._backSprite.visible = true;
    this.downArrowVisible = false;
    this.upArrowVisible = false;
    this.deselect();
    this.refresh();
  };

  //-----------------------------------------------------------------------------
  // Window_PartyCommand

  //28
  Alias.WiPaCo_makeCommandList = Window_PartyCommand.prototype.makeCommandList;
  Window_PartyCommand.prototype.makeCommandList = function () {
    Alias.WiPaCo_makeCommandList.apply(this, arguments);
    if (MPPlugin.LogCommand) this.addCommand(MPPlugin.LogCommand, "battleLog");
  };

  //-----------------------------------------------------------------------------
  // Sprite_Battler

  //
  Sprite_Battler.prototype.isAnimationPlaying = function () {
    return this._animationSprites.some(function (animation) {
      return animation._duration > MPPlugin.AnimationShortCount;
    });
  };

  //-----------------------------------------------------------------------------
  // Spriteset_Battle

  //271
  Spriteset_Battle.prototype.isBusy = function () {
    return this.isAnimationPlaying(); // || this.isAnyoneMoving();
  };

  //-----------------------------------------------------------------------------
  // Scene_Battle

  //46
  Alias.ScBat_isAnyInputWindowActive =
    Scene_Battle.prototype.isAnyInputWindowActive;
  Scene_Battle.prototype.isAnyInputWindowActive = function () {
    return (
      Alias.ScBat_isAnyInputWindowActive.apply(this, arguments) ||
      this._logWindow.active
    );
  };

  //127
  Alias.ScBat_createDisplayObjects =
    Scene_Battle.prototype.createDisplayObjects;
  Scene_Battle.prototype.createDisplayObjects = function () {
    Alias.ScBat_createDisplayObjects.apply(this, arguments);
    if (MPPlugin.StartMessagesOnLog) BattleManager.displayStartMessagesOnLog();
  };

  //156
  Alias.ScBat_createLogWindow = Scene_Battle.prototype.createLogWindow;
  Scene_Battle.prototype.createLogWindow = function () {
    Alias.ScBat_createLogWindow.apply(this, arguments);
    this._logWindow.y = MPPlugin.LogWindowY;
    this._logWindow.setHandler("cancel", this.onLogCancel.bind(this));
  };

  //166
  Alias.ScBat_createPartyCommandWindow =
    Scene_Battle.prototype.createPartyCommandWindow;
  Scene_Battle.prototype.createPartyCommandWindow = function () {
    Alias.ScBat_createPartyCommandWindow.apply(this, arguments);
    this._partyCommandWindow.setHandler(
      "battleLog",
      this.commandLog.bind(this)
    );
  };

  Scene_Battle.prototype.commandLog = function () {
    this._logWindow.startSelect(this._statusWindow.y);
  };

  Scene_Battle.prototype.onLogCancel = function () {
    this._logWindow.endSelect();
    this._partyCommandWindow.activate();
  };

  //400
  Alias.ScBat_endCommandSelection = Scene_Battle.prototype.endCommandSelection;
  Scene_Battle.prototype.endCommandSelection = function () {
    Alias.ScBat_endCommandSelection.call(this);
    this._logWindow.endSelect();
  };
})();

repo_name: dazed/translations

license: unknown


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

/*:
 * @target MV MZ
 * @plugindesc Displays the removed or added state above the character's head during battle.
 * @author Mokusei Penguin
 * @url
 *
 * @help [version 2.0.0]
 * This plugin is for RPG Maker MV and MZ.
 *
 * ================================
 * Mail : wood_penguin＠yahoo.co.jp (＠ is half-width)
 * Blog : http://woodpenguin.blog.fc2.com/
 * License : MIT license
 *
 *  @param Added Time
 *      @desc
 *      @type number
 *          @min 0
 *          @max 999
 *      @default 45
 *
 *  @param Removed Time
 *      @desc
 *      @type number
 *          @min 0
 *          @max 999
 *      @default 35
 *
 *  @param Interval Time
 *      @desc
 *      @type number
 *          @min 1
 *          @max 999
 *      @default 30
 *
 *  @param Popup To Actor?
 *      @desc
 *      @type boolean
 *      @default true
 *
 *  @param Popup To Enemy?
 *      @desc
 *      @type boolean
 *      @default false
 *
 */

/*:ja
 * @target MV MZ
 * @plugindesc 戦闘中、解除または付加されたステートをキャラクターの頭上に表示します。
 * @author 木星ペンギン
 * @url
 *
 * @help [version 2.0.0]
 * このプラグインはRPGツクールMVおよびMZ用です。
 *
 * ================================
 * Mail : wood_penguin＠yahoo.co.jp (＠は半角)
 * Blog : http://woodpenguin.blog.fc2.com/
 * License : MIT license
 *
 *  @param Added Time
 *      @text 付加時の表示時間
 *      @desc
 *      @type number
 *          @min 0
 *          @max 999
 *      @default 45
 *
 *  @param Removed Time
 *      @text 解除時の表示時間
 *      @desc
 *      @type number
 *          @min 0
 *          @max 999
 *      @default 35
 *
 *  @param Interval Time
 *      @text 表示間隔
 *      @desc
 *      @type number
 *          @min 1
 *          @max 999
 *      @default 30
 *
 *  @param Popup To Actor?
 *      @text アクターにポップアップさせるかどうか？
 *      @desc
 *      @type boolean
 *      @default true
 *
 *  @param Popup To Enemy?
 *      @text 敵キャラにポップアップさせるかどうか？
 *      @desc
 *      @type boolean
 *      @default false
 *
 */

(() => {
  "use strict";

  const pluginName = "MPP_StatePopup";

  // Plugin Parameters
  const parameters = PluginManager.parameters(pluginName);
  const param_AddedTime = Number(parameters["Added Time"] || 45);
  const param_RemovedTime = Number(parameters["Removed Time"] || 35);
  const param_IntervalTime = Number(parameters["Interval Time"] || 30);
  const param_PopupToActor = parameters["Popup To Actor?"] === "true";
  const param_PopupToEnemy = parameters["Popup To Enemy?"] === "true";

  //-------------------------------------------------------------------------
  // Game_ActionResult

  const _Game_ActionResult_clear = Game_ActionResult.prototype.clear;
  Game_ActionResult.prototype.clear = function () {
    _Game_ActionResult_clear.apply(this, arguments);
    this.removedDebuffs = [];
    this._affectedBuffLevels = {};
  };

  const _Game_ActionResult_isStatusAffected =
    Game_ActionResult.prototype.isStatusAffected;
  Game_ActionResult.prototype.isStatusAffected = function () {
    return (
      _Game_ActionResult_isStatusAffected.apply(this, arguments) ||
      this.removedDebuffs.length > 0
    );
  };

  Game_ActionResult.prototype.setAffectedBuffLevel = function (paramId, level) {
    this._affectedBuffLevels[paramId] = level;
  };

  Game_ActionResult.prototype.getAffectedBuffLevel = function (paramId) {
    return this._affectedBuffLevels[paramId] || 0;
  };

  Game_ActionResult.prototype.isDebuffRemoved = function (paramId) {
    return this.removedDebuffs.includes(paramId);
  };

  Game_ActionResult.prototype.pushRemovedDebuff = function (paramId) {
    if (!this.isDebuffRemoved(paramId)) {
      this.removedDebuffs.push(paramId);
    }
  };

  //-------------------------------------------------------------------------
  // Game_Battler

  const _Game_Battler_initMembers = Game_Battler.prototype.initMembers;
  Game_Battler.prototype.initMembers = function () {
    _Game_Battler_initMembers.apply(this, arguments);
    this._statePopup = false;
  };

  const _Game_Battler_addBuff = Game_Battler.prototype.addBuff;
  Game_Battler.prototype.addBuff = function (paramId, turns) {
    _Game_Battler_addBuff.apply(this, arguments);
    if (this._result.isBuffAdded(paramId)) {
      this._result.setAffectedBuffLevel(paramId, this.buff(paramId));
    }
  };

  const _Game_Battler_addDebuff = Game_Battler.prototype.addDebuff;
  Game_Battler.prototype.addDebuff = function (paramId, turns) {
    _Game_Battler_addDebuff.apply(this, arguments);
    if (this._result.isDebuffAdded(paramId)) {
      this._result.setAffectedBuffLevel(paramId, this.buff(paramId));
    }
  };

  const _Game_Battler_removeBuff = Game_Battler.prototype.removeBuff;
  Game_Battler.prototype.removeBuff = function (paramId) {
    if (this.isAlive() && this.isBuffOrDebuffAffected(paramId)) {
      this._result.setAffectedBuffLevel(paramId, this.buff(paramId));
      if (this.isDebuffAffected(paramId)) {
        this.eraseBuff(paramId);
        this._result.pushRemovedDebuff(paramId);
        this.refresh();
      }
    }
    _Game_Battler_removeBuff.apply(this, arguments);
  };

  Game_Battler.prototype.clearStatePopup = function () {
    this._statePopup = false;
  };

  Game_Battler.prototype.isStatePopupRequested = function () {
    return this._statePopup;
  };

  Game_Battler.prototype.startStatePopup = function () {
    this._statePopup = true;
  };

  Game_Battler.prototype.shouldPopupState = function () {
    return this._result.isStatusAffected();
  };

  //-------------------------------------------------------------------------
  // Window_BattleLog

  const _Window_BattleLog_popupDamage = Window_BattleLog.prototype.popupDamage;
  Window_BattleLog.prototype.popupDamage = function (target) {
    _Window_BattleLog_popupDamage.apply(this, arguments);
    if (target.shouldPopupState()) {
      target.startStatePopup();
    }
  };

  const _Window_BattleLog_displayChangedBuffs =
    Window_BattleLog.prototype.displayChangedBuffs;
  Window_BattleLog.prototype.displayChangedBuffs = function (target) {
    _Window_BattleLog_displayChangedBuffs.apply(this, arguments);
    const result = target.result();
    this.displayBuffs(target, result.removedDebuffs, TextManager.buffRemove);
  };

  //-------------------------------------------------------------------------
  // Sprite_Battler

  const _Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers;
  Sprite_Battler.prototype.initMembers = function () {
    _Sprite_Battler_initMembers.apply(this, arguments);
    this._popupStates = [];
  };

  const _Sprite_Battler_updateDamagePopup =
    Sprite_Battler.prototype.updateDamagePopup;
  Sprite_Battler.prototype.updateDamagePopup = function () {
    this.updateStatePopup();
    _Sprite_Battler_updateDamagePopup.apply(this, arguments);
  };

  Sprite_Battler.prototype.updateStatePopup = function () {
    this.setupStatePopup();
    if (this._popupStates.length > 0) {
      if (!this._popupStates[0].isPlaying()) {
        this.destroyTopPopupStateSprite();
      }
    }
  };

  Sprite_Battler.prototype.setupStatePopup = function () {
    if (this._battler.isStatePopupRequested()) {
      if (this.isPopupState()) {
        this.processPopupStateRequests();
      }
      this._battler.clearStatePopup();
      if (!this._battler.isDamagePopupRequested()) {
        this._battler.clearResult();
      }
    }
    if (this._battler._atbDamagePopup && this.isPopupState()) {
      this.setupStatePopup(this._battler._atbResult);
    }
  };

  Sprite_Battler.prototype.isPopupState = function () {
    return this._battler.isSpriteVisible();
  };

  Sprite_Battler.prototype.processPopupStateRequests = function () {
    const result = this._battler.result();
    for (const iconIndex of this.addedPopupStateIcons(result)) {
      this.createPopupStateSprite(iconIndex, "added");
    }
    for (const iconIndex of this.removedPopupStateIcons(result)) {
      this.createPopupStateSprite(iconIndex, "removed");
    }
  };

  Sprite_Battler.prototype.addedPopupStateIcons = function (result) {
    return [
      ...this.addedStateIcons(result),
      ...this.generatorAddedBuffIcons(result),
      ...this.generatorAddedDebuffIcons(result),
    ].filter((iconIndex) => iconIndex > 1);
  };

  Sprite_Battler.prototype.addedStateIcons = function (result) {
    return result.addedStateObjects().map((state) => state.iconIndex);
  };

  Sprite_Battler.prototype.generatorAddedBuffIcons = function* (result) {
    for (const paramId of result.addedBuffs) {
      const level = result.getAffectedBuffLevel(paramId);
      yield this._battler.buffIconIndex(level, paramId);
    }
  };

  Sprite_Battler.prototype.generatorAddedDebuffIcons = function* (result) {
    for (const paramId of result.addedDebuffs) {
      const level = result.getAffectedBuffLevel(paramId);
      yield this._battler.buffIconIndex(level, paramId);
    }
  };

  Sprite_Battler.prototype.removedPopupStateIcons = function (result) {
    return [
      ...this.removedStateIcons(result),
      ...this.generatorRemovedBuffIcons(result),
      ...this.generatorRemovedDebuffIcons(result),
    ].filter((iconIndex) => iconIndex > 1);
  };

  Sprite_Battler.prototype.removedStateIcons = function (result) {
    return result.removedStateObjects().map((state) => state.iconIndex);
  };

  Sprite_Battler.prototype.generatorRemovedBuffIcons = function* (result) {
    for (const paramId of result.removedBuffs) {
      const level = result.getAffectedBuffLevel(paramId);
      yield this._battler.buffIconIndex(level, paramId);
    }
  };

  Sprite_Battler.prototype.generatorRemovedDebuffIcons = function* (result) {
    for (const paramId of result.removedDebuffs) {
      const level = result.getAffectedBuffLevel(paramId);
      yield this._battler.buffIconIndex(level, paramId);
    }
  };

  Sprite_Battler.prototype.createPopupStateSprite = function (iconIndex, type) {
    const last = this._popupStates[this._popupStates.length - 1];
    const sprite = new Sprite_PopupState();
    const offsetY = Math.min(this.stateOffsetY(), this.y - 20);
    const delay = last ? last.delay + param_IntervalTime : 0;
    sprite.move(this.x, this.y - offsetY);
    sprite.setup(iconIndex, type, delay);
    sprite.pseudo3dAltitude = () => offsetY;
    this._popupStates.push(sprite);
    this.parent.addChild(sprite);
  };

  Sprite_Battler.prototype.destroyTopPopupStateSprite = function () {
    const sprite = this._popupStates.shift();
    if (sprite) {
      this.parent.removeChild(sprite);
      sprite.destroy();
    }
  };

  Sprite_Battler.prototype.stateOffsetY = function () {
    if (this.mainSprite) {
      return this.mainSprite().height;
    } else {
      return this._effectTarget.height;
    }
  };

  //-------------------------------------------------------------------------
  // Sprite_Actor

  Sprite_Actor.prototype.isPopupState = function () {
    return (
      Sprite_Battler.prototype.isPopupState.call(this) && param_PopupToActor
    );
  };

  //-------------------------------------------------------------------------
  // Sprite_Enemy

  Sprite_Enemy.prototype.isPopupState = function () {
    return (
      Sprite_Battler.prototype.isPopupState.call(this) && param_PopupToEnemy
    );
  };

  Sprite_Enemy.prototype.stateOffsetY = function () {
    return Math.round((this.bitmap.height + 40) * 0.9);
  };

  //-------------------------------------------------------------------------
  // Sprite_PopupState

  class Sprite_PopupState extends Sprite {
    constructor() {
      super();
      this.bitmap = ImageManager.loadSystem("IconSet");
      this.setFrame(0, 0, 0, 0);
      this.anchor.x = 0.5;
      this.anchor.y = 0.5;
      this.visible = false;
      this._iconIndex = 0;
      this._duration = 0;
      this._popupType = null;
      this._delay = 0;
      this._flashColor = [0, 0, 0, 0];
    }

    get delay() {
      return this._delay;
    }

    setup(iconIndex, type, delay) {
      this._iconIndex = iconIndex;
      this._popupType = type;
      this._delay = delay;
      if (type === "added") {
        this._duration = param_AddedTime + 15;
        this._flashColor = [255, 255, 255, 255];
      } else {
        this._duration = param_RemovedTime + 40;
        this._flashColor = [0, 0, 0, 0];
      }
    }

    update() {
      super.update();
      if (!this.updateDelay()) {
        this.updateMove();
        this.updateFlash();
        this.updateFrame();
        this.visible = true;
      }
    }

    updateDelay() {
      if (this._delay > 0) {
        this._delay--;
        return true;
      }
      return false;
    }

    updateMove() {
      if (this._duration > 0) {
        if (this._popupType === "added") {
          this.updateAddedMove();
        } else {
          this.updateRemovedMove();
        }
        this._duration--;
      }
    }

    updateAddedMove() {
      const d = this._duration;
      const base = param_AddedTime;
      if (d > base) {
        const radian = ((d - base) * Math.PI) / 30;
        this.scale.x = Math.cos(radian);
        this.anchor.y = 0.5 - (d - base) / base;
      } else {
        this.scale.x = 1;
        this.anchor.y = 0.5;
      }
    }

    updateRemovedMove() {
      const d = this._duration;
      const base = param_RemovedTime;
      if (d < 40) {
        this.anchor.y = d / 40 - 0.5;
        this.blendMode = 1;
        this.opacity = (255 * d) / 40;
      }
    }

    updateFlash() {
      if (this._flashColor[3] > 0) {
        this._flashColor[3] = Math.max(this._flashColor[3] - 10, 0);
        this.setBlendColor(this._flashColor);
      }
    }

    updateFrame() {
      const pw = ImageManager.iconWidth || Window_Base._iconWidth;
      const ph = ImageManager.iconHeight || Window_Base._iconHeight;
      const sx = (this._iconIndex % 16) * pw;
      const sy = Math.floor(this._iconIndex / 16) * ph;
      this.setFrame(sx, sy, pw, ph);
    }

    isPlaying() {
      return this._duration > 0;
    }
  }
})();


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

/*:
 * @plugindesc 【ver.1.9】戦闘時のターゲット選択で、キャラクターをタッチして選択できるようにします。
 * @author 木星ペンギン
 *
 * @help ●タッチ操作によるキャラクター選択
 *  デフォルトと同じです。
 *  マウス/タッチ操作改善プラグイン(MPP_SimpleTouch3.js)導入時のみ、
 *  そちらの操作に準じます。
 *
 * ●カーソル表示
 *  ▽画像ファイルは system フォルダから読み込まれます。
 *    未設定の場合は自動生成されます。
 *
 *  ▽カーソルの位置について
 *   0:画面左側にいる場合は右、画面右側にいる場合は左、
 *     左に表示される場合は左右反転されます。
 *   1～9:それぞれテンキーの位置
 *
 *  ▽幅とレートについて
 *   画像を幅で分割し、レートの速度で左から順に表示します。
 *   幅を 0 にした場合はアニメーションを行いません。
 *
 *  ▽画像の回転について
 *   0:回転なし, 1:通常の回転, 2:横回転, 3:縦回転
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param === Actor ===
 *
 * @param Actor Window View?
 * @type boolean
 * @desc アクターの選択ウィンドウを表示するかどうか
 * @default true
 * @parent === Actor ===
 *
 * @param Actor Arrow View?
 * @type boolean
 * @desc アクター選択カーソルを表示するかどうか
 * @default true
 * @parent === Actor ===
 *
 * @param Actor Arrow Name
 * @desc アクター選択カーソルの画像ファイル名
 * @default
 * @require 1
 * @dir img/system/
 * @type file
 * @parent === Actor ===
 *
 * @param Actor Arrow Pos
 * @type number
 * @max 9
 * @desc アクター選択カーソルの表示位置
 * @default 5
 * @parent === Actor ===
 *
 * @param Actor Arrow Width
 * @type number
 * @desc アクター選択カーソルの幅
 * @default 0
 * @parent === Actor ===
 *
 * @param Actor Arrow Rate
 * @type number
 * @desc アクター選択カーソルのアニメーションのレート
 * @default 4
 * @parent === Actor ===
 *
 * @param Actor Arrow Rotation
 * @type number
 * @max 3
 * @desc アクター選択カーソルの回転方向
 * (0:回転なし, 1:通常の回転, 2:横回転, 3:縦回転)
 * @default 1
 * @parent === Actor ===
 *
 * @param Actor Arrow Speed
 * @type number
 * @min -180
 * @max 180
 * @desc アクター選択カーソルの回転速度
 * @default 2
 * @parent === Actor ===
 *
 * @param Actor Arrow Opacity
 * @type number
 * @max 255
 * @desc アクター選択カーソルの不透明度
 * @default 255
 * @parent === Actor ===
 *
 * @param === Enemy ===
 *
 * @param Enemy Window View?
 * @type boolean
 * @desc エネミーの選択ウィンドウを表示するかどうか
 * @default true
 * @parent === Enemy ===
 *
 * @param Enemy Arrow View?
 * @type boolean
 * @desc エネミー選択カーソルを表示するかどうか
 * @default true
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Name
 * @desc エネミー選択カーソルの画像ファイル名
 * @default
 * @require 1
 * @dir img/system/
 * @type file
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Pos
 * @type number
 * @max 9
 * @desc エネミー選択カーソルの表示位置
 * @default 5
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Width
 * @type number
 * @desc エネミー選択カーソルの幅
 * @default 0
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Rate
 * @type number
 * @desc エネミー選択カーソルのアニメーションのレート
 * @default 4
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Rotation
 * @type number
 * @max 3
 * @desc エネミー選択カーソルの回転方向
 * (0:回転なし, 1:通常の回転, 2:横回転, 3:縦回転)
 * @default 1
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Speed
 * @type number
 * @min -180
 * @max 180
 * @desc エネミー選択カーソルの回転速度
 * @default 2
 * @parent === Enemy ===
 *
 * @param Enemy Arrow Opacity
 * @type number
 * @max 255
 * @desc エネミー選択カーソルの不透明度
 * @default 255
 * @parent === Enemy ===
 *
 */
var MPP = MPP || {};

(function (exports) {
  "use strict";

  const Params = {};

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

    // === Actor ===
    Params.actorWindowView = !!eval(parameters["Actor Window View?"]);
    Params.actorArrowView = !!eval(parameters["Actor Arrow View?"]);
    Params.actorArrow = {};
    Params.actorArrow.Name = parameters["Actor Arrow Name"];
    Params.actorArrow.Pos = Number(parameters["Actor Arrow Pos"] || 0);
    Params.actorArrow.Width = Number(parameters["Actor Arrow Width"] || 0);
    Params.actorArrow.Rate = Number(parameters["Actor Arrow Rate"] || 4);
    Params.actorArrow.Rotation = Number(
      parameters["Actor Arrow Rotation"] || 0
    );
    Params.actorArrow.Speed = Number(parameters["Actor Arrow Speed"] || 0);
    Params.actorArrow.Opacity = Number(
      parameters["Actor Arrow Opacity"] || 255
    );

    // === Enemy Arrow ===
    Params.enemyWindowView = !!eval(parameters["Enemy Window View?"]);
    Params.enemyArrowView = !!eval(parameters["Enemy Arrow View?"]);
    Params.enemyArrow = {};
    Params.enemyArrow.Name = parameters["Enemy Arrow Name"];
    Params.enemyArrow.Pos = Number(parameters["Enemy Arrow Pos"] || 0);
    Params.enemyArrow.Width = Number(parameters["Enemy Arrow Width"] || 0);
    Params.enemyArrow.Rate = Number(parameters["Enemy Arrow Rate"] || 4);
    Params.enemyArrow.Rotation = Number(
      parameters["Enemy Arrow Rotation"] || 0
    );
    Params.enemyArrow.Speed = Number(parameters["Enemy Arrow Speed"] || 0);
    Params.enemyArrow.Opacity = Number(
      parameters["Enemy Arrow Opacity"] || 255
    );
  }

  const Alias = {};

  //-----------------------------------------------------------------------------
  // Window_BattleActor

  //
  if (Window_BattleActor.prototype.hasOwnProperty("cursorDown")) {
    Alias.WiBaAc_cursorDown = Window_BattleActor.prototype.cursorDown;
  }
  Window_BattleActor.prototype.cursorDown = function (wrap) {
    if (Params.actorWindowView) {
      var _super =
        Alias.WiBaAc_cursorDown || Window_BattleStatus.prototype.cursorDown;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() + 1) % this.maxItems());
    }
  };

  //
  if (Window_BattleActor.prototype.hasOwnProperty("cursorUp")) {
    Alias.WiBaAc_cursorUp = Window_BattleActor.prototype.cursorUp;
  }
  Window_BattleActor.prototype.cursorUp = function (wrap) {
    if (Params.actorWindowView) {
      var _super =
        Alias.WiBaAc_cursorUp || Window_BattleStatus.prototype.cursorUp;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() - 1).mod(this.maxItems()));
    }
  };

  //
  if (Window_BattleActor.prototype.hasOwnProperty("cursorRight")) {
    Alias.WiBaAc_cursorRight = Window_BattleActor.prototype.cursorRight;
  }
  Window_BattleActor.prototype.cursorRight = function (wrap) {
    if (Params.actorWindowView) {
      var _super =
        Alias.WiBaAc_cursorRight || Window_BattleStatus.prototype.cursorRight;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() + 1) % this.maxItems());
    }
  };

  //
  if (Window_BattleActor.prototype.hasOwnProperty("cursorLeft")) {
    Alias.WiBaAc_cursorLeft = Window_BattleActor.prototype.cursorLeft;
  }
  Window_BattleActor.prototype.cursorLeft = function (wrap) {
    if (Params.actorWindowView) {
      var _super =
        Alias.WiBaAc_cursorLeft || Window_BattleStatus.prototype.cursorLeft;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() - 1).mod(this.maxItems()));
    }
  };

  //21
  Alias.WiBaAc_show = Window_BattleActor.prototype.show;
  Window_BattleActor.prototype.show = function () {
    if (Params.actorWindowView) {
      Alias.WiBaAc_show.apply(this, arguments);
    } else {
      this.select(0);
    }
  };

  //
  if (Window_BattleActor.prototype.hasOwnProperty("isTouchedInsideFrame")) {
    Alias.WiBaAc_isTouchedInsideFrame =
      Window_BattleActor.prototype.isTouchedInsideFrame;
  }
  Window_BattleActor.prototype.isTouchedInsideFrame = function () {
    if (this._hitActorHandler && this._hitActorHandler()) return true;
    if (this.visible) {
      var _super =
        Alias.WiBaAc_isTouchedInsideFrame ||
        Window_BattleStatus.prototype.isTouchedInsideFrame;
      return _super.apply(this, arguments);
    }
    return false;
  };

  //
  if (Window_BattleActor.prototype.hasOwnProperty("hitTest")) {
    Alias.WiBaAc_hitTest = Window_BattleActor.prototype.hitTest;
  }
  Window_BattleActor.prototype.hitTest = function (x, y) {
    if (this._hitActorHandler) {
      var actor = this._hitActorHandler();
      if (actor) return this._cursorAll ? 0 : actor.index();
    }
    if (this.visible) {
      var _super =
        Alias.WiBaAc_hitTest || Window_BattleStatus.prototype.hitTest;
      return _super.apply(this, arguments);
    }
    return -1;
  };

  //-----------------------------------------------------------------------------
  // Window_BattleEnemy

  //
  if (Window_BattleEnemy.prototype.hasOwnProperty("cursorDown")) {
    Alias.WiBaEn_cursorDown = Window_BattleEnemy.prototype.cursorDown;
  }
  Window_BattleEnemy.prototype.cursorDown = function (wrap) {
    if (Params.enemyWindowView) {
      var _super =
        Alias.WiBaEn_cursorDown || Window_Selectable.prototype.cursorDown;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() + 1) % this.maxItems());
    }
  };

  //
  if (Window_BattleEnemy.prototype.hasOwnProperty("cursorUp")) {
    Alias.WiBaEn_cursorUp = Window_BattleEnemy.prototype.cursorUp;
  }
  Window_BattleEnemy.prototype.cursorUp = function (wrap) {
    if (Params.enemyWindowView) {
      var _super =
        Alias.WiBaEn_cursorUp || Window_Selectable.prototype.cursorUp;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() - 1).mod(this.maxItems()));
    }
  };

  //
  if (Window_BattleEnemy.prototype.hasOwnProperty("cursorRight")) {
    Alias.WiBaEn_cursorRight = Window_BattleEnemy.prototype.cursorRight;
  }
  Window_BattleEnemy.prototype.cursorRight = function (wrap) {
    if (Params.enemyWindowView) {
      var _super =
        Alias.WiBaEn_cursorRight || Window_Selectable.prototype.cursorRight;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() + 1) % this.maxItems());
    }
  };

  //
  if (Window_BattleEnemy.prototype.hasOwnProperty("cursorLeft")) {
    Alias.WiBaEn_cursorLeft = Window_BattleEnemy.prototype.cursorLeft;
  }
  Window_BattleEnemy.prototype.cursorLeft = function (wrap) {
    if (Params.enemyWindowView) {
      var _super =
        Alias.WiBaEn_cursorLeft || Window_Selectable.prototype.cursorLeft;
      _super.apply(this, arguments);
    } else {
      this.select((this.index() - 1).mod(this.maxItems()));
    }
  };

  //58
  Alias.WiBaEn_show = Window_BattleEnemy.prototype.show;
  Window_BattleEnemy.prototype.show = function () {
    if (Params.enemyWindowView) {
      Alias.WiBaEn_show.apply(this, arguments);
    } else {
      this.select(0);
    }
  };

  if (Window_BattleEnemy.prototype.hasOwnProperty("isTouchedInsideFrame")) {
    Alias.WiBaEn_isTouchedInsideFrame =
      Window_BattleEnemy.prototype.isTouchedInsideFrame;
  }
  Window_BattleEnemy.prototype.isTouchedInsideFrame = function () {
    if (this._hitEnemyHandler && this._hitEnemyHandler()) return true;
    if (this.visible) {
      var _super =
        Alias.WiBaEn_isTouchedInsideFrame ||
        Window_Selectable.prototype.isTouchedInsideFrame;
      return _super.apply(this, arguments);
    }
    return false;
  };

  if (Window_BattleEnemy.prototype.hasOwnProperty("hitTest")) {
    Alias.WiBaEn_hitTest = Window_BattleEnemy.prototype.hitTest;
  }
  Window_BattleEnemy.prototype.hitTest = function (x, y) {
    if (this._hitEnemyHandler) {
      var enemy = this._hitEnemyHandler();
      if (enemy) return this._cursorAll ? 0 : this._enemies.indexOf(enemy);
    }
    if (this.visible) {
      var _super = Alias.WiBaEn_hitTest || Window_Selectable.prototype.hitTest;
      return _super.apply(this, arguments);
    }
    return -1;
  };

  //-----------------------------------------------------------------------------
  // Sprite_Battler

  Sprite_Battler.prototype.isArrowView = function () {
    return this._battler.isSpriteVisible();
  };

  //112
  Alias.SpBa_updateSelectionEffect =
    Sprite_Battler.prototype.updateSelectionEffect;
  Sprite_Battler.prototype.updateSelectionEffect = function () {
    Alias.SpBa_updateSelectionEffect.apply(this, arguments);
    if (this.isArrowView()) {
      if (this._battler.isSelected()) {
        if (!this._mppArrowSprite) this.createMppArrowSprite();
        if (this._mppArrowSprite) this.updateMppArrowVisibility();
      } else if (this._mppArrowSprite) {
        this._mppArrowSprite.remove();
        this._mppArrowSprite = null;
      }
    }
  };

  Sprite_Battler.prototype.createMppArrowSprite = function () {
    var sprite = new Sprite_SelectArrow();
    sprite.setup(this._effectTarget, this.mppArrowParams());
    this.parent.addChild(sprite);
    this._mppArrowSprite = sprite;
  };

  Sprite_Battler.prototype.updateMppArrowVisibility = function () {
    this._mppArrowSprite.visible = true;
  };

  Sprite_Battler.prototype.isOverlap = function (x, y) {
    if (!this.visible) return false;
    var target = this._effectTarget;
    var tw = Math.abs(target.width * target.scale.x);
    var th = Math.abs(target.height * target.scale.y);
    var sx = this.x - tw * target.anchor.x;
    var sy = this.y - th * target.anchor.y;
    return x >= sx && y >= sy && x < sx + tw && y < sy + th;
  };

  //-----------------------------------------------------------------------------
  // Sprite_Actor

  Sprite_Actor.prototype.isArrowView = function () {
    return (
      Sprite_Battler.prototype.isArrowView.call(this) && Params.actorArrowView
    );
  };

  Sprite_Actor.prototype.mppArrowParams = function () {
    return Params.actorArrow;
  };

  //-----------------------------------------------------------------------------
  // Sprite_Enemy

  Sprite_Enemy.prototype.isArrowView = function () {
    return (
      Sprite_Battler.prototype.isArrowView.call(this) && Params.enemyArrowView
    );
  };

  Sprite_Enemy.prototype.mppArrowParams = function () {
    return Params.enemyArrow;
  };

  Sprite_Enemy.prototype.updateMppArrowVisibility = function () {
    this._mppArrowSprite.visible = this._appeared;
  };

  Sprite_Enemy.prototype.isOverlap = function (x, y) {
    return (
      Sprite_Battler.prototype.isOverlap.call(this, x, y) &&
      this._enemy.isAlive()
    );
  };

  //-----------------------------------------------------------------------------
  // Sprite_SelectArrow

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

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

  MPP.Sprite_SelectArrow = Sprite_SelectArrow;

  Sprite_SelectArrow.prototype.initialize = function () {
    Sprite.prototype.initialize.call(this);
  };

  Sprite_SelectArrow.createArrowBitmap = function () {
    var bitmap = new Bitmap(52, 52);
    var context = bitmap.context;
    context.save();

    context.globalAlpha = 0.8;
    context.lineWidth = 6;
    context.lineCap = "round";

    var gradient = context.createLinearGradient(3, 0, 49, 0);
    gradient.addColorStop(0, "rgb(128,0,0)");
    gradient.addColorStop(1, "rgba(255,128,0,0.75)");
    context.strokeStyle = gradient;

    context.beginPath();
    context.arc(26, 26, 23, 0, (150 / 180) * Math.PI);
    context.stroke();

    var gradient = context.createLinearGradient(3, 0, 49, 0);
    gradient.addColorStop(0, "rgba(255,128,0,0.75)");
    gradient.addColorStop(1, "rgb(128,0,0)");
    context.strokeStyle = gradient;

    context.beginPath();
    context.arc(26, 26, 23, Math.PI, (330 / 180) * Math.PI);
    context.stroke();

    context.restore();

    bitmap.smooth = true;
    this.arrowBitmap = bitmap;
  };

  Sprite_SelectArrow.prototype.setup = function (target, params) {
    this._target = target;
    if (params.Name) {
      this.bitmap = ImageManager.loadSystem(params.Name);
    } else {
      this.bitmap = Sprite_SelectArrow.arrowBitmap;
    }
    this.anchor.x = 0.5;
    this.anchor.y = 0.5;
    this.opacity = params.Opacity;

    this._pos = params.Pos;
    this._width = params.Width;
    this._rate = params.Rate;
    this._rotation = params.Rotation;
    this._speed = params.Speed;
    this._animeCount = 0;
    this._angle = 0;
    this.update();
  };

  Sprite_SelectArrow.prototype.remove = function () {
    this.parent.removeChild(this);
  };

  Sprite_SelectArrow.prototype.update = function () {
    Sprite.prototype.update.call(this);
    this.updateAnime();
    this.updateRotation();
    this.updatePos();
  };

  Sprite_SelectArrow.prototype.updateAnime = function () {
    this._animeCount++;
    var w = this._width;
    if (w > 0) {
      var h = this.height;
      var x = Math.floor(this._animeCount / this._rate) * w;
      var y = 0;
      if (x >= this.bitmap.width) {
        this._animeCount = 0;
        x = 0;
      }
      this.setFrame(x, y, w, h);
    }
  };

  Sprite_SelectArrow.prototype.updateRotation = function () {
    this._angle += this._speed;
    this._angle = this._angle.mod(360);
    var radian = (this._angle * Math.PI) / 180;
    switch (this._rotation) {
      case 1:
        this.rotation = radian;
        break;
      case 2:
        this.scale.x = Math.cos(radian);
        break;
      case 3:
        this.scale.y = Math.cos(radian);
        break;
    }
  };

  Sprite_SelectArrow.prototype.updatePos = function () {
    var target = this._target;
    var pos = this._pos - 1;
    var hw = target.width / 2;
    var hh = target.height / 2;
    var parent = target.parent;
    var grandparent = parent ? parent.parent : null;
    this.x = target.x;
    this.y = target.y;
    if (this.parent === grandparent) {
      this.x += parent.x;
      this.y += parent.y;
    }
    if (pos === -1) {
      if (this.x < Graphics.width / 2) {
        this.x += hw;
        this.scale.x = 1;
      } else {
        this.x -= hw;
        this.scale.x = -1;
      }
      this.y -= hh;
    } else {
      if (pos % 3 === 0) this.x -= hw;
      else if (pos % 3 === 2) this.x += hw;
      if (Math.floor(pos / 3) === 1) this.y -= hh;
      else if (Math.floor(pos / 3) === 2) this.y -= hh * 2;
    }
  };

  //-----------------------------------------------------------------------------
  // Spriteset_Battle

  Spriteset_Battle.prototype.hitActor = function () {
    var x = TouchInput.x;
    var y = TouchInput.y;
    var sprites = this._actorSprites;
    for (var i = 0; i < sprites.length; i++) {
      if (sprites[i].isOverlap(x, y)) return sprites[i]._battler;
    }
    return null;
  };

  Spriteset_Battle.prototype.hitEnemy = function () {
    var x = TouchInput.x;
    var y = TouchInput.y;
    var sprites = this._enemySprites;
    for (var i = 0; i < sprites.length; i++) {
      if (sprites[i].isOverlap(x, y)) return sprites[i]._battler;
    }
    return null;
  };

  //-----------------------------------------------------------------------------
  // Scene_Boot

  //18
  Alias.ScBo_create = Scene_Boot.prototype.create;
  Scene_Boot.prototype.create = function () {
    Alias.ScBo_create.apply(this, arguments);
    if (!Params.actorArrow.Name || !Params.enemyArrow.Name)
      Sprite_SelectArrow.createArrowBitmap();
  };

  //29
  Alias.ScBo_loadSystemImages = Scene_Boot.loadSystemImages;
  Scene_Boot.loadSystemImages = function () {
    Alias.ScBo_loadSystemImages.apply(this, arguments);
    if (Params.actorArrow.Name)
      ImageManager.reserveSystem(Params.actorArrow.Name);
    if (Params.enemyArrow.Name)
      ImageManager.reserveSystem(Params.enemyArrow.Name);
  };

  //-----------------------------------------------------------------------------
  // Scene_Battle

  //210
  Alias.ScBa_createActorWindow = Scene_Battle.prototype.createActorWindow;
  Scene_Battle.prototype.createActorWindow = function () {
    Alias.ScBa_createActorWindow.apply(this, arguments);
    this._actorWindow._hitActorHandler = this._spriteset.hitActor.bind(
      this._spriteset
    );
  };

  //217
  Alias.ScBa_createEnemyWindow = Scene_Battle.prototype.createEnemyWindow;
  Scene_Battle.prototype.createEnemyWindow = function () {
    Alias.ScBa_createEnemyWindow.apply(this, arguments);
    this._enemyWindow._hitEnemyHandler = this._spriteset.hitEnemy.bind(
      this._spriteset
    );
  };
})(this);


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

/*:
 * @plugindesc 【ver.1.0】各ウィンドウの一行の高さ、文字の大きさ等を変更します。
 * @author 木星ペンギン
 *
 * @help ●変更できるもの
 *   ・lineHeight            # 一行の高さ(デフォルト値:36)
 *   ・standardFontSize      # 文字の大きさ(デフォルト値:28)
 *   ・standardPadding       # 余白の幅(デフォルト値:18)
 *   ・standardBackOpacity   # 背景の不透明度(デフォルト値:192)
 *  ※ツクール側が対応できない数値を設定した場合の動作は保証しません。
 *
 *  ●上位クラスの値を変えると、下位クラスの値も変わります。
 *  　ただし、下位クラスで値が設定されている場合は変わりません。
 *  　上位クラスと下位クラスで違う値を設定した場合、下位クラスが優先されます。
 *
 *  Window_Base                   # 全てのウィンドウの上位クラス
 *  ├Window_Selectable           # 項目選択の機能を持つクラス
 *  │├Window_Command            # 一般的なコマンド選択を行うクラス
 *  ││├Window_HorzCommand      # 横選択形式のコマンドウィンドウ
 *  │││├Window_ItemCategory   # アイテムの分類を選択するウィンドウ
 *  │││├Window_EquipCommand   # 装備コマンドを選択するウィンドウ
 *  │││└Window_ShopCommand    # ショップ画面でコマンドを選択するウィンドウ
 *  ││├Window_MenuCommand      # メニュー画面でコマンドを選択するウィンドウ
 *  ││├Window_SkillType        # スキルタイプを選択するウィンドウ
 *  ││├Window_Options          # オプション画面でコマンドを選択するウィンドウ
 *  ││├Window_ChoiceList       # [選択肢の表示]に使用するウィンドウ
 *  ││├Window_PartyCommand     # 戦闘画面で戦うか逃げるかを選択するウィンドウ
 *  ││├Window_ActorCommand     # 戦闘画面でアクターの行動を選択するウィンドウ
 *  ││├Window_TitleCommand     # タイトル画面でコマンドを選択するウィンドウ
 *  ││└Window_GameEnd          # ゲーム終了画面でコマンドを選択するウィンドウ
 *  │├Window_MenuStatus         # メニュー画面でステータスを表示するウィンドウ
 *  ││└Window_MenuActor        # アイテムやスキルの対象を選択するウィンドウ
 *  │├Window_ItemList           # アイテム画面で所持品を表示するウィンドウ
 *  ││├Window_EquipItem        # 装備画面で装備候補を表示するウィンドウ
 *  ││├Window_ShopSell         # ショップ画面で所持品を表示するウィンドウ
 *  ││├Window_EventItem        # [アイテム選択の処理]に使用するウィンドウ
 *  ││└Window_BattleItem       # 戦闘画面で所持品を選択するウィンドウ
 *  │├Window_SkillList          # スキル画面でスキルを表示するウィンドウ
 *  ││└Window_BattleSkill      # 戦闘画面でスキルを選択するウィンドウ
 *  │├Window_EquipSlot          # 装備画面で装備品を表示するウィンドウ
 *  │├Window_Status             # ステータス画面で表示するウィンドウ
 *  │├Window_SavefileList       # セーブ／ロード画面で表示するウィンドウ
 *  │├Window_ShopBuy            # ショップ画面で購入可能品を表示するウィンドウ
 *  │├Window_ShopNumber         # ショップ画面で個数を入力するウィンドウ
 *  │├Window_NameInput          # 名前入力画面で文字を選択するウィンドウ
 *  │├Window_NumberInput        # [数値入力の処理]に使用するウィンドウ
 *  │├Window_BattleLog          # 戦闘の進行を実況表示するウィンドウ
 *  │├Window_BattleStatus       # 戦闘画面でステータスを表示するウィンドウ
 *  ││└Window_BattleActor      # 戦闘画面で対象のアクターを選択するウィンドウ
 *  │└Window_BattleEnemy        # 戦闘画面で対象の敵キャラを選択するウィンドウ
 *  ├Window_Help                 # スキルやアイテムの説明等を表示するウィンドウ
 *  ├Window_Gold                 # 所持金を表示するウィンドウ
 *  ├Window_SkillStatus          # スキル画面でステータスを表示するウィンドウ
 *  ├Window_EquipStatus          # 装備画面で能力値変化を表示するウィンドウ
 *  ├Window_ShopStatus           # ショップ画面で所持数などを表示するウィンドウ
 *  ├Window_NameEdit             # 名前入力画面で名前を編集するウィンドウ
 *  ├Window_Message              # 文章表示に使うメッセージウィンドウ
 *  ├Window_ScrollText           # [文章のスクロール表示]に使うウィンドウ
 *  └Window_MapName              # マップ名を表示するウィンドウ
 *
 * ================================
 * 制作 : 木星ペンギン
 * URL : http://woodpenguin.blog.fc2.com/
 *
 * @param parameters
 * @type struct<param>[]
 * @desc パラメータの配列
 * @default []
 *
 */

/*~struct~param:
 * @param class
 * @type select
 * @option Window_Base
 * @option Window_Selectable
 * @option Window_Command
 * @option Window_HorzCommand
 * @option Window_ItemCategory
 * @option Window_EquipCommand
 * @option Window_ShopCommand
 * @option Window_MenuCommand
 * @option Window_SkillType
 * @option Window_Options
 * @option Window_ChoiceList
 * @option Window_PartyCommand
 * @option Window_ActorCommand
 * @option Window_TitleCommand
 * @option Window_GameEnd
 * @option Window_MenuStatus
 * @option Window_MenuActor
 * @option Window_ItemList
 * @option Window_EquipItem
 * @option Window_ShopSell
 * @option Window_EventItem
 * @option Window_BattleItem
 * @option Window_SkillList
 * @option Window_BattleSkill
 * @option Window_EquipSlot
 * @option Window_Status
 * @option Window_SavefileList
 * @option Window_ShopBuy
 * @option Window_ShopNumber
 * @option Window_NameInput
 * @option Window_NumberInput
 * @option Window_BattleLog
 * @option Window_BattleStatus
 * @option Window_BattleActor
 * @option Window_BattleEnemy
 * @option Window_Help
 * @option Window_Gold
 * @option Window_SkillStatus
 * @option Window_EquipStatus
 * @option Window_ShopStatus
 * @option Window_NameEdit
 * @option Window_Message
 * @option Window_ScrollText
 * @option Window_MapName
 * @desc クラス名
 * @default Window_Base
 *
 * @param lineHeight
 * @desc 一行の高さ
 * (デフォルト値:36 / 未設定の場合は変更なし)
 * @default
 *
 * @param standardFontSize
 * @desc 文字の大きさ
 * (デフォルト値:28 / 未設定の場合は変更なし)
 * @default
 *
 * @param standardPadding
 * @desc 余白の幅
 * (デフォルト値:18 / 未設定の場合は変更なし)
 * @default
 *
 * @param standardBackOpacity
 * @desc 背景の不透明度
 * (デフォルト値:192 / 未設定の場合は変更なし)
 * @default
 *
 */

(function () {
  var method = "%1.prototype.%2 = function() { return %3; };";
  var properties = [
    "lineHeight",
    "standardFontSize",
    "standardPadding",
    "standardBackOpacity",
  ];

  var parameters = PluginManager.parameters("MPP_WindowPropertyCustom");

  var parameters2 = JSON.parse(parameters["parameters"] || "[]");
  for (var i = 0; i < parameters2.length; i++) {
    var data = JSON.parse(parameters2[i]);
    for (var j = 0; j < 4; j++) {
      var property = properties[j];
      if (data.class && data[property]) {
        try {
          eval(method.format(data.class, property, data[property]));
        } catch (e) {}
      }
    }
  }
})();