Advertisement
GaleCelme94

rpg_windows.js

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