code:
//=============================================================================
// TouchUI.js
//
// (c)2016 KADOKAWA CORPORATION./YOJI OJIMA
//=============================================================================

/*:
 * @plugindesc Change the UI for the touch operation.
 * @author Takeya Kimura
 * @mobileOnly 1
 *
 * @param Menu Command Text
 * @desc The Menu Command Text for map scene.
 * @default メニュー
 *
 * @param Previous Command Text
 * @desc The Previous Command Text for menu scene.
 * @default 前
 *
 * @param Next Command Text
 * @desc The Next Command Text for menu scene.
 * @default 次
 *
 * @help This plugin does not provide plugin commands.
 * This plugin is the only for standard UI.
 */

/*:ja
 * @plugindesc UIをタッチ操作に適したものへ変更します。
 * @author Takeya Kimura
 * @mobileOnly 1
 *
 * @param Menu Command Text
 * @desc マップシーンに表示されるメニューボタンのテキストです。
 * @default メニュー
 *
 * @param Previous Command Text
 * @desc メニューに表示される前へボタンのテキストです。
 * @default 前
 *
 * @param Next Command Text
 * @desc メニューに表示される次へボタンのテキストです。
 * @default 次
 *
 * @help このプラグインにはプラグインコマンドはありません。
 * このプラグインはUIを変更する他のプラグインと共存はできません。
 */

if (Utils.isMobileDevice()) {
  (function () {
    var parameters = PluginManager.parameters("TouchUI");
    var menuCommandText = String(parameters["Menu Command Text"] || "メニュー");
    var prevCommandText = String(parameters["Previous Command Text"] || "前");
    var nextCommandText = String(parameters["Next Command Text"] || "次");

    //-----------------------------------------------------------------------------
    // Window_SwipeContainer
    //
    // Swipe container for vertical scroll

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

    Window_SwipeContainer.prototype = Object.create(
      PIXI.DisplayObjectContainer.prototype
    );
    Window_SwipeContainer.prototype.constructor = Window_SwipeContainer;

    Window_SwipeContainer.CONFIRM_GAP = 10;

    Window_SwipeContainer.prototype.initialize = function () {
      PIXI.DisplayObjectContainer.call(this);

      this._scrollY = 0;
      this._lastY = 0;
      this._lastScrollY = 0;
      this._touching = false;
      this._overGap = false;
      this._swiped = false;
      this._contentsWidth = 0;
      this._contentsHeight = 0;
      this._maxWidth = 0;
      this._maxHeight = 0;
      this._overDist = 0;
      this._activate = false;
    };

    Object.defineProperty(Window_SwipeContainer.prototype, "scrollY", {
      get: function () {
        return this._scrollY;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "overGap", {
      get: function () {
        return this._overGap;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "swiped", {
      get: function () {
        return this._swiped;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "contentsWidth", {
      get: function () {
        return this._contentsWidth;
      },
      set: function (value) {
        if (this._contentsWidth !== value) this._contentsWidth = value;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "contentsHeight", {
      get: function () {
        return this._contentsHeight;
      },
      set: function (value) {
        if (this._contentsHeight !== value) this._contentsHeight = value;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "maxWidth", {
      get: function () {
        return this._maxWidth;
      },
      set: function (value) {
        if (this._maxWidth !== value) this._maxWidth = value;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "maxHeight", {
      get: function () {
        return this._maxHeight;
      },
      set: function (value) {
        if (this._maxHeight !== value) this._maxHeight = value;
      },
      configurable: true,
    });

    Object.defineProperty(Window_SwipeContainer.prototype, "overDist", {
      get: function () {
        return this._overDist;
      },
      set: function (value) {
        if (this._overDist !== value) this._overDist = value;
      },
      configurable: true,
    });

    Window_SwipeContainer.prototype.activate = function () {
      this._activate = true;
    };

    Window_SwipeContainer.prototype.deactivate = function () {
      this._activate = false;
    };

    Window_SwipeContainer.prototype.update = function () {
      var dy;
      var overDistY;
      var ratio = 1;

      if (
        TouchInput.isTriggered() &&
        this.isTouchedInsideFrame() &&
        this._activate
      ) {
        this._touching = true;
        this._lastY = TouchInput.y;
        this._overGap = false;
        this._swiped = false;
        this._lastScrollY = this._scrollY;
      } else if (TouchInput.isReleased()) {
        this._touching = false;
        this._swiped = false;
      }

      if (TouchInput.isMoved() && this._touching && this._activate) {
        dy = TouchInput.y - this._lastY;

        var ny = this._scrollY + dy;

        if (ny <= 0 && ny + this.maxHeight >= this.contentsHeight) {
        } else {
          if (ny > 0) {
            overDistY = ny.clamp(0, this._overDist);
          } else if (ny + this.maxHeight < this.contentsHeight) {
            if (this.maxHeight < this.contentsHeight) {
              overDistY = Math.abs(ny).clamp(0, this._overDist);
            } else {
              overDistY = (this.contentsHeight - (ny + this.maxHeight)).clamp(
                0,
                this._overDist
              );
            }
          }
          ratio = Math.abs((this._overDist - overDistY) / this._overDist);
          dy *= ratio;
        }

        this._scrollY += dy;

        this._swiped = true;
        if (
          Math.abs(this._scrollY - this._lastScrollY) >
          Window_SwipeContainer.CONFIRM_GAP
        ) {
          this._overGap = true;
        }

        this._lastY = TouchInput.y;
      } else if (!this._touching) {
        dy = 0;

        if (this._scrollY > 0) {
          overDistY = this._scrollY;
          dy = -overDistY * 0.3;
        } else if (this._scrollY + this.maxHeight < this.contentsHeight) {
          if (this.maxHeight < this.contentsHeight) {
            overDistY = -this._scrollY;
          } else {
            overDistY = this.contentsHeight - (this._scrollY + this.maxHeight);
          }
          dy = overDistY * 0.3;
        }

        this._scrollY += dy;
      }
    };

    Window_SwipeContainer.prototype.isTouchedInsideFrame = function () {
      var x = this.canvasToLocalX(TouchInput.x);
      var y = this.canvasToLocalY(TouchInput.y);
      return (
        x >= 0 && y >= 0 && x < this.contentsWidth && y < this.contentsHeight
      );
    };

    Window_SwipeContainer.prototype.setScroll = function (y) {
      this._scrollY = y;
    };

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

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

    //-----------------------------------------------------------------------------
    // Window_MapCommand
    //
    // This button to open the menu from the map scene.

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

    Window_MapCommand.prototype = Object.create(Window_Command.prototype);
    Window_MapCommand.prototype.constructor = Window_MapCommand;

    Window_MapCommand.prototype.initialize = function (x, y) {
      Window_Command.prototype.initialize.call(this, x, y);
      this.updatePlacement();
      this.openness = 0;
    };

    Object.defineProperty(Window_MapCommand.prototype, "isTouching", {
      get: function () {
        return this._touching;
      },
      configurable: true,
    });

    Window_MapCommand.prototype.updatePlacement = function () {
      this.x = Graphics.boxWidth - this.windowWidth();
      this.y = Graphics.boxHeight - this.windowHeight();
    };

    Window_MapCommand.prototype.makeCommandList = function () {
      this.addCommand(menuCommandText, "menu");
    };

    //The top priority to open the menu
    Window_MapCommand.prototype.preUpdate = function () {
      Window_Selectable.prototype.update.call(this);
    };
    Window_MapCommand.prototype.update = function () {};

    Window_MapCommand.prototype.itemTextAlign = function () {
      return "center";
    };

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

    Window_CancelCommand.prototype = Object.create(
      Window_HorzCommand.prototype
    );
    Window_CancelCommand.prototype.constructor = Window_CancelCommand;

    Window_CancelCommand.prototype.initialize = function (x, y) {
      this._pagingEnable = false;
      Window_Command.prototype.initialize.call(this, x, y);
      this.setColumnRatio([0.25, 0.25, 0.5]);
      this.refresh();
    };

    Window_CancelCommand.prototype.makeCommandList = function () {
      this.addCommand(prevCommandText, "previous", this._pagingEnable);
      this.addCommand(nextCommandText, "next", this._pagingEnable);
      this.addCommand(TextManager.cancel, "cancel");
    };

    Window_CancelCommand.prototype.windowWidth = function () {
      return Graphics.boxWidth;
    };

    Window_CancelCommand.prototype.maxCols = function () {
      return 3;
    };

    Window_CancelCommand.prototype.pagingEnable = function (value) {
      if (this._pagingEnable !== value) {
        this._pagingEnable = value;
        this.clearCommandList();
        this.makeCommandList();
        this.refresh();
      }
    };

    Window_CancelCommand.prototype.itemTextAlign = function () {
      return "center";
    };

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

    Window_BattleCancelCommand.prototype = Object.create(
      Window_CancelCommand.prototype
    );
    Window_BattleCancelCommand.prototype.constructor =
      Window_BattleCancelCommand;

    Window_BattleCancelCommand.prototype.initialize = function (x, y) {
      Window_CancelCommand.prototype.initialize.call(this, x, y);
      this._pagingEnable = false;
      this.openness = 0;
      this.deactivate();
    };

    Window_BattleCancelCommand.prototype.windowWidth = function () {
      return 192;
    };

    Window_BattleCancelCommand.prototype.numVisibleRows = function () {
      return 1;
    };

    Window_BattleCancelCommand.prototype.makeCommandList = function () {
      this.addCommand(TextManager.cancel, "cancel");
    };

    Window_BattleCancelCommand.prototype.maxCols = function () {
      return 1;
    };

    Window_BattleCancelCommand.prototype.setup = function () {
      this.clearCommandList();
      this.makeCommandList();
      this.setColumnRatio([1]);
      this.refresh();
      this.activate();
      this.open();
    };

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

    Window_ShopCancelCommand.prototype = Object.create(
      Window_CancelCommand.prototype
    );
    Window_ShopCancelCommand.prototype.constructor = Window_ShopCancelCommand;

    Window_ShopCancelCommand.prototype.initialize = function (x, y) {
      Window_CancelCommand.prototype.initialize.call(this, x, y);
      this._pagingEnable = false;
      this.clearCommandList();
      this.makeCommandList();
      this.setColumnRatio([1]);
      this.refresh();
      this.activate();
    };

    Window_ShopCancelCommand.prototype.windowWidth = function () {
      return 192;
    };

    Window_ShopCancelCommand.prototype.numVisibleRows = function () {
      return 1;
    };

    Window_ShopCancelCommand.prototype.makeCommandList = function () {
      this.addCommand(TextManager.cancel, "cancel");
    };

    Window_ShopCancelCommand.prototype.maxCols = function () {
      return 1;
    };

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

    Window_MessageCancel.prototype = Object.create(Window_Command.prototype);
    Window_MessageCancel.prototype.constructor = Window_MessageCancel;

    Window_MessageCancel.prototype.initialize = function (messageWindow) {
      this._messageWindow = messageWindow;
      Window_Command.prototype.initialize.call(this, 0, 0);
      this.openness = 0;
      this.deactivate();
      this._background = 0;
    };

    Window_MessageCancel.prototype.makeCommandList = function () {
      this.addCommand(TextManager.cancel, "cancel");
    };

    Window_MessageCancel.prototype.maxCols = function () {
      return 1;
    };

    Window_MessageCancel.prototype.itemTextAlign = function () {
      return "center";
    };

    Window_MessageCancel.prototype.start = function () {
      this.updatePlacement();
      this.refresh();
      this.deselect();
      this.open();
      this.activate();
    };

    Window_MessageCancel.prototype.updatePlacement = function () {
      this.x = Graphics.boxWidth - this.width;
      this.y = Graphics.boxHeight - this.height;
    };

    Window_MessageCancel.prototype.callOkHandler = function () {
      TouchInput._events.cancelled = true;
    };

    Window_MessageCancel.prototype.callSelectHandler = function () {
      this._messageWindow.choiceDeselect();
    };

    var Scene_Map_initialize = Scene_Map.prototype.initialize;
    Scene_Map.prototype.initialize = function () {
      Scene_Map_initialize.call(this);
      this._menuWindow = null;
    };

    var Scene_Map_createDisplayObjects =
      Scene_Map.prototype.createDisplayObjects;
    Scene_Map.prototype.createDisplayObjects = function () {
      Scene_Map_createDisplayObjects.call(this);
      this._menuWindow = new Window_MapCommand();
      this._menuWindow.setHandler("menu", this.menu.bind(this));
      this.addWindow(this._menuWindow);
      this._stillCount = 0;
    };

    Scene_Map.prototype.menu = function () {
      this.menuCalling = true;
    };

    var Scene_Map_terminate = Scene_Map.prototype.terminate;
    Scene_Map.prototype.terminate = function () {
      this._menuWindow.hide();
      Scene_Map_terminate.call(this);
    };

    var Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function () {
      if ($gameMap.isEventRunning() || $gamePlayer.isMoving()) {
        this._stillCount = 0;
        this._menuWindow.close();
      } else {
        if (this._stillCount > 60) {
          this._menuWindow.open();
        } else {
          this._stillCount++;
        }
      }

      this._menuWindow.preUpdate();

      Scene_Map_update.call(this);
    };

    /*
     * Enable this method by the 1 touch operation (case of release handler)
     */
    //var Scene_Map_isMapTouchOk = Scene_Map.prototype.isMapTouchOk;
    //Scene_Map.prototype.isMapTouchOk = function() {
    //    var result = Scene_Map_isMapTouchOk.call(this);
    //    return result && !this._menuWindow.isTouching;
    //};

    var _Scene_Menu_create = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function () {
      _Scene_Menu_create.call(this);

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.cancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.deselect();

      this._commandWindow.setHandler("select", this.selectCommand.bind(this));

      var h = Graphics.boxHeight - this._cancelWindow.height;
      this._statusWindow.move(
        this._statusWindow.x,
        this._statusWindow.y,
        this._statusWindow.width,
        h
      );
      this._goldWindow.y =
        Graphics.boxHeight -
        this._cancelWindow.height -
        this._goldWindow.height;
      h = this._goldWindow.y;
      this._commandWindow.move(
        this._commandWindow.x,
        this._commandWindow.y,
        this._commandWindow.width,
        h
      );
      this._commandWindow.refresh();
    };

    Scene_Menu.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Menu.prototype.selectCancel = function () {
      if (this._commandWindow.active) this._commandWindow.deselect();
    };

    Scene_Menu.prototype.cancel = function () {
      if (this._commandWindow.active) {
        this.popScene();
      } else {
        if (this._statusWindow.formationMode()) {
          this.onFormationCancel();
        } else {
          this.onPersonalCancel();
          //Explicit deactivate
          this._statusWindow.deactivate();
        }
        this._cancelWindow.activate();
      }
    };

    Scene_Menu.prototype.onFormationCancel = function () {
      if (this._statusWindow.pendingIndex() >= 0) {
        this._statusWindow.setPendingIndex(-1);
        this._statusWindow.activate();
      } else {
        this._statusWindow.deselect();
        //Explicit deactivate
        this._statusWindow.deactivate();
        this._commandWindow.activate();
      }
    };

    var Scene_File_create = Scene_File.prototype.create;
    Scene_File.prototype.create = function () {
      Scene_File_create.call(this);

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.popScene.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.deselect();

      this._listWindow.setHandler("select", this.selectList.bind(this));

      var h = this._listWindow.height - this._cancelWindow.height;
      this._listWindow.move(
        this._listWindow.x,
        this._listWindow.y,
        this._listWindow.width,
        h
      );
    };

    Scene_File.prototype.selectCancel = function () {
      this._listWindow._windowCursorSprite.alpha = 1;
      this._listWindow._allowCursorBlink = false;
    };

    Scene_File.prototype.selectList = function () {
      this._listWindow._allowCursorBlink = true;
      this._cancelWindow.deselect();
    };

    Scene_ItemBase.prototype.createActorWindow = function () {
      this._actorWindow = new Window_MenuActor(this);
      this._actorWindow.setHandler("ok", this.onActorOk.bind(this));
      this._actorWindow.setHandler("cancel", this.onActorCancel.bind(this));
      this.addWindow(this._actorWindow);
    };

    var _Scene_Item_create = Scene_Item.prototype.create;
    Scene_Item.prototype.create = function () {
      _Scene_Item_create.call(this);

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.cancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.deselect();

      this._categoryWindow.setHandler("select", this.selectCommand.bind(this));
      this._itemWindow.setHandler("select", this.selectCommand.bind(this));
      this._actorWindow.setHandler("select", this.selectCommand.bind(this));

      var h = this._itemWindow.height - this._cancelWindow.height;
      this._itemWindow.move(
        this._itemWindow.x,
        this._itemWindow.y,
        this._itemWindow.width,
        h
      );
      this._itemWindow.refresh();
      h = Graphics.boxHeight - this._cancelWindow.height;
      this._actorWindow.move(
        this._actorWindow.x,
        this._actorWindow.y,
        this._actorWindow.width,
        h
      );
      this._actorWindow.refresh();
    };

    Scene_Item.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Item.prototype.selectCancel = function () {
      if (this._categoryWindow.active) {
        this._categoryWindow.deselect();
      } else if (this._itemWindow.active) {
        this._itemWindow.deselect();
      } else if (this._actorWindow.active) {
        this._actorWindow.deselect();
        this._actorWindow.setCursorRect(0, 0, 0, 0);
      }
    };

    Scene_Item.prototype.cancel = function () {
      if (this._categoryWindow.active) {
        this.popScene();
      } else if (this._itemWindow.active) {
        this.onItemCancel();
        //Explicit deactivate
        this._itemWindow.deactivate();
        this._cancelWindow.activate();
      } else if (this._actorWindow.active) {
        this.onActorCancel();
        this._actorWindow.deactivate();
        this._cancelWindow.activate();
      }
    };

    var _Scene_Skill_create = Scene_Skill.prototype.create;
    Scene_Skill.prototype.create = function () {
      _Scene_Skill_create.call(this);

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.cancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this._cancelWindow.setHandler("next", this.nextActor.bind(this));
      this._cancelWindow.setHandler("previous", this.previousActor.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.deselect();
      this._cancelWindow.pagingEnable(true);

      this._skillTypeWindow.setHandler("select", this.selectCommand.bind(this));
      this._itemWindow.setHandler("select", this.selectCommand.bind(this));
      this._actorWindow.setHandler("select", this.selectCommand.bind(this));

      var h = this._itemWindow.height - this._cancelWindow.height;
      this._itemWindow.move(
        this._itemWindow.x,
        this._itemWindow.y,
        this._itemWindow.width,
        h
      );
      this._itemWindow.refresh();
      h = Graphics.boxHeight - this._cancelWindow.height;
      this._actorWindow.move(
        this._actorWindow.x,
        this._actorWindow.y,
        this._actorWindow.width,
        h
      );
      this._actorWindow.refresh();
    };

    Scene_Skill.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Skill.prototype.selectCancel = function () {
      if (this._skillTypeWindow.active) {
        this._skillTypeWindow.deselect();
      } else if (this._itemWindow.active) {
        this._itemWindow.deselect();
      } else if (this._actorWindow.active) {
        this._actorWindow.deselect();
        this._actorWindow.setCursorRect(0, 0, 0, 0);
      }
    };

    Scene_Skill.prototype.cancel = function () {
      if (this._skillTypeWindow.active) {
        this.popScene();
      } else if (this._itemWindow.active) {
        this.onItemCancel();
        //Explicit deactivate
        this._itemWindow.deactivate();
        this._cancelWindow.activate();
        this._cancelWindow.pagingEnable(true);
      } else if (this._actorWindow.active) {
        this.onActorCancel();
        this._actorWindow.deactivate();
        this._cancelWindow.activate();
      }
    };

    var _Scene_Skill_commandSkill = Scene_Skill.prototype.commandSkill;
    Scene_Skill.prototype.commandSkill = function () {
      _Scene_Skill_commandSkill.call(this);
      this._cancelWindow.pagingEnable(false);
    };

    Scene_Skill.prototype.nextActor = function () {
      if (!this._skillTypeWindow.active) return;
      Scene_MenuBase.prototype.nextActor.call(this);
      this._cancelWindow.activate();
    };

    Scene_Skill.prototype.previousActor = function () {
      if (!this._skillTypeWindow.active) return;
      Scene_MenuBase.prototype.previousActor.call(this);
      this._cancelWindow.activate();
    };

    var _Scene_Equip_create = Scene_Equip.prototype.create;
    Scene_Equip.prototype.create = function () {
      _Scene_Equip_create.call(this);
      this._itemWindow.hide();

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.cancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this._cancelWindow.setHandler("next", this.nextActor.bind(this));
      this._cancelWindow.setHandler("previous", this.previousActor.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.deselect();
      this._cancelWindow.pagingEnable(true);

      this._commandWindow.setHandler("select", this.selectCommand.bind(this));
      this._slotWindow.setHandler("select", this.selectCommand.bind(this));
      this._itemWindow.setHandler("select", this.selectCommand.bind(this));

      var h =
        Graphics.boxHeight -
        this._helpWindow.height -
        this._cancelWindow.height;
      this._statusWindow.move(
        this._statusWindow.x,
        this._statusWindow.y,
        this._statusWindow._width,
        h
      );
      h = this._statusWindow.height;
      this._itemWindow.move(
        this._commandWindow.x,
        this._commandWindow.y,
        this._commandWindow.width,
        h
      );
      h -= this._commandWindow.height;
      this._slotWindow.move(
        this._slotWindow.x,
        this._slotWindow.y,
        this._slotWindow.width,
        h
      );
      this._slotWindow.refresh();
    };

    Scene_Equip.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Equip.prototype.selectCancel = function () {
      if (this._commandWindow.active) {
        this._commandWindow.deselect();
      } else if (this._slotWindow.active) {
        this._slotWindow.deselect();
      } else if (this._itemWindow.active) {
        this._itemWindow.deselect();
      }
    };

    Scene_Equip.prototype.cancel = function () {
      if (this._commandWindow.active) {
        this.popScene();
      } else if (this._slotWindow.active) {
        this.onSlotCancel();
        //Explicit deactivate
        this._slotWindow.deactivate();
        this._cancelWindow.activate();
        this._cancelWindow.pagingEnable(true);
      } else if (this._itemWindow.active) {
        this.onItemCancel();
        this._cancelWindow.activate();
        this._itemWindow.hide();
        this._commandWindow.show();
        this._slotWindow.show();
      }
    };

    var Scene_Equip_commandEquip = Scene_Equip.prototype.commandEquip;
    Scene_Equip.prototype.commandEquip = function () {
      Scene_Equip_commandEquip.call(this);
      this._cancelWindow.pagingEnable(false);
    };

    var Scene_Equip_onSlotOk = Scene_Equip.prototype.onSlotOk;
    Scene_Equip.prototype.onSlotOk = function () {
      this._commandWindow.hide();
      this._slotWindow.hide();
      this._itemWindow.show();
      Scene_Equip_onSlotOk.call(this);
    };

    var Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk;
    Scene_Equip.prototype.onItemOk = function () {
      Scene_Equip_onItemOk.call(this);
      this._itemWindow.hide();
      this._commandWindow.show();
      this._slotWindow.show();
    };

    Scene_Equip.prototype.nextActor = function () {
      if (!this._commandWindow.active) return;
      Scene_MenuBase.prototype.nextActor.call(this);
      this._cancelWindow.activate();
    };

    Scene_Equip.prototype.previousActor = function () {
      if (!this._commandWindow.active) return;
      Scene_MenuBase.prototype.previousActor.call(this);
      this._cancelWindow.activate();
    };

    var _Scene_Status_create = Scene_Status.prototype.create;
    Scene_Status.prototype.create = function () {
      _Scene_Status_create.call(this);

      this._cancelWindow = new Window_CancelCommand();
      this._cancelWindow.setHandler("cancel", this.popScene.bind(this));
      this._cancelWindow.setHandler("next", this.nextActor.bind(this));
      this._cancelWindow.setHandler("previous", this.previousActor.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;
      this._cancelWindow.select(2);
      this._cancelWindow.pagingEnable(true);

      var h = Graphics.boxHeight - this._cancelWindow.height;
      this._statusWindow.move(
        this._statusWindow.x,
        this._statusWindow.y,
        this._statusWindow._width,
        h
      );
      this._statusWindow.refresh();
    };

    Scene_Status.prototype.nextActor = function () {
      Scene_MenuBase.prototype.nextActor.call(this);
      this._cancelWindow.activate();
    };

    Scene_Status.prototype.previousActor = function () {
      Scene_MenuBase.prototype.previousActor.call(this);
      this._cancelWindow.activate();
    };
    var _Scene_Battle_create = Scene_Battle.prototype.create;
    Scene_Battle.prototype.create = function () {
      _Scene_Battle_create.call(this);

      this._cancelWindow = new Window_BattleCancelCommand();
      this._cancelWindow.setHandler("cancel", this.commandCancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this.addWindow(this._cancelWindow);
      this._cancelWindow.x = Graphics.boxWidth - this._cancelWindow.width;
      this._cancelWindow.y = Graphics.boxHeight - this._cancelWindow.height;

      this._miniStatusWindow = new Window_MiniBattleStatus();
      this.addWindow(this._miniStatusWindow);
      this._miniStatusWindow.x = this._actorCommandWindow.width;

      this._actorCommandWindow.setHandler(
        "select",
        this.selectCommand.bind(this)
      );
      this._skillWindow.setHandler("select", this.selectCommand.bind(this));
      this._itemWindow.setHandler("select", this.selectCommand.bind(this));
      this._actorWindow.setHandler("select", this.selectCommand.bind(this));
      this._enemyWindow.setHandler("select", this.selectCommand.bind(this));

      this._actorWindow.move(0, 0, Graphics.boxWidth, this._miniStatusWindow.y);
      this._enemyWindow.move(0, 0, Graphics.boxWidth, this._miniStatusWindow.y);
      var h =
        Graphics.boxHeight -
        this._helpWindow.height -
        this._miniStatusWindow.height;
      this._skillWindow.move(
        this._skillWindow.x,
        this._skillWindow.y,
        this._skillWindow.width,
        h
      );
      this._itemWindow.move(
        this._itemWindow.x,
        this._itemWindow.y,
        this._itemWindow.width,
        h
      );
    };

    var Scene_Battle_stop = Scene_Battle.prototype.stop;
    Scene_Battle.prototype.stop = function () {
      Scene_Battle_stop.call(this);
      this._miniStatusWindow.close();
    };

    var Scene_Battle_updateStatusWindow =
      Scene_Battle.prototype.updateStatusWindow;
    Scene_Battle.prototype.updateStatusWindow = function () {
      Scene_Battle_updateStatusWindow.call(this);
      if ($gameMessage.isBusy()) {
        this._miniStatusWindow.close();
      } else if (this.isActive() && !this._messageWindow.isClosing()) {
        if (!this._statusWindow.visible) {
          this._miniStatusWindow.open();
        }
      }
    };

    var Scene_Battle_refreshStatus = Scene_Battle.prototype.refreshStatus;
    Scene_Battle.prototype.refreshStatus = function () {
      Scene_Battle_refreshStatus.call(this);
      this._miniStatusWindow.refresh();
    };

    Scene_Battle.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Battle.prototype.selectCancel = function () {
      if (this._actorCommandWindow.active) {
        this._actorCommandWindow.deselect();
      } else if (this._skillWindow.active) {
        this._skillWindow.deselect();
      } else if (this._itemWindow.active) {
        this._itemWindow.deselect();
      } else if (this._actorWindow.active) {
        this._actorWindow.deselect();
      } else if (this._enemyWindow.active) {
        this._enemyWindow.deselect();
      }
    };

    Scene_Battle.prototype.commandCancel = function () {
      if (this._actorCommandWindow.active) {
        this.selectPreviousCommand();
        //Explicit deactivate
        this._actorCommandWindow.deactivate();
        this._cancelWindow.activate();
      } else if (this._skillWindow.active) {
        this.onSkillCancel();
        this._skillWindow.deactivate();
        this._cancelWindow.activate();
      } else if (this._itemWindow.active) {
        this.onItemCancel();
        this._itemWindow.deactivate();
        this._cancelWindow.activate();
      } else if (this._actorWindow.active) {
        this.onActorCancel();
        this._actorWindow.deactivate();
        this._cancelWindow.activate();
      } else if (this._enemyWindow.active) {
        this.onEnemyCancel();
        this._enemyWindow.deactivate();
        this._cancelWindow.activate();
      }
    };

    var Scene_Battle_startPartyCommandSelection =
      Scene_Battle.prototype.startPartyCommandSelection;
    Scene_Battle.prototype.startPartyCommandSelection = function () {
      Scene_Battle_startPartyCommandSelection.call(this);
      this._cancelWindow.close();
      this._statusWindow.show();
      this._miniStatusWindow.deselect();
      this._miniStatusWindow.close();
    };

    var Scene_Battle_startActorCommandSelection =
      Scene_Battle.prototype.startActorCommandSelection;
    Scene_Battle.prototype.startActorCommandSelection = function () {
      Scene_Battle_startActorCommandSelection.call(this);
      this._cancelWindow.setup();
      this._statusWindow.hide();
      this._miniStatusWindow.select(BattleManager.actor().index());
      this._miniStatusWindow.open();
    };

    var Scene_Battle_endCommandSelection =
      Scene_Battle.prototype.endCommandSelection;
    Scene_Battle.prototype.endCommandSelection = function () {
      Scene_Battle_endCommandSelection.call(this);
      this._cancelWindow.close();
      this._miniStatusWindow.close();
      this._statusWindow.show();
    };

    var _Scene_Shop_create = Scene_Shop.prototype.create;
    Scene_Shop.prototype.create = function () {
      _Scene_Shop_create.call(this);

      this._cancelWindow = new Window_ShopCancelCommand();
      this._cancelWindow.setHandler("cancel", this.cancel.bind(this));
      this._cancelWindow.setHandler("select", this.selectCancel.bind(this));
      this.addWindow(this._cancelWindow);
      var ww = this._numberWindow.width;
      var wh = this._cancelWindow.height;
      var wx = Graphics.boxWidth - ww;
      var wy = Graphics.boxHeight - wh;
      this._cancelWindow.move(wx, wy, ww, wh);
      this._cancelWindow.refresh();
      this._cancelWindow.deselect();

      this._commandWindow.setHandler("select", this.selectCommand.bind(this));
      this._numberWindow.setHandler("change", this.selectCommand.bind(this));
      this._buyWindow.setHandler("select", this.selectCommand.bind(this));
      this._categoryWindow.setHandler("select", this.selectCommand.bind(this));
      this._sellWindow.setHandler("select", this.selectCommand.bind(this));

      this._commandWindow.move(
        wx,
        this._commandWindow.y,
        ww,
        this._commandWindow.height
      );
      this._commandWindow.refresh();

      wh = this._dummyWindow.height - this._cancelWindow.height;
      this._dummyWindow.move(wx, this._dummyWindow.y, ww, wh);

      this._numberWindow.move(wx, this._numberWindow.y, ww, wh);

      wy = this._goldWindow.y + this._goldWindow.height;
      this._statusWindow.move(
        0,
        wy,
        this._statusWindow.width,
        Graphics.boxHeight - wy
      );
      //This class does not inherit the Window_Selectable class, resize of the bitmap
      this._statusWindow.contents.resize(
        this._statusWindow.contentsWidth(),
        this._statusWindow.contentsHeight()
      );

      this._goldWindow.move(
        0,
        this._goldWindow.y,
        this._statusWindow.width,
        this._goldWindow.height
      );
      //This class does not inherit the Window_Selectable class, resize of the bitmap
      this._goldWindow.contents.resize(
        this._goldWindow.contentsWidth(),
        this._goldWindow.contentsHeight()
      );
      this._goldWindow.refresh();

      this._buyWindow.move(wx, this._buyWindow.y, this._buyWindow.width, wh);
      this._sellWindow.move(
        this._sellWindow.x,
        this._sellWindow.y,
        this._sellWindow.width,
        wh - this._categoryWindow.height
      );

      this.createDummyWindow2();
    };

    Scene_Shop.prototype.createDummyWindow2 = function () {
      var wy = this._goldWindow.y + this._goldWindow.height;
      var wh = Graphics.boxHeight - wy;
      this._dummyWindow2 = new Window_Base(0, wy, this._goldWindow.width, wh);
      this.addWindow(this._dummyWindow2);
    };

    var Scene_Shop_commandBuy = Scene_Shop.prototype.commandBuy;
    Scene_Shop.prototype.commandBuy = function () {
      Scene_Shop_commandBuy.call(this);
      this._dummyWindow2.hide();
    };

    var Scene_Shop_commandSell = Scene_Shop.prototype.commandSell;
    Scene_Shop.prototype.commandSell = function () {
      Scene_Shop_commandSell.call(this);
      this._dummyWindow2.hide();
    };

    var Scene_Shop_onBuyCancel = Scene_Shop.prototype.onBuyCancel;
    Scene_Shop.prototype.onBuyCancel = function () {
      Scene_Shop_onBuyCancel.call(this);
      this._dummyWindow2.show();
    };

    var Scene_Shop_onCategoryCancel = Scene_Shop.prototype.onCategoryCancel;
    Scene_Shop.prototype.onCategoryCancel = function () {
      Scene_Shop_onCategoryCancel.call(this);
      this._dummyWindow2.show();
    };

    Scene_Shop.prototype.selectCommand = function () {
      this._cancelWindow.deselect();
    };

    Scene_Shop.prototype.selectCancel = function () {
      if (this._commandWindow.active) {
        this._commandWindow.deselect();
      } else if (this._numberWindow.active) {
        this._numberWindow.deselect();
      } else if (this._buyWindow.active) {
        this._buyWindow.deselect();
      } else if (this._categoryWindow.active) {
        this._categoryWindow.deselect();
      } else if (this._sellWindow.active) {
        this._sellWindow.deselect();
      }
    };

    Scene_Shop.prototype.cancel = function () {
      if (this._commandWindow.active) {
        this.popScene();
      } else {
        if (this._numberWindow.active) {
          this.onNumberCancel();
          //Explicit deactivate
          this._numberWindow.deactivate();
        } else if (this._buyWindow.active) {
          this.onBuyCancel();
          this._buyWindow.deactivate();
        } else if (this._categoryWindow.active) {
          this.onCategoryCancel();
        } else if (this._sellWindow.active) {
          this.onSellCancel();
          this._sellWindow.deactivate();
        }
        this._cancelWindow.activate();
      }
    };

    //vertical align center
    var Window_Base_drawIcon = Window_Base.prototype.drawIcon;
    Window_Base.prototype.drawIcon = function (iconIndex, x, y) {
      y += Math.floor((this.lineHeight() - Window_Base._iconHeight) / 2) - 2;
      Window_Base_drawIcon.call(this, iconIndex, x, y);
    };

    var Window_Selectable_initialize = Window_Selectable.prototype.initialize;
    Window_Selectable.prototype.initialize = function (x, y, width, height) {
      this._lastTopRow = 0;
      this._windowButtonSprite = null;
      this._swipeContainer = null;
      this._columnRatios = [];
      for (var i = 0; i < this.maxCols(); i++) {
        this._columnRatios.push(1 / this.maxCols());
      }
      if (typeof this._swipeable === "undefined") this._swipeable = false;
      Window_Selectable_initialize.call(this, x, y, width, height);
    };

    /**
     * The bitmap used for the button image contents.
     *
     * @property buttonBase
     * @type Bitmap
     */
    Object.defineProperty(Window_Selectable.prototype, "buttonBase", {
      get: function () {
        return this._windowButtonSprite.bitmap;
      },
      set: function (value) {
        this._windowButtonSprite.bitmap = value;
      },
      configurable: true,
    });

    var Window_Selectable_itemWidth = Window_Selectable.prototype.itemWidth;
    Window_Selectable.prototype.itemWidth = function (columnIndex) {
      if (typeof columnIndex !== "undefined" && columnIndex >= 0) {
        return Math.floor(
          (this.width - this.padding * 2 + this.spacing()) *
            this._columnRatios[columnIndex] -
            this.spacing()
        );
      }

      return Window_Selectable_itemWidth.call(this);
    };

    var Window_Selectable_activate = Window_Selectable.prototype.activate;
    Window_Selectable.prototype.activate = function () {
      Window_Selectable_activate.call(this);
      this._swipeContainer.activate();
    };

    var Window_Selectable_deactivate = Window_Selectable.prototype.deactivate;
    Window_Selectable.prototype.deactivate = function () {
      Window_Selectable_deactivate.call(this);
      this._swipeContainer.deactivate();
    };

    var Window_Selectable_select = Window_Selectable.prototype.select;
    Window_Selectable.prototype.select = function (index) {
      Window_Selectable_select.call(this, index);

      if (this._index >= 0) {
        if (this.isHandled("select")) {
          this._handlers["select"]();
        } else {
          this.callSelectHandler();
        }
      }
    };

    var Window_Selectable_setTopRow = Window_Selectable.prototype.setTopRow;
    Window_Selectable.prototype.setTopRow = function (row) {
      if (!this._swipeable) {
        Window_Selectable_setTopRow.call(this, row);
      } else {
        var scrollY = row.clamp(0, this.maxTopRow()) * this.itemHeight();
        if (this._swipeContainer.scrollY !== -scrollY) {
          this._swipeContainer.setScroll(-scrollY);
          this.refresh();
          this.updateCursor();
        }
      }
    };

    var Window_Selectable_maxPageRows = Window_Selectable.prototype.maxPageRows;
    Window_Selectable.prototype.maxPageRows = function () {
      if (this._swipeable) {
        var pageHeight = this.height - this.padding * 2;
        return Math.ceil(pageHeight / this.itemHeight());
      } else {
        return Window_Selectable_maxPageRows.call(this);
      }
    };

    var Window_Selectable_itemRect = Window_Selectable.prototype.itemRect;
    Window_Selectable.prototype.itemRect = function (index) {
      var rect = Window_Selectable_itemRect.call(this, index);

      if (this._swipeable) {
        rect.y -= rect.height * this._lastTopRow;
      }

      // Depend column width
      var x = 0;
      for (var i = 0; i < index % this.maxCols(); i++) {
        x += this.itemWidth(i) + this.spacing();
      }
      rect.x = x;
      rect.width = this.itemWidth(index % this.maxCols());

      return rect;
    };

    var Window_Selectable_update = Window_Selectable.prototype.update;
    Window_Selectable.prototype.update = function () {
      if (this._swipeable) {
        Window_Base.prototype.update.call(this);
        this.updateArrows();

        var currentTopRow =
          Math.floor(this._swipeContainer.scrollY / this.itemHeight()) * -1;
        currentTopRow = Math.max(0, currentTopRow - 1);
        if (currentTopRow !== this._lastTopRow) {
          this._lastTopRow = currentTopRow;
          this.refresh();
        }
        var maskOffsetY = this._lastTopRow * this.itemHeight();
        this.origin.x = 0;
        this.origin.y = -this._swipeContainer.scrollY - maskOffsetY;

        this.processHandling();
        this.processTouch();
        this._stayCount++;
      } else {
        Window_Selectable_update.call(this);
      }
    };

    Window_Selectable.prototype.updateArrows = function () {
      var topRow = this._lastTopRow;
      var maxTopRow = this.maxTopRow();
      this.downArrowVisible = maxTopRow > 0 && topRow < maxTopRow;
      this.upArrowVisible = topRow > 0;
    };

    /*
     * Enable this method by the 1 touch operation (case of release handler)
     */
    //var Window_Selectable_processTouch = Window_Selectable.prototype.processTouch;
    //Window_Selectable.prototype.processTouch = function () {
    //    if (this._swipeable) {
    //        if (this.isOpenAndActive()) {
    //            if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
    //                this._touching = true;
    //                this.onTouch(true);
    //            } else if (TouchInput.isCancelled()) {
    //                if (this.isCancelEnabled()) {
    //                    this.processCancel();
    //                }
    //            } else if (TouchInput.isReleased() && this.isTouchedInsideFrame()) {
    //                this.onRelease();
    //            }
    //            if (this._touching) {
    //                if (TouchInput.isPressed()) {
    //                    this.onTouch(false);
    //                } else {
    //                    this._touching = false;
    //                }
    //            }
    //        } else {
    //            this._touching = false;
    //        }
    //    }
    //    else {
    //        Window_Selectable_processTouch.call(this);
    //    }
    //};

    Window_Selectable.prototype.onRelease = function () {
      var lastIndex = this.index();
      var x = this.canvasToLocalX(TouchInput.x);
      var y = this.canvasToLocalY(TouchInput.y);
      var hitIndex = this.hitTest(x - 0, y - this._swipeContainer.scrollY);
      if (hitIndex >= 0 && !this._swipeContainer.overGap) {
        if (hitIndex === lastIndex) {
          if (this.isTouchOkEnabled()) {
            this.processOk();
          }
        }
      }
    };

    /*
     * Disable the "processOk" by the 1 touch operation (case of release handler)
     */
    var Window_Selectable_onTouch = Window_Selectable.prototype.onTouch;
    Window_Selectable.prototype.onTouch = function (triggered) {
      if (this._swipeable) {
        var lastIndex = this.index();
        var x = this.canvasToLocalX(TouchInput.x);
        var y = this.canvasToLocalY(TouchInput.y);
        var hitIndex = this.hitTest(x - 0, y - this._swipeContainer.scrollY);
        if (hitIndex >= 0) {
          if (hitIndex === this.index()) {
            if (triggered && this.isTouchOkEnabled()) {
              this.processOk();
            }
          } else if (this.isCursorMovable() && triggered) {
            this.select(hitIndex);
          }
        }
        if (this.index() !== lastIndex) {
          SoundManager.playCursor();
        }
      } else {
        Window_Selectable_onTouch.call(this, triggered);
      }
    };

    var Window_Selectable_hitTest = Window_Selectable.prototype.hitTest;
    Window_Selectable.prototype.hitTest = function (x, y) {
      if (this._swipeable) {
        var cx = x - this.padding;
        var cy = y - this.padding;
        var topIndex = this.topIndex();
        for (var i = 0; i < this.maxItems(); i++) {
          var index = topIndex + i;
          var rect = this.itemRect(index + this._lastTopRow * this.maxCols());
          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;
      } else {
        return Window_Selectable_hitTest.call(this, x, y);
      }
    };

    var Window_Selectable_updateCursor =
      Window_Selectable.prototype.updateCursor;
    Window_Selectable.prototype.updateCursor = function () {
      if (this._swipeable) {
        if (this._cursorAll) {
          var allRowsHeight = this.maxRows() * this.itemHeight();
          this.setCursorRect(0, 0, this.contents.width, allRowsHeight);
          this.setTopRow(0);
        } else if (this.isCursorVisible()) {
          var rect = this.itemRect(this.index());
          this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
        } else {
          this.setCursorRect(0, 0, 0, 0);
        }
      } else {
        Window_Selectable_updateCursor.call(this);
      }
    };

    var Window_Selectable_isCursorVisible =
      Window_Selectable.prototype.isCursorVisible;
    Window_Selectable.prototype.isCursorVisible = function () {
      if (this._swipeable) return true;
      else return Window_Selectable_isCursorVisible.call(this);
    };

    var Window_Selectable_drawAllItems =
      Window_Selectable.prototype.drawAllItems;
    Window_Selectable.prototype.drawAllItems = function () {
      var bitmap = this.buttonBase;
      bitmap.clear();

      if (this._swipeable) {
        var topIndex = this._lastTopRow * this.maxCols();
        var maxPageItems = this.maxPageItems() + this.maxCols();
        for (var i = 0; i < maxPageItems; i++) {
          var index = topIndex + i;
          if (index >= 0 && index < this.maxItems()) {
            this.drawItem(index);
            this.drawButtonImage(index);
          }
        }
        var tone = this._colorTone;
        bitmap.adjustTone(tone[0], tone[1], tone[2]);

        this.updateCursor();
      } else {
        Window_Selectable_drawAllItems.call(this);
      }
    };

    Window_Selectable.prototype.drawButtonImage = function (index) {
      var itemRect = this.itemRect(index);
      var x = itemRect.x;
      var y = itemRect.y;
      var w = itemRect.width;
      var h = itemRect.height;
      var m = 5;
      var bitmap = this.buttonBase;
      this.changePaintOpacity(true);

      bitmap.clearRect(x, y, w, h);

      if (w > 0 && h > 0 && this.windowskin) {
        var skin = this.windowskin;

        var p = 96;
        var q = 96;

        bitmap.blt(skin, 0, 0 + 192, m, m, x, y, m, m);
        bitmap.blt(skin, 0, m + 192, m, q - m * 2, x, y + m, m, h - m * 2);
        bitmap.blt(skin, 0, q - m + 192, m, m, x, y + h - m, m, m);

        bitmap.blt(skin, m, 0 + 192, p - m * 2, m, x + m, y, w - m * 2, m);
        bitmap.blt(
          skin,
          m,
          m + 192,
          p - m * 2,
          q - m * 2,
          x + m,
          y + m,
          w - m * 2,
          h - m * 2
        );
        bitmap.blt(
          skin,
          m,
          q - m + 192,
          p - m * 2,
          m,
          x + m,
          y + h - m,
          w - m * 2,
          m
        );

        bitmap.blt(skin, p - m, 0 + 192, m, m, x + w - m, y, m, m);
        bitmap.blt(
          skin,
          p - m,
          m + 192,
          m,
          q - m * 2,
          x + w - m,
          y + m,
          m,
          h - m * 2
        );
        bitmap.blt(skin, p - m, q - m + 192, m, m, x + w - m, y + h - m, m, m);
      }
    };

    /*
     * Expand the contents bitmap
     */
    var _Window_Selectable_contentsWidth =
      Window_Selectable.prototype.contentsWidth;
    Window_Selectable.prototype.contentsWidth = function () {
      var contentsWidth = _Window_Selectable_contentsWidth.call(this);
      if (this._swipeable) contentsWidth += this.itemWidth();
      return contentsWidth;
    };

    var _Window_Selectable_contentsHeight =
      Window_Selectable.prototype.contentsHeight;
    Window_Selectable.prototype.contentsHeight = function () {
      var contentsHeight = _Window_Selectable_contentsHeight.call(this);
      if (this._swipeable) contentsHeight += this.itemHeight();
      return contentsHeight;
    };

    /*
     * Create the button contents
     */
    Window_Selectable.prototype.createContents = function () {
      Window_Base.prototype.createContents.call(this);
      this.buttonBase = new Bitmap(this.contentsWidth(), this.contentsHeight());
    };

    /*
     * Set the swipe container
     */
    Window_Selectable.prototype._createAllParts = function () {
      Window.prototype._createAllParts.call(this);

      this._swipeContainer = new Window_SwipeContainer();
      this._windowButtonSprite = new Sprite();
      this.addChild(this._windowButtonSprite);
      this.addChild(this._windowCursorSprite);
      this.addChild(this._windowContentsSprite);
      this.addChild(this._downArrowSprite);
      this.addChild(this._upArrowSprite);
      this.addChild(this._windowPauseSignSprite);

      if (this._swipeable) {
        this._swipeContainer.addChild(this._windowButtonSprite);
        this._swipeContainer.addChild(this._windowCursorSprite);
        this._swipeContainer.addChild(this._windowContentsSprite);
        this.addChild(this._swipeContainer);
        this.addChild(this._downArrowSprite);
        this.addChild(this._upArrowSprite);
        this.addChild(this._windowPauseSignSprite);
      }
    };

    Window_Selectable.prototype._refreshAllParts = function () {
      Window.prototype._refreshAllParts.call(this);
      this._refreshButtonImage();
      this._refreshSwipeContainer();
      if (!!this.contents) {
        this.contents.resize(this.contentsWidth(), this.contentsHeight());
      }
      if (!!this._windowButtonSprite.bitmap) {
        this._windowButtonSprite.bitmap.resize(
          this.contentsWidth(),
          this.contentsHeight()
        );
      }
    };

    /*
     * Expand bitmap for cursor
     */
    Window_Selectable.prototype._refreshCursor = function () {
      if (this._swipeable) {
        var x = this._cursorRect.x;
        var y = this._cursorRect.y;
        var w = this._cursorRect.width;
        var h = this._cursorRect.height;
        var m = 4;
        var ox = x;
        var oy = y;
        var bitmap = new Bitmap(this.contentsWidth(), this.contentsHeight());

        this._windowCursorSprite.bitmap = bitmap;
        this._windowCursorSprite.setFrame(
          0,
          0,
          this._width - this._padding * 2,
          this._height - this._padding * 2
        );
        this._windowCursorSprite.move(this.padding, this.padding);

        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,
            ox + m,
            oy + m,
            w - m * 2,
            h - m * 2
          );
          bitmap.blt(
            skin,
            p + m,
            p + 0,
            q - m * 2,
            m,
            ox + m,
            oy + 0,
            w - m * 2,
            m
          );
          bitmap.blt(
            skin,
            p + m,
            p + q - m,
            q - m * 2,
            m,
            ox + m,
            oy + h - m,
            w - m * 2,
            m
          );
          bitmap.blt(
            skin,
            p + 0,
            p + m,
            m,
            q - m * 2,
            ox + 0,
            oy + m,
            m,
            h - m * 2
          );
          bitmap.blt(
            skin,
            p + q - m,
            p + m,
            m,
            q - m * 2,
            ox + w - m,
            oy + m,
            m,
            h - m * 2
          );
          bitmap.blt(skin, p + 0, p + 0, m, m, ox + 0, oy + 0, m, m);
          bitmap.blt(skin, p + q - m, p + 0, m, m, ox + w - m, oy + 0, m, m);
          bitmap.blt(skin, p + 0, p + q - m, m, m, ox + 0, oy + h - m, m, m);
          bitmap.blt(
            skin,
            p + q - m,
            p + q - m,
            m,
            m,
            ox + w - m,
            oy + h - m,
            m,
            m
          );
        }
      } else {
        Window.prototype._refreshCursor.call(this);
      }
    };

    Window_Selectable.prototype._refreshButtonImage = function () {
      this._windowButtonSprite.move(this.padding, this.padding);
    };

    Window_Selectable.prototype._refreshSwipeContainer = function () {
      if (this._swipeable) {
        this._swipeContainer.maxWidth = this._width - this.padding * 2;
        this._swipeContainer.maxHeight = this.maxRows() * this.itemHeight();
        this._swipeContainer.contentsWidth = this._width - this._padding * 2;
        this._swipeContainer.contentsHeight = this._height - this._padding * 2;
        this._swipeContainer.overDist = this.itemHeight();
      }
    };

    /*
     * Clipping the button image and the cursor
     */
    Window_Selectable.prototype._updateContents = function () {
      Window.prototype._updateContents.call(this);

      if (this._swipeable) {
        var w = this._width - this._padding * 2;
        var h = this._height - this._padding * 2;
        if (w > 0 && h > 0) {
          this._windowButtonSprite.setFrame(this.origin.x, this.origin.y, w, h);
          this._windowCursorSprite.setFrame(this.origin.x, this.origin.y, w, h);
        }
      }
    };

    var Window_Selectable_ensureCursorVisible =
      Window_Selectable.prototype.ensureCursorVisible;
    Window_Selectable.prototype.ensureCursorVisible = function () {
      if (!this._swipeable) {
        Window_Selectable_ensureCursorVisible.call(this);
      } else if (this._index !== -1) {
        var scrollY = this._swipeContainer.scrollY;
        var scrollTopY = -scrollY;
        var scrollBottomY =
          scrollTopY + this._swipeContainer.contentsHeight - this.itemHeight();
        var row = this.row();
        var itemY = row * this.itemHeight();
        if (scrollTopY <= itemY && itemY <= scrollBottomY) {
        } else {
          if (itemY < scrollTopY) {
            this.setTopRow(row);
          } else if (itemY > scrollBottomY) {
            this.setBottomRow(row);
          }
        }
      }
    };

    Window_Selectable.prototype.callSelectHandler = function () {};

    /*
     * Variable column width
     * Array of ratio in accordance with the number of elements.
     */
    Window_Selectable.prototype.setColumnRatio = function (ratios) {
      var i;
      if (ratios.length !== this._columnRatios.length) {
        this._columnRatios = [];
        for (i = 0; i < ratios.length; i++) {
          this._columnRatios.push(ratios[i]);
        }
      } else {
        for (i = 0; i < this.maxCols(); i++) {
          this._columnRatios[i] = ratios[i];
        }
      }
    };

    var Window_SavefileList_initialize =
      Window_SavefileList.prototype.initialize;
    Window_SavefileList.prototype.initialize = function (x, y, width, height) {
      Window_SavefileList_initialize.call(this, x, y, width, height);
      this._allowCursorBlink = true;
    };

    var Window_SavefileList_updateCursor =
      Window_SavefileList.prototype._updateCursor;
    Window_SavefileList.prototype._updateCursor = function () {
      if (this._allowCursorBlink) Window_SavefileList_updateCursor.call(this);
    };

    Window_Options.prototype.makeCommandList = function () {
      this.addGeneralOptions();
      this.addVolumeOptions();
      this.addCommand(TextManager.cancel, "cancel");
    };

    var Window_Options_drawItem = Window_Options.prototype.drawItem;
    Window_Options.prototype.drawItem = function (index) {
      if (this._list[index].symbol === "cancel") {
        var rect = this.itemRectForText(index);
        var statusWidth = this.statusWidth();
        var titleWidth = rect.width - statusWidth;
        this.resetTextColor();
        this.changePaintOpacity(this.isCommandEnabled(index));
        this.drawText(
          this.commandName(index),
          rect.x,
          rect.y,
          titleWidth,
          "left"
        );
      } else {
        Window_Options_drawItem.call(this, index);
      }
    };

    var Window_Options_processOk = Window_Options.prototype.processOk;
    Window_Options.prototype.processOk = function () {
      Window_Options_processOk.call(this);
      var index = this.index();
      var symbol = this.commandSymbol(index);
      if (symbol === "cancel" && this.isHandled("cancel")) {
        this._handlers["cancel"]();
      }
    };

    Window_EquipItem.prototype.maxCols = function () {
      return 1;
    };

    //Adjust of the position, and omit the display of equipment.
    Window_Status.prototype.refresh = function () {
      this.contents.clear();
      if (this._actor) {
        var lineHeight = this.lineHeight();
        this.drawBlock1(lineHeight * 0);
        this.drawHorzLine(lineHeight * 1);
        this.drawBlock2(lineHeight * 2);
        this.drawHorzLine(lineHeight * 6);
        this.drawBlock3(lineHeight * 7);
        this.drawHorzLine(lineHeight * 10);
        this.drawBlock4(lineHeight * 11);
      }
    };

    Window_Status.prototype.drawBlock3 = function (y) {
      this.drawParameters(48, y);
    };

    Window_Status.prototype.drawParameters = function (x, y) {
      var lineHeight = this.lineHeight();
      for (var i = 0; i < 6; i++) {
        var paramId = i + 2;
        var column = (i / 3) >> 0;
        var row = i % 3;
        var x2 = x + column * 384;
        var y2 = y + lineHeight * row;
        this.changeTextColor(this.systemColor());
        this.drawText(TextManager.param(paramId), x2, y2, 160);
        this.resetTextColor();
        this.drawText(this._actor.param(paramId), x2 + 160, y2, 60, "right");
      }
    };

    var Window_MenuActor_initialize = Window_MenuActor.prototype.initialize;
    Window_MenuActor.prototype.initialize = function (scene) {
      this._scene = scene;
      Window_MenuActor_initialize.call(this);
    };

    //Add reselect all
    Window_MenuActor.prototype.onTouch = function (triggered) {
      Window_Selectable.prototype.onTouch.call(this, triggered);
      var item = this._scene.item();
      if (item) {
        var actor = $gameParty.menuActor();
        var action = new Game_Action(actor);
        action.setItemObject(item);
        if (action.isForAll()) {
          this.setCursorAll(true);
          this.select(0);
        }
      }
    };
    //-----------------------------------------------------------------------------
    // Window_MiniBattleStatus
    //
    // The window for displaying the status of party members on the battle screen.
    // Omit the numerical display

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

    Window_MiniBattleStatus.prototype = Object.create(
      Window_BattleStatus.prototype
    );
    Window_MiniBattleStatus.prototype.constructor = Window_MiniBattleStatus;

    Window_MiniBattleStatus.prototype.initialize = function () {
      Window_BattleStatus.prototype.initialize.call(this);
    };

    Window_MiniBattleStatus.prototype.windowWidth = function () {
      return Graphics.boxWidth - 192 - 192;
    };

    Window_MiniBattleStatus.prototype.lineHeight = function () {
      return 54;
    };

    Window_MiniBattleStatus.prototype.basicAreaRect = function (index) {
      var rect = this.itemRectForText(index);
      return rect;
    };

    Window_MiniBattleStatus.prototype.drawActorHp = function (
      actor,
      x,
      y,
      width
    ) {
      width = width || 186;
      var color1 = this.hpGaugeColor1();
      var color2 = this.hpGaugeColor2();
      this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
    };

    Window_MiniBattleStatus.prototype.drawActorMp = function (
      actor,
      x,
      y,
      width
    ) {
      width = width || 186;
      var color1 = this.mpGaugeColor1();
      var color2 = this.mpGaugeColor2();
      this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
    };

    Window_MiniBattleStatus.prototype.drawActorTp = function (
      actor,
      x,
      y,
      width
    ) {
      width = width || 96;
      var color1 = this.tpGaugeColor1();
      var color2 = this.tpGaugeColor2();
      this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
    };
    Window_PartyCommand.prototype.numVisibleRows = function () {
      return 2;
    };

    Window_ActorCommand.prototype.numVisibleRows = function () {
      return 3;
    };

    //Refresh all parts
    Window_ActorCommand.prototype.setup = function (actor) {
      this._actor = actor;
      this.clearCommandList();
      this.makeCommandList();
      this._refreshAllParts();
      this.refresh();
      this.selectLast();
      this.activate();
      this.open();
    };
    Window_ShopCommand.prototype.maxCols = function () {
      return 2;
    };

    Window_ShopCommand.prototype.makeCommandList = function () {
      this.addCommand(TextManager.buy, "buy");
      this.addCommand(TextManager.sell, "sell", !this._purchaseOnly);
    };

    var Window_ShopNumber_changeNumber =
      Window_ShopNumber.prototype.changeNumber;
    Window_ShopNumber.prototype.changeNumber = function (amount) {
      Window_ShopNumber_changeNumber.call(this, amount);
      if (this.isHandled("change")) {
        this._handlers["change"]();
      }
    };

    var Window_Message_subWindows = Window_Message.prototype.subWindows;
    Window_Message.prototype.subWindows = function () {
      var subWindows = Window_Message_subWindows.call(this);
      subWindows.push(this._cancelWindow);
      return subWindows;
    };

    Window_Message.prototype.createSubWindows = function () {
      this._goldWindow = new Window_ThickGold(0, 0);
      this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
      this._goldWindow.openness = 0;
      this._choiceWindow = new Window_ChoiceList(this);
      this._numberWindow = new Window_NumberInput(this);
      this._itemWindow = new Window_EventItem(this);
      this._cancelWindow = new Window_MessageCancel(this);
    };

    var Window_Message_startInput = Window_Message.prototype.startInput;
    Window_Message.prototype.startInput = function () {
      var result = Window_Message_startInput.call(this);
      this.showCancel();
      return result;
    };

    Window_Message.prototype.showCancel = function () {
      if ($gameMessage.isChoice()) {
        this._cancelWindow.start();
        this.updatePlacementSubWindow();
      } else if ($gameMessage.isItemChoice()) {
        this._cancelWindow.start();
        this.updatePlacementSubWindow();
      }
    };

    Window_Message.prototype.updatePlacementSubWindow = function () {
      this._goldWindow.x = 0;
      this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;

      var h;
      if (this.isAnySubWindowActive()) {
        if (this._positionType > 0) {
          if (this._positionType > 1) {
            h = this._cancelWindow.height;
            this.y -= h;
          }
          if (this._choiceWindow.height > this.y) {
            this._choiceWindow.move(
              this._choiceWindow.x,
              this.y - this._choiceWindow.height,
              this._choiceWindow.width,
              this.y
            );
            this._choiceWindow.refresh();
          }
          if (this._itemWindow.height > this.y) {
            this._itemWindow.move(
              this._itemWindow.x,
              this._itemWindow.y,
              this._itemWindow.width,
              this.y
            );
            this._itemWindow.refresh();
          }
          this._choiceWindow.y = this.y - this._choiceWindow.height;
        } else {
          h = this._cancelWindow.y - this._choiceWindow.y;
          if (this._choiceWindow.height > h) {
            this._choiceWindow.move(
              this._choiceWindow.x,
              this._choiceWindow.y,
              this._choiceWindow.width,
              h
            );
            this._choiceWindow.refresh();
          }
        }
      }
    };

    var Window_Message_terminateMessage =
      Window_Message.prototype.terminateMessage;
    Window_Message.prototype.terminateMessage = function () {
      Window_Message_terminateMessage.call(this);
      this._cancelWindow.close();
    };

    Window_Message.prototype.choiceDeselect = function () {
      this._choiceWindow.deselect();
      this._itemWindow.deselect();
    };

    Window_Message.prototype.cancelDeselect = function () {
      if (this._cancelWindow) {
        this._cancelWindow.deselect();
      }
    };

    var Window_ChoiceList_updatePlacement =
      Window_ChoiceList.prototype.updatePlacement;
    Window_ChoiceList.prototype.updatePlacement = function () {
      Window_ChoiceList_updatePlacement.call(this);
      var messageY = this._messageWindow.y;
      if (messageY > 0) {
        this.y = 0;
      } else {
        this.y = messageY + this._messageWindow.height;
      }
    };

    Window_ChoiceList.prototype.callSelectHandler = function () {
      this._messageWindow.cancelDeselect();
    };

    //Fix Vertical align
    Window_ChoiceList.prototype.processNormalCharacter = function (textState) {
      var c = textState.text[textState.index++];
      var w = this.textWidth(c);
      this.contents.drawText(
        c,
        textState.x,
        textState.y,
        w * 2,
        this.lineHeight()
      );
      textState.x += w;
    };

    var Window_EventItem_updatePlacement =
      Window_EventItem.prototype.updatePlacement;
    Window_EventItem.prototype.updatePlacement = function () {
      Window_EventItem_updatePlacement.call(this);
      var messageY = this._messageWindow.y;
      if (messageY > 0) {
        this.y = 0;
      } else {
        this.y = messageY + this._messageWindow.height;
      }
    };

    Window_EventItem.prototype.callSelectHandler = function () {
      this._messageWindow.cancelDeselect();
    };

    var Window_SkillList_refresh = Window_SkillList.prototype.refresh;
    Window_SkillList.prototype.refresh = function () {
      Window_SkillList_refresh.call(this);
      if (this._swipeable) this._refreshSwipeContainer();
    };

    Window_SkillType.prototype.numVisibleRows = function () {
      return 2;
    };

    var Window_ItemList_refresh = Window_ItemList.prototype.refresh;
    Window_ItemList.prototype.refresh = function () {
      Window_ItemList_refresh.call(this);
      if (this._swipeable) this._refreshSwipeContainer();
    };

    //-----------------------------------------------------------------------------
    // Window_ThickGold
    //
    // The window for displaying the party's gold.

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

    Window_ThickGold.prototype = Object.create(Window_Gold.prototype);
    Window_ThickGold.prototype.constructor = Window_ThickGold;

    Window_ThickGold.prototype.initialize = function (x, y) {
      Window_Gold.prototype.initialize.call(this, x, y);
    };

    Window_ThickGold.prototype.lineHeight = function () {
      return 72;
    };

    Window_TitleCommand.prototype.itemTextAlign = function () {
      return "center";
    };

    var Window_Command_initialize = Window_Command.prototype.initialize;
    Window_Command.prototype.initialize = function (x, y) {
      this._swipeable = true;
      Window_Command_initialize.call(this, x, y);
    };

    var Window_MenuStatus_initialize = Window_MenuStatus.prototype.initialize;
    Window_MenuStatus.prototype.initialize = function (x, y) {
      this._swipeable = true;
      Window_MenuStatus_initialize.call(this, x, y);
    };

    var Window_SavefileList_initialize2 =
      Window_SavefileList.prototype.initialize;
    Window_SavefileList.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_SavefileList_initialize2.call(this, x, y, width, height);
    };

    var Window_ItemList_initialize = Window_ItemList.prototype.initialize;
    Window_ItemList.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_ItemList_initialize.call(this, x, y, width, height);
    };

    var Window_SkillList_initialize = Window_SkillList.prototype.initialize;
    Window_SkillList.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_SkillList_initialize.call(this, x, y, width, height);
    };

    var Window_EquipSlot_initialize = Window_EquipSlot.prototype.initialize;
    Window_EquipSlot.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_EquipSlot_initialize.call(this, x, y, width, height);
    };

    var Window_BattleActor_initialize = Window_BattleActor.prototype.initialize;
    Window_BattleActor.prototype.initialize = function (x, y) {
      this._swipeable = true;
      Window_BattleActor_initialize.call(this, x, y);
    };

    var Window_BattleEnemy_initialize = Window_BattleEnemy.prototype.initialize;
    Window_BattleEnemy.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_BattleEnemy_initialize.call(this, x, y, width, height);
    };

    var Window_ShopBuy_initialize = Window_ShopBuy.prototype.initialize;
    Window_ShopBuy.prototype.initialize = function (x, y, width, height) {
      this._swipeable = true;
      Window_ShopBuy_initialize.call(this, x, y, width, height);
    };

    Window_Command.prototype.lineHeight = function () {
      return 72;
    };

    Window_ItemList.prototype.lineHeight = function () {
      return 72;
    };

    Window_SkillList.prototype.lineHeight = function () {
      return 72;
    };

    Window_EquipSlot.prototype.lineHeight = function () {
      return 72;
    };

    Window_ActorCommand.prototype.lineHeight = function () {
      return 72;
    };

    Window_BattleActor.prototype.lineHeight = function () {
      return 72;
    };

    Window_BattleEnemy.prototype.lineHeight = function () {
      return 72;
    };

    Window_ShopBuy.prototype.lineHeight = function () {
      return 72;
    };
  })();
}


code:
//=============================================================================
// UTA_MessageSkip.js
//=============================================================================
// Version    : 1.00
// LastUpdate : 2016.02.17
// Author     : T.Akatsuki
// Website    : http://utakata-no-yume.net/
// License    : MIT License(http://opensource.org/licenses/mit-license.php)
//=============================================================================

//=============================================================================
/*:
 * @plugindesc Skip message on pressing a particular key.
 * @author T.Akatsuki
 *
 * @param Skip Key
 * @desc Set the message skip key. The value has been defined in the Input.KeyMapper is valid.
 * @default control
 *
 * @param Show Trace
 * @desc Set state traces display.
 * true  : Show trace., false : Don't show trace.
 * @default false
 *
 * @help # Overview
 * MessageSkip plugin can be done to skip in that continue to press a specfic key in a message display.
 * Well there is a message skip functions in such Novel games.
 * Skip if choice window will be temporarily supended.
 *
 * # Parameters
 *   Skip Key [any key]
 *     Set the message skip key.
 *     The value that has been defined in Input.keyMapper is valid.
 *     Initial value is in 'control'.
 *
 *   Show Trace [true|false]
 *     Set whether the issue a trace for debugging.
 *
 * # Plugin Commands
 *   There is no plugin command.
 *
 * # Change Log
 *   ver 1.00 (Feb 17, 2016)
 *     Initial release.
 */

/*:ja
 * @plugindesc 特定キーを押す事でメッセージをスキップできるようにします。
 * @author 赤月 智平
 *
 * @param Skip Key
 * @desc メッセージスキップキーを設定します。Input.keyMapperに定義された値が有効です。
 * @default control
 *
 * @param Show Trace
 * @desc デバッグ用のトレースを出すかを設定します。
 * true: トレースを表示, false: トレースを表示しない
 * @default false
 *
 * @help ■概要
 * MessageSkipプラグインではメッセージ表示中に特定のキーを押し続ける事で
 * スキップ処理を行う事ができます。
 * ADV等で良くあるメッセージスキップの機能です。
 * 選択肢を挟む場合は選択肢が表示されるタイミングでスキップが中断されます。
 *
 * ■パラメータの説明
 *   Skip Key [任意のキー]
 *     メッセージスキップキーを設定します。Input.keyMapperに定義された値が有効です。
 *     初期値はcontrolになっています。他にもshift等が使いやすそうです。
 *
 *   Show Trace [true|false]
 *     デバッグ用のトレースを出すかを設定します。
 *
 * ■プラグインコマンド
 *   プラグインコマンドはありません。
 *
 * ■更新履歴
 *   ver 1.00 (2016.02.17)
 *     初版。
 */
//=============================================================================

//name space
var utakata = utakata || (utakata = {});

(function (utakata) {
  //-----------------------------------------------------------------------------
  // class MessageSkip
  //-----------------------------------------------------------------------------
  var MessageSkip = (function () {
    //constructor
    function MessageSkip() {
      this._skipKey = ""; //bind target key

      //trace
      this._showTrace = false;
      this._tr = null;

      this.initialize();
    }

    //private methods
    MessageSkip.prototype.initialize = function () {
      var parameters = PluginManager.parameters("UTA_MessageSkip");

      this._skipKey = String(parameters["Skip Key"]) || null;

      var _show_tr = String(parameters["Show Trace"]) === "true";
      this._tr = _show_tr
        ? function (s) {
            var str = "MessageSkip: " + s;
            console.log(str);
          }
        : function (s) {};

      this._tr("skip key bind: " + this._skipKey);
    };

    //protected methods
    MessageSkip.prototype.isPressedMsgSkipButton = function () {
      return Input.isPressed(this._skipKey);
    };

    return MessageSkip;
  })();
  utakata.MessageSkip = new MessageSkip();
})(utakata || (utakata = {}));

(function () {
  //-----------------------------------------------------------------------------
  // PluginCommands
  //-----------------------------------------------------------------------------
  var _Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args);

    //UT_MessageSkip don't have plugin commands.
    if (command === "UT_MessageSkip") {
      switch (args[0]) {
        default:
          break;
      }
    }
  };

  //-----------------------------------------------------------------------------
  // Window_Message
  //-----------------------------------------------------------------------------
  //文章表示途中にskipキーが入力された場合は即全表示
  var _Window_Message_updateShowFast = Window_Message.prototype.updateShowFast;
  Window_Message.prototype.updateShowFast = function () {
    _Window_Message_updateShowFast.call(this);

    if (utakata.MessageSkip.isPressedMsgSkipButton()) {
      this._showFast = true;
      this._pauseSkip = true;
    }
  };

  //文章が表示されkey入力待ちの際もskipキーの入力を監視しておく
  var _Window_Message_updateInput = Window_Message.prototype.updateInput;
  Window_Message.prototype.updateInput = function () {
    var ret = _Window_Message_updateInput.call(this);

    if (this.pause && utakata.MessageSkip.isPressedMsgSkipButton()) {
      this.pause = false;
      if (!this._textState) {
        this.terminateMessage();
      }
      return true;
    }

    return ret;
  };

  //-----------------------------------------------------------------------------
  // Window_ScrollText
  //-----------------------------------------------------------------------------
  //スクロールメッセージは更に爆速で流れるように
  var Window_ScrollText_scrollSpeed = Window_ScrollText.prototype.scrollSpeed;
  Window_ScrollText.prototype.scrollSpeed = function () {
    var ret = Window_ScrollText_scrollSpeed.call(this);

    if (utakata.MessageSkip.isPressedMsgSkipButton()) {
      ret *= 100;
    }
    return ret;
  };

  //-----------------------------------------------------------------------------
  // Window_BattleLog
  //-----------------------------------------------------------------------------
  //バトルログを超高速に
  var _Window_BattleLog_messageSpeed = Window_BattleLog.prototype.messageSpeed;
  Window_BattleLog.prototype.messageSpeed = function () {
    var ret = _Window_BattleLog_messageSpeed.call(this);
    if (utakata.MessageSkip.isPressedMsgSkipButton()) {
      ret = 1;
    }
    return ret;
  };
})();

repo_name: dazed/translations

license: unknown


code:
//=============================================================================
// WeaponSkill.js
//=============================================================================

/*:
 * @plugindesc Change skill id of attack for each weapon.
 * @author Sasuke KANNAZUKI
 *
 * @help This plugin does not provide plugin commands.
 *
 * When <skill_id:3> is written in a weapon's note field,
 * skill id # 3 is used for the weapon's attack.
 * If nothing is written, default id(=1) is used.
 *
 * Check Points:
 * - When multiple weapons are equipped, the skill id of the weapon
 *  held in the dominant hand (previously defined) is used.
 * - It is most favorable for "skill type" to be "none"(=0),
 *  otherwise you cannot attack when your skill is blocked.
 *
 * Usage examples of this plugin:
 * - to create all-range weapons
 * - to create dual-attack or triple-attack weapons
 * - If healing skill is set when actor attacks, you can choose a friend to heal.
 * - It is possible to make a weapon that functions similar to a guard command.
 */

/*:ja
 * @plugindesc 武器ごとに通常攻撃のスキルIDを変更します。
 * @author 神無月サスケ
 *
 * @help このプラグインにはプラグインコマンドはありません。
 *
 *  武器の「メモ」欄に、<skill_id:3> と書いた場合、
 * 通常攻撃の際、3番のスキルが発動します。
 * ※特に記述がなければ、通常通り1番のスキルが採用されます。
 *
 * チェックポイント:
 * - 二刀流の場合、利き腕(先に定義された方)に持っているスキルIDが採用されます。
 * - スキルタイプは「なし」にするのが望ましいです。
 * さもなくば、技などを封じられたとき、攻撃が出来なくなります。
 *
 * 想定される用途:
 * - 全体攻撃可能な武器
 * - 2回攻撃、3回攻撃する武器
 * - 回復魔法をスキルに指定した場合、
 * 「攻撃」を選んだ際、味方の選択が出来、その仲間を回復します
 * - 防御コマンドなどと同等になる武器も実現可能です。
 */

(function () {
  //
  // set skill id for attack.
  //
  Game_Actor.prototype.attackSkillId = function () {
    var normalId = Game_BattlerBase.prototype.attackSkillId.call(this);
    if (this.hasNoWeapons()) {
      return normalId;
    }
    var weapon = this.weapons()[0]; // at plural weapon, one's first skill.
    var id = weapon.meta.skill_id;
    return id ? Number(id) : normalId;
  };

  //
  // for command at battle
  //
  var _Scene_Battle_commandAttack = Scene_Battle.prototype.commandAttack;
  Scene_Battle.prototype.commandAttack = function () {
    BattleManager.inputtingAction().setAttack();
    // normal attack weapon (or other single attack weapon)
    var action = BattleManager.inputtingAction();
    if (action.needsSelection() && action.isForOpponent()) {
      _Scene_Battle_commandAttack.call(this);
      return;
    }
    // special skill weapon
    this.onSelectAction();
  };
})();


code:
//=============================================================================
// WindowChange.js
//=============================================================================

/*:
 * @plugindesc Changes the windowskin image in the game.
 * @author Yoji Ojima
 *
 * @help
 *
 * Plugin Command:
 *   WindowChange Window2       # Change windowskin to 'Window2.png'
 */

/*:ja
 * @plugindesc ゲーム内でウィンドウスキンを変更します。
 * @author Yoji Ojima
 *
 * @help
 *
 * プラグインコマンド:
 *   WindowChange Window2       # ウィンドウスキンを「Window2.png」に変更
 */

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

  var _Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args);
    if (command === "WindowChange") {
      var name = String(args[0] || "Window");
      $gameSystem.windowskinName = name;
      ImageManager.loadSystem(name);
      this.setWaitMode("image");
    }
  };

  Window_Base.prototype.loadWindowskin = function () {
    this._windowskinName = $gameSystem.windowskinName || "Window";
    this.windowskin = ImageManager.loadSystem(this._windowskinName);
  };

  var _Window_Base_update = Window_Base.prototype.update;
  Window_Base.prototype.update = function () {
    _Window_Base_update.call(this);
    if ($gameSystem.windowskinName) {
      if (this._windowskinName !== $gameSystem.windowskinName) {
        this.loadWindowskin();
      }
    }
  };
})();


code:
//=============================================================================
// Window Identifier
// by Shaz (based on Ace script by Rhyme)
// Last Updated: 2015.11.18
//=============================================================================

/*:
 * @plugindesc Shows the name of the windows while holding CTRL.
 * @author Shaz, Rhyme
 *
 * @param Font Size
 * @desc Font Size for window names
 * @default 28
 *
 * @param Font Color
 * @desc Color of text for window names (based on windowskin)
 * @default 0
 *
 * @help
 *
 * Hold the CTRL key in a scene to have window names pop up.
 * Remember to disable this on your game's final release!
 *
 */
/*:ja
 * @plugindesc CTRLを押している間、ウィンドウ名を表示させます。
 * @author Shaz, Rhyme
 *
 * @param Font Size
 * @desc ウィンドウ名のフォントサイズを指定します。
 * @default 28
 *
 * @param Font Color
 * @desc ウィンドウ名テキストのカラーを指定します。(ウィンドウスキンに基づく)
 * @default 0
 *
 * @help
 *
 * CTRLキーを押している間、ウィンドウ名がポップアップします。
 * テストプレイや前後のエディットに役立つプラグインです。
 * 特別なコマンドなどは不要で、プラグインをONにするだけで有効になります。
 *
 * ゲームの最終版を配布する前に、消すのを忘れないようにしてくださいね！
 *
 */

(function () {
  var parameters = PluginManager.parameters("WindowIdentifier");
  var fontSize = parseInt(parameters["Font Size"] || 28);
  var fontColor = parseInt(parameters["Font Color"] || 0);

  _Window_Base_createContents = Window_Base.prototype.createContents;
  Window_Base.prototype.createContents = function () {
    _Window_Base_createContents.call(this);
    if (!this._windowName) {
      this._windowName = new Sprite();
      this._windowName.bitmap = new Bitmap(500, this.lineHeight());
      this._windowName.bitmap.fontSize = fontSize;
      this._windowName.bitmap.textColor = fontColor;
      this._windowName.bitmap.drawText(
        this.constructor.toString().match(/function (\w*)/)[1],
        this.standardPadding(),
        this.standardPadding(),
        500,
        0
      );
      this.addChild(this._windowName);
      this._windowName.opacity = 0;
    }
  };

  _Window_Base_update = Window_Base.prototype.update;
  Window_Base.prototype.update = function () {
    _Window_Base_update.call(this);
    if (Input.isPressed("control")) {
      this._windowName.opacity += 16;
    } else {
      this._windowName.opacity -= 16;
    }
  };
})();


code:
/*:
 * Yami Engine Delta - Aura State
 *
 * @plugindesc v1.0.0 This plugin allows user to create an aura where nearby battlers will receive states based on the aura.
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @help
 * States Notetags
 *
 * <Allies State Aura: X>
 * This aura will add state X to all allies.
 *
 * <Enemies State Aura: X>
 * This aura will add state X to all enemies.
 */

/**
 * @namespace AuraState
 * @memberof YED
 */

var YED = YED || {};

// init AuraState module
YED.AuraState = {};

/* globals YED: false */

(function ($AuraState) {
  /**
   * Enum for RegExp, used to notetags
   *
   * @readonly
   * @enum {RegExp}
   * @memberof YED.AuraState
   */
  var Regexp = {
    /**
     * Aura for allies
     */
    ALLIES_AURA: /<Allies State Aura:[ ]*(\d+)>/i,

    /**
     * Aura for enemies
     */
    ENEMIES_AURA: /<Enemies State Aura:[ ]*(\d+)>/i,
  };

  $AuraState.Regexp = Regexp;
})(YED.AuraState);

/* globals YED: false */

(function ($AuraState) {
  /**
   * Shorten Dependencies
   */
  var Regexp = $AuraState.Regexp;

  /**
   * Contains utility tools for module.
   *
   * @namespace Utils
   * @memberof YED.AuraState
   */
  var Utils = {};

  /**
   * Process notetag function.
   * Should be called with DataManager as current object.
   *
   * @function processNotetag
   * @memberof YED.AuraState.Utils
   */
  Utils.processNotetags = function () {
    var group = $dataStates, // shorten group name
      obj,
      notedata,
      line;

    for (var i = 1; i < group.length; i++) {
      obj = group[i];
      notedata = obj.note.split(/[\r\n]+/);

      Utils._processProperties.call(this, obj);
      Utils._processMethods.call(this, obj);

      for (var n = 0; n < notedata.length; n++) {
        line = notedata[n];
        Utils._processNotetag.call(this, obj, line);
      }
    }
  };

  /**
   * Add new properties into object.
   *
   * @function _processProperties
   * @memberof YED.AuraState.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processProperties = function (obj) {
    obj._auraState = {};

    obj._auraState.allies = [];
    obj._auraState.enemies = [];
  };

  /**
   * Add new methods into object.
   *
   * @function _processMethods
   * @memberof YED.AuraState.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processMethods = function (obj) {
    obj.getAuraState = Utils.getAuraState;
    obj.isAuraState = Utils.isAuraState;
  };

  /**
   * Process notetag for object.
   *
   * @function _processNotetag
   * @memberof YED.AuraState.Utils
   * @param  {Object} obj Data object
   * @param  {String} notetag Notetag
   * @private
   */
  Utils._processNotetag = function (obj, notetag) {
    var match;

    match = notetag.match(Regexp.ALLIES_AURA);
    if (match) {
      obj._auraState.allies.push(Number(match[1]));
    }

    match = notetag.match(Regexp.ENEMIES_AURA);
    if (match) {
      obj._auraState.enemies.push(Number(match[1]));
    }
  };

  /**
   * Get aura state infos.
   *
   * @function getAuraState
   * @memberof YED.AuraState.Utils
   * @return {Object}
   */
  Utils.getAuraState = function () {
    return this._auraState;
  };

  /**
   * Get aura state flag.
   *
   * @function isAuraState
   * @memberof YED.AuraState.Utils
   * @return {Boolean}
   */
  Utils.isAuraState = function () {
    return (
      this._auraState.allies.length > 0 || this._auraState.enemies.length > 0
    );
  };

  $AuraState.Utils = Utils;
})(YED.AuraState);

/* globals YED: false */

/**
 * Pre-processes and notetag parsing
 */
(function ($AuraState) {
  /**
   * Shorten Dependencies
   */
  var Utils = $AuraState.Utils;

  /**
   * Aliasing methods
   */
  var _DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;

  /**
   * Extending: DataManager.isDatabaseLoaded
   *
   * Add notetags and parameters processing for module.
   */
  DataManager.isDatabaseLoaded = function () {
    var loaded = _DataManager_isDatabaseLoaded.call(this);

    if (!loaded) {
      return false;
    }

    Utils.processNotetags.call(DataManager);

    return true;
  };
})(YED.AuraState);

(function () {
  /**
   * Aliasing methods
   */
  var _Game_Battler_initMembers = Game_Battler.prototype.initMembers;
  var _Game_Battler_refresh = Game_Battler.prototype.refresh;

  Game_Battler.prototype.initMembers = function () {
    _Game_Battler_initMembers.call(this);

    this._auraStates = [];
  };

  Game_Battler.prototype.auraStates = function () {
    return this._auraStates.map(function (id) {
      return $dataStates[id];
    });
  };

  Game_Battler.prototype.updateAuraState = function () {
    this._updateInactiveAura();
    this._updateActiveAura();
  };

  Game_Battler.prototype._updateInactiveAura = function () {
    var state,
      ids = [],
      index,
      alliesAura,
      enemiesAura,
      i;

    var removeStateParty = function (id) {
      $gameParty.members().forEach(function (actor) {
        actor.removeState(id);
      });
    };

    var removeStateTroop = function (id) {
      $gameTroop.members().forEach(function (enemy) {
        enemy.removeState(id);
      });
    };

    for (i = 0; i < this._auraStates.length; i++) {
      if (this.isStateAffected(this._auraStates[i])) {
        continue;
      }

      state = $dataStates[this._auraStates[i]];

      alliesAura = state.getAuraState().allies;
      enemiesAura = state.getAuraState().enemies;

      alliesAura.forEach(removeStateParty);
      enemiesAura.forEach(removeStateTroop);

      ids.push(this._auraStates[i]);
    }

    for (i = 0; i < ids.length; i++) {
      index = this._auraStates.indexOf(ids[i]);

      if (index > -1) {
        this._auraStates.splice(index, 1);
      }
    }
  };

  Game_Battler.prototype._updateActiveAura = function () {
    var states = this.states(),
      alliesAura,
      enemiesAura,
      state;

    var addStateParty = function (id) {
      $gameParty.members().forEach(function (actor) {
        actor.addState(id);
      });
    };

    var addStateTroop = function (id) {
      $gameTroop.members().forEach(function (enemy) {
        enemy.addState(id);
      });
    };

    for (var i = 0; i < states.length; i++) {
      if (!states[i].isAuraState()) {
        continue;
      }

      if (this._auraStates.indexOf(states[i].id) > -1) {
        continue;
      }

      this._auraStates.push(states[i].id);

      state = states[i];

      alliesAura = state.getAuraState().allies;
      enemiesAura = state.getAuraState().enemies;

      alliesAura.forEach(addStateParty);
      enemiesAura.forEach(addStateTroop);
    }
  };

  Game_Battler.prototype.refresh = function () {
    _Game_Battler_refresh.call(this);

    $gameParty.members().forEach(function (actor) {
      actor.updateAuraState();
    });

    $gameTroop.members().forEach(function (enemy) {
      enemy.updateAuraState();
    });
  };
})();


code:
/*:
 * Yami Engine Delta - Enemy Position
 *
 * @plugindesc v1.0.0 This plugin moves enemy sprites to certain positions or by offsets in battle. Works well for bigger resolution.
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @help
 * Enemy Notetags
 *
 * To move enemy sprite to position X, use this notetag (with N is a number):
 *   <Position X: N>
 *
 * To move enemy sprite to position Y, use this notetag (with N is a number):
 *   <Position Y: N>
 *
 * To move enemy sprite by an offset of X, use this notetag (with N is a number):
 *   <Position Offset X: N>
 *
 * To move enemy sprite by an offset of Y, use this notetag (with N is a number):
 *   <Position Offset Y: N>
 */

/**
 * @namespace EnemyPosition
 * @memberof YED
 */

var YED = YED || {};

// init EnemyPosition module
YED.EnemyPosition = {};

/* globals YED: false */

(function ($EnemyPosition) {
  /**
   * Enum for RegExp, used to notetags
   *
   * @readonly
   * @enum {RegExp}
   * @memberof YED.EnemyPosition
   */
  var Regexp = {
    /**
     * Offset X
     */
    POSITION_X: /<(?:Position X):[ ]*([-]?\d+)>/i,

    /**
     * Offset X
     */
    POSITION_Y: /<(?:Position Y):[ ]*([-]?\d+)>/i,

    /**
     * Offset X
     */
    OFFSET_X: /<(?:Position Offset X):[ ]*([-]?\d+)>/i,

    /**
     * Offset Y
     */
    OFFSET_Y: /<(?:Position Offset Y):[ ]*([-]?\d+)>/i,
  };

  $EnemyPosition.Regexp = Regexp;
})(YED.EnemyPosition);

/* globals YED: false */

(function ($EnemyPosition) {
  /**
   * Shorten Dependencies
   */
  var Regexp = $EnemyPosition.Regexp;

  /**
   * Contains utility tools for module.
   *
   * @namespace Utils
   * @memberof YED.EnemyPosition
   */
  var Utils = {};

  /**
   * Process notetag function.
   * Should be called with DataManager as current object.
   *
   * @function processNotetag
   * @memberof YED.EnemyPosition.Utils
   */
  Utils.processNotetags = function () {
    var group = $dataEnemies, // shorten group name
      obj,
      notedata,
      line;

    for (var i = 1; i < group.length; i++) {
      obj = group[i];
      notedata = obj.note.split(/[\r\n]+/);

      Utils._processProperties.call(this, obj);
      Utils._processMethods.call(this, obj);

      for (var n = 0; n < notedata.length; n++) {
        line = notedata[n];
        Utils._processNotetag.call(this, obj, line);
      }
    }
  };

  /**
   * Add new properties into object.
   *
   * @function _processProperties
   * @memberof YED.EnemyPosition.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processProperties = function (obj) {
    obj._positionX = null;
    obj._positionY = null;

    obj._positionOffsetX = 0;
    obj._positionOffsetY = 0;
  };

  /**
   * Add new methods into object.
   *
   * @function _processMethods
   * @memberof YED.EnemyPosition.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processMethods = function (obj) {
    obj.getPosition = Utils.getPosition;
    obj.getPositionOffsets = Utils.getPositionOffsets;
  };

  /**
   * Process notetag for object.
   *
   * @function _processNotetag
   * @memberof YED.EnemyPosition.Utils
   * @param  {Object} obj Data object
   * @param  {String} notetag Notetag
   * @private
   */
  Utils._processNotetag = function (obj, notetag) {
    var match;

    match = notetag.match(Regexp.POSITION_X);
    if (match) {
      obj._positionX = Number(match[1]);
    }

    match = notetag.match(Regexp.POSITION_Y);
    if (match) {
      obj._positionY = Number(match[1]);
    }

    match = notetag.match(Regexp.OFFSET_X);
    if (match) {
      obj._positionOffsetX = Number(match[1]);
    }

    match = notetag.match(Regexp.OFFSET_Y);
    if (match) {
      obj._positionOffsetY = Number(match[1]);
    }
  };

  /**
   * Get position.
   *
   * @function getPosition
   * @memberof YED.EnemyPosition.Utils
   * @return {Object} {x,y}
   */
  Utils.getPosition = function () {
    var result = {};

    result.x = this._positionX;
    result.y = this._positionY;

    return result;
  };

  /**
   * Get position offsets.
   *
   * @function getPositionOffsets
   * @memberof YED.EnemyPosition.Utils
   * @return {Object} {x,y}
   */
  Utils.getPositionOffsets = function () {
    var result = {};

    result.x = this._positionOffsetX;
    result.y = this._positionOffsetY;

    return result;
  };

  $EnemyPosition.Utils = Utils;
})(YED.EnemyPosition);

/* globals YED: false */

/**
 * Pre-processes and notetag parsing
 */
(function ($EnemyPosition) {
  /**
   * Shorten Dependencies
   */
  var Utils = $EnemyPosition.Utils;

  /**
   * Aliasing methods
   */
  var _DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;

  /**
   * Extending: DataManager.isDatabaseLoaded
   *
   * Add notetags and parameters processing for module.
   */
  DataManager.isDatabaseLoaded = function () {
    var loaded = _DataManager_isDatabaseLoaded.call(this);

    if (!loaded) {
      return false;
    }

    Utils.processNotetags.call(DataManager);

    return true;
  };
})(YED.EnemyPosition);

(function () {
  var _Game_Enemy_screenX = Game_Enemy.prototype.screenX;
  var _Game_Enemy_screenY = Game_Enemy.prototype.screenY;

  Game_Enemy.prototype.screenX = function () {
    var result,
      position = this.enemy().getPosition(),
      offsets = this.enemy().getPositionOffsets();

    result = position.x || _Game_Enemy_screenX.call(this);
    result = result + offsets.x;

    return result;
  };

  Game_Enemy.prototype.screenY = function () {
    var result,
      position = this.enemy().getPosition(),
      offsets = this.enemy().getPositionOffsets();

    result = position.y || _Game_Enemy_screenY.call(this);
    result = result + offsets.y;

    return result;
  };
})();


code:
//=============================================================================
// YED_Eventspassable.js
//=============================================================================

/*:ja
 * @plugindesc イベントもしくはフォロワーが他のイベントにヒットした際に、途中で停止してしまうことを防ぎます。
 */
Game_Event.prototype.isCollidedWithEvents = function (x, y) {
  var events = $gameMap.eventsXyNt(x, y);
  return events.some(function (event) {
    return event._priorityType === this._priorityType;
  });
};