1//============================================================================= 2// rpg_scenes.js 3//============================================================================= 4 5//----------------------------------------------------------------------------- 6// Scene_Base 7// 8// The superclass of all scenes within the game. 9 10function Scene_Base() { 11 this.initialize.apply(this, arguments); 12} 13 14Scene_Base.prototype = Object.create(Stage.prototype); 15Scene_Base.prototype.constructor = Scene_Base; 16 17Scene_Base.prototype.initialize = function() { 18 Stage.prototype.initialize.call(this); 19 this._active = false; 20 this._fadeSign = 0; 21 this._fadeDuration = 0; 22 this._fadeSprite = null; 23}; 24 25Scene_Base.prototype.create = function() { 26}; 27 28Scene_Base.prototype.isActive = function() { 29 return this._active; 30}; 31 32Scene_Base.prototype.isReady = function() { 33 return ImageManager.isReady(); 34}; 35 36Scene_Base.prototype.start = function() { 37 this._active = true; 38}; 39 40Scene_Base.prototype.update = function() { 41 this.updateFade(); 42 this.updateChildren(); 43 AudioManager.checkErrors(); 44}; 45 46Scene_Base.prototype.stop = function() { 47 this._active = false; 48}; 49 50Scene_Base.prototype.isBusy = function() { 51 return this._fadeDuration > 0; 52}; 53 54Scene_Base.prototype.terminate = function() { 55}; 56 57Scene_Base.prototype.createWindowLayer = function() { 58 var width = Graphics.boxWidth; 59 var height = Graphics.boxHeight; 60 var x = (Graphics.width - width) / 2; 61 var y = (Graphics.height - height) / 2; 62 this._windowLayer = new WindowLayer(); 63 this._windowLayer.move(x, y, width, height); 64 this.addChild(this._windowLayer); 65}; 66 67Scene_Base.prototype.addWindow = function(window) { 68 this._windowLayer.addChild(window); 69}; 70 71Scene_Base.prototype.startFadeIn = function(duration, white) { 72 this.createFadeSprite(white); 73 this._fadeSign = 1; 74 this._fadeDuration = duration || 30; 75 this._fadeSprite.opacity = 255; 76}; 77 78Scene_Base.prototype.startFadeOut = function(duration, white) { 79 this.createFadeSprite(white); 80 this._fadeSign = -1; 81 this._fadeDuration = duration || 30; 82 this._fadeSprite.opacity = 0; 83}; 84 85Scene_Base.prototype.createFadeSprite = function(white) { 86 if (!this._fadeSprite) { 87 this._fadeSprite = new ScreenSprite(); 88 this.addChild(this._fadeSprite); 89 } 90 if (white) { 91 this._fadeSprite.setWhite(); 92 } else { 93 this._fadeSprite.setBlack(); 94 } 95}; 96 97Scene_Base.prototype.updateFade = function() { 98 if (this._fadeDuration > 0) { 99 var d = this._fadeDuration; 100 if (this._fadeSign > 0) { 101 this._fadeSprite.opacity -= this._fadeSprite.opacity / d; 102 } else { 103 this._fadeSprite.opacity += (255 - this._fadeSprite.opacity) / d; 104 } 105 this._fadeDuration--; 106 } 107}; 108 109Scene_Base.prototype.updateChildren = function() { 110 this.children.forEach(function(child) { 111 if (child.update) { 112 child.update(); 113 } 114 }); 115}; 116 117Scene_Base.prototype.popScene = function() { 118 SceneManager.pop(); 119}; 120 121Scene_Base.prototype.checkGameover = function() { 122 if ($gameParty.isAllDead()) { 123 SceneManager.goto(Scene_Gameover); 124 } 125}; 126 127Scene_Base.prototype.fadeOutAll = function() { 128 var time = this.slowFadeSpeed() / 60; 129 AudioManager.fadeOutBgm(time); 130 AudioManager.fadeOutBgs(time); 131 AudioManager.fadeOutMe(time); 132 this.startFadeOut(this.slowFadeSpeed()); 133}; 134 135Scene_Base.prototype.fadeSpeed = function() { 136 return 24; 137}; 138 139Scene_Base.prototype.slowFadeSpeed = function() { 140 return this.fadeSpeed() * 2; 141}; 142 143//----------------------------------------------------------------------------- 144// Scene_Boot 145// 146// The scene class for initializing the entire game. 147 148function Scene_Boot() { 149 this.initialize.apply(this, arguments); 150} 151 152Scene_Boot.prototype = Object.create(Scene_Base.prototype); 153Scene_Boot.prototype.constructor = Scene_Boot; 154 155Scene_Boot.prototype.initialize = function() { 156 Scene_Base.prototype.initialize.call(this); 157 this._startDate = Date.now(); 158}; 159 160Scene_Boot.prototype.create = function() { 161 Scene_Base.prototype.create.call(this); 162 DataManager.loadDatabase(); 163 ConfigManager.load(); 164 this.loadSystemImages(); 165}; 166 167Scene_Boot.prototype.loadSystemImages = function() { 168 ImageManager.loadSystem('Window'); 169 ImageManager.loadSystem('IconSet'); 170 ImageManager.loadSystem('Balloon'); 171 ImageManager.loadSystem('Shadow1'); 172 ImageManager.loadSystem('Shadow2'); 173 ImageManager.loadSystem('Damage'); 174 ImageManager.loadSystem('States'); 175 ImageManager.loadSystem('Weapons1'); 176 ImageManager.loadSystem('Weapons2'); 177 ImageManager.loadSystem('Weapons3'); 178 ImageManager.loadSystem('ButtonSet'); 179}; 180 181Scene_Boot.prototype.isReady = function() { 182 if (Scene_Base.prototype.isReady.call(this)) { 183 return DataManager.isDatabaseLoaded() && this.isGameFontLoaded(); 184 } else { 185 return false;
186 } 187}; 188 189Scene_Boot.prototype.isGameFontLoaded = function() { 190 if (Graphics.isFontLoaded('GameFont')) { 191 return true; 192 } else { 193 var elapsed = Date.now() - this._startDate; 194 if (elapsed >= 20000) { 195 throw new Error('Failed to load GameFont'); 196 } 197 } 198}; 199 200Scene_Boot.prototype.start = function() { 201 Scene_Base.prototype.start.call(this); 202 SoundManager.preloadImportantSounds(); 203 if (DataManager.isBattleTest()) { 204 DataManager.setupBattleTest(); 205 SceneManager.goto(Scene_Battle); 206 } else if (DataManager.isEventTest()) { 207 DataManager.setupEventTest(); 208 SceneManager.goto(Scene_Map); 209 } else { 210 this.checkPlayerLocation(); 211 DataManager.setupNewGame(); 212 SceneManager.goto(Scene_Title); 213 Window_TitleCommand.initCommandPosition(); 214 } 215 this.updateDocumentTitle(); 216}; 217 218Scene_Boot.prototype.updateDocumentTitle = function() { 219 document.title = $dataSystem.gameTitle; 220}; 221 222Scene_Boot.prototype.checkPlayerLocation = function() { 223 if ($dataSystem.startMapId === 0) { 224 throw new Error('Player\'s starting position is not set'); 225 } 226}; 227 228//----------------------------------------------------------------------------- 229// Scene_Title 230// 231// The scene class of the title screen. 232 233function Scene_Title() { 234 this.initialize.apply(this, arguments); 235} 236 237Scene_Title.prototype = Object.create(Scene_Base.prototype); 238Scene_Title.prototype.constructor = Scene_Title; 239 240Scene_Title.prototype.initialize = function() { 241 Scene_Base.prototype.initialize.call(this); 242}; 243 244Scene_Title.prototype.create = function() { 245 Scene_Base.prototype.create.call(this); 246 this.createBackground(); 247 this.createForeground(); 248 this.createWindowLayer(); 249 this.createCommandWindow(); 250}; 251 252Scene_Title.prototype.start = function() { 253 Scene_Base.prototype.start.call(this); 254 SceneManager.clearStack(); 255 this.centerSprite(this._backSprite1); 256 this.centerSprite(this._backSprite2); 257 this.playTitleMusic(); 258 this.startFadeIn(this.fadeSpeed(), false); 259}; 260 261Scene_Title.prototype.update = function() { 262 if (!this.isBusy()) { 263 this._commandWindow.open(); 264 } 265 Scene_Base.prototype.update.call(this); 266}; 267 268Scene_Title.prototype.isBusy = function() { 269 return this._commandWindow.isClosing() || Scene_Base.prototype.isBusy.call(this); 270}; 271 272Scene_Title.prototype.terminate = function() { 273 Scene_Base.prototype.terminate.call(this);
274 SceneManager.snapForBackground(); 275}; 276 277Scene_Title.prototype.createBackground = function() { 278 this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name)); 279 this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name)); 280 this.addChild(this._backSprite1); 281 this.addChild(this._backSprite2); 282}; 283 284Scene_Title.prototype.createForeground = function() { 285 this._gameTitleSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height)); 286 this.addChild(this._gameTitleSprite); 287 if ($dataSystem.optDrawTitle) { 288 this.drawGameTitle(); 289 } 290}; 291 292Scene_Title.prototype.drawGameTitle = function() { 293 var x = 20; 294 var y = Graphics.height / 4; 295 var maxWidth = Graphics.width - x * 2; 296 var text = $dataSystem.gameTitle; 297 this._gameTitleSprite.bitmap.outlineColor = 'black'; 298 this._gameTitleSprite.bitmap.outlineWidth = 8; 299 this._gameTitleSprite.bitmap.fontSize = 72; 300 this._gameTitleSprite.bitmap.drawText(text, x, y, maxWidth, 48, 'center'); 301}; 302 303Scene_Title.prototype.centerSprite = function(sprite) { 304 sprite.x = Graphics.width / 2; 305 sprite.y = Graphics.height / 2; 306 sprite.anchor.x = 0.5; 307 sprite.anchor.y = 0.5; 308}; 309 310Scene_Title.prototype.createCommandWindow = function() { 311 this._commandWindow = new Window_TitleCommand(); 312 this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this)); 313 this._commandWindow.setHandler('continue', this.commandContinue.bind(this)); 314 this._commandWindow.setHandler('options', this.commandOptions.bind(this)); 315 this.addWindow(this._commandWindow); 316}; 317 318Scene_Title.prototype.commandNewGame = function() { 319 DataManager.setupNewGame(); 320 this._commandWindow.close(); 321 this.fadeOutAll(); 322 SceneManager.goto(Scene_Map); 323}; 324 325Scene_Title.prototype.commandContinue = function() { 326 this._commandWindow.close(); 327 SceneManager.push(Scene_Load); 328}; 329 330Scene_Title.prototype.commandOptions = function() { 331 this._commandWindow.close(); 332 SceneManager.push(Scene_Options); 333}; 334 335Scene_Title.prototype.playTitleMusic = function() { 336 AudioManager.playBgm($dataSystem.titleBgm); 337 AudioManager.stopBgs(); 338 AudioManager.stopMe(); 339}; 340 341//----------------------------------------------------------------------------- 342// Scene_Map 343// 344// The scene class of the map screen. 345 346function Scene_Map() { 347 this.initialize.apply(this, arguments); 348} 349 350Scene_Map.prototype = Object.create(Scene_Base.prototype); 351Scene_Map.prototype.constructor = Scene_Map; 352 353Scene_Map.prototype.initialize = function() { 354 Scene_Base.prototype.initialize.call(this); 355 this._waitCount = 0; 356 this._encounterEffectDuration = 0; 357 this._mapLoaded = false; 358 this._touchCount = 0; 359}; 360 361Scene_Map.prototype.create = function() { 362 Scene_Base.prototype.create.call(this); 363 this._transfer = $gamePlayer.isTransferring(); 364 var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId(); 365 DataManager.loadMapData(mapId); 366}; 367 368Scene_Map.prototype.isReady = function() { 369 if (!this._mapLoaded && DataManager.isMapLoaded()) { 370 this.onMapLoaded(); 371 this._mapLoaded = true; 372 } 373 return this._mapLoaded && Scene_Base.prototype.isReady.call(this); 374}; 375 376Scene_Map.prototype.onMapLoaded = function() { 377 if (this._transfer) { 378 $gamePlayer.performTransfer(); 379 } 380 this.createDisplayObjects(); 381}; 382 383Scene_Map.prototype.start = function() { 384 Scene_Base.prototype.start.call(this); 385 SceneManager.clearStack(); 386 if (this._transfer) { 387 this.fadeInForTransfer(); 388 this._mapNameWindow.open(); 389 $gameMap.autoplay(); 390 } else if (this.needsFadeIn()) { 391 this.startFadeIn(this.fadeSpeed(), false); 392 } 393 this.menuCalling = false; 394}; 395 396Scene_Map.prototype.update = function() { 397 this.updateDestination(); 398 this.updateMainMultiply(); 399 if (this.isSceneChangeOk()) { 400 this.updateScene(); 401 } else if (SceneManager.isNextScene(Scene_Battle)) { 402 this.updateEncounterEffect(); 403 } 404 this.updateWaitCount(); 405 Scene_Base.prototype.update.call(this); 406}; 407 408Scene_Map.prototype.updateMainMultiply = function() { 409 this.updateMain(); 410 if (this.isFastForward()) { 411 this.updateMain(); 412 } 413}; 414 415Scene_Map.prototype.updateMain = function() { 416 var active = this.isActive(); 417 $gameMap.update(active); 418 $gamePlayer.update(active); 419 $gameTimer.update(active); 420 $gameScreen.update(); 421}; 422 423Scene_Map.prototype.isFastForward = function() { 424 return ($gameMap.isEventRunning() && !SceneManager.isSceneChanging() && 425 (Input.isLongPressed('ok') || TouchInput.isLongPressed())); 426}; 427 428Scene_Map.prototype.stop = function() { 429 Scene_Base.prototype.stop.call(this); 430 $gamePlayer.straighten(); 431 this._mapNameWindow.close(); 432 if (this.needsSlowFadeOut()) { 433 this.startFadeOut(this.slowFadeSpeed(), false); 434 } else if (SceneManager.isNextScene(Scene_Map)) { 435 this.fadeOutForTransfer(); 436 } else if (SceneManager.isNextScene(Scene_Battle)) { 437 this.launchBattle(); 438 } 439}; 440 441Scene_Map.prototype.isBusy = function() { 442 return ((this._messageWindow && this._messageWindow.isClosing()) || 443 this._waitCount > 0 || this._encounterEffectDuration > 0 || 444 Scene_Base.prototype.isBusy.call(this)); 445}; 446 447Scene_Map.prototype.terminate = function() { 448 Scene_Base.prototype.terminate.call(this); 449 if (!SceneManager.isNextScene(Scene_Battle)) {
450 this._spriteset.update(); 451 this._mapNameWindow.hide(); 452 SceneManager.snapForBackground(); 453 } 454 $gameScreen.clearZoom(); 455}; 456 457Scene_Map.prototype.needsFadeIn = function() { 458 return (SceneManager.isPreviousScene(Scene_Battle) || 459 SceneManager.isPreviousScene(Scene_Load)); 460}; 461 462Scene_Map.prototype.needsSlowFadeOut = function() { 463 return (SceneManager.isNextScene(Scene_Title) || 464 SceneManager.isNextScene(Scene_Gameover)); 465}; 466 467Scene_Map.prototype.updateWaitCount = function() { 468 if (this._waitCount > 0) { 469 this._waitCount--; 470 return true; 471 } 472 return false; 473}; 474 475Scene_Map.prototype.updateDestination = function() { 476 if (this.isMapTouchOk()) { 477 this.processMapTouch(); 478 } else { 479 $gameTemp.clearDestination(); 480 this._touchCount = 0; 481 } 482}; 483 484Scene_Map.prototype.isMapTouchOk = function() { 485 return this.isActive() && $gamePlayer.canMove(); 486}; 487 488Scene_Map.prototype.processMapTouch = function() { 489 if (TouchInput.isTriggered() || this._touchCount > 0) { 490 if (TouchInput.isPressed()) { 491 if (this._touchCount === 0 || this._touchCount >= 15) { 492 var x = $gameMap.canvasToMapX(TouchInput.x); 493 var y = $gameMap.canvasToMapY(TouchInput.y); 494 $gameTemp.setDestination(x, y); 495 } 496 this._touchCount++; 497 } else { 498 this._touchCount = 0; 499 } 500 } 501}; 502 503Scene_Map.prototype.isSceneChangeOk = function() { 504 return this.isActive() && !$gameMessage.isBusy(); 505}; 506 507Scene_Map.prototype.updateScene = function() { 508 this.checkGameover(); 509 if (!SceneManager.isSceneChanging()) { 510 this.updateTransferPlayer(); 511 } 512 if (!SceneManager.isSceneChanging()) { 513 this.updateEncounter(); 514 } 515 if (!SceneManager.isSceneChanging()) { 516 this.updateCallMenu(); 517 } 518 if (!SceneManager.isSceneChanging()) { 519 this.updateCallDebug(); 520 } 521}; 522 523Scene_Map.prototype.createDisplayObjects = function() { 524 this.createSpriteset(); 525 this.createMapNameWindow(); 526 this.createWindowLayer(); 527 this.createAllWindows(); 528}; 529 530Scene_Map.prototype.createSpriteset = function() { 531 this._spriteset = new Spriteset_Map(); 532 this.addChild(this._spriteset); 533}; 534 535Scene_Map.prototype.createAllWindows = function() { 536 this.createMessageWindow(); 537 this.createScrollTextWindow(); 538}; 539 540Scene_Map.prototype.createMapNameWindow = function() { 541 this._mapNameWindow = new Window_MapName(); 542 this.addChild(this._mapNameWindow); 543}; 544 545Scene_Map.prototype.createMessageWindow = function() { 546 this._messageWindow = new Window_Message(); 547 this.addWindow(this._messageWindow); 548 this._messageWindow.subWindows().forEach(function(window) { 549 this.addWindow(window); 550 }, this); 551}; 552 553Scene_Map.prototype.createScrollTextWindow = function() { 554 this._scrollTextWindow = new Window_ScrollText(); 555 this.addWindow(this._scrollTextWindow); 556}; 557 558Scene_Map.prototype.updateTransferPlayer = function() { 559 if ($gamePlayer.isTransferring()) { 560 SceneManager.goto(Scene_Map); 561 } 562}; 563 564Scene_Map.prototype.updateEncounter = function() { 565 if ($gamePlayer.executeEncounter()) { 566 SceneManager.push(Scene_Battle); 567 } 568}; 569 570Scene_Map.prototype.updateCallMenu = function() { 571 if (this.isMenuEnabled()) { 572 if (this.isMenuCalled()) { 573 this.menuCalling = true; 574 } 575 if (this.menuCalling && !$gamePlayer.isMoving()) { 576 this.callMenu(); 577 } 578 } else { 579 this.menuCalling = false; 580 } 581}; 582 583Scene_Map.prototype.isMenuEnabled = function() { 584 return $gameSystem.isMenuEnabled() && !$gameMap.isEventRunning(); 585}; 586 587Scene_Map.prototype.isMenuCalled = function() { 588 return Input.isTriggered('menu') || TouchInput.isCancelled(); 589}; 590 591Scene_Map.prototype.callMenu = function() { 592 SoundManager.playOk(); 593 SceneManager.push(Scene_Menu); 594 Window_MenuCommand.initCommandPosition(); 595 $gameTemp.clearDestination(); 596 this._mapNameWindow.hide(); 597 this._waitCount = 2; 598}; 599 600Scene_Map.prototype.updateCallDebug = function() { 601 if (this.isDebugCalled()) { 602 SceneManager.push(Scene_Debug); 603 } 604}; 605 606Scene_Map.prototype.isDebugCalled = function() { 607 return Input.isTriggered('debug') && $gameTemp.isPlaytest(); 608}; 609 610Scene_Map.prototype.fadeInForTransfer = function() { 611 var fadeType = $gamePlayer.fadeType(); 612 switch (fadeType) { 613 case 0: case 1: 614 this.startFadeIn(this.fadeSpeed(), fadeType === 1); 615 break; 616 } 617}; 618 619Scene_Map.prototype.fadeOutForTransfer = function() { 620 var fadeType = $gamePlayer.fadeType(); 621 switch (fadeType) { 622 case 0: case 1: 623 this.startFadeOut(this.fadeSpeed(), fadeType === 1); 624 break; 625 } 626}; 627 628Scene_Map.prototype.launchBattle = function() { 629 BattleManager.saveBgmAndBgs(); 630 this.stopAudioOnBattleStart(); 631 SoundManager.playBattleStart(); 632 this.startEncounterEffect(); 633 this._mapNameWindow.hide(); 634}; 635 636Scene_Map.prototype.stopAudioOnBattleStart = function() { 637 if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) { 638 AudioManager.stopBgm(); 639 } 640 AudioManager.stopBgs(); 641 AudioManager.stopMe(); 642 AudioManager.stopSe(); 643}; 644 645Scene_Map.prototype.startEncounterEffect = function() { 646 this._spriteset.hideCharacters(); 647 this._encounterEffectDuration = this.encounterEffectSpeed(); 648}; 649 650Scene_Map.prototype.updateEncounterEffect = function() { 651 if (this._encounterEffectDuration > 0) { 652 this._encounterEffectDuration--; 653 var speed = this.encounterEffectSpeed(); 654 var n = speed - this._encounterEffectDuration; 655 var p = n / speed; 656 var q = ((p - 1) * 20 * p + 5) * p + 1; 657 var zoomX = $gamePlayer.screenX(); 658 var zoomY = $gamePlayer.screenY() - 24; 659 if (n === 2) { 660 $gameScreen.setZoom(zoomX, zoomY, 1);
661 this.snapForBattleBackground(); 662 this.startFlashForEncounter(speed / 2); 663 } 664 $gameScreen.setZoom(zoomX, zoomY, q); 665 if (n === Math.floor(speed / 6)) { 666 this.startFlashForEncounter(speed / 2); 667 } 668 if (n === Math.floor(speed / 2)) { 669 BattleManager.playBattleBgm(); 670 this.startFadeOut(this.fadeSpeed()); 671 } 672 } 673}; 674 675Scene_Map.prototype.snapForBattleBackground = function() { 676 this._windowLayer.visible = false; 677 SceneManager.snapForBackground(); 678 this._windowLayer.visible = true; 679}; 680 681Scene_Map.prototype.startFlashForEncounter = function(duration) { 682 var color = [255, 255, 255, 255]; 683 $gameScreen.startFlash(color, duration); 684}; 685 686Scene_Map.prototype.encounterEffectSpeed = function() { 687 return 60; 688}; 689 690//----------------------------------------------------------------------------- 691// Scene_MenuBase 692// 693// The superclass of all the menu-type scenes. 694 695function Scene_MenuBase() { 696 this.initialize.apply(this, arguments); 697} 698 699Scene_MenuBase.prototype = Object.create(Scene_Base.prototype); 700Scene_MenuBase.prototype.constructor = Scene_MenuBase; 701 702Scene_MenuBase.prototype.initialize = function() { 703 Scene_Base.prototype.initialize.call(this); 704}; 705 706Scene_MenuBase.prototype.create = function() { 707 Scene_Base.prototype.create.call(this); 708 this.createBackground(); 709 this.updateActor(); 710 this.createWindowLayer(); 711}; 712 713Scene_MenuBase.prototype.actor = function() { 714 return this._actor; 715}; 716 717Scene_MenuBase.prototype.updateActor = function() { 718 this._actor = $gameParty.menuActor(); 719}; 720 721Scene_MenuBase.prototype.createBackground = function() { 722 this._backgroundSprite = new Sprite(); 723 this._backgroundSprite.bitmap = SceneManager.backgroundBitmap(); 724 this.addChild(this._backgroundSprite); 725}; 726 727Scene_MenuBase.prototype.setBackgroundOpacity = function(opacity) { 728 this._backgroundSprite.opacity = opacity; 729}; 730 731Scene_MenuBase.prototype.createHelpWindow = function() { 732 this._helpWindow = new Window_Help(); 733 this.addWindow(this._helpWindow); 734}; 735 736Scene_MenuBase.prototype.nextActor = function() { 737 $gameParty.makeMenuActorNext(); 738 this.updateActor(); 739 this.onActorChange(); 740}; 741 742Scene_MenuBase.prototype.previousActor = function() { 743 $gameParty.makeMenuActorPrevious(); 744 this.updateActor(); 745 this.onActorChange(); 746}; 747 748Scene_MenuBase.prototype.onActorChange = function() { 749}; 750 751//----------------------------------------------------------------------------- 752// Scene_Menu 753// 754// The scene class of the menu screen. 755 756function Scene_Menu() { 757 this.initialize.apply(this, arguments); 758} 759 760Scene_Menu.prototype = Object.create(Scene_MenuBase.prototype); 761Scene_Menu.prototype.constructor = Scene_Menu; 762 763Scene_Menu.prototype.initialize = function() { 764 Scene_MenuBase.prototype.initialize.call(this); 765}; 766 767Scene_Menu.prototype.create = function() { 768 Scene_MenuBase.prototype.create.call(this); 769 this.createCommandWindow(); 770 this.createGoldWindow(); 771 this.createStatusWindow(); 772}; 773 774Scene_Menu.prototype.start = function() { 775 Scene_MenuBase.prototype.start.call(this); 776 this._statusWindow.refresh(); 777}; 778 779Scene_Menu.prototype.createCommandWindow = function() { 780 this._commandWindow = new Window_MenuCommand(0, 0); 781 this._commandWindow.setHandler('item', this.commandItem.bind(this)); 782 this._commandWindow.setHandler('skill', this.commandPersonal.bind(this)); 783 this._commandWindow.setHandler('equip', this.commandPersonal.bind(this)); 784 this._commandWindow.setHandler('status', this.commandPersonal.bind(this)); 785 this._commandWindow.setHandler('formation', this.commandFormation.bind(this)); 786 this._commandWindow.setHandler('options', this.commandOptions.bind(this)); 787 this._commandWindow.setHandler('save', this.commandSave.bind(this)); 788 this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this)); 789 this._commandWindow.setHandler('cancel', this.popScene.bind(this)); 790 this.addWindow(this._commandWindow); 791}; 792 793Scene_Menu.prototype.createGoldWindow = function() { 794 this._goldWindow = new Window_Gold(0, 0); 795 this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height; 796 this.addWindow(this._goldWindow); 797}; 798 799Scene_Menu.prototype.createStatusWindow = function() { 800 this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0); 801 this.addWindow(this._statusWindow); 802}; 803 804Scene_Menu.prototype.commandItem = function() { 805 SceneManager.push(Scene_Item); 806}; 807 808Scene_Menu.prototype.commandPersonal = function() { 809 this._statusWindow.setFormationMode(false); 810 this._statusWindow.selectLast(); 811 this._statusWindow.activate(); 812 this._statusWindow.setHandler('ok', this.onPersonalOk.bind(this)); 813 this._statusWindow.setHandler('cancel', this.onPersonalCancel.bind(this)); 814}; 815 816Scene_Menu.prototype.commandFormation = function() { 817 this._statusWindow.setFormationMode(true); 818 this._statusWindow.selectLast(); 819 this._statusWindow.activate(); 820 this._statusWindow.setHandler('ok', this.onFormationOk.bind(this)); 821 this._statusWindow.setHandler('cancel', this.onFormationCancel.bind(this)); 822}; 823 824Scene_Menu.prototype.commandOptions = function() { 825 SceneManager.push(Scene_Options); 826}; 827 828Scene_Menu.prototype.commandSave = function() { 829 SceneManager.push(Scene_Save); 830}; 831 832Scene_Menu.prototype.commandGameEnd = function() { 833 SceneManager.push(Scene_GameEnd); 834}; 835 836Scene_Menu.prototype.onPersonalOk = function() { 837 switch (this._commandWindow.currentSymbol()) { 838 case 'skill': 839 SceneManager.push(Scene_Skill); 840 break; 841 case 'equip': 842 SceneManager.push(Scene_Equip); 843 break; 844 case 'status': 845 SceneManager.push(Scene_Status); 846 break; 847 } 848}; 849 850Scene_Menu.prototype.onPersonalCancel = function() { 851 this._statusWindow.deselect(); 852 this._commandWindow.activate(); 853}; 854 855Scene_Menu.prototype.onFormationOk = function() { 856 var index = this._statusWindow.index(); 857 var actor = $gameParty.members()[index]; 858 var pendingIndex = this._statusWindow.pendingIndex(); 859 if (pendingIndex >= 0) { 860 $gameParty.swapOrder(index, pendingIndex); 861 this._statusWindow.setPendingIndex(-1); 862 this._statusWindow.redrawItem(index); 863 } else { 864 this._statusWindow.setPendingIndex(index); 865 } 866 this._statusWindow.activate(); 867}; 868 869Scene_Menu.prototype.onFormationCancel = function() { 870 if (this._statusWindow.pendingIndex() >= 0) { 871 this._statusWindow.setPendingIndex(-1); 872 this._statusWindow.activate(); 873 } else { 874 this._statusWindow.deselect(); 875 this._commandWindow.activate(); 876 } 877}; 878 879//----------------------------------------------------------------------------- 880// Scene_ItemBase 881// 882// The superclass of Scene_Item and Scene_Skill. 883 884function Scene_ItemBase() { 885 this.initialize.apply(this, arguments); 886} 887 888Scene_ItemBase.prototype = Object.create(Scene_MenuBase.prototype); 889Scene_ItemBase.prototype.constructor = Scene_ItemBase; 890 891Scene_ItemBase.prototype.initialize = function() { 892 Scene_MenuBase.prototype.initialize.call(this); 893}; 894 895Scene_ItemBase.prototype.create = function() { 896 Scene_MenuBase.prototype.create.call(this); 897}; 898 899Scene_ItemBase.prototype.createActorWindow = function() { 900 this._actorWindow = new Window_MenuActor(); 901 this._actorWindow.setHandler('ok', this.onActorOk.bind(this)); 902 this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this)); 903 this.addWindow(this._actorWindow); 904}; 905 906Scene_ItemBase.prototype.item = function() { 907 return this._itemWindow.item(); 908}; 909 910Scene_ItemBase.prototype.user = function() { 911 return null; 912}; 913 914Scene_ItemBase.prototype.isCursorLeft = function() { 915 return this._itemWindow.index() % 2 === 0; 916}; 917 918Scene_ItemBase.prototype.showSubWindow = function(window) { 919 window.x = this.isCursorLeft() ? Graphics.boxWidth - window.width : 0; 920 window.show(); 921 window.activate(); 922}; 923 924Scene_ItemBase.prototype.hideSubWindow = function(window) { 925 window.hide(); 926 window.deactivate(); 927 this.activateItemWindow(); 928}; 929 930Scene_ItemBase.prototype.onActorOk = function() { 931 if (this.canUse()) { 932 this.useItem(); 933 } else { 934 SoundManager.playBuzzer(); 935 } 936}; 937 938Scene_ItemBase.prototype.onActorCancel = function() { 939 this.hideSubWindow(this._actorWindow); 940}; 941 942Scene_ItemBase.prototype.determineItem = function() { 943 var action = new Game_Action(this.user()); 944 var item = this.item(); 945 action.setItemObject(item); 946 if (action.isForFriend()) { 947 this.showSubWindow(this._actorWindow); 948 this._actorWindow.selectForItem(this.item()); 949 } else { 950 this.useItem(); 951 this.activateItemWindow(); 952 } 953}; 954 955Scene_ItemBase.prototype.useItem = function() { 956 this.playSeForItem(); 957 this.user().useItem(this.item()); 958 this.applyItem(); 959 this.checkCommonEvent(); 960 this.checkGameover(); 961 this._actorWindow.refresh(); 962}; 963 964Scene_ItemBase.prototype.activateItemWindow = function() { 965 this._itemWindow.refresh(); 966 this._itemWindow.activate(); 967}; 968 969Scene_ItemBase.prototype.itemTargetActors = function() { 970 var action = new Game_Action(this.user()); 971 action.setItemObject(this.item()); 972 if (!action.isForFriend()) { 973 return []; 974 } else if (action.isForAll()) { 975 return $gameParty.members(); 976 } else { 977 return [$gameParty.members()[this._actorWindow.index()]]; 978 } 979}; 980 981Scene_ItemBase.prototype.canUse = function() { 982 return this.user().canUse(this.item()) && this.isItemEffectsValid(); 983}; 984 985Scene_ItemBase.prototype.isItemEffectsValid = function() { 986 var action = new Game_Action(this.user()); 987 action.setItemObject(this.item()); 988 return this.itemTargetActors().some(function(target) { 989 return action.testApply(target); 990 }, this); 991}; 992 993Scene_ItemBase.prototype.applyItem = function() { 994 var action = new Game_Action(this.user()); 995 action.setItemObject(this.item());
996 this.itemTargetActors().forEach(function(target) { 997 for (var i = 0; i < action.numRepeats(); i++) { 998 action.apply(target); 999 } 1000 }, this); 1001 action.applyGlobal(); 1002}; 1003 1004Scene_ItemBase.prototype.checkCommonEvent = function() { 1005 if ($gameTemp.isCommonEventReserved()) { 1006 SceneManager.goto(Scene_Map); 1007 } 1008}; 1009 1010//----------------------------------------------------------------------------- 1011// Scene_Item 1012// 1013// The scene class of the item screen. 1014 1015function Scene_Item() { 1016 this.initialize.apply(this, arguments); 1017} 1018 1019Scene_Item.prototype = Object.create(Scene_ItemBase.prototype); 1020Scene_Item.prototype.constructor = Scene_Item; 1021 1022Scene_Item.prototype.initialize = function() { 1023 Scene_ItemBase.prototype.initialize.call(this); 1024}; 1025 1026Scene_Item.prototype.create = function() { 1027 Scene_ItemBase.prototype.create.call(this); 1028 this.createHelpWindow(); 1029 this.createCategoryWindow(); 1030 this.createItemWindow(); 1031 this.createActorWindow(); 1032}; 1033 1034Scene_Item.prototype.createCategoryWindow = function() { 1035 this._categoryWindow = new Window_ItemCategory(); 1036 this._categoryWindow.setHelpWindow(this._helpWindow); 1037 this._categoryWindow.y = this._helpWindow.height; 1038 this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this)); 1039 this._categoryWindow.setHandler('cancel', this.popScene.bind(this)); 1040 this.addWindow(this._categoryWindow); 1041}; 1042 1043Scene_Item.prototype.createItemWindow = function() { 1044 var wy = this._categoryWindow.y + this._categoryWindow.height; 1045 var wh = Graphics.boxHeight - wy; 1046 this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh); 1047 this._itemWindow.setHelpWindow(this._helpWindow); 1048 this._itemWindow.setHandler('ok', this.onItemOk.bind(this)); 1049 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this)); 1050 this.addWindow(this._itemWindow); 1051 this._categoryWindow.setItemWindow(this._itemWindow); 1052}; 1053 1054Scene_Item.prototype.user = function() { 1055 var members = $gameParty.movableMembers(); 1056 var bestActor = members[0]; 1057 var bestPha = 0; 1058 for (var i = 0; i < members.length; i++) { 1059 if (members[i].pha > bestPha) { 1060 bestPha = members[i].pha; 1061 bestActor = members[i]; 1062 } 1063 } 1064 return bestActor; 1065}; 1066 1067Scene_Item.prototype.onCategoryOk = function() { 1068 this._itemWindow.activate(); 1069 this._itemWindow.selectLast(); 1070}; 1071 1072Scene_Item.prototype.onItemOk = function() { 1073 $gameParty.setLastItem(this.item()); 1074 this.determineItem(); 1075}; 1076 1077Scene_Item.prototype.onItemCancel = function() { 1078 this._itemWindow.deselect(); 1079 this._categoryWindow.activate(); 1080}; 1081 1082Scene_Item.prototype.playSeForItem = function() { 1083 SoundManager.playUseItem(); 1084}; 1085 1086Scene_Item.prototype.useItem = function() { 1087 Scene_ItemBase.prototype.useItem.call(this); 1088 this._itemWindow.redrawCurrentItem(); 1089}; 1090 1091//----------------------------------------------------------------------------- 1092// Scene_Skill 1093// 1094// The scene class of the skill screen. 1095 1096function Scene_Skill() { 1097 this.initialize.apply(this, arguments); 1098} 1099 1100Scene_Skill.prototype = Object.create(Scene_ItemBase.prototype); 1101Scene_Skill.prototype.constructor = Scene_Skill; 1102 1103Scene_Skill.prototype.initialize = function() { 1104 Scene_ItemBase.prototype.initialize.call(this); 1105}; 1106 1107Scene_Skill.prototype.create = function() { 1108 Scene_ItemBase.prototype.create.call(this); 1109 this.createHelpWindow(); 1110 this.createSkillTypeWindow(); 1111 this.createStatusWindow(); 1112 this.createItemWindow(); 1113 this.createActorWindow(); 1114 this.refreshActor(); 1115}; 1116 1117Scene_Skill.prototype.createSkillTypeWindow = function() { 1118 var wy = this._helpWindow.height; 1119 this._skillTypeWindow = new Window_SkillType(0, wy); 1120 this._skillTypeWindow.setHelpWindow(this._helpWindow); 1121 this._skillTypeWindow.setHandler('skill', this.commandSkill.bind(this)); 1122 this._skillTypeWindow.setHandler('cancel', this.popScene.bind(this)); 1123 this._skillTypeWindow.setHandler('pagedown', this.nextActor.bind(this)); 1124 this._skillTypeWindow.setHandler('pageup', this.previousActor.bind(this)); 1125 this.addWindow(this._skillTypeWindow); 1126}; 1127 1128Scene_Skill.prototype.createStatusWindow = function() { 1129 var wx = this._skillTypeWindow.width; 1130 var wy = this._helpWindow.height; 1131 var ww = Graphics.boxWidth - wx; 1132 var wh = this._skillTypeWindow.height; 1133 this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh); 1134 this.addWindow(this._statusWindow); 1135}; 1136 1137Scene_Skill.prototype.createItemWindow = function() { 1138 var wx = 0; 1139 var wy = this._statusWindow.y + this._statusWindow.height; 1140 var ww = Graphics.boxWidth; 1141 var wh = Graphics.boxHeight - wy; 1142 this._itemWindow = new Window_SkillList(wx, wy, ww, wh); 1143 this._itemWindow.setHelpWindow(this._helpWindow); 1144 this._itemWindow.setHandler('ok', this.onItemOk.bind(this)); 1145 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this)); 1146 this._skillTypeWindow.setSkillWindow(this._itemWindow); 1147 this.addWindow(this._itemWindow); 1148}; 1149 1150Scene_Skill.prototype.refreshActor = function() { 1151 var actor = this.actor(); 1152 this._skillTypeWindow.setActor(actor); 1153 this._statusWindow.setActor(actor); 1154 this._itemWindow.setActor(actor); 1155}; 1156 1157Scene_Skill.prototype.user = function() { 1158 return this.actor(); 1159}; 1160 1161Scene_Skill.prototype.commandSkill = function() { 1162 this._itemWindow.activate(); 1163 this._itemWindow.selectLast(); 1164}; 1165 1166Scene_Skill.prototype.onItemOk = function() { 1167 this.actor().setLastMenuSkill(this.item()); 1168 this.determineItem(); 1169}; 1170 1171Scene_Skill.prototype.onItemCancel = function() { 1172 this._itemWindow.deselect(); 1173 this._skillTypeWindow.activate(); 1174}; 1175 1176Scene_Skill.prototype.playSeForItem = function() { 1177 SoundManager.playUseSkill(); 1178}; 1179 1180Scene_Skill.prototype.useItem = function() { 1181 Scene_ItemBase.prototype.useItem.call(this); 1182 this._statusWindow.refresh(); 1183 this._itemWindow.refresh(); 1184}; 1185 1186Scene_Skill.prototype.onActorChange = function() { 1187 this.refreshActor(); 1188 this._skillTypeWindow.activate(); 1189}; 1190 1191//----------------------------------------------------------------------------- 1192// Scene_Equip 1193// 1194// The scene class of the equipment screen. 1195 1196function Scene_Equip() { 1197 this.initialize.apply(this, arguments); 1198} 1199 1200Scene_Equip.prototype = Object.create(Scene_MenuBase.prototype); 1201Scene_Equip.prototype.constructor = Scene_Equip; 1202 1203Scene_Equip.prototype.initialize = function() { 1204 Scene_MenuBase.prototype.initialize.call(this); 1205}; 1206 1207Scene_Equip.prototype.create = function() { 1208 Scene_MenuBase.prototype.create.call(this); 1209 this.createHelpWindow(); 1210 this.createStatusWindow(); 1211 this.createCommandWindow(); 1212 this.createSlotWindow(); 1213 this.createItemWindow(); 1214 this.refreshActor(); 1215}; 1216 1217Scene_Equip.prototype.createStatusWindow = function() { 1218 this._statusWindow = new Window_EquipStatus(0, this._helpWindow.height); 1219 this.addWindow(this._statusWindow); 1220}; 1221 1222Scene_Equip.prototype.createCommandWindow = function() { 1223 var wx = this._statusWindow.width; 1224 var wy = this._helpWindow.height; 1225 var ww = Graphics.boxWidth - this._statusWindow.width; 1226 this._commandWindow = new Window_EquipCommand(wx, wy, ww); 1227 this._commandWindow.setHelpWindow(this._helpWindow); 1228 this._commandWindow.setHandler('equip', this.commandEquip.bind(this)); 1229 this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this)); 1230 this._commandWindow.setHandler('clear', this.commandClear.bind(this)); 1231 this._commandWindow.setHandler('cancel', this.popScene.bind(this)); 1232 this._commandWindow.setHandler('pagedown', this.nextActor.bind(this)); 1233 this._commandWindow.setHandler('pageup', this.previousActor.bind(this)); 1234 this.addWindow(this._commandWindow); 1235}; 1236 1237Scene_Equip.prototype.createSlotWindow = function() { 1238 var wx = this._statusWindow.width; 1239 var wy = this._commandWindow.y + this._commandWindow.height; 1240 var ww = Graphics.boxWidth - this._statusWindow.width; 1241 var wh = this._statusWindow.height - this._commandWindow.height; 1242 this._slotWindow = new Window_EquipSlot(wx, wy, ww, wh); 1243 this._slotWindow.setHelpWindow(this._helpWindow); 1244 this._slotWindow.setStatusWindow(this._statusWindow); 1245 this._slotWindow.setHandler('ok', this.onSlotOk.bind(this)); 1246 this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this)); 1247 this.addWindow(this._slotWindow); 1248}; 1249 1250Scene_Equip.prototype.createItemWindow = function() { 1251 var wx = 0; 1252 var wy = this._statusWindow.y + this._statusWindow.height; 1253 var ww = Graphics.boxWidth; 1254 var wh = Graphics.boxHeight - wy; 1255 this._itemWindow = new Window_EquipItem(wx, wy, ww, wh); 1256 this._itemWindow.setHelpWindow(this._helpWindow); 1257 this._itemWindow.setStatusWindow(this._statusWindow); 1258 this._itemWindow.setHandler('ok', this.onItemOk.bind(this)); 1259 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this)); 1260 this._slotWindow.setItemWindow(this._itemWindow); 1261 this.addWindow(this._itemWindow); 1262}; 1263 1264Scene_Equip.prototype.refreshActor = function() { 1265 var actor = this.actor(); 1266 this._statusWindow.setActor(actor); 1267 this._slotWindow.setActor(actor); 1268 this._itemWindow.setActor(actor); 1269}; 1270 1271Scene_Equip.prototype.commandEquip = function() { 1272 this._slotWindow.activate(); 1273 this._slotWindow.select(0); 1274}; 1275 1276Scene_Equip.prototype.commandOptimize = function() { 1277 SoundManager.playEquip(); 1278 this.actor().optimizeEquipments(); 1279 this._statusWindow.refresh(); 1280 this._slotWindow.refresh(); 1281 this._commandWindow.activate(); 1282}; 1283 1284Scene_Equip.prototype.commandClear = function() { 1285 SoundManager.playEquip(); 1286 this.actor().clearEquipments(); 1287 this._statusWindow.refresh(); 1288 this._slotWindow.refresh(); 1289 this._commandWindow.activate(); 1290}; 1291 1292Scene_Equip.prototype.onSlotOk = function() { 1293 this._itemWindow.activate(); 1294 this._itemWindow.select(0); 1295}; 1296 1297Scene_Equip.prototype.onSlotCancel = function() { 1298 this._slotWindow.deselect(); 1299 this._commandWindow.activate(); 1300}; 1301 1302Scene_Equip.prototype.onItemOk = function() { 1303 SoundManager.playEquip(); 1304 this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item()); 1305 this._slotWindow.activate(); 1306 this._slotWindow.refresh(); 1307 this._itemWindow.deselect(); 1308 this._itemWindow.refresh(); 1309 this._statusWindow.refresh(); 1310}; 1311 1312Scene_Equip.prototype.onItemCancel = function() { 1313 this._slotWindow.activate(); 1314 this._itemWindow.deselect(); 1315}; 1316 1317Scene_Equip.prototype.onActorChange = function() { 1318 this.refreshActor(); 1319 this._commandWindow.activate(); 1320}; 1321 1322//----------------------------------------------------------------------------- 1323// Scene_Status 1324// 1325// The scene class of the status screen. 1326 1327function Scene_Status() { 1328 this.initialize.apply(this, arguments); 1329} 1330 1331Scene_Status.prototype = Object.create(Scene_MenuBase.prototype); 1332Scene_Status.prototype.constructor = Scene_Status; 1333 1334Scene_Status.prototype.initialize = function() { 1335 Scene_MenuBase.prototype.initialize.call(this); 1336}; 1337 1338Scene_Status.prototype.create = function() { 1339 Scene_MenuBase.prototype.create.call(this); 1340 this._statusWindow = new Window_Status(); 1341 this._statusWindow.setHandler('cancel', this.popScene.bind(this)); 1342 this._statusWindow.setHandler('pagedown', this.nextActor.bind(this)); 1343 this._statusWindow.setHandler('pageup', this.previousActor.bind(this)); 1344 this.addWindow(this._statusWindow); 1345 this.refreshActor(); 1346}; 1347 1348Scene_Status.prototype.refreshActor = function() { 1349 var actor = this.actor(); 1350 this._statusWindow.setActor(actor); 1351}; 1352 1353Scene_Status.prototype.onActorChange = function() { 1354 this.refreshActor(); 1355 this._statusWindow.activate(); 1356}; 1357 1358//----------------------------------------------------------------------------- 1359// Scene_Options 1360// 1361// The scene class of the options screen. 1362 1363function Scene_Options() { 1364 this.initialize.apply(this, arguments); 1365} 1366 1367Scene_Options.prototype = Object.create(Scene_MenuBase.prototype); 1368Scene_Options.prototype.constructor = Scene_Options; 1369 1370Scene_Options.prototype.initialize = function() { 1371 Scene_MenuBase.prototype.initialize.call(this); 1372}; 1373 1374Scene_Options.prototype.create = function() { 1375 Scene_MenuBase.prototype.create.call(this); 1376 this.createOptionsWindow(); 1377}; 1378 1379Scene_Options.prototype.terminate = function() { 1380 Scene_MenuBase.prototype.terminate.call(this); 1381 ConfigManager.save(); 1382}; 1383 1384Scene_Options.prototype.createOptionsWindow = function() { 1385 this._optionsWindow = new Window_Options(); 1386 this._optionsWindow.setHandler('cancel', this.popScene.bind(this)); 1387 this.addWindow(this._optionsWindow); 1388}; 1389 1390//----------------------------------------------------------------------------- 1391// Scene_File 1392// 1393// The superclass of Scene_Save and Scene_Load. 1394 1395function Scene_File() { 1396 this.initialize.apply(this, arguments); 1397} 1398 1399Scene_File.prototype = Object.create(Scene_MenuBase.prototype); 1400Scene_File.prototype.constructor = Scene_File; 1401 1402Scene_File.prototype.initialize = function() { 1403 Scene_MenuBase.prototype.initialize.call(this); 1404}; 1405 1406Scene_File.prototype.create = function() { 1407 Scene_MenuBase.prototype.create.call(this); 1408 DataManager.loadAllSavefileImages(); 1409 this.createHelpWindow(); 1410 this.createListWindow(); 1411}; 1412 1413Scene_File.prototype.start = function() { 1414 Scene_MenuBase.prototype.start.call(this); 1415 this._listWindow.refresh(); 1416}; 1417 1418Scene_File.prototype.savefileId = function() { 1419 return this._listWindow.index() + 1; 1420}; 1421 1422Scene_File.prototype.createHelpWindow = function() { 1423 this._helpWindow = new Window_Help(1); 1424 this._helpWindow.setText(this.helpWindowText()); 1425 this.addWindow(this._helpWindow); 1426}; 1427 1428Scene_File.prototype.createListWindow = function() { 1429 var x = 0; 1430 var y = this._helpWindow.height; 1431 var width = Graphics.boxWidth; 1432 var height = Graphics.boxHeight - y; 1433 this._listWindow = new Window_SavefileList(x, y, width, height); 1434 this._listWindow.setHandler('ok', this.onSavefileOk.bind(this)); 1435 this._listWindow.setHandler('cancel', this.popScene.bind(this)); 1436 this._listWindow.select(this.firstSavefileIndex()); 1437 this._listWindow.setTopRow(this.firstSavefileIndex() - 2); 1438 this._listWindow.setMode(this.mode()); 1439 this._listWindow.refresh(); 1440 this.addWindow(this._listWindow); 1441}; 1442 1443Scene_File.prototype.mode = function() { 1444 return null; 1445}; 1446 1447Scene_File.prototype.activateListWindow = function() { 1448 this._listWindow.activate(); 1449}; 1450 1451Scene_File.prototype.helpWindowText = function() { 1452 return ''; 1453}; 1454 1455Scene_File.prototype.firstSavefileIndex = function() { 1456 return 0; 1457}; 1458 1459Scene_File.prototype.onSavefileOk = function() { 1460}; 1461 1462//----------------------------------------------------------------------------- 1463// Scene_Save 1464// 1465// The scene class of the save screen. 1466 1467function Scene_Save() { 1468 this.initialize.apply(this, arguments); 1469} 1470 1471Scene_Save.prototype = Object.create(Scene_File.prototype); 1472Scene_Save.prototype.constructor = Scene_Save; 1473 1474Scene_Save.prototype.initialize = function() { 1475 Scene_File.prototype.initialize.call(this); 1476}; 1477 1478Scene_Save.prototype.mode = function() { 1479 return 'save'; 1480}; 1481 1482Scene_Save.prototype.helpWindowText = function() { 1483 return TextManager.saveMessage; 1484}; 1485 1486Scene_Save.prototype.firstSavefileIndex = function() { 1487 return DataManager.lastAccessedSavefileId() - 1; 1488}; 1489 1490Scene_Save.prototype.onSavefileOk = function() { 1491 Scene_File.prototype.onSavefileOk.call(this); 1492 $gameSystem.onBeforeSave(); 1493 if (DataManager.saveGame(this.savefileId())) { 1494 this.onSaveSuccess(); 1495 } else { 1496 this.onSaveFailure(); 1497 } 1498}; 1499 1500Scene_Save.prototype.onSaveSuccess = function() { 1501 SoundManager.playSave(); 1502 this.popScene(); 1503}; 1504 1505Scene_Save.prototype.onSaveFailure = function() { 1506 SoundManager.playBuzzer(); 1507 this.activateListWindow(); 1508}; 1509 1510//----------------------------------------------------------------------------- 1511// Scene_Load 1512// 1513// The scene class of the load screen. 1514 1515function Scene_Load() { 1516 this.initialize.apply(this, arguments); 1517} 1518 1519Scene_Load.prototype = Object.create(Scene_File.prototype); 1520Scene_Load.prototype.constructor = Scene_Load; 1521 1522Scene_Load.prototype.initialize = function() { 1523 Scene_File.prototype.initialize.call(this); 1524 this._loadSuccess = false;
1525}; 1526 1527Scene_Load.prototype.terminate = function() { 1528 Scene_File.prototype.terminate.call(this); 1529 if (this._loadSuccess) { 1530 $gameSystem.onAfterLoad(); 1531 } 1532}; 1533 1534Scene_Load.prototype.mode = function() { 1535 return 'load'; 1536}; 1537 1538Scene_Load.prototype.helpWindowText = function() { 1539 return TextManager.loadMessage; 1540}; 1541 1542Scene_Load.prototype.firstSavefileIndex = function() { 1543 return DataManager.latestSavefileId() - 1; 1544}; 1545 1546Scene_Load.prototype.onSavefileOk = function() { 1547 Scene_File.prototype.onSavefileOk.call(this); 1548 if (DataManager.loadGame(this.savefileId())) { 1549 this.onLoadSuccess(); 1550 } else { 1551 this.onLoadFailure(); 1552 } 1553}; 1554 1555Scene_Load.prototype.onLoadSuccess = function() { 1556 SoundManager.playLoad(); 1557 this.fadeOutAll(); 1558 this.reloadMapIfUpdated(); 1559 SceneManager.goto(Scene_Map); 1560 this._loadSuccess = true; 1561}; 1562 1563Scene_Load.prototype.onLoadFailure = function() { 1564 SoundManager.playBuzzer(); 1565 this.activateListWindow(); 1566}; 1567 1568Scene_Load.prototype.reloadMapIfUpdated = function() { 1569 if ($gameSystem.versionId() !== $dataSystem.versionId) { 1570 $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y); 1571 $gamePlayer.requestMapReload(); 1572 } 1573}; 1574 1575//----------------------------------------------------------------------------- 1576// Scene_GameEnd 1577// 1578// The scene class of the game end screen. 1579 1580function Scene_GameEnd() { 1581 this.initialize.apply(this, arguments); 1582} 1583 1584Scene_GameEnd.prototype = Object.create(Scene_MenuBase.prototype); 1585Scene_GameEnd.prototype.constructor = Scene_GameEnd; 1586 1587Scene_GameEnd.prototype.initialize = function() { 1588 Scene_MenuBase.prototype.initialize.call(this); 1589}; 1590 1591Scene_GameEnd.prototype.create = function() { 1592 Scene_MenuBase.prototype.create.call(this); 1593 this.createCommandWindow(); 1594}; 1595 1596Scene_GameEnd.prototype.stop = function() { 1597 Scene_MenuBase.prototype.stop.call(this); 1598 this._commandWindow.close(); 1599}; 1600 1601Scene_GameEnd.prototype.createBackground = function() { 1602 Scene_MenuBase.prototype.createBackground.call(this); 1603 this.setBackgroundOpacity(128); 1604}; 1605 1606Scene_GameEnd.prototype.createCommandWindow = function() { 1607 this._commandWindow = new Window_GameEnd(); 1608 this._commandWindow.setHandler('toTitle', this.commandToTitle.bind(this)); 1609 this._commandWindow.setHandler('cancel', this.popScene.bind(this)); 1610 this.addWindow(this._commandWindow); 1611}; 1612 1613Scene_GameEnd.prototype.commandToTitle = function() { 1614 this.fadeOutAll(); 1615 SceneManager.goto(Scene_Title); 1616}; 1617 1618//----------------------------------------------------------------------------- 1619// Scene_Shop 1620// 1621// The scene class of the shop screen. 1622 1623function Scene_Shop() { 1624 this.initialize.apply(this, arguments); 1625} 1626 1627Scene_Shop.prototype = Object.create(Scene_MenuBase.prototype); 1628Scene_Shop.prototype.constructor = Scene_Shop; 1629 1630Scene_Shop.prototype.initialize = function() { 1631 Scene_MenuBase.prototype.initialize.call(this); 1632}; 1633 1634Scene_Shop.prototype.prepare = function(goods, purchaseOnly) { 1635 this._goods = goods; 1636 this._purchaseOnly = purchaseOnly; 1637 this._item = null; 1638}; 1639 1640Scene_Shop.prototype.create = function() { 1641 Scene_MenuBase.prototype.create.call(this); 1642 this.createHelpWindow(); 1643 this.createGoldWindow(); 1644 this.createCommandWindow(); 1645 this.createDummyWindow(); 1646 this.createNumberWindow(); 1647 this.createStatusWindow(); 1648 this.createBuyWindow(); 1649 this.createCategoryWindow(); 1650 this.createSellWindow(); 1651}; 1652 1653Scene_Shop.prototype.createGoldWindow = function() { 1654 this._goldWindow = new Window_Gold(0, this._helpWindow.height); 1655 this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width; 1656 this.addWindow(this._goldWindow); 1657}; 1658 1659Scene_Shop.prototype.createCommandWindow = function() { 1660 this._commandWindow = new Window_ShopCommand(this._goldWindow.x, this._purchaseOnly); 1661 this._commandWindow.y = this._helpWindow.height; 1662 this._commandWindow.setHandler('buy', this.commandBuy.bind(this)); 1663 this._commandWindow.setHandler('sell', this.commandSell.bind(this)); 1664 this._commandWindow.setHandler('cancel', this.popScene.bind(this)); 1665 this.addWindow(this._commandWindow); 1666}; 1667 1668Scene_Shop.prototype.createDummyWindow = function() { 1669 var wy = this._commandWindow.y + this._commandWindow.height; 1670 var wh = Graphics.boxHeight - wy; 1671 this._dummyWindow = new Window_Base(0, wy, Graphics.boxWidth, wh); 1672 this.addWindow(this._dummyWindow); 1673}; 1674 1675Scene_Shop.prototype.createNumberWindow = function() { 1676 var wy = this._dummyWindow.y; 1677 var wh = this._dummyWindow.height; 1678 this._numberWindow = new Window_ShopNumber(0, wy, wh); 1679 this._numberWindow.hide(); 1680 this._numberWindow.setHandler('ok', this.onNumberOk.bind(this)); 1681 this._numberWindow.setHandler('cancel', this.onNumberCancel.bind(this)); 1682 this.addWindow(this._numberWindow); 1683}; 1684 1685Scene_Shop.prototype.createStatusWindow = function() { 1686 var wx = this._numberWindow.width; 1687 var wy = this._dummyWindow.y; 1688 var ww = Graphics.boxWidth - wx; 1689 var wh = this._dummyWindow.height; 1690 this._statusWindow = new Window_ShopStatus(wx, wy, ww, wh); 1691 this._statusWindow.hide(); 1692 this.addWindow(this._statusWindow); 1693}; 1694 1695Scene_Shop.prototype.createBuyWindow = function() { 1696 var wy = this._dummyWindow.y; 1697 var wh = this._dummyWindow.height; 1698 this._buyWindow = new Window_ShopBuy(0, wy, wh, this._goods); 1699 this._buyWindow.setHelpWindow(this._helpWindow); 1700 this._buyWindow.setStatusWindow(this._statusWindow); 1701 this._buyWindow.hide(); 1702 this._buyWindow.setHandler('ok', this.onBuyOk.bind(this)); 1703 this._buyWindow.setHandler('cancel', this.onBuyCancel.bind(this)); 1704 this.addWindow(this._buyWindow); 1705}; 1706 1707Scene_Shop.prototype.createCategoryWindow = function() { 1708 this._categoryWindow = new Window_ItemCategory(); 1709 this._categoryWindow.setHelpWindow(this._helpWindow); 1710 this._categoryWindow.y = this._dummyWindow.y; 1711 this._categoryWindow.hide(); 1712 this._categoryWindow.deactivate(); 1713 this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this)); 1714 this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this)); 1715 this.addWindow(this._categoryWindow); 1716}; 1717 1718Scene_Shop.prototype.createSellWindow = function() { 1719 var wy = this._categoryWindow.y + this._categoryWindow.height; 1720 var wh = Graphics.boxHeight - wy; 1721 this._sellWindow = new Window_ShopSell(0, wy, Graphics.boxWidth, wh); 1722 this._sellWindow.setHelpWindow(this._helpWindow); 1723 this._sellWindow.hide(); 1724 this._sellWindow.setHandler('ok', this.onSellOk.bind(this)); 1725 this._sellWindow.setHandler('cancel', this.onSellCancel.bind(this)); 1726 this._categoryWindow.setItemWindow(this._sellWindow); 1727 this.addWindow(this._sellWindow); 1728}; 1729 1730Scene_Shop.prototype.activateBuyWindow = function() { 1731 this._buyWindow.setMoney(this.money()); 1732 this._buyWindow.show(); 1733 this._buyWindow.activate(); 1734 this._statusWindow.show(); 1735}; 1736 1737Scene_Shop.prototype.activateSellWindow = function() { 1738 this._categoryWindow.show(); 1739 this._sellWindow.refresh(); 1740 this._sellWindow.show(); 1741 this._sellWindow.activate(); 1742 this._statusWindow.hide(); 1743}; 1744 1745Scene_Shop.prototype.commandBuy = function() { 1746 this._dummyWindow.hide(); 1747 this.activateBuyWindow(); 1748}; 1749 1750Scene_Shop.prototype.commandSell = function() { 1751 this._dummyWindow.hide(); 1752 this._categoryWindow.show(); 1753 this._categoryWindow.activate(); 1754 this._sellWindow.show(); 1755 this._sellWindow.deselect(); 1756 this._sellWindow.refresh(); 1757}; 1758 1759Scene_Shop.prototype.onBuyOk = function() { 1760 this._item = this._buyWindow.item(); 1761 this._buyWindow.hide(); 1762 this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice()); 1763 this._numberWindow.setCurrencyUnit(this.currencyUnit()); 1764 this._numberWindow.show(); 1765 this._numberWindow.activate(); 1766}; 1767 1768Scene_Shop.prototype.onBuyCancel = function() { 1769 this._commandWindow.activate(); 1770 this._dummyWindow.show(); 1771 this._buyWindow.hide(); 1772 this._statusWindow.hide(); 1773 this._statusWindow.setItem(null); 1774 this._helpWindow.clear(); 1775}; 1776 1777Scene_Shop.prototype.onCategoryOk = function() { 1778 this.activateSellWindow(); 1779 this._sellWindow.select(0); 1780}; 1781 1782Scene_Shop.prototype.onCategoryCancel = function() { 1783 this._commandWindow.activate(); 1784 this._dummyWindow.show(); 1785 this._categoryWindow.hide(); 1786 this._sellWindow.hide(); 1787}; 1788 1789Scene_Shop.prototype.onSellOk = function() { 1790 this._item = this._sellWindow.item(); 1791 this._categoryWindow.hide(); 1792 this._sellWindow.hide(); 1793 this._numberWindow.setup(this._item, this.maxSell(), this.sellingPrice()); 1794 this._numberWindow.setCurrencyUnit(this.currencyUnit()); 1795 this._numberWindow.show(); 1796 this._numberWindow.activate(); 1797 this._statusWindow.setItem(this._item); 1798 this._statusWindow.show(); 1799}; 1800 1801Scene_Shop.prototype.onSellCancel = function() { 1802 this._sellWindow.deselect(); 1803 this._categoryWindow.activate(); 1804 this._statusWindow.setItem(null); 1805 this._helpWindow.clear(); 1806}; 1807 1808Scene_Shop.prototype.onNumberOk = function() { 1809 SoundManager.playShop(); 1810 switch (this._commandWindow.currentSymbol()) { 1811 case 'buy': 1812 this.doBuy(this._numberWindow.number()); 1813 break; 1814 case 'sell': 1815 this.doSell(this._numberWindow.number()); 1816 break; 1817 } 1818 this.endNumberInput(); 1819 this._goldWindow.refresh(); 1820 this._statusWindow.refresh(); 1821}; 1822 1823Scene_Shop.prototype.onNumberCancel = function() { 1824 SoundManager.playCancel(); 1825 this.endNumberInput(); 1826}; 1827 1828Scene_Shop.prototype.doBuy = function(number) { 1829 $gameParty.loseGold(number * this.buyingPrice()); 1830 $gameParty.gainItem(this._item, number); 1831}; 1832 1833Scene_Shop.prototype.doSell = function(number) { 1834 $gameParty.gainGold(number * this.sellingPrice()); 1835 $gameParty.loseItem(this._item, number); 1836}; 1837 1838Scene_Shop.prototype.endNumberInput = function() { 1839 this._numberWindow.hide(); 1840 switch (this._commandWindow.currentSymbol()) { 1841 case 'buy': 1842 this.activateBuyWindow(); 1843 break; 1844 case 'sell': 1845 this.activateSellWindow(); 1846 break; 1847 } 1848}; 1849 1850Scene_Shop.prototype.maxBuy = function() { 1851 var max = $gameParty.maxItems(this._item) - $gameParty.numItems(this._item); 1852 var price = this.buyingPrice(); 1853 if (price > 0) { 1854 return Math.min(max, Math.floor(this.money() / price)); 1855 } else { 1856 return max; 1857 } 1858}; 1859 1860Scene_Shop.prototype.maxSell = function() { 1861 return $gameParty.numItems(this._item); 1862}; 1863 1864Scene_Shop.prototype.money = function() { 1865 return this._goldWindow.value(); 1866}; 1867 1868Scene_Shop.prototype.currencyUnit = function() { 1869 return this._goldWindow.currencyUnit(); 1870}; 1871 1872Scene_Shop.prototype.buyingPrice = function() { 1873 return this._buyWindow.price(this._item); 1874}; 1875 1876Scene_Shop.prototype.sellingPrice = function() { 1877 return Math.floor(this._item.price / 2); 1878}; 1879 1880//----------------------------------------------------------------------------- 1881// Scene_Name 1882// 1883// The scene class of the name input screen. 1884 1885function Scene_Name() { 1886 this.initialize.apply(this, arguments); 1887} 1888 1889Scene_Name.prototype = Object.create(Scene_MenuBase.prototype); 1890Scene_Name.prototype.constructor = Scene_Name; 1891 1892Scene_Name.prototype.initialize = function() { 1893 Scene_MenuBase.prototype.initialize.call(this); 1894}; 1895 1896Scene_Name.prototype.prepare = function(actorId, maxLength) { 1897 this._actorId = actorId; 1898 this._maxLength = maxLength; 1899}; 1900 1901Scene_Name.prototype.create = function() { 1902 Scene_MenuBase.prototype.create.call(this); 1903 this._actor = $gameActors.actor(this._actorId); 1904 this.createEditWindow(); 1905 this.createInputWindow(); 1906}; 1907 1908Scene_Name.prototype.start = function() { 1909 Scene_MenuBase.prototype.start.call(this); 1910 this._editWindow.refresh(); 1911}; 1912 1913Scene_Name.prototype.createEditWindow = function() { 1914 this._editWindow = new Window_NameEdit(this._actor, this._maxLength); 1915 this.addWindow(this._editWindow); 1916}; 1917 1918Scene_Name.prototype.createInputWindow = function() { 1919 this._inputWindow = new Window_NameInput(this._editWindow); 1920 this._inputWindow.setHandler('ok', this.onInputOk.bind(this)); 1921 this.addWindow(this._inputWindow); 1922}; 1923 1924Scene_Name.prototype.onInputOk = function() { 1925 this._actor.setName(this._editWindow.name()); 1926 this.popScene(); 1927}; 1928 1929//----------------------------------------------------------------------------- 1930// Scene_Debug 1931// 1932// The scene class of the debug screen. 1933 1934function Scene_Debug() { 1935 this.initialize.apply(this, arguments); 1936} 1937 1938Scene_Debug.prototype = Object.create(Scene_MenuBase.prototype); 1939Scene_Debug.prototype.constructor = Scene_Debug; 1940 1941Scene_Debug.prototype.initialize = function() { 1942 Scene_MenuBase.prototype.initialize.call(this); 1943}; 1944 1945Scene_Debug.prototype.create = function() { 1946 Scene_MenuBase.prototype.create.call(this); 1947 this.createRangeWindow(); 1948 this.createEditWindow(); 1949 this.createDebugHelpWindow(); 1950}; 1951 1952Scene_Debug.prototype.createRangeWindow = function() { 1953 this._rangeWindow = new Window_DebugRange(0, 0); 1954 this._rangeWindow.setHandler('ok', this.onRangeOk.bind(this)); 1955 this._rangeWindow.setHandler('cancel', this.popScene.bind(this)); 1956 this.addWindow(this._rangeWindow); 1957}; 1958 1959Scene_Debug.prototype.createEditWindow = function() { 1960 var wx = this._rangeWindow.width; 1961 var ww = Graphics.boxWidth - wx; 1962 this._editWindow = new Window_DebugEdit(wx, 0, ww); 1963 this._editWindow.setHandler('cancel', this.onEditCancel.bind(this)); 1964 this._rangeWindow.setEditWindow(this._editWindow); 1965 this.addWindow(this._editWindow); 1966}; 1967 1968Scene_Debug.prototype.createDebugHelpWindow = function() { 1969 var wx = this._editWindow.x; 1970 var wy = this._editWindow.height; 1971 var ww = this._editWindow.width; 1972 var wh = Graphics.boxHeight - wy; 1973 this._debugHelpWindow = new Window_Base(wx, wy, ww, wh); 1974 this.addWindow(this._debugHelpWindow); 1975}; 1976 1977Scene_Debug.prototype.onRangeOk = function() { 1978 this._editWindow.activate(); 1979 this._editWindow.select(0); 1980 this.refreshHelpWindow(); 1981}; 1982 1983Scene_Debug.prototype.onEditCancel = function() { 1984 this._rangeWindow.activate(); 1985 this._editWindow.deselect(); 1986 this.refreshHelpWindow(); 1987}; 1988 1989Scene_Debug.prototype.refreshHelpWindow = function() { 1990 this._debugHelpWindow.contents.clear(); 1991 if (this._editWindow.active) { 1992 this._debugHelpWindow.drawTextEx(this.helpText(), 4, 0); 1993 } 1994}; 1995 1996Scene_Debug.prototype.helpText = function() { 1997 if (this._rangeWindow.mode() === 'switch') { 1998 return 'Enter : ON / OFF'; 1999 } else { 2000 return ('Left : -1\n' + 2001 'Right : +1\n' + 2002 'Pageup : -10\n' + 2003 'Pagedown : +10'); 2004 } 2005}; 2006 2007//----------------------------------------------------------------------------- 2008// Scene_Battle 2009// 2010// The scene class of the battle screen. 2011 2012function Scene_Battle() { 2013 this.initialize.apply(this, arguments); 2014} 2015 2016Scene_Battle.prototype = Object.create(Scene_Base.prototype); 2017Scene_Battle.prototype.constructor = Scene_Battle; 2018 2019Scene_Battle.prototype.initialize = function() { 2020 Scene_Base.prototype.initialize.call(this); 2021}; 2022 2023Scene_Battle.prototype.create = function() { 2024 Scene_Base.prototype.create.call(this); 2025 this.createDisplayObjects(); 2026}; 2027 2028Scene_Battle.prototype.start = function() { 2029 Scene_Base.prototype.start.call(this); 2030 this.startFadeIn(this.fadeSpeed(), false); 2031 BattleManager.playBattleBgm(); 2032 BattleManager.startBattle(); 2033}; 2034 2035Scene_Battle.prototype.update = function() { 2036 var active = this.isActive(); 2037 $gameTimer.update(active); 2038 $gameScreen.update(); 2039 this.updateStatusWindow(); 2040 this.updateWindowPositions(); 2041 if (active && !this.isBusy()) { 2042 this.updateBattleProcess(); 2043 } 2044 Scene_Base.prototype.update.call(this); 2045}; 2046 2047Scene_Battle.prototype.updateBattleProcess = function() { 2048 if (!this.isAnyInputWindowActive() || BattleManager.isAborting() || 2049 BattleManager.isBattleEnd()) {
2050 BattleManager.update(); 2051 this.changeInputWindow(); 2052 } 2053}; 2054 2055Scene_Battle.prototype.isAnyInputWindowActive = function() { 2056 return (this._partyCommandWindow.active || 2057 this._actorCommandWindow.active || 2058 this._skillWindow.active || 2059 this._itemWindow.active || 2060 this._actorWindow.active || 2061 this._enemyWindow.active); 2062}; 2063 2064Scene_Battle.prototype.changeInputWindow = function() { 2065 if (BattleManager.isInputting()) { 2066 if (BattleManager.actor()) { 2067 this.startActorCommandSelection(); 2068 } else { 2069 this.startPartyCommandSelection(); 2070 } 2071 } else { 2072 this.endCommandSelection(); 2073 } 2074}; 2075 2076Scene_Battle.prototype.stop = function() { 2077 Scene_Base.prototype.stop.call(this); 2078 if (this.needsSlowFadeOut()) { 2079 this.startFadeOut(this.slowFadeSpeed(), false); 2080 } else { 2081 this.startFadeOut(this.fadeSpeed(), false); 2082 } 2083 this._statusWindow.close(); 2084 this._partyCommandWindow.close(); 2085 this._actorCommandWindow.close(); 2086}; 2087 2088Scene_Battle.prototype.terminate = function() { 2089 Scene_Base.prototype.terminate.call(this); 2090 $gameParty.onBattleEnd(); 2091 $gameTroop.onBattleEnd(); 2092 AudioManager.stopMe(); 2093}; 2094 2095Scene_Battle.prototype.needsSlowFadeOut = function() { 2096 return (SceneManager.isNextScene(Scene_Title) || 2097 SceneManager.isNextScene(Scene_Gameover)); 2098}; 2099 2100Scene_Battle.prototype.updateStatusWindow = function() { 2101 if ($gameMessage.isBusy()) { 2102 this._statusWindow.close(); 2103 this._partyCommandWindow.close(); 2104 this._actorCommandWindow.close(); 2105 } else if (this.isActive() && !this._messageWindow.isClosing()) { 2106 this._statusWindow.open(); 2107 } 2108}; 2109 2110Scene_Battle.prototype.updateWindowPositions = function() { 2111 var statusX = 0; 2112 if (BattleManager.isInputting()) { 2113 statusX = this._partyCommandWindow.width; 2114 } else { 2115 statusX = this._partyCommandWindow.width / 2; 2116 } 2117 if (this._statusWindow.x < statusX) { 2118 this._statusWindow.x += 16; 2119 if (this._statusWindow.x > statusX) { 2120 this._statusWindow.x = statusX; 2121 } 2122 } 2123 if (this._statusWindow.x > statusX) { 2124 this._statusWindow.x -= 16; 2125 if (this._statusWindow.x < statusX) { 2126 this._statusWindow.x = statusX; 2127 } 2128 } 2129}; 2130 2131Scene_Battle.prototype.createDisplayObjects = function() { 2132 this.createSpriteset(); 2133 this.createWindowLayer(); 2134 this.createAllWindows(); 2135 BattleManager.setLogWindow(this._logWindow); 2136 BattleManager.setStatusWindow(this._statusWindow); 2137 BattleManager.setSpriteset(this._spriteset); 2138 this._logWindow.setSpriteset(this._spriteset); 2139}; 2140 2141Scene_Battle.prototype.createSpriteset = function() { 2142 this._spriteset = new Spriteset_Battle(); 2143 this.addChild(this._spriteset); 2144}; 2145 2146Scene_Battle.prototype.createAllWindows = function() { 2147 this.createLogWindow(); 2148 this.createStatusWindow(); 2149 this.createPartyCommandWindow(); 2150 this.createActorCommandWindow(); 2151 this.createHelpWindow(); 2152 this.createSkillWindow(); 2153 this.createItemWindow(); 2154 this.createActorWindow(); 2155 this.createEnemyWindow(); 2156 this.createMessageWindow(); 2157 this.createScrollTextWindow(); 2158}; 2159 2160Scene_Battle.prototype.createLogWindow = function() { 2161 this._logWindow = new Window_BattleLog(); 2162 this.addWindow(this._logWindow); 2163}; 2164 2165Scene_Battle.prototype.createStatusWindow = function() { 2166 this._statusWindow = new Window_BattleStatus(); 2167 this.addWindow(this._statusWindow); 2168}; 2169 2170Scene_Battle.prototype.createPartyCommandWindow = function() { 2171 this._partyCommandWindow = new Window_PartyCommand(); 2172 this._partyCommandWindow.setHandler('fight', this.commandFight.bind(this)); 2173 this._partyCommandWindow.setHandler('escape', this.commandEscape.bind(this)); 2174 this._partyCommandWindow.deselect(); 2175 this.addWindow(this._partyCommandWindow); 2176}; 2177 2178Scene_Battle.prototype.createActorCommandWindow = function() { 2179 this._actorCommandWindow = new Window_ActorCommand(); 2180 this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this)); 2181 this._actorCommandWindow.setHandler('skill', this.commandSkill.bind(this)); 2182 this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this)); 2183 this._actorCommandWindow.setHandler('item', this.commandItem.bind(this)); 2184 this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this)); 2185 this.addWindow(this._actorCommandWindow); 2186}; 2187 2188Scene_Battle.prototype.createHelpWindow = function() { 2189 this._helpWindow = new Window_Help(); 2190 this._helpWindow.visible = false;
2191 this.addWindow(this._helpWindow); 2192}; 2193 2194Scene_Battle.prototype.createSkillWindow = function() { 2195 var wy = this._helpWindow.y + this._helpWindow.height; 2196 var wh = this._statusWindow.y - wy; 2197 this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh); 2198 this._skillWindow.setHelpWindow(this._helpWindow); 2199 this._skillWindow.setHandler('ok', this.onSkillOk.bind(this)); 2200 this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this)); 2201 this.addWindow(this._skillWindow); 2202}; 2203 2204Scene_Battle.prototype.createItemWindow = function() { 2205 var wy = this._helpWindow.y + this._helpWindow.height; 2206 var wh = this._statusWindow.y - wy; 2207 this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh); 2208 this._itemWindow.setHelpWindow(this._helpWindow); 2209 this._itemWindow.setHandler('ok', this.onItemOk.bind(this)); 2210 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this)); 2211 this.addWindow(this._itemWindow); 2212}; 2213 2214Scene_Battle.prototype.createActorWindow = function() { 2215 this._actorWindow = new Window_BattleActor(0, this._statusWindow.y); 2216 this._actorWindow.setHandler('ok', this.onActorOk.bind(this)); 2217 this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this)); 2218 this.addWindow(this._actorWindow); 2219}; 2220 2221Scene_Battle.prototype.createEnemyWindow = function() { 2222 this._enemyWindow = new Window_BattleEnemy(0, this._statusWindow.y); 2223 this._enemyWindow.x = Graphics.boxWidth - this._enemyWindow.width; 2224 this._enemyWindow.setHandler('ok', this.onEnemyOk.bind(this)); 2225 this._enemyWindow.setHandler('cancel', this.onEnemyCancel.bind(this)); 2226 this.addWindow(this._enemyWindow); 2227}; 2228 2229Scene_Battle.prototype.createMessageWindow = function() { 2230 this._messageWindow = new Window_Message(); 2231 this.addWindow(this._messageWindow); 2232 this._messageWindow.subWindows().forEach(function(window) { 2233 this.addWindow(window); 2234 }, this); 2235}; 2236 2237Scene_Battle.prototype.createScrollTextWindow = function() { 2238 this._scrollTextWindow = new Window_ScrollText(); 2239 this.addWindow(this._scrollTextWindow); 2240}; 2241 2242Scene_Battle.prototype.refreshStatus = function() { 2243 this._statusWindow.refresh(); 2244}; 2245 2246Scene_Battle.prototype.startPartyCommandSelection = function() { 2247 this.refreshStatus(); 2248 this._statusWindow.deselect(); 2249 this._statusWindow.open(); 2250 this._actorCommandWindow.close(); 2251 this._partyCommandWindow.setup(); 2252}; 2253 2254Scene_Battle.prototype.commandFight = function() { 2255 this.selectNextCommand(); 2256}; 2257 2258Scene_Battle.prototype.commandEscape = function() { 2259 BattleManager.processEscape(); 2260 this.changeInputWindow(); 2261}; 2262 2263Scene_Battle.prototype.startActorCommandSelection = function() { 2264 this._statusWindow.select(BattleManager.actor().index()); 2265 this._partyCommandWindow.close(); 2266 this._actorCommandWindow.setup(BattleManager.actor()); 2267}; 2268 2269Scene_Battle.prototype.commandAttack = function() { 2270 BattleManager.inputtingAction().setAttack(); 2271 this.selectEnemySelection(); 2272}; 2273 2274Scene_Battle.prototype.commandSkill = function() { 2275 this._skillWindow.setActor(BattleManager.actor()); 2276 this._skillWindow.setStypeId(this._actorCommandWindow.currentExt()); 2277 this._skillWindow.refresh(); 2278 this._skillWindow.show(); 2279 this._skillWindow.activate(); 2280}; 2281 2282Scene_Battle.prototype.commandGuard = function() { 2283 BattleManager.inputtingAction().setGuard(); 2284 this.selectNextCommand(); 2285}; 2286 2287Scene_Battle.prototype.commandItem = function() { 2288 this._itemWindow.refresh(); 2289 this._itemWindow.show(); 2290 this._itemWindow.activate(); 2291}; 2292 2293Scene_Battle.prototype.selectNextCommand = function() { 2294 BattleManager.selectNextCommand(); 2295 this.changeInputWindow(); 2296}; 2297 2298Scene_Battle.prototype.selectPreviousCommand = function() { 2299 BattleManager.selectPreviousCommand(); 2300 this.changeInputWindow(); 2301}; 2302 2303Scene_Battle.prototype.selectActorSelection = function() { 2304 this._actorWindow.refresh(); 2305 this._actorWindow.show(); 2306 this._actorWindow.activate(); 2307}; 2308 2309Scene_Battle.prototype.onActorOk = function() { 2310 var action = BattleManager.inputtingAction(); 2311 action.setTarget(this._actorWindow.index()); 2312 this._actorWindow.hide(); 2313 this._skillWindow.hide(); 2314 this._itemWindow.hide(); 2315 this.selectNextCommand(); 2316}; 2317 2318Scene_Battle.prototype.onActorCancel = function() { 2319 this._actorWindow.hide(); 2320 switch (this._actorCommandWindow.currentSymbol()) { 2321 case 'skill': 2322 this._skillWindow.show(); 2323 this._skillWindow.activate(); 2324 break; 2325 case 'item': 2326 this._itemWindow.show(); 2327 this._itemWindow.activate(); 2328 break; 2329 } 2330}; 2331 2332Scene_Battle.prototype.selectEnemySelection = function() { 2333 this._enemyWindow.refresh(); 2334 this._enemyWindow.show(); 2335 this._enemyWindow.select(0); 2336 this._enemyWindow.activate(); 2337}; 2338 2339Scene_Battle.prototype.onEnemyOk = function() { 2340 var action = BattleManager.inputtingAction(); 2341 action.setTarget(this._enemyWindow.enemyIndex()); 2342 this._enemyWindow.hide(); 2343 this._skillWindow.hide(); 2344 this._itemWindow.hide(); 2345 this.selectNextCommand(); 2346}; 2347 2348Scene_Battle.prototype.onEnemyCancel = function() { 2349 this._enemyWindow.hide(); 2350 switch (this._actorCommandWindow.currentSymbol()) { 2351 case 'attack': 2352 this._actorCommandWindow.activate(); 2353 break; 2354 case 'skill': 2355 this._skillWindow.show(); 2356 this._skillWindow.activate(); 2357 break; 2358 case 'item': 2359 this._itemWindow.show(); 2360 this._itemWindow.activate(); 2361 break; 2362 } 2363}; 2364 2365Scene_Battle.prototype.onSkillOk = function() { 2366 var skill = this._skillWindow.item(); 2367 var action = BattleManager.inputtingAction(); 2368 action.setSkill(skill.id); 2369 BattleManager.actor().setLastBattleSkill(skill); 2370 this.onSelectAction(); 2371}; 2372 2373Scene_Battle.prototype.onSkillCancel = function() { 2374 this._skillWindow.hide(); 2375 this._actorCommandWindow.activate(); 2376}; 2377 2378Scene_Battle.prototype.onItemOk = function() { 2379 var item = this._itemWindow.item(); 2380 var action = BattleManager.inputtingAction(); 2381 action.setItem(item.id); 2382 $gameParty.setLastItem(item); 2383 this.onSelectAction(); 2384}; 2385 2386Scene_Battle.prototype.onItemCancel = function() { 2387 this._itemWindow.hide(); 2388 this._actorCommandWindow.activate(); 2389}; 2390 2391Scene_Battle.prototype.onSelectAction = function() { 2392 var action = BattleManager.inputtingAction(); 2393 this._skillWindow.hide(); 2394 this._itemWindow.hide(); 2395 if (!action.needsSelection()) { 2396 this.selectNextCommand(); 2397 } else if (action.isForOpponent()) { 2398 this.selectEnemySelection(); 2399 } else { 2400 this.selectActorSelection(); 2401 } 2402}; 2403 2404Scene_Battle.prototype.endCommandSelection = function() { 2405 this._partyCommandWindow.close(); 2406 this._actorCommandWindow.close(); 2407 this._statusWindow.deselect(); 2408}; 2409 2410//----------------------------------------------------------------------------- 2411// Scene_Gameover 2412// 2413// The scene class of the game over screen. 2414 2415function Scene_Gameover() { 2416 this.initialize.apply(this, arguments); 2417} 2418 2419Scene_Gameover.prototype = Object.create(Scene_Base.prototype); 2420Scene_Gameover.prototype.constructor = Scene_Gameover; 2421 2422Scene_Gameover.prototype.initialize = function() { 2423 Scene_Base.prototype.initialize.call(this); 2424}; 2425 2426Scene_Gameover.prototype.create = function() { 2427 Scene_Base.prototype.create.call(this); 2428 this.playGameoverMusic();
2429 this.createBackground(); 2430}; 2431 2432Scene_Gameover.prototype.start = function() { 2433 Scene_Base.prototype.start.call(this); 2434 this.startFadeIn(this.slowFadeSpeed(), false); 2435}; 2436 2437Scene_Gameover.prototype.update = function() { 2438 if (this.isActive() && !this.isBusy() && this.isTriggered()) { 2439 this.gotoTitle(); 2440 } 2441 Scene_Base.prototype.update.call(this); 2442}; 2443 2444Scene_Gameover.prototype.stop = function() { 2445 Scene_Base.prototype.stop.call(this); 2446 this.fadeOutAll(); 2447}; 2448 2449Scene_Gameover.prototype.terminate = function() { 2450 Scene_Base.prototype.terminate.call(this); 2451 AudioManager.stopAll(); 2452}; 2453 2454Scene_Gameover.prototype.playGameoverMusic = function() { 2455 AudioManager.stopBgm(); 2456 AudioManager.stopBgs(); 2457 AudioManager.playMe($dataSystem.gameoverMe); 2458}; 2459 2460Scene_Gameover.prototype.createBackground = function() { 2461 this._backSprite = new Sprite(); 2462 this._backSprite.bitmap = ImageManager.loadSystem('GameOver'); 2463 this.addChild(this._backSprite); 2464}; 2465 2466Scene_Gameover.prototype.isTriggered = function() { 2467 return Input.isTriggered('ok') || TouchInput.isTriggered(); 2468}; 2469 2470Scene_Gameover.prototype.gotoTitle = function() { 2471 SceneManager.goto(Scene_Title); 2472};
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.