Project1

标题: 测试,此代码太长无法直接交给AI,发这里让AI过来读取试试 [打印本页]

作者: 雷影    时间: 2023-4-9 18:27
标题: 测试,此代码太长无法直接交给AI,发这里让AI过来读取试试
  1. //=============================================================================
  2. // rpg_windows.js v1.6.2
  3. //=============================================================================

  4. //-----------------------------------------------------------------------------
  5. // Window_Base
  6. //
  7. // The superclass of all windows within the game.

  8. function Window_Base() {
  9.     this.initialize.apply(this, arguments);
  10. }

  11. Window_Base.prototype = Object.create(Window.prototype);
  12. Window_Base.prototype.constructor = Window_Base;

  13. Window_Base.prototype.initialize = function(x, y, width, height) {
  14.     Window.prototype.initialize.call(this);
  15.     this.loadWindowskin();
  16.     this.move(x, y, width, height);
  17.     this.updatePadding();
  18.     this.updateBackOpacity();
  19.     this.updateTone();
  20.     this.createContents();
  21.     this._opening = false;
  22.     this._closing = false;
  23.     this._dimmerSprite = null;
  24. };

  25. Window_Base._iconWidth  = 32;
  26. Window_Base._iconHeight = 32;
  27. Window_Base._faceWidth  = 144;
  28. Window_Base._faceHeight = 144;

  29. Window_Base.prototype.lineHeight = function() {
  30.     return 36;
  31. };

  32. Window_Base.prototype.standardFontFace = function() {
  33.     if ($gameSystem.isChinese()) {
  34.         return 'SimHei, Heiti TC, sans-serif';
  35.     } else if ($gameSystem.isKorean()) {
  36.         return 'Dotum, AppleGothic, sans-serif';
  37.     } else {
  38.         return 'GameFont';
  39.     }
  40. };

  41. Window_Base.prototype.standardFontSize = function() {
  42.     return 28;
  43. };

  44. Window_Base.prototype.standardPadding = function() {
  45.     return 18;
  46. };

  47. Window_Base.prototype.textPadding = function() {
  48.     return 6;
  49. };

  50. Window_Base.prototype.standardBackOpacity = function() {
  51.     return 192;
  52. };

  53. Window_Base.prototype.loadWindowskin = function() {
  54.     this.windowskin = ImageManager.loadSystem('Window');
  55. };

  56. Window_Base.prototype.updatePadding = function() {
  57.     this.padding = this.standardPadding();
  58. };

  59. Window_Base.prototype.updateBackOpacity = function() {
  60.     this.backOpacity = this.standardBackOpacity();
  61. };

  62. Window_Base.prototype.contentsWidth = function() {
  63.     return this.width - this.standardPadding() * 2;
  64. };

  65. Window_Base.prototype.contentsHeight = function() {
  66.     return this.height - this.standardPadding() * 2;
  67. };

  68. Window_Base.prototype.fittingHeight = function(numLines) {
  69.     return numLines * this.lineHeight() + this.standardPadding() * 2;
  70. };

  71. Window_Base.prototype.updateTone = function() {
  72.     var tone = $gameSystem.windowTone();
  73.     this.setTone(tone[0], tone[1], tone[2]);
  74. };

  75. Window_Base.prototype.createContents = function() {
  76.     this.contents = new Bitmap(this.contentsWidth(), this.contentsHeight());
  77.     this.resetFontSettings();
  78. };

  79. Window_Base.prototype.resetFontSettings = function() {
  80.     this.contents.fontFace = this.standardFontFace();
  81.     this.contents.fontSize = this.standardFontSize();
  82.     this.resetTextColor();
  83. };

  84. Window_Base.prototype.resetTextColor = function() {
  85.     this.changeTextColor(this.normalColor());
  86. };

  87. Window_Base.prototype.update = function() {
  88.     Window.prototype.update.call(this);
  89.     this.updateTone();
  90.     this.updateOpen();
  91.     this.updateClose();
  92.     this.updateBackgroundDimmer();
  93. };

  94. Window_Base.prototype.updateOpen = function() {
  95.     if (this._opening) {
  96.         this.openness += 32;
  97.         if (this.isOpen()) {
  98.             this._opening = false;
  99.         }
  100.     }
  101. };

  102. Window_Base.prototype.updateClose = function() {
  103.     if (this._closing) {
  104.         this.openness -= 32;
  105.         if (this.isClosed()) {
  106.             this._closing = false;
  107.         }
  108.     }
  109. };

  110. Window_Base.prototype.open = function() {
  111.     if (!this.isOpen()) {
  112.         this._opening = true;
  113.     }
  114.     this._closing = false;
  115. };

  116. Window_Base.prototype.close = function() {
  117.     if (!this.isClosed()) {
  118.         this._closing = true;
  119.     }
  120.     this._opening = false;
  121. };

  122. Window_Base.prototype.isOpening = function() {
  123.     return this._opening;
  124. };

  125. Window_Base.prototype.isClosing = function() {
  126.     return this._closing;
  127. };

  128. Window_Base.prototype.show = function() {
  129.     this.visible = true;
  130. };

  131. Window_Base.prototype.hide = function() {
  132.     this.visible = false;
  133. };

  134. Window_Base.prototype.activate = function() {
  135.     this.active = true;
  136. };

  137. Window_Base.prototype.deactivate = function() {
  138.     this.active = false;
  139. };

  140. Window_Base.prototype.textColor = function(n) {
  141.     var px = 96 + (n % 8) * 12 + 6;
  142.     var py = 144 + Math.floor(n / 8) * 12 + 6;
  143.     return this.windowskin.getPixel(px, py);
  144. };

  145. Window_Base.prototype.normalColor = function() {
  146.     return this.textColor(0);
  147. };

  148. Window_Base.prototype.systemColor = function() {
  149.     return this.textColor(16);
  150. };

  151. Window_Base.prototype.crisisColor = function() {
  152.     return this.textColor(17);
  153. };

  154. Window_Base.prototype.deathColor = function() {
  155.     return this.textColor(18);
  156. };

  157. Window_Base.prototype.gaugeBackColor = function() {
  158.     return this.textColor(19);
  159. };

  160. Window_Base.prototype.hpGaugeColor1 = function() {
  161.     return this.textColor(20);
  162. };

  163. Window_Base.prototype.hpGaugeColor2 = function() {
  164.     return this.textColor(21);
  165. };

  166. Window_Base.prototype.mpGaugeColor1 = function() {
  167.     return this.textColor(22);
  168. };

  169. Window_Base.prototype.mpGaugeColor2 = function() {
  170.     return this.textColor(23);
  171. };

  172. Window_Base.prototype.mpCostColor = function() {
  173.     return this.textColor(23);
  174. };

  175. Window_Base.prototype.powerUpColor = function() {
  176.     return this.textColor(24);
  177. };

  178. Window_Base.prototype.powerDownColor = function() {
  179.     return this.textColor(25);
  180. };

  181. Window_Base.prototype.tpGaugeColor1 = function() {
  182.     return this.textColor(28);
  183. };

  184. Window_Base.prototype.tpGaugeColor2 = function() {
  185.     return this.textColor(29);
  186. };

  187. Window_Base.prototype.tpCostColor = function() {
  188.     return this.textColor(29);
  189. };

  190. Window_Base.prototype.pendingColor = function() {
  191.     return this.windowskin.getPixel(120, 120);
  192. };

  193. Window_Base.prototype.translucentOpacity = function() {
  194.     return 160;
  195. };

  196. Window_Base.prototype.changeTextColor = function(color) {
  197.     this.contents.textColor = color;
  198. };

  199. Window_Base.prototype.changePaintOpacity = function(enabled) {
  200.     this.contents.paintOpacity = enabled ? 255 : this.translucentOpacity();
  201. };

  202. Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
  203.     this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
  204. };

  205. Window_Base.prototype.textWidth = function(text) {
  206.     return this.contents.measureTextWidth(text);
  207. };

  208. Window_Base.prototype.drawTextEx = function(text, x, y) {
  209.     if (text) {
  210.         var textState = { index: 0, x: x, y: y, left: x };
  211.         textState.text = this.convertEscapeCharacters(text);
  212.         textState.height = this.calcTextHeight(textState, false);
  213.         this.resetFontSettings();
  214.         while (textState.index < textState.text.length) {
  215.             this.processCharacter(textState);
  216.         }
  217.         return textState.x - x;
  218.     } else {
  219.         return 0;
  220.     }
  221. };

  222. Window_Base.prototype.convertEscapeCharacters = function(text) {
  223.     text = text.replace(/\\/g, '\x1b');
  224.     text = text.replace(/\x1b\x1b/g, '\\');
  225.     text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  226.         return $gameVariables.value(parseInt(arguments[1]));
  227.     }.bind(this));
  228.     text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  229.         return $gameVariables.value(parseInt(arguments[1]));
  230.     }.bind(this));
  231.     text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
  232.         return this.actorName(parseInt(arguments[1]));
  233.     }.bind(this));
  234.     text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
  235.         return this.partyMemberName(parseInt(arguments[1]));
  236.     }.bind(this));
  237.     text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
  238.     return text;
  239. };

  240. Window_Base.prototype.actorName = function(n) {
  241.     var actor = n >= 1 ? $gameActors.actor(n) : null;
  242.     return actor ? actor.name() : '';
  243. };

  244. Window_Base.prototype.partyMemberName = function(n) {
  245.     var actor = n >= 1 ? $gameParty.members()[n - 1] : null;
  246.     return actor ? actor.name() : '';
  247. };

  248. Window_Base.prototype.processCharacter = function(textState) {
  249.     switch (textState.text[textState.index]) {
  250.     case '\n':
  251.         this.processNewLine(textState);
  252.         break;
  253.     case '\f':
  254.         this.processNewPage(textState);
  255.         break;
  256.     case '\x1b':
  257.         this.processEscapeCharacter(this.obtainEscapeCode(textState), textState);
  258.         break;
  259.     default:
  260.         this.processNormalCharacter(textState);
  261.         break;
  262.     }
  263. };

  264. Window_Base.prototype.processNormalCharacter = function(textState) {
  265.     var c = textState.text[textState.index++];
  266.     var w = this.textWidth(c);
  267.     this.contents.drawText(c, textState.x, textState.y, w * 2, textState.height);
  268.     textState.x += w;
  269. };

  270. Window_Base.prototype.processNewLine = function(textState) {
  271.     textState.x = textState.left;
  272.     textState.y += textState.height;
  273.     textState.height = this.calcTextHeight(textState, false);
  274.     textState.index++;
  275. };

  276. Window_Base.prototype.processNewPage = function(textState) {
  277.     textState.index++;
  278. };

  279. Window_Base.prototype.obtainEscapeCode = function(textState) {
  280.     textState.index++;
  281.     var regExp = /^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i;
  282.     var arr = regExp.exec(textState.text.slice(textState.index));
  283.     if (arr) {
  284.         textState.index += arr[0].length;
  285.         return arr[0].toUpperCase();
  286.     } else {
  287.         return '';
  288.     }
  289. };

  290. Window_Base.prototype.obtainEscapeParam = function(textState) {
  291.     var arr = /^\[\d+\]/.exec(textState.text.slice(textState.index));
  292.     if (arr) {
  293.         textState.index += arr[0].length;
  294.         return parseInt(arr[0].slice(1));
  295.     } else {
  296.         return '';
  297.     }
  298. };

  299. Window_Base.prototype.processEscapeCharacter = function(code, textState) {
  300.     switch (code) {
  301.     case 'C':
  302.         this.changeTextColor(this.textColor(this.obtainEscapeParam(textState)));
  303.         break;
  304.     case 'I':
  305.         this.processDrawIcon(this.obtainEscapeParam(textState), textState);
  306.         break;
  307.     case '{':
  308.         this.makeFontBigger();
  309.         break;
  310.     case '}':
  311.         this.makeFontSmaller();
  312.         break;
  313.     }
  314. };

  315. Window_Base.prototype.processDrawIcon = function(iconIndex, textState) {
  316.     this.drawIcon(iconIndex, textState.x + 2, textState.y + 2);
  317.     textState.x += Window_Base._iconWidth + 4;
  318. };

  319. Window_Base.prototype.makeFontBigger = function() {
  320.     if (this.contents.fontSize <= 96) {
  321.         this.contents.fontSize += 12;
  322.     }
  323. };

  324. Window_Base.prototype.makeFontSmaller = function() {
  325.     if (this.contents.fontSize >= 24) {
  326.         this.contents.fontSize -= 12;
  327.     }
  328. };

  329. Window_Base.prototype.calcTextHeight = function(textState, all) {
  330.     var lastFontSize = this.contents.fontSize;
  331.     var textHeight = 0;
  332.     var lines = textState.text.slice(textState.index).split('\n');
  333.     var maxLines = all ? lines.length : 1;

  334.     for (var i = 0; i < maxLines; i++) {
  335.         var maxFontSize = this.contents.fontSize;
  336.         var regExp = /\x1b[\{\}]/g;
  337.         for (;;) {
  338.             var array = regExp.exec(lines[i]);
  339.             if (array) {
  340.                 if (array[0] === '\x1b{') {
  341.                     this.makeFontBigger();
  342.                 }
  343.                 if (array[0] === '\x1b}') {
  344.                     this.makeFontSmaller();
  345.                 }
  346.                 if (maxFontSize < this.contents.fontSize) {
  347.                     maxFontSize = this.contents.fontSize;
  348.                 }
  349.             } else {
  350.                 break;
  351.             }
  352.         }
  353.         textHeight += maxFontSize + 8;
  354.     }

  355.     this.contents.fontSize = lastFontSize;
  356.     return textHeight;
  357. };

  358. Window_Base.prototype.drawIcon = function(iconIndex, x, y) {
  359.     var bitmap = ImageManager.loadSystem('IconSet');
  360.     var pw = Window_Base._iconWidth;
  361.     var ph = Window_Base._iconHeight;
  362.     var sx = iconIndex % 16 * pw;
  363.     var sy = Math.floor(iconIndex / 16) * ph;
  364.     this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
  365. };

  366. Window_Base.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
  367.     width = width || Window_Base._faceWidth;
  368.     height = height || Window_Base._faceHeight;
  369.     var bitmap = ImageManager.loadFace(faceName);
  370.     var pw = Window_Base._faceWidth;
  371.     var ph = Window_Base._faceHeight;
  372.     var sw = Math.min(width, pw);
  373.     var sh = Math.min(height, ph);
  374.     var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
  375.     var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
  376.     var sx = faceIndex % 4 * pw + (pw - sw) / 2;
  377.     var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
  378.     this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy);
  379. };

  380. Window_Base.prototype.drawCharacter = function(characterName, characterIndex, x, y) {
  381.     var bitmap = ImageManager.loadCharacter(characterName);
  382.     var big = ImageManager.isBigCharacter(characterName);
  383.     var pw = bitmap.width / (big ? 3 : 12);
  384.     var ph = bitmap.height / (big ? 4 : 8);
  385.     var n = characterIndex;
  386.     var sx = (n % 4 * 3 + 1) * pw;
  387.     var sy = (Math.floor(n / 4) * 4) * ph;
  388.     this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
  389. };

  390. Window_Base.prototype.drawGauge = function(x, y, width, rate, color1, color2) {
  391.     var fillW = Math.floor(width * rate);
  392.     var gaugeY = y + this.lineHeight() - 8;
  393.     this.contents.fillRect(x, gaugeY, width, 6, this.gaugeBackColor());
  394.     this.contents.gradientFillRect(x, gaugeY, fillW, 6, color1, color2);
  395. };

  396. Window_Base.prototype.hpColor = function(actor) {
  397.     if (actor.isDead()) {
  398.         return this.deathColor();
  399.     } else if (actor.isDying()) {
  400.         return this.crisisColor();
  401.     } else {
  402.         return this.normalColor();
  403.     }
  404. };

  405. Window_Base.prototype.mpColor = function(actor) {
  406.     return this.normalColor();
  407. };

  408. Window_Base.prototype.tpColor = function(actor) {
  409.     return this.normalColor();
  410. };

  411. Window_Base.prototype.drawActorCharacter = function(actor, x, y) {
  412.     this.drawCharacter(actor.characterName(), actor.characterIndex(), x, y);
  413. };

  414. Window_Base.prototype.drawActorFace = function(actor, x, y, width, height) {
  415.     this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height);
  416. };

  417. Window_Base.prototype.drawActorName = function(actor, x, y, width) {
  418.     width = width || 168;
  419.     this.changeTextColor(this.hpColor(actor));
  420.     this.drawText(actor.name(), x, y, width);
  421. };

  422. Window_Base.prototype.drawActorClass = function(actor, x, y, width) {
  423.     width = width || 168;
  424.     this.resetTextColor();
  425.     this.drawText(actor.currentClass().name, x, y, width);
  426. };

  427. Window_Base.prototype.drawActorNickname = function(actor, x, y, width) {
  428.     width = width || 270;
  429.     this.resetTextColor();
  430.     this.drawText(actor.nickname(), x, y, width);
  431. };

  432. Window_Base.prototype.drawActorLevel = function(actor, x, y) {
  433.     this.changeTextColor(this.systemColor());
  434.     this.drawText(TextManager.levelA, x, y, 48);
  435.     this.resetTextColor();
  436.     this.drawText(actor.level, x + 84, y, 36, 'right');
  437. };

  438. Window_Base.prototype.drawActorIcons = function(actor, x, y, width) {
  439.     width = width || 144;
  440.     var icons = actor.allIcons().slice(0, Math.floor(width / Window_Base._iconWidth));
  441.     for (var i = 0; i < icons.length; i++) {
  442.         this.drawIcon(icons[i], x + Window_Base._iconWidth * i, y + 2);
  443.     }
  444. };

  445. Window_Base.prototype.drawCurrentAndMax = function(current, max, x, y,
  446.                                                    width, color1, color2) {
  447.     var labelWidth = this.textWidth('HP');
  448.     var valueWidth = this.textWidth('0000');
  449.     var slashWidth = this.textWidth('/');
  450.     var x1 = x + width - valueWidth;
  451.     var x2 = x1 - slashWidth;
  452.     var x3 = x2 - valueWidth;
  453.     if (x3 >= x + labelWidth) {
  454.         this.changeTextColor(color1);
  455.         this.drawText(current, x3, y, valueWidth, 'right');
  456.         this.changeTextColor(color2);
  457.         this.drawText('/', x2, y, slashWidth, 'right');
  458.         this.drawText(max, x1, y, valueWidth, 'right');
  459.     } else {
  460.         this.changeTextColor(color1);
  461.         this.drawText(current, x1, y, valueWidth, 'right');
  462.     }
  463. };

  464. Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
  465.     width = width || 186;
  466.    
  467.     var color1 = this.hpGaugeColor1();
  468.     var color2 = this.hpGaugeColor2();
  469.     this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
  470.     this.changeTextColor(this.systemColor());
  471.     this.drawText(TextManager.hpA, x, y, 44);
  472.     this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
  473.                            this.hpColor(actor), this.normalColor());
  474. };

  475. Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
  476.     width = width || 186;
  477.     var color1 = this.mpGaugeColor1();
  478.     var color2 = this.mpGaugeColor2();
  479.     this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
  480.     this.changeTextColor(this.systemColor());
  481.     this.drawText(TextManager.mpA, x, y, 44);
  482.     this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
  483.                            this.mpColor(actor), this.normalColor());
  484. };

  485. Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  486.     width = width || 96;
  487.     var color1 = this.tpGaugeColor1();
  488.     var color2 = this.tpGaugeColor2();
  489.     this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
  490.     this.changeTextColor(this.systemColor());
  491.     this.drawText(TextManager.tpA, x, y, 44);
  492.     this.changeTextColor(this.tpColor(actor));
  493.     this.drawText(actor.tp, x + width - 64, y, 64, 'right');
  494. };

  495. Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
  496.     var lineHeight = this.lineHeight();
  497.     var x2 = x + 180;
  498.     var width2 = Math.min(200, width - 180 - this.textPadding());
  499.     this.drawActorName(actor, x, y);
  500.     this.drawActorLevel(actor, x, y + lineHeight * 1);
  501.     this.drawActorIcons(actor, x, y + lineHeight * 2);
  502.     this.drawActorClass(actor, x2, y);
  503.     this.drawActorHp(actor, x2, y + lineHeight * 1, width2);
  504.     this.drawActorMp(actor, x2, y + lineHeight * 2, width2);
  505. };

  506. Window_Base.prototype.drawItemName = function(item, x, y, width) {
  507.     width = width || 312;
  508.     if (item) {
  509.         var iconBoxWidth = Window_Base._iconWidth + 4;
  510.         this.resetTextColor();
  511.         this.drawIcon(item.iconIndex, x + 2, y + 2);
  512.         this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  513.     }
  514. };

  515. Window_Base.prototype.drawCurrencyValue = function(value, unit, x, y, width) {
  516.     var unitWidth = Math.min(80, this.textWidth(unit));
  517.     this.resetTextColor();
  518.     this.drawText(value, x, y, width - unitWidth - 6, 'right');
  519.     this.changeTextColor(this.systemColor());
  520.     this.drawText(unit, x + width - unitWidth, y, unitWidth, 'right');
  521. };

  522. Window_Base.prototype.paramchangeTextColor = function(change) {
  523.     if (change > 0) {
  524.         return this.powerUpColor();
  525.     } else if (change < 0) {
  526.         return this.powerDownColor();
  527.     } else {
  528.         return this.normalColor();
  529.     }
  530. };

  531. Window_Base.prototype.setBackgroundType = function(type) {
  532.     if (type === 0) {
  533.         this.opacity = 255;
  534.     } else {
  535.         this.opacity = 0;
  536.     }
  537.     if (type === 1) {
  538.         this.showBackgroundDimmer();
  539.     } else {
  540.         this.hideBackgroundDimmer();
  541.     }
  542. };

  543. Window_Base.prototype.showBackgroundDimmer = function() {
  544.     if (!this._dimmerSprite) {
  545.         this._dimmerSprite = new Sprite();
  546.         this._dimmerSprite.bitmap = new Bitmap(0, 0);
  547.         this.addChildToBack(this._dimmerSprite);
  548.     }
  549.     var bitmap = this._dimmerSprite.bitmap;
  550.     if (bitmap.width !== this.width || bitmap.height !== this.height) {
  551.         this.refreshDimmerBitmap();
  552.     }
  553.     this._dimmerSprite.visible = true;
  554.     this.updateBackgroundDimmer();
  555. };

  556. Window_Base.prototype.hideBackgroundDimmer = function() {
  557.     if (this._dimmerSprite) {
  558.         this._dimmerSprite.visible = false;
  559.     }
  560. };

  561. Window_Base.prototype.updateBackgroundDimmer = function() {
  562.     if (this._dimmerSprite) {
  563.         this._dimmerSprite.opacity = this.openness;
  564.     }
  565. };

  566. Window_Base.prototype.refreshDimmerBitmap = function() {
  567.     if (this._dimmerSprite) {
  568.         var bitmap = this._dimmerSprite.bitmap;
  569.         var w = this.width;
  570.         var h = this.height;
  571.         var m = this.padding;
  572.         var c1 = this.dimColor1();
  573.         var c2 = this.dimColor2();
  574.         bitmap.resize(w, h);
  575.         bitmap.gradientFillRect(0, 0, w, m, c2, c1, true);
  576.         bitmap.fillRect(0, m, w, h - m * 2, c1);
  577.         bitmap.gradientFillRect(0, h - m, w, m, c1, c2, true);
  578.         this._dimmerSprite.setFrame(0, 0, w, h);
  579.     }
  580. };

  581. Window_Base.prototype.dimColor1 = function() {
  582.     return 'rgba(0, 0, 0, 0.6)';
  583. };

  584. Window_Base.prototype.dimColor2 = function() {
  585.     return 'rgba(0, 0, 0, 0)';
  586. };

  587. Window_Base.prototype.canvasToLocalX = function(x) {
  588.     var node = this;
  589.     while (node) {
  590.         x -= node.x;
  591.         node = node.parent;
  592.     }
  593.     return x;
  594. };

  595. Window_Base.prototype.canvasToLocalY = function(y) {
  596.     var node = this;
  597.     while (node) {
  598.         y -= node.y;
  599.         node = node.parent;
  600.     }
  601.     return y;
  602. };

  603. Window_Base.prototype.reserveFaceImages = function() {
  604.     $gameParty.members().forEach(function(actor) {
  605.         ImageManager.reserveFace(actor.faceName());
  606.     }, this);
  607. };

  608. //-----------------------------------------------------------------------------
  609. // Window_Selectable
  610. //
  611. // The window class with cursor movement and scroll functions.

  612. function Window_Selectable() {
  613.     this.initialize.apply(this, arguments);
  614. }

  615. Window_Selectable.prototype = Object.create(Window_Base.prototype);
  616. Window_Selectable.prototype.constructor = Window_Selectable;

  617. Window_Selectable.prototype.initialize = function(x, y, width, height) {
  618.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  619.     this._index = -1;
  620.     this._cursorFixed = false;
  621.     this._cursorAll = false;
  622.     this._stayCount = 0;
  623.     this._helpWindow = null;
  624.     this._handlers = {};
  625.     this._touching = false;
  626.     this._scrollX = 0;
  627.     this._scrollY = 0;
  628.     this.deactivate();
  629. };

  630. Window_Selectable.prototype.index = function() {
  631.     return this._index;
  632. };

  633. Window_Selectable.prototype.cursorFixed = function() {
  634.     return this._cursorFixed;
  635. };

  636. Window_Selectable.prototype.setCursorFixed = function(cursorFixed) {
  637.     this._cursorFixed = cursorFixed;
  638. };

  639. Window_Selectable.prototype.cursorAll = function() {
  640.     return this._cursorAll;
  641. };

  642. Window_Selectable.prototype.setCursorAll = function(cursorAll) {
  643.     this._cursorAll = cursorAll;
  644. };

  645. Window_Selectable.prototype.maxCols = function() {
  646.     return 1;
  647. };

  648. Window_Selectable.prototype.maxItems = function() {
  649.     return 0;
  650. };

  651. Window_Selectable.prototype.spacing = function() {
  652.     return 12;
  653. };

  654. Window_Selectable.prototype.itemWidth = function() {
  655.     return Math.floor((this.width - this.padding * 2 +
  656.                        this.spacing()) / this.maxCols() - this.spacing());
  657. };

  658. Window_Selectable.prototype.itemHeight = function() {
  659.     return this.lineHeight();
  660. };

  661. Window_Selectable.prototype.maxRows = function() {
  662.     return Math.max(Math.ceil(this.maxItems() / this.maxCols()), 1);
  663. };

  664. Window_Selectable.prototype.activate = function() {
  665.     Window_Base.prototype.activate.call(this);
  666.     this.reselect();
  667. };

  668. Window_Selectable.prototype.deactivate = function() {
  669.     Window_Base.prototype.deactivate.call(this);
  670.     this.reselect();
  671. };

  672. Window_Selectable.prototype.select = function(index) {
  673.     this._index = index;
  674.     this._stayCount = 0;
  675.     this.ensureCursorVisible();
  676.     this.updateCursor();
  677.     this.callUpdateHelp();
  678. };

  679. Window_Selectable.prototype.deselect = function() {
  680.     this.select(-1);
  681. };

  682. Window_Selectable.prototype.reselect = function() {
  683.     this.select(this._index);
  684. };

  685. Window_Selectable.prototype.row = function() {
  686.     return Math.floor(this.index() / this.maxCols());
  687. };

  688. Window_Selectable.prototype.topRow = function() {
  689.     return Math.floor(this._scrollY / this.itemHeight());
  690. };

  691. Window_Selectable.prototype.maxTopRow = function() {
  692.     return Math.max(0, this.maxRows() - this.maxPageRows());
  693. };

  694. Window_Selectable.prototype.setTopRow = function(row) {
  695.     var scrollY = row.clamp(0, this.maxTopRow()) * this.itemHeight();
  696.     if (this._scrollY !== scrollY) {
  697.         this._scrollY = scrollY;
  698.         this.refresh();
  699.         this.updateCursor();
  700.     }
  701. };

  702. Window_Selectable.prototype.resetScroll = function() {
  703.     this.setTopRow(0);
  704. };

  705. Window_Selectable.prototype.maxPageRows = function() {
  706.     var pageHeight = this.height - this.padding * 2;
  707.     return Math.floor(pageHeight / this.itemHeight());
  708. };

  709. Window_Selectable.prototype.maxPageItems = function() {
  710.     return this.maxPageRows() * this.maxCols();
  711. };

  712. Window_Selectable.prototype.isHorizontal = function() {
  713.     return this.maxPageRows() === 1;
  714. };

  715. Window_Selectable.prototype.bottomRow = function() {
  716.     return Math.max(0, this.topRow() + this.maxPageRows() - 1);
  717. };

  718. Window_Selectable.prototype.setBottomRow = function(row) {
  719.     this.setTopRow(row - (this.maxPageRows() - 1));
  720. };

  721. Window_Selectable.prototype.topIndex = function() {
  722.     return this.topRow() * this.maxCols();
  723. };

  724. Window_Selectable.prototype.itemRect = function(index) {
  725.     var rect = new Rectangle();
  726.     var maxCols = this.maxCols();
  727.     rect.width = this.itemWidth();
  728.     rect.height = this.itemHeight();
  729.     rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
  730.     rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY;
  731.     return rect;
  732. };

  733. Window_Selectable.prototype.itemRectForText = function(index) {
  734.     var rect = this.itemRect(index);
  735.     rect.x += this.textPadding();
  736.     rect.width -= this.textPadding() * 2;
  737.     return rect;
  738. };

  739. Window_Selectable.prototype.setHelpWindow = function(helpWindow) {
  740.     this._helpWindow = helpWindow;
  741.     this.callUpdateHelp();
  742. };

  743. Window_Selectable.prototype.showHelpWindow = function() {
  744.     if (this._helpWindow) {
  745.         this._helpWindow.show();
  746.     }
  747. };

  748. Window_Selectable.prototype.hideHelpWindow = function() {
  749.     if (this._helpWindow) {
  750.         this._helpWindow.hide();
  751.     }
  752. };

  753. Window_Selectable.prototype.setHandler = function(symbol, method) {
  754.     this._handlers[symbol] = method;
  755. };

  756. Window_Selectable.prototype.isHandled = function(symbol) {
  757.     return !!this._handlers[symbol];
  758. };

  759. Window_Selectable.prototype.callHandler = function(symbol) {
  760.     if (this.isHandled(symbol)) {
  761.         this._handlers[symbol]();
  762.     }
  763. };

  764. Window_Selectable.prototype.isOpenAndActive = function() {
  765.     return this.isOpen() && this.active;
  766. };

  767. Window_Selectable.prototype.isCursorMovable = function() {
  768.     return (this.isOpenAndActive() && !this._cursorFixed &&
  769.             !this._cursorAll && this.maxItems() > 0);
  770. };

  771. Window_Selectable.prototype.cursorDown = function(wrap) {
  772.     var index = this.index();
  773.     var maxItems = this.maxItems();
  774.     var maxCols = this.maxCols();
  775.     if (index < maxItems - maxCols || (wrap && maxCols === 1)) {
  776.         this.select((index + maxCols) % maxItems);
  777.     }
  778. };

  779. Window_Selectable.prototype.cursorUp = function(wrap) {
  780.     var index = this.index();
  781.     var maxItems = this.maxItems();
  782.     var maxCols = this.maxCols();
  783.     if (index >= maxCols || (wrap && maxCols === 1)) {
  784.         this.select((index - maxCols + maxItems) % maxItems);
  785.     }
  786. };

  787. Window_Selectable.prototype.cursorRight = function(wrap) {
  788.     var index = this.index();
  789.     var maxItems = this.maxItems();
  790.     var maxCols = this.maxCols();
  791.     if (maxCols >= 2 && (index < maxItems - 1 || (wrap && this.isHorizontal()))) {
  792.         this.select((index + 1) % maxItems);
  793.     }
  794. };

  795. Window_Selectable.prototype.cursorLeft = function(wrap) {
  796.     var index = this.index();
  797.     var maxItems = this.maxItems();
  798.     var maxCols = this.maxCols();
  799.     if (maxCols >= 2 && (index > 0 || (wrap && this.isHorizontal()))) {
  800.         this.select((index - 1 + maxItems) % maxItems);
  801.     }
  802. };

  803. Window_Selectable.prototype.cursorPagedown = function() {
  804.     var index = this.index();
  805.     var maxItems = this.maxItems();
  806.     if (this.topRow() + this.maxPageRows() < this.maxRows()) {
  807.         this.setTopRow(this.topRow() + this.maxPageRows());
  808.         this.select(Math.min(index + this.maxPageItems(), maxItems - 1));
  809.     }
  810. };

  811. Window_Selectable.prototype.cursorPageup = function() {
  812.     var index = this.index();
  813.     if (this.topRow() > 0) {
  814.         this.setTopRow(this.topRow() - this.maxPageRows());
  815.         this.select(Math.max(index - this.maxPageItems(), 0));
  816.     }
  817. };

  818. Window_Selectable.prototype.scrollDown = function() {
  819.     if (this.topRow() + 1 < this.maxRows()) {
  820.         this.setTopRow(this.topRow() + 1);
  821.     }
  822. };

  823. Window_Selectable.prototype.scrollUp = function() {
  824.     if (this.topRow() > 0) {
  825.         this.setTopRow(this.topRow() - 1);
  826.     }
  827. };

  828. Window_Selectable.prototype.update = function() {
  829.     Window_Base.prototype.update.call(this);
  830.     this.updateArrows();
  831.     this.processCursorMove();
  832.     this.processHandling();
  833.     this.processWheel();
  834.     this.processTouch();
  835.     this._stayCount++;
  836. };

  837. Window_Selectable.prototype.updateArrows = function() {
  838.     var topRow = this.topRow();
  839.     var maxTopRow = this.maxTopRow();
  840.     this.downArrowVisible = maxTopRow > 0 && topRow < maxTopRow;
  841.     this.upArrowVisible = topRow > 0;
  842. };

  843. Window_Selectable.prototype.processCursorMove = function() {
  844.     if (this.isCursorMovable()) {
  845.         var lastIndex = this.index();
  846.         if (Input.isRepeated('down')) {
  847.             this.cursorDown(Input.isTriggered('down'));
  848.         }
  849.         if (Input.isRepeated('up')) {
  850.             this.cursorUp(Input.isTriggered('up'));
  851.         }
  852.         if (Input.isRepeated('right')) {
  853.             this.cursorRight(Input.isTriggered('right'));
  854.         }
  855.         if (Input.isRepeated('left')) {
  856.             this.cursorLeft(Input.isTriggered('left'));
  857.         }
  858.         if (!this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
  859.             this.cursorPagedown();
  860.         }
  861.         if (!this.isHandled('pageup') && Input.isTriggered('pageup')) {
  862.             this.cursorPageup();
  863.         }
  864.         if (this.index() !== lastIndex) {
  865.             SoundManager.playCursor();
  866.         }
  867.     }
  868. };

  869. Window_Selectable.prototype.processHandling = function() {
  870.     if (this.isOpenAndActive()) {
  871.         if (this.isOkEnabled() && this.isOkTriggered()) {
  872.             this.processOk();
  873.         } else if (this.isCancelEnabled() && this.isCancelTriggered()) {
  874.             this.processCancel();
  875.         } else if (this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
  876.             this.processPagedown();
  877.         } else if (this.isHandled('pageup') && Input.isTriggered('pageup')) {
  878.             this.processPageup();
  879.         }
  880.     }
  881. };

  882. Window_Selectable.prototype.processWheel = function() {
  883.     if (this.isOpenAndActive()) {
  884.         var threshold = 20;
  885.         if (TouchInput.wheelY >= threshold) {
  886.             this.scrollDown();
  887.         }
  888.         if (TouchInput.wheelY <= -threshold) {
  889.             this.scrollUp();
  890.         }
  891.     }
  892. };

  893. Window_Selectable.prototype.processTouch = function() {
  894.     if (this.isOpenAndActive()) {
  895.         if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  896.             this._touching = true;
  897.             this.onTouch(true);
  898.         } else if (TouchInput.isCancelled()) {
  899.             if (this.isCancelEnabled()) {
  900.                 this.processCancel();
  901.             }
  902.         }
  903.         if (this._touching) {
  904.             if (TouchInput.isPressed()) {
  905.                 this.onTouch(false);
  906.             } else {
  907.                 this._touching = false;
  908.             }
  909.         }
  910.     } else {
  911.         this._touching = false;
  912.     }
  913. };

  914. Window_Selectable.prototype.isTouchedInsideFrame = function() {
  915.     var x = this.canvasToLocalX(TouchInput.x);
  916.     var y = this.canvasToLocalY(TouchInput.y);
  917.     return x >= 0 && y >= 0 && x < this.width && y < this.height;
  918. };

  919. Window_Selectable.prototype.onTouch = function(triggered) {
  920.     var lastIndex = this.index();
  921.     var x = this.canvasToLocalX(TouchInput.x);
  922.     var y = this.canvasToLocalY(TouchInput.y);
  923.     var hitIndex = this.hitTest(x, y);
  924.     if (hitIndex >= 0) {
  925.         if (hitIndex === this.index()) {
  926.             if (triggered && this.isTouchOkEnabled()) {
  927.                 this.processOk();
  928.             }
  929.         } else if (this.isCursorMovable()) {
  930.             this.select(hitIndex);
  931.         }
  932.     } else if (this._stayCount >= 10) {
  933.         if (y < this.padding) {
  934.             this.cursorUp();
  935.         } else if (y >= this.height - this.padding) {
  936.             this.cursorDown();
  937.         }
  938.     }
  939.     if (this.index() !== lastIndex) {
  940.         SoundManager.playCursor();
  941.     }
  942. };

  943. Window_Selectable.prototype.hitTest = function(x, y) {
  944.     if (this.isContentsArea(x, y)) {
  945.         var cx = x - this.padding;
  946.         var cy = y - this.padding;
  947.         var topIndex = this.topIndex();
  948.         for (var i = 0; i < this.maxPageItems(); i++) {
  949.             var index = topIndex + i;
  950.             if (index < this.maxItems()) {
  951.                 var rect = this.itemRect(index);
  952.                 var right = rect.x + rect.width;
  953.                 var bottom = rect.y + rect.height;
  954.                 if (cx >= rect.x && cy >= rect.y && cx < right && cy < bottom) {
  955.                     return index;
  956.                 }
  957.             }
  958.         }
  959.     }
  960.     return -1;
  961. };

  962. Window_Selectable.prototype.isContentsArea = function(x, y) {
  963.     var left = this.padding;
  964.     var top = this.padding;
  965.     var right = this.width - this.padding;
  966.     var bottom = this.height - this.padding;
  967.     return (x >= left && y >= top && x < right && y < bottom);
  968. };

  969. Window_Selectable.prototype.isTouchOkEnabled = function() {
  970.     return this.isOkEnabled();
  971. };

  972. Window_Selectable.prototype.isOkEnabled = function() {
  973.     return this.isHandled('ok');
  974. };

  975. Window_Selectable.prototype.isCancelEnabled = function() {
  976.     return this.isHandled('cancel');
  977. };

  978. Window_Selectable.prototype.isOkTriggered = function() {
  979.     return Input.isRepeated('ok');
  980. };

  981. Window_Selectable.prototype.isCancelTriggered = function() {
  982.     return Input.isRepeated('cancel');
  983. };

  984. Window_Selectable.prototype.processOk = function() {
  985.     if (this.isCurrentItemEnabled()) {
  986.         this.playOkSound();
  987.         this.updateInputData();
  988.         this.deactivate();
  989.         this.callOkHandler();
  990.     } else {
  991.         this.playBuzzerSound();
  992.     }
  993. };

  994. Window_Selectable.prototype.playOkSound = function() {
  995.     SoundManager.playOk();
  996. };

  997. Window_Selectable.prototype.playBuzzerSound = function() {
  998.     SoundManager.playBuzzer();
  999. };

  1000. Window_Selectable.prototype.callOkHandler = function() {
  1001.     this.callHandler('ok');
  1002. };

  1003. Window_Selectable.prototype.processCancel = function() {
  1004.     SoundManager.playCancel();
  1005.     this.updateInputData();
  1006.     this.deactivate();
  1007.     this.callCancelHandler();
  1008. };

  1009. Window_Selectable.prototype.callCancelHandler = function() {
  1010.     this.callHandler('cancel');
  1011. };

  1012. Window_Selectable.prototype.processPageup = function() {
  1013.     SoundManager.playCursor();
  1014.     this.updateInputData();
  1015.     this.deactivate();
  1016.     this.callHandler('pageup');
  1017. };

  1018. Window_Selectable.prototype.processPagedown = function() {
  1019.     SoundManager.playCursor();
  1020.     this.updateInputData();
  1021.     this.deactivate();
  1022.     this.callHandler('pagedown');
  1023. };

  1024. Window_Selectable.prototype.updateInputData = function() {
  1025.     Input.update();
  1026.     TouchInput.update();
  1027. };

  1028. Window_Selectable.prototype.updateCursor = function() {
  1029.     if (this._cursorAll) {
  1030.         var allRowsHeight = this.maxRows() * this.itemHeight();
  1031.         this.setCursorRect(0, 0, this.contents.width, allRowsHeight);
  1032.         this.setTopRow(0);
  1033.     } else if (this.isCursorVisible()) {
  1034.         var rect = this.itemRect(this.index());
  1035.         this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  1036.     } else {
  1037.         this.setCursorRect(0, 0, 0, 0);
  1038.     }
  1039. };

  1040. Window_Selectable.prototype.isCursorVisible = function() {
  1041.     var row = this.row();
  1042.     return row >= this.topRow() && row <= this.bottomRow();
  1043. };

  1044. Window_Selectable.prototype.ensureCursorVisible = function() {
  1045.     var row = this.row();
  1046.     if (row < this.topRow()) {
  1047.         this.setTopRow(row);
  1048.     } else if (row > this.bottomRow()) {
  1049.         this.setBottomRow(row);
  1050.     }
  1051. };

  1052. Window_Selectable.prototype.callUpdateHelp = function() {
  1053.     if (this.active && this._helpWindow) {
  1054.         this.updateHelp();
  1055.     }
  1056. };

  1057. Window_Selectable.prototype.updateHelp = function() {
  1058.     this._helpWindow.clear();
  1059. };

  1060. Window_Selectable.prototype.setHelpWindowItem = function(item) {
  1061.     if (this._helpWindow) {
  1062.         this._helpWindow.setItem(item);
  1063.     }
  1064. };

  1065. Window_Selectable.prototype.isCurrentItemEnabled = function() {
  1066.     return true;
  1067. };

  1068. Window_Selectable.prototype.drawAllItems = function() {
  1069.     var topIndex = this.topIndex();
  1070.     for (var i = 0; i < this.maxPageItems(); i++) {
  1071.         var index = topIndex + i;
  1072.         if (index < this.maxItems()) {
  1073.             this.drawItem(index);
  1074.         }
  1075.     }
  1076. };

  1077. Window_Selectable.prototype.drawItem = function(index) {
  1078. };

  1079. Window_Selectable.prototype.clearItem = function(index) {
  1080.     var rect = this.itemRect(index);
  1081.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  1082. };

  1083. Window_Selectable.prototype.redrawItem = function(index) {
  1084.     if (index >= 0) {
  1085.         this.clearItem(index);
  1086.         this.drawItem(index);
  1087.     }
  1088. };

  1089. Window_Selectable.prototype.redrawCurrentItem = function() {
  1090.     this.redrawItem(this.index());
  1091. };

  1092. Window_Selectable.prototype.refresh = function() {
  1093.     if (this.contents) {
  1094.         this.contents.clear();
  1095.         this.drawAllItems();
  1096.     }
  1097. };

  1098. //-----------------------------------------------------------------------------
  1099. // Window_Command
  1100. //
  1101. // The superclass of windows for selecting a command.

  1102. function Window_Command() {
  1103.     this.initialize.apply(this, arguments);
  1104. }

  1105. Window_Command.prototype = Object.create(Window_Selectable.prototype);
  1106. Window_Command.prototype.constructor = Window_Command;

  1107. Window_Command.prototype.initialize = function(x, y) {
  1108.     this.clearCommandList();
  1109.     this.makeCommandList();
  1110.     var width = this.windowWidth();
  1111.     var height = this.windowHeight();
  1112.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1113.     this.refresh();
  1114.     this.select(0);
  1115.     this.activate();
  1116. };

  1117. Window_Command.prototype.windowWidth = function() {
  1118.     return 240;
  1119. };

  1120. Window_Command.prototype.windowHeight = function() {
  1121.     return this.fittingHeight(this.numVisibleRows());
  1122. };

  1123. Window_Command.prototype.numVisibleRows = function() {
  1124.     return Math.ceil(this.maxItems() / this.maxCols());
  1125. };

  1126. Window_Command.prototype.maxItems = function() {
  1127.     return this._list.length;
  1128. };

  1129. Window_Command.prototype.clearCommandList = function() {
  1130.     this._list = [];
  1131. };

  1132. Window_Command.prototype.makeCommandList = function() {
  1133. };

  1134. Window_Command.prototype.addCommand = function(name, symbol, enabled, ext) {
  1135.     if (enabled === undefined) {
  1136.         enabled = true;
  1137.     }
  1138.     if (ext === undefined) {
  1139.         ext = null;
  1140.     }
  1141.     this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext});
  1142. };

  1143. Window_Command.prototype.commandName = function(index) {
  1144.     return this._list[index].name;
  1145. };

  1146. Window_Command.prototype.commandSymbol = function(index) {
  1147.     return this._list[index].symbol;
  1148. };

  1149. Window_Command.prototype.isCommandEnabled = function(index) {
  1150.     return this._list[index].enabled;
  1151. };

  1152. Window_Command.prototype.currentData = function() {
  1153.     return this.index() >= 0 ? this._list[this.index()] : null;
  1154. };

  1155. Window_Command.prototype.isCurrentItemEnabled = function() {
  1156.     return this.currentData() ? this.currentData().enabled : false;
  1157. };

  1158. Window_Command.prototype.currentSymbol = function() {
  1159.     return this.currentData() ? this.currentData().symbol : null;
  1160. };

  1161. Window_Command.prototype.currentExt = function() {
  1162.     return this.currentData() ? this.currentData().ext : null;
  1163. };

  1164. Window_Command.prototype.findSymbol = function(symbol) {
  1165.     for (var i = 0; i < this._list.length; i++) {
  1166.         if (this._list[i].symbol === symbol) {
  1167.             return i;
  1168.         }
  1169.     }
  1170.     return -1;
  1171. };

  1172. Window_Command.prototype.selectSymbol = function(symbol) {
  1173.     var index = this.findSymbol(symbol);
  1174.     if (index >= 0) {
  1175.         this.select(index);
  1176.     } else {
  1177.         this.select(0);
  1178.     }
  1179. };

  1180. Window_Command.prototype.findExt = function(ext) {
  1181.     for (var i = 0; i < this._list.length; i++) {
  1182.         if (this._list[i].ext === ext) {
  1183.             return i;
  1184.         }
  1185.     }
  1186.     return -1;
  1187. };

  1188. Window_Command.prototype.selectExt = function(ext) {
  1189.     var index = this.findExt(ext);
  1190.     if (index >= 0) {
  1191.         this.select(index);
  1192.     } else {
  1193.         this.select(0);
  1194.     }
  1195. };

  1196. Window_Command.prototype.drawItem = function(index) {
  1197.     var rect = this.itemRectForText(index);
  1198.     var align = this.itemTextAlign();
  1199.     this.resetTextColor();
  1200.     this.changePaintOpacity(this.isCommandEnabled(index));
  1201.     this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align);
  1202. };

  1203. Window_Command.prototype.itemTextAlign = function() {
  1204.     return 'left';
  1205. };

  1206. Window_Command.prototype.isOkEnabled = function() {
  1207.     return true;
  1208. };

  1209. Window_Command.prototype.callOkHandler = function() {
  1210.     var symbol = this.currentSymbol();
  1211.     if (this.isHandled(symbol)) {
  1212.         this.callHandler(symbol);
  1213.     } else if (this.isHandled('ok')) {
  1214.         Window_Selectable.prototype.callOkHandler.call(this);
  1215.     } else {
  1216.         this.activate();
  1217.     }
  1218. };

  1219. Window_Command.prototype.refresh = function() {
  1220.     this.clearCommandList();
  1221.     this.makeCommandList();
  1222.     this.createContents();
  1223.     Window_Selectable.prototype.refresh.call(this);
  1224. };

  1225. //-----------------------------------------------------------------------------
  1226. // Window_HorzCommand
  1227. //
  1228. // The command window for the horizontal selection format.

  1229. function Window_HorzCommand() {
  1230.     this.initialize.apply(this, arguments);
  1231. }

  1232. Window_HorzCommand.prototype = Object.create(Window_Command.prototype);
  1233. Window_HorzCommand.prototype.constructor = Window_HorzCommand;

  1234. Window_HorzCommand.prototype.initialize = function(x, y) {
  1235.     Window_Command.prototype.initialize.call(this, x, y);
  1236. };

  1237. Window_HorzCommand.prototype.numVisibleRows = function() {
  1238.     return 1;
  1239. };

  1240. Window_HorzCommand.prototype.maxCols = function() {
  1241.     return 4;
  1242. };

  1243. Window_HorzCommand.prototype.itemTextAlign = function() {
  1244.     return 'center';
  1245. };

  1246. //-----------------------------------------------------------------------------
  1247. // Window_Help
  1248. //
  1249. // The window for displaying the description of the selected item.

  1250. function Window_Help() {
  1251.     this.initialize.apply(this, arguments);
  1252. }

  1253. Window_Help.prototype = Object.create(Window_Base.prototype);
  1254. Window_Help.prototype.constructor = Window_Help;

  1255. Window_Help.prototype.initialize = function(numLines) {
  1256.     var width = Graphics.boxWidth;
  1257.     var height = this.fittingHeight(numLines || 2);
  1258.     Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  1259.     this._text = '';
  1260. };

  1261. Window_Help.prototype.setText = function(text) {
  1262.     if (this._text !== text) {
  1263.         this._text = text;
  1264.         this.refresh();
  1265.     }
  1266. };

  1267. Window_Help.prototype.clear = function() {
  1268.     this.setText('');
  1269. };

  1270. Window_Help.prototype.setItem = function(item) {
  1271.     this.setText(item ? item.description : '');
  1272. };

  1273. Window_Help.prototype.refresh = function() {
  1274.     this.contents.clear();
  1275.     this.drawTextEx(this._text, this.textPadding(), 0);
  1276. };

  1277. //-----------------------------------------------------------------------------
  1278. // Window_Gold
  1279. //
  1280. // The window for displaying the party's gold.

  1281. function Window_Gold() {
  1282.     this.initialize.apply(this, arguments);
  1283. }

  1284. Window_Gold.prototype = Object.create(Window_Base.prototype);
  1285. Window_Gold.prototype.constructor = Window_Gold;

  1286. Window_Gold.prototype.initialize = function(x, y) {
  1287.     var width = this.windowWidth();
  1288.     var height = this.windowHeight();
  1289.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  1290.     this.refresh();
  1291. };

  1292. Window_Gold.prototype.windowWidth = function() {
  1293.     return 240;
  1294. };

  1295. Window_Gold.prototype.windowHeight = function() {
  1296.     return this.fittingHeight(1);
  1297. };

  1298. Window_Gold.prototype.refresh = function() {
  1299.     var x = this.textPadding();
  1300.     var width = this.contents.width - this.textPadding() * 2;
  1301.     this.contents.clear();
  1302.     this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 0, width);
  1303. };

  1304. Window_Gold.prototype.value = function() {
  1305.     return $gameParty.gold();
  1306. };

  1307. Window_Gold.prototype.currencyUnit = function() {
  1308.     return TextManager.currencyUnit;
  1309. };

  1310. Window_Gold.prototype.open = function() {
  1311.     this.refresh();
  1312.     Window_Base.prototype.open.call(this);
  1313. };

  1314. //-----------------------------------------------------------------------------
  1315. // Window_MenuCommand
  1316. //
  1317. // The window for selecting a command on the menu screen.

  1318. function Window_MenuCommand() {
  1319.     this.initialize.apply(this, arguments);
  1320. }

  1321. Window_MenuCommand.prototype = Object.create(Window_Command.prototype);
  1322. Window_MenuCommand.prototype.constructor = Window_MenuCommand;

  1323. Window_MenuCommand.prototype.initialize = function(x, y) {
  1324.     Window_Command.prototype.initialize.call(this, x, y);
  1325.     this.selectLast();
  1326. };

  1327. Window_MenuCommand._lastCommandSymbol = null;

  1328. Window_MenuCommand.initCommandPosition = function() {
  1329.     this._lastCommandSymbol = null;
  1330. };

  1331. Window_MenuCommand.prototype.windowWidth = function() {
  1332.     return 240;
  1333. };

  1334. Window_MenuCommand.prototype.numVisibleRows = function() {
  1335.     return this.maxItems();
  1336. };

  1337. Window_MenuCommand.prototype.makeCommandList = function() {
  1338.     this.addMainCommands();
  1339.     this.addFormationCommand();
  1340.     this.addOriginalCommands();
  1341.     this.addOptionsCommand();
  1342.     this.addSaveCommand();
  1343.     this.addGameEndCommand();
  1344. };

  1345. Window_MenuCommand.prototype.addMainCommands = function() {
  1346.     var enabled = this.areMainCommandsEnabled();
  1347.     if (this.needsCommand('item')) {
  1348.         this.addCommand(TextManager.item, 'item', enabled);
  1349.     }
  1350.     if (this.needsCommand('skill')) {
  1351.         this.addCommand(TextManager.skill, 'skill', enabled);
  1352.     }
  1353.     if (this.needsCommand('equip')) {
  1354.         this.addCommand(TextManager.equip, 'equip', enabled);
  1355.     }
  1356.     if (this.needsCommand('status')) {
  1357.         this.addCommand(TextManager.status, 'status', enabled);
  1358.     }
  1359. };

  1360. Window_MenuCommand.prototype.addFormationCommand = function() {
  1361.     if (this.needsCommand('formation')) {
  1362.         var enabled = this.isFormationEnabled();
  1363.         this.addCommand(TextManager.formation, 'formation', enabled);
  1364.     }
  1365. };

  1366. Window_MenuCommand.prototype.addOriginalCommands = function() {
  1367. };

  1368. Window_MenuCommand.prototype.addOptionsCommand = function() {
  1369.     if (this.needsCommand('options')) {
  1370.         var enabled = this.isOptionsEnabled();
  1371.         this.addCommand(TextManager.options, 'options', enabled);
  1372.     }
  1373. };

  1374. Window_MenuCommand.prototype.addSaveCommand = function() {
  1375.     if (this.needsCommand('save')) {
  1376.         var enabled = this.isSaveEnabled();
  1377.         this.addCommand(TextManager.save, 'save', enabled);
  1378.     }
  1379. };

  1380. Window_MenuCommand.prototype.addGameEndCommand = function() {
  1381.     var enabled = this.isGameEndEnabled();
  1382.     this.addCommand(TextManager.gameEnd, 'gameEnd', enabled);
  1383. };

  1384. Window_MenuCommand.prototype.needsCommand = function(name) {
  1385.     var flags = $dataSystem.menuCommands;
  1386.     if (flags) {
  1387.         switch (name) {
  1388.         case 'item':
  1389.             return flags[0];
  1390.         case 'skill':
  1391.             return flags[1];
  1392.         case 'equip':
  1393.             return flags[2];
  1394.         case 'status':
  1395.             return flags[3];
  1396.         case 'formation':
  1397.             return flags[4];
  1398.         case 'save':
  1399.             return flags[5];
  1400.         }
  1401.     }
  1402.     return true;
  1403. };

  1404. Window_MenuCommand.prototype.areMainCommandsEnabled = function() {
  1405.     return $gameParty.exists();
  1406. };

  1407. Window_MenuCommand.prototype.isFormationEnabled = function() {
  1408.     return $gameParty.size() >= 2 && $gameSystem.isFormationEnabled();
  1409. };

  1410. Window_MenuCommand.prototype.isOptionsEnabled = function() {
  1411.     return true;
  1412. };

  1413. Window_MenuCommand.prototype.isSaveEnabled = function() {
  1414.     return !DataManager.isEventTest() && $gameSystem.isSaveEnabled();
  1415. };

  1416. Window_MenuCommand.prototype.isGameEndEnabled = function() {
  1417.     return true;
  1418. };

  1419. Window_MenuCommand.prototype.processOk = function() {
  1420.     Window_MenuCommand._lastCommandSymbol = this.currentSymbol();
  1421.     Window_Command.prototype.processOk.call(this);
  1422. };

  1423. Window_MenuCommand.prototype.selectLast = function() {
  1424.     this.selectSymbol(Window_MenuCommand._lastCommandSymbol);
  1425. };

  1426. //-----------------------------------------------------------------------------
  1427. // Window_MenuStatus
  1428. //
  1429. // The window for displaying party member status on the menu screen.

  1430. function Window_MenuStatus() {
  1431.     this.initialize.apply(this, arguments);
  1432. }

  1433. Window_MenuStatus.prototype = Object.create(Window_Selectable.prototype);
  1434. Window_MenuStatus.prototype.constructor = Window_MenuStatus;

  1435. Window_MenuStatus.prototype.initialize = function(x, y) {
  1436.     var width = this.windowWidth();
  1437.     var height = this.windowHeight();
  1438.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1439.     this._formationMode = false;
  1440.     this._pendingIndex = -1;
  1441.     this.refresh();
  1442. };

  1443. Window_MenuStatus.prototype.windowWidth = function() {
  1444.     return Graphics.boxWidth - 240;
  1445. };

  1446. Window_MenuStatus.prototype.windowHeight = function() {
  1447.     return Graphics.boxHeight;
  1448. };

  1449. Window_MenuStatus.prototype.maxItems = function() {
  1450.     return $gameParty.size();
  1451. };

  1452. Window_MenuStatus.prototype.itemHeight = function() {
  1453.     var clientHeight = this.height - this.padding * 2;
  1454.     return Math.floor(clientHeight / this.numVisibleRows());
  1455. };

  1456. Window_MenuStatus.prototype.numVisibleRows = function() {
  1457.     return 4;
  1458. };

  1459. Window_MenuStatus.prototype.loadImages = function() {
  1460.     $gameParty.members().forEach(function(actor) {
  1461.         ImageManager.reserveFace(actor.faceName());
  1462.     }, this);
  1463. };

  1464. Window_MenuStatus.prototype.drawItem = function(index) {
  1465.     this.drawItemBackground(index);
  1466.     this.drawItemImage(index);
  1467.     this.drawItemStatus(index);
  1468. };

  1469. Window_MenuStatus.prototype.drawItemBackground = function(index) {
  1470.     if (index === this._pendingIndex) {
  1471.         var rect = this.itemRect(index);
  1472.         var color = this.pendingColor();
  1473.         this.changePaintOpacity(false);
  1474.         this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  1475.         this.changePaintOpacity(true);
  1476.     }
  1477. };

  1478. Window_MenuStatus.prototype.drawItemImage = function(index) {
  1479.     var actor = $gameParty.members()[index];
  1480.     var rect = this.itemRect(index);
  1481.     this.changePaintOpacity(actor.isBattleMember());
  1482.     this.drawActorFace(actor, rect.x + 1, rect.y + 1, Window_Base._faceWidth, Window_Base._faceHeight);
  1483.     this.changePaintOpacity(true);
  1484. };

  1485. Window_MenuStatus.prototype.drawItemStatus = function(index) {
  1486.     var actor = $gameParty.members()[index];
  1487.     var rect = this.itemRect(index);
  1488.     var x = rect.x + 162;
  1489.     var y = rect.y + rect.height / 2 - this.lineHeight() * 1.5;
  1490.     var width = rect.width - x - this.textPadding();
  1491.     this.drawActorSimpleStatus(actor, x, y, width);
  1492. };

  1493. Window_MenuStatus.prototype.processOk = function() {
  1494.     Window_Selectable.prototype.processOk.call(this);
  1495.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  1496. };

  1497. Window_MenuStatus.prototype.isCurrentItemEnabled = function() {
  1498.     if (this._formationMode) {
  1499.         var actor = $gameParty.members()[this.index()];
  1500.         return actor && actor.isFormationChangeOk();
  1501.     } else {
  1502.         return true;
  1503.     }
  1504. };

  1505. Window_MenuStatus.prototype.selectLast = function() {
  1506.     this.select($gameParty.menuActor().index() || 0);
  1507. };

  1508. Window_MenuStatus.prototype.formationMode = function() {
  1509.     return this._formationMode;
  1510. };

  1511. Window_MenuStatus.prototype.setFormationMode = function(formationMode) {
  1512.     this._formationMode = formationMode;
  1513. };

  1514. Window_MenuStatus.prototype.pendingIndex = function() {
  1515.     return this._pendingIndex;
  1516. };

  1517. Window_MenuStatus.prototype.setPendingIndex = function(index) {
  1518.     var lastPendingIndex = this._pendingIndex;
  1519.     this._pendingIndex = index;
  1520.     this.redrawItem(this._pendingIndex);
  1521.     this.redrawItem(lastPendingIndex);
  1522. };

  1523. //-----------------------------------------------------------------------------
  1524. // Window_MenuActor
  1525. //
  1526. // The window for selecting a target actor on the item and skill screens.

  1527. function Window_MenuActor() {
  1528.     this.initialize.apply(this, arguments);
  1529. }

  1530. Window_MenuActor.prototype = Object.create(Window_MenuStatus.prototype);
  1531. Window_MenuActor.prototype.constructor = Window_MenuActor;

  1532. Window_MenuActor.prototype.initialize = function() {
  1533.     Window_MenuStatus.prototype.initialize.call(this, 0, 0);
  1534.     this.hide();
  1535. };

  1536. Window_MenuActor.prototype.processOk = function() {
  1537.     if (!this.cursorAll()) {
  1538.         $gameParty.setTargetActor($gameParty.members()[this.index()]);
  1539.     }
  1540.     this.callOkHandler();
  1541. };

  1542. Window_MenuActor.prototype.selectLast = function() {
  1543.     this.select($gameParty.targetActor().index() || 0);
  1544. };

  1545. Window_MenuActor.prototype.selectForItem = function(item) {
  1546.     var actor = $gameParty.menuActor();
  1547.     var action = new Game_Action(actor);
  1548.     action.setItemObject(item);
  1549.     this.setCursorFixed(false);
  1550.     this.setCursorAll(false);
  1551.     if (action.isForUser()) {
  1552.         if (DataManager.isSkill(item)) {
  1553.             this.setCursorFixed(true);
  1554.             this.select(actor.index());
  1555.         } else {
  1556.             this.selectLast();
  1557.         }
  1558.     } else if (action.isForAll()) {
  1559.         this.setCursorAll(true);
  1560.         this.select(0);
  1561.     } else {
  1562.         this.selectLast();
  1563.     }
  1564. };

  1565. //-----------------------------------------------------------------------------
  1566. // Window_ItemCategory
  1567. //
  1568. // The window for selecting a category of items on the item and shop screens.

  1569. function Window_ItemCategory() {
  1570.     this.initialize.apply(this, arguments);
  1571. }

  1572. Window_ItemCategory.prototype = Object.create(Window_HorzCommand.prototype);
  1573. Window_ItemCategory.prototype.constructor = Window_ItemCategory;

  1574. Window_ItemCategory.prototype.initialize = function() {
  1575.     Window_HorzCommand.prototype.initialize.call(this, 0, 0);
  1576. };

  1577. Window_ItemCategory.prototype.windowWidth = function() {
  1578.     return Graphics.boxWidth;
  1579. };

  1580. Window_ItemCategory.prototype.maxCols = function() {
  1581.     return 4;
  1582. };

  1583. Window_ItemCategory.prototype.update = function() {
  1584.     Window_HorzCommand.prototype.update.call(this);
  1585.     if (this._itemWindow) {
  1586.         this._itemWindow.setCategory(this.currentSymbol());
  1587.     }
  1588. };

  1589. Window_ItemCategory.prototype.makeCommandList = function() {
  1590.     this.addCommand(TextManager.item,    'item');
  1591.     this.addCommand(TextManager.weapon,  'weapon');
  1592.     this.addCommand(TextManager.armor,   'armor');
  1593.     this.addCommand(TextManager.keyItem, 'keyItem');
  1594. };

  1595. Window_ItemCategory.prototype.setItemWindow = function(itemWindow) {
  1596.     this._itemWindow = itemWindow;
  1597. };

  1598. //-----------------------------------------------------------------------------
  1599. // Window_ItemList
  1600. //
  1601. // The window for selecting an item on the item screen.

  1602. function Window_ItemList() {
  1603.     this.initialize.apply(this, arguments);
  1604. }

  1605. Window_ItemList.prototype = Object.create(Window_Selectable.prototype);
  1606. Window_ItemList.prototype.constructor = Window_ItemList;

  1607. Window_ItemList.prototype.initialize = function(x, y, width, height) {
  1608.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1609.     this._category = 'none';
  1610.     this._data = [];
  1611. };

  1612. Window_ItemList.prototype.setCategory = function(category) {
  1613.     if (this._category !== category) {
  1614.         this._category = category;
  1615.         this.refresh();
  1616.         this.resetScroll();
  1617.     }
  1618. };

  1619. Window_ItemList.prototype.maxCols = function() {
  1620.     return 2;
  1621. };

  1622. Window_ItemList.prototype.spacing = function() {
  1623.     return 48;
  1624. };

  1625. Window_ItemList.prototype.maxItems = function() {
  1626.     return this._data ? this._data.length : 1;
  1627. };

  1628. Window_ItemList.prototype.item = function() {
  1629.     var index = this.index();
  1630.     return this._data && index >= 0 ? this._data[index] : null;
  1631. };

  1632. Window_ItemList.prototype.isCurrentItemEnabled = function() {
  1633.     return this.isEnabled(this.item());
  1634. };

  1635. Window_ItemList.prototype.includes = function(item) {
  1636.     switch (this._category) {
  1637.     case 'item':
  1638.         return DataManager.isItem(item) && item.itypeId === 1;
  1639.     case 'weapon':
  1640.         return DataManager.isWeapon(item);
  1641.     case 'armor':
  1642.         return DataManager.isArmor(item);
  1643.     case 'keyItem':
  1644.         return DataManager.isItem(item) && item.itypeId === 2;
  1645.     default:
  1646.         return false;
  1647.     }
  1648. };

  1649. Window_ItemList.prototype.needsNumber = function() {
  1650.     return true;
  1651. };

  1652. Window_ItemList.prototype.isEnabled = function(item) {
  1653.     return $gameParty.canUse(item);
  1654. };

  1655. Window_ItemList.prototype.makeItemList = function() {
  1656.     this._data = $gameParty.allItems().filter(function(item) {
  1657.         return this.includes(item);
  1658.     }, this);
  1659.     if (this.includes(null)) {
  1660.         this._data.push(null);
  1661.     }
  1662. };

  1663. Window_ItemList.prototype.selectLast = function() {
  1664.     var index = this._data.indexOf($gameParty.lastItem());
  1665.     this.select(index >= 0 ? index : 0);
  1666. };

  1667. Window_ItemList.prototype.drawItem = function(index) {
  1668.     var item = this._data[index];
  1669.     if (item) {
  1670.         var numberWidth = this.numberWidth();
  1671.         var rect = this.itemRect(index);
  1672.         rect.width -= this.textPadding();
  1673.         this.changePaintOpacity(this.isEnabled(item));
  1674.         this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
  1675.         this.drawItemNumber(item, rect.x, rect.y, rect.width);
  1676.         this.changePaintOpacity(1);
  1677.     }
  1678. };

  1679. Window_ItemList.prototype.numberWidth = function() {
  1680.     return this.textWidth('000');
  1681. };

  1682. Window_ItemList.prototype.drawItemNumber = function(item, x, y, width) {
  1683.     if (this.needsNumber()) {
  1684.         this.drawText(':', x, y, width - this.textWidth('00'), 'right');
  1685.         this.drawText($gameParty.numItems(item), x, y, width, 'right');
  1686.     }
  1687. };

  1688. Window_ItemList.prototype.updateHelp = function() {
  1689.     this.setHelpWindowItem(this.item());
  1690. };

  1691. Window_ItemList.prototype.refresh = function() {
  1692.     this.makeItemList();
  1693.     this.createContents();
  1694.     this.drawAllItems();
  1695. };

  1696. //-----------------------------------------------------------------------------
  1697. // Window_SkillType
  1698. //
  1699. // The window for selecting a skill type on the skill screen.

  1700. function Window_SkillType() {
  1701.     this.initialize.apply(this, arguments);
  1702. }

  1703. Window_SkillType.prototype = Object.create(Window_Command.prototype);
  1704. Window_SkillType.prototype.constructor = Window_SkillType;

  1705. Window_SkillType.prototype.initialize = function(x, y) {
  1706.     Window_Command.prototype.initialize.call(this, x, y);
  1707.     this._actor = null;
  1708. };

  1709. Window_SkillType.prototype.windowWidth = function() {
  1710.     return 240;
  1711. };

  1712. Window_SkillType.prototype.setActor = function(actor) {
  1713.     if (this._actor !== actor) {
  1714.         this._actor = actor;
  1715.         this.refresh();
  1716.         this.selectLast();
  1717.     }
  1718. };

  1719. Window_SkillType.prototype.numVisibleRows = function() {
  1720.     return 4;
  1721. };

  1722. Window_SkillType.prototype.makeCommandList = function() {
  1723.     if (this._actor) {
  1724.         var skillTypes = this._actor.addedSkillTypes();
  1725.         skillTypes.sort(function(a, b) {
  1726.             return a - b;
  1727.         });
  1728.         skillTypes.forEach(function(stypeId) {
  1729.             var name = $dataSystem.skillTypes[stypeId];
  1730.             this.addCommand(name, 'skill', true, stypeId);
  1731.         }, this);
  1732.     }
  1733. };

  1734. Window_SkillType.prototype.update = function() {
  1735.     Window_Command.prototype.update.call(this);
  1736.     if (this._skillWindow) {
  1737.         this._skillWindow.setStypeId(this.currentExt());
  1738.     }
  1739. };

  1740. Window_SkillType.prototype.setSkillWindow = function(skillWindow) {
  1741.     this._skillWindow = skillWindow;
  1742. };

  1743. Window_SkillType.prototype.selectLast = function() {
  1744.     var skill = this._actor.lastMenuSkill();
  1745.     if (skill) {
  1746.         this.selectExt(skill.stypeId);
  1747.     } else {
  1748.         this.select(0);
  1749.     }
  1750. };

  1751. //-----------------------------------------------------------------------------
  1752. // Window_SkillStatus
  1753. //
  1754. // The window for displaying the skill user's status on the skill screen.

  1755. function Window_SkillStatus() {
  1756.     this.initialize.apply(this, arguments);
  1757. }

  1758. Window_SkillStatus.prototype = Object.create(Window_Base.prototype);
  1759. Window_SkillStatus.prototype.constructor = Window_SkillStatus;

  1760. Window_SkillStatus.prototype.initialize = function(x, y, width, height) {
  1761.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  1762.     this._actor = null;
  1763. };

  1764. Window_SkillStatus.prototype.setActor = function(actor) {
  1765.     if (this._actor !== actor) {
  1766.         this._actor = actor;
  1767.         this.refresh();
  1768.     }
  1769. };

  1770. Window_SkillStatus.prototype.refresh = function() {
  1771.     this.contents.clear();
  1772.     if (this._actor) {
  1773.         var w = this.width - this.padding * 2;
  1774.         var h = this.height - this.padding * 2;
  1775.         var y = h / 2 - this.lineHeight() * 1.5;
  1776.         var width = w - 162 - this.textPadding();
  1777.         this.drawActorFace(this._actor, 0, 0, 144, h);
  1778.         this.drawActorSimpleStatus(this._actor, 162, y, width);
  1779.     }
  1780. };

  1781. //-----------------------------------------------------------------------------
  1782. // Window_SkillList
  1783. //
  1784. // The window for selecting a skill on the skill screen.

  1785. function Window_SkillList() {
  1786.     this.initialize.apply(this, arguments);
  1787. }

  1788. Window_SkillList.prototype = Object.create(Window_Selectable.prototype);
  1789. Window_SkillList.prototype.constructor = Window_SkillList;

  1790. Window_SkillList.prototype.initialize = function(x, y, width, height) {
  1791.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1792.     this._actor = null;
  1793.     this._stypeId = 0;
  1794.     this._data = [];
  1795. };

  1796. Window_SkillList.prototype.setActor = function(actor) {
  1797.     if (this._actor !== actor) {
  1798.         this._actor = actor;
  1799.         this.refresh();
  1800.         this.resetScroll();
  1801.     }
  1802. };

  1803. Window_SkillList.prototype.setStypeId = function(stypeId) {
  1804.     if (this._stypeId !== stypeId) {
  1805.         this._stypeId = stypeId;
  1806.         this.refresh();
  1807.         this.resetScroll();
  1808.     }
  1809. };

  1810. Window_SkillList.prototype.maxCols = function() {
  1811.     return 2;
  1812. };

  1813. Window_SkillList.prototype.spacing = function() {
  1814.     return 48;
  1815. };

  1816. Window_SkillList.prototype.maxItems = function() {
  1817.     return this._data ? this._data.length : 1;
  1818. };

  1819. Window_SkillList.prototype.item = function() {
  1820.     return this._data && this.index() >= 0 ? this._data[this.index()] : null;
  1821. };

  1822. Window_SkillList.prototype.isCurrentItemEnabled = function() {
  1823.     return this.isEnabled(this._data[this.index()]);
  1824. };

  1825. Window_SkillList.prototype.includes = function(item) {
  1826.     return item && item.stypeId === this._stypeId;
  1827. };

  1828. Window_SkillList.prototype.isEnabled = function(item) {
  1829.     return this._actor && this._actor.canUse(item);
  1830. };

  1831. Window_SkillList.prototype.makeItemList = function() {
  1832.     if (this._actor) {
  1833.         this._data = this._actor.skills().filter(function(item) {
  1834.             return this.includes(item);
  1835.         }, this);
  1836.     } else {
  1837.         this._data = [];
  1838.     }
  1839. };

  1840. Window_SkillList.prototype.selectLast = function() {
  1841.     var skill;
  1842.     if ($gameParty.inBattle()) {
  1843.         skill = this._actor.lastBattleSkill();
  1844.     } else {
  1845.         skill = this._actor.lastMenuSkill();
  1846.     }
  1847.     var index = this._data.indexOf(skill);
  1848.     this.select(index >= 0 ? index : 0);
  1849. };

  1850. Window_SkillList.prototype.drawItem = function(index) {
  1851.     var skill = this._data[index];
  1852.     if (skill) {
  1853.         var costWidth = this.costWidth();
  1854.         var rect = this.itemRect(index);
  1855.         rect.width -= this.textPadding();
  1856.         this.changePaintOpacity(this.isEnabled(skill));
  1857.         this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
  1858.         this.drawSkillCost(skill, rect.x, rect.y, rect.width);
  1859.         this.changePaintOpacity(1);
  1860.     }
  1861. };

  1862. Window_SkillList.prototype.costWidth = function() {
  1863.     return this.textWidth('000');
  1864. };

  1865. Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
  1866.     if (this._actor.skillTpCost(skill) > 0) {
  1867.         this.changeTextColor(this.tpCostColor());
  1868.         this.drawText(this._actor.skillTpCost(skill), x, y, width, 'right');
  1869.     } else if (this._actor.skillMpCost(skill) > 0) {
  1870.         this.changeTextColor(this.mpCostColor());
  1871.         this.drawText(this._actor.skillMpCost(skill), x, y, width, 'right');
  1872.     }
  1873. };

  1874. Window_SkillList.prototype.updateHelp = function() {
  1875.     this.setHelpWindowItem(this.item());
  1876. };

  1877. Window_SkillList.prototype.refresh = function() {
  1878.     this.makeItemList();
  1879.     this.createContents();
  1880.     this.drawAllItems();
  1881. };

  1882. //-----------------------------------------------------------------------------
  1883. // Window_EquipStatus
  1884. //
  1885. // The window for displaying parameter changes on the equipment screen.

  1886. function Window_EquipStatus() {
  1887.     this.initialize.apply(this, arguments);
  1888. }

  1889. Window_EquipStatus.prototype = Object.create(Window_Base.prototype);
  1890. Window_EquipStatus.prototype.constructor = Window_EquipStatus;

  1891. Window_EquipStatus.prototype.initialize = function(x, y) {
  1892.     var width = this.windowWidth();
  1893.     var height = this.windowHeight();
  1894.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  1895.     this._actor = null;
  1896.     this._tempActor = null;
  1897.     this.refresh();
  1898. };

  1899. Window_EquipStatus.prototype.windowWidth = function() {
  1900.     return 312;
  1901. };

  1902. Window_EquipStatus.prototype.windowHeight = function() {
  1903.     return this.fittingHeight(this.numVisibleRows());
  1904. };

  1905. Window_EquipStatus.prototype.numVisibleRows = function() {
  1906.     return 7;
  1907. };

  1908. Window_EquipStatus.prototype.setActor = function(actor) {
  1909.     if (this._actor !== actor) {
  1910.         this._actor = actor;
  1911.         this.refresh();
  1912.     }
  1913. };

  1914. Window_EquipStatus.prototype.refresh = function() {
  1915.     this.contents.clear();
  1916.     if (this._actor) {
  1917.         this.drawActorName(this._actor, this.textPadding(), 0);
  1918.         for (var i = 0; i < 6; i++) {
  1919.             this.drawItem(0, this.lineHeight() * (1 + i), 2 + i);
  1920.         }
  1921.     }
  1922. };

  1923. Window_EquipStatus.prototype.setTempActor = function(tempActor) {
  1924.     if (this._tempActor !== tempActor) {
  1925.         this._tempActor = tempActor;
  1926.         this.refresh();
  1927.     }
  1928. };

  1929. Window_EquipStatus.prototype.drawItem = function(x, y, paramId) {
  1930.     this.drawParamName(x + this.textPadding(), y, paramId);
  1931.     if (this._actor) {
  1932.         this.drawCurrentParam(x + 140, y, paramId);
  1933.     }
  1934.     this.drawRightArrow(x + 188, y);
  1935.     if (this._tempActor) {
  1936.         this.drawNewParam(x + 222, y, paramId);
  1937.     }
  1938. };

  1939. Window_EquipStatus.prototype.drawParamName = function(x, y, paramId) {
  1940.     this.changeTextColor(this.systemColor());
  1941.     this.drawText(TextManager.param(paramId), x, y, 120);
  1942. };

  1943. Window_EquipStatus.prototype.drawCurrentParam = function(x, y, paramId) {
  1944.     this.resetTextColor();
  1945.     this.drawText(this._actor.param(paramId), x, y, 48, 'right');
  1946. };

  1947. Window_EquipStatus.prototype.drawRightArrow = function(x, y) {
  1948.     this.changeTextColor(this.systemColor());
  1949.     this.drawText('\u2192', x, y, 32, 'center');
  1950. };

  1951. Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) {
  1952.     var newValue = this._tempActor.param(paramId);
  1953.     var diffvalue = newValue - this._actor.param(paramId);
  1954.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  1955.     this.drawText(newValue, x, y, 48, 'right');
  1956. };

  1957. //-----------------------------------------------------------------------------
  1958. // Window_EquipCommand
  1959. //
  1960. // The window for selecting a command on the equipment screen.

  1961. function Window_EquipCommand() {
  1962.     this.initialize.apply(this, arguments);
  1963. }

  1964. Window_EquipCommand.prototype = Object.create(Window_HorzCommand.prototype);
  1965. Window_EquipCommand.prototype.constructor = Window_EquipCommand;

  1966. Window_EquipCommand.prototype.initialize = function(x, y, width) {
  1967.     this._windowWidth = width;
  1968.     Window_HorzCommand.prototype.initialize.call(this, x, y);
  1969. };

  1970. Window_EquipCommand.prototype.windowWidth = function() {
  1971.     return this._windowWidth;
  1972. };

  1973. Window_EquipCommand.prototype.maxCols = function() {
  1974.     return 3;
  1975. };

  1976. Window_EquipCommand.prototype.makeCommandList = function() {
  1977.     this.addCommand(TextManager.equip2,   'equip');
  1978.     this.addCommand(TextManager.optimize, 'optimize');
  1979.     this.addCommand(TextManager.clear,    'clear');
  1980. };

  1981. //-----------------------------------------------------------------------------
  1982. // Window_EquipSlot
  1983. //
  1984. // The window for selecting an equipment slot on the equipment screen.

  1985. function Window_EquipSlot() {
  1986.     this.initialize.apply(this, arguments);
  1987. }

  1988. Window_EquipSlot.prototype = Object.create(Window_Selectable.prototype);
  1989. Window_EquipSlot.prototype.constructor = Window_EquipSlot;

  1990. Window_EquipSlot.prototype.initialize = function(x, y, width, height) {
  1991.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1992.     this._actor = null;
  1993.     this.refresh();
  1994. };

  1995. Window_EquipSlot.prototype.setActor = function(actor) {
  1996.     if (this._actor !== actor) {
  1997.         this._actor = actor;
  1998.         this.refresh();
  1999.     }
  2000. };

  2001. Window_EquipSlot.prototype.update = function() {
  2002.     Window_Selectable.prototype.update.call(this);
  2003.     if (this._itemWindow) {
  2004.         this._itemWindow.setSlotId(this.index());
  2005.     }
  2006. };

  2007. Window_EquipSlot.prototype.maxItems = function() {
  2008.     return this._actor ? this._actor.equipSlots().length : 0;
  2009. };

  2010. Window_EquipSlot.prototype.item = function() {
  2011.     return this._actor ? this._actor.equips()[this.index()] : null;
  2012. };

  2013. Window_EquipSlot.prototype.drawItem = function(index) {
  2014.     if (this._actor) {
  2015.         var rect = this.itemRectForText(index);
  2016.         this.changeTextColor(this.systemColor());
  2017.         this.changePaintOpacity(this.isEnabled(index));
  2018.         this.drawText(this.slotName(index), rect.x, rect.y, 138, this.lineHeight());
  2019.         this.drawItemName(this._actor.equips()[index], rect.x + 138, rect.y);
  2020.         this.changePaintOpacity(true);
  2021.     }
  2022. };

  2023. Window_EquipSlot.prototype.slotName = function(index) {
  2024.     var slots = this._actor.equipSlots();
  2025.     return this._actor ? $dataSystem.equipTypes[slots[index]] : '';
  2026. };

  2027. Window_EquipSlot.prototype.isEnabled = function(index) {
  2028.     return this._actor ? this._actor.isEquipChangeOk(index) : false;
  2029. };

  2030. Window_EquipSlot.prototype.isCurrentItemEnabled = function() {
  2031.     return this.isEnabled(this.index());
  2032. };

  2033. Window_EquipSlot.prototype.setStatusWindow = function(statusWindow) {
  2034.     this._statusWindow = statusWindow;
  2035.     this.callUpdateHelp();
  2036. };

  2037. Window_EquipSlot.prototype.setItemWindow = function(itemWindow) {
  2038.     this._itemWindow = itemWindow;
  2039. };

  2040. Window_EquipSlot.prototype.updateHelp = function() {
  2041.     Window_Selectable.prototype.updateHelp.call(this);
  2042.     this.setHelpWindowItem(this.item());
  2043.     if (this._statusWindow) {
  2044.         this._statusWindow.setTempActor(null);
  2045.     }
  2046. };

  2047. //-----------------------------------------------------------------------------
  2048. // Window_EquipItem
  2049. //
  2050. // The window for selecting an equipment item on the equipment screen.

  2051. function Window_EquipItem() {
  2052.     this.initialize.apply(this, arguments);
  2053. }

  2054. Window_EquipItem.prototype = Object.create(Window_ItemList.prototype);
  2055. Window_EquipItem.prototype.constructor = Window_EquipItem;

  2056. Window_EquipItem.prototype.initialize = function(x, y, width, height) {
  2057.     Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  2058.     this._actor = null;
  2059.     this._slotId = 0;
  2060. };

  2061. Window_EquipItem.prototype.setActor = function(actor) {
  2062.     if (this._actor !== actor) {
  2063.         this._actor = actor;
  2064.         this.refresh();
  2065.         this.resetScroll();
  2066.     }
  2067. };

  2068. Window_EquipItem.prototype.setSlotId = function(slotId) {
  2069.     if (this._slotId !== slotId) {
  2070.         this._slotId = slotId;
  2071.         this.refresh();
  2072.         this.resetScroll();
  2073.     }
  2074. };

  2075. Window_EquipItem.prototype.includes = function(item) {
  2076.     if (item === null) {
  2077.         return true;
  2078.     }
  2079.     if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
  2080.         return false;
  2081.     }
  2082.     return this._actor.canEquip(item);
  2083. };

  2084. Window_EquipItem.prototype.isEnabled = function(item) {
  2085.     return true;
  2086. };

  2087. Window_EquipItem.prototype.selectLast = function() {
  2088. };

  2089. Window_EquipItem.prototype.setStatusWindow = function(statusWindow) {
  2090.     this._statusWindow = statusWindow;
  2091.     this.callUpdateHelp();
  2092. };

  2093. Window_EquipItem.prototype.updateHelp = function() {
  2094.     Window_ItemList.prototype.updateHelp.call(this);
  2095.     if (this._actor && this._statusWindow) {
  2096.         var actor = JsonEx.makeDeepCopy(this._actor);
  2097.         actor.forceChangeEquip(this._slotId, this.item());
  2098.         this._statusWindow.setTempActor(actor);
  2099.     }
  2100. };

  2101. Window_EquipItem.prototype.playOkSound = function() {
  2102. };

  2103. //-----------------------------------------------------------------------------
  2104. // Window_Status
  2105. //
  2106. // The window for displaying full status on the status screen.

  2107. function Window_Status() {
  2108.     this.initialize.apply(this, arguments);
  2109. }

  2110. Window_Status.prototype = Object.create(Window_Selectable.prototype);
  2111. Window_Status.prototype.constructor = Window_Status;

  2112. Window_Status.prototype.initialize = function() {
  2113.     var width = Graphics.boxWidth;
  2114.     var height = Graphics.boxHeight;
  2115.     Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  2116.     this._actor = null;
  2117.     this.refresh();
  2118.     this.activate();
  2119. };

  2120. Window_Status.prototype.setActor = function(actor) {
  2121.     if (this._actor !== actor) {
  2122.         this._actor = actor;
  2123.         this.refresh();
  2124.     }
  2125. };

  2126. Window_Status.prototype.refresh = function() {
  2127.     this.contents.clear();
  2128.     if (this._actor) {
  2129.         var lineHeight = this.lineHeight();
  2130.         this.drawBlock1(lineHeight * 0);
  2131.         this.drawHorzLine(lineHeight * 1);
  2132.         this.drawBlock2(lineHeight * 2);
  2133.         this.drawHorzLine(lineHeight * 6);
  2134.         this.drawBlock3(lineHeight * 7);
  2135.         this.drawHorzLine(lineHeight * 13);
  2136.         this.drawBlock4(lineHeight * 14);
  2137.     }
  2138. };

  2139. Window_Status.prototype.drawBlock1 = function(y) {
  2140.     this.drawActorName(this._actor, 6, y);
  2141.     this.drawActorClass(this._actor, 192, y);
  2142.     this.drawActorNickname(this._actor, 432, y);
  2143. };

  2144. Window_Status.prototype.drawBlock2 = function(y) {
  2145.     this.drawActorFace(this._actor, 12, y);
  2146.     this.drawBasicInfo(204, y);
  2147.     this.drawExpInfo(456, y);
  2148. };

  2149. Window_Status.prototype.drawBlock3 = function(y) {
  2150.     this.drawParameters(48, y);
  2151.     this.drawEquipments(432, y);
  2152. };

  2153. Window_Status.prototype.drawBlock4 = function(y) {
  2154.     this.drawProfile(6, y);
  2155. };

  2156. Window_Status.prototype.drawHorzLine = function(y) {
  2157.     var lineY = y + this.lineHeight() / 2 - 1;
  2158.     this.contents.paintOpacity = 48;
  2159.     this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
  2160.     this.contents.paintOpacity = 255;
  2161. };

  2162. Window_Status.prototype.lineColor = function() {
  2163.     return this.normalColor();
  2164. };

  2165. Window_Status.prototype.drawBasicInfo = function(x, y) {
  2166.     var lineHeight = this.lineHeight();
  2167.     this.drawActorLevel(this._actor, x, y + lineHeight * 0);
  2168.     this.drawActorIcons(this._actor, x, y + lineHeight * 1);
  2169.     this.drawActorHp(this._actor, x, y + lineHeight * 2);
  2170.     this.drawActorMp(this._actor, x, y + lineHeight * 3);
  2171. };

  2172. Window_Status.prototype.drawParameters = function(x, y) {
  2173.     var lineHeight = this.lineHeight();
  2174.     for (var i = 0; i < 6; i++) {
  2175.         var paramId = i + 2;
  2176.         var y2 = y + lineHeight * i;
  2177.         this.changeTextColor(this.systemColor());
  2178.         this.drawText(TextManager.param(paramId), x, y2, 160);
  2179.         this.resetTextColor();
  2180.         this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right');
  2181.     }
  2182. };

  2183. Window_Status.prototype.drawExpInfo = function(x, y) {
  2184.     var lineHeight = this.lineHeight();
  2185.     var expTotal = TextManager.expTotal.format(TextManager.exp);
  2186.     var expNext = TextManager.expNext.format(TextManager.level);
  2187.     var value1 = this._actor.currentExp();
  2188.     var value2 = this._actor.nextRequiredExp();
  2189.     if (this._actor.isMaxLevel()) {
  2190.         value1 = '-------';
  2191.         value2 = '-------';
  2192.     }
  2193.     this.changeTextColor(this.systemColor());
  2194.     this.drawText(expTotal, x, y + lineHeight * 0, 270);
  2195.     this.drawText(expNext, x, y + lineHeight * 2, 270);
  2196.     this.resetTextColor();
  2197.     this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
  2198.     this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
  2199. };

  2200. Window_Status.prototype.drawEquipments = function(x, y) {
  2201.     var equips = this._actor.equips();
  2202.     var count = Math.min(equips.length, this.maxEquipmentLines());
  2203.     for (var i = 0; i < count; i++) {
  2204.         this.drawItemName(equips[i], x, y + this.lineHeight() * i);
  2205.     }
  2206. };

  2207. Window_Status.prototype.drawProfile = function(x, y) {
  2208.     this.drawTextEx(this._actor.profile(), x, y);
  2209. };

  2210. Window_Status.prototype.maxEquipmentLines = function() {
  2211.     return 6;
  2212. };

  2213. //-----------------------------------------------------------------------------
  2214. // Window_Options
  2215. //
  2216. // The window for changing various settings on the options screen.

  2217. function Window_Options() {
  2218.     this.initialize.apply(this, arguments);
  2219. }

  2220. Window_Options.prototype = Object.create(Window_Command.prototype);
  2221. Window_Options.prototype.constructor = Window_Options;

  2222. Window_Options.prototype.initialize = function() {
  2223.     Window_Command.prototype.initialize.call(this, 0, 0);
  2224.     this.updatePlacement();
  2225. };

  2226. Window_Options.prototype.windowWidth = function() {
  2227.     return 400;
  2228. };

  2229. Window_Options.prototype.windowHeight = function() {
  2230.     return this.fittingHeight(Math.min(this.numVisibleRows(), 12));
  2231. };

  2232. Window_Options.prototype.updatePlacement = function() {
  2233.     this.x = (Graphics.boxWidth - this.width) / 2;
  2234.     this.y = (Graphics.boxHeight - this.height) / 2;
  2235. };

  2236. Window_Options.prototype.makeCommandList = function() {
  2237.     this.addGeneralOptions();
  2238.     this.addVolumeOptions();
  2239. };

  2240. Window_Options.prototype.addGeneralOptions = function() {
  2241.     this.addCommand(TextManager.alwaysDash, 'alwaysDash');
  2242.     this.addCommand(TextManager.commandRemember, 'commandRemember');
  2243. };

  2244. Window_Options.prototype.addVolumeOptions = function() {
  2245.     this.addCommand(TextManager.bgmVolume, 'bgmVolume');
  2246.     this.addCommand(TextManager.bgsVolume, 'bgsVolume');
  2247.     this.addCommand(TextManager.meVolume, 'meVolume');
  2248.     this.addCommand(TextManager.seVolume, 'seVolume');
  2249. };

  2250. Window_Options.prototype.drawItem = function(index) {
  2251.     var rect = this.itemRectForText(index);
  2252.     var statusWidth = this.statusWidth();
  2253.     var titleWidth = rect.width - statusWidth;
  2254.     this.resetTextColor();
  2255.     this.changePaintOpacity(this.isCommandEnabled(index));
  2256.     this.drawText(this.commandName(index), rect.x, rect.y, titleWidth, 'left');
  2257.     this.drawText(this.statusText(index), titleWidth, rect.y, statusWidth, 'right');
  2258. };

  2259. Window_Options.prototype.statusWidth = function() {
  2260.     return 120;
  2261. };

  2262. Window_Options.prototype.statusText = function(index) {
  2263.     var symbol = this.commandSymbol(index);
  2264.     var value = this.getConfigValue(symbol);
  2265.     if (this.isVolumeSymbol(symbol)) {
  2266.         return this.volumeStatusText(value);
  2267.     } else {
  2268.         return this.booleanStatusText(value);
  2269.     }
  2270. };

  2271. Window_Options.prototype.isVolumeSymbol = function(symbol) {
  2272.     return symbol.contains('Volume');
  2273. };

  2274. Window_Options.prototype.booleanStatusText = function(value) {
  2275.     return value ? 'ON' : 'OFF';
  2276. };

  2277. Window_Options.prototype.volumeStatusText = function(value) {
  2278.     return value + '%';
  2279. };

  2280. Window_Options.prototype.processOk = function() {
  2281.     var index = this.index();
  2282.     var symbol = this.commandSymbol(index);
  2283.     var value = this.getConfigValue(symbol);
  2284.     if (this.isVolumeSymbol(symbol)) {
  2285.         value += this.volumeOffset();
  2286.         if (value > 100) {
  2287.             value = 0;
  2288.         }
  2289.         value = value.clamp(0, 100);
  2290.         this.changeValue(symbol, value);
  2291.     } else {
  2292.         this.changeValue(symbol, !value);
  2293.     }
  2294. };

  2295. Window_Options.prototype.cursorRight = function(wrap) {
  2296.     var index = this.index();
  2297.     var symbol = this.commandSymbol(index);
  2298.     var value = this.getConfigValue(symbol);
  2299.     if (this.isVolumeSymbol(symbol)) {
  2300.         value += this.volumeOffset();
  2301.         value = value.clamp(0, 100);
  2302.         this.changeValue(symbol, value);
  2303.     } else {
  2304.         this.changeValue(symbol, true);
  2305.     }
  2306. };

  2307. Window_Options.prototype.cursorLeft = function(wrap) {
  2308.     var index = this.index();
  2309.     var symbol = this.commandSymbol(index);
  2310.     var value = this.getConfigValue(symbol);
  2311.     if (this.isVolumeSymbol(symbol)) {
  2312.         value -= this.volumeOffset();
  2313.         value = value.clamp(0, 100);
  2314.         this.changeValue(symbol, value);
  2315.     } else {
  2316.         this.changeValue(symbol, false);
  2317.     }
  2318. };

  2319. Window_Options.prototype.volumeOffset = function() {
  2320.     return 20;
  2321. };

  2322. Window_Options.prototype.changeValue = function(symbol, value) {
  2323.     var lastValue = this.getConfigValue(symbol);
  2324.     if (lastValue !== value) {
  2325.         this.setConfigValue(symbol, value);
  2326.         this.redrawItem(this.findSymbol(symbol));
  2327.         SoundManager.playCursor();
  2328.     }
  2329. };

  2330. Window_Options.prototype.getConfigValue = function(symbol) {
  2331.     return ConfigManager[symbol];
  2332. };

  2333. Window_Options.prototype.setConfigValue = function(symbol, volume) {
  2334.     ConfigManager[symbol] = volume;
  2335. };

  2336. //-----------------------------------------------------------------------------
  2337. // Window_SavefileList
  2338. //
  2339. // The window for selecting a save file on the save and load screens.

  2340. function Window_SavefileList() {
  2341.     this.initialize.apply(this, arguments);
  2342. }

  2343. Window_SavefileList.prototype = Object.create(Window_Selectable.prototype);
  2344. Window_SavefileList.prototype.constructor = Window_SavefileList;

  2345. Window_SavefileList.prototype.initialize = function(x, y, width, height) {
  2346.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2347.     this.activate();
  2348.     this._mode = null;
  2349. };

  2350. Window_SavefileList.prototype.setMode = function(mode) {
  2351.     this._mode = mode;
  2352. };

  2353. Window_SavefileList.prototype.maxItems = function() {
  2354.     return DataManager.maxSavefiles();
  2355. };

  2356. Window_SavefileList.prototype.maxVisibleItems = function() {
  2357.     return 5;
  2358. };

  2359. Window_SavefileList.prototype.itemHeight = function() {
  2360.     var innerHeight = this.height - this.padding * 2;
  2361.     return Math.floor(innerHeight / this.maxVisibleItems());
  2362. };

  2363. Window_SavefileList.prototype.drawItem = function(index) {
  2364.     var id = index + 1;
  2365.     var valid = DataManager.isThisGameFile(id);
  2366.     var info = DataManager.loadSavefileInfo(id);
  2367.     var rect = this.itemRectForText(index);
  2368.     this.resetTextColor();
  2369.     if (this._mode === 'load') {
  2370.         this.changePaintOpacity(valid);
  2371.     }
  2372.     this.drawFileId(id, rect.x, rect.y);
  2373.     if (info) {
  2374.         this.changePaintOpacity(valid);
  2375.         this.drawContents(info, rect, valid);
  2376.         this.changePaintOpacity(true);
  2377.     }
  2378. };

  2379. Window_SavefileList.prototype.drawFileId = function(id, x, y) {
  2380.     this.drawText(TextManager.file + ' ' + id, x, y, 180);
  2381. };

  2382. Window_SavefileList.prototype.drawContents = function(info, rect, valid) {
  2383.     var bottom = rect.y + rect.height;
  2384.     if (rect.width >= 420) {
  2385.         this.drawGameTitle(info, rect.x + 192, rect.y, rect.width - 192);
  2386.         if (valid) {
  2387.             this.drawPartyCharacters(info, rect.x + 220, bottom - 4);
  2388.         }
  2389.     }
  2390.     var lineHeight = this.lineHeight();
  2391.     var y2 = bottom - lineHeight;
  2392.     if (y2 >= lineHeight) {
  2393.         this.drawPlaytime(info, rect.x, y2, rect.width);
  2394.     }
  2395. };

  2396. Window_SavefileList.prototype.drawGameTitle = function(info, x, y, width) {
  2397.     if (info.title) {
  2398.         this.drawText(info.title, x, y, width);
  2399.     }
  2400. };

  2401. Window_SavefileList.prototype.drawPartyCharacters = function(info, x, y) {
  2402.     if (info.characters) {
  2403.         for (var i = 0; i < info.characters.length; i++) {
  2404.             var data = info.characters[i];
  2405.             this.drawCharacter(data[0], data[1], x + i * 48, y);
  2406.         }
  2407.     }
  2408. };

  2409. Window_SavefileList.prototype.drawPlaytime = function(info, x, y, width) {
  2410.     if (info.playtime) {
  2411.         this.drawText(info.playtime, x, y, width, 'right');
  2412.     }
  2413. };

  2414. Window_SavefileList.prototype.playOkSound = function() {
  2415. };

  2416. //-----------------------------------------------------------------------------
  2417. // Window_ShopCommand
  2418. //
  2419. // The window for selecting buy/sell on the shop screen.

  2420. function Window_ShopCommand() {
  2421.     this.initialize.apply(this, arguments);
  2422. }

  2423. Window_ShopCommand.prototype = Object.create(Window_HorzCommand.prototype);
  2424. Window_ShopCommand.prototype.constructor = Window_ShopCommand;

  2425. Window_ShopCommand.prototype.initialize = function(width, purchaseOnly) {
  2426.     this._windowWidth = width;
  2427.     this._purchaseOnly = purchaseOnly;
  2428.     Window_HorzCommand.prototype.initialize.call(this, 0, 0);
  2429. };

  2430. Window_ShopCommand.prototype.windowWidth = function() {
  2431.     return this._windowWidth;
  2432. };

  2433. Window_ShopCommand.prototype.maxCols = function() {
  2434.     return 3;
  2435. };

  2436. Window_ShopCommand.prototype.makeCommandList = function() {
  2437.     this.addCommand(TextManager.buy,    'buy');
  2438.     this.addCommand(TextManager.sell,   'sell',   !this._purchaseOnly);
  2439.     this.addCommand(TextManager.cancel, 'cancel');
  2440. };

  2441. //-----------------------------------------------------------------------------
  2442. // Window_ShopBuy
  2443. //
  2444. // The window for selecting an item to buy on the shop screen.

  2445. function Window_ShopBuy() {
  2446.     this.initialize.apply(this, arguments);
  2447. }

  2448. Window_ShopBuy.prototype = Object.create(Window_Selectable.prototype);
  2449. Window_ShopBuy.prototype.constructor = Window_ShopBuy;

  2450. Window_ShopBuy.prototype.initialize = function(x, y, height, shopGoods) {
  2451.     var width = this.windowWidth();
  2452.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2453.     this._shopGoods = shopGoods;
  2454.     this._money = 0;
  2455.     this.refresh();
  2456.     this.select(0);
  2457. };

  2458. Window_ShopBuy.prototype.windowWidth = function() {
  2459.     return 456;
  2460. };

  2461. Window_ShopBuy.prototype.maxItems = function() {
  2462.     return this._data ? this._data.length : 1;
  2463. };

  2464. Window_ShopBuy.prototype.item = function() {
  2465.     return this._data[this.index()];
  2466. };

  2467. Window_ShopBuy.prototype.setMoney = function(money) {
  2468.     this._money = money;
  2469.     this.refresh();
  2470. };

  2471. Window_ShopBuy.prototype.isCurrentItemEnabled = function() {
  2472.     return this.isEnabled(this._data[this.index()]);
  2473. };

  2474. Window_ShopBuy.prototype.price = function(item) {
  2475.     return this._price[this._data.indexOf(item)] || 0;
  2476. };

  2477. Window_ShopBuy.prototype.isEnabled = function(item) {
  2478.     return (item && this.price(item) <= this._money &&
  2479.             !$gameParty.hasMaxItems(item));
  2480. };

  2481. Window_ShopBuy.prototype.refresh = function() {
  2482.     this.makeItemList();
  2483.     this.createContents();
  2484.     this.drawAllItems();
  2485. };

  2486. Window_ShopBuy.prototype.makeItemList = function() {
  2487.     this._data = [];
  2488.     this._price = [];
  2489.     this._shopGoods.forEach(function(goods) {
  2490.         var item = null;
  2491.         switch (goods[0]) {
  2492.         case 0:
  2493.             item = $dataItems[goods[1]];
  2494.             break;
  2495.         case 1:
  2496.             item = $dataWeapons[goods[1]];
  2497.             break;
  2498.         case 2:
  2499.             item = $dataArmors[goods[1]];
  2500.             break;
  2501.         }
  2502.         if (item) {
  2503.             this._data.push(item);
  2504.             this._price.push(goods[2] === 0 ? item.price : goods[3]);
  2505.         }
  2506.     }, this);
  2507. };

  2508. Window_ShopBuy.prototype.drawItem = function(index) {
  2509.     var item = this._data[index];
  2510.     var rect = this.itemRect(index);
  2511.     var priceWidth = 96;
  2512.     rect.width -= this.textPadding();
  2513.     this.changePaintOpacity(this.isEnabled(item));
  2514.     this.drawItemName(item, rect.x, rect.y, rect.width - priceWidth);
  2515.     this.drawText(this.price(item), rect.x + rect.width - priceWidth,
  2516.                   rect.y, priceWidth, 'right');
  2517.     this.changePaintOpacity(true);
  2518. };

  2519. Window_ShopBuy.prototype.setStatusWindow = function(statusWindow) {
  2520.     this._statusWindow = statusWindow;
  2521.     this.callUpdateHelp();
  2522. };

  2523. Window_ShopBuy.prototype.updateHelp = function() {
  2524.     this.setHelpWindowItem(this.item());
  2525.     if (this._statusWindow) {
  2526.         this._statusWindow.setItem(this.item());
  2527.     }
  2528. };

  2529. //-----------------------------------------------------------------------------
  2530. // Window_ShopSell
  2531. //
  2532. // The window for selecting an item to sell on the shop screen.

  2533. function Window_ShopSell() {
  2534.     this.initialize.apply(this, arguments);
  2535. }

  2536. Window_ShopSell.prototype = Object.create(Window_ItemList.prototype);
  2537. Window_ShopSell.prototype.constructor = Window_ShopSell;

  2538. Window_ShopSell.prototype.initialize = function(x, y, width, height) {
  2539.     Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  2540. };

  2541. Window_ShopSell.prototype.isEnabled = function(item) {
  2542.     return item && item.price > 0;
  2543. };

  2544. //-----------------------------------------------------------------------------
  2545. // Window_ShopNumber
  2546. //
  2547. // The window for inputting quantity of items to buy or sell on the shop
  2548. // screen.

  2549. function Window_ShopNumber() {
  2550.     this.initialize.apply(this, arguments);
  2551. }

  2552. Window_ShopNumber.prototype = Object.create(Window_Selectable.prototype);
  2553. Window_ShopNumber.prototype.constructor = Window_ShopNumber;

  2554. Window_ShopNumber.prototype.initialize = function(x, y, height) {
  2555.     var width = this.windowWidth();
  2556.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2557.     this._item = null;
  2558.     this._max = 1;
  2559.     this._price = 0;
  2560.     this._number = 1;
  2561.     this._currencyUnit = TextManager.currencyUnit;
  2562.     this.createButtons();
  2563. };

  2564. Window_ShopNumber.prototype.windowWidth = function() {
  2565.     return 456;
  2566. };

  2567. Window_ShopNumber.prototype.number = function() {
  2568.     return this._number;
  2569. };

  2570. Window_ShopNumber.prototype.setup = function(item, max, price) {
  2571.     this._item = item;
  2572.     this._max = Math.floor(max);
  2573.     this._price = price;
  2574.     this._number = 1;
  2575.     this.placeButtons();
  2576.     this.updateButtonsVisiblity();
  2577.     this.refresh();
  2578. };

  2579. Window_ShopNumber.prototype.setCurrencyUnit = function(currencyUnit) {
  2580.     this._currencyUnit = currencyUnit;
  2581.     this.refresh();
  2582. };

  2583. Window_ShopNumber.prototype.createButtons = function() {
  2584.     var bitmap = ImageManager.loadSystem('ButtonSet');
  2585.     var buttonWidth = 48;
  2586.     var buttonHeight = 48;
  2587.     this._buttons = [];
  2588.     for (var i = 0; i < 5; i++) {
  2589.         var button = new Sprite_Button();
  2590.         var x = buttonWidth * i;
  2591.         var w = buttonWidth * (i === 4 ? 2 : 1);
  2592.         button.bitmap = bitmap;
  2593.         button.setColdFrame(x, 0, w, buttonHeight);
  2594.         button.setHotFrame(x, buttonHeight, w, buttonHeight);
  2595.         button.visible = false;
  2596.         this._buttons.push(button);
  2597.         this.addChild(button);
  2598.     }
  2599.     this._buttons[0].setClickHandler(this.onButtonDown2.bind(this));
  2600.     this._buttons[1].setClickHandler(this.onButtonDown.bind(this));
  2601.     this._buttons[2].setClickHandler(this.onButtonUp.bind(this));
  2602.     this._buttons[3].setClickHandler(this.onButtonUp2.bind(this));
  2603.     this._buttons[4].setClickHandler(this.onButtonOk.bind(this));
  2604. };

  2605. Window_ShopNumber.prototype.placeButtons = function() {
  2606.     var numButtons = this._buttons.length;
  2607.     var spacing = 16;
  2608.     var totalWidth = -spacing;
  2609.     for (var i = 0; i < numButtons; i++) {
  2610.         totalWidth += this._buttons[i].width + spacing;
  2611.     }
  2612.     var x = (this.width - totalWidth) / 2;
  2613.     for (var j = 0; j < numButtons; j++) {
  2614.         var button = this._buttons[j];
  2615.         button.x = x;
  2616.         button.y = this.buttonY();
  2617.         x += button.width + spacing;
  2618.     }
  2619. };

  2620. Window_ShopNumber.prototype.updateButtonsVisiblity = function() {
  2621.     if (TouchInput.date > Input.date) {
  2622.         this.showButtons();
  2623.     } else {
  2624.         this.hideButtons();
  2625.     }
  2626. };

  2627. Window_ShopNumber.prototype.showButtons = function() {
  2628.     for (var i = 0; i < this._buttons.length; i++) {
  2629.         this._buttons[i].visible = true;
  2630.     }
  2631. };

  2632. Window_ShopNumber.prototype.hideButtons = function() {
  2633.     for (var i = 0; i < this._buttons.length; i++) {
  2634.         this._buttons[i].visible = false;
  2635.     }
  2636. };

  2637. Window_ShopNumber.prototype.refresh = function() {
  2638.     this.contents.clear();
  2639.     this.drawItemName(this._item, 0, this.itemY());
  2640.     this.drawMultiplicationSign();
  2641.     this.drawNumber();
  2642.     this.drawTotalPrice();
  2643. };

  2644. Window_ShopNumber.prototype.drawMultiplicationSign = function() {
  2645.     var sign = '\u00d7';
  2646.     var width = this.textWidth(sign);
  2647.     var x = this.cursorX() - width * 2;
  2648.     var y = this.itemY();
  2649.     this.resetTextColor();
  2650.     this.drawText(sign, x, y, width);
  2651. };

  2652. Window_ShopNumber.prototype.drawNumber = function() {
  2653.     var x = this.cursorX();
  2654.     var y = this.itemY();
  2655.     var width = this.cursorWidth() - this.textPadding();
  2656.     this.resetTextColor();
  2657.     this.drawText(this._number, x, y, width, 'right');
  2658. };

  2659. Window_ShopNumber.prototype.drawTotalPrice = function() {
  2660.     var total = this._price * this._number;
  2661.     var width = this.contentsWidth() - this.textPadding();
  2662.     this.drawCurrencyValue(total, this._currencyUnit, 0, this.priceY(), width);
  2663. };

  2664. Window_ShopNumber.prototype.itemY = function() {
  2665.     return Math.round(this.contentsHeight() / 2 - this.lineHeight() * 1.5);
  2666. };

  2667. Window_ShopNumber.prototype.priceY = function() {
  2668.     return Math.round(this.contentsHeight() / 2 + this.lineHeight() / 2);
  2669. };

  2670. Window_ShopNumber.prototype.buttonY = function() {
  2671.     return Math.round(this.priceY() + this.lineHeight() * 2.5);
  2672. };

  2673. Window_ShopNumber.prototype.cursorWidth = function() {
  2674.     var digitWidth = this.textWidth('0');
  2675.     return this.maxDigits() * digitWidth + this.textPadding() * 2;
  2676. };

  2677. Window_ShopNumber.prototype.cursorX = function() {
  2678.     return this.contentsWidth() - this.cursorWidth() - this.textPadding();
  2679. };

  2680. Window_ShopNumber.prototype.maxDigits = function() {
  2681.     return 2;
  2682. };

  2683. Window_ShopNumber.prototype.update = function() {
  2684.     Window_Selectable.prototype.update.call(this);
  2685.     this.processNumberChange();
  2686. };

  2687. Window_ShopNumber.prototype.isOkTriggered = function() {
  2688.     return Input.isTriggered('ok');
  2689. };

  2690. Window_ShopNumber.prototype.playOkSound = function() {
  2691. };

  2692. Window_ShopNumber.prototype.processNumberChange = function() {
  2693.     if (this.isOpenAndActive()) {
  2694.         if (Input.isRepeated('right')) {
  2695.             this.changeNumber(1);
  2696.         }
  2697.         if (Input.isRepeated('left')) {
  2698.             this.changeNumber(-1);
  2699.         }
  2700.         if (Input.isRepeated('up')) {
  2701.             this.changeNumber(10);
  2702.         }
  2703.         if (Input.isRepeated('down')) {
  2704.             this.changeNumber(-10);
  2705.         }
  2706.     }
  2707. };

  2708. Window_ShopNumber.prototype.changeNumber = function(amount) {
  2709.     var lastNumber = this._number;
  2710.     this._number = (this._number + amount).clamp(1, this._max);
  2711.     if (this._number !== lastNumber) {
  2712.         SoundManager.playCursor();
  2713.         this.refresh();
  2714.     }
  2715. };

  2716. Window_ShopNumber.prototype.updateCursor = function() {
  2717.     this.setCursorRect(this.cursorX(), this.itemY(),
  2718.                        this.cursorWidth(), this.lineHeight());
  2719. };

  2720. Window_ShopNumber.prototype.onButtonUp = function() {
  2721.     this.changeNumber(1);
  2722. };

  2723. Window_ShopNumber.prototype.onButtonUp2 = function() {
  2724.     this.changeNumber(10);
  2725. };

  2726. Window_ShopNumber.prototype.onButtonDown = function() {
  2727.     this.changeNumber(-1);
  2728. };

  2729. Window_ShopNumber.prototype.onButtonDown2 = function() {
  2730.     this.changeNumber(-10);
  2731. };

  2732. Window_ShopNumber.prototype.onButtonOk = function() {
  2733.     this.processOk();
  2734. };

  2735. //-----------------------------------------------------------------------------
  2736. // Window_ShopStatus
  2737. //
  2738. // The window for displaying number of items in possession and the actor's
  2739. // equipment on the shop screen.

  2740. function Window_ShopStatus() {
  2741.     this.initialize.apply(this, arguments);
  2742. }

  2743. Window_ShopStatus.prototype = Object.create(Window_Base.prototype);
  2744. Window_ShopStatus.prototype.constructor = Window_ShopStatus;

  2745. Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
  2746.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  2747.     this._item = null;
  2748.     this._pageIndex = 0;
  2749.     this.refresh();
  2750. };

  2751. Window_ShopStatus.prototype.refresh = function() {
  2752.     this.contents.clear();
  2753.     if (this._item) {
  2754.         var x = this.textPadding();
  2755.         this.drawPossession(x, 0);
  2756.         if (this.isEquipItem()) {
  2757.             this.drawEquipInfo(x, this.lineHeight() * 2);
  2758.         }
  2759.     }
  2760. };

  2761. Window_ShopStatus.prototype.setItem = function(item) {
  2762.     this._item = item;
  2763.     this.refresh();
  2764. };

  2765. Window_ShopStatus.prototype.isEquipItem = function() {
  2766.     return DataManager.isWeapon(this._item) || DataManager.isArmor(this._item);
  2767. };

  2768. Window_ShopStatus.prototype.drawPossession = function(x, y) {
  2769.     var width = this.contents.width - this.textPadding() - x;
  2770.     var possessionWidth = this.textWidth('0000');
  2771.     this.changeTextColor(this.systemColor());
  2772.     this.drawText(TextManager.possession, x, y, width - possessionWidth);
  2773.     this.resetTextColor();
  2774.     this.drawText($gameParty.numItems(this._item), x, y, width, 'right');
  2775. };

  2776. Window_ShopStatus.prototype.drawEquipInfo = function(x, y) {
  2777.     var members = this.statusMembers();
  2778.     for (var i = 0; i < members.length; i++) {
  2779.         this.drawActorEquipInfo(x, y + this.lineHeight() * (i * 2.4), members[i]);
  2780.     }
  2781. };

  2782. Window_ShopStatus.prototype.statusMembers = function() {
  2783.     var start = this._pageIndex * this.pageSize();
  2784.     var end = start + this.pageSize();
  2785.     return $gameParty.members().slice(start, end);
  2786. };

  2787. Window_ShopStatus.prototype.pageSize = function() {
  2788.     return 4;
  2789. };

  2790. Window_ShopStatus.prototype.maxPages = function() {
  2791.     return Math.floor(($gameParty.size() + this.pageSize() - 1) / this.pageSize());
  2792. };

  2793. Window_ShopStatus.prototype.drawActorEquipInfo = function(x, y, actor) {
  2794.     var enabled = actor.canEquip(this._item);
  2795.     this.changePaintOpacity(enabled);
  2796.     this.resetTextColor();
  2797.     this.drawText(actor.name(), x, y, 168);
  2798.     var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  2799.     if (enabled) {
  2800.         this.drawActorParamChange(x, y, actor, item1);
  2801.     }
  2802.     this.drawItemName(item1, x, y + this.lineHeight());
  2803.     this.changePaintOpacity(true);
  2804. };

  2805. Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1) {
  2806.     var width = this.contents.width - this.textPadding() - x;
  2807.     var paramId = this.paramId();
  2808.     var change = this._item.params[paramId] - (item1 ? item1.params[paramId] : 0);
  2809.     this.changeTextColor(this.paramchangeTextColor(change));
  2810.     this.drawText((change > 0 ? '+' : '') + change, x, y, width, 'right');
  2811. };

  2812. Window_ShopStatus.prototype.paramId = function() {
  2813.     return DataManager.isWeapon(this._item) ? 2 : 3;
  2814. };

  2815. Window_ShopStatus.prototype.currentEquippedItem = function(actor, etypeId) {
  2816.     var list = [];
  2817.     var equips = actor.equips();
  2818.     var slots = actor.equipSlots();
  2819.     for (var i = 0; i < slots.length; i++) {
  2820.         if (slots[i] === etypeId) {
  2821.             list.push(equips[i]);
  2822.         }
  2823.     }
  2824.     var paramId = this.paramId();
  2825.     var worstParam = Number.MAX_VALUE;
  2826.     var worstItem = null;
  2827.     for (var j = 0; j < list.length; j++) {
  2828.         if (list[j] && list[j].params[paramId] < worstParam) {
  2829.             worstParam = list[j].params[paramId];
  2830.             worstItem = list[j];
  2831.         }
  2832.     }
  2833.     return worstItem;
  2834. };

  2835. Window_ShopStatus.prototype.update = function() {
  2836.     Window_Base.prototype.update.call(this);
  2837.     this.updatePage();
  2838. };

  2839. Window_ShopStatus.prototype.updatePage = function() {
  2840.     if (this.isPageChangeEnabled() && this.isPageChangeRequested()) {
  2841.         this.changePage();
  2842.     }
  2843. };

  2844. Window_ShopStatus.prototype.isPageChangeEnabled = function() {
  2845.     return this.visible && this.maxPages() >= 2;
  2846. };

  2847. Window_ShopStatus.prototype.isPageChangeRequested = function() {
  2848.     if (Input.isTriggered('shift')) {
  2849.         return true;
  2850.     }
  2851.     if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  2852.         return true;
  2853.     }
  2854.     return false;
  2855. };

  2856. Window_ShopStatus.prototype.isTouchedInsideFrame = function() {
  2857.     var x = this.canvasToLocalX(TouchInput.x);
  2858.     var y = this.canvasToLocalY(TouchInput.y);
  2859.     return x >= 0 && y >= 0 && x < this.width && y < this.height;
  2860. };

  2861. Window_ShopStatus.prototype.changePage = function() {
  2862.     this._pageIndex = (this._pageIndex + 1) % this.maxPages();
  2863.     this.refresh();
  2864.     SoundManager.playCursor();
  2865. };

  2866. //-----------------------------------------------------------------------------
  2867. // Window_NameEdit
  2868. //
  2869. // The window for editing an actor's name on the name input screen.

  2870. function Window_NameEdit() {
  2871.     this.initialize.apply(this, arguments);
  2872. }

  2873. Window_NameEdit.prototype = Object.create(Window_Base.prototype);
  2874. Window_NameEdit.prototype.constructor = Window_NameEdit;

  2875. Window_NameEdit.prototype.initialize = function(actor, maxLength) {
  2876.     var width = this.windowWidth();
  2877.     var height = this.windowHeight();
  2878.     var x = (Graphics.boxWidth - width) / 2;
  2879.     var y = (Graphics.boxHeight - (height + this.fittingHeight(9) + 8)) / 2;
  2880.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  2881.     this._actor = actor;
  2882.     this._name = actor.name().slice(0, this._maxLength);
  2883.     this._index = this._name.length;
  2884.     this._maxLength = maxLength;
  2885.     this._defaultName = this._name;
  2886.     this.deactivate();
  2887.     this.refresh();
  2888.     ImageManager.reserveFace(actor.faceName());
  2889. };

  2890. Window_NameEdit.prototype.windowWidth = function() {
  2891.     return 480;
  2892. };

  2893. Window_NameEdit.prototype.windowHeight = function() {
  2894.     return this.fittingHeight(4);
  2895. };

  2896. Window_NameEdit.prototype.name = function() {
  2897.     return this._name;
  2898. };

  2899. Window_NameEdit.prototype.restoreDefault = function() {
  2900.     this._name = this._defaultName;
  2901.     this._index = this._name.length;
  2902.     this.refresh();
  2903.     return this._name.length > 0;
  2904. };

  2905. Window_NameEdit.prototype.add = function(ch) {
  2906.     if (this._index < this._maxLength) {
  2907.         this._name += ch;
  2908.         this._index++;
  2909.         this.refresh();
  2910.         return true;
  2911.     } else {
  2912.         return false;
  2913.     }
  2914. };

  2915. Window_NameEdit.prototype.back = function() {
  2916.     if (this._index > 0) {
  2917.         this._index--;
  2918.         this._name = this._name.slice(0, this._index);
  2919.         this.refresh();
  2920.         return true;
  2921.     } else {
  2922.         return false;
  2923.     }
  2924. };

  2925. Window_NameEdit.prototype.faceWidth = function() {
  2926.     return 144;
  2927. };

  2928. Window_NameEdit.prototype.charWidth = function() {
  2929.     var text = $gameSystem.isJapanese() ? '\uff21' : 'A';
  2930.     return this.textWidth(text);
  2931. };

  2932. Window_NameEdit.prototype.left = function() {
  2933.     var nameCenter = (this.contentsWidth() + this.faceWidth()) / 2;
  2934.     var nameWidth = (this._maxLength + 1) * this.charWidth();
  2935.     return Math.min(nameCenter - nameWidth / 2, this.contentsWidth() - nameWidth);
  2936. };

  2937. Window_NameEdit.prototype.itemRect = function(index) {
  2938.     return {
  2939.         x: this.left() + index * this.charWidth(),
  2940.         y: 54,
  2941.         width: this.charWidth(),
  2942.         height: this.lineHeight()
  2943.     };
  2944. };

  2945. Window_NameEdit.prototype.underlineRect = function(index) {
  2946.     var rect = this.itemRect(index);
  2947.     rect.x++;
  2948.     rect.y += rect.height - 4;
  2949.     rect.width -= 2;
  2950.     rect.height = 2;
  2951.     return rect;
  2952. };

  2953. Window_NameEdit.prototype.underlineColor = function() {
  2954.     return this.normalColor();
  2955. };

  2956. Window_NameEdit.prototype.drawUnderline = function(index) {
  2957.     var rect = this.underlineRect(index);
  2958.     var color = this.underlineColor();
  2959.     this.contents.paintOpacity = 48;
  2960.     this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  2961.     this.contents.paintOpacity = 255;
  2962. };

  2963. Window_NameEdit.prototype.drawChar = function(index) {
  2964.     var rect = this.itemRect(index);
  2965.     this.resetTextColor();
  2966.     this.drawText(this._name[index] || '', rect.x, rect.y);
  2967. };

  2968. Window_NameEdit.prototype.refresh = function() {
  2969.     this.contents.clear();
  2970.     this.drawActorFace(this._actor, 0, 0);
  2971.     for (var i = 0; i < this._maxLength; i++) {
  2972.         this.drawUnderline(i);
  2973.     }
  2974.     for (var j = 0; j < this._name.length; j++) {
  2975.         this.drawChar(j);
  2976.     }
  2977.     var rect = this.itemRect(this._index);
  2978.     this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  2979. };

  2980. //-----------------------------------------------------------------------------
  2981. // Window_NameInput
  2982. //
  2983. // The window for selecting text characters on the name input screen.

  2984. function Window_NameInput() {
  2985.     this.initialize.apply(this, arguments);
  2986. }

  2987. Window_NameInput.prototype = Object.create(Window_Selectable.prototype);
  2988. Window_NameInput.prototype.constructor = Window_NameInput;
  2989. Window_NameInput.LATIN1 =
  2990.         [ 'A','B','C','D','E',  'a','b','c','d','e',
  2991.           'F','G','H','I','J',  'f','g','h','i','j',
  2992.           'K','L','M','N','O',  'k','l','m','n','o',
  2993.           'P','Q','R','S','T',  'p','q','r','s','t',
  2994.           'U','V','W','X','Y',  'u','v','w','x','y',
  2995.           'Z','[',']','^','_',  'z','{','}','|','~',
  2996.           '0','1','2','3','4',  '!','#',','%','&',
  2997.           '5','6','7','8','9',  '(',')','*','+','-',
  2998.           '/','=','@','<','>',  ':',';',' ','Page','OK' ];
  2999. Window_NameInput.LATIN2 =
  3000.         [ 'Á','É','Í','Ó','Ú',  'á','é','í','ó','ú',
  3001.           'À','È','Ì','Ò','Ù',  'à','è','ì','ò','ù',
  3002.           'Â','Ê','Î','Ô','Û',  'â','ê','î','ô','û',
  3003.           'Ä','Ë','Ï','Ö','Ü',  'ä','ë','ï','ö','ü',
  3004.           'Ā','Ē','Ī','Ō','Ū',  'ā','ē','ī','ō','ū',
  3005.           'Ã','Å','Æ','Ç','Ð',  'ã','å','æ','ç','ð',
  3006.           'Ñ','Õ','Ø','Š','Ŵ',  'ñ','õ','ø','š','ŵ',
  3007.           'Ý','Ŷ','Ÿ','Ž','Þ',  'ý','ÿ','ŷ','ž','þ',
  3008.           'IJ','Œ','ij','œ','ß',  '«','»',' ','Page','OK' ];
  3009. Window_NameInput.RUSSIA =
  3010.         [ 'А','Б','В','Г','Д',  'а','б','в','г','д',
  3011.           'Е','Ё','Ж','З','И',  'е','ё','ж','з','и',
  3012.           'Й','К','Л','М','Н',  'й','к','л','м','н',
  3013.           'О','П','Р','С','Т',  'о','п','р','с','т',
  3014.           'У','Ф','Х','Ц','Ч',  'у','ф','х','ц','ч',
  3015.           'Ш','Щ','Ъ','Ы','Ь',  'ш','щ','ъ','ы','ь',
  3016.           'Э','Ю','Я','^','_',  'э','ю','я','%','&',
  3017.           '0','1','2','3','4',  '(',')','*','+','-',
  3018.           '5','6','7','8','9',  ':',';',' ','','OK' ];
  3019. Window_NameInput.JAPAN1 =
  3020.         [ 'あ','い','う','え','お',  'が','ぎ','ぐ','げ','ご',
  3021.           'か','き','く','け','こ',  'ざ','じ','ず','ぜ','ぞ',
  3022.           'さ','し','す','せ','そ',  'だ','ぢ','づ','で','ど',
  3023.           'た','ち','つ','て','と',  'ば','び','ぶ','べ','ぼ',
  3024.           'な','に','ぬ','ね','の',  'ぱ','ぴ','ぷ','ぺ','ぽ',
  3025.           'は','ひ','ふ','へ','ほ',  'ぁ','ぃ','ぅ','ぇ','ぉ',
  3026.           'ま','み','む','め','も',  'っ','ゃ','ゅ','ょ','ゎ',
  3027.           'や','ゆ','よ','わ','ん',  'ー','~','・','=','☆',
  3028.           'ら','り','る','れ','ろ',  'ゔ','を',' ','カナ','決定' ];
  3029. Window_NameInput.JAPAN2 =
  3030.         [ 'ア','イ','ウ','エ','オ',  'ガ','ギ','グ','ゲ','ゴ',
  3031.           'カ','キ','ク','ケ','コ',  'ザ','ジ','ズ','ゼ','ゾ',
  3032.           'サ','シ','ス','セ','ソ',  'ダ','ヂ','ヅ','デ','ド',
  3033.           'タ','チ','ツ','テ','ト',  'バ','ビ','ブ','ベ','ボ',
  3034.           'ナ','ニ','ヌ','ネ','ノ',  'パ','ピ','プ','ペ','ポ',
  3035.           'ハ','ヒ','フ','ヘ','ホ',  'ァ','ィ','ゥ','ェ','ォ',
  3036.           'マ','ミ','ム','メ','モ',  'ッ','ャ','ュ','ョ','ヮ',
  3037.           'ヤ','ユ','ヨ','ワ','ン',  'ー','~','・','=','☆',
  3038.           'ラ','リ','ル','レ','ロ',  'ヴ','ヲ',' ','英数','決定' ];
  3039. Window_NameInput.JAPAN3 =
  3040.         [ 'A','B','C','D','E',  'a','b','c','d','e',
  3041.           'F','G','H','I','J',  'f','g','h','i','j',
  3042.           'K','L','M','N','O',  'k','l','m','n','o',
  3043.           'P','Q','R','S','T',  'p','q','r','s','t',
  3044.           'U','V','W','X','Y',  'u','v','w','x','y',
  3045.           'Z','[',']','^','_',  'z','{','}','|','~',
  3046.           '0','1','2','3','4',  '!','#','$','%','&',
  3047.           '5','6','7','8','9',  '(',')','*','+','-',
  3048.           '/','=','@','<','>',  ':',';',' ','かな','決定' ];

  3049. Window_NameInput.prototype.initialize = function(editWindow) {
  3050.     var x = editWindow.x;
  3051.     var y = editWindow.y + editWindow.height + 8;
  3052.     var width = editWindow.width;
  3053.     var height = this.windowHeight();
  3054.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  3055.     this._editWindow = editWindow;
  3056.     this._page = 0;
  3057.     this._index = 0;
  3058.     this.refresh();
  3059.     this.updateCursor();
  3060.     this.activate();
  3061. };

  3062. Window_NameInput.prototype.windowHeight = function() {
  3063.     return this.fittingHeight(9);
  3064. };

  3065. Window_NameInput.prototype.table = function() {
  3066.     if ($gameSystem.isJapanese()) {
  3067.         return [Window_NameInput.JAPAN1,
  3068.                 Window_NameInput.JAPAN2,
  3069.                 Window_NameInput.JAPAN3];
  3070.     } else if ($gameSystem.isRussian()) {
  3071.         return [Window_NameInput.RUSSIA];
  3072.     } else {
  3073.         return [Window_NameInput.LATIN1,
  3074.                 Window_NameInput.LATIN2];
  3075.     }
  3076. };

  3077. Window_NameInput.prototype.maxCols = function() {
  3078.     return 10;
  3079. };

  3080. Window_NameInput.prototype.maxItems = function() {
  3081.     return 90;
  3082. };

  3083. Window_NameInput.prototype.character = function() {
  3084.     return this._index < 88 ? this.table()[this._page][this._index] : '';
  3085. };

  3086. Window_NameInput.prototype.isPageChange = function() {
  3087.     return this._index === 88;
  3088. };

  3089. Window_NameInput.prototype.isOk = function() {
  3090.     return this._index === 89;
  3091. };

  3092. Window_NameInput.prototype.itemRect = function(index) {
  3093.     return {
  3094.         x: index % 10 * 42 + Math.floor(index % 10 / 5) * 24,
  3095.         y: Math.floor(index / 10) * this.lineHeight(),
  3096.         width: 42,
  3097.         height: this.lineHeight()
  3098.     };
  3099. };

  3100. Window_NameInput.prototype.refresh = function() {
  3101.     var table = this.table();
  3102.     this.contents.clear();
  3103.     this.resetTextColor();
  3104.     for (var i = 0; i < 90; i++) {
  3105.         var rect = this.itemRect(i);
  3106.         rect.x += 3;
  3107.         rect.width -= 6;
  3108.         this.drawText(table[this._page][i], rect.x, rect.y, rect.width, 'center');
  3109.     }
  3110. };

  3111. Window_NameInput.prototype.updateCursor = function() {
  3112.     var rect = this.itemRect(this._index);
  3113.     this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  3114. };

  3115. Window_NameInput.prototype.isCursorMovable = function() {
  3116.     return this.active;
  3117. };

  3118. Window_NameInput.prototype.cursorDown = function(wrap) {
  3119.     if (this._index < 80 || wrap) {
  3120.         this._index = (this._index + 10) % 90;
  3121.     }
  3122. };

  3123. Window_NameInput.prototype.cursorUp = function(wrap) {
  3124.     if (this._index >= 10 || wrap) {
  3125.         this._index = (this._index + 80) % 90;
  3126.     }
  3127. };

  3128. Window_NameInput.prototype.cursorRight = function(wrap) {
  3129.     if (this._index % 10 < 9) {
  3130.         this._index++;
  3131.     } else if (wrap) {
  3132.         this._index -= 9;
  3133.     }
  3134. };

  3135. Window_NameInput.prototype.cursorLeft = function(wrap) {
  3136.     if (this._index % 10 > 0) {
  3137.         this._index--;
  3138.     } else if (wrap) {
  3139.         this._index += 9;
  3140.     }
  3141. };

  3142. Window_NameInput.prototype.cursorPagedown = function() {
  3143.     this._page = (this._page + 1) % this.table().length;
  3144.     this.refresh();
  3145. };

  3146. Window_NameInput.prototype.cursorPageup = function() {
  3147.     this._page = (this._page + this.table().length - 1) % this.table().length;
  3148.     this.refresh();
  3149. };

  3150. Window_NameInput.prototype.processCursorMove = function() {
  3151.     var lastPage = this._page;
  3152.     Window_Selectable.prototype.processCursorMove.call(this);
  3153.     this.updateCursor();
  3154.     if (this._page !== lastPage) {
  3155.         SoundManager.playCursor();
  3156.     }
  3157. };

  3158. Window_NameInput.prototype.processHandling = function() {
  3159.     if (this.isOpen() && this.active) {
  3160.         if (Input.isTriggered('shift')) {
  3161.             this.processJump();
  3162.         }
  3163.         if (Input.isRepeated('cancel')) {
  3164.             this.processBack();
  3165.         }
  3166.         if (Input.isRepeated('ok')) {
  3167.             this.processOk();
  3168.         }
  3169.     }
  3170. };

  3171. Window_NameInput.prototype.isCancelEnabled = function() {
  3172.     return true;
  3173. };

  3174. Window_NameInput.prototype.processCancel = function() {
  3175.     this.processBack();
  3176. };

  3177. Window_NameInput.prototype.processJump = function() {
  3178.     if (this._index !== 89) {
  3179.         this._index = 89;
  3180.         SoundManager.playCursor();
  3181.     }
  3182. };

  3183. Window_NameInput.prototype.processBack = function() {
  3184.     if (this._editWindow.back()) {
  3185.         SoundManager.playCancel();
  3186.     }
  3187. };

  3188. Window_NameInput.prototype.processOk = function() {
  3189.     if (this.character()) {
  3190.         this.onNameAdd();
  3191.     } else if (this.isPageChange()) {
  3192.         SoundManager.playOk();
  3193.         this.cursorPagedown();
  3194.     } else if (this.isOk()) {
  3195.         this.onNameOk();
  3196.     }
  3197. };

  3198. Window_NameInput.prototype.onNameAdd = function() {
  3199.     if (this._editWindow.add(this.character())) {
  3200.         SoundManager.playOk();
  3201.     } else {
  3202.         SoundManager.playBuzzer();
  3203.     }
  3204. };

  3205. Window_NameInput.prototype.onNameOk = function() {
  3206.     if (this._editWindow.name() === '') {
  3207.         if (this._editWindow.restoreDefault()) {
  3208.             SoundManager.playOk();
  3209.         } else {
  3210.             SoundManager.playBuzzer();
  3211.         }
  3212.     } else {
  3213.         SoundManager.playOk();
  3214.         this.callOkHandler();
  3215.     }
  3216. };

  3217. //-----------------------------------------------------------------------------
  3218. // Window_ChoiceList
  3219. //
  3220. // The window used for the event command [Show Choices].

  3221. function Window_ChoiceList() {
  3222.     this.initialize.apply(this, arguments);
  3223. }

  3224. Window_ChoiceList.prototype = Object.create(Window_Command.prototype);
  3225. Window_ChoiceList.prototype.constructor = Window_ChoiceList;

  3226. Window_ChoiceList.prototype.initialize = function(messageWindow) {
  3227.     this._messageWindow = messageWindow;
  3228.     Window_Command.prototype.initialize.call(this, 0, 0);
  3229.     this.openness = 0;
  3230.     this.deactivate();
  3231.     this._background = 0;
  3232. };

  3233. Window_ChoiceList.prototype.start = function() {
  3234.     this.updatePlacement();
  3235.     this.updateBackground();
  3236.     this.refresh();
  3237.     this.selectDefault();
  3238.     this.open();
  3239.     this.activate();
  3240. };

  3241. Window_ChoiceList.prototype.selectDefault = function() {
  3242.     this.select($gameMessage.choiceDefaultType());
  3243. };

  3244. Window_ChoiceList.prototype.updatePlacement = function() {
  3245.     var positionType = $gameMessage.choicePositionType();
  3246.     var messageY = this._messageWindow.y;
  3247.     this.width = this.windowWidth();
  3248.     this.height = this.windowHeight();
  3249.     switch (positionType) {
  3250.     case 0:
  3251.         this.x = 0;
  3252.         break;
  3253.     case 1:
  3254.         this.x = (Graphics.boxWidth - this.width) / 2;
  3255.         break;
  3256.     case 2:
  3257.         this.x = Graphics.boxWidth - this.width;
  3258.         break;
  3259.     }
  3260.     if (messageY >= Graphics.boxHeight / 2) {
  3261.         this.y = messageY - this.height;
  3262.     } else {
  3263.         this.y = messageY + this._messageWindow.height;
  3264.     }
  3265. };

  3266. Window_ChoiceList.prototype.updateBackground = function() {
  3267.     this._background = $gameMessage.choiceBackground();
  3268.     this.setBackgroundType(this._background);
  3269. };

  3270. Window_ChoiceList.prototype.windowWidth = function() {
  3271.     var width = this.maxChoiceWidth() + this.padding * 2;
  3272.     return Math.min(width, Graphics.boxWidth);
  3273. };

  3274. Window_ChoiceList.prototype.numVisibleRows = function() {
  3275.     var messageY = this._messageWindow.y;
  3276.     var messageHeight = this._messageWindow.height;
  3277.     var centerY = Graphics.boxHeight / 2;
  3278.     var choices = $gameMessage.choices();
  3279.     var numLines = choices.length;
  3280.     var maxLines = 8;
  3281.     if (messageY < centerY && messageY + messageHeight > centerY) {
  3282.         maxLines = 4;
  3283.     }
  3284.     if (numLines > maxLines) {
  3285.         numLines = maxLines;
  3286.     }
  3287.     return numLines;
  3288. };

  3289. Window_ChoiceList.prototype.maxChoiceWidth = function() {
  3290.     var maxWidth = 96;
  3291.     var choices = $gameMessage.choices();
  3292.     for (var i = 0; i < choices.length; i++) {
  3293.         var choiceWidth = this.textWidthEx(choices[i]) + this.textPadding() * 2;
  3294.         if (maxWidth < choiceWidth) {
  3295.             maxWidth = choiceWidth;
  3296.         }
  3297.     }
  3298.     return maxWidth;
  3299. };

  3300. Window_ChoiceList.prototype.textWidthEx = function(text) {
  3301.     return this.drawTextEx(text, 0, this.contents.height);
  3302. };

  3303. Window_ChoiceList.prototype.contentsHeight = function() {
  3304.     return this.maxItems() * this.itemHeight();
  3305. };

  3306. Window_ChoiceList.prototype.makeCommandList = function() {
  3307.     var choices = $gameMessage.choices();
  3308.     for (var i = 0; i < choices.length; i++) {
  3309.         this.addCommand(choices[i], 'choice');
  3310.     }
  3311. };

  3312. Window_ChoiceList.prototype.drawItem = function(index) {
  3313.     var rect = this.itemRectForText(index);
  3314.     this.drawTextEx(this.commandName(index), rect.x, rect.y);
  3315. };

  3316. Window_ChoiceList.prototype.isCancelEnabled = function() {
  3317.     return $gameMessage.choiceCancelType() !== -1;
  3318. };

  3319. Window_ChoiceList.prototype.isOkTriggered = function() {
  3320.     return Input.isTriggered('ok');
  3321. };

  3322. Window_ChoiceList.prototype.callOkHandler = function() {
  3323.     $gameMessage.onChoice(this.index());
  3324.     this._messageWindow.terminateMessage();
  3325.     this.close();
  3326. };

  3327. Window_ChoiceList.prototype.callCancelHandler = function() {
  3328.     $gameMessage.onChoice($gameMessage.choiceCancelType());
  3329.     this._messageWindow.terminateMessage();
  3330.     this.close();
  3331. };

  3332. //-----------------------------------------------------------------------------
  3333. // Window_NumberInput
  3334. //
  3335. // The window used for the event command [Input Number].

  3336. function Window_NumberInput() {
  3337.     this.initialize.apply(this, arguments);
  3338. }

  3339. Window_NumberInput.prototype = Object.create(Window_Selectable.prototype);
  3340. Window_NumberInput.prototype.constructor = Window_NumberInput;

  3341. Window_NumberInput.prototype.initialize = function(messageWindow) {
  3342.     this._messageWindow = messageWindow;
  3343.     Window_Selectable.prototype.initialize.call(this, 0, 0, 0, 0);
  3344.     this._number = 0;
  3345.     this._maxDigits = 1;
  3346.     this.openness = 0;
  3347.     this.createButtons();
  3348.     this.deactivate();
  3349. };

  3350. Window_NumberInput.prototype.start = function() {
  3351.     this._maxDigits = $gameMessage.numInputMaxDigits();
  3352.     this._number = $gameVariables.value($gameMessage.numInputVariableId());
  3353.     this._number = this._number.clamp(0, Math.pow(10, this._maxDigits) - 1);
  3354.     this.updatePlacement();
  3355.     this.placeButtons();
  3356.     this.updateButtonsVisiblity();
  3357.     this.createContents();
  3358.     this.refresh();
  3359.     this.open();
  3360.     this.activate();
  3361.     this.select(0);
  3362. };

  3363. Window_NumberInput.prototype.updatePlacement = function() {
  3364.     var messageY = this._messageWindow.y;
  3365.     var spacing = 8;
  3366.     this.width = this.windowWidth();
  3367.     this.height = this.windowHeight();
  3368.     this.x = (Graphics.boxWidth - this.width) / 2;
  3369.     if (messageY >= Graphics.boxHeight / 2) {
  3370.         this.y = messageY - this.height - spacing;
  3371.     } else {
  3372.         this.y = messageY + this._messageWindow.height + spacing;
  3373.     }
  3374. };

  3375. Window_NumberInput.prototype.windowWidth = function() {
  3376.     return this.maxCols() * this.itemWidth() + this.padding * 2;
  3377. };

  3378. Window_NumberInput.prototype.windowHeight = function() {
  3379.     return this.fittingHeight(1);
  3380. };

  3381. Window_NumberInput.prototype.maxCols = function() {
  3382.     return this._maxDigits;
  3383. };

  3384. Window_NumberInput.prototype.maxItems = function() {
  3385.     return this._maxDigits;
  3386. };

  3387. Window_NumberInput.prototype.spacing = function() {
  3388.     return 0;
  3389. };

  3390. Window_NumberInput.prototype.itemWidth = function() {
  3391.     return 32;
  3392. };

  3393. Window_NumberInput.prototype.createButtons = function() {
  3394.     var bitmap = ImageManager.loadSystem('ButtonSet');
  3395.     var buttonWidth = 48;
  3396.     var buttonHeight = 48;
  3397.     this._buttons = [];
  3398.     for (var i = 0; i < 3; i++) {
  3399.         var button = new Sprite_Button();
  3400.         var x = buttonWidth * [1, 2, 4][i];
  3401.         var w = buttonWidth * (i === 2 ? 2 : 1);
  3402.         button.bitmap = bitmap;
  3403.         button.setColdFrame(x, 0, w, buttonHeight);
  3404.         button.setHotFrame(x, buttonHeight, w, buttonHeight);
  3405.         button.visible = false;
  3406.         this._buttons.push(button);
  3407.         this.addChild(button);
  3408.     }
  3409.     this._buttons[0].setClickHandler(this.onButtonDown.bind(this));
  3410.     this._buttons[1].setClickHandler(this.onButtonUp.bind(this));
  3411.     this._buttons[2].setClickHandler(this.onButtonOk.bind(this));
  3412. };

  3413. Window_NumberInput.prototype.placeButtons = function() {
  3414.     var numButtons = this._buttons.length;
  3415.     var spacing = 16;
  3416.     var totalWidth = -spacing;
  3417.     for (var i = 0; i < numButtons; i++) {
  3418.         totalWidth += this._buttons[i].width + spacing;
  3419.     }
  3420.     var x = (this.width - totalWidth) / 2;
  3421.     for (var j = 0; j < numButtons; j++) {
  3422.         var button = this._buttons[j];
  3423.         button.x = x;
  3424.         button.y = this.buttonY();
  3425.         x += button.width + spacing;
  3426.     }
  3427. };

  3428. Window_NumberInput.prototype.updateButtonsVisiblity = function() {
  3429.     if (TouchInput.date > Input.date) {
  3430.         this.showButtons();
  3431.     } else {
  3432.         this.hideButtons();
  3433.     }
  3434. };

  3435. Window_NumberInput.prototype.showButtons = function() {
  3436.     for (var i = 0; i < this._buttons.length; i++) {
  3437.         this._buttons[i].visible = true;
  3438.     }
  3439. };

  3440. Window_NumberInput.prototype.hideButtons = function() {
  3441.     for (var i = 0; i < this._buttons.length; i++) {
  3442.         this._buttons[i].visible = false;
  3443.     }
  3444. };

  3445. Window_NumberInput.prototype.buttonY = function() {
  3446.     var spacing = 8;
  3447.     if (this._messageWindow.y >= Graphics.boxHeight / 2) {
  3448.         return 0 - this._buttons[0].height - spacing;
  3449.     } else {
  3450.         return this.height + spacing;
  3451.     }
  3452. };

  3453. Window_NumberInput.prototype.update = function() {
  3454.     Window_Selectable.prototype.update.call(this);
  3455.     this.processDigitChange();
  3456. };

  3457. Window_NumberInput.prototype.processDigitChange = function() {
  3458.     if (this.isOpenAndActive()) {
  3459.         if (Input.isRepeated('up')) {
  3460.             this.changeDigit(true);
  3461.         } else if (Input.isRepeated('down')) {
  3462.             this.changeDigit(false);
  3463.         }
  3464.     }
  3465. };

  3466. Window_NumberInput.prototype.changeDigit = function(up) {
  3467.     var index = this.index();
  3468.     var place = Math.pow(10, this._maxDigits - 1 - index);
  3469.     var n = Math.floor(this._number / place) % 10;
  3470.     this._number -= n * place;
  3471.     if (up) {
  3472.         n = (n + 1) % 10;
  3473.     } else {
  3474.         n = (n + 9) % 10;
  3475.     }
  3476.     this._number += n * place;
  3477.     this.refresh();
  3478.     SoundManager.playCursor();
  3479. };

  3480. Window_NumberInput.prototype.isTouchOkEnabled = function() {
  3481.     return false;
  3482. };

  3483. Window_NumberInput.prototype.isOkEnabled = function() {
  3484.     return true;
  3485. };

  3486. Window_NumberInput.prototype.isCancelEnabled = function() {
  3487.     return false;
  3488. };

  3489. Window_NumberInput.prototype.isOkTriggered = function() {
  3490.     return Input.isTriggered('ok');
  3491. };

  3492. Window_NumberInput.prototype.processOk = function() {
  3493.     SoundManager.playOk();
  3494.     $gameVariables.setValue($gameMessage.numInputVariableId(), this._number);
  3495.     this._messageWindow.terminateMessage();
  3496.     this.updateInputData();
  3497.     this.deactivate();
  3498.     this.close();
  3499. };

  3500. Window_NumberInput.prototype.drawItem = function(index) {
  3501.     var rect = this.itemRect(index);
  3502.     var align = 'center';
  3503.     var s = this._number.padZero(this._maxDigits);
  3504.     var c = s.slice(index, index + 1);
  3505.     this.resetTextColor();
  3506.     this.drawText(c, rect.x, rect.y, rect.width, align);
  3507. };

  3508. Window_NumberInput.prototype.onButtonUp = function() {
  3509.     this.changeDigit(true);
  3510. };

  3511. Window_NumberInput.prototype.onButtonDown = function() {
  3512.     this.changeDigit(false);
  3513. };

  3514. Window_NumberInput.prototype.onButtonOk = function() {
  3515.     this.processOk();
  3516.     this.hideButtons();
  3517. };

  3518. //-----------------------------------------------------------------------------
  3519. // Window_EventItem
  3520. //
  3521. // The window used for the event command [Select Item].

  3522. function Window_EventItem() {
  3523.     this.initialize.apply(this, arguments);
  3524. }

  3525. Window_EventItem.prototype = Object.create(Window_ItemList.prototype);
  3526. Window_EventItem.prototype.constructor = Window_EventItem;

  3527. Window_EventItem.prototype.initialize = function(messageWindow) {
  3528.     this._messageWindow = messageWindow;
  3529.     var width = Graphics.boxWidth;
  3530.     var height = this.windowHeight();
  3531.     Window_ItemList.prototype.initialize.call(this, 0, 0, width, height);
  3532.     this.openness = 0;
  3533.     this.deactivate();
  3534.     this.setHandler('ok',     this.onOk.bind(this));
  3535.     this.setHandler('cancel', this.onCancel.bind(this));
  3536. };

  3537. Window_EventItem.prototype.windowHeight = function() {
  3538.     return this.fittingHeight(this.numVisibleRows());
  3539. };

  3540. Window_EventItem.prototype.numVisibleRows = function() {
  3541.     return 4;
  3542. };

  3543. Window_EventItem.prototype.start = function() {
  3544.     this.refresh();
  3545.     this.updatePlacement();
  3546.     this.select(0);
  3547.     this.open();
  3548.     this.activate();
  3549. };

  3550. Window_EventItem.prototype.updatePlacement = function() {
  3551.     if (this._messageWindow.y >= Graphics.boxHeight / 2) {
  3552.         this.y = 0;
  3553.     } else {
  3554.         this.y = Graphics.boxHeight - this.height;
  3555.     }
  3556. };

  3557. Window_EventItem.prototype.includes = function(item) {
  3558.     var itypeId = $gameMessage.itemChoiceItypeId();
  3559.     return DataManager.isItem(item) && item.itypeId === itypeId;
  3560. };

  3561. Window_EventItem.prototype.isEnabled = function(item) {
  3562.     return true;
  3563. };

  3564. Window_EventItem.prototype.onOk = function() {
  3565.     var item = this.item();
  3566.     var itemId = item ? item.id : 0;
  3567.     $gameVariables.setValue($gameMessage.itemChoiceVariableId(), itemId);
  3568.     this._messageWindow.terminateMessage();
  3569.     this.close();
  3570. };

  3571. Window_EventItem.prototype.onCancel = function() {
  3572.     $gameVariables.setValue($gameMessage.itemChoiceVariableId(), 0);
  3573.     this._messageWindow.terminateMessage();
  3574.     this.close();
  3575. };

  3576. //-----------------------------------------------------------------------------
  3577. // Window_Message
  3578. //
  3579. // The window for displaying text messages.

  3580. function Window_Message() {
  3581.     this.initialize.apply(this, arguments);
  3582. }

  3583. Window_Message.prototype = Object.create(Window_Base.prototype);
  3584. Window_Message.prototype.constructor = Window_Message;

  3585. Window_Message.prototype.initialize = function() {
  3586.     var width = this.windowWidth();
  3587.     var height = this.windowHeight();
  3588.     var x = (Graphics.boxWidth - width) / 2;
  3589.     Window_Base.prototype.initialize.call(this, x, 0, width, height);
  3590.     this.openness = 0;
  3591.     this.initMembers();
  3592.     this.createSubWindows();
  3593.     this.updatePlacement();
  3594. };

  3595. Window_Message.prototype.initMembers = function() {
  3596.     this._imageReservationId = Utils.generateRuntimeId();
  3597.     this._background = 0;
  3598.     this._positionType = 2;
  3599.     this._waitCount = 0;
  3600.     this._faceBitmap = null;
  3601.     this._textState = null;
  3602.     this.clearFlags();
  3603. };

  3604. Window_Message.prototype.subWindows = function() {
  3605.     return [this._goldWindow, this._choiceWindow,
  3606.             this._numberWindow, this._itemWindow];
  3607. };

  3608. Window_Message.prototype.createSubWindows = function() {
  3609.     this._goldWindow = new Window_Gold(0, 0);
  3610.     this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
  3611.     this._goldWindow.openness = 0;
  3612.     this._choiceWindow = new Window_ChoiceList(this);
  3613.     this._numberWindow = new Window_NumberInput(this);
  3614.     this._itemWindow = new Window_EventItem(this);
  3615. };

  3616. Window_Message.prototype.windowWidth = function() {
  3617.     return Graphics.boxWidth;
  3618. };

  3619. Window_Message.prototype.windowHeight = function() {
  3620.     return this.fittingHeight(this.numVisibleRows());
  3621. };

  3622. Window_Message.prototype.clearFlags = function() {
  3623.     this._showFast = false;
  3624.     this._lineShowFast = false;
  3625.     this._pauseSkip = false;
  3626. };

  3627. Window_Message.prototype.numVisibleRows = function() {
  3628.     return 4;
  3629. };

  3630. Window_Message.prototype.update = function() {
  3631.     this.checkToNotClose();
  3632.     Window_Base.prototype.update.call(this);
  3633.     while (!this.isOpening() && !this.isClosing()) {
  3634.         if (this.updateWait()) {
  3635.             return;
  3636.         } else if (this.updateLoading()) {
  3637.             return;
  3638.         } else if (this.updateInput()) {
  3639.             return;
  3640.         } else if (this.updateMessage()) {
  3641.             return;
  3642.         } else if (this.canStart()) {
  3643.             this.startMessage();
  3644.         } else {
  3645.             this.startInput();
  3646.             return;
  3647.         }
  3648.     }
  3649. };

  3650. Window_Message.prototype.checkToNotClose = function() {
  3651.     if (this.isClosing() && this.isOpen()) {
  3652.         if (this.doesContinue()) {
  3653.             this.open();
  3654.         }
  3655.     }
  3656. };

  3657. Window_Message.prototype.canStart = function() {
  3658.     return $gameMessage.hasText() && !$gameMessage.scrollMode();
  3659. };

  3660. Window_Message.prototype.startMessage = function() {
  3661.     this._textState = {};
  3662.     this._textState.index = 0;
  3663.     this._textState.text = this.convertEscapeCharacters($gameMessage.allText());
  3664.     this.newPage(this._textState);
  3665.     this.updatePlacement();
  3666.     this.updateBackground();
  3667.     this.open();
  3668. };

  3669. Window_Message.prototype.updatePlacement = function() {
  3670.     this._positionType = $gameMessage.positionType();
  3671.     this.y = this._positionType * (Graphics.boxHeight - this.height) / 2;
  3672.     this._goldWindow.y = this.y > 0 ? 0 : Graphics.boxHeight - this._goldWindow.height;
  3673. };

  3674. Window_Message.prototype.updateBackground = function() {
  3675.     this._background = $gameMessage.background();
  3676.     this.setBackgroundType(this._background);
  3677. };

  3678. Window_Message.prototype.terminateMessage = function() {
  3679.     this.close();
  3680.     this._goldWindow.close();
  3681.     $gameMessage.clear();
  3682. };

  3683. Window_Message.prototype.updateWait = function() {
  3684.     if (this._waitCount > 0) {
  3685.         this._waitCount--;
  3686.         return true;
  3687.     } else {
  3688.         return false;
  3689.     }
  3690. };

  3691. Window_Message.prototype.updateLoading = function() {
  3692.     if (this._faceBitmap) {
  3693.         if (this._faceBitmap.isReady()) {
  3694.             this.drawMessageFace();
  3695.             this._faceBitmap = null;
  3696.             return false;
  3697.         } else {
  3698.             return true;
  3699.         }
  3700.     } else {
  3701.         return false;
  3702.     }
  3703. };

  3704. Window_Message.prototype.updateInput = function() {
  3705.     if (this.isAnySubWindowActive()) {
  3706.         return true;
  3707.     }
  3708.     if (this.pause) {
  3709.         if (this.isTriggered()) {
  3710.             Input.update();
  3711.             this.pause = false;
  3712.             if (!this._textState) {
  3713.                 this.terminateMessage();
  3714.             }
  3715.         }
  3716.         return true;
  3717.     }
  3718.     return false;
  3719. };

  3720. Window_Message.prototype.isAnySubWindowActive = function() {
  3721.     return (this._choiceWindow.active ||
  3722.             this._numberWindow.active ||
  3723.             this._itemWindow.active);
  3724. };

  3725. Window_Message.prototype.updateMessage = function() {
  3726.     if (this._textState) {
  3727.         while (!this.isEndOfText(this._textState)) {
  3728.             if (this.needsNewPage(this._textState)) {
  3729.                 this.newPage(this._textState);
  3730.             }
  3731.             this.updateShowFast();
  3732.             this.processCharacter(this._textState);
  3733.             if (!this._showFast && !this._lineShowFast) {
  3734.                 break;
  3735.             }
  3736.             if (this.pause || this._waitCount > 0) {
  3737.                 break;
  3738.             }
  3739.         }
  3740.         if (this.isEndOfText(this._textState)) {
  3741.             this.onEndOfText();
  3742.         }
  3743.         return true;
  3744.     } else {
  3745.         return false;
  3746.     }
  3747. };

  3748. Window_Message.prototype.onEndOfText = function() {
  3749.     if (!this.startInput()) {
  3750.         if (!this._pauseSkip) {
  3751.             this.startPause();
  3752.         } else {
  3753.             this.terminateMessage();
  3754.         }
  3755.     }
  3756.     this._textState = null;
  3757. };

  3758. Window_Message.prototype.startInput = function() {
  3759.     if ($gameMessage.isChoice()) {
  3760.         this._choiceWindow.start();
  3761.         return true;
  3762.     } else if ($gameMessage.isNumberInput()) {
  3763.         this._numberWindow.start();
  3764.         return true;
  3765.     } else if ($gameMessage.isItemChoice()) {
  3766.         this._itemWindow.start();
  3767.         return true;
  3768.     } else {
  3769.         return false;
  3770.     }
  3771. };

  3772. Window_Message.prototype.isTriggered = function() {
  3773.     return (Input.isRepeated('ok') || Input.isRepeated('cancel') ||
  3774.             TouchInput.isRepeated());
  3775. };

  3776. Window_Message.prototype.doesContinue = function() {
  3777.     return ($gameMessage.hasText() && !$gameMessage.scrollMode() &&
  3778.             !this.areSettingsChanged());
  3779. };

  3780. Window_Message.prototype.areSettingsChanged = function() {
  3781.     return (this._background !== $gameMessage.background() ||
  3782.             this._positionType !== $gameMessage.positionType());
  3783. };

  3784. Window_Message.prototype.updateShowFast = function() {
  3785.     if (this.isTriggered()) {
  3786.         this._showFast = true;
  3787.     }
  3788. };

  3789. Window_Message.prototype.newPage = function(textState) {
  3790.     this.contents.clear();
  3791.     this.resetFontSettings();
  3792.     this.clearFlags();
  3793.     this.loadMessageFace();
  3794.     textState.x = this.newLineX();
  3795.     textState.y = 0;
  3796.     textState.left = this.newLineX();
  3797.     textState.height = this.calcTextHeight(textState, false);
  3798. };

  3799. Window_Message.prototype.loadMessageFace = function() {
  3800.     this._faceBitmap = ImageManager.reserveFace($gameMessage.faceName(), 0, this._imageReservationId);
  3801. };

  3802. Window_Message.prototype.drawMessageFace = function() {
  3803.     this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), 0, 0);
  3804.     ImageManager.releaseReservation(this._imageReservationId);
  3805. };

  3806. Window_Message.prototype.newLineX = function() {
  3807.     return $gameMessage.faceName() === '' ? 0 : 168;
  3808. };

  3809. Window_Message.prototype.processNewLine = function(textState) {
  3810.     this._lineShowFast = false;
  3811.     Window_Base.prototype.processNewLine.call(this, textState);
  3812.     if (this.needsNewPage(textState)) {
  3813.         this.startPause();
  3814.     }
  3815. };

  3816. Window_Message.prototype.processNewPage = function(textState) {
  3817.     Window_Base.prototype.processNewPage.call(this, textState);
  3818.     if (textState.text[textState.index] === '\n') {
  3819.         textState.index++;
  3820.     }
  3821.     textState.y = this.contents.height;
  3822.     this.startPause();
  3823. };

  3824. Window_Message.prototype.isEndOfText = function(textState) {
  3825.     return textState.index >= textState.text.length;
  3826. };

  3827. Window_Message.prototype.needsNewPage = function(textState) {
  3828.     return (!this.isEndOfText(textState) &&
  3829.             textState.y + textState.height > this.contents.height);
  3830. };

  3831. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  3832.     switch (code) {
  3833.     case ':
  3834.         this._goldWindow.open();
  3835.         break;
  3836.     case '.':
  3837.         this.startWait(15);
  3838.         break;
  3839.     case '|':
  3840.         this.startWait(60);
  3841.         break;
  3842.     case '!':
  3843.         this.startPause();
  3844.         break;
  3845.     case '>':
  3846.         this._lineShowFast = true;
  3847.         break;
  3848.     case '<':
  3849.         this._lineShowFast = false;
  3850.         break;
  3851.     case '^':
  3852.         this._pauseSkip = true;
  3853.         break;
  3854.     default:
  3855.         Window_Base.prototype.processEscapeCharacter.call(this, code, textState);
  3856.         break;
  3857.     }
  3858. };

  3859. Window_Message.prototype.startWait = function(count) {
  3860.     this._waitCount = count;
  3861. };

  3862. Window_Message.prototype.startPause = function() {
  3863.     this.startWait(10);
  3864.     this.pause = true;
  3865. };

  3866. //-----------------------------------------------------------------------------
  3867. // Window_ScrollText
  3868. //
  3869. // The window for displaying scrolling text. No frame is displayed, but it
  3870. // is handled as a window for convenience.

  3871. function Window_ScrollText() {
  3872.     this.initialize.apply(this, arguments);
  3873. }

  3874. Window_ScrollText.prototype = Object.create(Window_Base.prototype);
  3875. Window_ScrollText.prototype.constructor = Window_ScrollText;

  3876. Window_ScrollText.prototype.initialize = function() {
  3877.     var width = Graphics.boxWidth;
  3878.     var height = Graphics.boxHeight;
  3879.     Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  3880.     this.opacity = 0;
  3881.     this.hide();
  3882.     this._text = '';
  3883.     this._allTextHeight = 0;
  3884. };

  3885. Window_ScrollText.prototype.update = function() {
  3886.     Window_Base.prototype.update.call(this);
  3887.     if ($gameMessage.scrollMode()) {
  3888.         if (this._text) {
  3889.             this.updateMessage();
  3890.         }
  3891.         if (!this._text && $gameMessage.hasText()) {
  3892.             this.startMessage();
  3893.         }
  3894.     }
  3895. };

  3896. Window_ScrollText.prototype.startMessage = function() {
  3897.     this._text = $gameMessage.allText();
  3898.     this.refresh();
  3899.     this.show();
  3900. };

  3901. Window_ScrollText.prototype.refresh = function() {
  3902.     var textState = { index: 0 };
  3903.     textState.text = this.convertEscapeCharacters(this._text);
  3904.     this.resetFontSettings();
  3905.     this._allTextHeight = this.calcTextHeight(textState, true);
  3906.     this.createContents();
  3907.     this.origin.y = -this.height;
  3908.     this.drawTextEx(this._text, this.textPadding(), 1);
  3909. };

  3910. Window_ScrollText.prototype.contentsHeight = function() {
  3911.     return Math.max(this._allTextHeight, 1);
  3912. };

  3913. Window_ScrollText.prototype.updateMessage = function() {
  3914.     this.origin.y += this.scrollSpeed();
  3915.     if (this.origin.y >= this.contents.height) {
  3916.         this.terminateMessage();
  3917.     }
  3918. };

  3919. Window_ScrollText.prototype.scrollSpeed = function() {
  3920.     var speed = $gameMessage.scrollSpeed() / 2;
  3921.     if (this.isFastForward()) {
  3922.         speed *= this.fastForwardRate();
  3923.     }
  3924.     return speed;
  3925. };

  3926. Window_ScrollText.prototype.isFastForward = function() {
  3927.     if ($gameMessage.scrollNoFast()) {
  3928.         return false;
  3929.     } else {
  3930.         return (Input.isPressed('ok') || Input.isPressed('shift') ||
  3931.                 TouchInput.isPressed());
  3932.     }
  3933. };

  3934. Window_ScrollText.prototype.fastForwardRate = function() {
  3935.     return 3;
  3936. };

  3937. Window_ScrollText.prototype.terminateMessage = function() {
  3938.     this._text = null;
  3939.     $gameMessage.clear();
  3940.     this.hide();
  3941. };

  3942. //-----------------------------------------------------------------------------
  3943. // Window_MapName
  3944. //
  3945. // The window for displaying the map name on the map screen.

  3946. function Window_MapName() {
  3947.     this.initialize.apply(this, arguments);
  3948. }

  3949. Window_MapName.prototype = Object.create(Window_Base.prototype);
  3950. Window_MapName.prototype.constructor = Window_MapName;

  3951. Window_MapName.prototype.initialize = function() {
  3952.     var wight = this.windowWidth();
  3953.     var height = this.windowHeight();
  3954.     Window_Base.prototype.initialize.call(this, 0, 0, wight, height);
  3955.     this.opacity = 0;
  3956.     this.contentsOpacity = 0;
  3957.     this._showCount = 0;
  3958.     this.refresh();
  3959. };

  3960. Window_MapName.prototype.windowWidth = function() {
  3961.     return 360;
  3962. };

  3963. Window_MapName.prototype.windowHeight = function() {
  3964.     return this.fittingHeight(1);
  3965. };

  3966. Window_MapName.prototype.update = function() {
  3967.     Window_Base.prototype.update.call(this);
  3968.     if (this._showCount > 0 && $gameMap.isNameDisplayEnabled()) {
  3969.         this.updateFadeIn();
  3970.         this._showCount--;
  3971.     } else {
  3972.         this.updateFadeOut();
  3973.     }
  3974. };

  3975. Window_MapName.prototype.updateFadeIn = function() {
  3976.     this.contentsOpacity += 16;
  3977. };

  3978. Window_MapName.prototype.updateFadeOut = function() {
  3979.     this.contentsOpacity -= 16;
  3980. };

  3981. Window_MapName.prototype.open = function() {
  3982.     this.refresh();
  3983.     this._showCount = 150;
  3984. };

  3985. Window_MapName.prototype.close = function() {
  3986.     this._showCount = 0;
  3987. };

  3988. Window_MapName.prototype.refresh = function() {
  3989.     this.contents.clear();
  3990.     if ($gameMap.displayName()) {
  3991.         var width = this.contentsWidth();
  3992.         this.drawBackground(0, 0, width, this.lineHeight());
  3993.         this.drawText($gameMap.displayName(), 0, 0, width, 'center');
  3994.     }
  3995. };

  3996. Window_MapName.prototype.drawBackground = function(x, y, width, height) {
  3997.     var color1 = this.dimColor1();
  3998.     var color2 = this.dimColor2();
  3999.     this.contents.gradientFillRect(x, y, width / 2, height, color2, color1);
  4000.     this.contents.gradientFillRect(x + width / 2, y, width / 2, height, color1, color2);
  4001. };

  4002. //-----------------------------------------------------------------------------
  4003. // Window_BattleLog
  4004. //
  4005. // The window for displaying battle progress. No frame is displayed, but it is
  4006. // handled as a window for convenience.

  4007. function Window_BattleLog() {
  4008.     this.initialize.apply(this, arguments);
  4009. }

  4010. Window_BattleLog.prototype = Object.create(Window_Selectable.prototype);
  4011. Window_BattleLog.prototype.constructor = Window_BattleLog;

  4012. Window_BattleLog.prototype.initialize = function() {
  4013.     var width = this.windowWidth();
  4014.     var height = this.windowHeight();
  4015.     Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  4016.     this.opacity = 0;
  4017.     this._lines = [];
  4018.     this._methods = [];
  4019.     this._waitCount = 0;
  4020.     this._waitMode = '';
  4021.     this._baseLineStack = [];
  4022.     this._spriteset = null;
  4023.     this.createBackBitmap();
  4024.     this.createBackSprite();
  4025.     this.refresh();
  4026. };

  4027. Window_BattleLog.prototype.setSpriteset = function(spriteset) {
  4028.     this._spriteset = spriteset;
  4029. };

  4030. Window_BattleLog.prototype.windowWidth = function() {
  4031.     return Graphics.boxWidth;
  4032. };

  4033. Window_BattleLog.prototype.windowHeight = function() {
  4034.     return this.fittingHeight(this.maxLines());
  4035. };

  4036. Window_BattleLog.prototype.maxLines = function() {
  4037.     return 10;
  4038. };

  4039. Window_BattleLog.prototype.createBackBitmap = function() {
  4040.     this._backBitmap = new Bitmap(this.width, this.height);
  4041. };

  4042. Window_BattleLog.prototype.createBackSprite = function() {
  4043.     this._backSprite = new Sprite();
  4044.     this._backSprite.bitmap = this._backBitmap;
  4045.     this._backSprite.y = this.y;
  4046.     this.addChildToBack(this._backSprite);
  4047. };

  4048. Window_BattleLog.prototype.numLines = function() {
  4049.     return this._lines.length;
  4050. };

  4051. Window_BattleLog.prototype.messageSpeed = function() {
  4052.     return 16;
  4053. };

  4054. Window_BattleLog.prototype.isBusy = function() {
  4055.     return this._waitCount > 0 || this._waitMode || this._methods.length > 0;
  4056. };

  4057. Window_BattleLog.prototype.update = function() {
  4058.     if (!this.updateWait()) {
  4059.         this.callNextMethod();
  4060.     }
  4061. };

  4062. Window_BattleLog.prototype.updateWait = function() {
  4063.     return this.updateWaitCount() || this.updateWaitMode();
  4064. };

  4065. Window_BattleLog.prototype.updateWaitCount = function() {
  4066.     if (this._waitCount > 0) {
  4067.         this._waitCount -= this.isFastForward() ? 3 : 1;
  4068.         if (this._waitCount < 0) {
  4069.             this._waitCount = 0;
  4070.         }
  4071.         return true;
  4072.     }
  4073.     return false;
  4074. };

  4075. Window_BattleLog.prototype.updateWaitMode = function() {
  4076.     var waiting = false;
  4077.     switch (this._waitMode) {
  4078.     case 'effect':
  4079.         waiting = this._spriteset.isEffecting();
  4080.         break;
  4081.     case 'movement':
  4082.         waiting = this._spriteset.isAnyoneMoving();
  4083.         break;
  4084.     }
  4085.     if (!waiting) {
  4086.         this._waitMode = '';
  4087.     }
  4088.     return waiting;
  4089. };

  4090. Window_BattleLog.prototype.setWaitMode = function(waitMode) {
  4091.     this._waitMode = waitMode;
  4092. };

  4093. Window_BattleLog.prototype.callNextMethod = function() {
  4094.     if (this._methods.length > 0) {
  4095.         var method = this._methods.shift();
  4096.         if (method.name && this[method.name]) {
  4097.             this[method.name].apply(this, method.params);
  4098.         } else {
  4099.             throw new Error('Method not found: ' + method.name);
  4100.         }
  4101.     }
  4102. };

  4103. Window_BattleLog.prototype.isFastForward = function() {
  4104.     return (Input.isLongPressed('ok') || Input.isPressed('shift') ||
  4105.             TouchInput.isLongPressed());
  4106. };

  4107. Window_BattleLog.prototype.push = function(methodName) {
  4108.     var methodArgs = Array.prototype.slice.call(arguments, 1);
  4109.     this._methods.push({ name: methodName, params: methodArgs });
  4110. };

  4111. Window_BattleLog.prototype.clear = function() {
  4112.     this._lines = [];
  4113.     this._baseLineStack = [];
  4114.     this.refresh();
  4115. };

  4116. Window_BattleLog.prototype.wait = function() {
  4117.     this._waitCount = this.messageSpeed();
  4118. };

  4119. Window_BattleLog.prototype.waitForEffect = function() {
  4120.     this.setWaitMode('effect');
  4121. };

  4122. Window_BattleLog.prototype.waitForMovement = function() {
  4123.     this.setWaitMode('movement');
  4124. };

  4125. Window_BattleLog.prototype.addText = function(text) {
  4126.     this._lines.push(text);
  4127.     this.refresh();
  4128.     this.wait();
  4129. };

  4130. Window_BattleLog.prototype.pushBaseLine = function() {
  4131.     this._baseLineStack.push(this._lines.length);
  4132. };

  4133. Window_BattleLog.prototype.popBaseLine = function() {
  4134.     var baseLine = this._baseLineStack.pop();
  4135.     while (this._lines.length > baseLine) {
  4136.         this._lines.pop();
  4137.     }
  4138. };

  4139. Window_BattleLog.prototype.waitForNewLine = function() {
  4140.     var baseLine = 0;
  4141.     if (this._baseLineStack.length > 0) {
  4142.         baseLine = this._baseLineStack[this._baseLineStack.length - 1];
  4143.     }
  4144.     if (this._lines.length > baseLine) {
  4145.         this.wait();
  4146.     }
  4147. };

  4148. Window_BattleLog.prototype.popupDamage = function(target) {
  4149.     target.startDamagePopup();
  4150. };

  4151. Window_BattleLog.prototype.performActionStart = function(subject, action) {
  4152.     subject.performActionStart(action);
  4153. };

  4154. Window_BattleLog.prototype.performAction = function(subject, action) {
  4155.     subject.performAction(action);
  4156. };

  4157. Window_BattleLog.prototype.performActionEnd = function(subject) {
  4158.     subject.performActionEnd();
  4159. };

  4160. Window_BattleLog.prototype.performDamage = function(target) {
  4161.     target.performDamage();
  4162. };

  4163. Window_BattleLog.prototype.performMiss = function(target) {
  4164.     target.performMiss();
  4165. };

  4166. Window_BattleLog.prototype.performRecovery = function(target) {
  4167.     target.performRecovery();
  4168. };

  4169. Window_BattleLog.prototype.performEvasion = function(target) {
  4170.     target.performEvasion();
  4171. };

  4172. Window_BattleLog.prototype.performMagicEvasion = function(target) {
  4173.     target.performMagicEvasion();
  4174. };

  4175. Window_BattleLog.prototype.performCounter = function(target) {
  4176.     target.performCounter();
  4177. };

  4178. Window_BattleLog.prototype.performReflection = function(target) {
  4179.     target.performReflection();
  4180. };

  4181. Window_BattleLog.prototype.performSubstitute = function(substitute, target) {
  4182.     substitute.performSubstitute(target);
  4183. };

  4184. Window_BattleLog.prototype.performCollapse = function(target) {
  4185.     target.performCollapse();
  4186. };

  4187. Window_BattleLog.prototype.showAnimation = function(subject, targets, animationId) {
  4188.     if (animationId < 0) {
  4189.         this.showAttackAnimation(subject, targets);
  4190.     } else {
  4191.         this.showNormalAnimation(targets, animationId);
  4192.     }
  4193. };

  4194. Window_BattleLog.prototype.showAttackAnimation = function(subject, targets) {
  4195.     if (subject.isActor()) {
  4196.         this.showActorAttackAnimation(subject, targets);
  4197.     } else {
  4198.         this.showEnemyAttackAnimation(subject, targets);
  4199.     }
  4200. };

  4201. Window_BattleLog.prototype.showActorAttackAnimation = function(subject, targets) {
  4202.     this.showNormalAnimation(targets, subject.attackAnimationId1(), false);
  4203.     this.showNormalAnimation(targets, subject.attackAnimationId2(), true);
  4204. };

  4205. Window_BattleLog.prototype.showEnemyAttackAnimation = function(subject, targets) {
  4206.     SoundManager.playEnemyAttack();
  4207. };

  4208. Window_BattleLog.prototype.showNormalAnimation = function(targets, animationId, mirror) {
  4209.     var animation = $dataAnimations[animationId];
  4210.     if (animation) {
  4211.         var delay = this.animationBaseDelay();
  4212.         var nextDelay = this.animationNextDelay();
  4213.         targets.forEach(function(target) {
  4214.             target.startAnimation(animationId, mirror, delay);
  4215.             delay += nextDelay;
  4216.         });
  4217.     }
  4218. };

  4219. Window_BattleLog.prototype.animationBaseDelay = function() {
  4220.     return 8;
  4221. };

  4222. Window_BattleLog.prototype.animationNextDelay = function() {
  4223.     return 12;
  4224. };

  4225. Window_BattleLog.prototype.refresh = function() {
  4226.     this.drawBackground();
  4227.     this.contents.clear();
  4228.     for (var i = 0; i < this._lines.length; i++) {
  4229.         this.drawLineText(i);
  4230.     }
  4231. };

  4232. Window_BattleLog.prototype.drawBackground = function() {
  4233.     var rect = this.backRect();
  4234.     var color = this.backColor();
  4235.     this._backBitmap.clear();
  4236.     this._backBitmap.paintOpacity = this.backPaintOpacity();
  4237.     this._backBitmap.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  4238.     this._backBitmap.paintOpacity = 255;
  4239. };

  4240. Window_BattleLog.prototype.backRect = function() {
  4241.     return {
  4242.         x: 0,
  4243.         y: this.padding,
  4244.         width: this.width,
  4245.         height: this.numLines() * this.lineHeight()
  4246.     };
  4247. };

  4248. Window_BattleLog.prototype.backColor = function() {
  4249.     return '#000000';
  4250. };

  4251. Window_BattleLog.prototype.backPaintOpacity = function() {
  4252.     return 64;
  4253. };

  4254. Window_BattleLog.prototype.drawLineText = function(index) {
  4255.     var rect = this.itemRectForText(index);
  4256.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4257.     this.drawTextEx(this._lines[index], rect.x, rect.y, rect.width);
  4258. };

  4259. Window_BattleLog.prototype.startTurn = function() {
  4260.     this.push('wait');
  4261. };

  4262. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
  4263.     var item = action.item();
  4264.     this.push('performActionStart', subject, action);
  4265.     this.push('waitForMovement');
  4266.     this.push('performAction', subject, action);
  4267.     this.push('showAnimation', subject, targets.clone(), item.animationId);
  4268.     this.displayAction(subject, item);
  4269. };

  4270. Window_BattleLog.prototype.endAction = function(subject) {
  4271.     this.push('waitForNewLine');
  4272.     this.push('clear');
  4273.     this.push('performActionEnd', subject);
  4274. };

  4275. Window_BattleLog.prototype.displayCurrentState = function(subject) {
  4276.     var stateText = subject.mostImportantStateText();
  4277.     if (stateText) {
  4278.         this.push('addText', subject.name() + stateText);
  4279.         this.push('wait');
  4280.         this.push('clear');
  4281.     }
  4282. };

  4283. Window_BattleLog.prototype.displayRegeneration = function(subject) {
  4284.     this.push('popupDamage', subject);
  4285. };

  4286. Window_BattleLog.prototype.displayAction = function(subject, item) {
  4287.     var numMethods = this._methods.length;
  4288.     if (DataManager.isSkill(item)) {
  4289.         if (item.message1) {
  4290.             this.push('addText', subject.name() + item.message1.format(item.name));
  4291.         }
  4292.         if (item.message2) {
  4293.             this.push('addText', item.message2.format(item.name));
  4294.         }
  4295.     } else {
  4296.         this.push('addText', TextManager.useItem.format(subject.name(), item.name));
  4297.     }
  4298.     if (this._methods.length === numMethods) {
  4299.         this.push('wait');
  4300.     }
  4301. };

  4302. Window_BattleLog.prototype.displayCounter = function(target) {
  4303.     this.push('performCounter', target);
  4304.     this.push('addText', TextManager.counterAttack.format(target.name()));
  4305. };

  4306. Window_BattleLog.prototype.displayReflection = function(target) {
  4307.     this.push('performReflection', target);
  4308.     this.push('addText', TextManager.magicReflection.format(target.name()));
  4309. };

  4310. Window_BattleLog.prototype.displaySubstitute = function(substitute, target) {
  4311.     var substName = substitute.name();
  4312.     this.push('performSubstitute', substitute, target);
  4313.     this.push('addText', TextManager.substitute.format(substName, target.name()));
  4314. };

  4315. Window_BattleLog.prototype.displayActionResults = function(subject, target) {
  4316.     if (target.result().used) {
  4317.         this.push('pushBaseLine');
  4318.         this.displayCritical(target);
  4319.         this.push('popupDamage', target);
  4320.         this.push('popupDamage', subject);
  4321.         this.displayDamage(target);
  4322.         this.displayAffectedStatus(target);
  4323.         this.displayFailure(target);
  4324.         this.push('waitForNewLine');
  4325.         this.push('popBaseLine');
  4326.     }
  4327. };

  4328. Window_BattleLog.prototype.displayFailure = function(target) {
  4329.     if (target.result().isHit() && !target.result().success) {
  4330.         this.push('addText', TextManager.actionFailure.format(target.name()));
  4331.     }
  4332. };

  4333. Window_BattleLog.prototype.displayCritical = function(target) {
  4334.     if (target.result().critical) {
  4335.         if (target.isActor()) {
  4336.             this.push('addText', TextManager.criticalToActor);
  4337.         } else {
  4338.             this.push('addText', TextManager.criticalToEnemy);
  4339.         }
  4340.     }
  4341. };

  4342. Window_BattleLog.prototype.displayDamage = function(target) {
  4343.     if (target.result().missed) {
  4344.         this.displayMiss(target);
  4345.     } else if (target.result().evaded) {
  4346.         this.displayEvasion(target);
  4347.     } else {
  4348.         this.displayHpDamage(target);
  4349.         this.displayMpDamage(target);
  4350.         this.displayTpDamage(target);
  4351.     }
  4352. };

  4353. Window_BattleLog.prototype.displayMiss = function(target) {
  4354.     var fmt;
  4355.     if (target.result().physical) {
  4356.         fmt = target.isActor() ? TextManager.actorNoHit : TextManager.enemyNoHit;
  4357.         this.push('performMiss', target);
  4358.     } else {
  4359.         fmt = TextManager.actionFailure;
  4360.     }
  4361.     this.push('addText', fmt.format(target.name()));
  4362. };

  4363. Window_BattleLog.prototype.displayEvasion = function(target) {
  4364.     var fmt;
  4365.     if (target.result().physical) {
  4366.         fmt = TextManager.evasion;
  4367.         this.push('performEvasion', target);
  4368.     } else {
  4369.         fmt = TextManager.magicEvasion;
  4370.         this.push('performMagicEvasion', target);
  4371.     }
  4372.     this.push('addText', fmt.format(target.name()));
  4373. };

  4374. Window_BattleLog.prototype.displayHpDamage = function(target) {
  4375.     if (target.result().hpAffected) {
  4376.         if (target.result().hpDamage > 0 && !target.result().drain) {
  4377.             this.push('performDamage', target);
  4378.         }
  4379.         if (target.result().hpDamage < 0) {
  4380.             this.push('performRecovery', target);
  4381.         }
  4382.         this.push('addText', this.makeHpDamageText(target));
  4383.     }
  4384. };

  4385. Window_BattleLog.prototype.displayMpDamage = function(target) {
  4386.     if (target.isAlive() && target.result().mpDamage !== 0) {
  4387.         if (target.result().mpDamage < 0) {
  4388.             this.push('performRecovery', target);
  4389.         }
  4390.         this.push('addText', this.makeMpDamageText(target));
  4391.     }
  4392. };

  4393. Window_BattleLog.prototype.displayTpDamage = function(target) {
  4394.     if (target.isAlive() && target.result().tpDamage !== 0) {
  4395.         if (target.result().tpDamage < 0) {
  4396.             this.push('performRecovery', target);
  4397.         }
  4398.         this.push('addText', this.makeTpDamageText(target));
  4399.     }
  4400. };

  4401. Window_BattleLog.prototype.displayAffectedStatus = function(target) {
  4402.     if (target.result().isStatusAffected()) {
  4403.         this.push('pushBaseLine');
  4404.         this.displayChangedStates(target);
  4405.         this.displayChangedBuffs(target);
  4406.         this.push('waitForNewLine');
  4407.         this.push('popBaseLine');
  4408.     }
  4409. };

  4410. Window_BattleLog.prototype.displayAutoAffectedStatus = function(target) {
  4411.     if (target.result().isStatusAffected()) {
  4412.         this.displayAffectedStatus(target, null);
  4413.         this.push('clear');
  4414.     }
  4415. };

  4416. Window_BattleLog.prototype.displayChangedStates = function(target) {
  4417.     this.displayAddedStates(target);
  4418.     this.displayRemovedStates(target);
  4419. };

  4420. Window_BattleLog.prototype.displayAddedStates = function(target) {
  4421.     target.result().addedStateObjects().forEach(function(state) {
  4422.         var stateMsg = target.isActor() ? state.message1 : state.message2;
  4423.         if (state.id === target.deathStateId()) {
  4424.             this.push('performCollapse', target);
  4425.         }
  4426.         if (stateMsg) {
  4427.             this.push('popBaseLine');
  4428.             this.push('pushBaseLine');
  4429.             this.push('addText', target.name() + stateMsg);
  4430.             this.push('waitForEffect');
  4431.         }
  4432.     }, this);
  4433. };

  4434. Window_BattleLog.prototype.displayRemovedStates = function(target) {
  4435.     target.result().removedStateObjects().forEach(function(state) {
  4436.         if (state.message4) {
  4437.             this.push('popBaseLine');
  4438.             this.push('pushBaseLine');
  4439.             this.push('addText', target.name() + state.message4);
  4440.         }
  4441.     }, this);
  4442. };

  4443. Window_BattleLog.prototype.displayChangedBuffs = function(target) {
  4444.     var result = target.result();
  4445.     this.displayBuffs(target, result.addedBuffs, TextManager.buffAdd);
  4446.     this.displayBuffs(target, result.addedDebuffs, TextManager.debuffAdd);
  4447.     this.displayBuffs(target, result.removedBuffs, TextManager.buffRemove);
  4448. };

  4449. Window_BattleLog.prototype.displayBuffs = function(target, buffs, fmt) {
  4450.     buffs.forEach(function(paramId) {
  4451.         this.push('popBaseLine');
  4452.         this.push('pushBaseLine');
  4453.         this.push('addText', fmt.format(target.name(), TextManager.param(paramId)));
  4454.     }, this);
  4455. };

  4456. Window_BattleLog.prototype.makeHpDamageText = function(target) {
  4457.     var result = target.result();
  4458.     var damage = result.hpDamage;
  4459.     var isActor = target.isActor();
  4460.     var fmt;
  4461.     if (damage > 0 && result.drain) {
  4462.         fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
  4463.         return fmt.format(target.name(), TextManager.hp, damage);
  4464.     } else if (damage > 0) {
  4465.         fmt = isActor ? TextManager.actorDamage : TextManager.enemyDamage;
  4466.         return fmt.format(target.name(), damage);
  4467.     } else if (damage < 0) {
  4468.         fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
  4469.         return fmt.format(target.name(), TextManager.hp, -damage);
  4470.     } else {
  4471.         fmt = isActor ? TextManager.actorNoDamage : TextManager.enemyNoDamage;
  4472.         return fmt.format(target.name());
  4473.     }
  4474. };

  4475. Window_BattleLog.prototype.makeMpDamageText = function(target) {
  4476.     var result = target.result();
  4477.     var damage = result.mpDamage;
  4478.     var isActor = target.isActor();
  4479.     var fmt;
  4480.     if (damage > 0 && result.drain) {
  4481.         fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
  4482.         return fmt.format(target.name(), TextManager.mp, damage);
  4483.     } else if (damage > 0) {
  4484.         fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
  4485.         return fmt.format(target.name(), TextManager.mp, damage);
  4486.     } else if (damage < 0) {
  4487.         fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
  4488.         return fmt.format(target.name(), TextManager.mp, -damage);
  4489.     } else {
  4490.         return '';
  4491.     }
  4492. };

  4493. Window_BattleLog.prototype.makeTpDamageText = function(target) {
  4494.     var result = target.result();
  4495.     var damage = result.tpDamage;
  4496.     var isActor = target.isActor();
  4497.     var fmt;
  4498.     if (damage > 0) {
  4499.         fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
  4500.         return fmt.format(target.name(), TextManager.tp, damage);
  4501.     } else if (damage < 0) {
  4502.         fmt = isActor ? TextManager.actorGain : TextManager.enemyGain;
  4503.         return fmt.format(target.name(), TextManager.tp, -damage);
  4504.     } else {
  4505.         return '';
  4506.     }
  4507. };

  4508. //-----------------------------------------------------------------------------
  4509. // Window_PartyCommand
  4510. //
  4511. // The window for selecting whether to fight or escape on the battle screen.

  4512. function Window_PartyCommand() {
  4513.     this.initialize.apply(this, arguments);
  4514. }

  4515. Window_PartyCommand.prototype = Object.create(Window_Command.prototype);
  4516. Window_PartyCommand.prototype.constructor = Window_PartyCommand;

  4517. Window_PartyCommand.prototype.initialize = function() {
  4518.     var y = Graphics.boxHeight - this.windowHeight();
  4519.     Window_Command.prototype.initialize.call(this, 0, y);
  4520.     this.openness = 0;
  4521.     this.deactivate();
  4522. };

  4523. Window_PartyCommand.prototype.windowWidth = function() {
  4524.     return 192;
  4525. };

  4526. Window_PartyCommand.prototype.numVisibleRows = function() {
  4527.     return 4;
  4528. };

  4529. Window_PartyCommand.prototype.makeCommandList = function() {
  4530.     this.addCommand(TextManager.fight,  'fight');
  4531.     this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  4532. };

  4533. Window_PartyCommand.prototype.setup = function() {
  4534.     this.clearCommandList();
  4535.     this.makeCommandList();
  4536.     this.refresh();
  4537.     this.select(0);
  4538.     this.activate();
  4539.     this.open();
  4540. };

  4541. //-----------------------------------------------------------------------------
  4542. // Window_ActorCommand
  4543. //
  4544. // The window for selecting an actor's action on the battle screen.

  4545. function Window_ActorCommand() {
  4546.     this.initialize.apply(this, arguments);
  4547. }

  4548. Window_ActorCommand.prototype = Object.create(Window_Command.prototype);
  4549. Window_ActorCommand.prototype.constructor = Window_ActorCommand;

  4550. Window_ActorCommand.prototype.initialize = function() {
  4551.     var y = Graphics.boxHeight - this.windowHeight();
  4552.     Window_Command.prototype.initialize.call(this, 0, y);
  4553.     this.openness = 0;
  4554.     this.deactivate();
  4555.     this._actor = null;
  4556. };

  4557. Window_ActorCommand.prototype.windowWidth = function() {
  4558.     return 192;
  4559. };

  4560. Window_ActorCommand.prototype.numVisibleRows = function() {
  4561.     return 4;
  4562. };

  4563. Window_ActorCommand.prototype.makeCommandList = function() {
  4564.     if (this._actor) {
  4565.         this.addAttackCommand();
  4566.         this.addSkillCommands();
  4567.         this.addGuardCommand();
  4568.         this.addItemCommand();
  4569.     }
  4570. };

  4571. Window_ActorCommand.prototype.addAttackCommand = function() {
  4572.     this.addCommand(TextManager.attack, 'attack', this._actor.canAttack());
  4573. };

  4574. Window_ActorCommand.prototype.addSkillCommands = function() {
  4575.     var skillTypes = this._actor.addedSkillTypes();
  4576.     skillTypes.sort(function(a, b) {
  4577.         return a - b;
  4578.     });
  4579.     skillTypes.forEach(function(stypeId) {
  4580.         var name = $dataSystem.skillTypes[stypeId];
  4581.         this.addCommand(name, 'skill', true, stypeId);
  4582.     }, this);
  4583. };

  4584. Window_ActorCommand.prototype.addGuardCommand = function() {
  4585.     this.addCommand(TextManager.guard, 'guard', this._actor.canGuard());
  4586. };

  4587. Window_ActorCommand.prototype.addItemCommand = function() {
  4588.     this.addCommand(TextManager.item, 'item');
  4589. };

  4590. Window_ActorCommand.prototype.setup = function(actor) {
  4591.     this._actor = actor;
  4592.     this.clearCommandList();
  4593.     this.makeCommandList();
  4594.     this.refresh();
  4595.     this.selectLast();
  4596.     this.activate();
  4597.     this.open();
  4598. };

  4599. Window_ActorCommand.prototype.processOk = function() {
  4600.     if (this._actor) {
  4601.         if (ConfigManager.commandRemember) {
  4602.             this._actor.setLastCommandSymbol(this.currentSymbol());
  4603.         } else {
  4604.             this._actor.setLastCommandSymbol('');
  4605.         }
  4606.     }
  4607.     Window_Command.prototype.processOk.call(this);
  4608. };

  4609. Window_ActorCommand.prototype.selectLast = function() {
  4610.     this.select(0);
  4611.     if (this._actor && ConfigManager.commandRemember) {
  4612.         var symbol = this._actor.lastCommandSymbol();
  4613.         this.selectSymbol(symbol);
  4614.         if (symbol === 'skill') {
  4615.             var skill = this._actor.lastBattleSkill();
  4616.             if (skill) {
  4617.                 this.selectExt(skill.stypeId);
  4618.             }
  4619.         }
  4620.     }
  4621. };

  4622. //-----------------------------------------------------------------------------
  4623. // Window_BattleStatus
  4624. //
  4625. // The window for displaying the status of party members on the battle screen.

  4626. function Window_BattleStatus() {
  4627.     this.initialize.apply(this, arguments);
  4628. }

  4629. Window_BattleStatus.prototype = Object.create(Window_Selectable.prototype);
  4630. Window_BattleStatus.prototype.constructor = Window_BattleStatus;

  4631. Window_BattleStatus.prototype.initialize = function() {
  4632.     var width = this.windowWidth();
  4633.     var height = this.windowHeight();
  4634.     var x = Graphics.boxWidth - width;
  4635.     var y = Graphics.boxHeight - height;
  4636.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  4637.     this.refresh();
  4638.     this.openness = 0;
  4639. };

  4640. Window_BattleStatus.prototype.windowWidth = function() {
  4641.     return Graphics.boxWidth - 192;
  4642. };

  4643. Window_BattleStatus.prototype.windowHeight = function() {
  4644.     return this.fittingHeight(this.numVisibleRows());
  4645. };

  4646. Window_BattleStatus.prototype.numVisibleRows = function() {
  4647.     return 4;
  4648. };

  4649. Window_BattleStatus.prototype.maxItems = function() {
  4650.     return $gameParty.battleMembers().length;
  4651. };

  4652. Window_BattleStatus.prototype.refresh = function() {
  4653.     this.contents.clear();
  4654.     this.drawAllItems();
  4655. };

  4656. Window_BattleStatus.prototype.drawItem = function(index) {
  4657.     var actor = $gameParty.battleMembers()[index];
  4658.     this.drawBasicArea(this.basicAreaRect(index), actor);
  4659.     this.drawGaugeArea(this.gaugeAreaRect(index), actor);
  4660. };

  4661. Window_BattleStatus.prototype.basicAreaRect = function(index) {
  4662.     var rect = this.itemRectForText(index);
  4663.     rect.width -= this.gaugeAreaWidth() + 15;
  4664.     return rect;
  4665. };

  4666. Window_BattleStatus.prototype.gaugeAreaRect = function(index) {
  4667.     var rect = this.itemRectForText(index);
  4668.     rect.x += rect.width - this.gaugeAreaWidth();
  4669.     rect.width = this.gaugeAreaWidth();
  4670.     return rect;
  4671. };

  4672. Window_BattleStatus.prototype.gaugeAreaWidth = function() {
  4673.     return 330;
  4674. };

  4675. Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
  4676.     this.drawActorName(actor, rect.x + 0, rect.y, 150);
  4677.     this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
  4678. };

  4679. Window_BattleStatus.prototype.drawGaugeArea = function(rect, actor) {
  4680.     if ($dataSystem.optDisplayTp) {
  4681.         this.drawGaugeAreaWithTp(rect, actor);
  4682.     } else {
  4683.         this.drawGaugeAreaWithoutTp(rect, actor);
  4684.     }
  4685. };

  4686. Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
  4687.     this.drawActorHp(actor, rect.x + 0, rect.y, 108);
  4688.     this.drawActorMp(actor, rect.x + 123, rect.y, 96);
  4689.     this.drawActorTp(actor, rect.x + 234, rect.y, 96);
  4690. };

  4691. Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
  4692.     this.drawActorHp(actor, rect.x + 0, rect.y, 201);
  4693.     this.drawActorMp(actor, rect.x + 216,  rect.y, 114);
  4694. };

  4695. //-----------------------------------------------------------------------------
  4696. // Window_BattleActor
  4697. //
  4698. // The window for selecting a target actor on the battle screen.

  4699. function Window_BattleActor() {
  4700.     this.initialize.apply(this, arguments);
  4701. }

  4702. Window_BattleActor.prototype = Object.create(Window_BattleStatus.prototype);
  4703. Window_BattleActor.prototype.constructor = Window_BattleActor;

  4704. Window_BattleActor.prototype.initialize = function(x, y) {
  4705.     Window_BattleStatus.prototype.initialize.call(this);
  4706.     this.x = x;
  4707.     this.y = y;
  4708.     this.openness = 255;
  4709.     this.hide();
  4710. };

  4711. Window_BattleActor.prototype.show = function() {
  4712.     this.select(0);
  4713.     Window_BattleStatus.prototype.show.call(this);
  4714. };

  4715. Window_BattleActor.prototype.hide = function() {
  4716.     Window_BattleStatus.prototype.hide.call(this);
  4717.     $gameParty.select(null);
  4718. };

  4719. Window_BattleActor.prototype.select = function(index) {
  4720.     Window_BattleStatus.prototype.select.call(this, index);
  4721.     $gameParty.select(this.actor());
  4722. };

  4723. Window_BattleActor.prototype.actor = function() {
  4724.     return $gameParty.members()[this.index()];
  4725. };

  4726. //-----------------------------------------------------------------------------
  4727. // Window_BattleEnemy
  4728. //
  4729. // The window for selecting a target enemy on the battle screen.

  4730. function Window_BattleEnemy() {
  4731.     this.initialize.apply(this, arguments);
  4732. }

  4733. Window_BattleEnemy.prototype = Object.create(Window_Selectable.prototype);
  4734. Window_BattleEnemy.prototype.constructor = Window_BattleEnemy;

  4735. Window_BattleEnemy.prototype.initialize = function(x, y) {
  4736.     this._enemies = [];
  4737.     var width = this.windowWidth();
  4738.     var height = this.windowHeight();
  4739.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  4740.     this.refresh();
  4741.     this.hide();
  4742. };

  4743. Window_BattleEnemy.prototype.windowWidth = function() {
  4744.     return Graphics.boxWidth - 192;
  4745. };

  4746. Window_BattleEnemy.prototype.windowHeight = function() {
  4747.     return this.fittingHeight(this.numVisibleRows());
  4748. };

  4749. Window_BattleEnemy.prototype.numVisibleRows = function() {
  4750.     return 4;
  4751. };

  4752. Window_BattleEnemy.prototype.maxCols = function() {
  4753.     return 2;
  4754. };

  4755. Window_BattleEnemy.prototype.maxItems = function() {
  4756.     return this._enemies.length;
  4757. };

  4758. Window_BattleEnemy.prototype.enemy = function() {
  4759.     return this._enemies[this.index()];
  4760. };

  4761. Window_BattleEnemy.prototype.enemyIndex = function() {
  4762.     var enemy = this.enemy();
  4763.     return enemy ? enemy.index() : -1;
  4764. };

  4765. Window_BattleEnemy.prototype.drawItem = function(index) {
  4766.     this.resetTextColor();
  4767.     var name = this._enemies[index].name();
  4768.     var rect = this.itemRectForText(index);
  4769.     this.drawText(name, rect.x, rect.y, rect.width);
  4770. };

  4771. Window_BattleEnemy.prototype.show = function() {
  4772.     this.refresh();
  4773.     this.select(0);
  4774.     Window_Selectable.prototype.show.call(this);
  4775. };

  4776. Window_BattleEnemy.prototype.hide = function() {
  4777.     Window_Selectable.prototype.hide.call(this);
  4778.     $gameTroop.select(null);
  4779. };

  4780. Window_BattleEnemy.prototype.refresh = function() {
  4781.     this._enemies = $gameTroop.aliveMembers();
  4782.     Window_Selectable.prototype.refresh.call(this);
  4783. };

  4784. Window_BattleEnemy.prototype.select = function(index) {
  4785.     Window_Selectable.prototype.select.call(this, index);
  4786.     $gameTroop.select(this.enemy());
  4787. };

  4788. //-----------------------------------------------------------------------------
  4789. // Window_BattleSkill
  4790. //
  4791. // The window for selecting a skill to use on the battle screen.

  4792. function Window_BattleSkill() {
  4793.     this.initialize.apply(this, arguments);
  4794. }

  4795. Window_BattleSkill.prototype = Object.create(Window_SkillList.prototype);
  4796. Window_BattleSkill.prototype.constructor = Window_BattleSkill;

  4797. Window_BattleSkill.prototype.initialize = function(x, y, width, height) {
  4798.     Window_SkillList.prototype.initialize.call(this, x, y, width, height);
  4799.     this.hide();
  4800. };

  4801. Window_BattleSkill.prototype.show = function() {
  4802.     this.selectLast();
  4803.     this.showHelpWindow();
  4804.     Window_SkillList.prototype.show.call(this);
  4805. };

  4806. Window_BattleSkill.prototype.hide = function() {
  4807.     this.hideHelpWindow();
  4808.     Window_SkillList.prototype.hide.call(this);
  4809. };

  4810. //-----------------------------------------------------------------------------
  4811. // Window_BattleItem
  4812. //
  4813. // The window for selecting an item to use on the battle screen.

  4814. function Window_BattleItem() {
  4815.     this.initialize.apply(this, arguments);
  4816. }

  4817. Window_BattleItem.prototype = Object.create(Window_ItemList.prototype);
  4818. Window_BattleItem.prototype.constructor = Window_BattleItem;

  4819. Window_BattleItem.prototype.initialize = function(x, y, width, height) {
  4820.     Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  4821.     this.hide();
  4822. };

  4823. Window_BattleItem.prototype.includes = function(item) {
  4824.     return $gameParty.canUse(item);
  4825. };

  4826. Window_BattleItem.prototype.show = function() {
  4827.     this.selectLast();
  4828.     this.showHelpWindow();
  4829.     Window_ItemList.prototype.show.call(this);
  4830. };

  4831. Window_BattleItem.prototype.hide = function() {
  4832.     this.hideHelpWindow();
  4833.     Window_ItemList.prototype.hide.call(this);
  4834. };

  4835. //-----------------------------------------------------------------------------
  4836. // Window_TitleCommand
  4837. //
  4838. // The window for selecting New Game/Continue on the title screen.

  4839. function Window_TitleCommand() {
  4840.     this.initialize.apply(this, arguments);
  4841. }

  4842. Window_TitleCommand.prototype = Object.create(Window_Command.prototype);
  4843. Window_TitleCommand.prototype.constructor = Window_TitleCommand;

  4844. Window_TitleCommand.prototype.initialize = function() {
  4845.     Window_Command.prototype.initialize.call(this, 0, 0);
  4846.     this.updatePlacement();
  4847.     this.openness = 0;
  4848.     this.selectLast();
  4849. };

  4850. Window_TitleCommand._lastCommandSymbol = null;

  4851. Window_TitleCommand.initCommandPosition = function() {
  4852.     this._lastCommandSymbol = null;
  4853. };

  4854. Window_TitleCommand.prototype.windowWidth = function() {
  4855.     return 240;
  4856. };

  4857. Window_TitleCommand.prototype.updatePlacement = function() {
  4858.     this.x = (Graphics.boxWidth - this.width) / 2;
  4859.     this.y = Graphics.boxHeight - this.height - 96;
  4860. };

  4861. Window_TitleCommand.prototype.makeCommandList = function() {
  4862.     this.addCommand(TextManager.newGame,   'newGame');
  4863.     this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
  4864.     this.addCommand(TextManager.options,   'options');
  4865. };

  4866. Window_TitleCommand.prototype.isContinueEnabled = function() {
  4867.     return DataManager.isAnySavefileExists();
  4868. };

  4869. Window_TitleCommand.prototype.processOk = function() {
  4870.     Window_TitleCommand._lastCommandSymbol = this.currentSymbol();
  4871.     Window_Command.prototype.processOk.call(this);
  4872. };

  4873. Window_TitleCommand.prototype.selectLast = function() {
  4874.     if (Window_TitleCommand._lastCommandSymbol) {
  4875.         this.selectSymbol(Window_TitleCommand._lastCommandSymbol);
  4876.     } else if (this.isContinueEnabled()) {
  4877.         this.selectSymbol('continue');
  4878.     }
  4879. };

  4880. //-----------------------------------------------------------------------------
  4881. // Window_GameEnd
  4882. //
  4883. // The window for selecting "Go to Title" on the game end screen.

  4884. function Window_GameEnd() {
  4885.     this.initialize.apply(this, arguments);
  4886. }

  4887. Window_GameEnd.prototype = Object.create(Window_Command.prototype);
  4888. Window_GameEnd.prototype.constructor = Window_GameEnd;

  4889. Window_GameEnd.prototype.initialize = function() {
  4890.     Window_Command.prototype.initialize.call(this, 0, 0);
  4891.     this.updatePlacement();
  4892.     this.openness = 0;
  4893.     this.open();
  4894. };

  4895. Window_GameEnd.prototype.windowWidth = function() {
  4896.     return 240;
  4897. };

  4898. Window_GameEnd.prototype.updatePlacement = function() {
  4899.     this.x = (Graphics.boxWidth - this.width) / 2;
  4900.     this.y = (Graphics.boxHeight - this.height) / 2;
  4901. };

  4902. Window_GameEnd.prototype.makeCommandList = function() {
  4903.     this.addCommand(TextManager.toTitle, 'toTitle');
  4904.     this.addCommand(TextManager.cancel,  'cancel');
  4905. };

  4906. //-----------------------------------------------------------------------------
  4907. // Window_DebugRange
  4908. //
  4909. // The window for selecting a block of switches/variables on the debug screen.

  4910. function Window_DebugRange() {
  4911.     this.initialize.apply(this, arguments);
  4912. }

  4913. Window_DebugRange.prototype = Object.create(Window_Selectable.prototype);
  4914. Window_DebugRange.prototype.constructor = Window_DebugRange;

  4915. Window_DebugRange.lastTopRow = 0;
  4916. Window_DebugRange.lastIndex  = 0;

  4917. Window_DebugRange.prototype.initialize = function(x, y) {
  4918.     this._maxSwitches = Math.ceil(($dataSystem.switches.length - 1) / 10);
  4919.     this._maxVariables = Math.ceil(($dataSystem.variables.length - 1) / 10);
  4920.     var width = this.windowWidth();
  4921.     var height = this.windowHeight();
  4922.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  4923.     this.refresh();
  4924.     this.setTopRow(Window_DebugRange.lastTopRow);
  4925.     this.select(Window_DebugRange.lastIndex);
  4926.     this.activate();
  4927. };

  4928. Window_DebugRange.prototype.windowWidth = function() {
  4929.     return 246;
  4930. };

  4931. Window_DebugRange.prototype.windowHeight = function() {
  4932.     return Graphics.boxHeight;
  4933. };

  4934. Window_DebugRange.prototype.maxItems = function() {
  4935.     return this._maxSwitches + this._maxVariables;
  4936. };

  4937. Window_DebugRange.prototype.update = function() {
  4938.     Window_Selectable.prototype.update.call(this);
  4939.     if (this._editWindow) {
  4940.         this._editWindow.setMode(this.mode());
  4941.         this._editWindow.setTopId(this.topId());
  4942.     }
  4943. };

  4944. Window_DebugRange.prototype.mode = function() {
  4945.     return this.index() < this._maxSwitches ? 'switch' : 'variable';
  4946. };

  4947. Window_DebugRange.prototype.topId = function() {
  4948.     var index = this.index();
  4949.     if (index < this._maxSwitches) {
  4950.         return index * 10 + 1;
  4951.     } else {
  4952.         return (index - this._maxSwitches) * 10 + 1;
  4953.     }
  4954. };

  4955. Window_DebugRange.prototype.refresh = function() {
  4956.     this.createContents();
  4957.     this.drawAllItems();
  4958. };

  4959. Window_DebugRange.prototype.drawItem = function(index) {
  4960.     var rect = this.itemRectForText(index);
  4961.     var start;
  4962.     var text;
  4963.     if (index < this._maxSwitches) {
  4964.         start = index * 10 + 1;
  4965.         text = 'S';
  4966.     } else {
  4967.         start = (index - this._maxSwitches) * 10 + 1;
  4968.         text = 'V';
  4969.     }
  4970.     var end = start + 9;
  4971.     text += ' [' + start.padZero(4) + '-' + end.padZero(4) + ']';
  4972.     this.drawText(text, rect.x, rect.y, rect.width);
  4973. };

  4974. Window_DebugRange.prototype.isCancelTriggered = function() {
  4975.     return (Window_Selectable.prototype.isCancelTriggered() ||
  4976.             Input.isTriggered('debug'));
  4977. };

  4978. Window_DebugRange.prototype.processCancel = function() {
  4979.     Window_Selectable.prototype.processCancel.call(this);
  4980.     Window_DebugRange.lastTopRow = this.topRow();
  4981.     Window_DebugRange.lastIndex = this.index();
  4982. };

  4983. Window_DebugRange.prototype.setEditWindow = function(editWindow) {
  4984.     this._editWindow = editWindow;
  4985. };

  4986. //-----------------------------------------------------------------------------
  4987. // Window_DebugEdit
  4988. //
  4989. // The window for displaying switches and variables on the debug screen.

  4990. function Window_DebugEdit() {
  4991.     this.initialize.apply(this, arguments);
  4992. }

  4993. Window_DebugEdit.prototype = Object.create(Window_Selectable.prototype);
  4994. Window_DebugEdit.prototype.constructor = Window_DebugEdit;

  4995. Window_DebugEdit.prototype.initialize = function(x, y, width) {
  4996.     var height = this.fittingHeight(10);
  4997.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  4998.     this._mode = 'switch';
  4999.     this._topId = 1;
  5000.     this.refresh();
  5001. };

  5002. Window_DebugEdit.prototype.maxItems = function() {
  5003.     return 10;
  5004. };

  5005. Window_DebugEdit.prototype.refresh = function() {
  5006.     this.contents.clear();
  5007.     this.drawAllItems();
  5008. };

  5009. Window_DebugEdit.prototype.drawItem = function(index) {
  5010.     var dataId = this._topId + index;
  5011.     var idText = dataId.padZero(4) + ':';
  5012.     var idWidth = this.textWidth(idText);
  5013.     var statusWidth = this.textWidth('-00000000');
  5014.     var name = this.itemName(dataId);
  5015.     var status = this.itemStatus(dataId);
  5016.     var rect = this.itemRectForText(index);
  5017.     this.resetTextColor();
  5018.     this.drawText(idText, rect.x, rect.y, rect.width);
  5019.     rect.x += idWidth;
  5020.     rect.width -= idWidth + statusWidth;
  5021.     this.drawText(name, rect.x, rect.y, rect.width);
  5022.     this.drawText(status, rect.x + rect.width, rect.y, statusWidth, 'right');
  5023. };

  5024. Window_DebugEdit.prototype.itemName = function(dataId) {
  5025.     if (this._mode === 'switch') {
  5026.         return $dataSystem.switches[dataId];
  5027.     } else {
  5028.         return $dataSystem.variables[dataId];
  5029.     }
  5030. };

  5031. Window_DebugEdit.prototype.itemStatus = function(dataId) {
  5032.     if (this._mode === 'switch') {
  5033.         return $gameSwitches.value(dataId) ? '[ON]' : '[OFF]';
  5034.     } else {
  5035.         return String($gameVariables.value(dataId));
  5036.     }
  5037. };

  5038. Window_DebugEdit.prototype.setMode = function(mode) {
  5039.     if (this._mode !== mode) {
  5040.         this._mode = mode;
  5041.         this.refresh();
  5042.     }
  5043. };

  5044. Window_DebugEdit.prototype.setTopId = function(id) {
  5045.     if (this._topId !== id) {
  5046.         this._topId = id;
  5047.         this.refresh();
  5048.     }
  5049. };

  5050. Window_DebugEdit.prototype.currentId = function() {
  5051.     return this._topId + this.index();
  5052. };

  5053. Window_DebugEdit.prototype.update = function() {
  5054.     Window_Selectable.prototype.update.call(this);
  5055.     if (this.active) {
  5056.         if (this._mode === 'switch') {
  5057.             this.updateSwitch();
  5058.         } else {
  5059.             this.updateVariable();
  5060.         }
  5061.     }
  5062. };

  5063. Window_DebugEdit.prototype.updateSwitch = function() {
  5064.     if (Input.isRepeated('ok')) {
  5065.         var switchId = this.currentId();
  5066.         SoundManager.playCursor();
  5067.         $gameSwitches.setValue(switchId, !$gameSwitches.value(switchId));
  5068.         this.redrawCurrentItem();
  5069.     }
  5070. };

  5071. Window_DebugEdit.prototype.updateVariable = function() {
  5072.     var variableId = this.currentId();
  5073.     var value = $gameVariables.value(variableId);
  5074.     if (typeof value === 'number') {
  5075.         if (Input.isRepeated('right')) {
  5076.             value++;
  5077.         }
  5078.         if (Input.isRepeated('left')) {
  5079.             value--;
  5080.         }
  5081.         if (Input.isRepeated('pagedown')) {
  5082.             value += 10;
  5083.         }
  5084.         if (Input.isRepeated('pageup')) {
  5085.             value -= 10;
  5086.         }
  5087.         if ($gameVariables.value(variableId) !== value) {
  5088.             $gameVariables.setValue(variableId, value);
  5089.             SoundManager.playCursor();
  5090.             this.redrawCurrentItem();
  5091.         }
  5092.     }
  5093. };
复制代码

作者: 雷影    时间: 2023-4-9 18:48
成功?失败?有点微妙!AI可以完整识别出是什么的代码!可要求改写以后,写出来的代码无效?也没报错,就是运行后没变化!
作者: 哇哇哇啊叭叭    时间: 2023-4-10 10:47
妈呀...眼瞎啦(捂眼A捂眼)(つ﹏⊂)~!!代码好~~~~~~~~~~~~~~~~~长

  这种需要“二分法”来排错呢。
  1. 把程序一分为2
  2. 分别测试1和2哪个有错
  3. 重复上述步骤








欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1