code:
//=============================================================================
// Yanfly Engine Plugins - Gamepad Config
// GamepadConfig.js
// Version: 1.00
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.GamepadConfig = Yanfly.GamepadConfig || {};

//=============================================================================
/*:
 * @plugindesc v1.00 Allows players to adjust their button configuration
 * for gamepads.
 * @author Yanfly Engine Plugins
 *
 * @param Command Name
 * @desc This is the option name that appears in the main menu.
 * @default Gamepad Config
 *
 * @param Button Name
 * @desc This is how a button name will appear in the config menu.
 * @default Button %1
 *
 * @param OK Button
 * @desc This is the command name for the OK button.
 * @default OK / Talk
 *
 * @param OK Help
 * @desc This is the help description for the OK button.
 * @default Used to accept menu actions and talk to people.
 *
 * @param Cancel Button
 * @desc Cancel Button
 * @desc This is the command name for the Cancel button.
 * @default Cancel
 *
 * @param Cancel Help
 * @desc This is the help description for the Cancel button.
 * @default Used to cancel menu actions.
 *
 * @param Shift Button
 * @desc This is the command name for the Shift button.
 * @default Dash
 *
 * @param Shift Help
 * @desc This is the help description for the Shift button.
 * @default Hold this button to dash on the field.
 *
 * @param Menu Button
 * @desc This is the command name for the Menu button.
 * @default Menu
 *
 * @param Menu Help
 * @desc This is the help description for the Menu button.
 * @default Access the Main Menu from the field.
 *
 * @param PageUp Button
 * @desc This is the command name for the Page Up button.
 * @default Page Up
 *
 * @param PageUp Help
 * @desc This is the help description for the Page Up button.
 * @default Use it to quickly scroll up menus.
 *
 * @param PageDown Button
 * @desc This is the command name for the Page Down button.
 * @default Page Down
 *
 * @param PageDown Help
 * @desc This is the help description for the Page Down button.
 * @default Use it to quickly scroll down menus.
 *
 * @param Reset Default
 * @desc This is the command name to reset the config to default.
 * @default Reset to Default
 *
 * @param Reset Help
 * @desc This is the help description for the Reset button.
 * @default Returns your controller to default settings.
 *
 * @param Finish Config
 * @desc This is the command name for the finish button.
 * @default Finish Configuration
 *
 * @param Finish Help
 * @desc This is the help description for the Finish button.
 * @default Are you done configuring your gamepad?
 *
 * @help
 * Adds a "Gamepad Config" option to the Options Menu if a gamepad is detected.
 * Players can then adjust the button configuration to their liking and it will
 * be loaded automatically each time they play the game. Keep in mind that if
 * at any point where a Gamepad is not detected inside of the Option or Gamepad
 * Config menu, the game will automatically eject the player out the prevent
 * the player from being locked inside.
 */

/*:ja
 * @plugindesc ゲームパッド向けにボタンコンフィグを行なうプラグインです。
 * @author Yanfly Engine Plugins
 *
 * @param Command Name
 * @desc メインメニューに表示されるオプション名を変更できます
 * @default Gamepad Config
 *
 * @param Button Name
 * @desc コンフィグメニューでのボタン名の表示方法を変更できます
 * @default Button %1
 *
 * @param OK Button
 * @desc OKボタンに対するコマンド名を変更できます
 * @default OK / Talk
 *
 * @param OK Help
 * @desc OKボタンに対するヘルプを設定できます
 * @default メニューの決定/人に話しかける際に使うボタンです
 *
 * @param Cancel Button
 * @desc キャンセルボタン
 * @desc キャンセルボタンに対するコマンド名を変更できます
 * @default Cancel
 *
 * @param Cancel Help
 * @desc キャンセルボタンに対するヘルプを設定できます
 * @default メニューアクションをキャンセルする際に使うボタンです
 *
 * @param Shift Button
 * @desc シフトボタンに対するコマンド名を変更できます
 * @default ダッシュ
 *
 * @param Shift Help
 * @desc シフトボタンに対するヘルプを設定できます
 * @default 長押しするとフィールド上をダッシュできます
 *
 * @param Menu Button
 * @desc メニューボタンに対するコマンド名を変更できます
 * @default Menu
 *
 * @param Menu Help
 * @desc メニューボタンに対するヘルプを設定できます
 * @default フィールドからメインメニューにアクセスします
 *
 * @param PageUp Button
 * @desc ページアップボタンに対するコマンド名を変更できます
 * @default Page Up
 *
 * @param PageUp Help
 * @desc ページアップボタンに対するヘルプを設定できます
 * @default メニューを素早くスクロールアップできます
 *
 * @param PageDown Button
 * @desc ページダウンボタンに対するコマンド名を変更できます
 * @default Page Down
 *
 * @param PageDown Help
 * @desc ページダウンボタンに対するヘルプを設定できます
 * @default メニューを素早くスクロールダウンできます
 *
 * @param Reset Default
 * @desc コンフィグをリセットする際のコマンド名を変更できます
 * @default Reset to Default
 *
 * @param Reset Help
 * @desc リセットボタンに対するヘルプを設定できます
 * @default コントローラコンフィグをデフォルトに戻します
 *
 * @param Finish Config
 * @desc コンフィグを完了する際のコマンド名を変更できます
 * @default Finish Configuration
 *
 * @param Finish Help
 * @desc 完了ボタンに対するヘルプを設定できます
 * @default ゲームパッドのコンフィグを完了しますか？
 *
 * @help
 * ゲームパッドが使用される場合、
 * "Gamepad Config"をオプションメニューに追加してください。
 * プレイヤーは好みのコンフィグ設定を行うことができ、
 * その設定は毎回プレイ時に自動的にロードされます。
 *
 * ゲームパッドがオプションやゲームパッドコンフィグから検出されなくなると、
 * ゲームは自動的にプレイヤーを排出し、ゲーム内に閉じ込められることを防ぎます。
 *
 */

//=============================================================================

//=============================================================================
// Parameter Variables
//=============================================================================

Yanfly.Parameters = PluginManager.parameters("GamepadConfig");
Yanfly.Param = Yanfly.Param || {};

Yanfly.Param.GamepadConfigName = String(Yanfly.Parameters["Command Name"]);
Yanfly.Param.GamepadConfigButton = String(Yanfly.Parameters["Button Name"]);
Yanfly.Param.GamepadConfigOkTx = String(Yanfly.Parameters["OK Button"]);
Yanfly.Param.GamepadConfigOkHelp = String(Yanfly.Parameters["OK Help"]);
Yanfly.Param.GamepadConfigCancelTx = String(Yanfly.Parameters["Cancel Button"]);
Yanfly.Param.GamepadConfigCancelHelp = String(Yanfly.Parameters["Cancel Help"]);
Yanfly.Param.GamepadConfigShiftTx = String(Yanfly.Parameters["Shift Button"]);
Yanfly.Param.GamepadConfigShiftHelp = String(Yanfly.Parameters["Shift Help"]);
Yanfly.Param.GamepadConfigMenuTx = String(Yanfly.Parameters["Menu Button"]);
Yanfly.Param.GamepadConfigMenuHelp = String(Yanfly.Parameters["Menu Help"]);
Yanfly.Param.GamepadConfigPgUpTx = String(Yanfly.Parameters["PageUp Button"]);
Yanfly.Param.GamepadConfigPgUpHelp = String(Yanfly.Parameters["PageUp Help"]);
Yanfly.Param.GamepadConfigPgDnTx = String(Yanfly.Parameters["PageDown Button"]);
Yanfly.Param.GamepadConfigPgDnHelp = String(Yanfly.Parameters["PageDown Help"]);
Yanfly.Param.GamepadConfigResetTx = String(Yanfly.Parameters["Reset Default"]);
Yanfly.Param.GamepadConfigResetHelp = String(Yanfly.Parameters["Reset Help"]);
Yanfly.Param.GamepadConfigFinishTx = String(Yanfly.Parameters["Finish Config"]);
Yanfly.Param.GamepadConfigFinishHelp = String(Yanfly.Parameters["Finish Help"]);

//=============================================================================
// Input
//=============================================================================

Input.getPressedGamepadButton = function () {
  if (Yanfly.Param.GamepadTimer > 0) {
    Yanfly.Param.GamepadTimer -= 1;
    return -1;
  }
  if (navigator.getGamepads) {
    var gamepads = navigator.getGamepads();
    if (gamepads) {
      for (var i = 0; i < gamepads.length; i++) {
        var gamepad = gamepads[i];
        if (gamepad && gamepad.connected) {
          return this.gamepadButtonId(gamepad);
        }
      }
    }
  }
  return -1;
};

Input.gamepadButtonId = function (gamepad) {
  var buttons = gamepad.buttons;
  for (var i = 0; i < buttons.length; i++) {
    if (buttons[i].pressed) return i;
  }
  return -1;
};

Input.getGamepadButton = function (type) {
  for (var i = 0; i < 12; ++i) {
    if (Input.gamepadMapper[i] === type) return i;
  }
  return null;
};

Input.isControllerConnected = function () {
  if (navigator.getGamepads) {
    var gamepads = navigator.getGamepads();
    if (gamepads) {
      for (var i = 0; i < gamepads.length; i++) {
        var gamepad = gamepads[i];
        if (gamepad && gamepad.connected) return true;
      }
    }
  }
  return false;
};

//=============================================================================
// ConfigManager
//=============================================================================

ConfigManager.gamepadInput = {
  0: "ok",
  1: "cancel",
  2: "shift",
  3: "menu",
  4: "pageup",
  5: "pagedown",
  12: "up",
  13: "down",
  14: "left",
  15: "right",
};

Yanfly.GamepadConfig.ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function () {
  var config = Yanfly.GamepadConfig.ConfigManager_makeData.call(this);
  config.gamepadInput = this.gamepadInput;
  return config;
};

Yanfly.GamepadConfig.ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function (config) {
  Yanfly.GamepadConfig.ConfigManager_applyData.call(this, config);
  this.gamepadInput = this.readGamepadConfig(config, "gamepadInput");
  this.applyGamepadConfig();
};

ConfigManager.applyGamepadConfig = function () {
  Input.gamepadMapper = this.gamepadInput;
  Input.update();
  Input.clear();
};

ConfigManager.readGamepadConfig = function (config, name) {
  var value = config[name];
  if (value !== undefined) {
    return value;
  } else {
    return {
      0: "ok",
      1: "cancel",
      2: "shift",
      3: "menu",
      4: "pageup",
      5: "pagedown",
      12: "up",
      13: "down",
      14: "left",
      15: "right",
    };
  }
};

//=============================================================================
// Window_MenuCommand
//=============================================================================

Yanfly.GamepadConfig.Window_Options_addGeneralOptions =
  Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function () {
  Yanfly.GamepadConfig.Window_Options_addGeneralOptions.call(this);
  this.addGameConfigCommand();
};

Window_Options.prototype.addGameConfigCommand = function () {
  if (Input.isControllerConnected()) {
    this.addCommand(Yanfly.Param.GamepadConfigName, "gamepadConfig", true);
    this._addedController = true;
  }
};

Yanfly.GamepadConfig.Window_Options_update = Window_Options.prototype.update;
Window_Options.prototype.update = function () {
  Yanfly.GamepadConfig.Window_Options_update.call(this);
  if (this._addedController && !Input.isControllerConnected()) {
    this.refresh();
    this.height = this.windowHeight();
    this.updatePlacement();
  }
};

Yanfly.GamepadConfig.Window_Options_drawItem =
  Window_Options.prototype.drawItem;
Window_Options.prototype.drawItem = function (index) {
  if (this.commandSymbol(index) === "gamepadConfig") {
    var rect = this.itemRectForText(index);
    var text = this.commandName(index);
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawText(text, rect.x, rect.y, rect.width, "left");
  } else {
    Yanfly.GamepadConfig.Window_Options_drawItem.call(this, index);
  }
};

Yanfly.GamepadConfig.Window_Options_processOk =
  Window_Options.prototype.processOk;
Window_Options.prototype.processOk = function () {
  if (this.commandSymbol(this.index()) === "gamepadConfig") {
    Window_Command.prototype.processOk.call(this);
  } else {
    Yanfly.GamepadConfig.Window_Options_processOk.call(this);
  }
};

//=============================================================================
// Window_GamepadConfig
//=============================================================================

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

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

Window_GamepadConfig.prototype.initialize = function (helpWindow) {
  var wy = helpWindow.height;
  Window_Command.prototype.initialize.call(this, 0, wy);
  this.setHelpWindow(helpWindow);
  this.height = Graphics.boxHeight - wy;
  this.refresh();
  this.activate();
  this.select(0);
};

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

Window_GamepadConfig.prototype.makeCommandList = function (index) {
  for (var i = 0; i < 6; ++i) {
    var text = this.getButtonTypeText(i);
    this.addCommand(text, "button", true);
  }
  this.addCommand("", "filler", true);
  this.addCommand(this.getButtonTypeText(7), "reset", true);
  this.addCommand(this.getButtonTypeText(8), "finish", true);
};

Window_GamepadConfig.prototype.drawItem = function (index) {
  if (index > 5) {
    Window_Command.prototype.drawItem.call(this, index);
  } else {
    var rect = this.itemRectForText(index);
    var align = this.itemTextAlign();
    var ww = rect.width / 2;
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawText(this.commandName(index), rect.x, rect.y, ww, align);
    var text = this.getButtonConfig(index);
    this.drawText(text, rect.x + ww, rect.y, ww, align);
  }
};

Window_GamepadConfig.prototype.getButtonTypeText = function (index) {
  if (index === 0) return Yanfly.Param.GamepadConfigOkTx;
  if (index === 1) return Yanfly.Param.GamepadConfigCancelTx;
  if (index === 2) return Yanfly.Param.GamepadConfigShiftTx;
  if (index === 3) return Yanfly.Param.GamepadConfigMenuTx;
  if (index === 4) return Yanfly.Param.GamepadConfigPgUpTx;
  if (index === 5) return Yanfly.Param.GamepadConfigPgDnTx;
  if (index === 7) return Yanfly.Param.GamepadConfigResetTx;
  if (index === 8) return Yanfly.Param.GamepadConfigFinishTx;
  return "";
};

Window_GamepadConfig.prototype.getButtonConfig = function (index) {
  if (index > 5) return "";
  var key = this.getButtonKey(index);
  var button = Input.getGamepadButton(key);
  return Yanfly.Param.GamepadConfigButton.format(button);
};

Window_GamepadConfig.prototype.getButtonKey = function (index) {
  if (index === 0) return "ok";
  if (index === 1) return "cancel";
  if (index === 2) return "shift";
  if (index === 3) return "menu";
  if (index === 4) return "pageup";
  if (index === 5) return "pagedown";
};

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

Window_GamepadConfig.prototype.clearButtonConfig = function (index) {
  var rect = this.itemRectForText(index);
  rect.x += rect.width / 2;
  rect.width /= 2;
  this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
};

Window_GamepadConfig.prototype.updateHelp = function () {
  if (!this._helpWindow) return;
  switch (this.index()) {
    case 0:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigOkHelp);
      break;
    case 1:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigCancelHelp);
      break;
    case 2:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigShiftHelp);
      break;
    case 3:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigMenuHelp);
      break;
    case 4:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigPgUpHelp);
      break;
    case 5:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigPgDnHelp);
      break;
    case 7:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigResetHelp);
      break;
    case 8:
      this._helpWindow.setText(Yanfly.Param.GamepadConfigFinishHelp);
      break;
    default:
      this._helpWindow.clear();
      break;
  }
};

//=============================================================================
// Scene_Options
//=============================================================================

Yanfly.GamepadConfig.Scene_Options_createOptionsWindow =
  Scene_Options.prototype.createOptionsWindow;
Scene_Options.prototype.createOptionsWindow = function () {
  Yanfly.GamepadConfig.Scene_Options_createOptionsWindow.call(this);
  this._optionsWindow.setHandler(
    "gamepadConfig",
    this.commandGamepadConfig.bind(this)
  );
};

Scene_Options.prototype.commandGamepadConfig = function () {
  SceneManager.push(Scene_GamepadConfig);
};

//=============================================================================
// Scene_GamepadConfig
//=============================================================================

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

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

Scene_GamepadConfig.prototype.initialize = function () {
  Scene_MenuBase.prototype.initialize.call(this);
};

Scene_GamepadConfig.prototype.create = function () {
  Scene_MenuBase.prototype.create.call(this);
  this.createHelpWindow();
  this.createGamepadConfigWindow();
};

Scene_GamepadConfig.prototype.terminate = function () {
  Scene_MenuBase.prototype.terminate.call(this);
  ConfigManager.save();
};

Scene_GamepadConfig.prototype.update = function () {
  Scene_MenuBase.prototype.update.call(this);
  this.updateAttachedController();
  this.updateButtonConfig();
  this.updateAfterConfig();
};

Scene_GamepadConfig.prototype.updateAttachedController = function () {
  if (Input.isControllerConnected()) return;
  this.popScene();
};

Scene_GamepadConfig.prototype.createGamepadConfigWindow = function () {
  this._configWindow = new Window_GamepadConfig(this._helpWindow);
  this._configWindow.setHandler("button", this.commandButton.bind(this));
  this._configWindow.setHandler("reset", this.commandReset.bind(this));
  this._configWindow.setHandler("finish", this.popScene.bind(this));
  this.addWindow(this._configWindow);
};

Scene_GamepadConfig.prototype.commandButton = function () {
  var index = this._configWindow.index();
  this._configWindow.clearButtonConfig(index);
  this._configEnabled = true;
  Yanfly.Param.GamepadTimer = 12;
};

Scene_GamepadConfig.prototype.commandReset = function () {
  ConfigManager.gamepadInput = {
    0: "ok",
    1: "cancel",
    2: "shift",
    3: "menu",
    4: "pageup",
    5: "pagedown",
    12: "up",
    13: "down",
    14: "left",
    15: "right",
  };
  ConfigManager.applyGamepadConfig();
  this.refreshWindows();
};

Scene_GamepadConfig.prototype.refreshWindows = function () {
  this._configWindow.refresh();
  this._configWindow.activate();
  ConfigManager.save();
};

Scene_GamepadConfig.prototype.updateButtonConfig = function () {
  if (!this._configEnabled) return;
  var buttonId = Input.getPressedGamepadButton();
  if (buttonId > 11) return;
  if (buttonId >= 0) this.applyButtonConfig(buttonId);
};

Scene_GamepadConfig.prototype.applyButtonConfig = function (buttonId) {
  this._configEnabled = false;
  var index = this._configWindow.index();
  var newConfig = this._configWindow.getButtonKey(index);
  var formerConfig = Input.gamepadMapper[buttonId];
  var formerButton = Input.getGamepadButton(newConfig);
  ConfigManager.gamepadInput[buttonId] = newConfig;
  ConfigManager.gamepadInput[formerButton] = formerConfig;
  ConfigManager.applyGamepadConfig();
  this._configTimer = 12;
};

Scene_GamepadConfig.prototype.updateAfterConfig = function () {
  if (!this._configTimer) return;
  if (--this._configTimer > 0) return;
  SoundManager.playEquip();
  this.refreshWindows();
};

//=============================================================================
// End of File
//=============================================================================


code:
//=============================================================================
// Yanfly Engine Plugins - Template
// KeyboardConfig.js
// Version: 1.00
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.KeyConfig = Yanfly.KeyboardConfig || {};

//=============================================================================
/*:
 * @plugindesc v1.00 Allows players to adjust their button configuration
 * for keyboards.
 * @author Yanfly Engine Plugins
 *
 * @param Command Name
 * @desc This is the option name that appears in the main menu.
 * @default Keyboard Config
 *
 * @param Key Help
 * @desc This is the help message that will display for keys.
 * @default Change the configuration of this key?
 *
 * @param Default Layout
 * @desc This is the text for switching to the default layout.
 * @default Default Keyboard Layout
 *
 * @param Default Help
 * @desc This is the help message that will display for keys.
 * @default Reverts your keyboard setting to the default setup.
 *
 * @param WASD Layout
 * @desc This is the text for switching to the WASD layout.
 * @default WASD Movement Layout
 *
 * @param WASD Help
 * @desc This is the help message that will display for WASD.
 * @default Changes your keyboard to WASD movement.
 *
 * @param Finish Config
 * @desc This is the text for finishing with keyboard configuration.
 * @default Finish Configuration
 *
 * @param Finish Help
 * @desc This is the help message that will display for Finish.
 * @default Are you done configuring your keyboard?
 *
 * @param Assigned Color
 * @desc This is the background color of a key that's assigned.
 * @default 21
 *
 * @param Action Color
 * @desc This is the text color of an assigned action.
 * @default 4
 *
 * @param Clear Text
 * @desc This is the Clear action will appear for the config text.
 * @default Clear
 *
 * @param OK Key
 * @desc This is the OK action will appear on a key.
 * @default OK
 *
 * @param OK Text
 * @desc This is the OK action will appear for the config text.
 * @default OK / Talk
 *
 * @param Escape Key
 * @desc This is the Escape action will appear on a key.
 * @default X
 *
 * @param Escape Text
 * @desc This is the Escape action will appear for the config text.
 * @default Cancel / Menu
 *
 * @param Cancel Key
 * @desc This is the Cancel action will appear on a key.
 * @default Cancel
 *
 * @param Cancel Text
 * @desc This is the Cancel action will appear for the config text.
 * @default Cancel
 *
 * @param Menu Key
 * @desc This is the Menu action will appear on a key.
 * @default Menu
 *
 * @param Menu Text
 * @desc This is the Menu action will appear for the config text.
 * @default Menu
 *
 * @param Shift Key
 * @desc This is the Shift action will appear on a key.
 * @default Dash
 *
 * @param Shift Text
 * @desc This is the Shift action will appear for the config text.
 * @default Dash
 *
 * @param PageUp Key
 * @desc This is the PageUp action will appear on a key.
 * @default PgUp
 *
 * @param PageUp Text
 * @desc This is the PageUp action will appear for the config text.
 * @default Page Up
 *
 * @param PageDown Key
 * @desc This is the PageUp action will appear on a key.
 * @default PgDn
 *
 * @param PageDown Text
 * @desc This is the PageUp action will appear for the config text.
 * @default Page Down
 *
 * @param Left Key
 * @desc This is the Left action will appear on a key.
 * @default ◄
 *
 * @param Left Text
 * @desc This is the Left action will appear for the config text.
 * @default Move ◄ Left
 *
 * @param Up Key
 * @desc This is the Up action will appear on a key.
 * @default ▲
 *
 * @param Up Text
 * @desc This is the Up action will appear for the config text.
 * @default Move ▲ Up
 *
 * @param Right Key
 * @desc This is the Right action will appear on a key.
 * @default ►
 *
 * @param Right Text
 * @desc This is the Right action will appear for the config text.
 * @default Move ► Right
 *
 * @param Down Key
 * @desc This is the Down action will appear on a key.
 * @default ▼
 *
 * @param Down Text
 * @desc This is the Down action will appear for the config text.
 * @default Move ▼ Down*
 *
 * @help
 * This plugin allows players to change their keyboard configuration from the
 * in-game Options menu provided that they're using a computer to play the
 * game and not from a mobile device. The "Keyboard Config" option will send
 * the player to a different screen where they can assign actions to each of
 * the allowed keys on the keyboard.
 *
 * Certain measures are made to prevent the player from locking himself or
 * herself in the configuration screen. These measures are that the Enter keys
 * and arrow keys cannot be changed. Almost every other key is capable of being
 * changed to something of the player's liking.
 */

/*:ja
 * @plugindesc キーボード向けにボタンコンフィグを行なうプラグインです。
 * @author Yanfly Engine Plugins
 *
 * @param Command Name
 * @desc メインメニューに表示されるオプション名を変更できます
 * @default Keyboard Config
 *
 * @param Key Help
 * @desc キー設定時に表示される補助メッセージです
 * @default このキーのコンフィグを変更しますか？
 *
 * @param Default Layout
 * @desc デフォルトのレイアウトに変更する際のテキストメッセージです.
 * @default デフォルトレイアウト
 *
 * @param Default Help
 * @desc デフォルト設定に対するヘルプメッセージを設定できます
 * @default キーボード設定をデフォルトに戻します
 *
 * @param WASD Layout
 * @desc WASDのレイアウトに切り替える際のテキストを設定します
 * @default WASDレイアウト
 *
 * @param WASD Help
 * @desc WADSD設定に対するヘルプメッセージを設定できます
 * @default キーボードをWASDレイアウトに変更します
 *
 * @param Finish Config
 * @desc キーボードコンフィグを完了する際のコマンド名を変更できます
 * @default Finish Configuration
 *
 * @param Finish Help
 * @desc 完了時のヘルプを設定できます
 * @default キーボードのコンフィグを完了しますか？
 *
 * @param Assigned Color
 * @desc アサインされたキーの背景色を設定できます
 * @default 21
 *
 * @param Action Color
 * @desc アサインされたアクションのテキストカラーを設定できます
 * @default 4
 *
 * @param Clear Text
 * @desc コンフィグテキストに表れるClearの説明文を変更できます
 * @default Clear
 *
 * @param OK Key
 * @desc キー上に表れるOKアクションの表記を変更できます
 * @default OK
 *
 * @param OK Text
 * @desc コンフィグテキストに表れるOKの説明文を変更できます
 * @default OK / 話す
 *
 * @param Escape Key
 * @desc キー上に表れるEscapeアクションの表記を変更できます
 * @default X
 *
 * @param Escape Text
 * @desc コンフィグテキストに表れるEscapeの説明文を変更できます
 * @default Cancel / Menu
 *
 * @param Cancel Key
 * @desc キー上に表れるキャンセルアクションの表記を変更できます
 * @default Cancel
 *
 * @param Cancel Text
 * @desc コンフィグテキストに表れるキャンセルの説明文を変更できます
 * @default キャンセル
 *
 * @param Menu Key
 * @desc キー上に表れるメニューアクションの表記を変更できます
 * @default Menu
 *
 * @param Menu Text
 * @desc コンフィグテキストに表れるメニューの説明文を変更できます
 * @default Menu
 *
 * @param Shift Key
 * @desc キー上に表れるShiftアクションの表記を変更できます
 * @default Dash
 *
 * @param Shift Text
 * @desc コンフィグテキストに表れるShiftの説明文を変更できます
 * @default ダッシュする
 *
 * @param PageUp Key
 * @desc キー上に表れるPageUpアクションの表記を変更できます
 * @default PgUp
 *
 * @param PageUp Text
 * @desc コンフィグテキストに表れるPageUpの説明文を変更できます
 * @default ページアップ
 *
 * @param PageDown Key
 * @desc キー上に表れるPageDownアクションの表記を変更できます
 * @default PgDn
 *
 * @param PageDown Text
 * @desc コンフィグテキストに表れるPageDownの説明文を変更できます
 * @default ページダウン
 *
 * @param Left Key
 * @desc キー上に表れるレフトキーアクションの表記を変更できます
 * @default ◄
 *
 * @param Left Text
 * @desc コンフィグテキストに表れるレフトキーの説明文を変更できます
 * @default 左へ ◄
 *
 * @param Up Key
 * @desc キー上に表れるアップキーアクションの表記を変更できます
 * @default ▲
 *
 * @param Up Text
 * @desc コンフィグテキストに表れるアップキーの説明文を変更できます
 * @default 上へ ▲
 *
 * @param Right Key
 * @desc キー上に表れるライトキーアクションの表記を変更できます
 * @default ►
 *
 * @param Right Text
 * @desc コンフィグテキストに表れるライトキーの説明文を変更できます
 * @default 右へ ►
 *
 * @param Down Key
 * @desc キー上に表れるダウンキーアクションの表記を変更できます
 * @default ▼
 *
 * @param Down Text
 * @desc コンフィグテキストに表れるダウンキーの説明文を変更できます
 * @default 下へ ▼
 *
 * @help
 * このプラグインを用いて、ゲーム内オプションから
 * キーボードコンフィグを変更することができます。（PCのみ有効）
 * プレイヤーは、ゲームとは別のスクリーンにて
 * キーボードにアクションをアサインすることができます。
 *
 * プレイヤーがコンフィグスクリーンに閉じ込められてしまうことが無いように、
 * エンターキーと矢印キーは変更できないようになっています。
 * それ以外の殆どのキーは、プレイヤーの好きなように変更することができます。
 *
 */

//=============================================================================

//=============================================================================
// Parameter Variables
//=============================================================================

Yanfly.Parameters = PluginManager.parameters("KeyboardConfig");
Yanfly.Param = Yanfly.Param || {};

Yanfly.Param.KeyConfigName = String(Yanfly.Parameters["Command Name"]);
Yanfly.Param.KeyConfigKeyHelp = String(Yanfly.Parameters["Key Help"]);
Yanfly.Param.KeyConfigDefaultTx = String(Yanfly.Parameters["Default Layout"]);
Yanfly.Param.KeyConfigDefaultHelp = String(Yanfly.Parameters["Default Help"]);
Yanfly.Param.KeyConfigWasdTx = String(Yanfly.Parameters["WASD Layout"]);
Yanfly.Param.KeyConfigWasdHelp = String(Yanfly.Parameters["WASD Help"]);
Yanfly.Param.KeyConfigFinishTx = String(Yanfly.Parameters["Finish Config"]);
Yanfly.Param.KeyConfigFinishHelp = String(Yanfly.Parameters["Finish Help"]);
Yanfly.Param.KeyConfigAssignColor = Number(Yanfly.Parameters["Assigned Color"]);
Yanfly.Param.KeyConfigActionColor = Number(Yanfly.Parameters["Action Color"]);
Yanfly.Param.KeyConfigClearTx = String(Yanfly.Parameters["Clear Text"]);
Yanfly.Param.KeyConfigOkKey = String(Yanfly.Parameters["OK Key"]);
Yanfly.Param.KeyConfigOkTx = String(Yanfly.Parameters["OK Text"]);
Yanfly.Param.KeyConfigEscKey = String(Yanfly.Parameters["Escape Key"]);
Yanfly.Param.KeyConfigEscTx = String(Yanfly.Parameters["Escape Text"]);
Yanfly.Param.KeyConfigCancelKey = String(Yanfly.Parameters["Cancel Key"]);
Yanfly.Param.KeyConfigCancelTx = String(Yanfly.Parameters["Cancel Text"]);
Yanfly.Param.KeyConfigMenuKey = String(Yanfly.Parameters["Menu Key"]);
Yanfly.Param.KeyConfigMenuTx = String(Yanfly.Parameters["Menu Text"]);
Yanfly.Param.KeyConfigShiftKey = String(Yanfly.Parameters["Shift Key"]);
Yanfly.Param.KeyConfigShiftTx = String(Yanfly.Parameters["Shift Text"]);
Yanfly.Param.KeyConfigPageUpKey = String(Yanfly.Parameters["PageUp Key"]);
Yanfly.Param.KeyConfigPageUpTx = String(Yanfly.Parameters["PageUp Text"]);
Yanfly.Param.KeyConfigPageDnKey = String(Yanfly.Parameters["PageDown Key"]);
Yanfly.Param.KeyConfigPageDnTx = String(Yanfly.Parameters["PageDown Text"]);
Yanfly.Param.KeyConfigLeftKey = String(Yanfly.Parameters["Left Key"]);
Yanfly.Param.KeyConfigLeftTx = String(Yanfly.Parameters["Left Text"]);
Yanfly.Param.KeyConfigUpKey = String(Yanfly.Parameters["Up Key"]);
Yanfly.Param.KeyConfigUpTx = String(Yanfly.Parameters["Up Text"]);
Yanfly.Param.KeyConfigRightKey = String(Yanfly.Parameters["Right Key"]);
Yanfly.Param.KeyConfigRightTx = String(Yanfly.Parameters["Right Text"]);
Yanfly.Param.KeyConfigDownKey = String(Yanfly.Parameters["Down Key"]);
Yanfly.Param.KeyConfigDownTx = String(Yanfly.Parameters["Down Text"]);

//=============================================================================
// ConfigManager
//=============================================================================

ConfigManager.keyMapper = {
  9: "tab",
  13: "ok",
  16: "shift",
  17: "control",
  18: "control",
  27: "escape",
  32: "ok",
  33: "pageup",
  34: "pagedown",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  45: "escape",
  81: "pageup",
  87: "pagedown",
  88: "escape",
  90: "ok",
  96: "escape",
  98: "down",
  100: "left",
  102: "right",
  104: "up",
  120: "debug",
};

Yanfly.KeyConfig.ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function () {
  var config = Yanfly.KeyConfig.ConfigManager_makeData.call(this);
  config.keyMapper = this.keyMapper;
  return config;
};

Yanfly.KeyConfig.ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function (config) {
  Yanfly.KeyConfig.ConfigManager_applyData.call(this, config);
  this.keyMapper = this.readKeyConfig(config, "keyMapper");
  this.applyKeyConfig();
};

ConfigManager.applyKeyConfig = function () {
  Input.keyMapper = this.keyMapper;
  Input.update();
  Input.clear();
};

ConfigManager.readKeyConfig = function (config, name) {
  var value = config[name];
  if (value !== undefined) {
    return value;
  } else {
    return {
      9: "tab",
      13: "ok",
      16: "shift",
      17: "control",
      18: "control",
      27: "escape",
      32: "ok",
      33: "pageup",
      34: "pagedown",
      37: "left",
      38: "up",
      39: "right",
      40: "down",
      45: "escape",
      46: "ok",
      35: "escape",
      36: "menu",
      81: "pageup",
      87: "pagedown",
      88: "escape",
      90: "ok",
      96: "escape",
      98: "down",
      100: "left",
      102: "right",
      104: "up",
      120: "debug",
    };
  }
};

//=============================================================================
// Window_Options
//=============================================================================

Yanfly.KeyConfig.Window_Options_addGeneralOptions =
  Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function () {
  Yanfly.KeyConfig.Window_Options_addGeneralOptions.call(this);
  this.addKeyConfigCommand();
};

Window_Options.prototype.addKeyConfigCommand = function () {
  if (Utils.isMobileDevice()) return;
  this.addCommand(Yanfly.Param.KeyConfigName, "keyConfig", true);
};

Yanfly.KeyConfig.Window_Options_drawItem = Window_Options.prototype.drawItem;
Window_Options.prototype.drawItem = function (index) {
  if (this.commandSymbol(index) === "keyConfig") {
    var rect = this.itemRectForText(index);
    var text = this.commandName(index);
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawText(text, rect.x, rect.y, rect.width, "left");
  } else {
    Yanfly.KeyConfig.Window_Options_drawItem.call(this, index);
  }
};

Yanfly.KeyConfig.Window_Options_processOk = Window_Options.prototype.processOk;
Window_Options.prototype.processOk = function () {
  if (this.commandSymbol(this.index()) === "keyConfig") {
    Window_Command.prototype.processOk.call(this);
  } else {
    Yanfly.KeyConfig.Window_Options_processOk.call(this);
  }
};

//=============================================================================
// Window_KeyConfig
//=============================================================================

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

Window_KeyConfig._keyLayout = [
  "~",
  "1",
  "2",
  "3",
  "4",
  "5",
  "6",
  "7",
  "8",
  "9",
  "0",
  "-",
  "=",
  " ",
  "Ins",
  "Home",
  "PgUp",
  " ",
  "#pD/",
  "*",
  "#pD-",
  " ",
  "Q",
  "W",
  "E",
  "R",
  "T",
  "Y",
  "U",
  "I",
  "O",
  "P",
  "[",
  "]",
  "\\",
  "Del",
  "End",
  "PgDn",
  "#pD7",
  "#pD8",
  "#pD9",
  "+",
  " ",
  "A",
  "S",
  "D",
  "F",
  "G",
  "H",
  "J",
  "K",
  "L",
  ";",
  "'",
  "Enter",
  "Enter",
  " ",
  " ",
  " ",
  "#pD4",
  "#pD5",
  "#pD6",
  "+",
  "Shift",
  "Shift",
  "Z",
  "X",
  "C",
  "V",
  "B",
  "N",
  "M",
  ",",
  ".",
  "/",
  "Shift",
  "Shift",
  " ",
  "↑",
  " ",
  "#pD1",
  "#pD2",
  "#pD3",
  "En",
  " ",
  " ",
  " ",
  "Space",
  "Space",
  "Space",
  "Space",
  "Space",
  "Space",
  "Space",
  " ",
  " ",
  " ",
  " ",
  "←",
  "↓",
  "→",
  "#pD0",
  "#pD0",
  "#pD.",
  "En",
];

Window_KeyConfig._refId = {
  "~": 192,
  0: 48,
  1: 49,
  2: 50,
  3: 51,
  4: 52,
  5: 53,
  6: 54,
  7: 55,
  8: 56,
  9: 57,
  "-": 189,
  "=": 187,
  Ins: 45,
  Home: 36,
  PgUp: 33,
  "#pD/": 111,
  "*": 106,
  "#pD-": 109,
  Q: 81,
  W: 87,
  E: 69,
  R: 82,
  T: 84,
  Y: 89,
  U: 85,
  I: 73,
  O: 79,
  P: 80,
  "[": 219,
  "]": 221,
  "\\": 220,
  Del: 46,
  End: 35,
  PgDn: 34,
  "#pD7": 103,
  "#pD8": 104,
  "#pD9": 105,
  "+": 107,
  A: 65,
  S: 83,
  D: 68,
  F: 70,
  G: 71,
  H: 72,
  J: 74,
  K: 75,
  L: 76,
  ";": 186,
  "'": 222,
  Enter: 13,
  "#pD4": 100,
  "#pD5": 101,
  "#pD6": 102,
  Shift: 16,
  Z: 90,
  X: 88,
  C: 67,
  V: 86,
  B: 66,
  N: 78,
  M: 77,
  ",": 188,
  ".": 190,
  "/": 191,
  Shift: 16,
  "↑": 38,
  "#pD1": 97,
  "#pD2": 98,
  "#pD3": 99,
  En: 13,
  Space: 32,
  "←": 37,
  "↓": 40,
  "→": 39,
  "#pD0": 96,
  "#pD.": 110,
};

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

Window_KeyConfig.prototype.initialize = function (helpWindow) {
  var wy = helpWindow.height;
  Window_Command.prototype.initialize.call(this, 0, wy);
  this.setHelpWindow(helpWindow);
  this.height = Graphics.boxHeight - wy;
  this.refresh();
  this.activate();
  this.select(0);
};

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

Window_KeyConfig.prototype.maxCols = function () {
  return 21;
};

Window_KeyConfig.prototype.spacing = function () {
  return 1;
};

Window_KeyConfig.prototype.itemHeight = function () {
  return this.lineHeight() * 2;
};

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

Window_KeyConfig.prototype.makeCommandList = function (index) {
  for (var i = 0; i < Window_KeyConfig._keyLayout.length; ++i) {
    var keyName = Window_KeyConfig._keyLayout[i];
    var enabled = this.isKeyEnabled(keyName);
    this.addCommand(keyName, "key", enabled);
  }
  this.addCommand(Yanfly.Param.KeyConfigDefaultTx, "default", true);
  for (var i = 0; i < 6; ++i) this.addCommand(" ", "default", true);
  this.addCommand(Yanfly.Param.KeyConfigWasdTx, "wasd", true);
  for (var i = 0; i < 6; ++i) this.addCommand(" ", "wasd", true);
  this.addCommand(Yanfly.Param.KeyConfigFinishTx, "cancel", true);
  for (var i = 0; i < 6; ++i) this.addCommand(" ", "cancel", true);
};

Window_KeyConfig.prototype.isKeyEnabled = function (keyName) {
  return ![" ", "Enter", "En", "↑", "←", "↓", "→"].contains(keyName);
};

Window_KeyConfig.prototype.itemRect = function (index) {
  var rect = Window_Selectable.prototype.itemRect.call(this, index);
  var maxCols = this.maxCols();
  if ([41, 62].contains(index)) {
    rect.y = Math.floor(41 / maxCols) * rect.height - this._scrollY;
    rect.height = this.itemHeight() * 2;
  } else if ([54, 55].contains(index)) {
    rect.x = (54 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing();
  } else if ([63, 64].contains(index)) {
    rect.x = (63 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing();
  } else if ([75, 76].contains(index)) {
    rect.x = (75 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing();
  } else if ([83, 104].contains(index)) {
    rect.y = Math.floor(83 / maxCols) * rect.height - this._scrollY;
    rect.height = this.itemHeight() * 2;
  } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) {
    rect.x = (87 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing();
  } else if ([101, 102].contains(index)) {
    rect.x = (101 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing();
  } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) {
    rect.x = (105 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing();
  } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) {
    rect.x = (112 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing();
  } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) {
    rect.x = (119 % maxCols) * (rect.width + this.spacing()) - this._scrollX;
    rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing();
  }
  rect.y += Math.max(0, (this.contents.height - this.lineHeight() * 12) / 2);
  return rect;
};

Window_KeyConfig.prototype.leaveEmpty = function (index) {
  return [
    55, 56, 57, 58, 62, 64, 76, 77, 79, 84, 85, 86, 88, 89, 90, 91, 92, 93, 94,
    95, 96, 97, 102, 104, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117,
    118, 120, 121, 122, 123, 124, 125,
  ].contains(index);
};

Window_KeyConfig.prototype.drawItem = function (index) {
  if (this.leaveEmpty(index)) return;
  this.drawItemRect(index);
  this.drawItemKey(index);
  this.drawItemAction(index);
};

Window_KeyConfig.prototype.drawItemRect = function (index) {
  var rect = this.itemRect(index);
  var color = this.getRectColor(index);
  this.drawRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2, color);
};

Window_KeyConfig.prototype.getRectColor = function (index) {
  if (index > 104) return this.gaugeBackColor();
  var key = Window_KeyConfig._refId[this.commandName(index)];
  var action = Input.keyMapper[key];
  if (action !== undefined) {
    return this.textColor(Yanfly.Param.KeyConfigAssignColor);
  } else {
    return this.gaugeBackColor();
  }
};

Window_KeyConfig.prototype.drawRect = function (dx, dy, dw, dh, color) {
  this.changePaintOpacity(false);
  this.contents.fillRect(dx, dy, dw, dh, color);
  this.changePaintOpacity(true);
};

Window_KeyConfig.prototype.drawItemKey = function (index) {
  this.resetFontSettings();
  this.contents.fontSize -= 8;
  this.resetTextColor();
  this.changePaintOpacity(true);
  var rect = this.itemRectForText(index);
  var align = this.itemTextAlign();
  this.drawText(this.visualName(index), rect.x, rect.y, rect.width, align);
};

Window_KeyConfig.prototype.visualName = function (index) {
  var text = this._list[index].name;
  text = text.replace(/#pD/gi, "");
  return text;
};

Window_KeyConfig.prototype.drawItemAction = function (index) {
  var key = Window_KeyConfig._refId[this.commandName(index)];
  var action = Input.keyMapper[key];
  if (action === undefined) return;
  this.resetFontSettings();
  this.contents.fontSize -= 8;
  var color = this.textColor(Yanfly.Param.KeyConfigActionColor);
  this.changeTextColor(color);
  this.changePaintOpacity(true);
  var rect = this.itemRectForText(index);
  rect.y += this.lineHeight();
  var align = this.itemTextAlign();
  this.drawText(this.actionKey(action), rect.x, rect.y, rect.width, align);
};

Window_KeyConfig.prototype.actionKey = function (action) {
  switch (action) {
    case "ok":
      return Yanfly.Param.KeyConfigOkKey;
      break;
    case "escape":
      return Yanfly.Param.KeyConfigEscKey;
      break;
    case "cancel":
      return Yanfly.Param.KeyConfigCancelKey;
      break;
    case "menu":
      return Yanfly.Param.KeyConfigMenuKey;
      break;
    case "shift":
      return Yanfly.Param.KeyConfigShiftKey;
      break;
    case "pageup":
      return Yanfly.Param.KeyConfigPageUpKey;
      break;
    case "pagedown":
      return Yanfly.Param.KeyConfigPageDnKey;
      break;
    case "left":
      return Yanfly.Param.KeyConfigLeftKey;
      break;
    case "up":
      return Yanfly.Param.KeyConfigUpKey;
      break;
    case "right":
      return Yanfly.Param.KeyConfigRightKey;
      break;
    case "down":
      return Yanfly.Param.KeyConfigDownKey;
      break;
  }
};

Window_KeyConfig.prototype.cursorDown = function (wrap) {
  var index = this.index();
  if (index >= 105) {
    this.select(index - 104);
  } else if ([41, 62].contains(index)) {
    this.select(83);
  } else if ([83, 104].contains(index)) {
    this.select(125);
  } else {
    Window_Command.prototype.cursorDown.call(this, wrap);
  }
};

Window_KeyConfig.prototype.cursorUp = function (wrap) {
  var index = this.index();
  if (index === 0) {
    this.select(125);
  } else if (index <= 20) {
    this.select(index + 104);
  } else if ([41, 62].contains(index)) {
    this.select(20);
  } else if ([83, 104].contains(index)) {
    this.select(41);
  } else {
    Window_Command.prototype.cursorUp.call(this, wrap);
  }
};

Window_KeyConfig.prototype.cursorRight = function (wrap) {
  var index = this.index();
  if ([54, 55].contains(index)) {
    this.select(56);
  } else if ([63, 64].contains(index)) {
    this.select(65);
  } else if ([75, 76].contains(index)) {
    this.select(77);
  } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) {
    this.select(94);
  } else if ([101, 102].contains(index)) {
    this.select(103);
  } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) {
    this.select(112);
  } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) {
    this.select(119);
  } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) {
    this.select(0);
  } else {
    Window_Command.prototype.cursorRight.call(this, wrap);
  }
};

Window_KeyConfig.prototype.cursorLeft = function (wrap) {
  var index = this.index();
  if (index === 0) {
    this.select(125);
  } else if ([54, 55].contains(index)) {
    this.select(53);
  } else if ([63, 64].contains(index)) {
    this.select(62);
  } else if ([75, 76].contains(index)) {
    this.select(74);
  } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) {
    this.select(86);
  } else if ([101, 102].contains(index)) {
    this.select(100);
  } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) {
    this.select(104);
  } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) {
    this.select(111);
  } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) {
    this.select(118);
  } else {
    Window_Command.prototype.cursorLeft.call(this, wrap);
  }
};

Window_KeyConfig.prototype.updateHelp = function () {
  if (!this._helpWindow) return;
  switch (this.currentSymbol()) {
    case "key":
      this._helpWindow.setText(Yanfly.Param.KeyConfigKeyHelp);
      break;
    case "default":
      this._helpWindow.setText(Yanfly.Param.KeyConfigDefaultHelp);
      break;
    case "wasd":
      this._helpWindow.setText(Yanfly.Param.KeyConfigWasdHelp);
      break;
    case "cancel":
      this._helpWindow.setText(Yanfly.Param.KeyConfigFinishHelp);
      break;
    default:
      this._helpWindow.clear();
      break;
  }
};

//=============================================================================
// Window_KeyAction
//=============================================================================

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

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

Window_KeyAction.prototype.initialize = function () {
  Window_Command.prototype.initialize.call(this, 0, 0);
  this.x = (Graphics.boxWidth - this.width) / 2;
  this.y = (Graphics.boxHeight - this.height) / 2;
  this.openness = 0;
  this.deactivate();
};

Window_KeyAction.prototype.makeCommandList = function () {
  this.addCommand(Yanfly.Param.KeyConfigClearTx, "ok", true, "clear");
  this.addCommand(Yanfly.Param.KeyConfigOkTx, "ok", true, "ok");
  this.addCommand(Yanfly.Param.KeyConfigEscTx, "ok", true, "escape");
  this.addCommand(Yanfly.Param.KeyConfigCancelTx, "ok", true, "cancel");
  this.addCommand(Yanfly.Param.KeyConfigMenuTx, "ok", true, "menu");
  this.addCommand(Yanfly.Param.KeyConfigShiftTx, "ok", true, "shift");
  this.addCommand(Yanfly.Param.KeyConfigPageUpTx, "ok", true, "pageup");
  this.addCommand(Yanfly.Param.KeyConfigPageDnTx, "ok", true, "pagedown");
  this.addCommand(Yanfly.Param.KeyConfigLeftTx, "ok", true, "left");
  this.addCommand(Yanfly.Param.KeyConfigUpTx, "ok", true, "up");
  this.addCommand(Yanfly.Param.KeyConfigRightTx, "ok", true, "right");
  this.addCommand(Yanfly.Param.KeyConfigDownTx, "ok", true, "down");
};

//=============================================================================
// Scene_Options
//=============================================================================

Yanfly.KeyConfig.Scene_Options_createOptionsWindow =
  Scene_Options.prototype.createOptionsWindow;
Scene_Options.prototype.createOptionsWindow = function () {
  Yanfly.KeyConfig.Scene_Options_createOptionsWindow.call(this);
  this._optionsWindow.setHandler("keyConfig", this.commandKeyConfig.bind(this));
};

Scene_Options.prototype.commandKeyConfig = function () {
  SceneManager.push(Scene_KeyConfig);
};

//=============================================================================
// Scene_KeyConfig
//=============================================================================

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

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

Scene_KeyConfig.prototype.initialize = function () {
  Scene_MenuBase.prototype.initialize.call(this);
};

Scene_KeyConfig.prototype.create = function () {
  Scene_MenuBase.prototype.create.call(this);
  this.createHelpWindow();
  this.createKeyConfigWindow();
  this.createKeyActionWindow();
};

Scene_KeyConfig.prototype.terminate = function () {
  Scene_MenuBase.prototype.terminate.call(this);
  ConfigManager.save();
};

Scene_KeyConfig.prototype.refreshWindows = function () {
  this._configWindow.refresh();
  this._configWindow.activate();
  ConfigManager.save();
};

Scene_KeyConfig.prototype.createKeyConfigWindow = function () {
  this._configWindow = new Window_KeyConfig(this._helpWindow);
  this._configWindow.setHandler("default", this.commandDefault.bind(this));
  this._configWindow.setHandler("wasd", this.commandWasd.bind(this));
  this._configWindow.setHandler("cancel", this.popScene.bind(this));
  this._configWindow.setHandler("key", this.commandKey.bind(this));
  this.addWindow(this._configWindow);
};

Scene_KeyConfig.prototype.createKeyActionWindow = function () {
  this._actionWindow = new Window_KeyAction();
  this._actionWindow.setHandler("ok", this.onActionOk.bind(this));
  this._actionWindow.setHandler("cancel", this.onActionCancel.bind(this));
  this.addWindow(this._actionWindow);
};

Scene_KeyConfig.prototype.commandDefault = function () {
  ConfigManager.keyMapper = {
    9: "tab",
    13: "ok",
    16: "shift",
    17: "control",
    18: "control",
    27: "escape",
    32: "ok",
    33: "pageup",
    34: "pagedown",
    37: "left",
    38: "up",
    39: "right",
    40: "down",
    45: "escape",
    46: "ok",
    35: "escape",
    36: "menu",
    81: "pageup",
    87: "pagedown",
    88: "escape",
    90: "ok",
    96: "escape",
    98: "down",
    100: "left",
    102: "right",
    104: "up",
    120: "debug",
  };
  ConfigManager.applyKeyConfig();
  this.refreshWindows();
};

Scene_KeyConfig.prototype.commandWasd = function () {
  ConfigManager.keyMapper = {
    9: "tab",
    13: "ok",
    16: "shift",
    17: "control",
    18: "control",
    27: "escape",
    32: "ok",
    33: "pageup",
    34: "pagedown",
    37: "left",
    38: "up",
    39: "right",
    40: "down",
    87: "up",
    65: "left",
    83: "down",
    68: "right",
    74: "ok",
    75: "escape",
    77: "menu",
    219: "pageup",
    221: "pagedown",
    45: "escape",
    46: "ok",
    35: "escape",
    36: "menu",
    96: "escape",
    98: "down",
    100: "left",
    102: "right",
    104: "up",
    120: "debug",
  };
  ConfigManager.applyKeyConfig();
  this.refreshWindows();
};

Scene_KeyConfig.prototype.commandKey = function () {
  this._actionWindow.select(0);
  this._actionWindow.open();
  this._actionWindow.activate();
};

Scene_KeyConfig.prototype.onActionCancel = function () {
  this._actionWindow.close();
  this._actionWindow.deactivate();
  this._configWindow.activate();
};

Scene_KeyConfig.prototype.onActionOk = function () {
  var action = this._actionWindow.currentExt();
  var name = this._configWindow.commandName(this._configWindow.index());
  var key = Window_KeyConfig._refId[name];
  if (action === "clear") {
    ConfigManager.keyMapper[key] = undefined;
  } else {
    ConfigManager.keyMapper[key] = action;
  }
  SoundManager.playEquip();
  ConfigManager.applyKeyConfig();
  this.onActionCancel();
  this.refreshWindows();
};

//=============================================================================
// End of File
//=============================================================================

repo_name: dazed/translations

license: unknown


code:
//=============================================================================
// Lazy Tilesets
// by Shaz
// Last Updated: 2015.10.21
//=============================================================================

/*:
* @plugindesc Allows you to export/import/copy tilesets and all their data
* @author Shaz
*
* @help This plugin does not provide plugin commands.
*
* Tileset Note:
*   <lzexport: filename>     # Export settings to img/tilesets/filename.MVTileset
*   <lzimport: filename>     # Import settings from img/tilesets/filename.MVTileset
*   <lzcopy: ID>             # Copy settings from tileset with ID
*
*   <lzimport: filename A1 A2 B C>
*   <lzcopy: ID A1 A2 B C>   # Import/copy slots A1, A2, B and C
*
*   <lzimport: filename B:D C:E>
*   <lzcopy: ID B:D C:E>     # Import/copy slots B and C, placing them into D and E
*
* Remember to remove the commands after use to prevent loss of custom changes
* This plugin only runs in DEBUG mode (from PlayTest)
*/
*
/*:ja
* @plugindesc タイルセットとその全データの
* エクスポート/インポート/コピーを可能にします。
* @author Shaz
*
* @help このプラグインは、プラグインコマンドを含みません。
*
* Tileset Note:
*   <lzexport: filename>     #
* 	img/tilesets/filename.MVTilesetに設定をエクスポートします。
*   <lzimport: filename>     #
* 	img/tilesets/filename.MVTilesetからファイルをインポートします。
*   <lzcopy: ID>             #
* 	タイルセットから設定をコピーします。
*
*   <lzimport: filename A1 A2 B C>
*   <lzcopy: ID A1 A2 B C>   #
* 	A1, A2, B, Cのインポート/コピーを行います。
*
*   <lzimport: filename B:D C:E>
*   <lzcopy: ID B:D C:E>     #
* 	B, Cのインポート/コピーを行い、D, Eに置換します。
*
* 変更の反映を失わないために、使用後はコマンドを消去してください。
* このプラグインはデバッグモードのみで動作します。
*/

(function() {

  var slots = {
    'A1': [0, 2048, 2815],
    'A2': [1, 2816, 4351],
    'A3': [2, 4352, 5887],
    'A4': [3, 5888, 8191],
    'A5': [4, 1536, 1663],
    'B':  [5, 0, 255],
    'C':  [6, 256, 511],
    'D':  [7, 512, 767],
    'E':  [8, 768, 1023]
  };

  var _Scene_Boot_start = Scene_Boot.prototype.start;
  Scene_Boot.prototype.start = function() {
    _Scene_Boot_start.call(this);

    if (!Utils.isOptionValid('test')) return;

    var saveMods = false;
    var fs = require('fs');

    for (var i = 0; i < $dataTilesets.length; i++) {
      ts = $dataTilesets[i];

      if (!ts) continue;

      if (ts.meta.lzexport) {
        filename = ts.meta.lzexport.trim();
        fs.writeFileSync(StorageManager.lzFile(filename), JSON.stringify(ts));
      }

      if (ts.meta.lzimport) {
        var options = ts.meta.lzimport.trim().split(' ');
        filename = options.shift();
        data = JSON.parse(fs.readFileSync(StorageManager.lzFile(filename)));
        $dataTilesets[i] = this.lzReadData(data, options, i);
        saveMods = true;
      }

      if (ts.meta.lzcopy) {
        var options = ts.meta.lzcopy.trim().split(' ');
        tilesetId = options.shift();
        data = $dataTilesets[Number(tilesetId)];
        $dataTilesets[i] = this.lzReadData(data, options, i);
        saveMods = true;
      }
    }

    if (saveMods) {
      fs.writeFileSync(StorageManager.lzData('Tilesets'), JSON.stringify($dataTilesets));
    }
  };

  Scene_Boot.prototype.lzReadData = function(data, options, tilesetId) {
    if (options.length < 1) {
      return data;
    } else {
      var rtnData = $dataTilesets[tilesetId];
      msgprfx = 'Tileset #' + String(tilesetId) + ' - ' + rtnData.name + ': ';

      for (i = 0; i < options.length; i++) {
        var group = options[i].toUpperCase().split(':');
        var fromSlot = group[0];
        var toSlot = group[1] || group[0];

        // 'from' slot not valid
        if ((slots[fromSlot] || 'X') === 'X') {
          window.alert(msgprfx + 'Invalid slot ' + fromSlot);
          return rtnData;
        }

        // 'to' slot not valid
        if ((slots[toSlot] || 'X') === 'X') {
          window.alert(msgprfx + 'Invalid slot ' + toSlot);
          return rtnData;
        }

        // trying to move something invalid into/out of one of the A slots
        if (fromSlot !== toSlot && ('BCDE'.indexOf(fromSlot) < 0 || 'BCDE'.indexOf(toSlot) < 0)) {
          window.alert(msgprfx + 'A1-A5 slots cannot be moved');
          return rtnData;
        }

        // all good - copy the slot data in
        fromSlotId = slots[fromSlot][0];
        fromSlotStart = slots[fromSlot][1];
        fromSlotEnd = slots[fromSlot][2];

        toSlotId = slots[toSlot][0];
        k = slots[toSlot][1];

        rtnData.tilesetNames[toSlotId] = data.tilesetNames[fromSlotId];
        for (j = fromSlotStart; j <= fromSlotEnd; j++) {
          rtnData.flags[k] = data.flags[j];
          k++;
        }

      }
    }
    return rtnData;
  };

  StorageManager.lzFile = function(filename) {
    var path = window.location.pathname.replace(/\/[^\/]*$/, '/img/tilesets/');
    if (path.match(/^\/([A-Z]\:)/)) {
        path = path.slice(1);
    }
    return decodeURIComponent(path) + filename.replace(/[^a-zA-Z0-9]/,'') + '.MVTileset';
  };

  StorageManager.lzData = function(filename) {
    var path = window.location.pathname.replace(/\/[^\/]*$/, '/data/');
    if (path.match(/^\/([A-Z]\:)/)) {
        path = path.slice(1);
    }
    return decodeURIComponent(path) + filename.replace(/[^a-zA-Z0-9]/,'') + '.json';
  }
})();


code:
//=============================================================================
// Looping Animations
// by Shaz
// Last Updated: 2015.09.21
//=============================================================================

/*:
 * @plugindesc Allows animations on the map to loop
 * @author Shaz
 *
 * @help
 *
 * Plugin Command:
 *   LoopAnim start event animid   # Start a looping animation on an event
 *   LoopAnim stop event           # Stop animation loop
 *
 *   event = number for specific event
 *   event = 0 for "this" event
 *   event = -1 for player
 *   event = $gameVariables.value(x) to get the event id from variable x
 */

/*:ja
 * @plugindesc マップ上のアニメーションループを可能にします。
 * @author Shaz
 *
 * @help
 *
 * Plugin Command:
 *   LoopAnim start event animid   #
 * 	イベント上でのアニメーションループを開始します。
 *   LoopAnim stop event           #
 * 	アニメーションループを停止します。
 *
 *   event = 0 →このイベント
 *   event = -1 →プレイヤー
 *   event = $gameVariables.value(x) →xからイベントIDを取得
 */

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

    if (command.toUpperCase() === "LOOPANIM") {
      var character = this.character(eval(args[1]));
      if (character) {
        switch (args[0].toUpperCase()) {
          case "START":
            character.loopAnimStart(args[2]);
            break;
          case "STOP":
            character.loopAnimStop();
        }
      }
    }
  };

  var _Game_CharacterBase_initMembers =
    Game_CharacterBase.prototype.initMembers;
  Game_CharacterBase.prototype.initMembers = function () {
    _Game_CharacterBase_initMembers.call(this);
    this._loopAnimId = 0;
  };

  Game_CharacterBase.prototype.loopAnimStart = function (animId) {
    this._loopAnimId = animId;
    this.requestAnimation(animId);
  };

  Game_CharacterBase.prototype.loopAnimStop = function () {
    this._loopAnimId = 0;
  };

  Sprite_Character.prototype.isAnimationPlaying = function () {
    if (this._animationSprites.length > 0) {
      result = true;
    } else if (this._character._loopAnimId > 0) {
      this._character.requestAnimation(this._character._loopAnimId);
      this.setupAnimation();
      result = true;
    } else {
      result = false;
    }
    return result;
  };
})();


code:
//=============================================================================
// More Character Frames
// by Shaz
// Last Updated: 2015.09.21
//=============================================================================

/*:
 * @plugindesc Allows more than 3 Frames
 * @author Shaz
 *
 * @help This plugin does not provide plugin commands.
 *
 * Add [D L R U] to your character sheet name (with $ prefix) to specify haw
 * many frames in each direction (Down, Left, Right, Up).
 * Spritesheets with this added to the file name will use a looping frame
 * animation rather than the back-and-forth default animation.
 *
 * The first frame should be the idle/still pose.
 *
 * eg. $Ralph [8 8 8 8].png
 *     is a character sheet consisting of 4 rows with 8 frames per row.
 *     Animation will go from frame 1 to 8 then start at 1 again.
 */

/*:ja
 * @plugindesc キャラクターの3フレーム以上のアニメーションを可能にします。
 * @author Shaz
 *
 * @help このプラグインは、プラグインコマンドを含みません。
 *
 * キャラクターシート名に、$ + [下 左 右 上]の数値を追記することで、
 * それぞれの方向にフレーム数を指定することができます。
 * ファイル名にこの数値が追記されたスプライトシートは、
 * デフォルトの行ったり来たりのアニメーションの代わりに、
 * こちらのループアニメを優先して使用します。
 *
 * 最初のフレームは待機のポーズである必要があります。
 *
 * 例） $Ralph [8 8 8 8].png
 *     8フレーム x 4方向を指定したキャラクターシートです。
 *     1から8のアニメーションが再生され、再度1から繰り返されます。
 */

(function () {
  ImageManager.isMultiFrameCharacter = function (filename) {
    var frames = filename.match(/\[(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\]/);
    return frames && frames.length === 5;
  };

  ImageManager.getCharacterFrameCount = function (filename) {
    var frames = filename.match(/\[(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\]/);
    if (!frames) {
      return [3, 3, 3, 3];
    } else {
      return frames.splice(1, 4);
    }
  };

  var _Game_CharacterBase_initMembers =
    Game_CharacterBase.prototype.initMembers;
  Game_CharacterBase.initMembers = function () {
    _Game_CharacterBase_initMembers.call(this);
    this._isMultiFrame = false;
    this._frames = [3, 3, 3, 3];
  };

  var _Game_CharacterBase_maxPattern = Game_CharacterBase.prototype.maxPattern;
  Game_CharacterBase.prototype.maxPattern = function () {
    if (!this._isMultiFrame) {
      return _Game_CharacterBase_maxPattern.call(this);
    } else {
      return this._frames[this._direction / 2 - 1];
    }
  };

  var _Game_CharacterBase_pattern = Game_CharacterBase.prototype.pattern;
  Game_CharacterBase.prototype.pattern = function () {
    if (!this._isMultiFrame) {
      return _Game_CharacterBase_pattern.call(this);
    } else {
      return this._pattern < this._frames[this._direction / 2 - 1]
        ? this._pattern
        : 0;
    }
  };

  var _Game_CharacterBase_isOriginalPattern =
    Game_CharacterBase.prototype.isOriginalPattern;
  Game_CharacterBase.prototype.isOriginalPattern = function () {
    if (!this._isMultiFrame) {
      return _Game_CharacterBase_isOriginalPattern.call(this);
    } else {
      return this.pattern() === 0;
    }
  };

  var _Game_CharacterBase_resetPattern =
    Game_CharacterBase.prototype.resetPattern;
  Game_CharacterBase.prototype.resetPattern = function () {
    if (!this._isMultiFrame) {
      _Game_CharacterBase_resetPattern.call(this);
    } else {
      this.setPattern(0);
    }
  };

  var _Game_CharacterBase_setImage = Game_CharacterBase.prototype.setImage;
  Game_CharacterBase.prototype.setImage = function (
    characterName,
    characterIndex
  ) {
    _Game_CharacterBase_setImage.call(this, characterName, characterIndex);
    this._isMultiFrame = ImageManager.isMultiFrameCharacter(characterName);
    this._frames = ImageManager.getCharacterFrameCount(characterName);
  };

  var _Game_CharacterBase_setTileImage =
    Game_CharacterBase.prototype.setTileImage;
  Game_CharacterBase.prototype.setTileImage = function (tileId) {
    _Game_CharacterBase_setTileImage.call(this, tileId);
    this._isMultiFrame = false;
    this._frames = [3, 3, 3, 3];
  };

  Game_CharacterBase.prototype.isMultiFrame = function () {
    return this._isMultiFrame;
  };

  Game_CharacterBase.prototype.getDirectionFrames = function () {
    return this._frames[this._direction / 2 - 1];
  };

  var _Game_Event_initMembers = Game_Event.prototype.initMembers;
  Game_Event.prototype.initMembers = function () {
    _Game_Event_initMembers.call(this);
    if (this._isMultiFrame) {
      this._originalPattern = 0;
    }
  };

  var _Sprite_Character_patternWidth = Sprite_Character.prototype.patternWidth;
  Sprite_Character.prototype.patternWidth = function () {
    if (!this._character.isMultiFrame()) {
      return _Sprite_Character_patternWidth.call(this);
    } else {
      return this.bitmap.width / this._character.getDirectionFrames();
    }
  };
})();


code:
//=============================================================================
// More Escape Codes
// by Shaz
// Last Update: 2015.10.21
//=============================================================================

/*:
 * @plugindesc Extends the number of escape codes in the Show Text command
 * @author Shaz
 *
 * @param Face ID Index
 * @desc Escape code for ID of actor and index for face graphic
 * @default f
 *
 * @param Nickname/Handle
 * @desc Escape code for actor nickname/handle
 * @default h
 *
 * @help This plugin does not provide plugin commands.
 *
 * Hover the mouse over the text input box of the Show Text command to see
 * the default escape codes.  Do not use values that are already being used.
 *
 * ---Face Graphic---
 * if the Face ID Index value is 'f', use \f[1,2] in a Show Text command
 * to add the face at index 2 of Actor 1's face graphic.  Remember indexes
 * start at 0.  This escape code can be used multiple times within a
 * Show Text command to change expressions.
 *
 * ---Nickname/Handle---
 * if the Nickname/Handle value is 'h', use \h[1] to show Actor 1's nickname.
 *
 */

/*:ja
 * @plugindesc イベントコマンド[文章の表示]内で使える
 * エスケープコードの種類を拡張します。
 * @author Shaz
 *
 * @param Face ID Index
 * @desc アクターIDのエスケープコードおよび
 * 顔グラフィックのインデックスを指定します
 * @default f
 *
 * @param Nickname/Handle
 * @desc アクターのニックネーム/HNのエスケープコードを指定します
 * @default h
 *
 * @help このプラグインは、プラグインコマンドを含みません。
 *
 * イベントコマンド[文章の表示]のインプットボックスにマウスを重ねると
 * デフォルトのエスケープコードを確認することができます。
 * 既に使用されている値は、重複して使用しないようにしてください。
 *
 * ---顔グラフィック---
 * 顔グラフィックのインデックス値を"f"としたとき、
 * [文章の表示]コマンド内で \f[1,2] を挿入することで、
 * アクター1の顔グラフィックに インデックス2の顔を使用することができます。
 * (インデックスは0から始まることに留意してください。)
 * このコードを、[文章の表示]コマンド内で何度も切り替えることで、
 * 会話中の表情の変化などを表現することができます。
 *
 * ---ニックネーム---
 * ニックネームのインデックス値を"h"としたとき、
 * \h[1] を挿入した部分で、アクター1のニックネームを表示することができます。
 *
 */

(function () {
  var parameters = PluginManager.parameters("MoreEscapeCodes");
  var reFace = String(parameters["Face ID Index"] || "");
  var reHandle = String(parameters["Nickname/Handle"] || null);
  var reHandlePattern = reHandle
    ? new RegExp("\\x1b" + reHandle + "\\[(\\d+)\\]", "gi")
    : null;

  Window_Base.prototype.obtainMultiEscapeParams = function (textState) {
    var arr = /^\[(\d+,\d+)\]/.exec(textState.text.slice(textState.index));
    if (arr) {
      textState.index += arr[0].length;
      return arr[1].split(",");
    } else {
      return "";
    }
  };

  var _Window_Base_convertEscapeCharacters =
    Window_Base.prototype.convertEscapeCharacters;
  Window_Base.prototype.convertEscapeCharacters = function (text) {
    text = _Window_Base_convertEscapeCharacters.call(this, text);
    if (reHandle) {
      text = text.replace(
        reHandlePattern,
        function () {
          return this.actorNickname(parseInt(arguments[1]));
        }.bind(this)
      );
    }
    return text;
  };

  Window_Base.prototype.actorNickname = function (n) {
    var actor = n >= 1 ? $gameActors.actor(n) : null;
    return actor ? actor.nickname() : "";
  };

  var _Window_Message_processEscapeCharacter =
    Window_Message.prototype.processEscapeCharacter;
  Window_Message.prototype.processEscapeCharacter = function (code, textState) {
    switch (code) {
      case reFace.toUpperCase():
        this.changeFace(textState);
        break;
      default:
        _Window_Message_processEscapeCharacter.call(this, code, textState);
        break;
    }
  };

  Window_Message.prototype.changeFace = function (textState) {
    newFace = this.obtainMultiEscapeParams(textState);
    if (newFace) {
      $gameMessage.setFaceImage(
        $gameActors.actor(newFace[0]).faceName(),
        newFace[1]
      );
      this.contents.clearRect(
        0,
        0,
        Window_Base._faceWidth,
        Window_Base._faceHeight
      );
      this.loadMessageFace();
      this.drawMessageFace();
    }
  };

  var _Window_Message_newLineX = Window_Message.prototype.newLineX;
  Window_Message.prototype.newLineX = function () {
    var pattern = new RegExp("\\\\" + reFace + "\\[(\\d+,\\d+)\\]", "i");
    if ($gameMessage.allText().match(pattern)) {
      return 168;
    } else {
      return _Window_Message_newLineX.call(this);
    }
  };
})();


path: www/js/MVPlugins_JA/No Autoshadow.js


code:
//=============================================================================
// Yanfly Engine Plugins - Screen Resolution
// ScreenResolution.js
// Version: 1.00
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.ScrRes = Yanfly.ScrRes || {};

//=============================================================================
/*:
 * @plugindesc v1.00 Change your game's screen resolution to your liking!
 * @author Yanfly Engine Plugins
 *
 * @param Screen Width
 * @desc Adjusts the width of the screen.                           .
 * Default: 816
 * @default 816
 *
 * @param Screen Height
 * @desc Adjusts the height of the screen.                          .
 * Default: 624
 * @default 624
 *
 * @help
 * Adjust the parameters to change the size of how you want your game's
 * screen resolution to appear.
 */
/*:ja
 * @plugindesc ゲームスクリーンの解像度を好きなように変更することができます
 * @author Yanfly Engine Plugins
 *
 * @param Screen Width
 * @desc スクリーンの横幅を調整します                           .
 * Default: 816
 * @default 816
 *
 * @param Screen Height
 * @desc スクリーンの縦幅を調整します                          .
 * Default: 624
 * @default 624
 *
 * @help
 * パラメータを調整して、ゲームスクリーンの解像度を変更することができます。
 *
 */

//=============================================================================

Yanfly.Parameters = PluginManager.parameters("ScreenResolution");

//=============================================================================
// Scene_Manager
//=============================================================================

SceneManager._screenWidth = Number(Yanfly.Parameters["Screen Width"] || 816);
SceneManager._screenHeight = Number(Yanfly.Parameters["Screen Height"] || 624);
SceneManager._boxWidth = Number(Yanfly.Parameters["Screen Width"] || 816);
SceneManager._boxHeight = Number(Yanfly.Parameters["Screen Height"] || 624);

Yanfly.ScrRes.SceneManager_run = SceneManager.run;
SceneManager.run = function (sceneClass) {
  Yanfly.ScrRes.SceneManager_run.call(this, sceneClass);
  if (Utils.isMobileDevice()) return;
  if (Utils.isMobileSafari()) return;
  if (Utils.isAndroidChrome()) return;
  var resizeWidth = Graphics.boxWidth - window.innerWidth;
  var resizeHeight = Graphics.boxHeight - window.innerHeight;
  window.moveBy((-1 * resizeWidth) / 2, (-1 * resizeHeight) / 2);
  window.resizeBy(resizeWidth, resizeHeight);
};

//=============================================================================
// End of File
//=============================================================================


code:
//=============================================================================
// Smart Pathfinding
// by Shaz
// Last Updated: 2015.10.21
//=============================================================================

/*:
 * @plugindesc Allows events or players to do smart Pathfinding
 * @author Shaz
 *
 * @help
 *
 * Plugin Command:
 *  SmartPath eventId1 eventId2      # Makes event 1 find path to event 2
 *  SmartPath eventId x y            # Makes event find a path to location x, y
 *  SmartPath eventId cancel         # Cancel Pathfinding for event
 *
 *  event = number for specific event
 *  event = 0 for "this" event
 *  event = -1 for player
 *  event = $gameVariables.value(x) to get the event id from variable x
 *
 *  x, y = coordinates or $gameVariables.value(#) to use a variable coordinate
 *
 */
/*:ja
 * @plugindesc イベントもしくはプレイヤーに、高度な経路探索を提供します。
 * @author Shaz
 *
 * @help
 *
 * Plugin Command:
 *  SmartPath eventId1 eventId2      #
 * 	イベント1に、イベント2までの経路を探索させます。
 *  SmartPath eventId x y            #
 * 	イベントに、(x, y)までの経路を探索させます。
 *  SmartPath eventId cancel         #
 * 	イベントの経路探索を中止させます。
 *
 *  event = 0 →このイベント
 *  event = -1 →プレイヤー
 *  event = $gameVariables.value(x) →xからイベントIDを取得
 *
 *  x, y = coordinates or $gameVariables.value(#) →好きな座標を指定
 *
 */

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

    if (command.toUpperCase() === "SMARTPATH") {
      subject = this.character(eval(args[0]));
      if (args[1].toUpperCase() === "CANCEL") {
        subject.clearTarget();
      } else if (args.length > 2) {
        subject.setTarget(null, eval(args[1]), eval(args[2]));
      } else {
        subject.setTarget(this.character(eval(args[1])));
      }
    }
  };

  var _Game_CharacterBase_initMembers =
    Game_CharacterBase.prototype.initMembers;
  Game_CharacterBase.prototype.initMembers = function () {
    _Game_CharacterBase_initMembers.call(this);
    this._target = null;
    this._targetX = null;
    this._targetY = null;
  };

  Game_CharacterBase.prototype.setTarget = function (target, targetX, targetY) {
    this._target = target;
    if (this._target) {
      this._targetX = this._target.x;
      this._targetY = this._target.y;
    } else {
      this._targetX = targetX;
      this._targetY = targetY;
    }
  };

  Game_CharacterBase.prototype.clearTarget = function () {
    this._target = null;
    this._targetX = null;
    this._targetY = null;
  };

  var _Game_CharacterBase_updateStop = Game_CharacterBase.prototype.updateStop;
  Game_CharacterBase.prototype.updateStop = function () {
    _Game_CharacterBase_updateStop.call(this);

    if (this._target) {
      this._targetX = this._target.x;
      this._targetY = this._target.y;
    }

    if (this._targetX != null) {
      direction = this.findDirectionTo(this._targetX, this._targetY);
      if (direction > 0) {
        this.moveStraight(direction);
      }
    }
  };
})();


code:
//=============================================================================
// TDDP_BindPicturesToMap.js
// Version: 1.0.4
//=============================================================================
var Imported = Imported || {};
Imported.TDDP_BindPicturesToMap = "1.0.4";
//=============================================================================
/*:
 * @plugindesc 1.0.4 Plugin Commands for binding pictures to the map and/or changing what layer they're drawn on.
 *
 * @author Tor Damian Design / Galenmereth
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * The Bind Pictures To Map plugin lets you bind the movement of pictures to
 * the movement of the map rather than to the camera. You can also change what
 * "layer" a picture is drawn to, like below characters, or even below the
 * parallax layer.
 *
 * For updates and easy to use documentation, please go to the plugin's website:
 * http://mvplugins.tordamian.com/?p=54
 *
 * There you can also download a PDF of the documentation for offline use, and
 * having the documentation in one cleanly presented place means you can always
 * be sure it's the most recent available.
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * This plugin is free for both non-commercial and commercial use. Please see
 * http://mvplugins.tordamian.com/terms-of-use for the full terms of use.
 */
/*:ja
 * @plugindesc 画像をマップに固定したり、レイヤーの変更をすることができます。
 *
 * @author Tor Damian Design / Galenmereth
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Bind Pictures To Mapは、画像を、カメラの動きではなく
 * マップの動きに同期させるプラグインです。
 * キャラクターの下層や、パララックスレイヤーの下層など、
 * どのレイヤーに画像を埋め込むかを変更することができます。
 *
 * アップデートと簡易使用方法については、
 * こちらのプラグインのサイトを参照してください。
 * http://mvplugins.tordamian.com/?p=54
 * このサイトでは、オフラインで使用するためのPDFをダウンロードすることができます。
 * またいつでも最新版の確認を行なうことができます。
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * このプラグインは、商用利用・非商用利用どちらにもフリーで公開されています。
 * 使用方法の全文についてはこちらのサイトを確認してください。
 * http://mvplugins.tordamian.com/terms-of-use
 */
(function () {
  "use strict";
  //=============================================================================
  // Game_Interpreter - register plugin commands
  //=============================================================================
  var _Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args);
    var args = args || [];
    if (command === "BindPictureToMap")
      this.bindPictureToMap(args[0], true, args[1]);
    if (command === "UnbindPictureFromMap")
      this.bindPictureToMap(args[0], false, args[1]);
    if (command === "ChangePictureLayer")
      this.changePictureLayer(args[0], args[1]);
    if (command === "START_BindPicturesToMap") this.bindAllPicturesToMap(args);
    if (command === "STOP_BindPicturesToMap") this.stopBindAllPicturesToMap();
  };

  var _Game_Interpreter_clear = Game_Interpreter.prototype.clear;
  Game_Interpreter.prototype.clear = function () {
    _Game_Interpreter_clear.call(this);
    this._bindAllPicturesToMap = this._bindAllPicturesToMapLayer = false;
  };

  Game_Interpreter.prototype.bindPictureToMap = function (
    pictureId,
    bindToMap,
    layer
  ) {
    // Control first argument input, pictureId
    if (!pictureId)
      alert(
        "BindPictureToMap requires the first parameter to be a valid picture Id"
      );
    if (layer) {
      this.changePictureLayer(pictureId, layer);
    }
    var game_picture = $gameScreen.picture(pictureId);
    // Update picture_sprite
    var picture_sprite =
      SceneManager._scene._spriteset._pictureStorage[pictureId];
    if (picture_sprite) {
      if (game_picture && bindToMap != game_picture._bindToMap) {
        picture_sprite.loadBitmap();
      }
      picture_sprite.updateLayer();
    }
    if (game_picture) game_picture._bindToMap = bindToMap;
  };

  Game_Interpreter.prototype.changePictureLayer = function (pictureId, layer) {
    var layer = String(layer);
    if (!SceneManager._scene._spriteset._pictureContainer[layer]) {
      throw new Error("BindPictureToMap: " + layer + " is not a valid layer.");
    }
    var game_picture = $gameScreen.picture(pictureId);
    game_picture._layer = layer;
  };

  Game_Interpreter.prototype.bindAllPicturesToMap = function (args) {
    this._bindAllPicturesToMap = true;
    // Control second argument input, layer
    if (args && args[0]) {
      var layer = String(args[0]);
      if (!SceneManager._scene._spriteset._pictureContainer[layer]) {
        throw new Error(
          "BindPicturesToMap: " + args[0] + " is not a valid layer."
        );
      }
      this._bindAllPicturesToMapLayer = layer;
    }
  };

  Game_Interpreter.prototype.stopBindAllPicturesToMap = function () {
    this._bindAllPicturesToMap = false;
    this._bindAllPicturesToMapLayer = false;
  };

  //=============================================================================
  // Spriteset_Map
  //=============================================================================
  Spriteset_Map.prototype.createLowerLayer = function () {
    Spriteset_Base.prototype.createLowerLayer.call(this);
    this.createPicturesLayer("bottom", this._baseSprite);
    this.createParallax();
    this.createPicturesLayer("below_tilemap", this._baseSprite);
    this.createTilemap();
    this.createPicturesLayer("below_characters", this._tilemap);
    this.createCharacters();
    this.createPicturesLayer("above_characters", this._tilemap, 8);
    this.createShadow();
    this.createPicturesLayer("below_weather", this._tilemap, 8);
    this.createWeather();
    this.createPicturesLayer("top", this);
    this.createDestination();
  };

  // Modified
  Spriteset_Map.prototype.createDestination = function () {
    this._destinationSprite = new Sprite_Destination();
    this._destinationSprite.z = 9;
    this._pictureContainer["top"].addChild(this._destinationSprite);
  };

  // NEW
  Spriteset_Map.prototype.createPicturesLayer = function (layer, parent, z) {
    var z = z || 0;
    this._pictureContainer[layer] = new Sprite();
    var container = this._pictureContainer[layer];
    container.z = z;
    parent.addChild(container);
  };

  // ALIAS
  var _Spriteset_Map_initialize = Spriteset_Map.prototype.initialize;
  Spriteset_Map.prototype.initialize = function () {
    this._pictureStorage = {};
    this._pictureContainer = {};
    _Spriteset_Map_initialize.call(this);
  };

  var _Spriteset_Map_update = Spriteset_Map.prototype.update;
  Spriteset_Map.prototype.update = function () {
    _Spriteset_Map_update.call(this);
    this.updatePictures();
  };

  Spriteset_Map.prototype.updatePictures = function () {
    for (var i = 1; i <= $gameScreen.maxPictures(); i++) {
      var sprite = this._pictureStorage[i];
      if (!sprite.parent && sprite.picture()) {
        this._pictureStorage[i].update();
      }
    }
  };

  // OVERWRITE inherited
  Spriteset_Map.prototype.createPictures = function () {
    for (var i = 1; i <= $gameScreen.maxPictures(); i++) {
      this._pictureStorage[i] = new Sprite_Picture(i);
    }
  };

  //=============================================================================
  // Sprite_Picture
  //=============================================================================
  var _Sprite_Picture_updatePosition = Sprite_Picture.prototype.updatePosition;
  Sprite_Picture.prototype.updatePosition = function () {
    _Sprite_Picture_updatePosition.apply(this);
    var picture = this.picture();
    this._offset.x = picture._offsetX;
    this._offset.y = picture._offsetY;
  };

  Sprite_Picture.prototype.updateLayer = function () {
    var picture = this.picture();
    var parent = this.parent;
    if (picture) {
      if (picture.layer()) {
        if (picture.layer() != parent) {
          if (parent) parent.removeChild(this);
          picture.layer().addChild(this);
          // Sort parent on new entry by pic id
          picture.layer().children.sort(function (a, b) {
            return a._pictureId - b._pictureId;
          });
        }
      }
    }
  };

  var _Sprite_Picture_updateOther = Sprite_Picture.prototype.updateOther;
  Sprite_Picture.prototype.updateOther = function () {
    _Sprite_Picture_updateOther.call(this);
    this.updateLayer();
  };

  var _Sprite_Picture_loadBitmap = Sprite_Picture.prototype.loadBitmap;
  Sprite_Picture.prototype.loadBitmap = function () {
    var bitmap = ImageManager.loadPicture(this.picture()._name);
    bitmap.addLoadListener(this.bltLoadedBitmap.bind(this, bitmap));
    return;
  };

  Sprite_Picture.prototype._useLoopingBitmap = function () {
    return (
      this.picture()._bindToMap &&
      ($gameMap.isLoopHorizontal() || $gameMap.isLoopVertical())
    );
  };

  Sprite_Picture.prototype.bltLoadedBitmap = function (sourceBitmap) {
    var picture = this.picture();

    // Check if bitmap size is too large
    if (picture._width + picture._height > 8032) {
      throw new Error(
        "Picture " +
          this._pictureId +
          "(" +
          this._pictureName +
          ") is too large for bitmaps bound to the map and looping enabled. Its height + width must be less than 8032 in total."
      );
    }

    this.bitmap = new Bitmap(picture._bitmapWidth, picture._bitmapHeight);
    // Blit original bitmap
    this.bitmap.blt(
      sourceBitmap,
      0,
      0,
      sourceBitmap.width,
      sourceBitmap.height,
      0,
      0
    );

    // Make a copy for horizontal offscreen scrolls into view
    if ($gameMap.isLoopHorizontal() && picture._useHorizontalRepeat) {
      this.bitmap.blt(
        sourceBitmap,
        0,
        0,
        sourceBitmap.width,
        sourceBitmap.height,
        picture._horSpacing,
        0
      );
    }
    // Make a copy for vertical offscreen scrolling into view
    if ($gameMap.isLoopVertical() && picture._useVerticalRepeat) {
      this.bitmap.blt(
        sourceBitmap,
        0,
        0,
        sourceBitmap.width,
        sourceBitmap.height,
        0,
        picture._verSpacing
      );
    }
    // Make a copy if horizontal + vertical is scrolled into view
    if (
      $gameMap.isLoopHorizontal() &&
      $gameMap.isLoopVertical() &&
      picture._useHorizontalRepeat &&
      picture._useVerticalRepeat
    ) {
      this.bitmap.blt(
        sourceBitmap,
        0,
        0,
        sourceBitmap.width,
        sourceBitmap.height,
        picture._horSpacing,
        picture._verSpacing
      );
    }
  };
  //=============================================================================
  // Game_Picture
  //=============================================================================
  var _Game_Picture_initBasic = Game_Picture.prototype.initBasic;
  Game_Picture.prototype.initBasic = function () {
    _Game_Picture_initBasic.call(this);
    this._bindToMap = $gameMap._interpreter._bindAllPicturesToMap;
    if ($gameMap._interpreter._bindAllPicturesToMapLayer) {
      this._layer = $gameMap._interpreter._bindAllPicturesToMapLayer;
    } else {
      this._layer = "top";
    }
  };
  /**
   * Get current layer object
   */
  Game_Picture.prototype.layer = function () {
    if (!SceneManager._scene._spriteset) return null;
    return SceneManager._scene._spriteset._pictureContainer[this._layer];
  };
  /**
   * Extensions to show function to set additional properties
   */
  var _Game_Picture_show = Game_Picture.prototype.show;
  Game_Picture.prototype.show = function (
    name,
    origin,
    x,
    y,
    scaleX,
    scaleY,
    opacity,
    blendMode
  ) {
    _Game_Picture_show.call(
      this,
      name,
      origin,
      x,
      y,
      scaleX,
      scaleY,
      opacity,
      blendMode
    );

    this._offsetX = this._offsetY = 0;
    // Map offsets for resolutions that offset the map's drawing start. Used only when binding pictures to map
    this._mapOffsX = Math.max(
      SceneManager._screenWidth - $gameMap.width() * $gameMap.tileWidth(),
      0
    );
    this._mapOffsY = Math.max(
      SceneManager._screenHeight - $gameMap.height() * $gameMap.tileHeight(),
      0
    );
    this._originX = this._x;
    this._originY = this._y;
    // Fetch temp bitmap to calculate sizes
    var bitmap = ImageManager.loadPicture(this._name);
    bitmap.addLoadListener(this.setDimensions.bind(this, bitmap));
  };
  /**
   * Set dimensions based on temp bitmap
   */
  Game_Picture.prototype.setDimensions = function (bitmap) {
    this._width = bitmap.width;
    this._height = bitmap.height;

    // Clear bitmap
    bitmap = null;

    // Horizontal and  vertical spacing for repeating textures
    this._horSpacing = $gameMap.width() * $gameMap.tileWidth();
    this._verSpacing = $gameMap.height() * $gameMap.tileHeight();

    // Check if we need horizontal and vertical repeating
    this._useHorizontalRepeat = this._width < this._horSpacing * 2; //this._width + Graphics.width > this._horSpacing && this._width < this._horSpacing;
    this._useVerticalRepeat = this._height < this._verSpacing * 2; //this._height + Graphics.height > this._verSpacing && this._height < this._verSpacing;

    // Set requested bitmap width based on repeating
    this._bitmapWidth = this._useHorizontalRepeat
      ? this._horSpacing * 2
      : this._width;
    this._bitmapHeight = this._useVerticalRepeat
      ? this._verSpacing * 2
      : this._height;
  };
  /**
   * Extensions to updateMove when binding pictures to map
   */
  var _Game_Picture_updateMove = Game_Picture.prototype.updateMove;
  Game_Picture.prototype.updateMove = function () {
    _Game_Picture_updateMove.call(this);
    if (this._bindToMap) {
      var mw = $gameMap.width() * $gameMap.tileWidth();
      var mh = $gameMap.height() * $gameMap.tileHeight();
      var dx = Math.abs($gameMap.displayX());
      var dy = Math.abs($gameMap.displayY());
      var ox = dx * $gameMap.tileWidth();
      var oy = dy * $gameMap.tileHeight();
      this._x = this._originX - ox;
      this._y = this._originY - oy;
      if (this._useHorizontalRepeat && ox >= mw) {
        this._x += mw;
      } else {
        this._x += this._mapOffsX;
      }
      if (this._useVerticalRepeat && oy >= mh) {
        this._y += mh;
      } else {
        this._y += this._mapOffsY;
      }
    }
  };
  //=============================================================================
  // Game_Picture
  //=============================================================================
  /**
   * Fix to displayX's returned decimal value to hinder JS rounding errors
   */
  Game_Map.prototype.displayX = function () {
    return Math.ceil10(this._displayX, -8);
  };
  /**
   * Fix to displayY's returned decimal value to hinder JS rounding errors
   */
  Game_Map.prototype.displayY = function () {
    return Math.ceil10(this._displayY, -8);
  };
  //=============================================================================
  // Math additions
  //=============================================================================
  /**
   * Decimal adjustment of a number.
   *
   * @param {String}  type  The type of adjustment.
   * @param {Number}  value The number.
   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).
   * @returns {Number} The adjusted value.
   */
  function decimalAdjust(type, value, exp) {
    // If the exp is undefined or zero...
    if (typeof exp === "undefined" || +exp === 0) {
      return Math[type](value);
    }
    value = +value;
    exp = +exp;
    // If the value is not a number or the exp is not an integer...
    if (isNaN(value) || !(typeof exp === "number" && exp % 1 === 0)) {
      return NaN;
    }
    // Shift
    value = value.toString().split("e");
    value = Math[type](+(value[0] + "e" + (value[1] ? +value[1] - exp : -exp)));
    // Shift back
    value = value.toString().split("e");
    return +(value[0] + "e" + (value[1] ? +value[1] + exp : exp));
  }

  // Decimal ceil
  if (!Math.ceil10) {
    Math.ceil10 = function (value, exp) {
      return decimalAdjust("ceil", value, exp);
    };
  }
})();


code:
//=============================================================================
// TDDP_DisableScriptCalls
// Version: 1.0.0
//=============================================================================
/*:
 * @plugindesc 1.0.0 Disables all Script calls in your game's events by default.
 * @author Tor Damian Design / Galenmereth
 *
 * @param Force Code
 * @desc If you write this code anywhere in your Script calls, the Script call will be called like normal.
 * @default FORCE!
 *
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * TDDP_DisableScriptCalls is a tiny script that disables all the Script calls
 * in your events. An optional Force Code parameter can be configured to allow
 * individual Script calls to still be called. Useful for debugging / testing.
 *
 * For updates and easy to use documentation, please go to the plugin's website:
 * http://mvplugins.tordamian.com/?p=290
 *
 * There you can also download a PDF of the documentation for offline use, and
 * having the documentation in one cleanly presented place means you can always
 * be sure it's the most recent available.
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * This plugin is free for both non-commercial and commercial use. Please see
 * http://mvplugins.tordamian.com/terms-of-use for the full terms of use.
 *
 * A big thank you to Degica for making this plugin free for commercial use for
 * everyone!
 */
/*:ja
 * @plugindesc ゲーム内イベントのスクリプトコールを全て無効化します。
 * @author Tor Damian Design / Galenmereth
 *
 * @param Force Code
 * @desc このコードをスクリプトコール内のどこかに挿入することで、
 * 通常どおりにコールされるようになります。
 * @default FORCE!
 *
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * TDDP_DisableScriptCallsはイベント内の
 * すべてのスクリプト呼び出しを無効化する、スクリプトです。
 * オプションのForce Codeパラメーターは、
 * 個々のスクリプトコールをコールされた状態にすることができます。
 * これはデバッグやテストプレイに役立つコードです。
 *
 * アップデートと簡易使用方法については、
 * こちらのプラグインのサイトを参照してください。
 * http://mvplugins.tordamian.com/?p=290
 * このサイトでは、オフラインで使用するためのPDFをダウンロードすることができます。
 * またいつでも最新版の確認を行なうことができます。
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * このプラグインは、商用利用・非商用利用どちらにもフリーで公開されています。
 * 使用方法の全文についてはこちらのサイトを確認してください。
 * http://mvplugins.tordamian.com/terms-of-use
 *
 * 最後に、このプラグインのフリーでの商用利用を実現してくれた
 * Degicaさんに感謝の意を表します。
 */
var TDDP_DisableScriptCalls = {};
(function () {
  "use strict";
  var parameters = PluginManager.parameters("TDDP_DisableScriptCalls");
  TDDP_DisableScriptCalls.forceValue = String(parameters["Force Code"]);
  Game_Interpreter.prototype.command355 = function () {
    // This is the normal functionality of command355
    var script = this.currentCommand().parameters[0] + "\n";
    while (this.nextEventCode() === 655) {
      this._index++;
      script += this.currentCommand().parameters[0] + "\n";
    }
    // We now check if the force code is found; if not we ignore
    var result = script.match(TDDP_DisableScriptCalls.forceValue);
    if (result !== null) {
      script = script.replace(TDDP_DisableScriptCalls.forceValue);
      eval(script);
    }
    return true;
  };
})();


code:
//=============================================================================
// TDDP_ManageDashing
// Version: 1.0.0
//=============================================================================
/*:
 * @plugindesc 1.0.0 Lets you manage the dashing mode in your game with simple plugin options.
 * @author Tor Damian Design / Galenmereth
 *
 * @param Disable Auto-dash
 * @desc If set to true this disables touch and mouse input to cause auto-dashing behavior. Can still use dash button.
 * @default false
 *
 * @param Disable Dashing
 * @desc If set to true this disables dashing in the game. This will also remove the "Always Dash" game option.
 * @default false
 *
 * @param Remove Dash Option
 * @desc If set to true this removes the "Always Dash" option from the game's options.
 * @default false
 *
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * TDDP_ManageDashing lets you manage the dashing mode in your game with simple
 * plugin options.
 *
 * For updates and easy to use documentation, please go to the plugin's website:
 * http://mvplugins.tordamian.com/plugins/manage-dashing/
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Changelog:
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *  1.0.0  Stable initial release.
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * This plugin is free for both non-commercial and commercial use. Please see
 * http://mvplugins.tordamian.com/terms-of-use for the full terms of use.
 */
/*:ja
 * @plugindesc ゲーム内でのダッシュモードの利用が可能になります。
 * @author Tor Damian Design / Galenmereth
 *
 * @param Disable Auto-dash
 * @desc trueにすることで、タッチおよびマウスのインプットを無効化し、
 * オートダッシュが発動します。ダッシュボタンの利用も可能です。
 * @default false
 *
 * @param Disable Dashing
 * @desc trueにすることで、ダッシュを無効化します。
 * 同時に、「常時ダッシュ」のオプションを削除します。
 * @default false
 *
 * @param Remove Dash Option
 * @desc trueにすることで、「常時ダッシュ」のオプションをゲームから削除します。
 * @default false
 *
 * @help =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * Information
 * =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 * TDDP_ManageDashingはシンプルなオプションによって、
 * ゲーム内でのダッシュモードを可能にするプラグインです。
 *
 * アップデートと簡易使用方法については、
 * こちらのプラグインのサイトを参照してください。
 * http://mvplugins.tordamian.com/plugins/manage-dashing/
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Changelog:
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *  1.0.0  Stable initial release.
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Terms & Conditions
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * このプラグインは、商用利用・非商用利用どちらにもフリーで公開されています。
 * 使用方法の全文についてはこちらのサイトを確認してください。
 * http://mvplugins.tordamian.com/terms-of-use
 */
var Imported = Imported || {};
Imported.TDDP_ManageDashing = "1.0.0";

var TDDP_ManageDashing = {};
(function () {
  "use strict";
  var parameters = PluginManager.parameters("TDDP_ManageDashing");
  TDDP_ManageDashing.disableAutoDash = Boolean(
    parameters["Disable Auto-dash"] === "true" || false
  );
  TDDP_ManageDashing.disableDashing = Boolean(
    parameters["Disable Dashing"] === "true" || false
  );
  TDDP_ManageDashing.removeDashOption = Boolean(
    parameters["Remove Dash Option"] === "true" || false
  );
  /**
   * Whether Always Dash option should be shown
   */
  TDDP_ManageDashing.showDashOption = function () {
    if (this.disableDashing || this.removeDashOption) return false;
    return true;
  };
  /**
   * Extended check for dashing based on plugin parameters
   */
  TDDP_ManageDashing.dashing = function (gamePlayer) {
    if (this.disableDashing) return false;
    if (this.disableAutoDash) {
      return gamePlayer.isDashButtonPressed();
    } else {
      // Default behavior
      return gamePlayer.isDashButtonPressed() || $gameTemp.isDestinationValid();
    }
  };
  /**
   * Add check to see if Dash option should be removed
   */
  Window_Options.prototype.addGeneralOptions = function () {
    if (TDDP_ManageDashing.showDashOption())
      this.addCommand(TextManager.alwaysDash, "alwaysDash");
    this.addCommand(TextManager.commandRemember, "commandRemember");
  };
  /**
   * Alter functionality so that touch input doesn't force auto dash
   */
  Game_Player.prototype.updateDashing = function () {
    if (this.isMoving()) {
      return;
    }
    if (this.canMove() && !this.isInVehicle() && !$gameMap.isDashDisabled()) {
      this._dashing = TDDP_ManageDashing.dashing(this);
    } else {
      this._dashing = false;
    }
  };
  /**
   * Extend with a check to see if the Always Dash option is available
   */
  Game_Player.prototype.isDashButtonPressed = function () {
    var shift = Input.isPressed("shift");
    // If Dash option is removed, don't respect Always Dash option settings.
    if (ConfigManager.alwaysDash && TDDP_ManageDashing.showDashOption()) {
      return !shift;
    } else {
      return shift;
    }
  };
})();