Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 178.10 KB | None | 0 0
  1. //=============================================================================
  2. // rpg_windows.js v1.4.0
  3. //=============================================================================
  4.  
  5. //-----------------------------------------------------------------------------
  6. // Window_Base
  7. //
  8. // The superclass of all windows within the game.
  9.  
  10. function Window_Base() {
  11. this.initialize.apply(this, arguments);
  12. }
  13.  
  14. Window_Base.prototype = Object.create(Window.prototype);
  15. Window_Base.prototype.constructor = Window_Base;
  16.  
  17. Window_Base.prototype.initialize = function(x, y, width, height) {
  18. Window.prototype.initialize.call(this);
  19. this.loadWindowskin();
  20. this.move(x, y, width, height);
  21. this.updatePadding();
  22. this.updateBackOpacity();
  23. this.updateTone();
  24. this.createContents();
  25. this._opening = false;
  26. this._closing = false;
  27. this._dimmerSprite = null;
  28. };
  29.  
  30. Window_Base._iconWidth = 32;
  31. Window_Base._iconHeight = 32;
  32. Window_Base._faceWidth = 144;
  33. Window_Base._faceHeight = 144;
  34.  
  35. Window_Base.prototype.lineHeight = function() {
  36. return 36;
  37. };
  38.  
  39. Window_Base.prototype.standardFontFace = function() {
  40. if ($gameSystem.isChinese()) {
  41. return 'SimHei, Heiti TC, sans-serif';
  42. } else if ($gameSystem.isKorean()) {
  43. return 'Dotum, AppleGothic, sans-serif';
  44. } else {
  45. return 'GameFont';
  46. }
  47. };
  48.  
  49. Window_Base.prototype.standardFontSize = function() {
  50. return 28;
  51. };
  52.  
  53. Window_Base.prototype.standardPadding = function() {
  54. return 18;
  55. };
  56.  
  57. Window_Base.prototype.textPadding = function() {
  58. return 6;
  59. };
  60.  
  61. Window_Base.prototype.standardBackOpacity = function() {
  62. return 192;
  63. };
  64.  
  65. Window_Base.prototype.loadWindowskin = function() {
  66. this.windowskin = ImageManager.loadSystem('Window');
  67. };
  68.  
  69. Window_Base.prototype.updatePadding = function() {
  70. this.padding = this.standardPadding();
  71. };
  72.  
  73. Window_Base.prototype.updateBackOpacity = function() {
  74. this.backOpacity = this.standardBackOpacity();
  75. };
  76.  
  77. Window_Base.prototype.contentsWidth = function() {
  78. return this.width - this.standardPadding() * 2;
  79. };
  80.  
  81. Window_Base.prototype.contentsHeight = function() {
  82. return this.height - this.standardPadding() * 2;
  83. };
  84.  
  85. Window_Base.prototype.fittingHeight = function(numLines) {
  86. return numLines * this.lineHeight() + this.standardPadding() * 2;
  87. };
  88.  
  89. Window_Base.prototype.updateTone = function() {
  90. var tone = $gameSystem.windowTone();
  91. this.setTone(tone[0], tone[1], tone[2]);
  92. };
  93.  
  94. Window_Base.prototype.createContents = function() {
  95. this.contents = new Bitmap(this.contentsWidth(), this.contentsHeight());
  96. this.resetFontSettings();
  97. };
  98.  
  99. Window_Base.prototype.resetFontSettings = function() {
  100. this.contents.fontFace = this.standardFontFace();
  101. this.contents.fontSize = this.standardFontSize();
  102. this.resetTextColor();
  103. };
  104.  
  105. Window_Base.prototype.resetTextColor = function() {
  106. this.changeTextColor(this.normalColor());
  107. };
  108.  
  109. Window_Base.prototype.update = function() {
  110. Window.prototype.update.call(this);
  111. this.updateTone();
  112. this.updateOpen();
  113. this.updateClose();
  114. this.updateBackgroundDimmer();
  115. };
  116.  
  117. Window_Base.prototype.updateOpen = function() {
  118. if (this._opening) {
  119. this.openness += 32;
  120. if (this.isOpen()) {
  121. this._opening = false;
  122. }
  123. }
  124. };
  125.  
  126. Window_Base.prototype.updateClose = function() {
  127. if (this._closing) {
  128. this.openness -= 32;
  129. if (this.isClosed()) {
  130. this._closing = false;
  131. }
  132. }
  133. };
  134.  
  135. Window_Base.prototype.open = function() {
  136. if (!this.isOpen()) {
  137. this._opening = true;
  138. }
  139. this._closing = false;
  140. };
  141.  
  142. Window_Base.prototype.close = function() {
  143. if (!this.isClosed()) {
  144. this._closing = true;
  145. }
  146. this._opening = false;
  147. };
  148.  
  149. Window_Base.prototype.isOpening = function() {
  150. return this._opening;
  151. };
  152.  
  153. Window_Base.prototype.isClosing = function() {
  154. return this._closing;
  155. };
  156.  
  157. Window_Base.prototype.show = function() {
  158. this.visible = true;
  159. };
  160.  
  161. Window_Base.prototype.hide = function() {
  162. this.visible = false;
  163. };
  164.  
  165. Window_Base.prototype.activate = function() {
  166. this.active = true;
  167. };
  168.  
  169. Window_Base.prototype.deactivate = function() {
  170. this.active = false;
  171. };
  172.  
  173. Window_Base.prototype.textColor = function(n) {
  174. var px = 96 + (n % 8) * 12 + 6;
  175. var py = 144 + Math.floor(n / 8) * 12 + 6;
  176. return this.windowskin.getPixel(px, py);
  177. };
  178.  
  179. Window_Base.prototype.normalColor = function() {
  180. return this.textColor(0);
  181. };
  182.  
  183. Window_Base.prototype.systemColor = function() {
  184. return this.textColor(16);
  185. };
  186.  
  187. Window_Base.prototype.crisisColor = function() {
  188. return this.textColor(17);
  189. };
  190.  
  191. Window_Base.prototype.deathColor = function() {
  192. return this.textColor(18);
  193. };
  194.  
  195. Window_Base.prototype.gaugeBackColor = function() {
  196. return this.textColor(19);
  197. };
  198.  
  199. Window_Base.prototype.hpGaugeColor1 = function() {
  200. return this.textColor(20);
  201. };
  202.  
  203. Window_Base.prototype.hpGaugeColor2 = function() {
  204. return this.textColor(21);
  205. };
  206.  
  207. Window_Base.prototype.mpGaugeColor1 = function() {
  208. return this.textColor(22);
  209. };
  210.  
  211. Window_Base.prototype.mpGaugeColor2 = function() {
  212. return this.textColor(23);
  213. };
  214.  
  215. Window_Base.prototype.mpCostColor = function() {
  216. return this.textColor(23);
  217. };
  218.  
  219. Window_Base.prototype.powerUpColor = function() {
  220. return this.textColor(24);
  221. };
  222.  
  223. Window_Base.prototype.powerDownColor = function() {
  224. return this.textColor(25);
  225. };
  226.  
  227. Window_Base.prototype.tpGaugeColor1 = function() {
  228. return this.textColor(28);
  229. };
  230.  
  231. Window_Base.prototype.tpGaugeColor2 = function() {
  232. return this.textColor(29);
  233. };
  234.  
  235. Window_Base.prototype.tpCostColor = function() {
  236. return this.textColor(29);
  237. };
  238.  
  239. Window_Base.prototype.pendingColor = function() {
  240. return this.windowskin.getPixel(120, 120);
  241. };
  242.  
  243. Window_Base.prototype.translucentOpacity = function() {
  244. return 160;
  245. };
  246.  
  247. Window_Base.prototype.changeTextColor = function(color) {
  248. this.contents.textColor = color;
  249. };
  250.  
  251. Window_Base.prototype.changePaintOpacity = function(enabled) {
  252. this.contents.paintOpacity = enabled ? 255 : this.translucentOpacity();
  253. };
  254.  
  255. Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
  256. this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
  257. };
  258.  
  259. Window_Base.prototype.textWidth = function(text) {
  260. return this.contents.measureTextWidth(text);
  261. };
  262.  
  263. Window_Base.prototype.drawTextEx = function(text, x, y) {
  264. if (text) {
  265. var textState = { index: 0, x: x, y: y, left: x };
  266. textState.text = this.convertEscapeCharacters(text);
  267. textState.height = this.calcTextHeight(textState, false);
  268. this.resetFontSettings();
  269. while (textState.index < textState.text.length) {
  270. this.processCharacter(textState);
  271. }
  272. return textState.x - x;
  273. } else {
  274. return 0;
  275. }
  276. };
  277.  
  278. Window_Base.prototype.convertEscapeCharacters = function(text) {
  279. text = text.replace(/\\/g, '\x1b');
  280. text = text.replace(/\x1b\x1b/g, '\\');
  281. text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  282. return $gameVariables.value(parseInt(arguments[1]));
  283. }.bind(this));
  284. text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  285. return $gameVariables.value(parseInt(arguments[1]));
  286. }.bind(this));
  287. text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
  288. return this.actorName(parseInt(arguments[1]));
  289. }.bind(this));
  290. text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
  291. return this.partyMemberName(parseInt(arguments[1]));
  292. }.bind(this));
  293. text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
  294. return text;
  295. };
  296.  
  297. Window_Base.prototype.actorName = function(n) {
  298. var actor = n >= 1 ? $gameActors.actor(n) : null;
  299. return actor ? actor.name() : '';
  300. };
  301.  
  302. Window_Base.prototype.partyMemberName = function(n) {
  303. var actor = n >= 1 ? $gameParty.members()[n - 1] : null;
  304. return actor ? actor.name() : '';
  305. };
  306.  
  307. Window_Base.prototype.processCharacter = function(textState) {
  308. switch (textState.text[textState.index]) {
  309. case '\n':
  310. this.processNewLine(textState);
  311. break;
  312. case '\f':
  313. this.processNewPage(textState);
  314. break;
  315. case '\x1b':
  316. this.processEscapeCharacter(this.obtainEscapeCode(textState), textState);
  317. break;
  318. default:
  319. this.processNormalCharacter(textState);
  320. break;
  321. }
  322. };
  323.  
  324. Window_Base.prototype.processNormalCharacter = function(textState) {
  325. var c = textState.text[textState.index++];
  326. var w = this.textWidth(c);
  327. this.contents.drawText(c, textState.x, textState.y, w * 2, textState.height);
  328. textState.x += w;
  329. };
  330.  
  331. Window_Base.prototype.processNewLine = function(textState) {
  332. textState.x = textState.left;
  333. textState.y += textState.height;
  334. textState.height = this.calcTextHeight(textState, false);
  335. textState.index++;
  336. };
  337.  
  338. Window_Base.prototype.processNewPage = function(textState) {
  339. textState.index++;
  340. };
  341.  
  342. Window_Base.prototype.obtainEscapeCode = function(textState) {
  343. textState.index++;
  344. var regExp = /^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i;
  345. var arr = regExp.exec(textState.text.slice(textState.index));
  346. if (arr) {
  347. textState.index += arr[0].length;
  348. return arr[0].toUpperCase();
  349. } else {
  350. return '';
  351. }
  352. };
  353.  
  354. Window_Base.prototype.obtainEscapeParam = function(textState) {
  355. var arr = /^\[\d+\]/.exec(textState.text.slice(textState.index));
  356. if (arr) {
  357. textState.index += arr[0].length;
  358. return parseInt(arr[0].slice(1));
  359. } else {
  360. return '';
  361. }
  362. };
  363.  
  364. Window_Base.prototype.processEscapeCharacter = function(code, textState) {
  365. switch (code) {
  366. case 'C':
  367. this.changeTextColor(this.textColor(this.obtainEscapeParam(textState)));
  368. break;
  369. case 'I':
  370. this.processDrawIcon(this.obtainEscapeParam(textState), textState);
  371. break;
  372. case '{':
  373. this.makeFontBigger();
  374. break;
  375. case '}':
  376. this.makeFontSmaller();
  377. break;
  378. }
  379. };
  380.  
  381. Window_Base.prototype.processDrawIcon = function(iconIndex, textState) {
  382. this.drawIcon(iconIndex, textState.x + 2, textState.y + 2);
  383. textState.x += Window_Base._iconWidth + 4;
  384. };
  385.  
  386. Window_Base.prototype.makeFontBigger = function() {
  387. if (this.contents.fontSize <= 96) {
  388. this.contents.fontSize += 12;
  389. }
  390. };
  391.  
  392. Window_Base.prototype.makeFontSmaller = function() {
  393. if (this.contents.fontSize >= 24) {
  394. this.contents.fontSize -= 12;
  395. }
  396. };
  397.  
  398. Window_Base.prototype.calcTextHeight = function(textState, all) {
  399. var lastFontSize = this.contents.fontSize;
  400. var textHeight = 0;
  401. var lines = textState.text.slice(textState.index).split('\n');
  402. var maxLines = all ? lines.length : 1;
  403.  
  404. for (var i = 0; i < maxLines; i++) {
  405. var maxFontSize = this.contents.fontSize;
  406. var regExp = /\x1b[\{\}]/g;
  407. for (;;) {
  408. var array = regExp.exec(lines[i]);
  409. if (array) {
  410. if (array[0] === '\x1b{') {
  411. this.makeFontBigger();
  412. }
  413. if (array[0] === '\x1b}') {
  414. this.makeFontSmaller();
  415. }
  416. if (maxFontSize < this.contents.fontSize) {
  417. maxFontSize = this.contents.fontSize;
  418. }
  419. } else {
  420. break;
  421. }
  422. }
  423. textHeight += maxFontSize + 8;
  424. }
  425.  
  426. this.contents.fontSize = lastFontSize;
  427. return textHeight;
  428. };
  429.  
  430. Window_Base.prototype.drawIcon = function(iconIndex, x, y) {
  431. var bitmap = ImageManager.loadSystem('IconSet');
  432. var pw = Window_Base._iconWidth;
  433. var ph = Window_Base._iconHeight;
  434. var sx = iconIndex % 16 * pw;
  435. var sy = Math.floor(iconIndex / 16) * ph;
  436. this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
  437. };
  438.  
  439. Window_Base.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
  440. width = width || Window_Base._faceWidth;
  441. height = height || Window_Base._faceHeight;
  442. var bitmap = ImageManager.loadFace(faceName);
  443. var pw = Window_Base._faceWidth;
  444. var ph = Window_Base._faceHeight;
  445. var sw = Math.min(width, pw);
  446. var sh = Math.min(height, ph);
  447. var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
  448. var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
  449. var sx = faceIndex % 4 * pw + (pw - sw) / 2;
  450. var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
  451. this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy);
  452. };
  453.  
  454. Window_Base.prototype.drawCharacter = function(characterName, characterIndex, x, y) {
  455. var bitmap = ImageManager.loadCharacter(characterName);
  456. var big = ImageManager.isBigCharacter(characterName);
  457. var pw = bitmap.width / (big ? 3 : 12);
  458. var ph = bitmap.height / (big ? 4 : 8);
  459. var n = characterIndex;
  460. var sx = (n % 4 * 3 + 1) * pw;
  461. var sy = (Math.floor(n / 4) * 4) * ph;
  462. this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
  463. };
  464.  
  465. Window_Base.prototype.drawGauge = function(x, y, width, rate, color1, color2) {
  466. var fillW = Math.floor(width * rate);
  467. var gaugeY = y + this.lineHeight() - 8;
  468. this.contents.fillRect(x, gaugeY, width, 6, this.gaugeBackColor());
  469. this.contents.gradientFillRect(x, gaugeY, fillW, 6, color1, color2);
  470. };
  471.  
  472. Window_Base.prototype.hpColor = function(actor) {
  473. if (actor.isDead()) {
  474. return this.deathColor();
  475. } else if (actor.isDying()) {
  476. return this.crisisColor();
  477. } else {
  478. return this.normalColor();
  479. }
  480. };
  481.  
  482. Window_Base.prototype.mpColor = function(actor) {
  483. return this.normalColor();
  484. };
  485.  
  486. Window_Base.prototype.tpColor = function(actor) {
  487. return this.normalColor();
  488. };
  489.  
  490. Window_Base.prototype.drawActorCharacter = function(actor, x, y) {
  491. this.drawCharacter(actor.characterName(), actor.characterIndex(), x, y);
  492. };
  493.  
  494. Window_Base.prototype.drawActorFace = function(actor, x, y, width, height) {
  495. this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height);
  496. };
  497.  
  498. Window_Base.prototype.drawActorName = function(actor, x, y, width) {
  499. width = width || 168;
  500. this.changeTextColor(this.hpColor(actor));
  501. this.drawText(actor.name(), x, y, width);
  502. };
  503.  
  504. Window_Base.prototype.drawActorClass = function(actor, x, y, width) {
  505. width = width || 168;
  506. this.resetTextColor();
  507. this.drawText(actor.currentClass().name, x, y, width);
  508. };
  509.  
  510. Window_Base.prototype.drawActorNickname = function(actor, x, y, width) {
  511. width = width || 270;
  512. this.resetTextColor();
  513. this.drawText(actor.nickname(), x, y, width);
  514. };
  515.  
  516. Window_Base.prototype.drawActorLevel = function(actor, x, y) {
  517. this.changeTextColor(this.systemColor());
  518. this.drawText(TextManager.levelA, x, y, 48);
  519. this.resetTextColor();
  520. this.drawText(actor.level, x + 84, y, 36, 'right');
  521. };
  522.  
  523. Window_Base.prototype.drawActorIcons = function(actor, x, y, width) {
  524. width = width || 144;
  525. var icons = actor.allIcons().slice(0, Math.floor(width / Window_Base._iconWidth));
  526. for (var i = 0; i < icons.length; i++) {
  527. this.drawIcon(icons[i], x + Window_Base._iconWidth * i, y + 2);
  528. }
  529. };
  530.  
  531. Window_Base.prototype.drawCurrentAndMax = function(current, max, x, y,
  532. width, color1, color2) {
  533. var labelWidth = this.textWidth('HP');
  534. var valueWidth = this.textWidth('0000');
  535. var slashWidth = this.textWidth('/');
  536. var x1 = x + width - valueWidth;
  537. var x2 = x1 - slashWidth;
  538. var x3 = x2 - valueWidth;
  539. if (x3 >= x + labelWidth) {
  540. this.changeTextColor(color1);
  541. this.drawText(current, x3, y, valueWidth, 'right');
  542. this.changeTextColor(color2);
  543. this.drawText('/', x2, y, slashWidth, 'right');
  544. this.drawText(max, x1, y, valueWidth, 'right');
  545. } else {
  546. this.changeTextColor(color1);
  547. this.drawText(current, x1, y, valueWidth, 'right');
  548. }
  549. };
  550.  
  551. Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
  552. width = width || 186;
  553. var color1 = this.hpGaugeColor1();
  554. var color2 = this.hpGaugeColor2();
  555. this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
  556. this.changeTextColor(this.systemColor());
  557. this.drawText(TextManager.hpA, x, y, 44);
  558. this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
  559. this.hpColor(actor), this.normalColor());
  560. };
  561.  
  562. Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
  563. width = width || 186;
  564. var color1 = this.mpGaugeColor1();
  565. var color2 = this.mpGaugeColor2();
  566. this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
  567. this.changeTextColor(this.systemColor());
  568. this.drawText(TextManager.mpA, x, y, 44);
  569. this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
  570. this.mpColor(actor), this.normalColor());
  571. };
  572.  
  573. Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  574. width = width || 96;
  575. var color1 = this.tpGaugeColor1();
  576. var color2 = this.tpGaugeColor2();
  577. this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
  578. this.changeTextColor(this.systemColor());
  579. this.drawText(TextManager.tpA, x, y, 44);
  580. this.changeTextColor(this.tpColor(actor));
  581. this.drawText(actor.tp, x + width - 64, y, 64, 'right');
  582. };
  583.  
  584. Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
  585. var lineHeight = this.lineHeight();
  586. var x2 = x + 180;
  587. var width2 = Math.min(200, width - 180 - this.textPadding());
  588. this.drawActorName(actor, x, y);
  589. this.drawActorLevel(actor, x, y + lineHeight * 1);
  590. this.drawActorIcons(actor, x, y + lineHeight * 2);
  591. this.drawActorClass(actor, x2, y);
  592. this.drawActorHp(actor, x2, y + lineHeight * 1, width2);
  593. this.drawActorMp(actor, x2, y + lineHeight * 2, width2);
  594. };
  595.  
  596. Window_Base.prototype.drawItemName = function(item, x, y, width) {
  597. width = width || 312;
  598. if (item) {
  599. var iconBoxWidth = Window_Base._iconWidth + 4;
  600. this.resetTextColor();
  601. this.drawIcon(item.iconIndex, x + 2, y + 2);
  602. this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  603. }
  604. };
  605.  
  606. Window_Base.prototype.drawCurrencyValue = function(value, unit, x, y, width) {
  607. var unitWidth = Math.min(80, this.textWidth(unit));
  608. this.resetTextColor();
  609. this.drawText(value, x, y, width - unitWidth - 6, 'right');
  610. this.changeTextColor(this.systemColor());
  611. this.drawText(unit, x + width - unitWidth, y, unitWidth, 'right');
  612. };
  613.  
  614. Window_Base.prototype.paramchangeTextColor = function(change) {
  615. if (change > 0) {
  616. return this.powerUpColor();
  617. } else if (change < 0) {
  618. return this.powerDownColor();
  619. } else {
  620. return this.normalColor();
  621. }
  622. };
  623.  
  624. Window_Base.prototype.setBackgroundType = function(type) {
  625. if (type === 0) {
  626. this.opacity = 255;
  627. } else {
  628. this.opacity = 0;
  629. }
  630. if (type === 1) {
  631. this.showBackgroundDimmer();
  632. } else {
  633. this.hideBackgroundDimmer();
  634. }
  635. };
  636.  
  637. Window_Base.prototype.showBackgroundDimmer = function() {
  638. if (!this._dimmerSprite) {
  639. this._dimmerSprite = new Sprite();
  640. this._dimmerSprite.bitmap = new Bitmap(0, 0);
  641. this.addChildToBack(this._dimmerSprite);
  642. }
  643. var bitmap = this._dimmerSprite.bitmap;
  644. if (bitmap.width !== this.width || bitmap.height !== this.height) {
  645. this.refreshDimmerBitmap();
  646. }
  647. this._dimmerSprite.visible = true;
  648. this.updateBackgroundDimmer();
  649. };
  650.  
  651. Window_Base.prototype.hideBackgroundDimmer = function() {
  652. if (this._dimmerSprite) {
  653. this._dimmerSprite.visible = false;
  654. }
  655. };
  656.  
  657. Window_Base.prototype.updateBackgroundDimmer = function() {
  658. if (this._dimmerSprite) {
  659. this._dimmerSprite.opacity = this.openness;
  660. }
  661. };
  662.  
  663. Window_Base.prototype.refreshDimmerBitmap = function() {
  664. if (this._dimmerSprite) {
  665. var bitmap = this._dimmerSprite.bitmap;
  666. var w = this.width;
  667. var h = this.height;
  668. var m = this.padding;
  669. var c1 = this.dimColor1();
  670. var c2 = this.dimColor2();
  671. bitmap.resize(w, h);
  672. bitmap.gradientFillRect(0, 0, w, m, c2, c1, true);
  673. bitmap.fillRect(0, m, w, h - m * 2, c1);
  674. bitmap.gradientFillRect(0, h - m, w, m, c1, c2, true);
  675. this._dimmerSprite.setFrame(0, 0, w, h);
  676. }
  677. };
  678.  
  679. Window_Base.prototype.dimColor1 = function() {
  680. return 'rgba(0, 0, 0, 0.6)';
  681. };
  682.  
  683. Window_Base.prototype.dimColor2 = function() {
  684. return 'rgba(0, 0, 0, 0)';
  685. };
  686.  
  687. Window_Base.prototype.canvasToLocalX = function(x) {
  688. var node = this;
  689. while (node) {
  690. x -= node.x;
  691. node = node.parent;
  692. }
  693. return x;
  694. };
  695.  
  696. Window_Base.prototype.canvasToLocalY = function(y) {
  697. var node = this;
  698. while (node) {
  699. y -= node.y;
  700. node = node.parent;
  701. }
  702. return y;
  703. };
  704.  
  705. //-----------------------------------------------------------------------------
  706. // Window_Selectable
  707. //
  708. // The window class with cursor movement and scroll functions.
  709.  
  710. function Window_Selectable() {
  711. this.initialize.apply(this, arguments);
  712. }
  713.  
  714. Window_Selectable.prototype = Object.create(Window_Base.prototype);
  715. Window_Selectable.prototype.constructor = Window_Selectable;
  716.  
  717. Window_Selectable.prototype.initialize = function(x, y, width, height) {
  718. Window_Base.prototype.initialize.call(this, x, y, width, height);
  719. this._index = -1;
  720. this._cursorFixed = false;
  721. this._cursorAll = false;
  722. this._stayCount = 0;
  723. this._helpWindow = null;
  724. this._handlers = {};
  725. this._touching = false;
  726. this._scrollX = 0;
  727. this._scrollY = 0;
  728. this.deactivate();
  729. };
  730.  
  731. Window_Selectable.prototype.index = function() {
  732. return this._index;
  733. };
  734.  
  735. Window_Selectable.prototype.cursorFixed = function() {
  736. return this._cursorFixed;
  737. };
  738.  
  739. Window_Selectable.prototype.setCursorFixed = function(cursorFixed) {
  740. this._cursorFixed = cursorFixed;
  741. };
  742.  
  743. Window_Selectable.prototype.cursorAll = function() {
  744. return this._cursorAll;
  745. };
  746.  
  747. Window_Selectable.prototype.setCursorAll = function(cursorAll) {
  748. this._cursorAll = cursorAll;
  749. };
  750.  
  751. Window_Selectable.prototype.maxCols = function() {
  752. return 1;
  753. };
  754.  
  755. Window_Selectable.prototype.maxItems = function() {
  756. return 0;
  757. };
  758.  
  759. Window_Selectable.prototype.spacing = function() {
  760. return 12;
  761. };
  762.  
  763. Window_Selectable.prototype.itemWidth = function() {
  764. return Math.floor((this.width - this.padding * 2 +
  765. this.spacing()) / this.maxCols() - this.spacing());
  766. };
  767.  
  768. Window_Selectable.prototype.itemHeight = function() {
  769. return this.lineHeight();
  770. };
  771.  
  772. Window_Selectable.prototype.maxRows = function() {
  773. return Math.max(Math.ceil(this.maxItems() / this.maxCols()), 1);
  774. };
  775.  
  776. Window_Selectable.prototype.activate = function() {
  777. Window_Base.prototype.activate.call(this);
  778. this.reselect();
  779. };
  780.  
  781. Window_Selectable.prototype.deactivate = function() {
  782. Window_Base.prototype.deactivate.call(this);
  783. this.reselect();
  784. };
  785.  
  786. Window_Selectable.prototype.select = function(index) {
  787. this._index = index;
  788. this._stayCount = 0;
  789. this.ensureCursorVisible();
  790. this.updateCursor();
  791. this.callUpdateHelp();
  792. };
  793.  
  794. Window_Selectable.prototype.deselect = function() {
  795. this.select(-1);
  796. };
  797.  
  798. Window_Selectable.prototype.reselect = function() {
  799. this.select(this._index);
  800. };
  801.  
  802. Window_Selectable.prototype.row = function() {
  803. return Math.floor(this.index() / this.maxCols());
  804. };
  805.  
  806. Window_Selectable.prototype.topRow = function() {
  807. return Math.floor(this._scrollY / this.itemHeight());
  808. };
  809.  
  810. Window_Selectable.prototype.maxTopRow = function() {
  811. return Math.max(0, this.maxRows() - this.maxPageRows());
  812. };
  813.  
  814. Window_Selectable.prototype.setTopRow = function(row) {
  815. var scrollY = row.clamp(0, this.maxTopRow()) * this.itemHeight();
  816. if (this._scrollY !== scrollY) {
  817. this._scrollY = scrollY;
  818. this.refresh();
  819. this.updateCursor();
  820. }
  821. };
  822.  
  823. Window_Selectable.prototype.resetScroll = function() {
  824. this.setTopRow(0);
  825. };
  826.  
  827. Window_Selectable.prototype.maxPageRows = function() {
  828. var pageHeight = this.height - this.padding * 2;
  829. return Math.floor(pageHeight / this.itemHeight());
  830. };
  831.  
  832. Window_Selectable.prototype.maxPageItems = function() {
  833. return this.maxPageRows() * this.maxCols();
  834. };
  835.  
  836. Window_Selectable.prototype.isHorizontal = function() {
  837. return this.maxPageRows() === 1;
  838. };
  839.  
  840. Window_Selectable.prototype.bottomRow = function() {
  841. return Math.max(0, this.topRow() + this.maxPageRows() - 1);
  842. };
  843.  
  844. Window_Selectable.prototype.setBottomRow = function(row) {
  845. this.setTopRow(row - (this.maxPageRows() - 1));
  846. };
  847.  
  848. Window_Selectable.prototype.topIndex = function() {
  849. return this.topRow() * this.maxCols();
  850. };
  851.  
  852. Window_Selectable.prototype.itemRect = function(index) {
  853. var rect = new Rectangle();
  854. var maxCols = this.maxCols();
  855. rect.width = this.itemWidth();
  856. rect.height = this.itemHeight();
  857. rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
  858. rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY;
  859. return rect;
  860. };
  861.  
  862. Window_Selectable.prototype.itemRectForText = function(index) {
  863. var rect = this.itemRect(index);
  864. rect.x += this.textPadding();
  865. rect.width -= this.textPadding() * 2;
  866. return rect;
  867. };
  868.  
  869. Window_Selectable.prototype.setHelpWindow = function(helpWindow) {
  870. this._helpWindow = helpWindow;
  871. this.callUpdateHelp();
  872. };
  873.  
  874. Window_Selectable.prototype.showHelpWindow = function() {
  875. if (this._helpWindow) {
  876. this._helpWindow.show();
  877. }
  878. };
  879.  
  880. Window_Selectable.prototype.hideHelpWindow = function() {
  881. if (this._helpWindow) {
  882. this._helpWindow.hide();
  883. }
  884. };
  885.  
  886. Window_Selectable.prototype.setHandler = function(symbol, method) {
  887. this._handlers[symbol] = method;
  888. };
  889.  
  890. Window_Selectable.prototype.isHandled = function(symbol) {
  891. return !!this._handlers[symbol];
  892. };
  893.  
  894. Window_Selectable.prototype.callHandler = function(symbol) {
  895. if (this.isHandled(symbol)) {
  896. this._handlers[symbol]();
  897. }
  898. };
  899.  
  900. Window_Selectable.prototype.isOpenAndActive = function() {
  901. return this.isOpen() && this.active;
  902. };
  903.  
  904. Window_Selectable.prototype.isCursorMovable = function() {
  905. return (this.isOpenAndActive() && !this._cursorFixed &&
  906. !this._cursorAll && this.maxItems() > 0);
  907. };
  908.  
  909. Window_Selectable.prototype.cursorDown = function(wrap) {
  910. var index = this.index();
  911. var maxItems = this.maxItems();
  912. var maxCols = this.maxCols();
  913. if (index < maxItems - maxCols || (wrap && maxCols === 1)) {
  914. this.select((index + maxCols) % maxItems);
  915. }
  916. };
  917.  
  918. Window_Selectable.prototype.cursorUp = function(wrap) {
  919. var index = this.index();
  920. var maxItems = this.maxItems();
  921. var maxCols = this.maxCols();
  922. if (index >= maxCols || (wrap && maxCols === 1)) {
  923. this.select((index - maxCols + maxItems) % maxItems);
  924. }
  925. };
  926.  
  927. Window_Selectable.prototype.cursorRight = function(wrap) {
  928. var index = this.index();
  929. var maxItems = this.maxItems();
  930. var maxCols = this.maxCols();
  931. if (maxCols >= 2 && (index < maxItems - 1 || (wrap && this.isHorizontal()))) {
  932. this.select((index + 1) % maxItems);
  933. }
  934. };
  935.  
  936. Window_Selectable.prototype.cursorLeft = function(wrap) {
  937. var index = this.index();
  938. var maxItems = this.maxItems();
  939. var maxCols = this.maxCols();
  940. if (maxCols >= 2 && (index > 0 || (wrap && this.isHorizontal()))) {
  941. this.select((index - 1 + maxItems) % maxItems);
  942. }
  943. };
  944.  
  945. Window_Selectable.prototype.cursorPagedown = function() {
  946. var index = this.index();
  947. var maxItems = this.maxItems();
  948. if (this.topRow() + this.maxPageRows() < this.maxRows()) {
  949. this.setTopRow(this.topRow() + this.maxPageRows());
  950. this.select(Math.min(index + this.maxPageItems(), maxItems - 1));
  951. }
  952. };
  953.  
  954. Window_Selectable.prototype.cursorPageup = function() {
  955. var index = this.index();
  956. if (this.topRow() > 0) {
  957. this.setTopRow(this.topRow() - this.maxPageRows());
  958. this.select(Math.max(index - this.maxPageItems(), 0));
  959. }
  960. };
  961.  
  962. Window_Selectable.prototype.scrollDown = function() {
  963. if (this.topRow() + 1 < this.maxRows()) {
  964. this.setTopRow(this.topRow() + 1);
  965. }
  966. };
  967.  
  968. Window_Selectable.prototype.scrollUp = function() {
  969. if (this.topRow() > 0) {
  970. this.setTopRow(this.topRow() - 1);
  971. }
  972. };
  973.  
  974. Window_Selectable.prototype.update = function() {
  975. Window_Base.prototype.update.call(this);
  976. this.updateArrows();
  977. this.processCursorMove();
  978. this.processHandling();
  979. this.processWheel();
  980. this.processTouch();
  981. this._stayCount++;
  982. };
  983.  
  984. Window_Selectable.prototype.updateArrows = function() {
  985. var topRow = this.topRow();
  986. var maxTopRow = this.maxTopRow();
  987. this.downArrowVisible = maxTopRow > 0 && topRow < maxTopRow;
  988. this.upArrowVisible = topRow > 0;
  989. };
  990.  
  991. Window_Selectable.prototype.processCursorMove = function() {
  992. if (this.isCursorMovable()) {
  993. var lastIndex = this.index();
  994. if (Input.isRepeated('down')) {
  995. this.cursorDown(Input.isTriggered('down'));
  996. }
  997. if (Input.isRepeated('up')) {
  998. this.cursorUp(Input.isTriggered('up'));
  999. }
  1000. if (Input.isRepeated('right')) {
  1001. this.cursorRight(Input.isTriggered('right'));
  1002. }
  1003. if (Input.isRepeated('left')) {
  1004. this.cursorLeft(Input.isTriggered('left'));
  1005. }
  1006. if (!this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
  1007. this.cursorPagedown();
  1008. }
  1009. if (!this.isHandled('pageup') && Input.isTriggered('pageup')) {
  1010. this.cursorPageup();
  1011. }
  1012. if (this.index() !== lastIndex) {
  1013. SoundManager.playCursor();
  1014. }
  1015. }
  1016. };
  1017.  
  1018. Window_Selectable.prototype.processHandling = function() {
  1019. if (this.isOpenAndActive()) {
  1020. if (this.isOkEnabled() && this.isOkTriggered()) {
  1021. this.processOk();
  1022. } else if (this.isCancelEnabled() && this.isCancelTriggered()) {
  1023. this.processCancel();
  1024. } else if (this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
  1025. this.processPagedown();
  1026. } else if (this.isHandled('pageup') && Input.isTriggered('pageup')) {
  1027. this.processPageup();
  1028. }
  1029. }
  1030. };
  1031.  
  1032. Window_Selectable.prototype.processWheel = function() {
  1033. if (this.isOpenAndActive()) {
  1034. var threshold = 20;
  1035. if (TouchInput.wheelY >= threshold) {
  1036. this.scrollDown();
  1037. }
  1038. if (TouchInput.wheelY <= -threshold) {
  1039. this.scrollUp();
  1040. }
  1041. }
  1042. };
  1043.  
  1044. Window_Selectable.prototype.processTouch = function() {
  1045. if (this.isOpenAndActive()) {
  1046. if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  1047. this._touching = true;
  1048. this.onTouch(true);
  1049. } else if (TouchInput.isCancelled()) {
  1050. if (this.isCancelEnabled()) {
  1051. this.processCancel();
  1052. }
  1053. }
  1054. if (this._touching) {
  1055. if (TouchInput.isPressed()) {
  1056. this.onTouch(false);
  1057. } else {
  1058. this._touching = false;
  1059. }
  1060. }
  1061. } else {
  1062. this._touching = false;
  1063. }
  1064. };
  1065.  
  1066. Window_Selectable.prototype.isTouchedInsideFrame = function() {
  1067. var x = this.canvasToLocalX(TouchInput.x);
  1068. var y = this.canvasToLocalY(TouchInput.y);
  1069. return x >= 0 && y >= 0 && x < this.width && y < this.height;
  1070. };
  1071.  
  1072. Window_Selectable.prototype.onTouch = function(triggered) {
  1073. var lastIndex = this.index();
  1074. var x = this.canvasToLocalX(TouchInput.x);
  1075. var y = this.canvasToLocalY(TouchInput.y);
  1076. var hitIndex = this.hitTest(x, y);
  1077. if (hitIndex >= 0) {
  1078. if (hitIndex === this.index()) {
  1079. if (triggered && this.isTouchOkEnabled()) {
  1080. this.processOk();
  1081. }
  1082. } else if (this.isCursorMovable()) {
  1083. this.select(hitIndex);
  1084. }
  1085. } else if (this._stayCount >= 10) {
  1086. if (y < this.padding) {
  1087. this.cursorUp();
  1088. } else if (y >= this.height - this.padding) {
  1089. this.cursorDown();
  1090. }
  1091. }
  1092. if (this.index() !== lastIndex) {
  1093. SoundManager.playCursor();
  1094. }
  1095. };
  1096.  
  1097. Window_Selectable.prototype.hitTest = function(x, y) {
  1098. if (this.isContentsArea(x, y)) {
  1099. var cx = x - this.padding;
  1100. var cy = y - this.padding;
  1101. var topIndex = this.topIndex();
  1102. for (var i = 0; i < this.maxPageItems(); i++) {
  1103. var index = topIndex + i;
  1104. if (index < this.maxItems()) {
  1105. var rect = this.itemRect(index);
  1106. var right = rect.x + rect.width;
  1107. var bottom = rect.y + rect.height;
  1108. if (cx >= rect.x && cy >= rect.y && cx < right && cy < bottom) {
  1109. return index;
  1110. }
  1111. }
  1112. }
  1113. }
  1114. return -1;
  1115. };
  1116.  
  1117. Window_Selectable.prototype.isContentsArea = function(x, y) {
  1118. var left = this.padding;
  1119. var top = this.padding;
  1120. var right = this.width - this.padding;
  1121. var bottom = this.height - this.padding;
  1122. return (x >= left && y >= top && x < right && y < bottom);
  1123. };
  1124.  
  1125. Window_Selectable.prototype.isTouchOkEnabled = function() {
  1126. return this.isOkEnabled();
  1127. };
  1128.  
  1129. Window_Selectable.prototype.isOkEnabled = function() {
  1130. return this.isHandled('ok');
  1131. };
  1132.  
  1133. Window_Selectable.prototype.isCancelEnabled = function() {
  1134. return this.isHandled('cancel');
  1135. };
  1136.  
  1137. Window_Selectable.prototype.isOkTriggered = function() {
  1138. return Input.isRepeated('ok');
  1139. };
  1140.  
  1141. Window_Selectable.prototype.isCancelTriggered = function() {
  1142. return Input.isRepeated('cancel');
  1143. };
  1144.  
  1145. Window_Selectable.prototype.processOk = function() {
  1146. if (this.isCurrentItemEnabled()) {
  1147. this.playOkSound();
  1148. this.updateInputData();
  1149. this.deactivate();
  1150. this.callOkHandler();
  1151. } else {
  1152. this.playBuzzerSound();
  1153. }
  1154. };
  1155.  
  1156. Window_Selectable.prototype.playOkSound = function() {
  1157. SoundManager.playOk();
  1158. };
  1159.  
  1160. Window_Selectable.prototype.playBuzzerSound = function() {
  1161. SoundManager.playBuzzer();
  1162. };
  1163.  
  1164. Window_Selectable.prototype.callOkHandler = function() {
  1165. this.callHandler('ok');
  1166. };
  1167.  
  1168. Window_Selectable.prototype.processCancel = function() {
  1169. SoundManager.playCancel();
  1170. this.updateInputData();
  1171. this.deactivate();
  1172. this.callCancelHandler();
  1173. };
  1174.  
  1175. Window_Selectable.prototype.callCancelHandler = function() {
  1176. this.callHandler('cancel');
  1177. };
  1178.  
  1179. Window_Selectable.prototype.processPageup = function() {
  1180. SoundManager.playCursor();
  1181. this.updateInputData();
  1182. this.deactivate();
  1183. this.callHandler('pageup');
  1184. };
  1185.  
  1186. Window_Selectable.prototype.processPagedown = function() {
  1187. SoundManager.playCursor();
  1188. this.updateInputData();
  1189. this.deactivate();
  1190. this.callHandler('pagedown');
  1191. };
  1192.  
  1193. Window_Selectable.prototype.updateInputData = function() {
  1194. Input.update();
  1195. TouchInput.update();
  1196. };
  1197.  
  1198. Window_Selectable.prototype.updateCursor = function() {
  1199. if (this._cursorAll) {
  1200. var allRowsHeight = this.maxRows() * this.itemHeight();
  1201. this.setCursorRect(0, 0, this.contents.width, allRowsHeight);
  1202. this.setTopRow(0);
  1203. } else if (this.isCursorVisible()) {
  1204. var rect = this.itemRect(this.index());
  1205. this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  1206. } else {
  1207. this.setCursorRect(0, 0, 0, 0);
  1208. }
  1209. };
  1210.  
  1211. Window_Selectable.prototype.isCursorVisible = function() {
  1212. var row = this.row();
  1213. return row >= this.topRow() && row <= this.bottomRow();
  1214. };
  1215.  
  1216. Window_Selectable.prototype.ensureCursorVisible = function() {
  1217. var row = this.row();
  1218. if (row < this.topRow()) {
  1219. this.setTopRow(row);
  1220. } else if (row > this.bottomRow()) {
  1221. this.setBottomRow(row);
  1222. }
  1223. };
  1224.  
  1225. Window_Selectable.prototype.callUpdateHelp = function() {
  1226. if (this.active && this._helpWindow) {
  1227. this.updateHelp();
  1228. }
  1229. };
  1230.  
  1231. Window_Selectable.prototype.updateHelp = function() {
  1232. this._helpWindow.clear();
  1233. };
  1234.  
  1235. Window_Selectable.prototype.setHelpWindowItem = function(item) {
  1236. if (this._helpWindow) {
  1237. this._helpWindow.setItem(item);
  1238. }
  1239. };
  1240.  
  1241. Window_Selectable.prototype.isCurrentItemEnabled = function() {
  1242. return true;
  1243. };
  1244.  
  1245. Window_Selectable.prototype.drawAllItems = function() {
  1246. var topIndex = this.topIndex();
  1247. for (var i = 0; i < this.maxPageItems(); i++) {
  1248. var index = topIndex + i;
  1249. if (index < this.maxItems()) {
  1250. this.drawItem(index);
  1251. }
  1252. }
  1253. };
  1254.  
  1255. Window_Selectable.prototype.drawItem = function(index) {
  1256. };
  1257.  
  1258. Window_Selectable.prototype.clearItem = function(index) {
  1259. var rect = this.itemRect(index);
  1260. this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  1261. };
  1262.  
  1263. Window_Selectable.prototype.redrawItem = function(index) {
  1264. if (index >= 0) {
  1265. this.clearItem(index);
  1266. this.drawItem(index);
  1267. }
  1268. };
  1269.  
  1270. Window_Selectable.prototype.redrawCurrentItem = function() {
  1271. this.redrawItem(this.index());
  1272. };
  1273.  
  1274. Window_Selectable.prototype.refresh = function() {
  1275. if (this.contents) {
  1276. this.contents.clear();
  1277. this.drawAllItems();
  1278. }
  1279. };
  1280.  
  1281. //-----------------------------------------------------------------------------
  1282. // Window_Command
  1283. //
  1284. // The superclass of windows for selecting a command.
  1285.  
  1286. function Window_Command() {
  1287. this.initialize.apply(this, arguments);
  1288. }
  1289.  
  1290. Window_Command.prototype = Object.create(Window_Selectable.prototype);
  1291. Window_Command.prototype.constructor = Window_Command;
  1292.  
  1293. Window_Command.prototype.initialize = function(x, y) {
  1294. this.clearCommandList();
  1295. this.makeCommandList();
  1296. var width = this.windowWidth();
  1297. var height = this.windowHeight();
  1298. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1299. this.refresh();
  1300. this.select(0);
  1301. this.activate();
  1302. };
  1303.  
  1304. Window_Command.prototype.windowWidth = function() {
  1305. return 240;
  1306. };
  1307.  
  1308. Window_Command.prototype.windowHeight = function() {
  1309. return this.fittingHeight(this.numVisibleRows());
  1310. };
  1311.  
  1312. Window_Command.prototype.numVisibleRows = function() {
  1313. return Math.ceil(this.maxItems() / this.maxCols());
  1314. };
  1315.  
  1316. Window_Command.prototype.maxItems = function() {
  1317. return this._list.length;
  1318. };
  1319.  
  1320. Window_Command.prototype.clearCommandList = function() {
  1321. this._list = [];
  1322. };
  1323.  
  1324. Window_Command.prototype.makeCommandList = function() {
  1325. };
  1326.  
  1327. Window_Command.prototype.addCommand = function(name, symbol, enabled, ext) {
  1328. if (enabled === undefined) {
  1329. enabled = true;
  1330. }
  1331. if (ext === undefined) {
  1332. ext = null;
  1333. }
  1334. this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext});
  1335. };
  1336.  
  1337. Window_Command.prototype.commandName = function(index) {
  1338. return this._list[index].name;
  1339. };
  1340.  
  1341. Window_Command.prototype.commandSymbol = function(index) {
  1342. return this._list[index].symbol;
  1343. };
  1344.  
  1345. Window_Command.prototype.isCommandEnabled = function(index) {
  1346. return this._list[index].enabled;
  1347. };
  1348.  
  1349. Window_Command.prototype.currentData = function() {
  1350. return this.index() >= 0 ? this._list[this.index()] : null;
  1351. };
  1352.  
  1353. Window_Command.prototype.isCurrentItemEnabled = function() {
  1354. return this.currentData() ? this.currentData().enabled : false;
  1355. };
  1356.  
  1357. Window_Command.prototype.currentSymbol = function() {
  1358. return this.currentData() ? this.currentData().symbol : null;
  1359. };
  1360.  
  1361. Window_Command.prototype.currentExt = function() {
  1362. return this.currentData() ? this.currentData().ext : null;
  1363. };
  1364.  
  1365. Window_Command.prototype.findSymbol = function(symbol) {
  1366. for (var i = 0; i < this._list.length; i++) {
  1367. if (this._list[i].symbol === symbol) {
  1368. return i;
  1369. }
  1370. }
  1371. return -1;
  1372. };
  1373.  
  1374. Window_Command.prototype.selectSymbol = function(symbol) {
  1375. var index = this.findSymbol(symbol);
  1376. if (index >= 0) {
  1377. this.select(index);
  1378. } else {
  1379. this.select(0);
  1380. }
  1381. };
  1382.  
  1383. Window_Command.prototype.findExt = function(ext) {
  1384. for (var i = 0; i < this._list.length; i++) {
  1385. if (this._list[i].ext === ext) {
  1386. return i;
  1387. }
  1388. }
  1389. return -1;
  1390. };
  1391.  
  1392. Window_Command.prototype.selectExt = function(ext) {
  1393. var index = this.findExt(ext);
  1394. if (index >= 0) {
  1395. this.select(index);
  1396. } else {
  1397. this.select(0);
  1398. }
  1399. };
  1400.  
  1401. Window_Command.prototype.drawItem = function(index) {
  1402. var rect = this.itemRectForText(index);
  1403. var align = this.itemTextAlign();
  1404. this.resetTextColor();
  1405. this.changePaintOpacity(this.isCommandEnabled(index));
  1406. this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align);
  1407. };
  1408.  
  1409. Window_Command.prototype.itemTextAlign = function() {
  1410. return 'left';
  1411. };
  1412.  
  1413. Window_Command.prototype.isOkEnabled = function() {
  1414. return true;
  1415. };
  1416.  
  1417. Window_Command.prototype.callOkHandler = function() {
  1418. var symbol = this.currentSymbol();
  1419. if (this.isHandled(symbol)) {
  1420. this.callHandler(symbol);
  1421. } else if (this.isHandled('ok')) {
  1422. Window_Selectable.prototype.callOkHandler.call(this);
  1423. } else {
  1424. this.activate();
  1425. }
  1426. };
  1427.  
  1428. Window_Command.prototype.refresh = function() {
  1429. this.clearCommandList();
  1430. this.makeCommandList();
  1431. this.createContents();
  1432. Window_Selectable.prototype.refresh.call(this);
  1433. };
  1434.  
  1435. //-----------------------------------------------------------------------------
  1436. // Window_HorzCommand
  1437. //
  1438. // The command window for the horizontal selection format.
  1439.  
  1440. function Window_HorzCommand() {
  1441. this.initialize.apply(this, arguments);
  1442. }
  1443.  
  1444. Window_HorzCommand.prototype = Object.create(Window_Command.prototype);
  1445. Window_HorzCommand.prototype.constructor = Window_HorzCommand;
  1446.  
  1447. Window_HorzCommand.prototype.initialize = function(x, y) {
  1448. Window_Command.prototype.initialize.call(this, x, y);
  1449. };
  1450.  
  1451. Window_HorzCommand.prototype.numVisibleRows = function() {
  1452. return 1;
  1453. };
  1454.  
  1455. Window_HorzCommand.prototype.maxCols = function() {
  1456. return 4;
  1457. };
  1458.  
  1459. Window_HorzCommand.prototype.itemTextAlign = function() {
  1460. return 'center';
  1461. };
  1462.  
  1463. //-----------------------------------------------------------------------------
  1464. // Window_Help
  1465. //
  1466. // The window for displaying the description of the selected item.
  1467.  
  1468. function Window_Help() {
  1469. this.initialize.apply(this, arguments);
  1470. }
  1471.  
  1472. Window_Help.prototype = Object.create(Window_Base.prototype);
  1473. Window_Help.prototype.constructor = Window_Help;
  1474.  
  1475. Window_Help.prototype.initialize = function(numLines) {
  1476. var width = Graphics.boxWidth;
  1477. var height = this.fittingHeight(numLines || 2);
  1478. Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  1479. this._text = '';
  1480. };
  1481.  
  1482. Window_Help.prototype.setText = function(text) {
  1483. if (this._text !== text) {
  1484. this._text = text;
  1485. this.refresh();
  1486. }
  1487. };
  1488.  
  1489. Window_Help.prototype.clear = function() {
  1490. this.setText('');
  1491. };
  1492.  
  1493. Window_Help.prototype.setItem = function(item) {
  1494. this.setText(item ? item.description : '');
  1495. };
  1496.  
  1497. Window_Help.prototype.refresh = function() {
  1498. this.contents.clear();
  1499. this.drawTextEx(this._text, this.textPadding(), 0);
  1500. };
  1501.  
  1502. //-----------------------------------------------------------------------------
  1503. // Window_Gold
  1504. //
  1505. // The window for displaying the party's gold.
  1506.  
  1507. function Window_Gold() {
  1508. this.initialize.apply(this, arguments);
  1509. }
  1510.  
  1511. Window_Gold.prototype = Object.create(Window_Base.prototype);
  1512. Window_Gold.prototype.constructor = Window_Gold;
  1513.  
  1514. Window_Gold.prototype.initialize = function(x, y) {
  1515. var width = this.windowWidth();
  1516. var height = this.windowHeight();
  1517. Window_Base.prototype.initialize.call(this, x, y, width, height);
  1518. this.refresh();
  1519. };
  1520.  
  1521. Window_Gold.prototype.windowWidth = function() {
  1522. return 240;
  1523. };
  1524.  
  1525. Window_Gold.prototype.windowHeight = function() {
  1526. return this.fittingHeight(1);
  1527. };
  1528.  
  1529. Window_Gold.prototype.refresh = function() {
  1530. var x = this.textPadding();
  1531. var width = this.contents.width - this.textPadding() * 2;
  1532. this.contents.clear();
  1533. this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 0, width);
  1534. };
  1535.  
  1536. Window_Gold.prototype.value = function() {
  1537. return $gameParty.gold();
  1538. };
  1539.  
  1540. Window_Gold.prototype.currencyUnit = function() {
  1541. return TextManager.currencyUnit;
  1542. };
  1543.  
  1544. Window_Gold.prototype.open = function() {
  1545. this.refresh();
  1546. Window_Base.prototype.open.call(this);
  1547. };
  1548.  
  1549. //-----------------------------------------------------------------------------
  1550. // Window_MenuCommand
  1551. //
  1552. // The window for selecting a command on the menu screen.
  1553.  
  1554. function Window_MenuCommand() {
  1555. this.initialize.apply(this, arguments);
  1556. }
  1557.  
  1558. Window_MenuCommand.prototype = Object.create(Window_Command.prototype);
  1559. Window_MenuCommand.prototype.constructor = Window_MenuCommand;
  1560.  
  1561. Window_MenuCommand.prototype.initialize = function(x, y) {
  1562. Window_Command.prototype.initialize.call(this, x, y);
  1563. this.selectLast();
  1564. };
  1565.  
  1566. Window_MenuCommand._lastCommandSymbol = null;
  1567.  
  1568. Window_MenuCommand.initCommandPosition = function() {
  1569. this._lastCommandSymbol = null;
  1570. };
  1571.  
  1572. Window_MenuCommand.prototype.windowWidth = function() {
  1573. return 240;
  1574. };
  1575.  
  1576. Window_MenuCommand.prototype.numVisibleRows = function() {
  1577. return this.maxItems();
  1578. };
  1579.  
  1580. Window_MenuCommand.prototype.makeCommandList = function() {
  1581. this.addMainCommands();
  1582. this.addFormationCommand();
  1583. this.addOriginalCommands();
  1584. this.addOptionsCommand();
  1585. this.addSaveCommand();
  1586. this.addGameEndCommand();
  1587. };
  1588.  
  1589. Window_MenuCommand.prototype.addMainCommands = function() {
  1590. var enabled = this.areMainCommandsEnabled();
  1591. if (this.needsCommand('item')) {
  1592. this.addCommand(TextManager.item, 'item', enabled);
  1593. }
  1594. if (this.needsCommand('skill')) {
  1595. this.addCommand(TextManager.skill, 'skill', enabled);
  1596. }
  1597. if (this.needsCommand('equip')) {
  1598. this.addCommand(TextManager.equip, 'equip', enabled);
  1599. }
  1600. if (this.needsCommand('status')) {
  1601. this.addCommand(TextManager.status, 'status', enabled);
  1602. }
  1603. };
  1604.  
  1605. Window_MenuCommand.prototype.addFormationCommand = function() {
  1606. if (this.needsCommand('formation')) {
  1607. var enabled = this.isFormationEnabled();
  1608. this.addCommand(TextManager.formation, 'formation', enabled);
  1609. }
  1610. };
  1611.  
  1612. Window_MenuCommand.prototype.addOriginalCommands = function() {
  1613. };
  1614.  
  1615. Window_MenuCommand.prototype.addOptionsCommand = function() {
  1616. if (this.needsCommand('options')) {
  1617. var enabled = this.isOptionsEnabled();
  1618. this.addCommand(TextManager.options, 'options', enabled);
  1619. }
  1620. };
  1621.  
  1622. Window_MenuCommand.prototype.addSaveCommand = function() {
  1623. if (this.needsCommand('save')) {
  1624. var enabled = this.isSaveEnabled();
  1625. this.addCommand(TextManager.save, 'save', enabled);
  1626. }
  1627. };
  1628.  
  1629. Window_MenuCommand.prototype.addGameEndCommand = function() {
  1630. var enabled = this.isGameEndEnabled();
  1631. this.addCommand(TextManager.gameEnd, 'gameEnd', enabled);
  1632. };
  1633.  
  1634. Window_MenuCommand.prototype.needsCommand = function(name) {
  1635. var flags = $dataSystem.menuCommands;
  1636. if (flags) {
  1637. switch (name) {
  1638. case 'item':
  1639. return flags[0];
  1640. case 'skill':
  1641. return flags[1];
  1642. case 'equip':
  1643. return flags[2];
  1644. case 'status':
  1645. return flags[3];
  1646. case 'formation':
  1647. return flags[4];
  1648. case 'save':
  1649. return flags[5];
  1650. }
  1651. }
  1652. return true;
  1653. };
  1654.  
  1655. Window_MenuCommand.prototype.areMainCommandsEnabled = function() {
  1656. return $gameParty.exists();
  1657. };
  1658.  
  1659. Window_MenuCommand.prototype.isFormationEnabled = function() {
  1660. return $gameParty.size() >= 2 && $gameSystem.isFormationEnabled();
  1661. };
  1662.  
  1663. Window_MenuCommand.prototype.isOptionsEnabled = function() {
  1664. return true;
  1665. };
  1666.  
  1667. Window_MenuCommand.prototype.isSaveEnabled = function() {
  1668. return !DataManager.isEventTest() && $gameSystem.isSaveEnabled();
  1669. };
  1670.  
  1671. Window_MenuCommand.prototype.isGameEndEnabled = function() {
  1672. return true;
  1673. };
  1674.  
  1675. Window_MenuCommand.prototype.processOk = function() {
  1676. Window_MenuCommand._lastCommandSymbol = this.currentSymbol();
  1677. Window_Command.prototype.processOk.call(this);
  1678. };
  1679.  
  1680. Window_MenuCommand.prototype.selectLast = function() {
  1681. this.selectSymbol(Window_MenuCommand._lastCommandSymbol);
  1682. };
  1683.  
  1684. //-----------------------------------------------------------------------------
  1685. // Window_MenuStatus
  1686. //
  1687. // The window for displaying party member status on the menu screen.
  1688.  
  1689. function Window_MenuStatus() {
  1690. this.initialize.apply(this, arguments);
  1691. }
  1692.  
  1693. Window_MenuStatus.prototype = Object.create(Window_Selectable.prototype);
  1694. Window_MenuStatus.prototype.constructor = Window_MenuStatus;
  1695.  
  1696. Window_MenuStatus.prototype.initialize = function(x, y) {
  1697. var width = this.windowWidth();
  1698. var height = this.windowHeight();
  1699. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1700. this._formationMode = false;
  1701. this._pendingIndex = -1;
  1702. this.loadImages();
  1703. this.refresh();
  1704. };
  1705.  
  1706. Window_MenuStatus.prototype.windowWidth = function() {
  1707. return Graphics.boxWidth - 240;
  1708. };
  1709.  
  1710. Window_MenuStatus.prototype.windowHeight = function() {
  1711. return Graphics.boxHeight;
  1712. };
  1713.  
  1714. Window_MenuStatus.prototype.maxItems = function() {
  1715. return $gameParty.size();
  1716. };
  1717.  
  1718. Window_MenuStatus.prototype.itemHeight = function() {
  1719. var clientHeight = this.height - this.padding * 2;
  1720. return Math.floor(clientHeight / this.numVisibleRows());
  1721. };
  1722.  
  1723. Window_MenuStatus.prototype.numVisibleRows = function() {
  1724. return 4;
  1725. };
  1726.  
  1727. Window_MenuStatus.prototype.loadImages = function() {
  1728. $gameParty.members().forEach(function(actor) {
  1729. ImageManager.loadFace(actor.faceName());
  1730. }, this);
  1731. };
  1732.  
  1733. Window_MenuStatus.prototype.drawItem = function(index) {
  1734. this.drawItemBackground(index);
  1735. this.drawItemImage(index);
  1736. this.drawItemStatus(index);
  1737. };
  1738.  
  1739. Window_MenuStatus.prototype.drawItemBackground = function(index) {
  1740. if (index === this._pendingIndex) {
  1741. var rect = this.itemRect(index);
  1742. var color = this.pendingColor();
  1743. this.changePaintOpacity(false);
  1744. this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  1745. this.changePaintOpacity(true);
  1746. }
  1747. };
  1748.  
  1749. Window_MenuStatus.prototype.drawItemImage = function(index) {
  1750. var actor = $gameParty.members()[index];
  1751. var rect = this.itemRect(index);
  1752. this.changePaintOpacity(actor.isBattleMember());
  1753. this.drawActorFace(actor, rect.x + 1, rect.y + 1, Window_Base._faceWidth, Window_Base._faceHeight);
  1754. this.changePaintOpacity(true);
  1755. };
  1756.  
  1757. Window_MenuStatus.prototype.drawItemStatus = function(index) {
  1758. var actor = $gameParty.members()[index];
  1759. var rect = this.itemRect(index);
  1760. var x = rect.x + 162;
  1761. var y = rect.y + rect.height / 2 - this.lineHeight() * 1.5;
  1762. var width = rect.width - x - this.textPadding();
  1763. this.drawActorSimpleStatus(actor, x, y, width);
  1764. };
  1765.  
  1766. Window_MenuStatus.prototype.processOk = function() {
  1767. Window_Selectable.prototype.processOk.call(this);
  1768. $gameParty.setMenuActor($gameParty.members()[this.index()]);
  1769. };
  1770.  
  1771. Window_MenuStatus.prototype.isCurrentItemEnabled = function() {
  1772. if (this._formationMode) {
  1773. var actor = $gameParty.members()[this.index()];
  1774. return actor && actor.isFormationChangeOk();
  1775. } else {
  1776. return true;
  1777. }
  1778. };
  1779.  
  1780. Window_MenuStatus.prototype.selectLast = function() {
  1781. this.select($gameParty.menuActor().index() || 0);
  1782. };
  1783.  
  1784. Window_MenuStatus.prototype.formationMode = function() {
  1785. return this._formationMode;
  1786. };
  1787.  
  1788. Window_MenuStatus.prototype.setFormationMode = function(formationMode) {
  1789. this._formationMode = formationMode;
  1790. };
  1791.  
  1792. Window_MenuStatus.prototype.pendingIndex = function() {
  1793. return this._pendingIndex;
  1794. };
  1795.  
  1796. Window_MenuStatus.prototype.setPendingIndex = function(index) {
  1797. var lastPendingIndex = this._pendingIndex;
  1798. this._pendingIndex = index;
  1799. this.redrawItem(this._pendingIndex);
  1800. this.redrawItem(lastPendingIndex);
  1801. };
  1802.  
  1803. //-----------------------------------------------------------------------------
  1804. // Window_MenuActor
  1805. //
  1806. // The window for selecting a target actor on the item and skill screens.
  1807.  
  1808. function Window_MenuActor() {
  1809. this.initialize.apply(this, arguments);
  1810. }
  1811.  
  1812. Window_MenuActor.prototype = Object.create(Window_MenuStatus.prototype);
  1813. Window_MenuActor.prototype.constructor = Window_MenuActor;
  1814.  
  1815. Window_MenuActor.prototype.initialize = function() {
  1816. Window_MenuStatus.prototype.initialize.call(this, 0, 0);
  1817. this.hide();
  1818. };
  1819.  
  1820. Window_MenuActor.prototype.processOk = function() {
  1821. if (!this.cursorAll()) {
  1822. $gameParty.setTargetActor($gameParty.members()[this.index()]);
  1823. }
  1824. this.callOkHandler();
  1825. };
  1826.  
  1827. Window_MenuActor.prototype.selectLast = function() {
  1828. this.select($gameParty.targetActor().index() || 0);
  1829. };
  1830.  
  1831. Window_MenuActor.prototype.selectForItem = function(item) {
  1832. var actor = $gameParty.menuActor();
  1833. var action = new Game_Action(actor);
  1834. action.setItemObject(item);
  1835. this.setCursorFixed(false);
  1836. this.setCursorAll(false);
  1837. if (action.isForUser()) {
  1838. if (DataManager.isSkill(item)) {
  1839. this.setCursorFixed(true);
  1840. this.select(actor.index());
  1841. } else {
  1842. this.selectLast();
  1843. }
  1844. } else if (action.isForAll()) {
  1845. this.setCursorAll(true);
  1846. this.select(0);
  1847. } else {
  1848. this.selectLast();
  1849. }
  1850. };
  1851.  
  1852. //-----------------------------------------------------------------------------
  1853. // Window_ItemCategory
  1854. //
  1855. // The window for selecting a category of items on the item and shop screens.
  1856.  
  1857. function Window_ItemCategory() {
  1858. this.initialize.apply(this, arguments);
  1859. }
  1860.  
  1861. Window_ItemCategory.prototype = Object.create(Window_HorzCommand.prototype);
  1862. Window_ItemCategory.prototype.constructor = Window_ItemCategory;
  1863.  
  1864. Window_ItemCategory.prototype.initialize = function() {
  1865. Window_HorzCommand.prototype.initialize.call(this, 0, 0);
  1866. };
  1867.  
  1868. Window_ItemCategory.prototype.windowWidth = function() {
  1869. return Graphics.boxWidth;
  1870. };
  1871.  
  1872. Window_ItemCategory.prototype.maxCols = function() {
  1873. return 4;
  1874. };
  1875.  
  1876. Window_ItemCategory.prototype.update = function() {
  1877. Window_HorzCommand.prototype.update.call(this);
  1878. if (this._itemWindow) {
  1879. this._itemWindow.setCategory(this.currentSymbol());
  1880. }
  1881. };
  1882.  
  1883. Window_ItemCategory.prototype.makeCommandList = function() {
  1884. this.addCommand(TextManager.item, 'item');
  1885. this.addCommand(TextManager.weapon, 'weapon');
  1886. this.addCommand(TextManager.armor, 'armor');
  1887. this.addCommand(TextManager.keyItem, 'keyItem');
  1888. };
  1889.  
  1890. Window_ItemCategory.prototype.setItemWindow = function(itemWindow) {
  1891. this._itemWindow = itemWindow;
  1892. this.update();
  1893. };
  1894.  
  1895. //-----------------------------------------------------------------------------
  1896. // Window_ItemList
  1897. //
  1898. // The window for selecting an item on the item screen.
  1899.  
  1900. function Window_ItemList() {
  1901. this.initialize.apply(this, arguments);
  1902. }
  1903.  
  1904. Window_ItemList.prototype = Object.create(Window_Selectable.prototype);
  1905. Window_ItemList.prototype.constructor = Window_ItemList;
  1906.  
  1907. Window_ItemList.prototype.initialize = function(x, y, width, height) {
  1908. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1909. this._category = 'none';
  1910. this._data = [];
  1911. };
  1912.  
  1913. Window_ItemList.prototype.setCategory = function(category) {
  1914. if (this._category !== category) {
  1915. this._category = category;
  1916. this.refresh();
  1917. this.resetScroll();
  1918. }
  1919. };
  1920.  
  1921. Window_ItemList.prototype.maxCols = function() {
  1922. return 2;
  1923. };
  1924.  
  1925. Window_ItemList.prototype.spacing = function() {
  1926. return 48;
  1927. };
  1928.  
  1929. Window_ItemList.prototype.maxItems = function() {
  1930. return this._data ? this._data.length : 1;
  1931. };
  1932.  
  1933. Window_ItemList.prototype.item = function() {
  1934. var index = this.index();
  1935. return this._data && index >= 0 ? this._data[index] : null;
  1936. };
  1937.  
  1938. Window_ItemList.prototype.isCurrentItemEnabled = function() {
  1939. return this.isEnabled(this.item());
  1940. };
  1941.  
  1942. Window_ItemList.prototype.includes = function(item) {
  1943. switch (this._category) {
  1944. case 'item':
  1945. return DataManager.isItem(item) && item.itypeId === 1;
  1946. case 'weapon':
  1947. return DataManager.isWeapon(item);
  1948. case 'armor':
  1949. return DataManager.isArmor(item);
  1950. case 'keyItem':
  1951. return DataManager.isItem(item) && item.itypeId === 2;
  1952. default:
  1953. return false;
  1954. }
  1955. };
  1956.  
  1957. Window_ItemList.prototype.needsNumber = function() {
  1958. return true;
  1959. };
  1960.  
  1961. Window_ItemList.prototype.isEnabled = function(item) {
  1962. return $gameParty.canUse(item);
  1963. };
  1964.  
  1965. Window_ItemList.prototype.makeItemList = function() {
  1966. this._data = $gameParty.allItems().filter(function(item) {
  1967. return this.includes(item);
  1968. }, this);
  1969. if (this.includes(null)) {
  1970. this._data.push(null);
  1971. }
  1972. };
  1973.  
  1974. Window_ItemList.prototype.selectLast = function() {
  1975. var index = this._data.indexOf($gameParty.lastItem());
  1976. this.select(index >= 0 ? index : 0);
  1977. };
  1978.  
  1979. Window_ItemList.prototype.drawItem = function(index) {
  1980. var item = this._data[index];
  1981. if (item) {
  1982. var numberWidth = this.numberWidth();
  1983. var rect = this.itemRect(index);
  1984. rect.width -= this.textPadding();
  1985. this.changePaintOpacity(this.isEnabled(item));
  1986. this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
  1987. this.drawItemNumber(item, rect.x, rect.y, rect.width);
  1988. this.changePaintOpacity(1);
  1989. }
  1990. };
  1991.  
  1992. Window_ItemList.prototype.numberWidth = function() {
  1993. return this.textWidth('000');
  1994. };
  1995.  
  1996. Window_ItemList.prototype.drawItemNumber = function(item, x, y, width) {
  1997. if (this.needsNumber()) {
  1998. this.drawText(':', x, y, width - this.textWidth('00'), 'right');
  1999. this.drawText($gameParty.numItems(item), x, y, width, 'right');
  2000. }
  2001. };
  2002.  
  2003. Window_ItemList.prototype.updateHelp = function() {
  2004. this.setHelpWindowItem(this.item());
  2005. };
  2006.  
  2007. Window_ItemList.prototype.refresh = function() {
  2008. this.makeItemList();
  2009. this.createContents();
  2010. this.drawAllItems();
  2011. };
  2012.  
  2013. //-----------------------------------------------------------------------------
  2014. // Window_SkillType
  2015. //
  2016. // The window for selecting a skill type on the skill screen.
  2017.  
  2018. function Window_SkillType() {
  2019. this.initialize.apply(this, arguments);
  2020. }
  2021.  
  2022. Window_SkillType.prototype = Object.create(Window_Command.prototype);
  2023. Window_SkillType.prototype.constructor = Window_SkillType;
  2024.  
  2025. Window_SkillType.prototype.initialize = function(x, y) {
  2026. Window_Command.prototype.initialize.call(this, x, y);
  2027. this._actor = null;
  2028. };
  2029.  
  2030. Window_SkillType.prototype.windowWidth = function() {
  2031. return 240;
  2032. };
  2033.  
  2034. Window_SkillType.prototype.setActor = function(actor) {
  2035. if (this._actor !== actor) {
  2036. this._actor = actor;
  2037. this.refresh();
  2038. this.selectLast();
  2039. }
  2040. };
  2041.  
  2042. Window_SkillType.prototype.numVisibleRows = function() {
  2043. return 4;
  2044. };
  2045.  
  2046. Window_SkillType.prototype.makeCommandList = function() {
  2047. if (this._actor) {
  2048. var skillTypes = this._actor.addedSkillTypes();
  2049. skillTypes.sort(function(a, b) {
  2050. return a - b;
  2051. });
  2052. skillTypes.forEach(function(stypeId) {
  2053. var name = $dataSystem.skillTypes[stypeId];
  2054. this.addCommand(name, 'skill', true, stypeId);
  2055. }, this);
  2056. }
  2057. };
  2058.  
  2059. Window_SkillType.prototype.update = function() {
  2060. Window_Command.prototype.update.call(this);
  2061. if (this._skillWindow) {
  2062. this._skillWindow.setStypeId(this.currentExt());
  2063. }
  2064. };
  2065.  
  2066. Window_SkillType.prototype.setSkillWindow = function(skillWindow) {
  2067. this._skillWindow = skillWindow;
  2068. this.update();
  2069. };
  2070.  
  2071. Window_SkillType.prototype.selectLast = function() {
  2072. var skill = this._actor.lastMenuSkill();
  2073. if (skill) {
  2074. this.selectExt(skill.stypeId);
  2075. } else {
  2076. this.select(0);
  2077. }
  2078. };
  2079.  
  2080. //-----------------------------------------------------------------------------
  2081. // Window_SkillStatus
  2082. //
  2083. // The window for displaying the skill user's status on the skill screen.
  2084.  
  2085. function Window_SkillStatus() {
  2086. this.initialize.apply(this, arguments);
  2087. }
  2088.  
  2089. Window_SkillStatus.prototype = Object.create(Window_Base.prototype);
  2090. Window_SkillStatus.prototype.constructor = Window_SkillStatus;
  2091.  
  2092. Window_SkillStatus.prototype.initialize = function(x, y, width, height) {
  2093. Window_Base.prototype.initialize.call(this, x, y, width, height);
  2094. this._actor = null;
  2095. };
  2096.  
  2097. Window_SkillStatus.prototype.setActor = function(actor) {
  2098. if (this._actor !== actor) {
  2099. this._actor = actor;
  2100. this.refresh();
  2101. }
  2102. };
  2103.  
  2104. Window_SkillStatus.prototype.refresh = function() {
  2105. this.contents.clear();
  2106. if (this._actor) {
  2107. var w = this.width - this.padding * 2;
  2108. var h = this.height - this.padding * 2;
  2109. var y = h / 2 - this.lineHeight() * 1.5;
  2110. var width = w - 162 - this.textPadding();
  2111. this.drawActorFace(this._actor, 0, 0, 144, h);
  2112. this.drawActorSimpleStatus(this._actor, 162, y, width);
  2113. }
  2114. };
  2115.  
  2116. //-----------------------------------------------------------------------------
  2117. // Window_SkillList
  2118. //
  2119. // The window for selecting a skill on the skill screen.
  2120.  
  2121. function Window_SkillList() {
  2122. this.initialize.apply(this, arguments);
  2123. }
  2124.  
  2125. Window_SkillList.prototype = Object.create(Window_Selectable.prototype);
  2126. Window_SkillList.prototype.constructor = Window_SkillList;
  2127.  
  2128. Window_SkillList.prototype.initialize = function(x, y, width, height) {
  2129. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2130. this._actor = null;
  2131. this._stypeId = 0;
  2132. this._data = [];
  2133. };
  2134.  
  2135. Window_SkillList.prototype.setActor = function(actor) {
  2136. if (this._actor !== actor) {
  2137. this._actor = actor;
  2138. this.refresh();
  2139. this.resetScroll();
  2140. }
  2141. };
  2142.  
  2143. Window_SkillList.prototype.setStypeId = function(stypeId) {
  2144. if (this._stypeId !== stypeId) {
  2145. this._stypeId = stypeId;
  2146. this.refresh();
  2147. this.resetScroll();
  2148. }
  2149. };
  2150.  
  2151. Window_SkillList.prototype.maxCols = function() {
  2152. return 2;
  2153. };
  2154.  
  2155. Window_SkillList.prototype.spacing = function() {
  2156. return 48;
  2157. };
  2158.  
  2159. Window_SkillList.prototype.maxItems = function() {
  2160. return this._data ? this._data.length : 1;
  2161. };
  2162.  
  2163. Window_SkillList.prototype.item = function() {
  2164. return this._data && this.index() >= 0 ? this._data[this.index()] : null;
  2165. };
  2166.  
  2167. Window_SkillList.prototype.isCurrentItemEnabled = function() {
  2168. return this.isEnabled(this._data[this.index()]);
  2169. };
  2170.  
  2171. Window_SkillList.prototype.includes = function(item) {
  2172. return item && item.stypeId === this._stypeId;
  2173. };
  2174.  
  2175. Window_SkillList.prototype.isEnabled = function(item) {
  2176. return this._actor && this._actor.canUse(item);
  2177. };
  2178.  
  2179. Window_SkillList.prototype.makeItemList = function() {
  2180. if (this._actor) {
  2181. this._data = this._actor.skills().filter(function(item) {
  2182. return this.includes(item);
  2183. }, this);
  2184. } else {
  2185. this._data = [];
  2186. }
  2187. };
  2188.  
  2189. Window_SkillList.prototype.selectLast = function() {
  2190. var skill;
  2191. if ($gameParty.inBattle()) {
  2192. skill = this._actor.lastBattleSkill();
  2193. } else {
  2194. skill = this._actor.lastMenuSkill();
  2195. }
  2196. var index = this._data.indexOf(skill);
  2197. this.select(index >= 0 ? index : 0);
  2198. };
  2199.  
  2200. Window_SkillList.prototype.drawItem = function(index) {
  2201. var skill = this._data[index];
  2202. if (skill) {
  2203. var costWidth = this.costWidth();
  2204. var rect = this.itemRect(index);
  2205. rect.width -= this.textPadding();
  2206. this.changePaintOpacity(this.isEnabled(skill));
  2207. this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
  2208. this.drawSkillCost(skill, rect.x, rect.y, rect.width);
  2209. this.changePaintOpacity(1);
  2210. }
  2211. };
  2212.  
  2213. Window_SkillList.prototype.costWidth = function() {
  2214. return this.textWidth('000');
  2215. };
  2216.  
  2217. Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
  2218. if (this._actor.skillTpCost(skill) > 0) {
  2219. this.changeTextColor(this.tpCostColor());
  2220. this.drawText(this._actor.skillTpCost(skill), x, y, width, 'right');
  2221. } else if (this._actor.skillMpCost(skill) > 0) {
  2222. this.changeTextColor(this.mpCostColor());
  2223. this.drawText(this._actor.skillMpCost(skill), x, y, width, 'right');
  2224. }
  2225. };
  2226.  
  2227. Window_SkillList.prototype.updateHelp = function() {
  2228. this.setHelpWindowItem(this.item());
  2229. };
  2230.  
  2231. Window_SkillList.prototype.refresh = function() {
  2232. this.makeItemList();
  2233. this.createContents();
  2234. this.drawAllItems();
  2235. };
  2236.  
  2237. //-----------------------------------------------------------------------------
  2238. // Window_EquipStatus
  2239. //
  2240. // The window for displaying parameter changes on the equipment screen.
  2241.  
  2242. function Window_EquipStatus() {
  2243. this.initialize.apply(this, arguments);
  2244. }
  2245.  
  2246. Window_EquipStatus.prototype = Object.create(Window_Base.prototype);
  2247. Window_EquipStatus.prototype.constructor = Window_EquipStatus;
  2248.  
  2249. Window_EquipStatus.prototype.initialize = function(x, y) {
  2250. var width = this.windowWidth();
  2251. var height = this.windowHeight();
  2252. Window_Base.prototype.initialize.call(this, x, y, width, height);
  2253. this._actor = null;
  2254. this._tempActor = null;
  2255. this.refresh();
  2256. };
  2257.  
  2258. Window_EquipStatus.prototype.windowWidth = function() {
  2259. return 312;
  2260. };
  2261.  
  2262. Window_EquipStatus.prototype.windowHeight = function() {
  2263. return this.fittingHeight(this.numVisibleRows());
  2264. };
  2265.  
  2266. Window_EquipStatus.prototype.numVisibleRows = function() {
  2267. return 7;
  2268. };
  2269.  
  2270. Window_EquipStatus.prototype.setActor = function(actor) {
  2271. if (this._actor !== actor) {
  2272. this._actor = actor;
  2273. this.refresh();
  2274. }
  2275. };
  2276.  
  2277. Window_EquipStatus.prototype.refresh = function() {
  2278. this.contents.clear();
  2279. if (this._actor) {
  2280. this.drawActorName(this._actor, this.textPadding(), 0);
  2281. for (var i = 0; i < 6; i++) {
  2282. this.drawItem(0, this.lineHeight() * (1 + i), 2 + i);
  2283. }
  2284. }
  2285. };
  2286.  
  2287. Window_EquipStatus.prototype.setTempActor = function(tempActor) {
  2288. if (this._tempActor !== tempActor) {
  2289. this._tempActor = tempActor;
  2290. this.refresh();
  2291. }
  2292. };
  2293.  
  2294. Window_EquipStatus.prototype.drawItem = function(x, y, paramId) {
  2295. this.drawParamName(x + this.textPadding(), y, paramId);
  2296. if (this._actor) {
  2297. this.drawCurrentParam(x + 140, y, paramId);
  2298. }
  2299. this.drawRightArrow(x + 188, y);
  2300. if (this._tempActor) {
  2301. this.drawNewParam(x + 222, y, paramId);
  2302. }
  2303. };
  2304.  
  2305. Window_EquipStatus.prototype.drawParamName = function(x, y, paramId) {
  2306. this.changeTextColor(this.systemColor());
  2307. this.drawText(TextManager.param(paramId), x, y, 120);
  2308. };
  2309.  
  2310. Window_EquipStatus.prototype.drawCurrentParam = function(x, y, paramId) {
  2311. this.resetTextColor();
  2312. this.drawText(this._actor.param(paramId), x, y, 48, 'right');
  2313. };
  2314.  
  2315. Window_EquipStatus.prototype.drawRightArrow = function(x, y) {
  2316. this.changeTextColor(this.systemColor());
  2317. this.drawText('\u2192', x, y, 32, 'center');
  2318. };
  2319.  
  2320. Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) {
  2321. var newValue = this._tempActor.param(paramId);
  2322. var diffvalue = newValue - this._actor.param(paramId);
  2323. this.changeTextColor(this.paramchangeTextColor(diffvalue));
  2324. this.drawText(newValue, x, y, 48, 'right');
  2325. };
  2326.  
  2327. //-----------------------------------------------------------------------------
  2328. // Window_EquipCommand
  2329. //
  2330. // The window for selecting a command on the equipment screen.
  2331.  
  2332. function Window_EquipCommand() {
  2333. this.initialize.apply(this, arguments);
  2334. }
  2335.  
  2336. Window_EquipCommand.prototype = Object.create(Window_HorzCommand.prototype);
  2337. Window_EquipCommand.prototype.constructor = Window_EquipCommand;
  2338.  
  2339. Window_EquipCommand.prototype.initialize = function(x, y, width) {
  2340. this._windowWidth = width;
  2341. Window_HorzCommand.prototype.initialize.call(this, x, y);
  2342. };
  2343.  
  2344. Window_EquipCommand.prototype.windowWidth = function() {
  2345. return this._windowWidth;
  2346. };
  2347.  
  2348. Window_EquipCommand.prototype.maxCols = function() {
  2349. return 3;
  2350. };
  2351.  
  2352. Window_EquipCommand.prototype.makeCommandList = function() {
  2353. this.addCommand(TextManager.equip2, 'equip');
  2354. this.addCommand(TextManager.optimize, 'optimize');
  2355. this.addCommand(TextManager.clear, 'clear');
  2356. };
  2357.  
  2358. //-----------------------------------------------------------------------------
  2359. // Window_EquipSlot
  2360. //
  2361. // The window for selecting an equipment slot on the equipment screen.
  2362.  
  2363. function Window_EquipSlot() {
  2364. this.initialize.apply(this, arguments);
  2365. }
  2366.  
  2367. Window_EquipSlot.prototype = Object.create(Window_Selectable.prototype);
  2368. Window_EquipSlot.prototype.constructor = Window_EquipSlot;
  2369.  
  2370. Window_EquipSlot.prototype.initialize = function(x, y, width, height) {
  2371. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2372. this._actor = null;
  2373. this.refresh();
  2374. };
  2375.  
  2376. Window_EquipSlot.prototype.setActor = function(actor) {
  2377. if (this._actor !== actor) {
  2378. this._actor = actor;
  2379. this.refresh();
  2380. }
  2381. };
  2382.  
  2383. Window_EquipSlot.prototype.update = function() {
  2384. Window_Selectable.prototype.update.call(this);
  2385. if (this._itemWindow) {
  2386. this._itemWindow.setSlotId(this.index());
  2387. }
  2388. };
  2389.  
  2390. Window_EquipSlot.prototype.maxItems = function() {
  2391. return this._actor ? this._actor.equipSlots().length : 0;
  2392. };
  2393.  
  2394. Window_EquipSlot.prototype.item = function() {
  2395. return this._actor ? this._actor.equips()[this.index()] : null;
  2396. };
  2397.  
  2398. Window_EquipSlot.prototype.drawItem = function(index) {
  2399. if (this._actor) {
  2400. var rect = this.itemRectForText(index);
  2401. this.changeTextColor(this.systemColor());
  2402. this.changePaintOpacity(this.isEnabled(index));
  2403. this.drawText(this.slotName(index), rect.x, rect.y, 138, this.lineHeight());
  2404. this.drawItemName(this._actor.equips()[index], rect.x + 138, rect.y);
  2405. this.changePaintOpacity(true);
  2406. }
  2407. };
  2408.  
  2409. Window_EquipSlot.prototype.slotName = function(index) {
  2410. var slots = this._actor.equipSlots();
  2411. return this._actor ? $dataSystem.equipTypes[slots[index]] : '';
  2412. };
  2413.  
  2414. Window_EquipSlot.prototype.isEnabled = function(index) {
  2415. return this._actor ? this._actor.isEquipChangeOk(index) : false;
  2416. };
  2417.  
  2418. Window_EquipSlot.prototype.isCurrentItemEnabled = function() {
  2419. return this.isEnabled(this.index());
  2420. };
  2421.  
  2422. Window_EquipSlot.prototype.setStatusWindow = function(statusWindow) {
  2423. this._statusWindow = statusWindow;
  2424. this.callUpdateHelp();
  2425. };
  2426.  
  2427. Window_EquipSlot.prototype.setItemWindow = function(itemWindow) {
  2428. this._itemWindow = itemWindow;
  2429. this.update();
  2430. };
  2431.  
  2432. Window_EquipSlot.prototype.updateHelp = function() {
  2433. Window_Selectable.prototype.updateHelp.call(this);
  2434. this.setHelpWindowItem(this.item());
  2435. if (this._statusWindow) {
  2436. this._statusWindow.setTempActor(null);
  2437. }
  2438. };
  2439.  
  2440. //-----------------------------------------------------------------------------
  2441. // Window_EquipItem
  2442. //
  2443. // The window for selecting an equipment item on the equipment screen.
  2444.  
  2445. function Window_EquipItem() {
  2446. this.initialize.apply(this, arguments);
  2447. }
  2448.  
  2449. Window_EquipItem.prototype = Object.create(Window_ItemList.prototype);
  2450. Window_EquipItem.prototype.constructor = Window_EquipItem;
  2451.  
  2452. Window_EquipItem.prototype.initialize = function(x, y, width, height) {
  2453. Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  2454. this._actor = null;
  2455. this._slotId = 0;
  2456. };
  2457.  
  2458. Window_EquipItem.prototype.setActor = function(actor) {
  2459. if (this._actor !== actor) {
  2460. this._actor = actor;
  2461. this.refresh();
  2462. this.resetScroll();
  2463. }
  2464. };
  2465.  
  2466. Window_EquipItem.prototype.setSlotId = function(slotId) {
  2467. if (this._slotId !== slotId) {
  2468. this._slotId = slotId;
  2469. this.refresh();
  2470. this.resetScroll();
  2471. }
  2472. };
  2473.  
  2474. Window_EquipItem.prototype.includes = function(item) {
  2475. if (item === null) {
  2476. return true;
  2477. }
  2478. if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
  2479. return false;
  2480. }
  2481. return this._actor.canEquip(item);
  2482. };
  2483.  
  2484. Window_EquipItem.prototype.isEnabled = function(item) {
  2485. return true;
  2486. };
  2487.  
  2488. Window_EquipItem.prototype.selectLast = function() {
  2489. };
  2490.  
  2491. Window_EquipItem.prototype.setStatusWindow = function(statusWindow) {
  2492. this._statusWindow = statusWindow;
  2493. this.callUpdateHelp();
  2494. };
  2495.  
  2496. Window_EquipItem.prototype.updateHelp = function() {
  2497. Window_ItemList.prototype.updateHelp.call(this);
  2498. if (this._actor && this._statusWindow) {
  2499. var actor = JsonEx.makeDeepCopy(this._actor);
  2500. actor.forceChangeEquip(this._slotId, this.item());
  2501. this._statusWindow.setTempActor(actor);
  2502. }
  2503. };
  2504.  
  2505. Window_EquipItem.prototype.playOkSound = function() {
  2506. };
  2507.  
  2508. //-----------------------------------------------------------------------------
  2509. // Window_Status
  2510. //
  2511. // The window for displaying full status on the status screen.
  2512.  
  2513. function Window_Status() {
  2514. this.initialize.apply(this, arguments);
  2515. }
  2516.  
  2517. Window_Status.prototype = Object.create(Window_Selectable.prototype);
  2518. Window_Status.prototype.constructor = Window_Status;
  2519.  
  2520. Window_Status.prototype.initialize = function() {
  2521. var width = Graphics.boxWidth;
  2522. var height = Graphics.boxHeight;
  2523. Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  2524. this.refresh();
  2525. this.activate();
  2526. };
  2527.  
  2528. Window_Status.prototype.setActor = function(actor) {
  2529. if (this._actor !== actor) {
  2530. this._actor = actor;
  2531. this.refresh();
  2532. }
  2533. };
  2534.  
  2535. Window_Status.prototype.refresh = function() {
  2536. this.contents.clear();
  2537. if (this._actor) {
  2538. var lineHeight = this.lineHeight();
  2539. this.drawBlock1(lineHeight * 0);
  2540. this.drawHorzLine(lineHeight * 1);
  2541. this.drawBlock2(lineHeight * 2);
  2542. this.drawHorzLine(lineHeight * 6);
  2543. this.drawBlock3(lineHeight * 7);
  2544. this.drawHorzLine(lineHeight * 13);
  2545. this.drawBlock4(lineHeight * 14);
  2546. }
  2547. };
  2548.  
  2549. Window_Status.prototype.drawBlock1 = function(y) {
  2550. this.drawActorName(this._actor, 6, y);
  2551. this.drawActorClass(this._actor, 192, y);
  2552. this.drawActorNickname(this._actor, 432, y);
  2553. };
  2554.  
  2555. Window_Status.prototype.drawBlock2 = function(y) {
  2556. this.drawActorFace(this._actor, 12, y);
  2557. this.drawBasicInfo(204, y);
  2558. this.drawExpInfo(456, y);
  2559. };
  2560.  
  2561. Window_Status.prototype.drawBlock3 = function(y) {
  2562. this.drawParameters(48, y);
  2563. this.drawEquipments(432, y);
  2564. };
  2565.  
  2566. Window_Status.prototype.drawBlock4 = function(y) {
  2567. this.drawProfile(6, y);
  2568. };
  2569.  
  2570. Window_Status.prototype.drawHorzLine = function(y) {
  2571. var lineY = y + this.lineHeight() / 2 - 1;
  2572. this.contents.paintOpacity = 48;
  2573. this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
  2574. this.contents.paintOpacity = 255;
  2575. };
  2576.  
  2577. Window_Status.prototype.lineColor = function() {
  2578. return this.normalColor();
  2579. };
  2580.  
  2581. Window_Status.prototype.drawBasicInfo = function(x, y) {
  2582. var lineHeight = this.lineHeight();
  2583. this.drawActorLevel(this._actor, x, y + lineHeight * 0);
  2584. this.drawActorIcons(this._actor, x, y + lineHeight * 1);
  2585. this.drawActorHp(this._actor, x, y + lineHeight * 2);
  2586. this.drawActorMp(this._actor, x, y + lineHeight * 3);
  2587. };
  2588.  
  2589. Window_Status.prototype.drawParameters = function(x, y) {
  2590. var lineHeight = this.lineHeight();
  2591. for (var i = 0; i < 6; i++) {
  2592. var paramId = i + 2;
  2593. var y2 = y + lineHeight * i;
  2594. this.changeTextColor(this.systemColor());
  2595. this.drawText(TextManager.param(paramId), x, y2, 160);
  2596. this.resetTextColor();
  2597. this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right');
  2598. }
  2599. };
  2600.  
  2601. Window_Status.prototype.drawExpInfo = function(x, y) {
  2602. var lineHeight = this.lineHeight();
  2603. var expTotal = TextManager.expTotal.format(TextManager.exp);
  2604. var expNext = TextManager.expNext.format(TextManager.level);
  2605. var value1 = this._actor.currentExp();
  2606. var value2 = this._actor.nextRequiredExp();
  2607. if (this._actor.isMaxLevel()) {
  2608. value1 = '-------';
  2609. value2 = '-------';
  2610. }
  2611. this.changeTextColor(this.systemColor());
  2612. this.drawText(expTotal, x, y + lineHeight * 0, 270);
  2613. this.drawText(expNext, x, y + lineHeight * 2, 270);
  2614. this.resetTextColor();
  2615. this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
  2616. this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
  2617. };
  2618.  
  2619. Window_Status.prototype.drawEquipments = function(x, y) {
  2620. var equips = this._actor.equips();
  2621. var count = Math.min(equips.length, this.maxEquipmentLines());
  2622. for (var i = 0; i < count; i++) {
  2623. this.drawItemName(equips[i], x, y + this.lineHeight() * i);
  2624. }
  2625. };
  2626.  
  2627. Window_Status.prototype.drawProfile = function(x, y) {
  2628. this.drawTextEx(this._actor.profile(), x, y);
  2629. };
  2630.  
  2631. Window_Status.prototype.maxEquipmentLines = function() {
  2632. return 6;
  2633. };
  2634.  
  2635. //-----------------------------------------------------------------------------
  2636. // Window_Options
  2637. //
  2638. // The window for changing various settings on the options screen.
  2639.  
  2640. function Window_Options() {
  2641. this.initialize.apply(this, arguments);
  2642. }
  2643.  
  2644. Window_Options.prototype = Object.create(Window_Command.prototype);
  2645. Window_Options.prototype.constructor = Window_Options;
  2646.  
  2647. Window_Options.prototype.initialize = function() {
  2648. Window_Command.prototype.initialize.call(this, 0, 0);
  2649. this.updatePlacement();
  2650. };
  2651.  
  2652. Window_Options.prototype.windowWidth = function() {
  2653. return 400;
  2654. };
  2655.  
  2656. Window_Options.prototype.windowHeight = function() {
  2657. return this.fittingHeight(Math.min(this.numVisibleRows(), 12));
  2658. };
  2659.  
  2660. Window_Options.prototype.updatePlacement = function() {
  2661. this.x = (Graphics.boxWidth - this.width) / 2;
  2662. this.y = (Graphics.boxHeight - this.height) / 2;
  2663. };
  2664.  
  2665. Window_Options.prototype.makeCommandList = function() {
  2666. this.addGeneralOptions();
  2667. this.addVolumeOptions();
  2668. };
  2669.  
  2670. Window_Options.prototype.addGeneralOptions = function() {
  2671. this.addCommand(TextManager.alwaysDash, 'alwaysDash');
  2672. this.addCommand(TextManager.commandRemember, 'commandRemember');
  2673. };
  2674.  
  2675. Window_Options.prototype.addVolumeOptions = function() {
  2676. this.addCommand(TextManager.bgmVolume, 'bgmVolume');
  2677. this.addCommand(TextManager.bgsVolume, 'bgsVolume');
  2678. this.addCommand(TextManager.meVolume, 'meVolume');
  2679. this.addCommand(TextManager.seVolume, 'seVolume');
  2680. };
  2681.  
  2682. Window_Options.prototype.drawItem = function(index) {
  2683. var rect = this.itemRectForText(index);
  2684. var statusWidth = this.statusWidth();
  2685. var titleWidth = rect.width - statusWidth;
  2686. this.resetTextColor();
  2687. this.changePaintOpacity(this.isCommandEnabled(index));
  2688. this.drawText(this.commandName(index), rect.x, rect.y, titleWidth, 'left');
  2689. this.drawText(this.statusText(index), titleWidth, rect.y, statusWidth, 'right');
  2690. };
  2691.  
  2692. Window_Options.prototype.statusWidth = function() {
  2693. return 120;
  2694. };
  2695.  
  2696. Window_Options.prototype.statusText = function(index) {
  2697. var symbol = this.commandSymbol(index);
  2698. var value = this.getConfigValue(symbol);
  2699. if (this.isVolumeSymbol(symbol)) {
  2700. return this.volumeStatusText(value);
  2701. } else {
  2702. return this.booleanStatusText(value);
  2703. }
  2704. };
  2705.  
  2706. Window_Options.prototype.isVolumeSymbol = function(symbol) {
  2707. return symbol.contains('Volume');
  2708. };
  2709.  
  2710. Window_Options.prototype.booleanStatusText = function(value) {
  2711. return value ? 'ON' : 'OFF';
  2712. };
  2713.  
  2714. Window_Options.prototype.volumeStatusText = function(value) {
  2715. return value + '%';
  2716. };
  2717.  
  2718. Window_Options.prototype.processOk = function() {
  2719. var index = this.index();
  2720. var symbol = this.commandSymbol(index);
  2721. var value = this.getConfigValue(symbol);
  2722. if (this.isVolumeSymbol(symbol)) {
  2723. value += this.volumeOffset();
  2724. if (value > 100) {
  2725. value = 0;
  2726. }
  2727. value = value.clamp(0, 100);
  2728. this.changeValue(symbol, value);
  2729. } else {
  2730. this.changeValue(symbol, !value);
  2731. }
  2732. };
  2733.  
  2734. Window_Options.prototype.cursorRight = function(wrap) {
  2735. var index = this.index();
  2736. var symbol = this.commandSymbol(index);
  2737. var value = this.getConfigValue(symbol);
  2738. if (this.isVolumeSymbol(symbol)) {
  2739. value += this.volumeOffset();
  2740. value = value.clamp(0, 100);
  2741. this.changeValue(symbol, value);
  2742. } else {
  2743. this.changeValue(symbol, true);
  2744. }
  2745. };
  2746.  
  2747. Window_Options.prototype.cursorLeft = function(wrap) {
  2748. var index = this.index();
  2749. var symbol = this.commandSymbol(index);
  2750. var value = this.getConfigValue(symbol);
  2751. if (this.isVolumeSymbol(symbol)) {
  2752. value -= this.volumeOffset();
  2753. value = value.clamp(0, 100);
  2754. this.changeValue(symbol, value);
  2755. } else {
  2756. this.changeValue(symbol, false);
  2757. }
  2758. };
  2759.  
  2760. Window_Options.prototype.volumeOffset = function() {
  2761. return 20;
  2762. };
  2763.  
  2764. Window_Options.prototype.changeValue = function(symbol, value) {
  2765. var lastValue = this.getConfigValue(symbol);
  2766. if (lastValue !== value) {
  2767. this.setConfigValue(symbol, value);
  2768. this.redrawItem(this.findSymbol(symbol));
  2769. SoundManager.playCursor();
  2770. }
  2771. };
  2772.  
  2773. Window_Options.prototype.getConfigValue = function(symbol) {
  2774. return ConfigManager[symbol];
  2775. };
  2776.  
  2777. Window_Options.prototype.setConfigValue = function(symbol, volume) {
  2778. ConfigManager[symbol] = volume;
  2779. };
  2780.  
  2781. //-----------------------------------------------------------------------------
  2782. // Window_SavefileList
  2783. //
  2784. // The window for selecting a save file on the save and load screens.
  2785.  
  2786. function Window_SavefileList() {
  2787. this.initialize.apply(this, arguments);
  2788. }
  2789.  
  2790. Window_SavefileList.prototype = Object.create(Window_Selectable.prototype);
  2791. Window_SavefileList.prototype.constructor = Window_SavefileList;
  2792.  
  2793. Window_SavefileList.prototype.initialize = function(x, y, width, height) {
  2794. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2795. this.activate();
  2796. this._mode = null;
  2797. };
  2798.  
  2799. Window_SavefileList.prototype.setMode = function(mode) {
  2800. this._mode = mode;
  2801. };
  2802.  
  2803. Window_SavefileList.prototype.maxItems = function() {
  2804. return DataManager.maxSavefiles();
  2805. };
  2806.  
  2807. Window_SavefileList.prototype.maxVisibleItems = function() {
  2808. return 5;
  2809. };
  2810.  
  2811. Window_SavefileList.prototype.itemHeight = function() {
  2812. var innerHeight = this.height - this.padding * 2;
  2813. return Math.floor(innerHeight / this.maxVisibleItems());
  2814. };
  2815.  
  2816. Window_SavefileList.prototype.drawItem = function(index) {
  2817. var id = index + 1;
  2818. var valid = DataManager.isThisGameFile(id);
  2819. var info = DataManager.loadSavefileInfo(id);
  2820. var rect = this.itemRectForText(index);
  2821. this.resetTextColor();
  2822. if (this._mode === 'load') {
  2823. this.changePaintOpacity(valid);
  2824. }
  2825. this.drawFileId(id, rect.x, rect.y);
  2826. if (info) {
  2827. this.changePaintOpacity(valid);
  2828. this.drawContents(info, rect, valid);
  2829. this.changePaintOpacity(true);
  2830. }
  2831. };
  2832.  
  2833. Window_SavefileList.prototype.drawFileId = function(id, x, y) {
  2834. this.drawText(TextManager.file + ' ' + id, x, y, 180);
  2835. };
  2836.  
  2837. Window_SavefileList.prototype.drawContents = function(info, rect, valid) {
  2838. var bottom = rect.y + rect.height;
  2839. if (rect.width >= 420) {
  2840. this.drawGameTitle(info, rect.x + 192, rect.y, rect.width - 192);
  2841. if (valid) {
  2842. this.drawPartyCharacters(info, rect.x + 220, bottom - 4);
  2843. }
  2844. }
  2845. var lineHeight = this.lineHeight();
  2846. var y2 = bottom - lineHeight;
  2847. if (y2 >= lineHeight) {
  2848. this.drawPlaytime(info, rect.x, y2, rect.width);
  2849. }
  2850. };
  2851.  
  2852. Window_SavefileList.prototype.drawGameTitle = function(info, x, y, width) {
  2853. if (info.title) {
  2854. this.drawText(info.title, x, y, width);
  2855. }
  2856. };
  2857.  
  2858. Window_SavefileList.prototype.drawPartyCharacters = function(info, x, y) {
  2859. if (info.characters) {
  2860. for (var i = 0; i < info.characters.length; i++) {
  2861. var data = info.characters[i];
  2862. this.drawCharacter(data[0], data[1], x + i * 48, y);
  2863. }
  2864. }
  2865. };
  2866.  
  2867. Window_SavefileList.prototype.drawPlaytime = function(info, x, y, width) {
  2868. if (info.playtime) {
  2869. this.drawText(info.playtime, x, y, width, 'right');
  2870. }
  2871. };
  2872.  
  2873. Window_SavefileList.prototype.playOkSound = function() {
  2874. };
  2875.  
  2876. //-----------------------------------------------------------------------------
  2877. // Window_ShopCommand
  2878. //
  2879. // The window for selecting buy/sell on the shop screen.
  2880.  
  2881. function Window_ShopCommand() {
  2882. this.initialize.apply(this, arguments);
  2883. }
  2884.  
  2885. Window_ShopCommand.prototype = Object.create(Window_HorzCommand.prototype);
  2886. Window_ShopCommand.prototype.constructor = Window_ShopCommand;
  2887.  
  2888. Window_ShopCommand.prototype.initialize = function(width, purchaseOnly) {
  2889. this._windowWidth = width;
  2890. this._purchaseOnly = purchaseOnly;
  2891. Window_HorzCommand.prototype.initialize.call(this, 0, 0);
  2892. };
  2893.  
  2894. Window_ShopCommand.prototype.windowWidth = function() {
  2895. return this._windowWidth;
  2896. };
  2897.  
  2898. Window_ShopCommand.prototype.maxCols = function() {
  2899. return 3;
  2900. };
  2901.  
  2902. Window_ShopCommand.prototype.makeCommandList = function() {
  2903. this.addCommand(TextManager.buy, 'buy');
  2904. this.addCommand(TextManager.sell, 'sell', !this._purchaseOnly);
  2905. this.addCommand(TextManager.cancel, 'cancel');
  2906. };
  2907.  
  2908. //-----------------------------------------------------------------------------
  2909. // Window_ShopBuy
  2910. //
  2911. // The window for selecting an item to buy on the shop screen.
  2912.  
  2913. function Window_ShopBuy() {
  2914. this.initialize.apply(this, arguments);
  2915. }
  2916.  
  2917. Window_ShopBuy.prototype = Object.create(Window_Selectable.prototype);
  2918. Window_ShopBuy.prototype.constructor = Window_ShopBuy;
  2919.  
  2920. Window_ShopBuy.prototype.initialize = function(x, y, height, shopGoods) {
  2921. var width = this.windowWidth();
  2922. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2923. this._shopGoods = shopGoods;
  2924. this._money = 0;
  2925. this.refresh();
  2926. this.select(0);
  2927. };
  2928.  
  2929. Window_ShopBuy.prototype.windowWidth = function() {
  2930. return 456;
  2931. };
  2932.  
  2933. Window_ShopBuy.prototype.maxItems = function() {
  2934. return this._data ? this._data.length : 1;
  2935. };
  2936.  
  2937. Window_ShopBuy.prototype.item = function() {
  2938. return this._data[this.index()];
  2939. };
  2940.  
  2941. Window_ShopBuy.prototype.setMoney = function(money) {
  2942. this._money = money;
  2943. this.refresh();
  2944. };
  2945.  
  2946. Window_ShopBuy.prototype.isCurrentItemEnabled = function() {
  2947. return this.isEnabled(this._data[this.index()]);
  2948. };
  2949.  
  2950. Window_ShopBuy.prototype.price = function(item) {
  2951. return this._price[this._data.indexOf(item)] || 0;
  2952. };
  2953.  
  2954. Window_ShopBuy.prototype.isEnabled = function(item) {
  2955. return (item && this.price(item) <= this._money &&
  2956. !$gameParty.hasMaxItems(item));
  2957. };
  2958.  
  2959. Window_ShopBuy.prototype.refresh = function() {
  2960. this.makeItemList();
  2961. this.createContents();
  2962. this.drawAllItems();
  2963. };
  2964.  
  2965. Window_ShopBuy.prototype.makeItemList = function() {
  2966. this._data = [];
  2967. this._price = [];
  2968. this._shopGoods.forEach(function(goods) {
  2969. var item = null;
  2970. switch (goods[0]) {
  2971. case 0:
  2972. item = $dataItems[goods[1]];
  2973. break;
  2974. case 1:
  2975. item = $dataWeapons[goods[1]];
  2976. break;
  2977. case 2:
  2978. item = $dataArmors[goods[1]];
  2979. break;
  2980. }
  2981. if (item) {
  2982. this._data.push(item);
  2983. this._price.push(goods[2] === 0 ? item.price : goods[3]);
  2984. }
  2985. }, this);
  2986. };
  2987.  
  2988. Window_ShopBuy.prototype.drawItem = function(index) {
  2989. var item = this._data[index];
  2990. var rect = this.itemRect(index);
  2991. var priceWidth = 96;
  2992. rect.width -= this.textPadding();
  2993. this.changePaintOpacity(this.isEnabled(item));
  2994. this.drawItemName(item, rect.x, rect.y, rect.width - priceWidth);
  2995. this.drawText(this.price(item), rect.x + rect.width - priceWidth,
  2996. rect.y, priceWidth, 'right');
  2997. this.changePaintOpacity(true);
  2998. };
  2999.  
  3000. Window_ShopBuy.prototype.setStatusWindow = function(statusWindow) {
  3001. this._statusWindow = statusWindow;
  3002. this.callUpdateHelp();
  3003. };
  3004.  
  3005. Window_ShopBuy.prototype.updateHelp = function() {
  3006. this.setHelpWindowItem(this.item());
  3007. if (this._statusWindow) {
  3008. this._statusWindow.setItem(this.item());
  3009. }
  3010. };
  3011.  
  3012. //-----------------------------------------------------------------------------
  3013. // Window_ShopSell
  3014. //
  3015. // The window for selecting an item to sell on the shop screen.
  3016.  
  3017. function Window_ShopSell() {
  3018. this.initialize.apply(this, arguments);
  3019. }
  3020.  
  3021. Window_ShopSell.prototype = Object.create(Window_ItemList.prototype);
  3022. Window_ShopSell.prototype.constructor = Window_ShopSell;
  3023.  
  3024. Window_ShopSell.prototype.initialize = function(x, y, width, height) {
  3025. Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  3026. };
  3027.  
  3028. Window_ShopSell.prototype.isEnabled = function(item) {
  3029. return item && item.price > 0;
  3030. };
  3031.  
  3032. //-----------------------------------------------------------------------------
  3033. // Window_ShopNumber
  3034. //
  3035. // The window for inputting quantity of items to buy or sell on the shop
  3036. // screen.
  3037.  
  3038. function Window_ShopNumber() {
  3039. this.initialize.apply(this, arguments);
  3040. }
  3041.  
  3042. Window_ShopNumber.prototype = Object.create(Window_Selectable.prototype);
  3043. Window_ShopNumber.prototype.constructor = Window_ShopNumber;
  3044.  
  3045. Window_ShopNumber.prototype.initialize = function(x, y, height) {
  3046. var width = this.windowWidth();
  3047. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  3048. this._item = null;
  3049. this._max = 1;
  3050. this._price = 0;
  3051. this._number = 1;
  3052. this._currencyUnit = TextManager.currencyUnit;
  3053. this.createButtons();
  3054. };
  3055.  
  3056. Window_ShopNumber.prototype.windowWidth = function() {
  3057. return 456;
  3058. };
  3059.  
  3060. Window_ShopNumber.prototype.number = function() {
  3061. return this._number;
  3062. };
  3063.  
  3064. Window_ShopNumber.prototype.setup = function(item, max, price) {
  3065. this._item = item;
  3066. this._max = Math.floor(max);
  3067. this._price = price;
  3068. this._number = 1;
  3069. this.placeButtons();
  3070. this.updateButtonsVisiblity();
  3071. this.refresh();
  3072. };
  3073.  
  3074. Window_ShopNumber.prototype.setCurrencyUnit = function(currencyUnit) {
  3075. this._currencyUnit = currencyUnit;
  3076. this.refresh();
  3077. };
  3078.  
  3079. Window_ShopNumber.prototype.createButtons = function() {
  3080. var bitmap = ImageManager.loadSystem('ButtonSet');
  3081. var buttonWidth = 48;
  3082. var buttonHeight = 48;
  3083. this._buttons = [];
  3084. for (var i = 0; i < 5; i++) {
  3085. var button = new Sprite_Button();
  3086. var x = buttonWidth * i;
  3087. var w = buttonWidth * (i === 4 ? 2 : 1);
  3088. button.bitmap = bitmap;
  3089. button.setColdFrame(x, 0, w, buttonHeight);
  3090. button.setHotFrame(x, buttonHeight, w, buttonHeight);
  3091. button.visible = false;
  3092. this._buttons.push(button);
  3093. this.addChild(button);
  3094. }
  3095. this._buttons[0].setClickHandler(this.onButtonDown2.bind(this));
  3096. this._buttons[1].setClickHandler(this.onButtonDown.bind(this));
  3097. this._buttons[2].setClickHandler(this.onButtonUp.bind(this));
  3098. this._buttons[3].setClickHandler(this.onButtonUp2.bind(this));
  3099. this._buttons[4].setClickHandler(this.onButtonOk.bind(this));
  3100. };
  3101.  
  3102. Window_ShopNumber.prototype.placeButtons = function() {
  3103. var numButtons = this._buttons.length;
  3104. var spacing = 16;
  3105. var totalWidth = -spacing;
  3106. for (var i = 0; i < numButtons; i++) {
  3107. totalWidth += this._buttons[i].width + spacing;
  3108. }
  3109. var x = (this.width - totalWidth) / 2;
  3110. for (var j = 0; j < numButtons; j++) {
  3111. var button = this._buttons[j];
  3112. button.x = x;
  3113. button.y = this.buttonY();
  3114. x += button.width + spacing;
  3115. }
  3116. };
  3117.  
  3118. Window_ShopNumber.prototype.updateButtonsVisiblity = function() {
  3119. if (TouchInput.date > Input.date) {
  3120. this.showButtons();
  3121. } else {
  3122. this.hideButtons();
  3123. }
  3124. };
  3125.  
  3126. Window_ShopNumber.prototype.showButtons = function() {
  3127. for (var i = 0; i < this._buttons.length; i++) {
  3128. this._buttons[i].visible = true;
  3129. }
  3130. };
  3131.  
  3132. Window_ShopNumber.prototype.hideButtons = function() {
  3133. for (var i = 0; i < this._buttons.length; i++) {
  3134. this._buttons[i].visible = false;
  3135. }
  3136. };
  3137.  
  3138. Window_ShopNumber.prototype.refresh = function() {
  3139. this.contents.clear();
  3140. this.drawItemName(this._item, 0, this.itemY());
  3141. this.drawMultiplicationSign();
  3142. this.drawNumber();
  3143. this.drawTotalPrice();
  3144. };
  3145.  
  3146. Window_ShopNumber.prototype.drawMultiplicationSign = function() {
  3147. var sign = '\u00d7';
  3148. var width = this.textWidth(sign);
  3149. var x = this.cursorX() - width * 2;
  3150. var y = this.itemY();
  3151. this.resetTextColor();
  3152. this.drawText(sign, x, y, width);
  3153. };
  3154.  
  3155. Window_ShopNumber.prototype.drawNumber = function() {
  3156. var x = this.cursorX();
  3157. var y = this.itemY();
  3158. var width = this.cursorWidth() - this.textPadding();
  3159. this.resetTextColor();
  3160. this.drawText(this._number, x, y, width, 'right');
  3161. };
  3162.  
  3163. Window_ShopNumber.prototype.drawTotalPrice = function() {
  3164. var total = this._price * this._number;
  3165. var width = this.contentsWidth() - this.textPadding();
  3166. this.drawCurrencyValue(total, this._currencyUnit, 0, this.priceY(), width);
  3167. };
  3168.  
  3169. Window_ShopNumber.prototype.itemY = function() {
  3170. return Math.round(this.contentsHeight() / 2 - this.lineHeight() * 1.5);
  3171. };
  3172.  
  3173. Window_ShopNumber.prototype.priceY = function() {
  3174. return Math.round(this.contentsHeight() / 2 + this.lineHeight() / 2);
  3175. };
  3176.  
  3177. Window_ShopNumber.prototype.buttonY = function() {
  3178. return Math.round(this.priceY() + this.lineHeight() * 2.5);
  3179. };
  3180.  
  3181. Window_ShopNumber.prototype.cursorWidth = function() {
  3182. var digitWidth = this.textWidth('0');
  3183. return this.maxDigits() * digitWidth + this.textPadding() * 2;
  3184. };
  3185.  
  3186. Window_ShopNumber.prototype.cursorX = function() {
  3187. return this.contentsWidth() - this.cursorWidth() - this.textPadding();
  3188. };
  3189.  
  3190. Window_ShopNumber.prototype.maxDigits = function() {
  3191. return 2;
  3192. };
  3193.  
  3194. Window_ShopNumber.prototype.update = function() {
  3195. Window_Selectable.prototype.update.call(this);
  3196. this.processNumberChange();
  3197. };
  3198.  
  3199. Window_ShopNumber.prototype.isOkTriggered = function() {
  3200. return Input.isTriggered('ok');
  3201. };
  3202.  
  3203. Window_ShopNumber.prototype.playOkSound = function() {
  3204. };
  3205.  
  3206. Window_ShopNumber.prototype.processNumberChange = function() {
  3207. if (this.isOpenAndActive()) {
  3208. if (Input.isRepeated('right')) {
  3209. this.changeNumber(1);
  3210. }
  3211. if (Input.isRepeated('left')) {
  3212. this.changeNumber(-1);
  3213. }
  3214. if (Input.isRepeated('up')) {
  3215. this.changeNumber(10);
  3216. }
  3217. if (Input.isRepeated('down')) {
  3218. this.changeNumber(-10);
  3219. }
  3220. }
  3221. };
  3222.  
  3223. Window_ShopNumber.prototype.changeNumber = function(amount) {
  3224. var lastNumber = this._number;
  3225. this._number = (this._number + amount).clamp(1, this._max);
  3226. if (this._number !== lastNumber) {
  3227. SoundManager.playCursor();
  3228. this.refresh();
  3229. }
  3230. };
  3231.  
  3232. Window_ShopNumber.prototype.updateCursor = function() {
  3233. this.setCursorRect(this.cursorX(), this.itemY(),
  3234. this.cursorWidth(), this.lineHeight());
  3235. };
  3236.  
  3237. Window_ShopNumber.prototype.onButtonUp = function() {
  3238. this.changeNumber(1);
  3239. };
  3240.  
  3241. Window_ShopNumber.prototype.onButtonUp2 = function() {
  3242. this.changeNumber(10);
  3243. };
  3244.  
  3245. Window_ShopNumber.prototype.onButtonDown = function() {
  3246. this.changeNumber(-1);
  3247. };
  3248.  
  3249. Window_ShopNumber.prototype.onButtonDown2 = function() {
  3250. this.changeNumber(-10);
  3251. };
  3252.  
  3253. Window_ShopNumber.prototype.onButtonOk = function() {
  3254. this.processOk();
  3255. };
  3256.  
  3257. //-----------------------------------------------------------------------------
  3258. // Window_ShopStatus
  3259. //
  3260. // The window for displaying number of items in possession and the actor's
  3261. // equipment on the shop screen.
  3262.  
  3263. function Window_ShopStatus() {
  3264. this.initialize.apply(this, arguments);
  3265. }
  3266.  
  3267. Window_ShopStatus.prototype = Object.create(Window_Base.prototype);
  3268. Window_ShopStatus.prototype.constructor = Window_ShopStatus;
  3269.  
  3270. Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
  3271. Window_Base.prototype.initialize.call(this, x, y, width, height);
  3272. this._item = null;
  3273. this._pageIndex = 0;
  3274. this.refresh();
  3275. };
  3276.  
  3277. Window_ShopStatus.prototype.refresh = function() {
  3278. this.contents.clear();
  3279. if (this._item) {
  3280. var x = this.textPadding();
  3281. this.drawPossession(x, 0);
  3282. if (this.isEquipItem()) {
  3283. this.drawEquipInfo(x, this.lineHeight() * 2);
  3284. }
  3285. }
  3286. };
  3287.  
  3288. Window_ShopStatus.prototype.setItem = function(item) {
  3289. this._item = item;
  3290. this.refresh();
  3291. };
  3292.  
  3293. Window_ShopStatus.prototype.isEquipItem = function() {
  3294. return DataManager.isWeapon(this._item) || DataManager.isArmor(this._item);
  3295. };
  3296.  
  3297. Window_ShopStatus.prototype.drawPossession = function(x, y) {
  3298. var width = this.contents.width - this.textPadding() - x;
  3299. var possessionWidth = this.textWidth('0000');
  3300. this.changeTextColor(this.systemColor());
  3301. this.drawText(TextManager.possession, x, y, width - possessionWidth);
  3302. this.resetTextColor();
  3303. this.drawText($gameParty.numItems(this._item), x, y, width, 'right');
  3304. };
  3305.  
  3306. Window_ShopStatus.prototype.drawEquipInfo = function(x, y) {
  3307. var members = this.statusMembers();
  3308. for (var i = 0; i < members.length; i++) {
  3309. this.drawActorEquipInfo(x, y + this.lineHeight() * (i * 2.4), members[i]);
  3310. }
  3311. };
  3312.  
  3313. Window_ShopStatus.prototype.statusMembers = function() {
  3314. var start = this._pageIndex * this.pageSize();
  3315. var end = start + this.pageSize();
  3316. return $gameParty.members().slice(start, end);
  3317. };
  3318.  
  3319. Window_ShopStatus.prototype.pageSize = function() {
  3320. return 4;
  3321. };
  3322.  
  3323. Window_ShopStatus.prototype.maxPages = function() {
  3324. return Math.floor(($gameParty.size() + this.pageSize() - 1) / this.pageSize());
  3325. };
  3326.  
  3327. Window_ShopStatus.prototype.drawActorEquipInfo = function(x, y, actor) {
  3328. var enabled = actor.canEquip(this._item);
  3329. this.changePaintOpacity(enabled);
  3330. this.resetTextColor();
  3331. this.drawText(actor.name(), x, y, 168);
  3332. var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  3333. if (enabled) {
  3334. this.drawActorParamChange(x, y, actor, item1);
  3335. }
  3336. this.drawItemName(item1, x, y + this.lineHeight());
  3337. this.changePaintOpacity(true);
  3338. };
  3339.  
  3340. Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1) {
  3341. var width = this.contents.width - this.textPadding() - x;
  3342. var paramId = this.paramId();
  3343. var change = this._item.params[paramId] - (item1 ? item1.params[paramId] : 0);
  3344. this.changeTextColor(this.paramchangeTextColor(change));
  3345. this.drawText((change > 0 ? '+' : '') + change, x, y, width, 'right');
  3346. };
  3347.  
  3348. Window_ShopStatus.prototype.paramId = function() {
  3349. return DataManager.isWeapon(this._item) ? 2 : 3;
  3350. };
  3351.  
  3352. Window_ShopStatus.prototype.currentEquippedItem = function(actor, etypeId) {
  3353. var list = [];
  3354. var equips = actor.equips();
  3355. var slots = actor.equipSlots();
  3356. for (var i = 0; i < slots.length; i++) {
  3357. if (slots[i] === etypeId) {
  3358. list.push(equips[i]);
  3359. }
  3360. }
  3361. var paramId = this.paramId();
  3362. var worstParam = Number.MAX_VALUE;
  3363. var worstItem = null;
  3364. for (var j = 0; j < list.length; j++) {
  3365. if (list[j] && list[j].params[paramId] < worstParam) {
  3366. worstParam = list[j].params[paramId];
  3367. worstItem = list[j];
  3368. }
  3369. }
  3370. return worstItem;
  3371. };
  3372.  
  3373. Window_ShopStatus.prototype.update = function() {
  3374. Window_Base.prototype.update.call(this);
  3375. this.updatePage();
  3376. };
  3377.  
  3378. Window_ShopStatus.prototype.updatePage = function() {
  3379. if (this.isPageChangeEnabled() && this.isPageChangeRequested()) {
  3380. this.changePage();
  3381. }
  3382. };
  3383.  
  3384. Window_ShopStatus.prototype.isPageChangeEnabled = function() {
  3385. return this.visible && this.maxPages() >= 2;
  3386. };
  3387.  
  3388. Window_ShopStatus.prototype.isPageChangeRequested = function() {
  3389. if (Input.isTriggered('shift')) {
  3390. return true;
  3391. }
  3392. if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  3393. return true;
  3394. }
  3395. return false;
  3396. };
  3397.  
  3398. Window_ShopStatus.prototype.isTouchedInsideFrame = function() {
  3399. var x = this.canvasToLocalX(TouchInput.x);
  3400. var y = this.canvasToLocalY(TouchInput.y);
  3401. return x >= 0 && y >= 0 && x < this.width && y < this.height;
  3402. };
  3403.  
  3404. Window_ShopStatus.prototype.changePage = function() {
  3405. this._pageIndex = (this._pageIndex + 1) % this.maxPages();
  3406. this.refresh();
  3407. SoundManager.playCursor();
  3408. };
  3409.  
  3410. //-----------------------------------------------------------------------------
  3411. // Window_NameEdit
  3412. //
  3413. // The window for editing an actor's name on the name input screen.
  3414.  
  3415. function Window_NameEdit() {
  3416. this.initialize.apply(this, arguments);
  3417. }
  3418.  
  3419. Window_NameEdit.prototype = Object.create(Window_Base.prototype);
  3420. Window_NameEdit.prototype.constructor = Window_NameEdit;
  3421.  
  3422. Window_NameEdit.prototype.initialize = function(actor, maxLength) {
  3423. var width = this.windowWidth();
  3424. var height = this.windowHeight();
  3425. var x = (Graphics.boxWidth - width) / 2;
  3426. var y = (Graphics.boxHeight - (height + this.fittingHeight(9) + 8)) / 2;
  3427. Window_Base.prototype.initialize.call(this, x, y, width, height);
  3428. this._actor = actor;
  3429. this._name = actor.name().slice(0, this._maxLength);
  3430. this._index = this._name.length;
  3431. this._maxLength = maxLength;
  3432. this._defaultName = this._name;
  3433. this.deactivate();
  3434. this.refresh();
  3435. ImageManager.loadFace(actor.faceName());
  3436. };
  3437.  
  3438. Window_NameEdit.prototype.windowWidth = function() {
  3439. return 480;
  3440. };
  3441.  
  3442. Window_NameEdit.prototype.windowHeight = function() {
  3443. return this.fittingHeight(4);
  3444. };
  3445.  
  3446. Window_NameEdit.prototype.name = function() {
  3447. return this._name;
  3448. };
  3449.  
  3450. Window_NameEdit.prototype.restoreDefault = function() {
  3451. this._name = this._defaultName;
  3452. this._index = this._name.length;
  3453. this.refresh();
  3454. return this._name.length > 0;
  3455. };
  3456.  
  3457. Window_NameEdit.prototype.add = function(ch) {
  3458. if (this._index < this._maxLength) {
  3459. this._name += ch;
  3460. this._index++;
  3461. this.refresh();
  3462. return true;
  3463. } else {
  3464. return false;
  3465. }
  3466. };
  3467.  
  3468. Window_NameEdit.prototype.back = function() {
  3469. if (this._index > 0) {
  3470. this._index--;
  3471. this._name = this._name.slice(0, this._index);
  3472. this.refresh();
  3473. return true;
  3474. } else {
  3475. return false;
  3476. }
  3477. };
  3478.  
  3479. Window_NameEdit.prototype.faceWidth = function() {
  3480. return 144;
  3481. };
  3482.  
  3483. Window_NameEdit.prototype.charWidth = function() {
  3484. var text = $gameSystem.isJapanese() ? '\uff21' : 'A';
  3485. return this.textWidth(text);
  3486. };
  3487.  
  3488. Window_NameEdit.prototype.left = function() {
  3489. var nameCenter = (this.contentsWidth() + this.faceWidth()) / 2;
  3490. var nameWidth = (this._maxLength + 1) * this.charWidth();
  3491. return Math.min(nameCenter - nameWidth / 2, this.contentsWidth() - nameWidth);
  3492. };
  3493.  
  3494. Window_NameEdit.prototype.itemRect = function(index) {
  3495. return {
  3496. x: this.left() + index * this.charWidth(),
  3497. y: 54,
  3498. width: this.charWidth(),
  3499. height: this.lineHeight()
  3500. };
  3501. };
  3502.  
  3503. Window_NameEdit.prototype.underlineRect = function(index) {
  3504. var rect = this.itemRect(index);
  3505. rect.x++;
  3506. rect.y += rect.height - 4;
  3507. rect.width -= 2;
  3508. rect.height = 2;
  3509. return rect;
  3510. };
  3511.  
  3512. Window_NameEdit.prototype.underlineColor = function() {
  3513. return this.normalColor();
  3514. };
  3515.  
  3516. Window_NameEdit.prototype.drawUnderline = function(index) {
  3517. var rect = this.underlineRect(index);
  3518. var color = this.underlineColor();
  3519. this.contents.paintOpacity = 48;
  3520. this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  3521. this.contents.paintOpacity = 255;
  3522. };
  3523.  
  3524. Window_NameEdit.prototype.drawChar = function(index) {
  3525. var rect = this.itemRect(index);
  3526. this.resetTextColor();
  3527. this.drawText(this._name[index] || '', rect.x, rect.y);
  3528. };
  3529.  
  3530. Window_NameEdit.prototype.refresh = function() {
  3531. this.contents.clear();
  3532. this.drawActorFace(this._actor, 0, 0);
  3533. for (var i = 0; i < this._maxLength; i++) {
  3534. this.drawUnderline(i);
  3535. }
  3536. for (var j = 0; j < this._name.length; j++) {
  3537. this.drawChar(j);
  3538. }
  3539. var rect = this.itemRect(this._index);
  3540. this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  3541. };
  3542.  
  3543. //-----------------------------------------------------------------------------
  3544. // Window_NameInput
  3545. //
  3546. // The window for selecting text characters on the name input screen.
  3547.  
  3548. function Window_NameInput() {
  3549. this.initialize.apply(this, arguments);
  3550. }
  3551.  
  3552. Window_NameInput.prototype = Object.create(Window_Selectable.prototype);
  3553. Window_NameInput.prototype.constructor = Window_NameInput;
  3554. Window_NameInput.LATIN1 =
  3555. [ 'A','B','C','D','E', 'a','b','c','d','e',
  3556. 'F','G','H','I','J', 'f','g','h','i','j',
  3557. 'K','L','M','N','O', 'k','l','m','n','o',
  3558. 'P','Q','R','S','T', 'p','q','r','s','t',
  3559. 'U','V','W','X','Y', 'u','v','w','x','y',
  3560. 'Z','[',']','^','_', 'z','{','}','|','~',
  3561. '0','1','2','3','4', '!','#','$','%','&',
  3562. '5','6','7','8','9', '(',')','*','+','-',
  3563. '/','=','@','<','>', ':',';',' ','Page','OK' ];
  3564. Window_NameInput.LATIN2 =
  3565. [ 'Á','É','Í','Ó','Ú', 'á','é','í','ó','ú',
  3566. 'À','È','Ì','Ò','Ù', 'à','è','ì','ò','ù',
  3567. 'Â','Ê','Î','Ô','Û', 'â','ê','î','ô','û',
  3568. 'Ä','Ë','Ï','Ö','Ü', 'ä','ë','ï','ö','ü',
  3569. 'Ā','Ē','Ī','Ō','Ū', 'ā','ē','ī','ō','ū',
  3570. 'Ã','Å','Æ','Ç','Ð', 'ã','å','æ','ç','ð',
  3571. 'Ñ','Õ','Ø','Š','Ŵ', 'ñ','õ','ø','š','ŵ',
  3572. 'Ý','Ŷ','Ÿ','Ž','Þ', 'ý','ÿ','ŷ','ž','þ',
  3573. 'IJ','Œ','ij','œ','ß', '«','»',' ','Page','OK' ];
  3574. Window_NameInput.RUSSIA =
  3575. [ 'А','Б','В','Г','Д', 'а','б','в','г','д',
  3576. 'Е','Ё','Ж','З','И', 'е','ё','ж','з','и',
  3577. 'Й','К','Л','М','Н', 'й','к','л','м','н',
  3578. 'О','П','Р','С','Т', 'о','п','р','с','т',
  3579. 'У','Ф','Х','Ц','Ч', 'у','ф','х','ц','ч',
  3580. 'Ш','Щ','Ъ','Ы','Ь', 'ш','щ','ъ','ы','ь',
  3581. 'Э','Ю','Я','^','_', 'э','ю','я','%','&',
  3582. '0','1','2','3','4', '(',')','*','+','-',
  3583. '5','6','7','8','9', ':',';',' ','','OK' ];
  3584. Window_NameInput.JAPAN1 =
  3585. [ 'あ','い','う','え','お', 'が','ぎ','ぐ','げ','ご',
  3586. 'か','き','く','け','こ', 'ざ','じ','ず','ぜ','ぞ',
  3587. 'さ','し','す','せ','そ', 'だ','ぢ','づ','で','ど',
  3588. 'た','ち','つ','て','と', 'ば','び','ぶ','べ','ぼ',
  3589. 'な','に','ぬ','ね','の', 'ぱ','ぴ','ぷ','ぺ','ぽ',
  3590. 'は','ひ','ふ','へ','ほ', 'ぁ','ぃ','ぅ','ぇ','ぉ',
  3591. 'ま','み','む','め','も', 'っ','ゃ','ゅ','ょ','ゎ',
  3592. 'や','ゆ','よ','わ','ん', 'ー','~','・','=','☆',
  3593. 'ら','り','る','れ','ろ', 'ゔ','を',' ','カナ','決定' ];
  3594. Window_NameInput.JAPAN2 =
  3595. [ 'ア','イ','ウ','エ','オ', 'ガ','ギ','グ','ゲ','ゴ',
  3596. 'カ','キ','ク','ケ','コ', 'ザ','ジ','ズ','ゼ','ゾ',
  3597. 'サ','シ','ス','セ','ソ', 'ダ','ヂ','ヅ','デ','ド',
  3598. 'タ','チ','ツ','テ','ト', 'バ','ビ','ブ','ベ','ボ',
  3599. 'ナ','ニ','ヌ','ネ','ノ', 'パ','ピ','プ','ペ','ポ',
  3600. 'ハ','ヒ','フ','ヘ','ホ', 'ァ','ィ','ゥ','ェ','ォ',
  3601. 'マ','ミ','ム','メ','モ', 'ッ','ャ','ュ','ョ','ヮ',
  3602. 'ヤ','ユ','ヨ','ワ','ン', 'ー','~','・','=','☆',
  3603. 'ラ','リ','ル','レ','ロ', 'ヴ','ヲ',' ','英数','決定' ];
  3604. Window_NameInput.JAPAN3 =
  3605. [ 'A','B','C','D','E', 'a','b','c','d','e',
  3606. 'F','G','H','I','J', 'f','g','h','i','j',
  3607. 'K','L','M','N','O', 'k','l','m','n','o',
  3608. 'P','Q','R','S','T', 'p','q','r','s','t',
  3609. 'U','V','W','X','Y', 'u','v','w','x','y',
  3610. 'Z','[',']','^','_', 'z','{','}','|','~',
  3611. '0','1','2','3','4', '!','#','$','%','&',
  3612. '5','6','7','8','9', '(',')','*','+','-',
  3613. '/','=','@','<','>', ':',';',' ','かな','決定' ];
  3614.  
  3615. Window_NameInput.prototype.initialize = function(editWindow) {
  3616. var x = editWindow.x;
  3617. var y = editWindow.y + editWindow.height + 8;
  3618. var width = editWindow.width;
  3619. var height = this.windowHeight();
  3620. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  3621. this._editWindow = editWindow;
  3622. this._page = 0;
  3623. this._index = 0;
  3624. this.refresh();
  3625. this.updateCursor();
  3626. this.activate();
  3627. };
  3628.  
  3629. Window_NameInput.prototype.windowHeight = function() {
  3630. return this.fittingHeight(9);
  3631. };
  3632.  
  3633. Window_NameInput.prototype.table = function() {
  3634. if ($gameSystem.isJapanese()) {
  3635. return [Window_NameInput.JAPAN1,
  3636. Window_NameInput.JAPAN2,
  3637. Window_NameInput.JAPAN3];
  3638. } else if ($gameSystem.isRussian()) {
  3639. return [Window_NameInput.RUSSIA];
  3640. } else {
  3641. return [Window_NameInput.LATIN1,
  3642. Window_NameInput.LATIN2];
  3643. }
  3644. };
  3645.  
  3646. Window_NameInput.prototype.maxCols = function() {
  3647. return 10;
  3648. };
  3649.  
  3650. Window_NameInput.prototype.maxItems = function() {
  3651. return 90;
  3652. };
  3653.  
  3654. Window_NameInput.prototype.character = function() {
  3655. return this._index < 88 ? this.table()[this._page][this._index] : '';
  3656. };
  3657.  
  3658. Window_NameInput.prototype.isPageChange = function() {
  3659. return this._index === 88;
  3660. };
  3661.  
  3662. Window_NameInput.prototype.isOk = function() {
  3663. return this._index === 89;
  3664. };
  3665.  
  3666. Window_NameInput.prototype.itemRect = function(index) {
  3667. return {
  3668. x: index % 10 * 42 + Math.floor(index % 10 / 5) * 24,
  3669. y: Math.floor(index / 10) * this.lineHeight(),
  3670. width: 42,
  3671. height: this.lineHeight()
  3672. };
  3673. };
  3674.  
  3675. Window_NameInput.prototype.refresh = function() {
  3676. var table = this.table();
  3677. this.contents.clear();
  3678. this.resetTextColor();
  3679. for (var i = 0; i < 90; i++) {
  3680. var rect = this.itemRect(i);
  3681. rect.x += 3;
  3682. rect.width -= 6;
  3683. this.drawText(table[this._page][i], rect.x, rect.y, rect.width, 'center');
  3684. }
  3685. };
  3686.  
  3687. Window_NameInput.prototype.updateCursor = function() {
  3688. var rect = this.itemRect(this._index);
  3689. this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
  3690. };
  3691.  
  3692. Window_NameInput.prototype.isCursorMovable = function() {
  3693. return this.active;
  3694. };
  3695.  
  3696. Window_NameInput.prototype.cursorDown = function(wrap) {
  3697. if (this._index < 80 || wrap) {
  3698. this._index = (this._index + 10) % 90;
  3699. }
  3700. };
  3701.  
  3702. Window_NameInput.prototype.cursorUp = function(wrap) {
  3703. if (this._index >= 10 || wrap) {
  3704. this._index = (this._index + 80) % 90;
  3705. }
  3706. };
  3707.  
  3708. Window_NameInput.prototype.cursorRight = function(wrap) {
  3709. if (this._index % 10 < 9) {
  3710. this._index++;
  3711. } else if (wrap) {
  3712. this._index -= 9;
  3713. }
  3714. };
  3715.  
  3716. Window_NameInput.prototype.cursorLeft = function(wrap) {
  3717. if (this._index % 10 > 0) {
  3718. this._index--;
  3719. } else if (wrap) {
  3720. this._index += 9;
  3721. }
  3722. };
  3723.  
  3724. Window_NameInput.prototype.cursorPagedown = function() {
  3725. this._page = (this._page + 1) % this.table().length;
  3726. this.refresh();
  3727. };
  3728.  
  3729. Window_NameInput.prototype.cursorPageup = function() {
  3730. this._page = (this._page + this.table().length - 1) % this.table().length;
  3731. this.refresh();
  3732. };
  3733.  
  3734. Window_NameInput.prototype.processCursorMove = function() {
  3735. var lastPage = this._page;
  3736. Window_Selectable.prototype.processCursorMove.call(this);
  3737. this.updateCursor();
  3738. if (this._page !== lastPage) {
  3739. SoundManager.playCursor();
  3740. }
  3741. };
  3742.  
  3743. Window_NameInput.prototype.processHandling = function() {
  3744. if (this.isOpen() && this.active) {
  3745. if (Input.isTriggered('shift')) {
  3746. this.processJump();
  3747. }
  3748. if (Input.isRepeated('cancel')) {
  3749. this.processBack();
  3750. }
  3751. if (Input.isRepeated('ok')) {
  3752. this.processOk();
  3753. }
  3754. }
  3755. };
  3756.  
  3757. Window_NameInput.prototype.isCancelEnabled = function() {
  3758. return true;
  3759. };
  3760.  
  3761. Window_NameInput.prototype.processCancel = function() {
  3762. this.processBack();
  3763. };
  3764.  
  3765. Window_NameInput.prototype.processJump = function() {
  3766. if (this._index !== 89) {
  3767. this._index = 89;
  3768. SoundManager.playCursor();
  3769. }
  3770. };
  3771.  
  3772. Window_NameInput.prototype.processBack = function() {
  3773. if (this._editWindow.back()) {
  3774. SoundManager.playCancel();
  3775. }
  3776. };
  3777.  
  3778. Window_NameInput.prototype.processOk = function() {
  3779. if (this.character()) {
  3780. this.onNameAdd();
  3781. } else if (this.isPageChange()) {
  3782. SoundManager.playOk();
  3783. this.cursorPagedown();
  3784. } else if (this.isOk()) {
  3785. this.onNameOk();
  3786. }
  3787. };
  3788.  
  3789. Window_NameInput.prototype.onNameAdd = function() {
  3790. if (this._editWindow.add(this.character())) {
  3791. SoundManager.playOk();
  3792. } else {
  3793. SoundManager.playBuzzer();
  3794. }
  3795. };
  3796.  
  3797. Window_NameInput.prototype.onNameOk = function() {
  3798. if (this._editWindow.name() === '') {
  3799. if (this._editWindow.restoreDefault()) {
  3800. SoundManager.playOk();
  3801. } else {
  3802. SoundManager.playBuzzer();
  3803. }
  3804. } else {
  3805. SoundManager.playOk();
  3806. this.callOkHandler();
  3807. }
  3808. };
  3809.  
  3810. //-----------------------------------------------------------------------------
  3811. // Window_ChoiceList
  3812. //
  3813. // The window used for the event command [Show Choices].
  3814.  
  3815. function Window_ChoiceList() {
  3816. this.initialize.apply(this, arguments);
  3817. }
  3818.  
  3819. Window_ChoiceList.prototype = Object.create(Window_Command.prototype);
  3820. Window_ChoiceList.prototype.constructor = Window_ChoiceList;
  3821.  
  3822. Window_ChoiceList.prototype.initialize = function(messageWindow) {
  3823. this._messageWindow = messageWindow;
  3824. Window_Command.prototype.initialize.call(this, 0, 0);
  3825. this.openness = 0;
  3826. this.deactivate();
  3827. this._background = 0;
  3828. };
  3829.  
  3830. Window_ChoiceList.prototype.start = function() {
  3831. this.updatePlacement();
  3832. this.updateBackground();
  3833. this.refresh();
  3834. this.selectDefault();
  3835. this.open();
  3836. this.activate();
  3837. };
  3838.  
  3839. Window_ChoiceList.prototype.selectDefault = function() {
  3840. this.select($gameMessage.choiceDefaultType());
  3841. };
  3842.  
  3843. Window_ChoiceList.prototype.updatePlacement = function() {
  3844. var positionType = $gameMessage.choicePositionType();
  3845. var messageY = this._messageWindow.y;
  3846. this.width = this.windowWidth();
  3847. this.height = this.windowHeight();
  3848. switch (positionType) {
  3849. case 0:
  3850. this.x = 0;
  3851. break;
  3852. case 1:
  3853. this.x = (Graphics.boxWidth - this.width) / 2;
  3854. break;
  3855. case 2:
  3856. this.x = Graphics.boxWidth - this.width;
  3857. break;
  3858. }
  3859. if (messageY >= Graphics.boxHeight / 2) {
  3860. this.y = messageY - this.height;
  3861. } else {
  3862. this.y = messageY + this._messageWindow.height;
  3863. }
  3864. };
  3865.  
  3866. Window_ChoiceList.prototype.updateBackground = function() {
  3867. this._background = $gameMessage.choiceBackground();
  3868. this.setBackgroundType(this._background);
  3869. };
  3870.  
  3871. Window_ChoiceList.prototype.windowWidth = function() {
  3872. var width = this.maxChoiceWidth() + this.padding * 2;
  3873. return Math.min(width, Graphics.boxWidth);
  3874. };
  3875.  
  3876. Window_ChoiceList.prototype.numVisibleRows = function() {
  3877. var messageY = this._messageWindow.y;
  3878. var messageHeight = this._messageWindow.height;
  3879. var centerY = Graphics.boxHeight / 2;
  3880. var choices = $gameMessage.choices();
  3881. var numLines = choices.length;
  3882. var maxLines = 8;
  3883. if (messageY < centerY && messageY + messageHeight > centerY) {
  3884. maxLines = 4;
  3885. }
  3886. if (numLines > maxLines) {
  3887. numLines = maxLines;
  3888. }
  3889. return numLines;
  3890. };
  3891.  
  3892. Window_ChoiceList.prototype.maxChoiceWidth = function() {
  3893. var maxWidth = 96;
  3894. var choices = $gameMessage.choices();
  3895. for (var i = 0; i < choices.length; i++) {
  3896. var choiceWidth = this.textWidthEx(choices[i]) + this.textPadding() * 2;
  3897. if (maxWidth < choiceWidth) {
  3898. maxWidth = choiceWidth;
  3899. }
  3900. }
  3901. return maxWidth;
  3902. };
  3903.  
  3904. Window_ChoiceList.prototype.textWidthEx = function(text) {
  3905. return this.drawTextEx(text, 0, this.contents.height);
  3906. };
  3907.  
  3908. Window_ChoiceList.prototype.contentsHeight = function() {
  3909. return this.maxItems() * this.itemHeight();
  3910. };
  3911.  
  3912. Window_ChoiceList.prototype.makeCommandList = function() {
  3913. var choices = $gameMessage.choices();
  3914. for (var i = 0; i < choices.length; i++) {
  3915. this.addCommand(choices[i], 'choice');
  3916. }
  3917. };
  3918.  
  3919. Window_ChoiceList.prototype.drawItem = function(index) {
  3920. var rect = this.itemRectForText(index);
  3921. this.drawTextEx(this.commandName(index), rect.x, rect.y);
  3922. };
  3923.  
  3924. Window_ChoiceList.prototype.isCancelEnabled = function() {
  3925. return $gameMessage.choiceCancelType() !== -1;
  3926. };
  3927.  
  3928. Window_ChoiceList.prototype.isOkTriggered = function() {
  3929. return Input.isTriggered('ok');
  3930. };
  3931.  
  3932. Window_ChoiceList.prototype.callOkHandler = function() {
  3933. $gameMessage.onChoice(this.index());
  3934. this._messageWindow.terminateMessage();
  3935. this.close();
  3936. };
  3937.  
  3938. Window_ChoiceList.prototype.callCancelHandler = function() {
  3939. $gameMessage.onChoice($gameMessage.choiceCancelType());
  3940. this._messageWindow.terminateMessage();
  3941. this.close();
  3942. };
  3943.  
  3944. //-----------------------------------------------------------------------------
  3945. // Window_NumberInput
  3946. //
  3947. // The window used for the event command [Input Number].
  3948.  
  3949. function Window_NumberInput() {
  3950. this.initialize.apply(this, arguments);
  3951. }
  3952.  
  3953. Window_NumberInput.prototype = Object.create(Window_Selectable.prototype);
  3954. Window_NumberInput.prototype.constructor = Window_NumberInput;
  3955.  
  3956. Window_NumberInput.prototype.initialize = function(messageWindow) {
  3957. this._messageWindow = messageWindow;
  3958. Window_Selectable.prototype.initialize.call(this, 0, 0, 0, 0);
  3959. this._number = 0;
  3960. this._maxDigits = 1;
  3961. this.openness = 0;
  3962. this.createButtons();
  3963. this.deactivate();
  3964. };
  3965.  
  3966. Window_NumberInput.prototype.start = function() {
  3967. this._maxDigits = $gameMessage.numInputMaxDigits();
  3968. this._number = $gameVariables.value($gameMessage.numInputVariableId());
  3969. this._number = this._number.clamp(0, Math.pow(10, this._maxDigits) - 1);
  3970. this.updatePlacement();
  3971. this.placeButtons();
  3972. this.updateButtonsVisiblity();
  3973. this.createContents();
  3974. this.refresh();
  3975. this.open();
  3976. this.activate();
  3977. this.select(0);
  3978. };
  3979.  
  3980. Window_NumberInput.prototype.updatePlacement = function() {
  3981. var messageY = this._messageWindow.y;
  3982. var spacing = 8;
  3983. this.width = this.windowWidth();
  3984. this.height = this.windowHeight();
  3985. this.x = (Graphics.boxWidth - this.width) / 2;
  3986. if (messageY >= Graphics.boxHeight / 2) {
  3987. this.y = messageY - this.height - spacing;
  3988. } else {
  3989. this.y = messageY + this._messageWindow.height + spacing;
  3990. }
  3991. };
  3992.  
  3993. Window_NumberInput.prototype.windowWidth = function() {
  3994. return this.maxCols() * this.itemWidth() + this.padding * 2;
  3995. };
  3996.  
  3997. Window_NumberInput.prototype.windowHeight = function() {
  3998. return this.fittingHeight(1);
  3999. };
  4000.  
  4001. Window_NumberInput.prototype.maxCols = function() {
  4002. return this._maxDigits;
  4003. };
  4004.  
  4005. Window_NumberInput.prototype.maxItems = function() {
  4006. return this._maxDigits;
  4007. };
  4008.  
  4009. Window_NumberInput.prototype.spacing = function() {
  4010. return 0;
  4011. };
  4012.  
  4013. Window_NumberInput.prototype.itemWidth = function() {
  4014. return 32;
  4015. };
  4016.  
  4017. Window_NumberInput.prototype.createButtons = function() {
  4018. var bitmap = ImageManager.loadSystem('ButtonSet');
  4019. var buttonWidth = 48;
  4020. var buttonHeight = 48;
  4021. this._buttons = [];
  4022. for (var i = 0; i < 3; i++) {
  4023. var button = new Sprite_Button();
  4024. var x = buttonWidth * [1, 2, 4][i];
  4025. var w = buttonWidth * (i === 2 ? 2 : 1);
  4026. button.bitmap = bitmap;
  4027. button.setColdFrame(x, 0, w, buttonHeight);
  4028. button.setHotFrame(x, buttonHeight, w, buttonHeight);
  4029. button.visible = false;
  4030. this._buttons.push(button);
  4031. this.addChild(button);
  4032. }
  4033. this._buttons[0].setClickHandler(this.onButtonDown.bind(this));
  4034. this._buttons[1].setClickHandler(this.onButtonUp.bind(this));
  4035. this._buttons[2].setClickHandler(this.onButtonOk.bind(this));
  4036. };
  4037.  
  4038. Window_NumberInput.prototype.placeButtons = function() {
  4039. var numButtons = this._buttons.length;
  4040. var spacing = 16;
  4041. var totalWidth = -spacing;
  4042. for (var i = 0; i < numButtons; i++) {
  4043. totalWidth += this._buttons[i].width + spacing;
  4044. }
  4045. var x = (this.width - totalWidth) / 2;
  4046. for (var j = 0; j < numButtons; j++) {
  4047. var button = this._buttons[j];
  4048. button.x = x;
  4049. button.y = this.buttonY();
  4050. x += button.width + spacing;
  4051. }
  4052. };
  4053.  
  4054. Window_NumberInput.prototype.updateButtonsVisiblity = function() {
  4055. if (TouchInput.date > Input.date) {
  4056. this.showButtons();
  4057. } else {
  4058. this.hideButtons();
  4059. }
  4060. };
  4061.  
  4062. Window_NumberInput.prototype.showButtons = function() {
  4063. for (var i = 0; i < this._buttons.length; i++) {
  4064. this._buttons[i].visible = true;
  4065. }
  4066. };
  4067.  
  4068. Window_NumberInput.prototype.hideButtons = function() {
  4069. for (var i = 0; i < this._buttons.length; i++) {
  4070. this._buttons[i].visible = false;
  4071. }
  4072. };
  4073.  
  4074. Window_NumberInput.prototype.buttonY = function() {
  4075. var spacing = 8;
  4076. if (this._messageWindow.y >= Graphics.boxHeight / 2) {
  4077. return 0 - this._buttons[0].height - spacing;
  4078. } else {
  4079. return this.height + spacing;
  4080. }
  4081. };
  4082.  
  4083. Window_NumberInput.prototype.update = function() {
  4084. Window_Selectable.prototype.update.call(this);
  4085. this.processDigitChange();
  4086. };
  4087.  
  4088. Window_NumberInput.prototype.processDigitChange = function() {
  4089. if (this.isOpenAndActive()) {
  4090. if (Input.isRepeated('up')) {
  4091. this.changeDigit(true);
  4092. } else if (Input.isRepeated('down')) {
  4093. this.changeDigit(false);
  4094. }
  4095. }
  4096. };
  4097.  
  4098. Window_NumberInput.prototype.changeDigit = function(up) {
  4099. var index = this.index();
  4100. var place = Math.pow(10, this._maxDigits - 1 - index);
  4101. var n = Math.floor(this._number / place) % 10;
  4102. this._number -= n * place;
  4103. if (up) {
  4104. n = (n + 1) % 10;
  4105. } else {
  4106. n = (n + 9) % 10;
  4107. }
  4108. this._number += n * place;
  4109. this.refresh();
  4110. SoundManager.playCursor();
  4111. };
  4112.  
  4113. Window_NumberInput.prototype.isTouchOkEnabled = function() {
  4114. return false;
  4115. };
  4116.  
  4117. Window_NumberInput.prototype.isOkEnabled = function() {
  4118. return true;
  4119. };
  4120.  
  4121. Window_NumberInput.prototype.isCancelEnabled = function() {
  4122. return false;
  4123. };
  4124.  
  4125. Window_NumberInput.prototype.isOkTriggered = function() {
  4126. return Input.isTriggered('ok');
  4127. };
  4128.  
  4129. Window_NumberInput.prototype.processOk = function() {
  4130. SoundManager.playOk();
  4131. $gameVariables.setValue($gameMessage.numInputVariableId(), this._number);
  4132. this._messageWindow.terminateMessage();
  4133. this.updateInputData();
  4134. this.deactivate();
  4135. this.close();
  4136. };
  4137.  
  4138. Window_NumberInput.prototype.drawItem = function(index) {
  4139. var rect = this.itemRect(index);
  4140. var align = 'center';
  4141. var s = this._number.padZero(this._maxDigits);
  4142. var c = s.slice(index, index + 1);
  4143. this.resetTextColor();
  4144. this.drawText(c, rect.x, rect.y, rect.width, align);
  4145. };
  4146.  
  4147. Window_NumberInput.prototype.onButtonUp = function() {
  4148. this.changeDigit(true);
  4149. };
  4150.  
  4151. Window_NumberInput.prototype.onButtonDown = function() {
  4152. this.changeDigit(false);
  4153. };
  4154.  
  4155. Window_NumberInput.prototype.onButtonOk = function() {
  4156. this.processOk();
  4157. this.hideButtons();
  4158. };
  4159.  
  4160. //-----------------------------------------------------------------------------
  4161. // Window_EventItem
  4162. //
  4163. // The window used for the event command [Select Item].
  4164.  
  4165. function Window_EventItem() {
  4166. this.initialize.apply(this, arguments);
  4167. }
  4168.  
  4169. Window_EventItem.prototype = Object.create(Window_ItemList.prototype);
  4170. Window_EventItem.prototype.constructor = Window_EventItem;
  4171.  
  4172. Window_EventItem.prototype.initialize = function(messageWindow) {
  4173. this._messageWindow = messageWindow;
  4174. var width = Graphics.boxWidth;
  4175. var height = this.windowHeight();
  4176. Window_ItemList.prototype.initialize.call(this, 0, 0, width, height);
  4177. this.openness = 0;
  4178. this.deactivate();
  4179. this.setHandler('ok', this.onOk.bind(this));
  4180. this.setHandler('cancel', this.onCancel.bind(this));
  4181. };
  4182.  
  4183. Window_EventItem.prototype.windowHeight = function() {
  4184. return this.fittingHeight(this.numVisibleRows());
  4185. };
  4186.  
  4187. Window_EventItem.prototype.numVisibleRows = function() {
  4188. return 4;
  4189. };
  4190.  
  4191. Window_EventItem.prototype.start = function() {
  4192. this.refresh();
  4193. this.updatePlacement();
  4194. this.select(0);
  4195. this.open();
  4196. this.activate();
  4197. };
  4198.  
  4199. Window_EventItem.prototype.updatePlacement = function() {
  4200. if (this._messageWindow.y >= Graphics.boxHeight / 2) {
  4201. this.y = 0;
  4202. } else {
  4203. this.y = Graphics.boxHeight - this.height;
  4204. }
  4205. };
  4206.  
  4207. Window_EventItem.prototype.includes = function(item) {
  4208. var itypeId = $gameMessage.itemChoiceItypeId();
  4209. return DataManager.isItem(item) && item.itypeId === itypeId;
  4210. };
  4211.  
  4212. Window_EventItem.prototype.isEnabled = function(item) {
  4213. return true;
  4214. };
  4215.  
  4216. Window_EventItem.prototype.onOk = function() {
  4217. var item = this.item();
  4218. var itemId = item ? item.id : 0;
  4219. $gameVariables.setValue($gameMessage.itemChoiceVariableId(), itemId);
  4220. this._messageWindow.terminateMessage();
  4221. this.close();
  4222. };
  4223.  
  4224. Window_EventItem.prototype.onCancel = function() {
  4225. $gameVariables.setValue($gameMessage.itemChoiceVariableId(), 0);
  4226. this._messageWindow.terminateMessage();
  4227. this.close();
  4228. };
  4229.  
  4230. //-----------------------------------------------------------------------------
  4231. // Window_Message
  4232. //
  4233. // The window for displaying text messages.
  4234.  
  4235. function Window_Message() {
  4236. this.initialize.apply(this, arguments);
  4237. }
  4238.  
  4239. Window_Message.prototype = Object.create(Window_Base.prototype);
  4240. Window_Message.prototype.constructor = Window_Message;
  4241.  
  4242. Window_Message.prototype.initialize = function() {
  4243. var width = this.windowWidth();
  4244. var height = this.windowHeight();
  4245. var x = (Graphics.boxWidth - width) / 2;
  4246. Window_Base.prototype.initialize.call(this, x, 0, width, height);
  4247. this.openness = 0;
  4248. this.initMembers();
  4249. this.createSubWindows();
  4250. this.updatePlacement();
  4251. };
  4252.  
  4253. Window_Message.prototype.initMembers = function() {
  4254. this._background = 0;
  4255. this._positionType = 2;
  4256. this._waitCount = 0;
  4257. this._faceBitmap = null;
  4258. this._textState = null;
  4259. this.clearFlags();
  4260. };
  4261.  
  4262. Window_Message.prototype.subWindows = function() {
  4263. return [this._goldWindow, this._choiceWindow,
  4264. this._numberWindow, this._itemWindow];
  4265. };
  4266.  
  4267. Window_Message.prototype.createSubWindows = function() {
  4268. this._goldWindow = new Window_Gold(0, 0);
  4269. this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
  4270. this._goldWindow.openness = 0;
  4271. this._choiceWindow = new Window_ChoiceList(this);
  4272. this._numberWindow = new Window_NumberInput(this);
  4273. this._itemWindow = new Window_EventItem(this);
  4274. };
  4275.  
  4276. Window_Message.prototype.windowWidth = function() {
  4277. return Graphics.boxWidth;
  4278. };
  4279.  
  4280. Window_Message.prototype.windowHeight = function() {
  4281. return this.fittingHeight(this.numVisibleRows());
  4282. };
  4283.  
  4284. Window_Message.prototype.clearFlags = function() {
  4285. this._showFast = false;
  4286. this._lineShowFast = false;
  4287. this._pauseSkip = false;
  4288. };
  4289.  
  4290. Window_Message.prototype.numVisibleRows = function() {
  4291. return 4;
  4292. };
  4293.  
  4294. Window_Message.prototype.update = function() {
  4295. this.checkToNotClose();
  4296. Window_Base.prototype.update.call(this);
  4297. while (!this.isOpening() && !this.isClosing()) {
  4298. if (this.updateWait()) {
  4299. return;
  4300. } else if (this.updateLoading()) {
  4301. return;
  4302. } else if (this.updateInput()) {
  4303. return;
  4304. } else if (this.updateMessage()) {
  4305. return;
  4306. } else if (this.canStart()) {
  4307. this.startMessage();
  4308. } else {
  4309. this.startInput();
  4310. return;
  4311. }
  4312. }
  4313. };
  4314.  
  4315. Window_Message.prototype.checkToNotClose = function() {
  4316. if (this.isClosing() && this.isOpen()) {
  4317. if (this.doesContinue()) {
  4318. this.open();
  4319. }
  4320. }
  4321. };
  4322.  
  4323. Window_Message.prototype.canStart = function() {
  4324. return $gameMessage.hasText() && !$gameMessage.scrollMode();
  4325. };
  4326.  
  4327. Window_Message.prototype.startMessage = function() {
  4328. this._textState = {};
  4329. this._textState.index = 0;
  4330. this._textState.text = this.convertEscapeCharacters($gameMessage.allText());
  4331. this.newPage(this._textState);
  4332. this.updatePlacement();
  4333. this.updateBackground();
  4334. this.open();
  4335. };
  4336.  
  4337. Window_Message.prototype.updatePlacement = function() {
  4338. this._positionType = $gameMessage.positionType();
  4339. this.y = this._positionType * (Graphics.boxHeight - this.height) / 2;
  4340. this._goldWindow.y = this.y > 0 ? 0 : Graphics.boxHeight - this._goldWindow.height;
  4341. };
  4342.  
  4343. Window_Message.prototype.updateBackground = function() {
  4344. this._background = $gameMessage.background();
  4345. this.setBackgroundType(this._background);
  4346. };
  4347.  
  4348. Window_Message.prototype.terminateMessage = function() {
  4349. this.close();
  4350. this._goldWindow.close();
  4351. $gameMessage.clear();
  4352. };
  4353.  
  4354. Window_Message.prototype.updateWait = function() {
  4355. if (this._waitCount > 0) {
  4356. this._waitCount--;
  4357. return true;
  4358. } else {
  4359. return false;
  4360. }
  4361. };
  4362.  
  4363. Window_Message.prototype.updateLoading = function() {
  4364. if (this._faceBitmap) {
  4365. if (ImageManager.isReady()) {
  4366. this.drawMessageFace();
  4367. this._faceBitmap = null;
  4368. return false;
  4369. } else {
  4370. return true;
  4371. }
  4372. } else {
  4373. return false;
  4374. }
  4375. };
  4376.  
  4377. Window_Message.prototype.updateInput = function() {
  4378. if (this.isAnySubWindowActive()) {
  4379. return true;
  4380. }
  4381. if (this.pause) {
  4382. if (this.isTriggered()) {
  4383. Input.update();
  4384. this.pause = false;
  4385. if (!this._textState) {
  4386. this.terminateMessage();
  4387. }
  4388. }
  4389. return true;
  4390. }
  4391. return false;
  4392. };
  4393.  
  4394. Window_Message.prototype.isAnySubWindowActive = function() {
  4395. return (this._choiceWindow.active ||
  4396. this._numberWindow.active ||
  4397. this._itemWindow.active);
  4398. };
  4399.  
  4400. Window_Message.prototype.updateMessage = function() {
  4401. if (this._textState) {
  4402. while (!this.isEndOfText(this._textState)) {
  4403. if (this.needsNewPage(this._textState)) {
  4404. this.newPage(this._textState);
  4405. }
  4406. this.updateShowFast();
  4407. this.processCharacter(this._textState);
  4408. if (!this._showFast && !this._lineShowFast) {
  4409. break;
  4410. }
  4411. if (this.pause || this._waitCount > 0) {
  4412. break;
  4413. }
  4414. }
  4415. if (this.isEndOfText(this._textState)) {
  4416. this.onEndOfText();
  4417. }
  4418. return true;
  4419. } else {
  4420. return false;
  4421. }
  4422. };
  4423.  
  4424. Window_Message.prototype.onEndOfText = function() {
  4425. if (!this.startInput()) {
  4426. if (!this._pauseSkip) {
  4427. this.startPause();
  4428. } else {
  4429. this.terminateMessage();
  4430. }
  4431. }
  4432. this._textState = null;
  4433. };
  4434.  
  4435. Window_Message.prototype.startInput = function() {
  4436. if ($gameMessage.isChoice()) {
  4437. this._choiceWindow.start();
  4438. return true;
  4439. } else if ($gameMessage.isNumberInput()) {
  4440. this._numberWindow.start();
  4441. return true;
  4442. } else if ($gameMessage.isItemChoice()) {
  4443. this._itemWindow.start();
  4444. return true;
  4445. } else {
  4446. return false;
  4447. }
  4448. };
  4449.  
  4450. Window_Message.prototype.isTriggered = function() {
  4451. return (Input.isRepeated('ok') || Input.isRepeated('cancel') ||
  4452. TouchInput.isRepeated());
  4453. };
  4454.  
  4455. Window_Message.prototype.doesContinue = function() {
  4456. return ($gameMessage.hasText() && !$gameMessage.scrollMode() &&
  4457. !this.areSettingsChanged());
  4458. };
  4459.  
  4460. Window_Message.prototype.areSettingsChanged = function() {
  4461. return (this._background !== $gameMessage.background() ||
  4462. this._positionType !== $gameMessage.positionType());
  4463. };
  4464.  
  4465. Window_Message.prototype.updateShowFast = function() {
  4466. if (this.isTriggered()) {
  4467. this._showFast = true;
  4468. }
  4469. };
  4470.  
  4471. Window_Message.prototype.newPage = function(textState) {
  4472. this.contents.clear();
  4473. this.resetFontSettings();
  4474. this.clearFlags();
  4475. this.loadMessageFace();
  4476. textState.x = this.newLineX();
  4477. textState.y = 0;
  4478. textState.left = this.newLineX();
  4479. textState.height = this.calcTextHeight(textState, false);
  4480. };
  4481.  
  4482. Window_Message.prototype.loadMessageFace = function() {
  4483. this._faceBitmap = ImageManager.loadFace($gameMessage.faceName());
  4484. };
  4485.  
  4486. Window_Message.prototype.drawMessageFace = function() {
  4487. this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), 0, 0);
  4488. };
  4489.  
  4490. Window_Message.prototype.newLineX = function() {
  4491. return $gameMessage.faceName() === '' ? 0 : 168;
  4492. };
  4493.  
  4494. Window_Message.prototype.processNewLine = function(textState) {
  4495. this._lineShowFast = false;
  4496. Window_Base.prototype.processNewLine.call(this, textState);
  4497. if (this.needsNewPage(textState)) {
  4498. this.startPause();
  4499. }
  4500. };
  4501.  
  4502. Window_Message.prototype.processNewPage = function(textState) {
  4503. Window_Base.prototype.processNewPage.call(this, textState);
  4504. if (textState.text[textState.index] === '\n') {
  4505. textState.index++;
  4506. }
  4507. textState.y = this.contents.height;
  4508. this.startPause();
  4509. };
  4510.  
  4511. Window_Message.prototype.isEndOfText = function(textState) {
  4512. return textState.index >= textState.text.length;
  4513. };
  4514.  
  4515. Window_Message.prototype.needsNewPage = function(textState) {
  4516. return (!this.isEndOfText(textState) &&
  4517. textState.y + textState.height > this.contents.height);
  4518. };
  4519.  
  4520. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  4521. switch (code) {
  4522. case '$':
  4523. this._goldWindow.open();
  4524. break;
  4525. case '.':
  4526. this.startWait(15);
  4527. break;
  4528. case '|':
  4529. this.startWait(60);
  4530. break;
  4531. case '!':
  4532. this.startPause();
  4533. break;
  4534. case '>':
  4535. this._lineShowFast = true;
  4536. break;
  4537. case '<':
  4538. this._lineShowFast = false;
  4539. break;
  4540. case '^':
  4541. this._pauseSkip = true;
  4542. break;
  4543. default:
  4544. Window_Base.prototype.processEscapeCharacter.call(this, code, textState);
  4545. break;
  4546. }
  4547. };
  4548.  
  4549. Window_Message.prototype.startWait = function(count) {
  4550. this._waitCount = count;
  4551. };
  4552.  
  4553. Window_Message.prototype.startPause = function() {
  4554. this.startWait(10);
  4555. this.pause = true;
  4556. };
  4557.  
  4558. //-----------------------------------------------------------------------------
  4559. // Window_ScrollText
  4560. //
  4561. // The window for displaying scrolling text. No frame is displayed, but it
  4562. // is handled as a window for convenience.
  4563.  
  4564. function Window_ScrollText() {
  4565. this.initialize.apply(this, arguments);
  4566. }
  4567.  
  4568. Window_ScrollText.prototype = Object.create(Window_Base.prototype);
  4569. Window_ScrollText.prototype.constructor = Window_ScrollText;
  4570.  
  4571. Window_ScrollText.prototype.initialize = function() {
  4572. var width = Graphics.boxWidth;
  4573. var height = Graphics.boxHeight;
  4574. Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  4575. this.opacity = 0;
  4576. this.hide();
  4577. this._text = '';
  4578. this._allTextHeight = 0;
  4579. };
  4580.  
  4581. Window_ScrollText.prototype.update = function() {
  4582. Window_Base.prototype.update.call(this);
  4583. if ($gameMessage.scrollMode()) {
  4584. if (this._text) {
  4585. this.updateMessage();
  4586. }
  4587. if (!this._text && $gameMessage.hasText()) {
  4588. this.startMessage();
  4589. }
  4590. }
  4591. };
  4592.  
  4593. Window_ScrollText.prototype.startMessage = function() {
  4594. this._text = $gameMessage.allText();
  4595. this.refresh();
  4596. this.show();
  4597. };
  4598.  
  4599. Window_ScrollText.prototype.refresh = function() {
  4600. var textState = { index: 0 };
  4601. textState.text = this.convertEscapeCharacters(this._text);
  4602. this.resetFontSettings();
  4603. this._allTextHeight = this.calcTextHeight(textState, true);
  4604. this.createContents();
  4605. this.origin.y = -this.height;
  4606. this.drawTextEx(this._text, this.textPadding(), 1);
  4607. };
  4608.  
  4609. Window_ScrollText.prototype.contentsHeight = function() {
  4610. return Math.max(this._allTextHeight, 1);
  4611. };
  4612.  
  4613. Window_ScrollText.prototype.updateMessage = function() {
  4614. this.origin.y += this.scrollSpeed();
  4615. if (this.origin.y >= this.contents.height) {
  4616. this.terminateMessage();
  4617. }
  4618. };
  4619.  
  4620. Window_ScrollText.prototype.scrollSpeed = function() {
  4621. var speed = $gameMessage.scrollSpeed() / 2;
  4622. if (this.isFastForward()) {
  4623. speed *= this.fastForwardRate();
  4624. }
  4625. return speed;
  4626. };
  4627.  
  4628. Window_ScrollText.prototype.isFastForward = function() {
  4629. if ($gameMessage.scrollNoFast()) {
  4630. return false;
  4631. } else {
  4632. return (Input.isPressed('ok') || Input.isPressed('shift') ||
  4633. TouchInput.isPressed());
  4634. }
  4635. };
  4636.  
  4637. Window_ScrollText.prototype.fastForwardRate = function() {
  4638. return 3;
  4639. };
  4640.  
  4641. Window_ScrollText.prototype.terminateMessage = function() {
  4642. this._text = null;
  4643. $gameMessage.clear();
  4644. this.hide();
  4645. };
  4646.  
  4647. //-----------------------------------------------------------------------------
  4648. // Window_MapName
  4649. //
  4650. // The window for displaying the map name on the map screen.
  4651.  
  4652. function Window_MapName() {
  4653. this.initialize.apply(this, arguments);
  4654. }
  4655.  
  4656. Window_MapName.prototype = Object.create(Window_Base.prototype);
  4657. Window_MapName.prototype.constructor = Window_MapName;
  4658.  
  4659. Window_MapName.prototype.initialize = function() {
  4660. var wight = this.windowWidth();
  4661. var height = this.windowHeight();
  4662. Window_Base.prototype.initialize.call(this, 0, 0, wight, height);
  4663. this.opacity = 0;
  4664. this.contentsOpacity = 0;
  4665. this._showCount = 0;
  4666. this.refresh();
  4667. };
  4668.  
  4669. Window_MapName.prototype.windowWidth = function() {
  4670. return 360;
  4671. };
  4672.  
  4673. Window_MapName.prototype.windowHeight = function() {
  4674. return this.fittingHeight(1);
  4675. };
  4676.  
  4677. Window_MapName.prototype.update = function() {
  4678. Window_Base.prototype.update.call(this);
  4679. if (this._showCount > 0 && $gameMap.isNameDisplayEnabled()) {
  4680. this.updateFadeIn();
  4681. this._showCount--;
  4682. } else {
  4683. this.updateFadeOut();
  4684. }
  4685. };
  4686.  
  4687. Window_MapName.prototype.updateFadeIn = function() {
  4688. this.contentsOpacity += 16;
  4689. };
  4690.  
  4691. Window_MapName.prototype.updateFadeOut = function() {
  4692. this.contentsOpacity -= 16;
  4693. };
  4694.  
  4695. Window_MapName.prototype.open = function() {
  4696. this.refresh();
  4697. this._showCount = 150;
  4698. };
  4699.  
  4700. Window_MapName.prototype.close = function() {
  4701. this._showCount = 0;
  4702. };
  4703.  
  4704. Window_MapName.prototype.refresh = function() {
  4705. this.contents.clear();
  4706. if ($gameMap.displayName()) {
  4707. var width = this.contentsWidth();
  4708. this.drawBackground(0, 0, width, this.lineHeight());
  4709. this.drawText($gameMap.displayName(), 0, 0, width, 'center');
  4710. }
  4711. };
  4712.  
  4713. Window_MapName.prototype.drawBackground = function(x, y, width, height) {
  4714. var color1 = this.dimColor1();
  4715. var color2 = this.dimColor2();
  4716. this.contents.gradientFillRect(x, y, width / 2, height, color2, color1);
  4717. this.contents.gradientFillRect(x + width / 2, y, width / 2, height, color1, color2);
  4718. };
  4719.  
  4720. //-----------------------------------------------------------------------------
  4721. // Window_BattleLog
  4722. //
  4723. // The window for displaying battle progress. No frame is displayed, but it is
  4724. // handled as a window for convenience.
  4725.  
  4726. function Window_BattleLog() {
  4727. this.initialize.apply(this, arguments);
  4728. }
  4729.  
  4730. Window_BattleLog.prototype = Object.create(Window_Selectable.prototype);
  4731. Window_BattleLog.prototype.constructor = Window_BattleLog;
  4732.  
  4733. Window_BattleLog.prototype.initialize = function() {
  4734. var width = this.windowWidth();
  4735. var height = this.windowHeight();
  4736. Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  4737. this.opacity = 0;
  4738. this._lines = [];
  4739. this._methods = [];
  4740. this._waitCount = 0;
  4741. this._waitMode = '';
  4742. this._baseLineStack = [];
  4743. this._spriteset = null;
  4744. this.createBackBitmap();
  4745. this.createBackSprite();
  4746. this.refresh();
  4747. };
  4748.  
  4749. Window_BattleLog.prototype.setSpriteset = function(spriteset) {
  4750. this._spriteset = spriteset;
  4751. };
  4752.  
  4753. Window_BattleLog.prototype.windowWidth = function() {
  4754. return Graphics.boxWidth;
  4755. };
  4756.  
  4757. Window_BattleLog.prototype.windowHeight = function() {
  4758. return this.fittingHeight(this.maxLines());
  4759. };
  4760.  
  4761. Window_BattleLog.prototype.maxLines = function() {
  4762. return 10;
  4763. };
  4764.  
  4765. Window_BattleLog.prototype.createBackBitmap = function() {
  4766. this._backBitmap = new Bitmap(this.width, this.height);
  4767. };
  4768.  
  4769. Window_BattleLog.prototype.createBackSprite = function() {
  4770. this._backSprite = new Sprite();
  4771. this._backSprite.bitmap = this._backBitmap;
  4772. this._backSprite.y = this.y;
  4773. this.addChildToBack(this._backSprite);
  4774. };
  4775.  
  4776. Window_BattleLog.prototype.numLines = function() {
  4777. return this._lines.length;
  4778. };
  4779.  
  4780. Window_BattleLog.prototype.messageSpeed = function() {
  4781. return 16;
  4782. };
  4783.  
  4784. Window_BattleLog.prototype.isBusy = function() {
  4785. return this._waitCount > 0 || this._waitMode || this._methods.length > 0;
  4786. };
  4787.  
  4788. Window_BattleLog.prototype.update = function() {
  4789. if (!this.updateWait()) {
  4790. this.callNextMethod();
  4791. }
  4792. };
  4793.  
  4794. Window_BattleLog.prototype.updateWait = function() {
  4795. return this.updateWaitCount() || this.updateWaitMode();
  4796. };
  4797.  
  4798. Window_BattleLog.prototype.updateWaitCount = function() {
  4799. if (this._waitCount > 0) {
  4800. this._waitCount -= this.isFastForward() ? 3 : 1;
  4801. if (this._waitCount < 0) {
  4802. this._waitCount = 0;
  4803. }
  4804. return true;
  4805. }
  4806. return false;
  4807. };
  4808.  
  4809. Window_BattleLog.prototype.updateWaitMode = function() {
  4810. var waiting = false;
  4811. switch (this._waitMode) {
  4812. case 'effect':
  4813. waiting = this._spriteset.isEffecting();
  4814. break;
  4815. case 'movement':
  4816. waiting = this._spriteset.isAnyoneMoving();
  4817. break;
  4818. }
  4819. if (!waiting) {
  4820. this._waitMode = '';
  4821. }
  4822. return waiting;
  4823. };
  4824.  
  4825. Window_BattleLog.prototype.setWaitMode = function(waitMode) {
  4826. this._waitMode = waitMode;
  4827. };
  4828.  
  4829. Window_BattleLog.prototype.callNextMethod = function() {
  4830. if (this._methods.length > 0) {
  4831. var method = this._methods.shift();
  4832. if (method.name && this[method.name]) {
  4833. this[method.name].apply(this, method.params);
  4834. } else {
  4835. throw new Error('Method not found: ' + method.name);
  4836. }
  4837. }
  4838. };
  4839.  
  4840. Window_BattleLog.prototype.isFastForward = function() {
  4841. return (Input.isLongPressed('ok') || Input.isPressed('shift') ||
  4842. TouchInput.isLongPressed());
  4843. };
  4844.  
  4845. Window_BattleLog.prototype.push = function(methodName) {
  4846. var methodArgs = Array.prototype.slice.call(arguments, 1);
  4847. this._methods.push({ name: methodName, params: methodArgs });
  4848. };
  4849.  
  4850. Window_BattleLog.prototype.clear = function() {
  4851. this._lines = [];
  4852. this._baseLineStack = [];
  4853. this.refresh();
  4854. };
  4855.  
  4856. Window_BattleLog.prototype.wait = function() {
  4857. this._waitCount = this.messageSpeed();
  4858. };
  4859.  
  4860. Window_BattleLog.prototype.waitForEffect = function() {
  4861. this.setWaitMode('effect');
  4862. };
  4863.  
  4864. Window_BattleLog.prototype.waitForMovement = function() {
  4865. this.setWaitMode('movement');
  4866. };
  4867.  
  4868. Window_BattleLog.prototype.addText = function(text) {
  4869. this._lines.push(text);
  4870. this.refresh();
  4871. this.wait();
  4872. };
  4873.  
  4874. Window_BattleLog.prototype.pushBaseLine = function() {
  4875. this._baseLineStack.push(this._lines.length);
  4876. };
  4877.  
  4878. Window_BattleLog.prototype.popBaseLine = function() {
  4879. var baseLine = this._baseLineStack.pop();
  4880. while (this._lines.length > baseLine) {
  4881. this._lines.pop();
  4882. }
  4883. };
  4884.  
  4885. Window_BattleLog.prototype.waitForNewLine = function() {
  4886. var baseLine = 0;
  4887. if (this._baseLineStack.length > 0) {
  4888. baseLine = this._baseLineStack[this._baseLineStack.length - 1];
  4889. }
  4890. if (this._lines.length > baseLine) {
  4891. this.wait();
  4892. }
  4893. };
  4894.  
  4895. Window_BattleLog.prototype.popupDamage = function(target) {
  4896. target.startDamagePopup();
  4897. };
  4898.  
  4899. Window_BattleLog.prototype.performActionStart = function(subject, action) {
  4900. subject.performActionStart(action);
  4901. };
  4902.  
  4903. Window_BattleLog.prototype.performAction = function(subject, action) {
  4904. subject.performAction(action);
  4905. };
  4906.  
  4907. Window_BattleLog.prototype.performActionEnd = function(subject) {
  4908. subject.performActionEnd();
  4909. };
  4910.  
  4911. Window_BattleLog.prototype.performDamage = function(target) {
  4912. target.performDamage();
  4913. };
  4914.  
  4915. Window_BattleLog.prototype.performMiss = function(target) {
  4916. target.performMiss();
  4917. };
  4918.  
  4919. Window_BattleLog.prototype.performRecovery = function(target) {
  4920. target.performRecovery();
  4921. };
  4922.  
  4923. Window_BattleLog.prototype.performEvasion = function(target) {
  4924. target.performEvasion();
  4925. };
  4926.  
  4927. Window_BattleLog.prototype.performMagicEvasion = function(target) {
  4928. target.performMagicEvasion();
  4929. };
  4930.  
  4931. Window_BattleLog.prototype.performCounter = function(target) {
  4932. target.performCounter();
  4933. };
  4934.  
  4935. Window_BattleLog.prototype.performReflection = function(target) {
  4936. target.performReflection();
  4937. };
  4938.  
  4939. Window_BattleLog.prototype.performSubstitute = function(substitute, target) {
  4940. substitute.performSubstitute(target);
  4941. };
  4942.  
  4943. Window_BattleLog.prototype.performCollapse = function(target) {
  4944. target.performCollapse();
  4945. };
  4946.  
  4947. Window_BattleLog.prototype.showAnimation = function(subject, targets, animationId) {
  4948. if (animationId < 0) {
  4949. this.showAttackAnimation(subject, targets);
  4950. } else {
  4951. this.showNormalAnimation(targets, animationId);
  4952. }
  4953. };
  4954.  
  4955. Window_BattleLog.prototype.showAttackAnimation = function(subject, targets) {
  4956. if (subject.isActor()) {
  4957. this.showActorAttackAnimation(subject, targets);
  4958. } else {
  4959. this.showEnemyAttackAnimation(subject, targets);
  4960. }
  4961. };
  4962.  
  4963. Window_BattleLog.prototype.showActorAttackAnimation = function(subject, targets) {
  4964. this.showNormalAnimation(targets, subject.attackAnimationId1(), false);
  4965. this.showNormalAnimation(targets, subject.attackAnimationId2(), true);
  4966. };
  4967.  
  4968. Window_BattleLog.prototype.showEnemyAttackAnimation = function(subject, targets) {
  4969. SoundManager.playEnemyAttack();
  4970. };
  4971.  
  4972. Window_BattleLog.prototype.showNormalAnimation = function(targets, animationId, mirror) {
  4973. var animation = $dataAnimations[animationId];
  4974. if (animation) {
  4975. var delay = this.animationBaseDelay();
  4976. var nextDelay = this.animationNextDelay();
  4977. targets.forEach(function(target) {
  4978. target.startAnimation(animationId, mirror, delay);
  4979. delay += nextDelay;
  4980. });
  4981. }
  4982. };
  4983.  
  4984. Window_BattleLog.prototype.animationBaseDelay = function() {
  4985. return 8;
  4986. };
  4987.  
  4988. Window_BattleLog.prototype.animationNextDelay = function() {
  4989. return 12;
  4990. };
  4991.  
  4992. Window_BattleLog.prototype.refresh = function() {
  4993. this.drawBackground();
  4994. this.contents.clear();
  4995. for (var i = 0; i < this._lines.length; i++) {
  4996. this.drawLineText(i);
  4997. }
  4998. };
  4999.  
  5000. Window_BattleLog.prototype.drawBackground = function() {
  5001. var rect = this.backRect();
  5002. var color = this.backColor();
  5003. this._backBitmap.clear();
  5004. this._backBitmap.paintOpacity = this.backPaintOpacity();
  5005. this._backBitmap.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  5006. this._backBitmap.paintOpacity = 255;
  5007. };
  5008.  
  5009. Window_BattleLog.prototype.backRect = function() {
  5010. return {
  5011. x: 0,
  5012. y: this.padding,
  5013. width: this.width,
  5014. height: this.numLines() * this.lineHeight()
  5015. };
  5016. };
  5017.  
  5018. Window_BattleLog.prototype.backColor = function() {
  5019. return '#000000';
  5020. };
  5021.  
  5022. Window_BattleLog.prototype.backPaintOpacity = function() {
  5023. return 64;
  5024. };
  5025.  
  5026. Window_BattleLog.prototype.drawLineText = function(index) {
  5027. var rect = this.itemRectForText(index);
  5028. this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  5029. this.drawTextEx(this._lines[index], rect.x, rect.y, rect.width);
  5030. };
  5031.  
  5032. Window_BattleLog.prototype.startTurn = function() {
  5033. this.push('wait');
  5034. };
  5035.  
  5036. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
  5037. var item = action.item();
  5038. this.push('performActionStart', subject, action);
  5039. this.push('waitForMovement');
  5040. this.push('performAction', subject, action);
  5041. this.push('showAnimation', subject, targets.clone(), item.animationId);
  5042. this.displayAction(subject, item);
  5043. };
  5044.  
  5045. Window_BattleLog.prototype.endAction = function(subject) {
  5046. this.push('waitForNewLine');
  5047. this.push('clear');
  5048. this.push('performActionEnd', subject);
  5049. };
  5050.  
  5051. Window_BattleLog.prototype.displayCurrentState = function(subject) {
  5052. var stateText = subject.mostImportantStateText();
  5053. if (stateText) {
  5054. this.push('addText', subject.name() + stateText);
  5055. this.push('wait');
  5056. this.push('clear');
  5057. }
  5058. };
  5059.  
  5060. Window_BattleLog.prototype.displayRegeneration = function(subject) {
  5061. this.push('popupDamage', subject);
  5062. };
  5063.  
  5064. Window_BattleLog.prototype.displayAction = function(subject, item) {
  5065. var numMethods = this._methods.length;
  5066. if (DataManager.isSkill(item)) {
  5067. if (item.message1) {
  5068. this.push('addText', subject.name() + item.message1.format(item.name));
  5069. }
  5070. if (item.message2) {
  5071. this.push('addText', item.message2.format(item.name));
  5072. }
  5073. } else {
  5074. this.push('addText', TextManager.useItem.format(subject.name(), item.name));
  5075. }
  5076. if (this._methods.length === numMethods) {
  5077. this.push('wait');
  5078. }
  5079. };
  5080.  
  5081. Window_BattleLog.prototype.displayCounter = function(target) {
  5082. this.push('performCounter', target);
  5083. this.push('addText', TextManager.counterAttack.format(target.name()));
  5084. };
  5085.  
  5086. Window_BattleLog.prototype.displayReflection = function(target) {
  5087. this.push('performReflection', target);
  5088. this.push('addText', TextManager.magicReflection.format(target.name()));
  5089. };
  5090.  
  5091. Window_BattleLog.prototype.displaySubstitute = function(substitute, target) {
  5092. var substName = substitute.name();
  5093. this.push('performSubstitute', substitute, target);
  5094. this.push('addText', TextManager.substitute.format(substName, target.name()));
  5095. };
  5096.  
  5097. Window_BattleLog.prototype.displayActionResults = function(subject, target) {
  5098. if (target.result().used) {
  5099. this.push('pushBaseLine');
  5100. this.displayCritical(target);
  5101. this.push('popupDamage', target);
  5102. this.push('popupDamage', subject);
  5103. this.displayDamage(target);
  5104. this.displayAffectedStatus(target);
  5105. this.displayFailure(target);
  5106. this.push('waitForNewLine');
  5107. this.push('popBaseLine');
  5108. }
  5109. };
  5110.  
  5111. Window_BattleLog.prototype.displayFailure = function(target) {
  5112. if (target.result().isHit() && !target.result().success) {
  5113. this.push('addText', TextManager.actionFailure.format(target.name()));
  5114. }
  5115. };
  5116.  
  5117. Window_BattleLog.prototype.displayCritical = function(target) {
  5118. if (target.result().critical) {
  5119. if (target.isActor()) {
  5120. this.push('addText', TextManager.criticalToActor);
  5121. } else {
  5122. this.push('addText', TextManager.criticalToEnemy);
  5123. }
  5124. }
  5125. };
  5126.  
  5127. Window_BattleLog.prototype.displayDamage = function(target) {
  5128. if (target.result().missed) {
  5129. this.displayMiss(target);
  5130. } else if (target.result().evaded) {
  5131. this.displayEvasion(target);
  5132. } else {
  5133. this.displayHpDamage(target);
  5134. this.displayMpDamage(target);
  5135. this.displayTpDamage(target);
  5136. }
  5137. };
  5138.  
  5139. Window_BattleLog.prototype.displayMiss = function(target) {
  5140. var fmt;
  5141. if (target.result().physical) {
  5142. fmt = target.isActor() ? TextManager.actorNoHit : TextManager.enemyNoHit;
  5143. this.push('performMiss', target);
  5144. } else {
  5145. fmt = TextManager.actionFailure;
  5146. }
  5147. this.push('addText', fmt.format(target.name()));
  5148. };
  5149.  
  5150. Window_BattleLog.prototype.displayEvasion = function(target) {
  5151. var fmt;
  5152. if (target.result().physical) {
  5153. fmt = TextManager.evasion;
  5154. this.push('performEvasion', target);
  5155. } else {
  5156. fmt = TextManager.magicEvasion;
  5157. this.push('performMagicEvasion', target);
  5158. }
  5159. this.push('addText', fmt.format(target.name()));
  5160. };
  5161.  
  5162. Window_BattleLog.prototype.displayHpDamage = function(target) {
  5163. if (target.result().hpAffected) {
  5164. if (target.result().hpDamage > 0 && !target.result().drain) {
  5165. this.push('performDamage', target);
  5166. }
  5167. if (target.result().hpDamage < 0) {
  5168. this.push('performRecovery', target);
  5169. }
  5170. this.push('addText', this.makeHpDamageText(target));
  5171. }
  5172. };
  5173.  
  5174. Window_BattleLog.prototype.displayMpDamage = function(target) {
  5175. if (target.isAlive() && target.result().mpDamage !== 0) {
  5176. if (target.result().mpDamage < 0) {
  5177. this.push('performRecovery', target);
  5178. }
  5179. this.push('addText', this.makeMpDamageText(target));
  5180. }
  5181. };
  5182.  
  5183. Window_BattleLog.prototype.displayTpDamage = function(target) {
  5184. if (target.isAlive() && target.result().tpDamage !== 0) {
  5185. if (target.result().tpDamage < 0) {
  5186. this.push('performRecovery', target);
  5187. }
  5188. this.push('addText', this.makeTpDamageText(target));
  5189. }
  5190. };
  5191.  
  5192. Window_BattleLog.prototype.displayAffectedStatus = function(target) {
  5193. if (target.result().isStatusAffected()) {
  5194. this.push('pushBaseLine');
  5195. this.displayChangedStates(target);
  5196. this.displayChangedBuffs(target);
  5197. this.push('waitForNewLine');
  5198. this.push('popBaseLine');
  5199. }
  5200. };
  5201.  
  5202. Window_BattleLog.prototype.displayAutoAffectedStatus = function(target) {
  5203. if (target.result().isStatusAffected()) {
  5204. this.displayAffectedStatus(target, null);
  5205. this.push('clear');
  5206. }
  5207. };
  5208.  
  5209. Window_BattleLog.prototype.displayChangedStates = function(target) {
  5210. this.displayAddedStates(target);
  5211. this.displayRemovedStates(target);
  5212. };
  5213.  
  5214. Window_BattleLog.prototype.displayAddedStates = function(target) {
  5215. target.result().addedStateObjects().forEach(function(state) {
  5216. var stateMsg = target.isActor() ? state.message1 : state.message2;
  5217. if (state.id === target.deathStateId()) {
  5218. this.push('performCollapse', target);
  5219. }
  5220. if (stateMsg) {
  5221. this.push('popBaseLine');
  5222. this.push('pushBaseLine');
  5223. this.push('addText', target.name() + stateMsg);
  5224. this.push('waitForEffect');
  5225. }
  5226. }, this);
  5227. };
  5228.  
  5229. Window_BattleLog.prototype.displayRemovedStates = function(target) {
  5230. target.result().removedStateObjects().forEach(function(state) {
  5231. if (state.message4) {
  5232. this.push('popBaseLine');
  5233. this.push('pushBaseLine');
  5234. this.push('addText', target.name() + state.message4);
  5235. }
  5236. }, this);
  5237. };
  5238.  
  5239. Window_BattleLog.prototype.displayChangedBuffs = function(target) {
  5240. var result = target.result();
  5241. this.displayBuffs(target, result.addedBuffs, TextManager.buffAdd);
  5242. this.displayBuffs(target, result.addedDebuffs, TextManager.debuffAdd);
  5243. this.displayBuffs(target, result.removedBuffs, TextManager.buffRemove);
  5244. };
  5245.  
  5246. Window_BattleLog.prototype.displayBuffs = function(target, buffs, fmt) {
  5247. buffs.forEach(function(paramId) {
  5248. this.push('popBaseLine');
  5249. this.push('pushBaseLine');
  5250. this.push('addText', fmt.format(target.name(), TextManager.param(paramId)));
  5251. }, this);
  5252. };
  5253.  
  5254. Window_BattleLog.prototype.makeHpDamageText = function(target) {
  5255. var result = target.result();
  5256. var damage = result.hpDamage;
  5257. var isActor = target.isActor();
  5258. var fmt;
  5259. if (damage > 0 && result.drain) {
  5260. fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
  5261. return fmt.format(target.name(), TextManager.hp, damage);
  5262. } else if (damage > 0) {
  5263. fmt = isActor ? TextManager.actorDamage : TextManager.enemyDamage;
  5264. return fmt.format(target.name(), damage);
  5265. } else if (damage < 0) {
  5266. fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
  5267. return fmt.format(target.name(), TextManager.hp, -damage);
  5268. } else {
  5269. fmt = isActor ? TextManager.actorNoDamage : TextManager.enemyNoDamage;
  5270. return fmt.format(target.name());
  5271. }
  5272. };
  5273.  
  5274. Window_BattleLog.prototype.makeMpDamageText = function(target) {
  5275. var result = target.result();
  5276. var damage = result.mpDamage;
  5277. var isActor = target.isActor();
  5278. var fmt;
  5279. if (damage > 0 && result.drain) {
  5280. fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
  5281. return fmt.format(target.name(), TextManager.mp, damage);
  5282. } else if (damage > 0) {
  5283. fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
  5284. return fmt.format(target.name(), TextManager.mp, damage);
  5285. } else if (damage < 0) {
  5286. fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
  5287. return fmt.format(target.name(), TextManager.mp, -damage);
  5288. } else {
  5289. return '';
  5290. }
  5291. };
  5292.  
  5293. Window_BattleLog.prototype.makeTpDamageText = function(target) {
  5294. var result = target.result();
  5295. var damage = result.tpDamage;
  5296. var isActor = target.isActor();
  5297. var fmt;
  5298. if (damage > 0) {
  5299. fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
  5300. return fmt.format(target.name(), TextManager.tp, damage);
  5301. } else if (damage < 0) {
  5302. fmt = isActor ? TextManager.actorGain : TextManager.enemyGain;
  5303. return fmt.format(target.name(), TextManager.tp, -damage);
  5304. } else {
  5305. return '';
  5306. }
  5307. };
  5308.  
  5309. //-----------------------------------------------------------------------------
  5310. // Window_PartyCommand
  5311. //
  5312. // The window for selecting whether to fight or escape on the battle screen.
  5313.  
  5314. function Window_PartyCommand() {
  5315. this.initialize.apply(this, arguments);
  5316. }
  5317.  
  5318. Window_PartyCommand.prototype = Object.create(Window_Command.prototype);
  5319. Window_PartyCommand.prototype.constructor = Window_PartyCommand;
  5320.  
  5321. Window_PartyCommand.prototype.initialize = function() {
  5322. var y = Graphics.boxHeight - this.windowHeight();
  5323. Window_Command.prototype.initialize.call(this, 0, y);
  5324. this.openness = 0;
  5325. this.deactivate();
  5326. };
  5327.  
  5328. Window_PartyCommand.prototype.windowWidth = function() {
  5329. return 192;
  5330. };
  5331.  
  5332. Window_PartyCommand.prototype.numVisibleRows = function() {
  5333. return 4;
  5334. };
  5335.  
  5336. Window_PartyCommand.prototype.makeCommandList = function() {
  5337. this.addCommand(TextManager.fight, 'fight');
  5338. this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  5339. };
  5340.  
  5341. Window_PartyCommand.prototype.setup = function() {
  5342. this.clearCommandList();
  5343. this.makeCommandList();
  5344. this.refresh();
  5345. this.select(0);
  5346. this.activate();
  5347. this.open();
  5348. };
  5349.  
  5350. //-----------------------------------------------------------------------------
  5351. // Window_ActorCommand
  5352. //
  5353. // The window for selecting an actor's action on the battle screen.
  5354.  
  5355. function Window_ActorCommand() {
  5356. this.initialize.apply(this, arguments);
  5357. }
  5358.  
  5359. Window_ActorCommand.prototype = Object.create(Window_Command.prototype);
  5360. Window_ActorCommand.prototype.constructor = Window_ActorCommand;
  5361.  
  5362. Window_ActorCommand.prototype.initialize = function() {
  5363. var y = Graphics.boxHeight - this.windowHeight();
  5364. Window_Command.prototype.initialize.call(this, 0, y);
  5365. this.openness = 0;
  5366. this.deactivate();
  5367. this._actor = null;
  5368. };
  5369.  
  5370. Window_ActorCommand.prototype.windowWidth = function() {
  5371. return 192;
  5372. };
  5373.  
  5374. Window_ActorCommand.prototype.numVisibleRows = function() {
  5375. return 4;
  5376. };
  5377.  
  5378. Window_ActorCommand.prototype.makeCommandList = function() {
  5379. if (this._actor) {
  5380. this.addAttackCommand();
  5381. this.addSkillCommands();
  5382. this.addGuardCommand();
  5383. this.addItemCommand();
  5384. }
  5385. };
  5386.  
  5387. Window_ActorCommand.prototype.addAttackCommand = function() {
  5388. this.addCommand(TextManager.attack, 'attack', this._actor.canAttack());
  5389. };
  5390.  
  5391. Window_ActorCommand.prototype.addSkillCommands = function() {
  5392. var skillTypes = this._actor.addedSkillTypes();
  5393. skillTypes.sort(function(a, b) {
  5394. return a - b;
  5395. });
  5396. skillTypes.forEach(function(stypeId) {
  5397. var name = $dataSystem.skillTypes[stypeId];
  5398. this.addCommand(name, 'skill', true, stypeId);
  5399. }, this);
  5400. };
  5401.  
  5402. Window_ActorCommand.prototype.addGuardCommand = function() {
  5403. this.addCommand(TextManager.guard, 'guard', this._actor.canGuard());
  5404. };
  5405.  
  5406. Window_ActorCommand.prototype.addItemCommand = function() {
  5407. this.addCommand(TextManager.item, 'item');
  5408. };
  5409.  
  5410. Window_ActorCommand.prototype.setup = function(actor) {
  5411. this._actor = actor;
  5412. this.clearCommandList();
  5413. this.makeCommandList();
  5414. this.refresh();
  5415. this.selectLast();
  5416. this.activate();
  5417. this.open();
  5418. };
  5419.  
  5420. Window_ActorCommand.prototype.processOk = function() {
  5421. if (this._actor) {
  5422. if (ConfigManager.commandRemember) {
  5423. this._actor.setLastCommandSymbol(this.currentSymbol());
  5424. } else {
  5425. this._actor.setLastCommandSymbol('');
  5426. }
  5427. }
  5428. Window_Command.prototype.processOk.call(this);
  5429. };
  5430.  
  5431. Window_ActorCommand.prototype.selectLast = function() {
  5432. this.select(0);
  5433. if (this._actor && ConfigManager.commandRemember) {
  5434. var symbol = this._actor.lastCommandSymbol();
  5435. this.selectSymbol(symbol);
  5436. if (symbol === 'skill') {
  5437. var skill = this._actor.lastBattleSkill();
  5438. if (skill) {
  5439. this.selectExt(skill.stypeId);
  5440. }
  5441. }
  5442. }
  5443. };
  5444.  
  5445. //-----------------------------------------------------------------------------
  5446. // Window_BattleStatus
  5447. //
  5448. // The window for displaying the status of party members on the battle screen.
  5449.  
  5450. function Window_BattleStatus() {
  5451. this.initialize.apply(this, arguments);
  5452. }
  5453.  
  5454. Window_BattleStatus.prototype = Object.create(Window_Selectable.prototype);
  5455. Window_BattleStatus.prototype.constructor = Window_BattleStatus;
  5456.  
  5457. Window_BattleStatus.prototype.initialize = function() {
  5458. var width = this.windowWidth();
  5459. var height = this.windowHeight();
  5460. var x = Graphics.boxWidth - width;
  5461. var y = Graphics.boxHeight - height;
  5462. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  5463. this.refresh();
  5464. this.openness = 0;
  5465. };
  5466.  
  5467. Window_BattleStatus.prototype.windowWidth = function() {
  5468. return Graphics.boxWidth - 192;
  5469. };
  5470.  
  5471. Window_BattleStatus.prototype.windowHeight = function() {
  5472. return this.fittingHeight(this.numVisibleRows());
  5473. };
  5474.  
  5475. Window_BattleStatus.prototype.numVisibleRows = function() {
  5476. return 4;
  5477. };
  5478.  
  5479. Window_BattleStatus.prototype.maxItems = function() {
  5480. return $gameParty.battleMembers().length;
  5481. };
  5482.  
  5483. Window_BattleStatus.prototype.refresh = function() {
  5484. this.contents.clear();
  5485. this.drawAllItems();
  5486. };
  5487.  
  5488. Window_BattleStatus.prototype.drawItem = function(index) {
  5489. var actor = $gameParty.battleMembers()[index];
  5490. this.drawBasicArea(this.basicAreaRect(index), actor);
  5491. this.drawGaugeArea(this.gaugeAreaRect(index), actor);
  5492. };
  5493.  
  5494. Window_BattleStatus.prototype.basicAreaRect = function(index) {
  5495. var rect = this.itemRectForText(index);
  5496. rect.width -= this.gaugeAreaWidth() + 15;
  5497. return rect;
  5498. };
  5499.  
  5500. Window_BattleStatus.prototype.gaugeAreaRect = function(index) {
  5501. var rect = this.itemRectForText(index);
  5502. rect.x += rect.width - this.gaugeAreaWidth();
  5503. rect.width = this.gaugeAreaWidth();
  5504. return rect;
  5505. };
  5506.  
  5507. Window_BattleStatus.prototype.gaugeAreaWidth = function() {
  5508. return 330;
  5509. };
  5510.  
  5511. Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
  5512. this.drawActorName(actor, rect.x + 0, rect.y, 150);
  5513. this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
  5514. };
  5515.  
  5516. Window_BattleStatus.prototype.drawGaugeArea = function(rect, actor) {
  5517. if ($dataSystem.optDisplayTp) {
  5518. this.drawGaugeAreaWithTp(rect, actor);
  5519. } else {
  5520. this.drawGaugeAreaWithoutTp(rect, actor);
  5521. }
  5522. };
  5523.  
  5524. Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
  5525. this.drawActorHp(actor, rect.x + 0, rect.y, 108);
  5526. this.drawActorMp(actor, rect.x + 123, rect.y, 96);
  5527. this.drawActorTp(actor, rect.x + 234, rect.y, 96);
  5528. };
  5529.  
  5530. Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
  5531. this.drawActorHp(actor, rect.x + 0, rect.y, 201);
  5532. this.drawActorMp(actor, rect.x + 216, rect.y, 114);
  5533. };
  5534.  
  5535. //-----------------------------------------------------------------------------
  5536. // Window_BattleActor
  5537. //
  5538. // The window for selecting a target actor on the battle screen.
  5539.  
  5540. function Window_BattleActor() {
  5541. this.initialize.apply(this, arguments);
  5542. }
  5543.  
  5544. Window_BattleActor.prototype = Object.create(Window_BattleStatus.prototype);
  5545. Window_BattleActor.prototype.constructor = Window_BattleActor;
  5546.  
  5547. Window_BattleActor.prototype.initialize = function(x, y) {
  5548. Window_BattleStatus.prototype.initialize.call(this);
  5549. this.x = x;
  5550. this.y = y;
  5551. this.openness = 255;
  5552. this.hide();
  5553. };
  5554.  
  5555. Window_BattleActor.prototype.show = function() {
  5556. this.select(0);
  5557. Window_BattleStatus.prototype.show.call(this);
  5558. };
  5559.  
  5560. Window_BattleActor.prototype.hide = function() {
  5561. Window_BattleStatus.prototype.hide.call(this);
  5562. $gameParty.select(null);
  5563. };
  5564.  
  5565. Window_BattleActor.prototype.select = function(index) {
  5566. Window_BattleStatus.prototype.select.call(this, index);
  5567. $gameParty.select(this.actor());
  5568. };
  5569.  
  5570. Window_BattleActor.prototype.actor = function() {
  5571. return $gameParty.members()[this.index()];
  5572. };
  5573.  
  5574. //-----------------------------------------------------------------------------
  5575. // Window_BattleEnemy
  5576. //
  5577. // The window for selecting a target enemy on the battle screen.
  5578.  
  5579. function Window_BattleEnemy() {
  5580. this.initialize.apply(this, arguments);
  5581. }
  5582.  
  5583. Window_BattleEnemy.prototype = Object.create(Window_Selectable.prototype);
  5584. Window_BattleEnemy.prototype.constructor = Window_BattleEnemy;
  5585.  
  5586. Window_BattleEnemy.prototype.initialize = function(x, y) {
  5587. this._enemies = [];
  5588. var width = this.windowWidth();
  5589. var height = this.windowHeight();
  5590. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  5591. this.refresh();
  5592. this.hide();
  5593. };
  5594.  
  5595. Window_BattleEnemy.prototype.windowWidth = function() {
  5596. return Graphics.boxWidth - 192;
  5597. };
  5598.  
  5599. Window_BattleEnemy.prototype.windowHeight = function() {
  5600. return this.fittingHeight(this.numVisibleRows());
  5601. };
  5602.  
  5603. Window_BattleEnemy.prototype.numVisibleRows = function() {
  5604. return 4;
  5605. };
  5606.  
  5607. Window_BattleEnemy.prototype.maxCols = function() {
  5608. return 2;
  5609. };
  5610.  
  5611. Window_BattleEnemy.prototype.maxItems = function() {
  5612. return this._enemies.length;
  5613. };
  5614.  
  5615. Window_BattleEnemy.prototype.enemy = function() {
  5616. return this._enemies[this.index()];
  5617. };
  5618.  
  5619. Window_BattleEnemy.prototype.enemyIndex = function() {
  5620. var enemy = this.enemy();
  5621. return enemy ? enemy.index() : -1;
  5622. };
  5623.  
  5624. Window_BattleEnemy.prototype.drawItem = function(index) {
  5625. this.resetTextColor();
  5626. var name = this._enemies[index].name();
  5627. var rect = this.itemRectForText(index);
  5628. this.drawText(name, rect.x, rect.y, rect.width);
  5629. };
  5630.  
  5631. Window_BattleEnemy.prototype.show = function() {
  5632. this.refresh();
  5633. this.select(0);
  5634. Window_Selectable.prototype.show.call(this);
  5635. };
  5636.  
  5637. Window_BattleEnemy.prototype.hide = function() {
  5638. Window_Selectable.prototype.hide.call(this);
  5639. $gameTroop.select(null);
  5640. };
  5641.  
  5642. Window_BattleEnemy.prototype.refresh = function() {
  5643. this._enemies = $gameTroop.aliveMembers();
  5644. Window_Selectable.prototype.refresh.call(this);
  5645. };
  5646.  
  5647. Window_BattleEnemy.prototype.select = function(index) {
  5648. Window_Selectable.prototype.select.call(this, index);
  5649. $gameTroop.select(this.enemy());
  5650. };
  5651.  
  5652. //-----------------------------------------------------------------------------
  5653. // Window_BattleSkill
  5654. //
  5655. // The window for selecting a skill to use on the battle screen.
  5656.  
  5657. function Window_BattleSkill() {
  5658. this.initialize.apply(this, arguments);
  5659. }
  5660.  
  5661. Window_BattleSkill.prototype = Object.create(Window_SkillList.prototype);
  5662. Window_BattleSkill.prototype.constructor = Window_BattleSkill;
  5663.  
  5664. Window_BattleSkill.prototype.initialize = function(x, y, width, height) {
  5665. Window_SkillList.prototype.initialize.call(this, x, y, width, height);
  5666. this.hide();
  5667. };
  5668.  
  5669. Window_BattleSkill.prototype.show = function() {
  5670. this.selectLast();
  5671. this.showHelpWindow();
  5672. Window_SkillList.prototype.show.call(this);
  5673. };
  5674.  
  5675. Window_BattleSkill.prototype.hide = function() {
  5676. this.hideHelpWindow();
  5677. Window_SkillList.prototype.hide.call(this);
  5678. };
  5679.  
  5680. //-----------------------------------------------------------------------------
  5681. // Window_BattleItem
  5682. //
  5683. // The window for selecting an item to use on the battle screen.
  5684.  
  5685. function Window_BattleItem() {
  5686. this.initialize.apply(this, arguments);
  5687. }
  5688.  
  5689. Window_BattleItem.prototype = Object.create(Window_ItemList.prototype);
  5690. Window_BattleItem.prototype.constructor = Window_BattleItem;
  5691.  
  5692. Window_BattleItem.prototype.initialize = function(x, y, width, height) {
  5693. Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  5694. this.hide();
  5695. };
  5696.  
  5697. Window_BattleItem.prototype.includes = function(item) {
  5698. return $gameParty.canUse(item);
  5699. };
  5700.  
  5701. Window_BattleItem.prototype.show = function() {
  5702. this.selectLast();
  5703. this.showHelpWindow();
  5704. Window_ItemList.prototype.show.call(this);
  5705. };
  5706.  
  5707. Window_BattleItem.prototype.hide = function() {
  5708. this.hideHelpWindow();
  5709. Window_ItemList.prototype.hide.call(this);
  5710. };
  5711.  
  5712. //-----------------------------------------------------------------------------
  5713. // Window_TitleCommand
  5714. //
  5715. // The window for selecting New Game/Continue on the title screen.
  5716.  
  5717. function Window_TitleCommand() {
  5718. this.initialize.apply(this, arguments);
  5719. }
  5720.  
  5721. Window_TitleCommand.prototype = Object.create(Window_Command.prototype);
  5722. Window_TitleCommand.prototype.constructor = Window_TitleCommand;
  5723.  
  5724. Window_TitleCommand.prototype.initialize = function() {
  5725. Window_Command.prototype.initialize.call(this, 0, 0);
  5726. this.updatePlacement();
  5727. this.openness = 0;
  5728. this.selectLast();
  5729. };
  5730.  
  5731. Window_TitleCommand._lastCommandSymbol = null;
  5732.  
  5733. Window_TitleCommand.initCommandPosition = function() {
  5734. this._lastCommandSymbol = null;
  5735. };
  5736.  
  5737. Window_TitleCommand.prototype.windowWidth = function() {
  5738. return 240;
  5739. };
  5740.  
  5741. Window_TitleCommand.prototype.updatePlacement = function() {
  5742. this.x = (Graphics.boxWidth - this.width) / 2;
  5743. this.y = Graphics.boxHeight - this.height - 96;
  5744. };
  5745.  
  5746. Window_TitleCommand.prototype.makeCommandList = function() {
  5747. this.addCommand(TextManager.newGame, 'newGame');
  5748. this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
  5749. this.addCommand(TextManager.options, 'options');
  5750. };
  5751.  
  5752. Window_TitleCommand.prototype.isContinueEnabled = function() {
  5753. return DataManager.isAnySavefileExists();
  5754. };
  5755.  
  5756. Window_TitleCommand.prototype.processOk = function() {
  5757. Window_TitleCommand._lastCommandSymbol = this.currentSymbol();
  5758. Window_Command.prototype.processOk.call(this);
  5759. };
  5760.  
  5761. Window_TitleCommand.prototype.selectLast = function() {
  5762. if (Window_TitleCommand._lastCommandSymbol) {
  5763. this.selectSymbol(Window_TitleCommand._lastCommandSymbol);
  5764. } else if (this.isContinueEnabled()) {
  5765. this.selectSymbol('continue');
  5766. }
  5767. };
  5768.  
  5769. //-----------------------------------------------------------------------------
  5770. // Window_GameEnd
  5771. //
  5772. // The window for selecting "Go to Title" on the game end screen.
  5773.  
  5774. function Window_GameEnd() {
  5775. this.initialize.apply(this, arguments);
  5776. }
  5777.  
  5778. Window_GameEnd.prototype = Object.create(Window_Command.prototype);
  5779. Window_GameEnd.prototype.constructor = Window_GameEnd;
  5780.  
  5781. Window_GameEnd.prototype.initialize = function() {
  5782. Window_Command.prototype.initialize.call(this, 0, 0);
  5783. this.updatePlacement();
  5784. this.openness = 0;
  5785. this.open();
  5786. };
  5787.  
  5788. Window_GameEnd.prototype.windowWidth = function() {
  5789. return 240;
  5790. };
  5791.  
  5792. Window_GameEnd.prototype.updatePlacement = function() {
  5793. this.x = (Graphics.boxWidth - this.width) / 2;
  5794. this.y = (Graphics.boxHeight - this.height) / 2;
  5795. };
  5796.  
  5797. Window_GameEnd.prototype.makeCommandList = function() {
  5798. this.addCommand(TextManager.toTitle, 'toTitle');
  5799. this.addCommand(TextManager.cancel, 'cancel');
  5800. };
  5801.  
  5802. //-----------------------------------------------------------------------------
  5803. // Window_DebugRange
  5804. //
  5805. // The window for selecting a block of switches/variables on the debug screen.
  5806.  
  5807. function Window_DebugRange() {
  5808. this.initialize.apply(this, arguments);
  5809. }
  5810.  
  5811. Window_DebugRange.prototype = Object.create(Window_Selectable.prototype);
  5812. Window_DebugRange.prototype.constructor = Window_DebugRange;
  5813.  
  5814. Window_DebugRange.lastTopRow = 0;
  5815. Window_DebugRange.lastIndex = 0;
  5816.  
  5817. Window_DebugRange.prototype.initialize = function(x, y) {
  5818. this._maxSwitches = Math.ceil(($dataSystem.switches.length - 1) / 10);
  5819. this._maxVariables = Math.ceil(($dataSystem.variables.length - 1) / 10);
  5820. var width = this.windowWidth();
  5821. var height = this.windowHeight();
  5822. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  5823. this.refresh();
  5824. this.setTopRow(Window_DebugRange.lastTopRow);
  5825. this.select(Window_DebugRange.lastIndex);
  5826. this.activate();
  5827. };
  5828.  
  5829. Window_DebugRange.prototype.windowWidth = function() {
  5830. return 246;
  5831. };
  5832.  
  5833. Window_DebugRange.prototype.windowHeight = function() {
  5834. return Graphics.boxHeight;
  5835. };
  5836.  
  5837. Window_DebugRange.prototype.maxItems = function() {
  5838. return this._maxSwitches + this._maxVariables;
  5839. };
  5840.  
  5841. Window_DebugRange.prototype.update = function() {
  5842. Window_Selectable.prototype.update.call(this);
  5843. if (this._editWindow) {
  5844. this._editWindow.setMode(this.mode());
  5845. this._editWindow.setTopId(this.topId());
  5846. }
  5847. };
  5848.  
  5849. Window_DebugRange.prototype.mode = function() {
  5850. return this.index() < this._maxSwitches ? 'switch' : 'variable';
  5851. };
  5852.  
  5853. Window_DebugRange.prototype.topId = function() {
  5854. var index = this.index();
  5855. if (index < this._maxSwitches) {
  5856. return index * 10 + 1;
  5857. } else {
  5858. return (index - this._maxSwitches) * 10 + 1;
  5859. }
  5860. };
  5861.  
  5862. Window_DebugRange.prototype.refresh = function() {
  5863. this.createContents();
  5864. this.drawAllItems();
  5865. };
  5866.  
  5867. Window_DebugRange.prototype.drawItem = function(index) {
  5868. var rect = this.itemRectForText(index);
  5869. var start;
  5870. var text;
  5871. if (index < this._maxSwitches) {
  5872. start = index * 10 + 1;
  5873. text = 'S';
  5874. } else {
  5875. start = (index - this._maxSwitches) * 10 + 1;
  5876. text = 'V';
  5877. }
  5878. var end = start + 9;
  5879. text += ' [' + start.padZero(4) + '-' + end.padZero(4) + ']';
  5880. this.drawText(text, rect.x, rect.y, rect.width);
  5881. };
  5882.  
  5883. Window_DebugRange.prototype.isCancelTriggered = function() {
  5884. return (Window_Selectable.prototype.isCancelTriggered() ||
  5885. Input.isTriggered('debug'));
  5886. };
  5887.  
  5888. Window_DebugRange.prototype.processCancel = function() {
  5889. Window_Selectable.prototype.processCancel.call(this);
  5890. Window_DebugRange.lastTopRow = this.topRow();
  5891. Window_DebugRange.lastIndex = this.index();
  5892. };
  5893.  
  5894. Window_DebugRange.prototype.setEditWindow = function(editWindow) {
  5895. this._editWindow = editWindow;
  5896. this.update();
  5897. };
  5898.  
  5899. //-----------------------------------------------------------------------------
  5900. // Window_DebugEdit
  5901. //
  5902. // The window for displaying switches and variables on the debug screen.
  5903.  
  5904. function Window_DebugEdit() {
  5905. this.initialize.apply(this, arguments);
  5906. }
  5907.  
  5908. Window_DebugEdit.prototype = Object.create(Window_Selectable.prototype);
  5909. Window_DebugEdit.prototype.constructor = Window_DebugEdit;
  5910.  
  5911. Window_DebugEdit.prototype.initialize = function(x, y, width) {
  5912. var height = this.fittingHeight(10);
  5913. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  5914. this._mode = 'switch';
  5915. this._topId = 1;
  5916. this.refresh();
  5917. };
  5918.  
  5919. Window_DebugEdit.prototype.maxItems = function() {
  5920. return 10;
  5921. };
  5922.  
  5923. Window_DebugEdit.prototype.refresh = function() {
  5924. this.contents.clear();
  5925. this.drawAllItems();
  5926. };
  5927.  
  5928. Window_DebugEdit.prototype.drawItem = function(index) {
  5929. var dataId = this._topId + index;
  5930. var idText = dataId.padZero(4) + ':';
  5931. var idWidth = this.textWidth(idText);
  5932. var statusWidth = this.textWidth('-00000000');
  5933. var name = this.itemName(dataId);
  5934. var status = this.itemStatus(dataId);
  5935. var rect = this.itemRectForText(index);
  5936. this.resetTextColor();
  5937. this.drawText(idText, rect.x, rect.y, rect.width);
  5938. rect.x += idWidth;
  5939. rect.width -= idWidth + statusWidth;
  5940. this.drawText(name, rect.x, rect.y, rect.width);
  5941. this.drawText(status, rect.x + rect.width, rect.y, statusWidth, 'right');
  5942. };
  5943.  
  5944. Window_DebugEdit.prototype.itemName = function(dataId) {
  5945. if (this._mode === 'switch') {
  5946. return $dataSystem.switches[dataId];
  5947. } else {
  5948. return $dataSystem.variables[dataId];
  5949. }
  5950. };
  5951.  
  5952. Window_DebugEdit.prototype.itemStatus = function(dataId) {
  5953. if (this._mode === 'switch') {
  5954. return $gameSwitches.value(dataId) ? '[ON]' : '[OFF]';
  5955. } else {
  5956. return String($gameVariables.value(dataId));
  5957. }
  5958. };
  5959.  
  5960. Window_DebugEdit.prototype.setMode = function(mode) {
  5961. if (this._mode !== mode) {
  5962. this._mode = mode;
  5963. this.refresh();
  5964. }
  5965. };
  5966.  
  5967. Window_DebugEdit.prototype.setTopId = function(id) {
  5968. if (this._topId !== id) {
  5969. this._topId = id;
  5970. this.refresh();
  5971. }
  5972. };
  5973.  
  5974. Window_DebugEdit.prototype.currentId = function() {
  5975. return this._topId + this.index();
  5976. };
  5977.  
  5978. Window_DebugEdit.prototype.update = function() {
  5979. Window_Selectable.prototype.update.call(this);
  5980. if (this.active) {
  5981. if (this._mode === 'switch') {
  5982. this.updateSwitch();
  5983. } else {
  5984. this.updateVariable();
  5985. }
  5986. }
  5987. };
  5988.  
  5989. Window_DebugEdit.prototype.updateSwitch = function() {
  5990. if (Input.isRepeated('ok')) {
  5991. var switchId = this.currentId();
  5992. SoundManager.playCursor();
  5993. $gameSwitches.setValue(switchId, !$gameSwitches.value(switchId));
  5994. this.redrawCurrentItem();
  5995. }
  5996. };
  5997.  
  5998. Window_DebugEdit.prototype.updateVariable = function() {
  5999. var variableId = this.currentId();
  6000. var value = $gameVariables.value(variableId);
  6001. if (typeof value === 'number') {
  6002. if (Input.isRepeated('right')) {
  6003. value++;
  6004. }
  6005. if (Input.isRepeated('left')) {
  6006. value--;
  6007. }
  6008. if (Input.isRepeated('pagedown')) {
  6009. value += 10;
  6010. }
  6011. if (Input.isRepeated('pageup')) {
  6012. value -= 10;
  6013. }
  6014. if ($gameVariables.value(variableId) !== value) {
  6015. $gameVariables.setValue(variableId, value);
  6016. SoundManager.playCursor();
  6017. this.redrawCurrentItem();
  6018. }
  6019. }
  6020. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement