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