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
//=============================================================================


code:
//=============================================================================
// LastSubjectActor.js
//=============================================================================

/*:
 * @plugindesc Stores the ID of the actor who acted lastly to a variable.
 * @author Yoji Ojima
 *
 * @param Variable ID
 * @desc The ID of the variable for storing the actor ID.
 * @default 0
 *
 * @help This plugin does not provide plugin commands.
 */

/*:ja
 * @plugindesc 最後に行動したアクターのIDを変数に格納します。
 * @author Yoji Ojima
 *
 * @param Variable ID
 * @desc アクターIDを格納する変数のIDです。
 * @default 0
 *
 * @help このプラグインには、プラグインコマンドはありません。
 */

(function () {
  var parameters = PluginManager.parameters("LastSubjectActor");
  var variableId = Number(parameters["Variable ID"] || 0);

  var _BattleManager_processTurn = BattleManager.processTurn;
  BattleManager.processTurn = function () {
    var subject = this._subject;
    if (subject.isActor()) {
      $gameVariables.setValue(variableId, subject.actorId());
    }
    _BattleManager_processTurn.call(this);
  };
})();

repo_name: dazed/translations

license: unknown


code:
//=============================================================================
// LastUsedItem.js
//=============================================================================

/*:
 * @plugindesc Stores the ID of the skill or item which is used last.
 * @author Yoji Ojima
 *
 * @param Variable ID 1
 * @desc The ID of the variable for storing the skill or item ID.
 * @default 0
 *
 * @param Variable ID 2
 * @desc The ID of the variable for distinguishing between skills and items.
 *       Stored value 0: item, 1: skill
 * @default 0
 *
 * @help This plugin does not provide plugin commands.
 */

/*:ja
 * @plugindesc 最後に使用されたスキルかアイテムのIDを変数に格納します。
 * @author Yoji Ojima
 *
 * @param Variable ID 1
 * @desc スキルかアイテムのIDを格納する変数のIDです。
 * @default 0
 *
 * @param Variable ID 2
 * @desc スキルかアイテムの判別情報を格納する変数のIDです。
 *       代入された値 0: アイテム、1: スキル
 * @default 0
 *
 * @help このプラグインには、プラグインコマンドはありません。
 */

(function () {
  var parameters = PluginManager.parameters("LastUsedItem");
  var variableId1 = Number(parameters["Variable ID 1"] || 0);
  var variableId2 = Number(parameters["Variable ID 2"] || 0);

  var _Game_Battler_useItem = Game_Battler.prototype.useItem;
  Game_Battler.prototype.useItem = function (item) {
    _Game_Battler_useItem.call(this, item);
    $gameVariables.setValue(variableId1, item.id);
    if (DataManager.isSkill(item)) {
      $gameVariables.setValue(variableId2, 1);
    } else {
      $gameVariables.setValue(variableId2, 0);
    }
  };
})();


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:
//=============================================================================
// MKR_MapScrollFix.js
//=============================================================================
// Copyright (c) 2016 マンカインド
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.1.0 2019/07/28 DP_MapZoomプラグインとの競合を修正
//
// 1.0.4 2019/07/15 画面固定時、画面のスクロールを
//                  タイル単位で行わないようにできる設定を追加
//
// 1.0.3 2017/10/24 画面固定時、ジャンプ移動で画面外へ移動できていた
//                  問題を修正。
//
// 1.0.2 2017/10/20 一部プラグインとの競合に対応。
//
// 1.0.1 2017/10/04 スクロール固定時、画面外への離脱と画面内への侵入を
//                  制限できるようにした。
//
// 1.0.0 2016/10/24 初版公開。
// ----------------------------------------------------------------------------
// [Twitter] https://twitter.com/mankind_games/
//  [GitHub] https://github.com/mankindGames/
//    [Blog] http://mankind-games.blogspot.jp/
//=============================================================================

/*:
 *
 * @plugindesc (v1.1.0) マップスクロール固定プラグイン
 * @author マンカインド
 *
 * @help = MKR_MapScrollFix.js =
 * 指定されたスイッチがオンの間、
 * プレイヤーの移動によるマップスクロールを固定します。
 *
 * プラグインパラメータ(以下、パラメータ)でスクロールを禁止するための
 * スイッチ番号を指定します。
 * ゲーム中にそのスイッチがオンになると画面スクロールが固定されます。
 *
 *
 * パラメータ[画面外への離脱/画面内への侵入]により、
 * イベントが固定された画面から外への離脱、画面内への侵入が可能か設定できます。
 * (プレイヤー/イベントがすり抜けONの場合、この設定は無視されます)
 *
 *
 * スクロール固定はタイル(48px四方)単位で行われます。
 * そのため、解像度変更などでマップ画面の更新がタイル単位で行われなくなった場合、
 * 画面表示がタイル単位になるようスクロールされてから固定が行われます。
 *
 * パラメータ[画面固定方法]で「緩和する」を設定することで、
 * タイル単位ではなくその場で画面が固定されます。
 * ただし、キャラクター移動はタイル単位となっているため、
 * 画面固定の結果、画面内に収まっていないタイルは画面外と判定されます。
 *
 *
 * プラグイン:DP_MapZoom.js(以下、MapZoomプラグイン)併用時、
 * プラグイン管理画面で本プラグインをMapZoomプラグインより下に登録し
 * 本プラグインのプラグインパラメータ[MapZoom併用]を「有効にする」と
 * 設定してください。
 *
 *
 * プラグインコマンド:
 *   ありません。
 *
 *
 * スクリプトコマンド:
 *   ありません。
 *
 *
 * 補足：
 *   ・このプラグインに関するメモ欄の設定、プラグインコマンド/パラメーター、
 *     制御文字は大文字/小文字を区別していません。
 *
 *
 * 利用規約:
 *   ・作者に無断で本プラグインの改変、再配布が可能です。
 *     (ただしヘッダーの著作権表示部分は残してください。)
 *
 *   ・利用形態(フリーゲーム、商用ゲーム、R-18作品等)に制限はありません。
 *     ご自由にお使いください。
 *
 *   ・本プラグインを使用したことにより発生した問題について作者は一切の責任を
 *     負いません。
 *
 *   ・要望などがある場合、本プラグインのバージョンアップを行う
 *     可能性がありますが、
 *     バージョンアップにより本プラグインの仕様が変更される可能性があります。
 *     ご了承ください。
 *
 *
 * @param Default_Scroll_Fix_Sw
 * @text スクロール固定スイッチ
 * @desc 画面スクロールを固定するスイッチの番号を指定します。
 * @type switch
 * @default 10
 *
 * @param Is_Display_Out
 * @text 画面外への離脱
 * @desc 画面スクロール固定時、イベントが画面外へと移動可能か選択します。
 * @type boolean
 * @on 移動可能
 * @off 移動不可
 * @default true
 *
 * @param Is_Display_In
 * @text 画面内への侵入
 * @desc 画面スクロール固定時、画面外にいるイベントが画面内へと移動可能か選択します。
 * @type boolean
 * @on 移動可能
 * @off 移動不可
 * @default true
 *
 * @param Scroll_Fix_Type
 * @text 画面固定方法
 * @type select
 * @option 厳格に行う
 * @value 1
 * @option 緩和する
 * @value 0
 * @default 1
 * @desc ゲーム画面内にマップタイルが収まる(=画面解像度がタイル1マスのサイズ、48の倍数である)場合は[厳格に行う]を選択します。
 *
 * @param Enable_MapZoom
 * @text MapZoom併用
 * @desc DP_MapZoom.jsプラグイン併用時、「有効する」に設定してください
 * @type boolean
 * @on 有効にする
 * @off 無効にする
 * @default false
 *
 */

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

(function () {
  "use strict";

  const PN = "MKR_MapScrollFix";

  const CheckParam = function (type, name, value, def, min, max, options) {
    if (min == undefined || min == null) {
      min = -Infinity;
    }
    if (max == undefined || max == null) {
      max = Infinity;
    }

    if (value == null) {
      value = "";
    } else {
      value = String(value);
    }

    switch (type) {
      case "bool":
        if (value == "") {
          value = def ? true : false;
        }
        value =
          value.toUpperCase() === "ON" ||
          value.toUpperCase() === "TRUE" ||
          value.toUpperCase() === "1";
        break;
      case "num":
        value = isFinite(value)
          ? parseInt(value, 10)
          : isFinite(def)
          ? parseInt(def, 10)
          : 0;
        value = value.clamp(min, max);
        break;
      default:
        throw new Error("[CheckParam] " + name + "のタイプが不正です: " + type);
        break;
    }

    return [value, type, def, min, max];
  };

  const paramParse = function (obj) {
    return JSON.parse(JSON.stringify(obj, paramReplace));
  };

  const paramReplace = function (key, value) {
    try {
      return JSON.parse(value || null);
    } catch (e) {
      return value;
    }
  };

  const Parameters = paramParse(PluginManager.parameters(PN));
  let Params = {};

  Params = {
    ScrollFixSw: CheckParam(
      "num",
      "Default_Scroll_Fix_Sw",
      Parameters["Default_Scroll_Fix_Sw"],
      10,
      0
    ),
    ScrollFixType: CheckParam(
      "num",
      "Scroll_Fix_Type",
      Parameters["Scroll_Fix_Type"],
      1
    ),
    IsDisplayOut: CheckParam(
      "bool",
      "Is_Display_Out",
      Parameters["Is_Display_Out"],
      true
    ),
    IsDisplayIn: CheckParam(
      "bool",
      "Is_Display_In",
      Parameters["Is_Display_In"],
      true
    ),
    EnableMapZoom: CheckParam(
      "bool",
      "Enable_MapZoom",
      Parameters["Enable_MapZoom"],
      false
    ),
  };

  //=========================================================================
  // Game_Player
  //  ・プレイヤー移動による画面のスクロールを再定義します。
  //
  //=========================================================================
  var _Game_Player_updateScroll = Game_Player.prototype.updateScroll;
  Game_Player.prototype.updateScroll = function (lastScrolledX, lastScrolledY) {
    if (!$gameSwitches.value(Params.ScrollFixSw[0])) {
      _Game_Player_updateScroll.apply(this, arguments);
      return;
    }

    if (Params.ScrollFixType[0] != 1) {
      return;
    }

    if ($gameMap.displayX() != Math.round($gameMap.displayX())) {
      $gameMap._displayX = Math.round($gameMap.displayX());
    }
    if ($gameMap.displayY() != Math.round($gameMap.displayY())) {
      $gameMap._displayY = Math.round($gameMap.displayY());
    }
  };

  //=========================================================================
  // Game_Map
  //  ・マップスクロール処理を再定義します。
  //
  //=========================================================================
  const _Game_Map_scrollDown = Game_Map.prototype.scrollDown;
  Game_Map.prototype.scrollDown = function (distance) {
    if (Params.EnableMapZoom[0] && $gameSwitches.value(Params.ScrollFixSw[0])) {
      return;
    }
    _Game_Map_scrollDown.call(this, distance);
  };

  const _Game_Map_scrollLeft = Game_Map.prototype.scrollLeft;
  Game_Map.prototype.scrollLeft = function (distance) {
    if (Params.EnableMapZoom[0] && $gameSwitches.value(Params.ScrollFixSw[0])) {
      return;
    }
    _Game_Map_scrollLeft.call(this, distance);
  };

  const _Game_Map_scrollRight = Game_Map.prototype.scrollRight;
  Game_Map.prototype.scrollRight = function (distance) {
    if (Params.EnableMapZoom[0] && $gameSwitches.value(Params.ScrollFixSw[0])) {
      return;
    }
    _Game_Map_scrollRight.call(this, distance);
  };

  const _Game_Map_scrollUp = Game_Map.prototype.scrollUp;
  Game_Map.prototype.scrollUp = function (distance) {
    if (Params.EnableMapZoom[0] && $gameSwitches.value(Params.ScrollFixSw[0])) {
      return;
    }
    _Game_Map_scrollUp.call(this, distance);
  };

  //=========================================================================
  // Game_CharacterBase
  //  ・画面外への移動可能判定を定義します
  //
  //=========================================================================
  var _Game_CharacterBase_isMapPassable =
    Game_CharacterBase.prototype.isMapPassable;
  Game_CharacterBase.prototype.isMapPassable = function (x, y, d) {
    let isPass, x2, y2;
    isPass = _Game_CharacterBase_isMapPassable.apply(this, arguments);

    if (!this.isThrough() && $gameSwitches.value(Params.ScrollFixSw[0])) {
      if (isPass && !Params.IsDisplayOut[0]) {
        isPass = this.isDisplayOutPassible(x, y, d);
      }
      if (isPass && !Params.IsDisplayIn[0]) {
        isPass = this.isDisplayInPassible(x, y, d);
      }
    }
    return isPass;
  };

  Game_CharacterBase.prototype.isDisplayOutPassible = function (x, y, d) {
    let x2, y2, dx, rdx, dy, rdy, realX, realY;
    dx = $gameMap.displayX();
    rdx = dx + $gameMap.screenTileX() - 1;
    dy = $gameMap.displayY();
    rdy = dy + $gameMap.screenTileY() - 1;
    x2 = $gameMap.roundXWithDirection(x, d);
    y2 = $gameMap.roundYWithDirection(y, d);
    realX = this._realX;
    realY = this._realY;

    // switch(true) {
    //     case x == dx && x2 < dx:
    //     case x == rdx && x2 > rdx:
    //     case y == dy && y2 < dy:
    //     case y == rdy && y2 > rdy:
    //     case realX == dx && x2 < dx:
    //     case realX == rdx && x2 > rdx:
    //     case realY == dy && y2 < dy:
    //     case realY == rdy && y2 > rdy:
    //         return false;
    // }

    if (d == 8 || d == 2) {
      switch (true) {
        case y == Math.floor(dy) && y2 < dy:
        case y == Math.ceil(dy) && y2 < dy:
        case y == Math.floor(rdy) && y2 > rdy:
        case y == Math.ceil(rdy) && y2 > rdy:
        case realY == Math.floor(dy) && y2 < dy:
        case realY == Math.ceil(dy) && y2 < dy:
        case realY == Math.floor(rdy) && y2 > rdy:
        case realY == Math.ceil(rdy) && y2 > rdy:
          return false;
      }
    } else if (d == 6 || d == 4) {
      switch (true) {
        case x == Math.floor(dx) && x2 < dx:
        case x == Math.ceil(dx) && x2 < dx:
        case x == Math.floor(rdx) && x2 > rdx:
        case x == Math.ceil(rdx) && x2 > rdx:
        case realX == Math.floor(dx) && x2 < dx:
        case realX == Math.ceil(dx) && x2 < dx:
        case realX == Math.floor(rdx) && x2 > rdx:
        case realX == Math.ceil(rdx) && x2 > rdx:
          return false;
      }
    }

    return true;
  };

  Game_CharacterBase.prototype.isDisplayInPassible = function (x, y, d) {
    let x2, y2, dx, rdx, dy, rdy, realX, realY;
    dx = $gameMap.displayX();
    rdx = dx + $gameMap.screenTileX();
    dx--;
    dy = $gameMap.displayY();
    rdy = dy + $gameMap.screenTileY();
    dy--;
    x2 = $gameMap.roundXWithDirection(x, d);
    y2 = $gameMap.roundYWithDirection(y, d);
    realX = this._realX;
    realY = this._realY;

    // switch(true) {
    //     case x == dx && x2 > dx:
    //     case x == rdx && x2 < rdx:
    //     case y == dy && y2 > dy:
    //     case y == rdy && y2 < rdy:
    //     case realX == dx && x2 > dx:
    //     case realX == rdx && x2 < rdx:
    //     case realY == dy && y2 > dy:
    //     case realY == rdy && y2 < rdy:
    //         return false;
    // }

    if (d == 8 || d == 2) {
      switch (true) {
        case y == Math.floor(dy) && y2 > dy:
        case y == Math.ceil(dy) && y2 > dy:
        case y == Math.floor(rdy) && y2 < rdy:
        case y == Math.ceil(rdy) && y2 < rdy:
        case realY == Math.floor(dy) && y2 > dy:
        case realY == Math.ceil(dy) && y2 > dy:
        case realY == Math.floor(rdy) && y2 < rdy:
        case realY == Math.ceil(rdy) && y2 < rdy:
          return false;
      }
    } else if (d == 6 || d == 4) {
      switch (true) {
        case x == Math.floor(dx) && x2 < dx:
        case x == Math.ceil(dx) && x2 < dx:
        case x == Math.floor(rdx) && x2 > rdx:
        case x == Math.ceil(rdx) && x2 > rdx:
        case realX == Math.floor(dx) && x2 > dx:
        case realX == Math.ceil(dx) && x2 > dx:
        case realX == Math.floor(rdx) && x2 < rdx:
        case realX == Math.ceil(rdx) && x2 < rdx:
          return false;
      }
    }

    return true;
  };

  const _Game_CharacterBase_updateJump =
    Game_CharacterBase.prototype.updateJump;
  Game_CharacterBase.prototype.updateJump = function () {
    _Game_CharacterBase_updateJump.call(this);

    let maxDisplayX, maxDisplayY;
    maxDisplayX = $gameMap.displayX() + $gameMap.screenTileX() - 1;
    maxDisplayY = $gameMap.displayY() + $gameMap.screenTileY() - 1;

    if (!this.isThrough() && $gameSwitches.value(Params.ScrollFixSw[0])) {
      if (this._realX > maxDisplayX) {
        this._realX = maxDisplayX;
        this._x = maxDisplayX;
      } else if (this._realX <= $gameMap.displayX()) {
        this._realX = $gameMap.displayX();
        this._x = $gameMap.displayX();
      }
      if (this._realY >= maxDisplayY) {
        this._realY = maxDisplayY;
        this._y = maxDisplayY;
      } else if (this._realY <= $gameMap.displayY()) {
        this._realY = $gameMap.displayY();
        this._y = $gameMap.displayY();
      }
    }
  };
})();


code:
//=============================================================================
// MOG_SceneFile.js
//=============================================================================

/*:
 * @plugindesc (v1.0) Modifica a cena de salvar e carregar arquivos.
 * @author Moghunter
 *
 * @param Font Size
 * @desc Definição do tamanho da fonte.
 * @default 22
 *
 * @param Text Color
 * @desc Definição da cor do texto.
 * @default 21
 *
 * @param Word Playtime
 * @desc Definição da palavra Playtime.
 * @default Playtime
 *
 * @param Word Location
 * @desc Definição da palavra Localização.
 * @default Location
 *
 * @param Display Gold
 * @desc Apresentar dinheiro.
 * @default true
 *
 * @param Actor X-Axis
 * @desc Definição X-axis da imagem do personagem.
 * @default 100
 *
 * @param Actor Y-Axis
 * @desc Definição Y-axis da imagem do personagem.
 * @default 0
 *
 * @param Help X-Axis
 * @desc Definição X-axis da janela de ajuda.
 * @default 0
 *
 * @param Help Y-Axis
 * @desc Definição Y-axis da janela de ajuda.
 * @default 30
 *
 * @param Parameter X-Axis
 * @desc Definição X-axis dos parâmetros.
 * @default 0
 *
 * @param Parameter Y-Axis
 * @desc Definição Y-axis dos parâmetros.
 * @default 300
 *
 * @param Parameter Space
 * @desc Definição do espaço entre os parâmetros.
 * @default 28
 *
 * @param Parback X-Axis
 * @desc Definição X-Axis do imagem de fundo dos parâmetros.
 * @default 0
 *
 * @param Parback Y-Axis
 * @desc Definição Y-Axis do imagem de fundo dos parâmetros.
 * @default 320
 *
 * @param Cursor X-Axis
 * @desc Definição X-Axis do cursor.
 * @default 342
 *
 * @param Cursor Y-Axis
 * @desc Definição Y-Axis do cursor.
 * @default 0
 *
 * @param Cursor File Space
 * @desc Definição do espaço entre os saves.
 * @default 159
 *
 * @param Save Pages
 * @desc セーブデータページ数
 * @default 10
 *
 * @param Save Per Page
 * @desc 一ページのセーブ数
 * @default 3
 *
 * @help
 * =============================================================================
 * +++ MOG - Scene File (v1.0) +++
 * By Moghunter
 * https://atelierrgss.wordpress.com/
 * =============================================================================
 * Modifica a cena de salvar e carregar arquivos.
 *
 * =============================================================================
 * UTILIZAÇÃO
 * =============================================================================
 * As imagens do sistema deverão ser gravados na pasta.
 *
 * /img/menus/file/
 *
 * =============================================================================
 *
 * E as pictures na pasta.
 *
 * /img/pictures/
 *
 * Nomeie os arquivos da seguinte forma.
 *
 * Actor_ ID.png
 *
 * Exemplo
 *
 * Actor_1.png
 * Actor_2.png
 * Actor_3.png
 * Actor_4.png
 *...
 *
 *
 * 改造：剣崎宗二
 * layout.png→layout0.pngとすること。
 * layout1.png... 等（layout0を一ページとして含めたうえで）ページ数だけ用意する事。
 * （セーブデータが3ページならlayout0, layout1, layout2を用意）
 */

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

Moghunter.parameters = PluginManager.parameters('MOG_SceneFile');
Moghunter.scFile_FontSize = Number(Moghunter.parameters['Font Size'] || 22);
Moghunter.scFile_TextColor = Number(Moghunter.parameters['Text Color'] || 21);
Moghunter.scFile_PlayTimeWord = String(Moghunter.parameters['Word Playtime'] || "Playtime");
Moghunter.scFile_LocationWord = String(Moghunter.parameters['Word Location'] || "Location");
Moghunter.scFile_Gold = String(Moghunter.parameters['Display Gold'] || "true");
Moghunter.scFile_ActorX = Number(Moghunter.parameters['Actor X-Axis'] || 100);
Moghunter.scFile_ActorY = Number(Moghunter.parameters['Actor Y-Axis'] || 0);
Moghunter.scFile_HelpX = Number(Moghunter.parameters['Help X-Axis'] || 0);
Moghunter.scFile_HelpY = Number(Moghunter.parameters['Help Y-Axis'] || 30);
Moghunter.scFile_ParBackX = Number(Moghunter.parameters['Parback X-Axis'] || 0);
Moghunter.scFile_ParBackY = Number(Moghunter.parameters['Parback Y-Axis'] || 320);
Moghunter.scFile_CursorX = Number(Moghunter.parameters['Cursor X-Axis'] || 342);
Moghunter.scFile_CursorY = Number(Moghunter.parameters['Cursor Y-Axis'] || 0);
Moghunter.scFile_CursorS = Number(Moghunter.parameters['File Space'] || 159);
Moghunter.scFile_ParX = Number(Moghunter.parameters['Parameter X-Axis'] || 0);
Moghunter.scFile_ParY = Number(Moghunter.parameters['Parameter Y-Axis'] || 300);
Moghunter.scFile_ParS = Number(Moghunter.parameters['Parameter Space'] || 28);

Moghunter.scFile_NumPages = Number(Moghunter.parameters['Save Pages'] || 5);
Moghunter.scFile_SPerPage = Number(Moghunter.parameters['Save Per Page'] || 3);

//=============================================================================
// ** ImageManager
//=============================================================================

//==============================
// * Menus
//==============================
ImageManager.loadMenusFile = function (filename) {
	return this.loadBitmap('img/menus/file/', filename, 0, true);
};

//=============================================================================
// ** Data Manager
//=============================================================================

//==============================
// * Max Save Files
//==============================
DataManager.maxSavefiles = function () {
	return Moghunter.scFile_NumPages * Moghunter.scFile_SPerPage;
};

//==============================
// * Max Save File Info
//==============================
DataManager.makeSavefileInfo = function () {
	var info = {};
	info.globalId = this._globalId;
	info.title = $dataSystem.gameTitle;
	info.members = $gameParty.members();
	if ($gameMap.displayName()) {
		info.location = $gameMap.displayName();
	} else {
		if ($dataMapInfos[$gameMap._mapId]) {
			info.location = $dataMapInfos[$gameMap._mapId].name;
		} else {
			info.location = "";
		};
	};
	var actor = info.members[0];
	info.actor = [actor.name(), actor.level, actor.mhp, actor.mmp, actor.atk, actor.def,
	actor.mat, actor.mdf, actor.agi, actor.luk, actor._actorId];
	info.gold = $gameParty.gold();
	info.characters = $gameParty.charactersForSavefile();
	info.faces = $gameParty.facesForSavefile();
	info.playtime = $gameSystem.playtimeText();
	info.timestamp = Date.now();
	return info;
};

//=============================================================================
// ** Window Save File List
//=============================================================================

//==============================
// * initialize
//==============================
var _mog_sfile_wsav_initialize = Window_SavefileList.prototype.initialize;
Window_SavefileList.prototype.initialize = function (x, y, width, height) {
	_mog_sfile_wsav_initialize.call(this, x, y, width, height)
	this.visible = false;
};

//=============================================================================
// ** Scene File
//=============================================================================

//==============================
// * initialize
//==============================
var _mog_sfile_sf_initialize = Scene_File.prototype.initialize;
Scene_File.prototype.initialize = function () {
	_mog_sfile_sf_initialize.call(this);
	this._fIndex = -3;
	this._actorIndex = -1;
};

//==============================
// * create
//==============================
var _mog_sfile_create = Scene_File.prototype.create;
Scene_File.prototype.create = function () {
	_mog_sfile_create.call(this)
	this.createActorPicture();
	this.createCursor();
	this.createLayout();
	this.createParBack();
	this.createWindowData();
	this._listWindow.x = (this._listWindow.width * 2);
	if (this._listWindow._index < 0 || this._listWindow._index > (Moghunter.scFile_SPerPage * Moghunter.scFile_NumPages) - 1) { this._listWindow._index = 0 };
	this._Cursor.x = Moghunter.scFile_CursorX + (Moghunter.scFile_CursorS * (this._listWindow._index % Moghunter.scFile_SPerPage));
};

//==============================
// * Create Mbackground
//==============================
Scene_File.prototype.create_mbackground = function () {
};

//==============================
// * Update MBackground
//==============================
Scene_File.prototype.update_mbackground = function () {
};

//==============================
// * create Background
//==============================
Scene_File.prototype.update_mbackgr
var _mog_sfile_createBackground = Scene_File.prototype.createBackground;
Scene_File.prototype.createBackground = function () {
	_mog_sfile_createBackground.call(this);
	this._backgroundSprite.bitmap = ImageManager.loadMenusFile("background");

};

//==============================
// * create Actor Picture
//==============================
Scene_File.prototype.createActorPicture = function () {
	this._ActorPicture = new Sprite();
	this._ActorPicture.anchor.x = 0.5;
	this.addChild(this._ActorPicture);
};

//==============================
// * create Layout
//==============================
Scene_File.prototype.createLayout = function () {
	this._layout = new Sprite(ImageManager.loadMenusFile("layout0"));
	this.addChild(this._layout);
	this._currentPage = 0;
};

//==============================
// * update Layout
//==============================
Scene_File.prototype.updateLayout = function () {
	var index = this._listWindow ? this._listWindow._index : 0;
	var page = Math.floor(index / Moghunter.scFile_SPerPage);
	if (page != this._currentPage) {
		this._layout.bitmap = ImageManager.loadMenusFile("layout" + page);
		this._currentPage = page;
	}
};

//==============================
// * create Cursor
//==============================
Scene_File.prototype.createParBack = function () {
	this._parBack = new Sprite(ImageManager.loadMenusFile("parback"));
	this._parBack.x = Moghunter.scFile_ParBackX;
	this._parBack.y = Moghunter.scFile_ParBackY;
	this._parBack.visible = false;
	this.addChild(this._parBack);
};

//==============================
// * update Par Back
//==============================
Scene_File.prototype.updateParBack = function () {
	this._parBack.visible = this._actorIndex > 0 ? true : false;
};

//==============================
// * create Cursor
//==============================
Scene_File.prototype.createCursor = function () {
	this._Cursor = new Sprite(ImageManager.loadMenusFile("cursor"));
	this._Cursor.opacity = 0;
	this.addChild(this._Cursor);
};

//==============================
// * update Cursor
//==============================
Scene_File.prototype.updateCursor = function () {
	var nx = Moghunter.scFile_CursorX + (Moghunter.scFile_CursorS * (this._listWindow._index % Moghunter.scFile_SPerPage));
	var ny = Moghunter.scFile_CursorY;
	this._Cursor.x = this.barCMT(this._Cursor.x, nx);
	this._Cursor.y = this.barCMT(this._Cursor.y, ny);
	if (this._Cursor.opacity < 120) { this._Cursor.opacity += 5 };
};

//==============================
// * next Index
//==============================
Scene_File.prototype.nextIndex = function (value) {
	SoundManager.playCursor();
	this._listWindow._index += value;
	var maxIndex = (Moghunter.scFile_SPerPage * Moghunter.scFile_NumPages) - 1;
	if (this._listWindow._index < 0) { this._listWindow._index = maxIndex };
	if (this._listWindow._index > maxIndex) { this._listWindow._index = 0 };
};

//==============================
// * update Command
//==============================
Scene_File.prototype.updateCommand = function () {
	if (Input.isRepeated("right")) { this.nextIndex(1) }
	else if (Input.isRepeated("left")) { this.nextIndex(-1) }
	if (TouchInput.isTriggered()) { this.checkTouchFile() };
};

//==============================
// * check Touch File
//==============================
Scene_File.prototype.checkTouchFile = function () {
	var oldIndex = this._listWindow._index;
	var onfile = false
	for (i = 0; i < Moghunter.scFile_SPerPage; i++) {
		if (this.isOnFile(i)) {
			this._listWindow._index = i + this._currentPage * Moghunter.scFile_SPerPage;
			onfile = true;
		};
	};
	if (!onfile) { return };
	if (oldIndex === this._listWindow._index) {
		this._listWindow.processOk();
	} else {
		SoundManager.playCursor();
	};
};

//==============================
// * On Picture Com
//==============================
Scene_File.prototype.isOnFile = function (index) {
	var x = Moghunter.scFile_CursorX + (Moghunter.scFile_CursorS * index);
	var y = Moghunter.scFile_CursorY;
	var cw = this._Cursor.bitmap.width;
	var ch = this._Cursor.bitmap.height;
	if (TouchInput.x < x) { return false };
	if (TouchInput.x > x + cw) { return false };
	if (TouchInput.y < y) { return false };
	if (TouchInput.y > y + ch) { return false };
	return true;
};

//==============================
// * bar CMT
//==============================
Scene_File.prototype.barCMT = function (value, real_value) {
	if (value == real_value) { return value };
	var dnspeed = 5 + (Math.abs(value - real_value) / 5);
	if (value > real_value) {
		value -= dnspeed;
		if (value < real_value) { value = real_value };
	}
	else if (value < real_value) {
		value += dnspeed;
		if (value > real_value) { value = real_value };
	};
	return Math.floor(value);
};

//==============================
// * refresh Actor Picture
//==============================
Scene_File.prototype.refreshActorPicture = function () {
	this._actorIndex = this._dataWindow.actorID();
	this._ActorPicture.bitmap = null;
	if (!this._actorIndex) { return };
	this._ActorPicture.bitmap = ImageManager.loadPicture("Actor_" + String(this._actorIndex));
	this._ActorPicture.x = Moghunter.scFile_ActorX - 100;
	this._ActorPicture.opacity = 0;
};

//==============================
// * update Actor Picture
//==============================
Scene_File.prototype.updateActorPicture = function () {
	if (!this._ActorPicture.bitmap || !this._ActorPicture.bitmap.isReady()) { return };
	if (this._ActorPicture.x < Moghunter.scFile_ActorX) {
		this._ActorPicture.x += 3;
		this._ActorPicture.opacity += 5;
		if (this._ActorPicture.x >= Moghunter.scFile_ActorX) {
			this._ActorPicture.x = Moghunter.scFile_ActorX;
			this._ActorPicture.opacity = 255;
		};
	};
	this._ActorPicture.y = (Graphics.boxHeight - this._ActorPicture.height) + Moghunter.scFile_ActorY;
};

//==============================
// * create Window Data
//==============================
Scene_File.prototype.createWindowData = function () {
	var x = 0;
	var y = 0;
	var w = 320;
	var h = Graphics.boxHeight + 48;
	this._dataWindow = new Window_FileData(x, y, w, h);
	this.addChild(this._dataWindow);
};

//==============================
// * refresh Window Data
//==============================
Scene_File.prototype.refreshDataWindow = function () {
	this._fIndex = this._listWindow._index;
	this._dataWindow.setData(this._fIndex);
	this.refreshActorPicture()
};

//==============================
// * update
//==============================
var _mog_sfile_sf_update = Scene_File.prototype.update;
Scene_File.prototype.update = function () {
	_mog_sfile_sf_update.call(this);
	if (this._fIndex != this._listWindow._index) { this.refreshDataWindow() };
	this.updateActorPicture();
	this.updateCursor();
	this.updateLayout();
	this.updateParBack();
	if (!SceneManager.isSceneChanging()) { this.updateCommand() };
	this._helpWindow.opacity = 0;
	this._helpWindow.x = Moghunter.scFile_HelpX;
	this._helpWindow.y = Moghunter.scFile_HelpY;

};

//=============================================================================
// ** Window FileData
//=============================================================================
function Window_FileData() {
	this.initialize.apply(this, arguments);
}

Window_FileData.prototype = Object.create(Window_Base.prototype);
Window_FileData.prototype.constructor = Window_FileData;

//==============================
// * initialize
//==============================
Window_FileData.prototype.initialize = function (x, y, width, height) {
	Window_Base.prototype.initialize.call(this, x, y, width, height);
	this.active = false;
	this._fileIndex = 0;
	this._actorID = null;
	this._dataInfo = null;
	this._gold = String(Moghunter.scFile_Gold) === "true" ? true : false;
	this.contents.fontSize = Moghunter.scFile_FontSize;
};

//==============================
// * data
//==============================
Window_FileData.prototype.data = function () {
	return this._dataInfo;
};

//==============================
// * actor ID
//==============================
Window_FileData.prototype.actorID = function () {
	return this._actorID;
};

//==============================
// * set Data
//==============================
Window_FileData.prototype.setData = function (index) {
	this._fileIndex = index;
	this._dataInfo = DataManager.loadSavefileInfo(this._fileIndex + 1);
	this.refresh();
};

//==============================
// * refresh
//==============================
Window_FileData.prototype.refresh = function () {
	if (this.contents) { this.contents.clear() };
	this._actorID = null;
	if (this.data()) {
		this.drawData()
	} else {
		this.drawText("- No Data - ", (this.width / 2) - 50, (this.height / 2), 120, 'center');
	};
};

//==============================
// * draw Data
//==============================
Window_FileData.prototype.drawData = function () {
	var actor = this.data().actor;
	var x = Moghunter.scFile_ParX;
	var y = Moghunter.scFile_ParY;
	var s = Moghunter.scFile_ParS;
	var w1 = this.width - 120 + x;;
	this._actorID = actor[];
	this.changeTextColor(this.textColor(Moghunter.scFile_TextColor));
	this.drawText(String(Moghunter.scFile_PlayTimeWord), x, 80, 120, 'left');
	this.drawText(String(Moghunter.scFile_LocationWord), x, 112, 120, 'left');
	this.drawText(TextManager.levelA, w1, y, 120, 'left'); // Level
	this.drawText(TextManager.param(0), x, y + s * 1, 120, 'left'); // HP
	this.drawText(TextManager.param(1), x, y + s * 2, 120, 'left'); // MP
	this.drawText(TextManager.param(2), x, y + s * 3, 120, 'left'); // Atk
	this.drawText(TextManager.param(3), x, y + s * 4, 120, 'left'); // Def
	this.drawText(TextManager.param(4), x, y + s * 5, 120, 'left'); // Mat
	this.drawText(TextManager.param(5), x, y + s * 6, 120, 'left'); // Mdf
	this.drawText(TextManager.param(6), x, y + s * 7, 120, 'left'); // Agi
	this.drawText(TextManager.param(7), x, y + s * 8, 120, 'left'); // Luk
	if (this._gold) { this.drawText(TextManager.currencyUnit, x, y + s * 9, 120, 'left') }; // Gold
	this.resetTextColor();
	this.drawText(this.data().playtime, w1 - 40, 80, 120, 'right');
	this.drawText(this.data().location, w1 - 80, 112, 160, 'right');
	this.drawText(actor[0], x, y, 120, 'left'); // Name
	this.drawText(actor[1], w1, y, 80, 'right'); // Level
	this.drawText(actor[2], w1, y + s * 1, 80, 'right'); // HP
	this.drawText(actor[3], w1, y + s * 2, 80, 'right'); // MP
	this.drawText(actor[4], w1, y + s * 3, 80, 'right'); // Atk
	this.drawText(actor[5], w1, y + s * 4, 80, 'right'); // Def
	this.drawText(actor[6], w1, y + s * 5, 80, 'right'); // Mat
	this.drawText(actor[7], w1, y + s * 6, 80, 'right'); // Mdf
	this.drawText(actor[8], w1, y + s * 7, 80, 'right'); // Agi
	this.drawText(actor[9], w1, y + s * 8, 80, 'right'); // Luk
	if (this._gold) { this.drawText(this.data().gold, w1 - 40, y + s * 9, 120, 'right') }; // Gold
};

//==============================
// * Update
//==============================
Window_FileData.prototype.update = function () {
	Window_Base.prototype.update.call(this);
	this.opacity = 0;
};