Best JavaScript code snippet using cypress
rpg_scenes.js
Source:rpg_scenes.js
1//=============================================================================2// rpg_scenes.js v1.6.23//=============================================================================4//=============================================================================5/**6 * The Superclass of all scene within the game.7 * 8 * @class Scene_Base9 * @constructor 10 * @extends Stage11 */12function Scene_Base() {13 this.initialize.apply(this, arguments);14}15Scene_Base.prototype = Object.create(Stage.prototype);16Scene_Base.prototype.constructor = Scene_Base;17/**18 * Create a instance of Scene_Base.19 * 20 * @instance 21 * @memberof Scene_Base22 */23Scene_Base.prototype.initialize = function() {24 Stage.prototype.initialize.call(this);25 this._active = false;26 this._fadeSign = 0;27 this._fadeDuration = 0;28 this._fadeSprite = null;29 this._imageReservationId = Utils.generateRuntimeId();30};31/**32 * Attach a reservation to the reserve queue.33 * 34 * @method attachReservation35 * @instance 36 * @memberof Scene_Base37 */38Scene_Base.prototype.attachReservation = function() {39 ImageManager.setDefaultReservationId(this._imageReservationId);40};41/**42 * Remove the reservation from the Reserve queue.43 * 44 * @method detachReservation45 * @instance 46 * @memberof Scene_Base47 */48Scene_Base.prototype.detachReservation = function() {49 ImageManager.releaseReservation(this._imageReservationId);50};51/**52 * Create the components and add them to the rendering process.53 * 54 * @method create55 * @instance 56 * @memberof Scene_Base57 */58Scene_Base.prototype.create = function() {59};60/**61 * Returns whether the scene is active or not.62 * 63 * @method isActive64 * @instance 65 * @memberof Scene_Base66 * @return {Boolean} return true if the scene is active67 */68Scene_Base.prototype.isActive = function() {69 return this._active;70};71/**72 * Return whether the scene is ready to start or not.73 * 74 * @method isReady75 * @instance 76 * @memberof Scene_Base77 * @return {Boolean} Return true if the scene is ready to start78 */79Scene_Base.prototype.isReady = function() {80 return ImageManager.isReady();81};82/**83 * Start the scene processing.84 * 85 * @method start86 * @instance 87 * @memberof Scene_Base88 */89Scene_Base.prototype.start = function() {90 this._active = true;91};92/**93 * Update the scene processing each new frame.94 * 95 * @method update96 * @instance 97 * @memberof Scene_Base98 */99Scene_Base.prototype.update = function() {100 this.updateFade();101 this.updateChildren();102};103/**104 * Stop the scene processing.105 * 106 * @method stop107 * @instance 108 * @memberof Scene_Base109 */110Scene_Base.prototype.stop = function() {111 this._active = false;112};113/**114 * Return whether the scene is busy or not.115 * 116 * @method isBusy117 * @instance118 * @memberof Scene_Base119 * @return {Boolean} Return true if the scene is currently busy120 */121Scene_Base.prototype.isBusy = function() {122 return this._fadeDuration > 0;123};124/**125 * Terminate the scene before switching to a another scene.126 * 127 * @method terminate128 * @instance 129 * @memberof Scene_Base130 */131Scene_Base.prototype.terminate = function() {132};133/**134 * Create the layer for the windows children135 * and add it to the rendering process.136 * 137 * @method createWindowLayer138 * @instance 139 * @memberof Scene_Base140 */141Scene_Base.prototype.createWindowLayer = function() {142 var width = Graphics.boxWidth;143 var height = Graphics.boxHeight;144 var x = (Graphics.width - width) / 2;145 var y = (Graphics.height - height) / 2;146 this._windowLayer = new WindowLayer();147 this._windowLayer.move(x, y, width, height);148 this.addChild(this._windowLayer);149};150/**151 * Add the children window to the windowLayer processing.152 * 153 * @method addWindow154 * @instance 155 * @memberof Scene_Base156 */157Scene_Base.prototype.addWindow = function(window) {158 this._windowLayer.addChild(window);159};160/**161 * Request a fadeIn screen process.162 * 163 * @method startFadeIn164 * @param {Number} [duration=30] The time the process will take for fadeIn the screen165 * @param {Boolean} [white=false] If true the fadein will be process with a white color else it's will be black166 * 167 * @instance 168 * @memberof Scene_Base169 */170Scene_Base.prototype.startFadeIn = function(duration, white) {171 this.createFadeSprite(white);172 this._fadeSign = 1;173 this._fadeDuration = duration || 30;174 this._fadeSprite.opacity = 255;175};176/**177 * Request a fadeOut screen process.178 * 179 * @method startFadeOut180 * @param {Number} [duration=30] The time the process will take for fadeOut the screen181 * @param {Boolean} [white=false] If true the fadeOut will be process with a white color else it's will be black182 * 183 * @instance 184 * @memberof Scene_Base185 */186Scene_Base.prototype.startFadeOut = function(duration, white) {187 this.createFadeSprite(white);188 this._fadeSign = -1;189 this._fadeDuration = duration || 30;190 this._fadeSprite.opacity = 0;191};192/**193 * Create a Screen sprite for the fadein and fadeOut purpose and194 * add it to the rendering process.195 * 196 * @method createFadeSprite197 * @instance 198 * @memberof Scene_Base199 */200Scene_Base.prototype.createFadeSprite = function(white) {201 if (!this._fadeSprite) {202 this._fadeSprite = new ScreenSprite();203 this.addChild(this._fadeSprite);204 }205 if (white) {206 this._fadeSprite.setWhite();207 } else {208 this._fadeSprite.setBlack();209 }210};211/**212 * Update the screen fade processing.213 * 214 * @method updateFade215 * @instance 216 * @memberof Scene_Base217 */218Scene_Base.prototype.updateFade = function() {219 if (this._fadeDuration > 0) {220 var d = this._fadeDuration;221 if (this._fadeSign > 0) {222 this._fadeSprite.opacity -= this._fadeSprite.opacity / d;223 } else {224 this._fadeSprite.opacity += (255 - this._fadeSprite.opacity) / d;225 }226 this._fadeDuration--;227 }228};229/**230 * Update the children of the scene EACH frame.231 * 232 * @method updateChildren233 * @instance 234 * @memberof Scene_Base235 */236Scene_Base.prototype.updateChildren = function() {237 this.children.forEach(function(child) {238 if (child.update) {239 child.update();240 }241 });242};243/**244 * Pop the scene from the stack array and switch to the245 * previous scene.246 * 247 * @method popScene248 * @instance 249 * @memberof Scene_Base250 */251Scene_Base.prototype.popScene = function() {252 SceneManager.pop();253};254/**255 * Check whether the game should be triggering a gameover.256 * 257 * @method checkGameover258 * @instance 259 * @memberof Scene_Base260 */261Scene_Base.prototype.checkGameover = function() {262 if ($gameParty.isAllDead()) {263 SceneManager.goto(Scene_Gameover);264 }265};266/**267 * Slowly fade out all the visual and audio of the scene.268 * 269 * @method fadeOutAll270 * @instance 271 * @memberof Scene_Base272 */273Scene_Base.prototype.fadeOutAll = function() {274 var time = this.slowFadeSpeed() / 60;275 AudioManager.fadeOutBgm(time);276 AudioManager.fadeOutBgs(time);277 AudioManager.fadeOutMe(time);278 this.startFadeOut(this.slowFadeSpeed());279};280/**281 * Return the screen fade speed value.282 * 283 * @method fadeSpeed284 * @instance 285 * @memberof Scene_Base286 * @return {Number} Return the fade speed287 */288Scene_Base.prototype.fadeSpeed = function() {289 return 24;290};291/**292 * Return a slow screen fade speed value.293 * 294 * @method slowFadeSpeed295 * @instance 296 * @memberof Scene_Base297 * @return {Number} Return the fade speed298 */299Scene_Base.prototype.slowFadeSpeed = function() {300 return this.fadeSpeed() * 2;301};302//-----------------------------------------------------------------------------303// Scene_Boot304//305// The scene class for initializing the entire game.306function Scene_Boot() {307 this.initialize.apply(this, arguments);308}309Scene_Boot.prototype = Object.create(Scene_Base.prototype);310Scene_Boot.prototype.constructor = Scene_Boot;311Scene_Boot.prototype.initialize = function() {312 Scene_Base.prototype.initialize.call(this);313 this._startDate = Date.now();314};315Scene_Boot.prototype.create = function() {316 Scene_Base.prototype.create.call(this);317 DataManager.loadDatabase();318 ConfigManager.load();319 this.loadSystemWindowImage();320};321Scene_Boot.prototype.loadSystemWindowImage = function() {322 ImageManager.reserveSystem('Window');323};324Scene_Boot.loadSystemImages = function() {325 ImageManager.reserveSystem('IconSet');326 ImageManager.reserveSystem('Balloon');327 ImageManager.reserveSystem('Shadow1');328 ImageManager.reserveSystem('Shadow2');329 ImageManager.reserveSystem('Damage');330 ImageManager.reserveSystem('States');331 ImageManager.reserveSystem('Weapons1');332 ImageManager.reserveSystem('Weapons2');333 ImageManager.reserveSystem('Weapons3');334 ImageManager.reserveSystem('ButtonSet');335};336Scene_Boot.prototype.isReady = function() {337 if (Scene_Base.prototype.isReady.call(this)) {338 return DataManager.isDatabaseLoaded() && this.isGameFontLoaded();339 } else {340 return false;341 }342};343Scene_Boot.prototype.isGameFontLoaded = function() {344 if (Graphics.isFontLoaded('GameFont')) {345 return true;346 } else if (!Graphics.canUseCssFontLoading()){347 var elapsed = Date.now() - this._startDate;348 if (elapsed >= 60000) {349 throw new Error('Failed to load GameFont');350 }351 }352};353Scene_Boot.prototype.start = function() {354 Scene_Base.prototype.start.call(this);355 SoundManager.preloadImportantSounds();356 if (DataManager.isBattleTest()) {357 DataManager.setupBattleTest();358 SceneManager.goto(Scene_Battle);359 } else if (DataManager.isEventTest()) {360 DataManager.setupEventTest();361 SceneManager.goto(Scene_Map);362 } else {363 this.checkPlayerLocation();364 DataManager.setupNewGame();365 SceneManager.goto(Scene_Title);366 Window_TitleCommand.initCommandPosition();367 }368 this.updateDocumentTitle();369};370Scene_Boot.prototype.updateDocumentTitle = function() {371 document.title = $dataSystem.gameTitle;372};373Scene_Boot.prototype.checkPlayerLocation = function() {374 if ($dataSystem.startMapId === 0) {375 throw new Error('Player\'s starting position is not set');376 }377};378//-----------------------------------------------------------------------------379// Scene_Title380//381// The scene class of the title screen.382function Scene_Title() {383 this.initialize.apply(this, arguments);384}385Scene_Title.prototype = Object.create(Scene_Base.prototype);386Scene_Title.prototype.constructor = Scene_Title;387Scene_Title.prototype.initialize = function() {388 Scene_Base.prototype.initialize.call(this);389};390Scene_Title.prototype.create = function() {391 Scene_Base.prototype.create.call(this);392 this.createBackground();393 this.createForeground();394 this.createWindowLayer();395 this.createCommandWindow();396};397Scene_Title.prototype.start = function() {398 Scene_Base.prototype.start.call(this);399 SceneManager.clearStack();400 this.centerSprite(this._backSprite1);401 this.centerSprite(this._backSprite2);402 this.playTitleMusic();403 this.startFadeIn(this.fadeSpeed(), false);404};405Scene_Title.prototype.update = function() {406 if (!this.isBusy()) {407 this._commandWindow.open();408 }409 Scene_Base.prototype.update.call(this);410};411Scene_Title.prototype.isBusy = function() {412 return this._commandWindow.isClosing() || Scene_Base.prototype.isBusy.call(this);413};414Scene_Title.prototype.terminate = function() {415 Scene_Base.prototype.terminate.call(this);416 SceneManager.snapForBackground();417};418Scene_Title.prototype.createBackground = function() {419 this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));420 this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));421 this.addChild(this._backSprite1);422 this.addChild(this._backSprite2);423};424Scene_Title.prototype.createForeground = function() {425 this._gameTitleSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));426 this.addChild(this._gameTitleSprite);427 if ($dataSystem.optDrawTitle) {428 this.drawGameTitle();429 }430};431Scene_Title.prototype.drawGameTitle = function() {432 var x = 20;433 var y = Graphics.height / 4;434 var maxWidth = Graphics.width - x * 2;435 var text = $dataSystem.gameTitle;436 this._gameTitleSprite.bitmap.outlineColor = 'black';437 this._gameTitleSprite.bitmap.outlineWidth = 8;438 this._gameTitleSprite.bitmap.fontSize = 72;439 this._gameTitleSprite.bitmap.drawText(text, x, y, maxWidth, 48, 'center');440};441Scene_Title.prototype.centerSprite = function(sprite) {442 sprite.x = Graphics.width / 2;443 sprite.y = Graphics.height / 2;444 sprite.anchor.x = 0.5;445 sprite.anchor.y = 0.5;446};447Scene_Title.prototype.createCommandWindow = function() {448 this._commandWindow = new Window_TitleCommand();449 this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));450 this._commandWindow.setHandler('continue', this.commandContinue.bind(this));451 this._commandWindow.setHandler('options', this.commandOptions.bind(this));452 this.addWindow(this._commandWindow);453};454Scene_Title.prototype.commandNewGame = function() {455 DataManager.setupNewGame();456 this._commandWindow.close();457 this.fadeOutAll();458 SceneManager.goto(Scene_Map);459};460Scene_Title.prototype.commandContinue = function() {461 this._commandWindow.close();462 SceneManager.push(Scene_Load);463};464Scene_Title.prototype.commandOptions = function() {465 this._commandWindow.close();466 SceneManager.push(Scene_Options);467};468Scene_Title.prototype.playTitleMusic = function() {469 AudioManager.playBgm($dataSystem.titleBgm);470 AudioManager.stopBgs();471 AudioManager.stopMe();472};473//-----------------------------------------------------------------------------474// Scene_Map475//476// The scene class of the map screen.477function Scene_Map() {478 this.initialize.apply(this, arguments);479}480Scene_Map.prototype = Object.create(Scene_Base.prototype);481Scene_Map.prototype.constructor = Scene_Map;482Scene_Map.prototype.initialize = function() {483 Scene_Base.prototype.initialize.call(this);484 this._waitCount = 0;485 this._encounterEffectDuration = 0;486 this._mapLoaded = false;487 this._touchCount = 0;488};489Scene_Map.prototype.create = function() {490 Scene_Base.prototype.create.call(this);491 this._transfer = $gamePlayer.isTransferring();492 var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();493 DataManager.loadMapData(mapId);494};495Scene_Map.prototype.isReady = function() {496 if (!this._mapLoaded && DataManager.isMapLoaded()) {497 this.onMapLoaded();498 this._mapLoaded = true;499 }500 return this._mapLoaded && Scene_Base.prototype.isReady.call(this);501};502Scene_Map.prototype.onMapLoaded = function() {503 if (this._transfer) {504 $gamePlayer.performTransfer();505 }506 this.createDisplayObjects();507};508Scene_Map.prototype.start = function() {509 Scene_Base.prototype.start.call(this);510 SceneManager.clearStack();511 if (this._transfer) {512 this.fadeInForTransfer();513 this._mapNameWindow.open();514 $gameMap.autoplay();515 } else if (this.needsFadeIn()) {516 this.startFadeIn(this.fadeSpeed(), false);517 }518 this.menuCalling = false;519};520Scene_Map.prototype.update = function() {521 this.updateDestination();522 this.updateMainMultiply();523 if (this.isSceneChangeOk()) {524 this.updateScene();525 } else if (SceneManager.isNextScene(Scene_Battle)) {526 this.updateEncounterEffect();527 }528 this.updateWaitCount();529 Scene_Base.prototype.update.call(this);530};531Scene_Map.prototype.updateMainMultiply = function() {532 this.updateMain();533 if (this.isFastForward()) {534 this.updateMain();535 }536};537Scene_Map.prototype.updateMain = function() {538 var active = this.isActive();539 $gameMap.update(active);540 $gamePlayer.update(active);541 $gameTimer.update(active);542 $gameScreen.update();543};544Scene_Map.prototype.isFastForward = function() {545 return ($gameMap.isEventRunning() && !SceneManager.isSceneChanging() &&546 (Input.isLongPressed('ok') || TouchInput.isLongPressed()));547};548Scene_Map.prototype.stop = function() {549 Scene_Base.prototype.stop.call(this);550 $gamePlayer.straighten();551 this._mapNameWindow.close();552 if (this.needsSlowFadeOut()) {553 this.startFadeOut(this.slowFadeSpeed(), false);554 } else if (SceneManager.isNextScene(Scene_Map)) {555 this.fadeOutForTransfer();556 } else if (SceneManager.isNextScene(Scene_Battle)) {557 this.launchBattle();558 }559};560Scene_Map.prototype.isBusy = function() {561 return ((this._messageWindow && this._messageWindow.isClosing()) ||562 this._waitCount > 0 || this._encounterEffectDuration > 0 ||563 Scene_Base.prototype.isBusy.call(this));564};565Scene_Map.prototype.terminate = function() {566 Scene_Base.prototype.terminate.call(this);567 if (!SceneManager.isNextScene(Scene_Battle)) {568 this._spriteset.update();569 this._mapNameWindow.hide();570 SceneManager.snapForBackground();571 } else {572 ImageManager.clearRequest();573 }574 if (SceneManager.isNextScene(Scene_Map)) {575 ImageManager.clearRequest();576 }577 $gameScreen.clearZoom();578 this.removeChild(this._fadeSprite);579 this.removeChild(this._mapNameWindow);580 this.removeChild(this._windowLayer);581 this.removeChild(this._spriteset);582};583Scene_Map.prototype.needsFadeIn = function() {584 return (SceneManager.isPreviousScene(Scene_Battle) ||585 SceneManager.isPreviousScene(Scene_Load));586};587Scene_Map.prototype.needsSlowFadeOut = function() {588 return (SceneManager.isNextScene(Scene_Title) ||589 SceneManager.isNextScene(Scene_Gameover));590};591Scene_Map.prototype.updateWaitCount = function() {592 if (this._waitCount > 0) {593 this._waitCount--;594 return true;595 }596 return false;597};598Scene_Map.prototype.updateDestination = function() {599 if (this.isMapTouchOk()) {600 this.processMapTouch();601 } else {602 $gameTemp.clearDestination();603 this._touchCount = 0;604 }605};606Scene_Map.prototype.isMapTouchOk = function() {607 return this.isActive() && $gamePlayer.canMove();608};609Scene_Map.prototype.processMapTouch = function() {610 if (TouchInput.isTriggered() || this._touchCount > 0) {611 if (TouchInput.isPressed()) {612 if (this._touchCount === 0 || this._touchCount >= 15) {613 var x = $gameMap.canvasToMapX(TouchInput.x);614 var y = $gameMap.canvasToMapY(TouchInput.y);615 $gameTemp.setDestination(x, y);616 }617 this._touchCount++;618 } else {619 this._touchCount = 0;620 }621 }622};623Scene_Map.prototype.isSceneChangeOk = function() {624 return this.isActive() && !$gameMessage.isBusy();625};626Scene_Map.prototype.updateScene = function() {627 this.checkGameover();628 if (!SceneManager.isSceneChanging()) {629 this.updateTransferPlayer();630 }631 if (!SceneManager.isSceneChanging()) {632 this.updateEncounter();633 }634 if (!SceneManager.isSceneChanging()) {635 this.updateCallMenu();636 }637 if (!SceneManager.isSceneChanging()) {638 this.updateCallDebug();639 }640};641Scene_Map.prototype.createDisplayObjects = function() {642 this.createSpriteset();643 this.createMapNameWindow();644 this.createWindowLayer();645 this.createAllWindows();646};647Scene_Map.prototype.createSpriteset = function() {648 this._spriteset = new Spriteset_Map();649 this.addChild(this._spriteset);650};651Scene_Map.prototype.createAllWindows = function() {652 this.createMessageWindow();653 this.createScrollTextWindow();654};655Scene_Map.prototype.createMapNameWindow = function() {656 this._mapNameWindow = new Window_MapName();657 this.addChild(this._mapNameWindow);658};659Scene_Map.prototype.createMessageWindow = function() {660 this._messageWindow = new Window_Message();661 this.addWindow(this._messageWindow);662 this._messageWindow.subWindows().forEach(function(window) {663 this.addWindow(window);664 }, this);665};666Scene_Map.prototype.createScrollTextWindow = function() {667 this._scrollTextWindow = new Window_ScrollText();668 this.addWindow(this._scrollTextWindow);669};670Scene_Map.prototype.updateTransferPlayer = function() {671 if ($gamePlayer.isTransferring()) {672 SceneManager.goto(Scene_Map);673 }674};675Scene_Map.prototype.updateEncounter = function() {676 if ($gamePlayer.executeEncounter()) {677 SceneManager.push(Scene_Battle);678 }679};680Scene_Map.prototype.updateCallMenu = function() {681 if (this.isMenuEnabled()) {682 if (this.isMenuCalled()) {683 this.menuCalling = true;684 }685 if (this.menuCalling && !$gamePlayer.isMoving()) {686 this.callMenu();687 }688 } else {689 this.menuCalling = false;690 }691};692Scene_Map.prototype.isMenuEnabled = function() {693 return $gameSystem.isMenuEnabled() && !$gameMap.isEventRunning();694};695Scene_Map.prototype.isMenuCalled = function() {696 return Input.isTriggered('menu') || TouchInput.isCancelled();697};698Scene_Map.prototype.callMenu = function() {699 SoundManager.playOk();700 SceneManager.push(Scene_Menu);701 Window_MenuCommand.initCommandPosition();702 $gameTemp.clearDestination();703 this._mapNameWindow.hide();704 this._waitCount = 2;705};706Scene_Map.prototype.updateCallDebug = function() {707 if (this.isDebugCalled()) {708 SceneManager.push(Scene_Debug);709 }710};711Scene_Map.prototype.isDebugCalled = function() {712 return Input.isTriggered('debug') && $gameTemp.isPlaytest();713};714Scene_Map.prototype.fadeInForTransfer = function() {715 var fadeType = $gamePlayer.fadeType();716 switch (fadeType) {717 case 0: case 1:718 this.startFadeIn(this.fadeSpeed(), fadeType === 1);719 break;720 }721};722Scene_Map.prototype.fadeOutForTransfer = function() {723 var fadeType = $gamePlayer.fadeType();724 switch (fadeType) {725 case 0: case 1:726 this.startFadeOut(this.fadeSpeed(), fadeType === 1);727 break;728 }729};730Scene_Map.prototype.launchBattle = function() {731 BattleManager.saveBgmAndBgs();732 this.stopAudioOnBattleStart();733 SoundManager.playBattleStart();734 this.startEncounterEffect();735 this._mapNameWindow.hide();736};737Scene_Map.prototype.stopAudioOnBattleStart = function() {738 if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) {739 AudioManager.stopBgm();740 }741 AudioManager.stopBgs();742 AudioManager.stopMe();743 AudioManager.stopSe();744};745Scene_Map.prototype.startEncounterEffect = function() {746 this._spriteset.hideCharacters();747 this._encounterEffectDuration = this.encounterEffectSpeed();748};749Scene_Map.prototype.updateEncounterEffect = function() {750 if (this._encounterEffectDuration > 0) {751 this._encounterEffectDuration--;752 var speed = this.encounterEffectSpeed();753 var n = speed - this._encounterEffectDuration;754 var p = n / speed;755 var q = ((p - 1) * 20 * p + 5) * p + 1;756 var zoomX = $gamePlayer.screenX();757 var zoomY = $gamePlayer.screenY() - 24;758 if (n === 2) {759 $gameScreen.setZoom(zoomX, zoomY, 1);760 this.snapForBattleBackground();761 this.startFlashForEncounter(speed / 2);762 }763 $gameScreen.setZoom(zoomX, zoomY, q);764 if (n === Math.floor(speed / 6)) {765 this.startFlashForEncounter(speed / 2);766 }767 if (n === Math.floor(speed / 2)) {768 BattleManager.playBattleBgm();769 this.startFadeOut(this.fadeSpeed());770 }771 }772};773Scene_Map.prototype.snapForBattleBackground = function() {774 this._windowLayer.visible = false;775 SceneManager.snapForBackground();776 this._windowLayer.visible = true;777};778Scene_Map.prototype.startFlashForEncounter = function(duration) {779 var color = [255, 255, 255, 255];780 $gameScreen.startFlash(color, duration);781};782Scene_Map.prototype.encounterEffectSpeed = function() {783 return 60;784};785//-----------------------------------------------------------------------------786// Scene_MenuBase787//788// The superclass of all the menu-type scenes.789function Scene_MenuBase() {790 this.initialize.apply(this, arguments);791}792Scene_MenuBase.prototype = Object.create(Scene_Base.prototype);793Scene_MenuBase.prototype.constructor = Scene_MenuBase;794Scene_MenuBase.prototype.initialize = function() {795 Scene_Base.prototype.initialize.call(this);796};797Scene_MenuBase.prototype.create = function() {798 Scene_Base.prototype.create.call(this);799 this.createBackground();800 this.updateActor();801 this.createWindowLayer();802};803Scene_MenuBase.prototype.actor = function() {804 return this._actor;805};806Scene_MenuBase.prototype.updateActor = function() {807 this._actor = $gameParty.menuActor();808};809Scene_MenuBase.prototype.createBackground = function() {810 this._backgroundSprite = new Sprite();811 this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();812 this.addChild(this._backgroundSprite);813};814Scene_MenuBase.prototype.setBackgroundOpacity = function(opacity) {815 this._backgroundSprite.opacity = opacity;816};817Scene_MenuBase.prototype.createHelpWindow = function() {818 this._helpWindow = new Window_Help();819 this.addWindow(this._helpWindow);820};821Scene_MenuBase.prototype.nextActor = function() {822 $gameParty.makeMenuActorNext();823 this.updateActor();824 this.onActorChange();825};826Scene_MenuBase.prototype.previousActor = function() {827 $gameParty.makeMenuActorPrevious();828 this.updateActor();829 this.onActorChange();830};831Scene_MenuBase.prototype.onActorChange = function() {832};833//-----------------------------------------------------------------------------834// Scene_Menu835//836// The scene class of the menu screen.837function Scene_Menu() {838 this.initialize.apply(this, arguments);839}840Scene_Menu.prototype = Object.create(Scene_MenuBase.prototype);841Scene_Menu.prototype.constructor = Scene_Menu;842Scene_Menu.prototype.initialize = function() {843 Scene_MenuBase.prototype.initialize.call(this);844};845Scene_Menu.prototype.create = function() {846 Scene_MenuBase.prototype.create.call(this);847 this.createCommandWindow();848 this.createGoldWindow();849 this.createStatusWindow();850};851Scene_Menu.prototype.start = function() {852 Scene_MenuBase.prototype.start.call(this);853 this._statusWindow.refresh();854};855Scene_Menu.prototype.createCommandWindow = function() {856 this._commandWindow = new Window_MenuCommand(0, 0);857 this._commandWindow.setHandler('item', this.commandItem.bind(this));858 this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));859 this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));860 this._commandWindow.setHandler('status', this.commandPersonal.bind(this));861 this._commandWindow.setHandler('formation', this.commandFormation.bind(this));862 this._commandWindow.setHandler('options', this.commandOptions.bind(this));863 this._commandWindow.setHandler('save', this.commandSave.bind(this));864 this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));865 this._commandWindow.setHandler('cancel', this.popScene.bind(this));866 this.addWindow(this._commandWindow);867};868Scene_Menu.prototype.createGoldWindow = function() {869 this._goldWindow = new Window_Gold(0, 0);870 this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;871 this.addWindow(this._goldWindow);872};873Scene_Menu.prototype.createStatusWindow = function() {874 this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0);875 this._statusWindow.reserveFaceImages();876 this.addWindow(this._statusWindow);877};878Scene_Menu.prototype.commandItem = function() {879 SceneManager.push(Scene_Item);880};881Scene_Menu.prototype.commandPersonal = function() {882 this._statusWindow.setFormationMode(false);883 this._statusWindow.selectLast();884 this._statusWindow.activate();885 this._statusWindow.setHandler('ok', this.onPersonalOk.bind(this));886 this._statusWindow.setHandler('cancel', this.onPersonalCancel.bind(this));887};888Scene_Menu.prototype.commandFormation = function() {889 this._statusWindow.setFormationMode(true);890 this._statusWindow.selectLast();891 this._statusWindow.activate();892 this._statusWindow.setHandler('ok', this.onFormationOk.bind(this));893 this._statusWindow.setHandler('cancel', this.onFormationCancel.bind(this));894};895Scene_Menu.prototype.commandOptions = function() {896 SceneManager.push(Scene_Options);897};898Scene_Menu.prototype.commandSave = function() {899 SceneManager.push(Scene_Save);900};901Scene_Menu.prototype.commandGameEnd = function() {902 SceneManager.push(Scene_GameEnd);903};904Scene_Menu.prototype.onPersonalOk = function() {905 switch (this._commandWindow.currentSymbol()) {906 case 'skill':907 SceneManager.push(Scene_Skill);908 break;909 case 'equip':910 SceneManager.push(Scene_Equip);911 break;912 case 'status':913 SceneManager.push(Scene_Status);914 break;915 }916};917Scene_Menu.prototype.onPersonalCancel = function() {918 this._statusWindow.deselect();919 this._commandWindow.activate();920};921Scene_Menu.prototype.onFormationOk = function() {922 var index = this._statusWindow.index();923 var actor = $gameParty.members()[index];924 var pendingIndex = this._statusWindow.pendingIndex();925 if (pendingIndex >= 0) {926 $gameParty.swapOrder(index, pendingIndex);927 this._statusWindow.setPendingIndex(-1);928 this._statusWindow.redrawItem(index);929 } else {930 this._statusWindow.setPendingIndex(index);931 }932 this._statusWindow.activate();933};934Scene_Menu.prototype.onFormationCancel = function() {935 if (this._statusWindow.pendingIndex() >= 0) {936 this._statusWindow.setPendingIndex(-1);937 this._statusWindow.activate();938 } else {939 this._statusWindow.deselect();940 this._commandWindow.activate();941 }942};943//-----------------------------------------------------------------------------944// Scene_ItemBase945//946// The superclass of Scene_Item and Scene_Skill.947function Scene_ItemBase() {948 this.initialize.apply(this, arguments);949}950Scene_ItemBase.prototype = Object.create(Scene_MenuBase.prototype);951Scene_ItemBase.prototype.constructor = Scene_ItemBase;952Scene_ItemBase.prototype.initialize = function() {953 Scene_MenuBase.prototype.initialize.call(this);954};955Scene_ItemBase.prototype.create = function() {956 Scene_MenuBase.prototype.create.call(this);957};958Scene_ItemBase.prototype.createActorWindow = function() {959 this._actorWindow = new Window_MenuActor();960 this._actorWindow.setHandler('ok', this.onActorOk.bind(this));961 this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));962 this.addWindow(this._actorWindow);963};964Scene_ItemBase.prototype.item = function() {965 return this._itemWindow.item();966};967Scene_ItemBase.prototype.user = function() {968 return null;969};970Scene_ItemBase.prototype.isCursorLeft = function() {971 return this._itemWindow.index() % 2 === 0;972};973Scene_ItemBase.prototype.showSubWindow = function(window) {974 window.x = this.isCursorLeft() ? Graphics.boxWidth - window.width : 0;975 window.show();976 window.activate();977};978Scene_ItemBase.prototype.hideSubWindow = function(window) {979 window.hide();980 window.deactivate();981 this.activateItemWindow();982};983Scene_ItemBase.prototype.onActorOk = function() {984 if (this.canUse()) {985 this.useItem();986 } else {987 SoundManager.playBuzzer();988 }989};990Scene_ItemBase.prototype.onActorCancel = function() {991 this.hideSubWindow(this._actorWindow);992};993Scene_ItemBase.prototype.determineItem = function() {994 var action = new Game_Action(this.user());995 var item = this.item();996 action.setItemObject(item);997 if (action.isForFriend()) {998 this.showSubWindow(this._actorWindow);999 this._actorWindow.selectForItem(this.item());1000 } else {1001 this.useItem();1002 this.activateItemWindow();1003 }1004};1005Scene_ItemBase.prototype.useItem = function() {1006 this.playSeForItem();1007 this.user().useItem(this.item());1008 this.applyItem();1009 this.checkCommonEvent();1010 this.checkGameover();1011 this._actorWindow.refresh();1012};1013Scene_ItemBase.prototype.activateItemWindow = function() {1014 this._itemWindow.refresh();1015 this._itemWindow.activate();1016};1017Scene_ItemBase.prototype.itemTargetActors = function() {1018 var action = new Game_Action(this.user());1019 action.setItemObject(this.item());1020 if (!action.isForFriend()) {1021 return [];1022 } else if (action.isForAll()) {1023 return $gameParty.members();1024 } else {1025 return [$gameParty.members()[this._actorWindow.index()]];1026 }1027};1028Scene_ItemBase.prototype.canUse = function() {1029 return this.user().canUse(this.item()) && this.isItemEffectsValid();1030};1031Scene_ItemBase.prototype.isItemEffectsValid = function() {1032 var action = new Game_Action(this.user());1033 action.setItemObject(this.item());1034 return this.itemTargetActors().some(function(target) {1035 return action.testApply(target);1036 }, this);1037};1038Scene_ItemBase.prototype.applyItem = function() {1039 var action = new Game_Action(this.user());1040 action.setItemObject(this.item());1041 this.itemTargetActors().forEach(function(target) {1042 for (var i = 0; i < action.numRepeats(); i++) {1043 action.apply(target);1044 }1045 }, this);1046 action.applyGlobal();1047};1048Scene_ItemBase.prototype.checkCommonEvent = function() {1049 if ($gameTemp.isCommonEventReserved()) {1050 SceneManager.goto(Scene_Map);1051 }1052};1053//-----------------------------------------------------------------------------1054// Scene_Item1055//1056// The scene class of the item screen.1057function Scene_Item() {1058 this.initialize.apply(this, arguments);1059}1060Scene_Item.prototype = Object.create(Scene_ItemBase.prototype);1061Scene_Item.prototype.constructor = Scene_Item;1062Scene_Item.prototype.initialize = function() {1063 Scene_ItemBase.prototype.initialize.call(this);1064};1065Scene_Item.prototype.create = function() {1066 Scene_ItemBase.prototype.create.call(this);1067 this.createHelpWindow();1068 this.createCategoryWindow();1069 this.createItemWindow();1070 this.createActorWindow();1071};1072Scene_Item.prototype.createCategoryWindow = function() {1073 this._categoryWindow = new Window_ItemCategory();1074 this._categoryWindow.setHelpWindow(this._helpWindow);1075 this._categoryWindow.y = this._helpWindow.height;1076 this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));1077 this._categoryWindow.setHandler('cancel', this.popScene.bind(this));1078 this.addWindow(this._categoryWindow);1079};1080Scene_Item.prototype.createItemWindow = function() {1081 var wy = this._categoryWindow.y + this._categoryWindow.height;1082 var wh = Graphics.boxHeight - wy;1083 this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh);1084 this._itemWindow.setHelpWindow(this._helpWindow);1085 this._itemWindow.setHandler('ok', this.onItemOk.bind(this));1086 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));1087 this.addWindow(this._itemWindow);1088 this._categoryWindow.setItemWindow(this._itemWindow);1089};1090Scene_Item.prototype.user = function() {1091 var members = $gameParty.movableMembers();1092 var bestActor = members[0];1093 var bestPha = 0;1094 for (var i = 0; i < members.length; i++) {1095 if (members[i].pha > bestPha) {1096 bestPha = members[i].pha;1097 bestActor = members[i];1098 }1099 }1100 return bestActor;1101};1102Scene_Item.prototype.onCategoryOk = function() {1103 this._itemWindow.activate();1104 this._itemWindow.selectLast();1105};1106Scene_Item.prototype.onItemOk = function() {1107 $gameParty.setLastItem(this.item());1108 this.determineItem();1109};1110Scene_Item.prototype.onItemCancel = function() {1111 this._itemWindow.deselect();1112 this._categoryWindow.activate();1113};1114Scene_Item.prototype.playSeForItem = function() {1115 SoundManager.playUseItem();1116};1117Scene_Item.prototype.useItem = function() {1118 Scene_ItemBase.prototype.useItem.call(this);1119 this._itemWindow.redrawCurrentItem();1120};1121//-----------------------------------------------------------------------------1122// Scene_Skill1123//1124// The scene class of the skill screen.1125function Scene_Skill() {1126 this.initialize.apply(this, arguments);1127}1128Scene_Skill.prototype = Object.create(Scene_ItemBase.prototype);1129Scene_Skill.prototype.constructor = Scene_Skill;1130Scene_Skill.prototype.initialize = function() {1131 Scene_ItemBase.prototype.initialize.call(this);1132};1133Scene_Skill.prototype.create = function() {1134 Scene_ItemBase.prototype.create.call(this);1135 this.createHelpWindow();1136 this.createSkillTypeWindow();1137 this.createStatusWindow();1138 this.createItemWindow();1139 this.createActorWindow();1140};1141Scene_Skill.prototype.start = function() {1142 Scene_ItemBase.prototype.start.call(this);1143 this.refreshActor();1144};1145Scene_Skill.prototype.createSkillTypeWindow = function() {1146 var wy = this._helpWindow.height;1147 this._skillTypeWindow = new Window_SkillType(0, wy);1148 this._skillTypeWindow.setHelpWindow(this._helpWindow);1149 this._skillTypeWindow.setHandler('skill', this.commandSkill.bind(this));1150 this._skillTypeWindow.setHandler('cancel', this.popScene.bind(this));1151 this._skillTypeWindow.setHandler('pagedown', this.nextActor.bind(this));1152 this._skillTypeWindow.setHandler('pageup', this.previousActor.bind(this));1153 this.addWindow(this._skillTypeWindow);1154};1155Scene_Skill.prototype.createStatusWindow = function() {1156 var wx = this._skillTypeWindow.width;1157 var wy = this._helpWindow.height;1158 var ww = Graphics.boxWidth - wx;1159 var wh = this._skillTypeWindow.height;1160 this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh);1161 this._statusWindow.reserveFaceImages();1162 this.addWindow(this._statusWindow);1163};1164Scene_Skill.prototype.createItemWindow = function() {1165 var wx = 0;1166 var wy = this._statusWindow.y + this._statusWindow.height;1167 var ww = Graphics.boxWidth;1168 var wh = Graphics.boxHeight - wy;1169 this._itemWindow = new Window_SkillList(wx, wy, ww, wh);1170 this._itemWindow.setHelpWindow(this._helpWindow);1171 this._itemWindow.setHandler('ok', this.onItemOk.bind(this));1172 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));1173 this._skillTypeWindow.setSkillWindow(this._itemWindow);1174 this.addWindow(this._itemWindow);1175};1176Scene_Skill.prototype.refreshActor = function() {1177 var actor = this.actor();1178 this._skillTypeWindow.setActor(actor);1179 this._statusWindow.setActor(actor);1180 this._itemWindow.setActor(actor);1181};1182Scene_Skill.prototype.user = function() {1183 return this.actor();1184};1185Scene_Skill.prototype.commandSkill = function() {1186 this._itemWindow.activate();1187 this._itemWindow.selectLast();1188};1189Scene_Skill.prototype.onItemOk = function() {1190 this.actor().setLastMenuSkill(this.item());1191 this.determineItem();1192};1193Scene_Skill.prototype.onItemCancel = function() {1194 this._itemWindow.deselect();1195 this._skillTypeWindow.activate();1196};1197Scene_Skill.prototype.playSeForItem = function() {1198 SoundManager.playUseSkill();1199};1200Scene_Skill.prototype.useItem = function() {1201 Scene_ItemBase.prototype.useItem.call(this);1202 this._statusWindow.refresh();1203 this._itemWindow.refresh();1204};1205Scene_Skill.prototype.onActorChange = function() {1206 this.refreshActor();1207 this._skillTypeWindow.activate();1208};1209//-----------------------------------------------------------------------------1210// Scene_Equip1211//1212// The scene class of the equipment screen.1213function Scene_Equip() {1214 this.initialize.apply(this, arguments);1215}1216Scene_Equip.prototype = Object.create(Scene_MenuBase.prototype);1217Scene_Equip.prototype.constructor = Scene_Equip;1218Scene_Equip.prototype.initialize = function() {1219 Scene_MenuBase.prototype.initialize.call(this);1220};1221Scene_Equip.prototype.create = function() {1222 Scene_MenuBase.prototype.create.call(this);1223 this.createHelpWindow();1224 this.createStatusWindow();1225 this.createCommandWindow();1226 this.createSlotWindow();1227 this.createItemWindow();1228 this.refreshActor();1229};1230Scene_Equip.prototype.createStatusWindow = function() {1231 this._statusWindow = new Window_EquipStatus(0, this._helpWindow.height);1232 this.addWindow(this._statusWindow);1233};1234Scene_Equip.prototype.createCommandWindow = function() {1235 var wx = this._statusWindow.width;1236 var wy = this._helpWindow.height;1237 var ww = Graphics.boxWidth - this._statusWindow.width;1238 this._commandWindow = new Window_EquipCommand(wx, wy, ww);1239 this._commandWindow.setHelpWindow(this._helpWindow);1240 this._commandWindow.setHandler('equip', this.commandEquip.bind(this));1241 this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this));1242 this._commandWindow.setHandler('clear', this.commandClear.bind(this));1243 this._commandWindow.setHandler('cancel', this.popScene.bind(this));1244 this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));1245 this._commandWindow.setHandler('pageup', this.previousActor.bind(this));1246 this.addWindow(this._commandWindow);1247};1248Scene_Equip.prototype.createSlotWindow = function() {1249 var wx = this._statusWindow.width;1250 var wy = this._commandWindow.y + this._commandWindow.height;1251 var ww = Graphics.boxWidth - this._statusWindow.width;1252 var wh = this._statusWindow.height - this._commandWindow.height;1253 this._slotWindow = new Window_EquipSlot(wx, wy, ww, wh);1254 this._slotWindow.setHelpWindow(this._helpWindow);1255 this._slotWindow.setStatusWindow(this._statusWindow);1256 this._slotWindow.setHandler('ok', this.onSlotOk.bind(this));1257 this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this));1258 this.addWindow(this._slotWindow);1259};1260Scene_Equip.prototype.createItemWindow = function() {1261 var wx = 0;1262 var wy = this._statusWindow.y + this._statusWindow.height;1263 var ww = Graphics.boxWidth;1264 var wh = Graphics.boxHeight - wy;1265 this._itemWindow = new Window_EquipItem(wx, wy, ww, wh);1266 this._itemWindow.setHelpWindow(this._helpWindow);1267 this._itemWindow.setStatusWindow(this._statusWindow);1268 this._itemWindow.setHandler('ok', this.onItemOk.bind(this));1269 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));1270 this._slotWindow.setItemWindow(this._itemWindow);1271 this.addWindow(this._itemWindow);1272};1273Scene_Equip.prototype.refreshActor = function() {1274 var actor = this.actor();1275 this._statusWindow.setActor(actor);1276 this._slotWindow.setActor(actor);1277 this._itemWindow.setActor(actor);1278};1279Scene_Equip.prototype.commandEquip = function() {1280 this._slotWindow.activate();1281 this._slotWindow.select(0);1282};1283Scene_Equip.prototype.commandOptimize = function() {1284 SoundManager.playEquip();1285 this.actor().optimizeEquipments();1286 this._statusWindow.refresh();1287 this._slotWindow.refresh();1288 this._commandWindow.activate();1289};1290Scene_Equip.prototype.commandClear = function() {1291 SoundManager.playEquip();1292 this.actor().clearEquipments();1293 this._statusWindow.refresh();1294 this._slotWindow.refresh();1295 this._commandWindow.activate();1296};1297Scene_Equip.prototype.onSlotOk = function() {1298 this._itemWindow.activate();1299 this._itemWindow.select(0);1300};1301Scene_Equip.prototype.onSlotCancel = function() {1302 this._slotWindow.deselect();1303 this._commandWindow.activate();1304};1305Scene_Equip.prototype.onItemOk = function() {1306 SoundManager.playEquip();1307 this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());1308 this._slotWindow.activate();1309 this._slotWindow.refresh();1310 this._itemWindow.deselect();1311 this._itemWindow.refresh();1312 this._statusWindow.refresh();1313};1314Scene_Equip.prototype.onItemCancel = function() {1315 this._slotWindow.activate();1316 this._itemWindow.deselect();1317};1318Scene_Equip.prototype.onActorChange = function() {1319 this.refreshActor();1320 this._commandWindow.activate();1321};1322//-----------------------------------------------------------------------------1323// Scene_Status1324//1325// The scene class of the status screen.1326function Scene_Status() {1327 this.initialize.apply(this, arguments);1328}1329Scene_Status.prototype = Object.create(Scene_MenuBase.prototype);1330Scene_Status.prototype.constructor = Scene_Status;1331Scene_Status.prototype.initialize = function() {1332 Scene_MenuBase.prototype.initialize.call(this);1333};1334Scene_Status.prototype.create = function() {1335 Scene_MenuBase.prototype.create.call(this);1336 this._statusWindow = new Window_Status();1337 this._statusWindow.setHandler('cancel', this.popScene.bind(this));1338 this._statusWindow.setHandler('pagedown', this.nextActor.bind(this));1339 this._statusWindow.setHandler('pageup', this.previousActor.bind(this));1340 this._statusWindow.reserveFaceImages();1341 this.addWindow(this._statusWindow);1342};1343Scene_Status.prototype.start = function() {1344 Scene_MenuBase.prototype.start.call(this);1345 this.refreshActor();1346};1347Scene_Status.prototype.refreshActor = function() {1348 var actor = this.actor();1349 this._statusWindow.setActor(actor);1350};1351Scene_Status.prototype.onActorChange = function() {1352 this.refreshActor();1353 this._statusWindow.activate();1354};1355//-----------------------------------------------------------------------------1356// Scene_Options1357//1358// The scene class of the options screen.1359function Scene_Options() {1360 this.initialize.apply(this, arguments);1361}1362Scene_Options.prototype = Object.create(Scene_MenuBase.prototype);1363Scene_Options.prototype.constructor = Scene_Options;1364Scene_Options.prototype.initialize = function() {1365 Scene_MenuBase.prototype.initialize.call(this);1366};1367Scene_Options.prototype.create = function() {1368 Scene_MenuBase.prototype.create.call(this);1369 this.createOptionsWindow();1370};1371Scene_Options.prototype.terminate = function() {1372 Scene_MenuBase.prototype.terminate.call(this);1373 ConfigManager.save();1374};1375Scene_Options.prototype.createOptionsWindow = function() {1376 this._optionsWindow = new Window_Options();1377 this._optionsWindow.setHandler('cancel', this.popScene.bind(this));1378 this.addWindow(this._optionsWindow);1379};1380//-----------------------------------------------------------------------------1381// Scene_File1382//1383// The superclass of Scene_Save and Scene_Load.1384function Scene_File() {1385 this.initialize.apply(this, arguments);1386}1387Scene_File.prototype = Object.create(Scene_MenuBase.prototype);1388Scene_File.prototype.constructor = Scene_File;1389Scene_File.prototype.initialize = function() {1390 Scene_MenuBase.prototype.initialize.call(this);1391};1392Scene_File.prototype.create = function() {1393 Scene_MenuBase.prototype.create.call(this);1394 DataManager.loadAllSavefileImages();1395 this.createHelpWindow();1396 this.createListWindow();1397};1398Scene_File.prototype.start = function() {1399 Scene_MenuBase.prototype.start.call(this);1400 this._listWindow.refresh();1401};1402Scene_File.prototype.savefileId = function() {1403 return this._listWindow.index() + 1;1404};1405Scene_File.prototype.createHelpWindow = function() {1406 this._helpWindow = new Window_Help(1);1407 this._helpWindow.setText(this.helpWindowText());1408 this.addWindow(this._helpWindow);1409};1410Scene_File.prototype.createListWindow = function() {1411 var x = 0;1412 var y = this._helpWindow.height;1413 var width = Graphics.boxWidth;1414 var height = Graphics.boxHeight - y;1415 this._listWindow = new Window_SavefileList(x, y, width, height);1416 this._listWindow.setHandler('ok', this.onSavefileOk.bind(this));1417 this._listWindow.setHandler('cancel', this.popScene.bind(this));1418 this._listWindow.select(this.firstSavefileIndex());1419 this._listWindow.setTopRow(this.firstSavefileIndex() - 2);1420 this._listWindow.setMode(this.mode());1421 this._listWindow.refresh();1422 this.addWindow(this._listWindow);1423};1424Scene_File.prototype.mode = function() {1425 return null;1426};1427Scene_File.prototype.activateListWindow = function() {1428 this._listWindow.activate();1429};1430Scene_File.prototype.helpWindowText = function() {1431 return '';1432};1433Scene_File.prototype.firstSavefileIndex = function() {1434 return 0;1435};1436Scene_File.prototype.onSavefileOk = function() {1437};1438//-----------------------------------------------------------------------------1439// Scene_Save1440//1441// The scene class of the save screen.1442function Scene_Save() {1443 this.initialize.apply(this, arguments);1444}1445Scene_Save.prototype = Object.create(Scene_File.prototype);1446Scene_Save.prototype.constructor = Scene_Save;1447Scene_Save.prototype.initialize = function() {1448 Scene_File.prototype.initialize.call(this);1449};1450Scene_Save.prototype.mode = function() {1451 return 'save';1452};1453Scene_Save.prototype.helpWindowText = function() {1454 return TextManager.saveMessage;1455};1456Scene_Save.prototype.firstSavefileIndex = function() {1457 return DataManager.lastAccessedSavefileId() - 1;1458};1459Scene_Save.prototype.onSavefileOk = function() {1460 Scene_File.prototype.onSavefileOk.call(this);1461 $gameSystem.onBeforeSave();1462 if (DataManager.saveGame(this.savefileId())) {1463 this.onSaveSuccess();1464 } else {1465 this.onSaveFailure();1466 }1467};1468Scene_Save.prototype.onSaveSuccess = function() {1469 SoundManager.playSave();1470 StorageManager.cleanBackup(this.savefileId());1471 this.popScene();1472};1473Scene_Save.prototype.onSaveFailure = function() {1474 SoundManager.playBuzzer();1475 this.activateListWindow();1476};1477//-----------------------------------------------------------------------------1478// Scene_Load1479//1480// The scene class of the load screen.1481function Scene_Load() {1482 this.initialize.apply(this, arguments);1483}1484Scene_Load.prototype = Object.create(Scene_File.prototype);1485Scene_Load.prototype.constructor = Scene_Load;1486Scene_Load.prototype.initialize = function() {1487 Scene_File.prototype.initialize.call(this);1488 this._loadSuccess = false;1489};1490Scene_Load.prototype.terminate = function() {1491 Scene_File.prototype.terminate.call(this);1492 if (this._loadSuccess) {1493 $gameSystem.onAfterLoad();1494 }1495};1496Scene_Load.prototype.mode = function() {1497 return 'load';1498};1499Scene_Load.prototype.helpWindowText = function() {1500 return TextManager.loadMessage;1501};1502Scene_Load.prototype.firstSavefileIndex = function() {1503 return DataManager.latestSavefileId() - 1;1504};1505Scene_Load.prototype.onSavefileOk = function() {1506 Scene_File.prototype.onSavefileOk.call(this);1507 if (DataManager.loadGame(this.savefileId())) {1508 this.onLoadSuccess();1509 } else {1510 this.onLoadFailure();1511 }1512};1513Scene_Load.prototype.onLoadSuccess = function() {1514 SoundManager.playLoad();1515 this.fadeOutAll();1516 this.reloadMapIfUpdated();1517 SceneManager.goto(Scene_Map);1518 this._loadSuccess = true;1519};1520Scene_Load.prototype.onLoadFailure = function() {1521 SoundManager.playBuzzer();1522 this.activateListWindow();1523};1524Scene_Load.prototype.reloadMapIfUpdated = function() {1525 if ($gameSystem.versionId() !== $dataSystem.versionId) {1526 $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);1527 $gamePlayer.requestMapReload();1528 }1529};1530//-----------------------------------------------------------------------------1531// Scene_GameEnd1532//1533// The scene class of the game end screen.1534function Scene_GameEnd() {1535 this.initialize.apply(this, arguments);1536}1537Scene_GameEnd.prototype = Object.create(Scene_MenuBase.prototype);1538Scene_GameEnd.prototype.constructor = Scene_GameEnd;1539Scene_GameEnd.prototype.initialize = function() {1540 Scene_MenuBase.prototype.initialize.call(this);1541};1542Scene_GameEnd.prototype.create = function() {1543 Scene_MenuBase.prototype.create.call(this);1544 this.createCommandWindow();1545};1546Scene_GameEnd.prototype.stop = function() {1547 Scene_MenuBase.prototype.stop.call(this);1548 this._commandWindow.close();1549};1550Scene_GameEnd.prototype.createBackground = function() {1551 Scene_MenuBase.prototype.createBackground.call(this);1552 this.setBackgroundOpacity(128);1553};1554Scene_GameEnd.prototype.createCommandWindow = function() {1555 this._commandWindow = new Window_GameEnd();1556 this._commandWindow.setHandler('toTitle', this.commandToTitle.bind(this));1557 this._commandWindow.setHandler('cancel', this.popScene.bind(this));1558 this.addWindow(this._commandWindow);1559};1560Scene_GameEnd.prototype.commandToTitle = function() {1561 this.fadeOutAll();1562 SceneManager.goto(Scene_Title);1563};1564//-----------------------------------------------------------------------------1565// Scene_Shop1566//1567// The scene class of the shop screen.1568function Scene_Shop() {1569 this.initialize.apply(this, arguments);1570}1571Scene_Shop.prototype = Object.create(Scene_MenuBase.prototype);1572Scene_Shop.prototype.constructor = Scene_Shop;1573Scene_Shop.prototype.initialize = function() {1574 Scene_MenuBase.prototype.initialize.call(this);1575};1576Scene_Shop.prototype.prepare = function(goods, purchaseOnly) {1577 this._goods = goods;1578 this._purchaseOnly = purchaseOnly;1579 this._item = null;1580};1581Scene_Shop.prototype.create = function() {1582 Scene_MenuBase.prototype.create.call(this);1583 this.createHelpWindow();1584 this.createGoldWindow();1585 this.createCommandWindow();1586 this.createDummyWindow();1587 this.createNumberWindow();1588 this.createStatusWindow();1589 this.createBuyWindow();1590 this.createCategoryWindow();1591 this.createSellWindow();1592};1593Scene_Shop.prototype.createGoldWindow = function() {1594 this._goldWindow = new Window_Gold(0, this._helpWindow.height);1595 this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;1596 this.addWindow(this._goldWindow);1597};1598Scene_Shop.prototype.createCommandWindow = function() {1599 this._commandWindow = new Window_ShopCommand(this._goldWindow.x, this._purchaseOnly);1600 this._commandWindow.y = this._helpWindow.height;1601 this._commandWindow.setHandler('buy', this.commandBuy.bind(this));1602 this._commandWindow.setHandler('sell', this.commandSell.bind(this));1603 this._commandWindow.setHandler('cancel', this.popScene.bind(this));1604 this.addWindow(this._commandWindow);1605};1606Scene_Shop.prototype.createDummyWindow = function() {1607 var wy = this._commandWindow.y + this._commandWindow.height;1608 var wh = Graphics.boxHeight - wy;1609 this._dummyWindow = new Window_Base(0, wy, Graphics.boxWidth, wh);1610 this.addWindow(this._dummyWindow);1611};1612Scene_Shop.prototype.createNumberWindow = function() {1613 var wy = this._dummyWindow.y;1614 var wh = this._dummyWindow.height;1615 this._numberWindow = new Window_ShopNumber(0, wy, wh);1616 this._numberWindow.hide();1617 this._numberWindow.setHandler('ok', this.onNumberOk.bind(this));1618 this._numberWindow.setHandler('cancel', this.onNumberCancel.bind(this));1619 this.addWindow(this._numberWindow);1620};1621Scene_Shop.prototype.createStatusWindow = function() {1622 var wx = this._numberWindow.width;1623 var wy = this._dummyWindow.y;1624 var ww = Graphics.boxWidth - wx;1625 var wh = this._dummyWindow.height;1626 this._statusWindow = new Window_ShopStatus(wx, wy, ww, wh);1627 this._statusWindow.hide();1628 this.addWindow(this._statusWindow);1629};1630Scene_Shop.prototype.createBuyWindow = function() {1631 var wy = this._dummyWindow.y;1632 var wh = this._dummyWindow.height;1633 this._buyWindow = new Window_ShopBuy(0, wy, wh, this._goods);1634 this._buyWindow.setHelpWindow(this._helpWindow);1635 this._buyWindow.setStatusWindow(this._statusWindow);1636 this._buyWindow.hide();1637 this._buyWindow.setHandler('ok', this.onBuyOk.bind(this));1638 this._buyWindow.setHandler('cancel', this.onBuyCancel.bind(this));1639 this.addWindow(this._buyWindow);1640};1641Scene_Shop.prototype.createCategoryWindow = function() {1642 this._categoryWindow = new Window_ItemCategory();1643 this._categoryWindow.setHelpWindow(this._helpWindow);1644 this._categoryWindow.y = this._dummyWindow.y;1645 this._categoryWindow.hide();1646 this._categoryWindow.deactivate();1647 this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));1648 this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this));1649 this.addWindow(this._categoryWindow);1650};1651Scene_Shop.prototype.createSellWindow = function() {1652 var wy = this._categoryWindow.y + this._categoryWindow.height;1653 var wh = Graphics.boxHeight - wy;1654 this._sellWindow = new Window_ShopSell(0, wy, Graphics.boxWidth, wh);1655 this._sellWindow.setHelpWindow(this._helpWindow);1656 this._sellWindow.hide();1657 this._sellWindow.setHandler('ok', this.onSellOk.bind(this));1658 this._sellWindow.setHandler('cancel', this.onSellCancel.bind(this));1659 this._categoryWindow.setItemWindow(this._sellWindow);1660 this.addWindow(this._sellWindow);1661};1662Scene_Shop.prototype.activateBuyWindow = function() {1663 this._buyWindow.setMoney(this.money());1664 this._buyWindow.show();1665 this._buyWindow.activate();1666 this._statusWindow.show();1667};1668Scene_Shop.prototype.activateSellWindow = function() {1669 this._categoryWindow.show();1670 this._sellWindow.refresh();1671 this._sellWindow.show();1672 this._sellWindow.activate();1673 this._statusWindow.hide();1674};1675Scene_Shop.prototype.commandBuy = function() {1676 this._dummyWindow.hide();1677 this.activateBuyWindow();1678};1679Scene_Shop.prototype.commandSell = function() {1680 this._dummyWindow.hide();1681 this._categoryWindow.show();1682 this._categoryWindow.activate();1683 this._sellWindow.show();1684 this._sellWindow.deselect();1685 this._sellWindow.refresh();1686};1687Scene_Shop.prototype.onBuyOk = function() {1688 this._item = this._buyWindow.item();1689 this._buyWindow.hide();1690 this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());1691 this._numberWindow.setCurrencyUnit(this.currencyUnit());1692 this._numberWindow.show();1693 this._numberWindow.activate();1694};1695Scene_Shop.prototype.onBuyCancel = function() {1696 this._commandWindow.activate();1697 this._dummyWindow.show();1698 this._buyWindow.hide();1699 this._statusWindow.hide();1700 this._statusWindow.setItem(null);1701 this._helpWindow.clear();1702};1703Scene_Shop.prototype.onCategoryOk = function() {1704 this.activateSellWindow();1705 this._sellWindow.select(0);1706};1707Scene_Shop.prototype.onCategoryCancel = function() {1708 this._commandWindow.activate();1709 this._dummyWindow.show();1710 this._categoryWindow.hide();1711 this._sellWindow.hide();1712};1713Scene_Shop.prototype.onSellOk = function() {1714 this._item = this._sellWindow.item();1715 this._categoryWindow.hide();1716 this._sellWindow.hide();1717 this._numberWindow.setup(this._item, this.maxSell(), this.sellingPrice());1718 this._numberWindow.setCurrencyUnit(this.currencyUnit());1719 this._numberWindow.show();1720 this._numberWindow.activate();1721 this._statusWindow.setItem(this._item);1722 this._statusWindow.show();1723};1724Scene_Shop.prototype.onSellCancel = function() {1725 this._sellWindow.deselect();1726 this._categoryWindow.activate();1727 this._statusWindow.setItem(null);1728 this._helpWindow.clear();1729};1730Scene_Shop.prototype.onNumberOk = function() {1731 SoundManager.playShop();1732 switch (this._commandWindow.currentSymbol()) {1733 case 'buy':1734 this.doBuy(this._numberWindow.number());1735 break;1736 case 'sell':1737 this.doSell(this._numberWindow.number());1738 break;1739 }1740 this.endNumberInput();1741 this._goldWindow.refresh();1742 this._statusWindow.refresh();1743};1744Scene_Shop.prototype.onNumberCancel = function() {1745 SoundManager.playCancel();1746 this.endNumberInput();1747};1748Scene_Shop.prototype.doBuy = function(number) {1749 $gameParty.loseGold(number * this.buyingPrice());1750 $gameParty.gainItem(this._item, number);1751};1752Scene_Shop.prototype.doSell = function(number) {1753 $gameParty.gainGold(number * this.sellingPrice());1754 $gameParty.loseItem(this._item, number);1755};1756Scene_Shop.prototype.endNumberInput = function() {1757 this._numberWindow.hide();1758 switch (this._commandWindow.currentSymbol()) {1759 case 'buy':1760 this.activateBuyWindow();1761 break;1762 case 'sell':1763 this.activateSellWindow();1764 break;1765 }1766};1767Scene_Shop.prototype.maxBuy = function() {1768 var max = $gameParty.maxItems(this._item) - $gameParty.numItems(this._item);1769 var price = this.buyingPrice();1770 if (price > 0) {1771 return Math.min(max, Math.floor(this.money() / price));1772 } else {1773 return max;1774 }1775};1776Scene_Shop.prototype.maxSell = function() {1777 return $gameParty.numItems(this._item);1778};1779Scene_Shop.prototype.money = function() {1780 return this._goldWindow.value();1781};1782Scene_Shop.prototype.currencyUnit = function() {1783 return this._goldWindow.currencyUnit();1784};1785Scene_Shop.prototype.buyingPrice = function() {1786 return this._buyWindow.price(this._item);1787};1788Scene_Shop.prototype.sellingPrice = function() {1789 return Math.floor(this._item.price / 2);1790};1791//-----------------------------------------------------------------------------1792// Scene_Name1793//1794// The scene class of the name input screen.1795function Scene_Name() {1796 this.initialize.apply(this, arguments);1797}1798Scene_Name.prototype = Object.create(Scene_MenuBase.prototype);1799Scene_Name.prototype.constructor = Scene_Name;1800Scene_Name.prototype.initialize = function() {1801 Scene_MenuBase.prototype.initialize.call(this);1802};1803Scene_Name.prototype.prepare = function(actorId, maxLength) {1804 this._actorId = actorId;1805 this._maxLength = maxLength;1806};1807Scene_Name.prototype.create = function() {1808 Scene_MenuBase.prototype.create.call(this);1809 this._actor = $gameActors.actor(this._actorId);1810 this.createEditWindow();1811 this.createInputWindow();1812};1813Scene_Name.prototype.start = function() {1814 Scene_MenuBase.prototype.start.call(this);1815 this._editWindow.refresh();1816};1817Scene_Name.prototype.createEditWindow = function() {1818 this._editWindow = new Window_NameEdit(this._actor, this._maxLength);1819 this.addWindow(this._editWindow);1820};1821Scene_Name.prototype.createInputWindow = function() {1822 this._inputWindow = new Window_NameInput(this._editWindow);1823 this._inputWindow.setHandler('ok', this.onInputOk.bind(this));1824 this.addWindow(this._inputWindow);1825};1826Scene_Name.prototype.onInputOk = function() {1827 this._actor.setName(this._editWindow.name());1828 this.popScene();1829};1830//-----------------------------------------------------------------------------1831// Scene_Debug1832//1833// The scene class of the debug screen.1834function Scene_Debug() {1835 this.initialize.apply(this, arguments);1836}1837Scene_Debug.prototype = Object.create(Scene_MenuBase.prototype);1838Scene_Debug.prototype.constructor = Scene_Debug;1839Scene_Debug.prototype.initialize = function() {1840 Scene_MenuBase.prototype.initialize.call(this);1841};1842Scene_Debug.prototype.create = function() {1843 Scene_MenuBase.prototype.create.call(this);1844 this.createRangeWindow();1845 this.createEditWindow();1846 this.createDebugHelpWindow();1847};1848Scene_Debug.prototype.createRangeWindow = function() {1849 this._rangeWindow = new Window_DebugRange(0, 0);1850 this._rangeWindow.setHandler('ok', this.onRangeOk.bind(this));1851 this._rangeWindow.setHandler('cancel', this.popScene.bind(this));1852 this.addWindow(this._rangeWindow);1853};1854Scene_Debug.prototype.createEditWindow = function() {1855 var wx = this._rangeWindow.width;1856 var ww = Graphics.boxWidth - wx;1857 this._editWindow = new Window_DebugEdit(wx, 0, ww);1858 this._editWindow.setHandler('cancel', this.onEditCancel.bind(this));1859 this._rangeWindow.setEditWindow(this._editWindow);1860 this.addWindow(this._editWindow);1861};1862Scene_Debug.prototype.createDebugHelpWindow = function() {1863 var wx = this._editWindow.x;1864 var wy = this._editWindow.height;1865 var ww = this._editWindow.width;1866 var wh = Graphics.boxHeight - wy;1867 this._debugHelpWindow = new Window_Base(wx, wy, ww, wh);1868 this.addWindow(this._debugHelpWindow);1869};1870Scene_Debug.prototype.onRangeOk = function() {1871 this._editWindow.activate();1872 this._editWindow.select(0);1873 this.refreshHelpWindow();1874};1875Scene_Debug.prototype.onEditCancel = function() {1876 this._rangeWindow.activate();1877 this._editWindow.deselect();1878 this.refreshHelpWindow();1879};1880Scene_Debug.prototype.refreshHelpWindow = function() {1881 this._debugHelpWindow.contents.clear();1882 if (this._editWindow.active) {1883 this._debugHelpWindow.drawTextEx(this.helpText(), 4, 0);1884 }1885};1886Scene_Debug.prototype.helpText = function() {1887 if (this._rangeWindow.mode() === 'switch') {1888 return 'Enter : ON / OFF';1889 } else {1890 return ('Left : -1\n' +1891 'Right : +1\n' +1892 'Pageup : -10\n' +1893 'Pagedown : +10');1894 }1895};1896//-----------------------------------------------------------------------------1897// Scene_Battle1898//1899// The scene class of the battle screen.1900function Scene_Battle() {1901 this.initialize.apply(this, arguments);1902}1903Scene_Battle.prototype = Object.create(Scene_Base.prototype);1904Scene_Battle.prototype.constructor = Scene_Battle;1905Scene_Battle.prototype.initialize = function() {1906 Scene_Base.prototype.initialize.call(this);1907};1908Scene_Battle.prototype.create = function() {1909 Scene_Base.prototype.create.call(this);1910 this.createDisplayObjects();1911};1912Scene_Battle.prototype.start = function() {1913 Scene_Base.prototype.start.call(this);1914 this.startFadeIn(this.fadeSpeed(), false);1915 BattleManager.playBattleBgm();1916 BattleManager.startBattle();1917};1918Scene_Battle.prototype.update = function() {1919 var active = this.isActive();1920 $gameTimer.update(active);1921 $gameScreen.update();1922 this.updateStatusWindow();1923 this.updateWindowPositions();1924 if (active && !this.isBusy()) {1925 this.updateBattleProcess();1926 }1927 Scene_Base.prototype.update.call(this);1928};1929Scene_Battle.prototype.updateBattleProcess = function() {1930 if (!this.isAnyInputWindowActive() || BattleManager.isAborting() ||1931 BattleManager.isBattleEnd()) {1932 BattleManager.update();1933 this.changeInputWindow();1934 }1935};1936Scene_Battle.prototype.isAnyInputWindowActive = function() {1937 return (this._partyCommandWindow.active ||1938 this._actorCommandWindow.active ||1939 this._skillWindow.active ||1940 this._itemWindow.active ||1941 this._actorWindow.active ||1942 this._enemyWindow.active);1943};1944Scene_Battle.prototype.changeInputWindow = function() {1945 if (BattleManager.isInputting()) {1946 if (BattleManager.actor()) {1947 this.startActorCommandSelection();1948 } else {1949 this.startPartyCommandSelection();1950 }1951 } else {1952 this.endCommandSelection();1953 }1954};1955Scene_Battle.prototype.stop = function() {1956 Scene_Base.prototype.stop.call(this);1957 if (this.needsSlowFadeOut()) {1958 this.startFadeOut(this.slowFadeSpeed(), false);1959 } else {1960 this.startFadeOut(this.fadeSpeed(), false);1961 }1962 this._statusWindow.close();1963 this._partyCommandWindow.close();1964 this._actorCommandWindow.close();1965};1966Scene_Battle.prototype.terminate = function() {1967 Scene_Base.prototype.terminate.call(this);1968 $gameParty.onBattleEnd();1969 $gameTroop.onBattleEnd();1970 AudioManager.stopMe();1971 ImageManager.clearRequest();1972};1973Scene_Battle.prototype.needsSlowFadeOut = function() {1974 return (SceneManager.isNextScene(Scene_Title) ||1975 SceneManager.isNextScene(Scene_Gameover));1976};1977Scene_Battle.prototype.updateStatusWindow = function() {1978 if ($gameMessage.isBusy()) {1979 this._statusWindow.close();1980 this._partyCommandWindow.close();1981 this._actorCommandWindow.close();1982 } else if (this.isActive() && !this._messageWindow.isClosing()) {1983 this._statusWindow.open();1984 }1985};1986Scene_Battle.prototype.updateWindowPositions = function() {1987 var statusX = 0;1988 if (BattleManager.isInputting()) {1989 statusX = this._partyCommandWindow.width;1990 } else {1991 statusX = this._partyCommandWindow.width / 2;1992 }1993 if (this._statusWindow.x < statusX) {1994 this._statusWindow.x += 16;1995 if (this._statusWindow.x > statusX) {1996 this._statusWindow.x = statusX;1997 }1998 }1999 if (this._statusWindow.x > statusX) {2000 this._statusWindow.x -= 16;2001 if (this._statusWindow.x < statusX) {2002 this._statusWindow.x = statusX;2003 }2004 }2005};2006Scene_Battle.prototype.createDisplayObjects = function() {2007 this.createSpriteset();2008 this.createWindowLayer();2009 this.createAllWindows();2010 BattleManager.setLogWindow(this._logWindow);2011 BattleManager.setStatusWindow(this._statusWindow);2012 BattleManager.setSpriteset(this._spriteset);2013 this._logWindow.setSpriteset(this._spriteset);2014};2015Scene_Battle.prototype.createSpriteset = function() {2016 this._spriteset = new Spriteset_Battle();2017 this.addChild(this._spriteset);2018};2019Scene_Battle.prototype.createAllWindows = function() {2020 this.createLogWindow();2021 this.createStatusWindow();2022 this.createPartyCommandWindow();2023 this.createActorCommandWindow();2024 this.createHelpWindow();2025 this.createSkillWindow();2026 this.createItemWindow();2027 this.createActorWindow();2028 this.createEnemyWindow();2029 this.createMessageWindow();2030 this.createScrollTextWindow();2031};2032Scene_Battle.prototype.createLogWindow = function() {2033 this._logWindow = new Window_BattleLog();2034 this.addWindow(this._logWindow);2035};2036Scene_Battle.prototype.createStatusWindow = function() {2037 this._statusWindow = new Window_BattleStatus();2038 this.addWindow(this._statusWindow);2039};2040Scene_Battle.prototype.createPartyCommandWindow = function() {2041 this._partyCommandWindow = new Window_PartyCommand();2042 this._partyCommandWindow.setHandler('fight', this.commandFight.bind(this));2043 this._partyCommandWindow.setHandler('escape', this.commandEscape.bind(this));2044 this._partyCommandWindow.deselect();2045 this.addWindow(this._partyCommandWindow);2046};2047Scene_Battle.prototype.createActorCommandWindow = function() {2048 this._actorCommandWindow = new Window_ActorCommand();2049 this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));2050 this._actorCommandWindow.setHandler('skill', this.commandSkill.bind(this));2051 this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this));2052 this._actorCommandWindow.setHandler('item', this.commandItem.bind(this));2053 this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));2054 this.addWindow(this._actorCommandWindow);2055};2056Scene_Battle.prototype.createHelpWindow = function() {2057 this._helpWindow = new Window_Help();2058 this._helpWindow.visible = false;2059 this.addWindow(this._helpWindow);2060};2061Scene_Battle.prototype.createSkillWindow = function() {2062 var wy = this._helpWindow.y + this._helpWindow.height;2063 var wh = this._statusWindow.y - wy;2064 this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh);2065 this._skillWindow.setHelpWindow(this._helpWindow);2066 this._skillWindow.setHandler('ok', this.onSkillOk.bind(this));2067 this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));2068 this.addWindow(this._skillWindow);2069};2070Scene_Battle.prototype.createItemWindow = function() {2071 var wy = this._helpWindow.y + this._helpWindow.height;2072 var wh = this._statusWindow.y - wy;2073 this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh);2074 this._itemWindow.setHelpWindow(this._helpWindow);2075 this._itemWindow.setHandler('ok', this.onItemOk.bind(this));2076 this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));2077 this.addWindow(this._itemWindow);2078};2079Scene_Battle.prototype.createActorWindow = function() {2080 this._actorWindow = new Window_BattleActor(0, this._statusWindow.y);2081 this._actorWindow.setHandler('ok', this.onActorOk.bind(this));2082 this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));2083 this.addWindow(this._actorWindow);2084};2085Scene_Battle.prototype.createEnemyWindow = function() {2086 this._enemyWindow = new Window_BattleEnemy(0, this._statusWindow.y);2087 this._enemyWindow.x = Graphics.boxWidth - this._enemyWindow.width;2088 this._enemyWindow.setHandler('ok', this.onEnemyOk.bind(this));2089 this._enemyWindow.setHandler('cancel', this.onEnemyCancel.bind(this));2090 this.addWindow(this._enemyWindow);2091};2092Scene_Battle.prototype.createMessageWindow = function() {2093 this._messageWindow = new Window_Message();2094 this.addWindow(this._messageWindow);2095 this._messageWindow.subWindows().forEach(function(window) {2096 this.addWindow(window);2097 }, this);2098};2099Scene_Battle.prototype.createScrollTextWindow = function() {2100 this._scrollTextWindow = new Window_ScrollText();2101 this.addWindow(this._scrollTextWindow);2102};2103Scene_Battle.prototype.refreshStatus = function() {2104 this._statusWindow.refresh();2105};2106Scene_Battle.prototype.startPartyCommandSelection = function() {2107 this.refreshStatus();2108 this._statusWindow.deselect();2109 this._statusWindow.open();2110 this._actorCommandWindow.close();2111 this._partyCommandWindow.setup();2112};2113Scene_Battle.prototype.commandFight = function() {2114 this.selectNextCommand();2115};2116Scene_Battle.prototype.commandEscape = function() {2117 BattleManager.processEscape();2118 this.changeInputWindow();2119};2120Scene_Battle.prototype.startActorCommandSelection = function() {2121 this._statusWindow.select(BattleManager.actor().index());2122 this._partyCommandWindow.close();2123 this._actorCommandWindow.setup(BattleManager.actor());2124};2125Scene_Battle.prototype.commandAttack = function() {2126 BattleManager.inputtingAction().setAttack();2127 this.selectEnemySelection();2128};2129Scene_Battle.prototype.commandSkill = function() {2130 this._skillWindow.setActor(BattleManager.actor());2131 this._skillWindow.setStypeId(this._actorCommandWindow.currentExt());2132 this._skillWindow.refresh();2133 this._skillWindow.show();2134 this._skillWindow.activate();2135};2136Scene_Battle.prototype.commandGuard = function() {2137 BattleManager.inputtingAction().setGuard();2138 this.selectNextCommand();2139};2140Scene_Battle.prototype.commandItem = function() {2141 this._itemWindow.refresh();2142 this._itemWindow.show();2143 this._itemWindow.activate();2144};2145Scene_Battle.prototype.selectNextCommand = function() {2146 BattleManager.selectNextCommand();2147 this.changeInputWindow();2148};2149Scene_Battle.prototype.selectPreviousCommand = function() {2150 BattleManager.selectPreviousCommand();2151 this.changeInputWindow();2152};2153Scene_Battle.prototype.selectActorSelection = function() {2154 this._actorWindow.refresh();2155 this._actorWindow.show();2156 this._actorWindow.activate();2157};2158Scene_Battle.prototype.onActorOk = function() {2159 var action = BattleManager.inputtingAction();2160 action.setTarget(this._actorWindow.index());2161 this._actorWindow.hide();2162 this._skillWindow.hide();2163 this._itemWindow.hide();2164 this.selectNextCommand();2165};2166Scene_Battle.prototype.onActorCancel = function() {2167 this._actorWindow.hide();2168 switch (this._actorCommandWindow.currentSymbol()) {2169 case 'skill':2170 this._skillWindow.show();2171 this._skillWindow.activate();2172 break;2173 case 'item':2174 this._itemWindow.show();2175 this._itemWindow.activate();2176 break;2177 }2178};2179Scene_Battle.prototype.selectEnemySelection = function() {2180 this._enemyWindow.refresh();2181 this._enemyWindow.show();2182 this._enemyWindow.select(0);2183 this._enemyWindow.activate();2184};2185Scene_Battle.prototype.onEnemyOk = function() {2186 var action = BattleManager.inputtingAction();2187 action.setTarget(this._enemyWindow.enemyIndex());2188 this._enemyWindow.hide();2189 this._skillWindow.hide();2190 this._itemWindow.hide();2191 this.selectNextCommand();2192};2193Scene_Battle.prototype.onEnemyCancel = function() {2194 this._enemyWindow.hide();2195 switch (this._actorCommandWindow.currentSymbol()) {2196 case 'attack':2197 this._actorCommandWindow.activate();2198 break;2199 case 'skill':2200 this._skillWindow.show();2201 this._skillWindow.activate();2202 break;2203 case 'item':2204 this._itemWindow.show();2205 this._itemWindow.activate();2206 break;2207 }2208};2209Scene_Battle.prototype.onSkillOk = function() {2210 var skill = this._skillWindow.item();2211 var action = BattleManager.inputtingAction();2212 action.setSkill(skill.id);2213 BattleManager.actor().setLastBattleSkill(skill);2214 this.onSelectAction();2215};2216Scene_Battle.prototype.onSkillCancel = function() {2217 this._skillWindow.hide();2218 this._actorCommandWindow.activate();2219};2220Scene_Battle.prototype.onItemOk = function() {2221 var item = this._itemWindow.item();2222 var action = BattleManager.inputtingAction();2223 action.setItem(item.id);2224 $gameParty.setLastItem(item);2225 this.onSelectAction();2226};2227Scene_Battle.prototype.onItemCancel = function() {2228 this._itemWindow.hide();2229 this._actorCommandWindow.activate();2230};2231Scene_Battle.prototype.onSelectAction = function() {2232 var action = BattleManager.inputtingAction();2233 this._skillWindow.hide();2234 this._itemWindow.hide();2235 if (!action.needsSelection()) {2236 this.selectNextCommand();2237 } else if (action.isForOpponent()) {2238 this.selectEnemySelection();2239 } else {2240 this.selectActorSelection();2241 }2242};2243Scene_Battle.prototype.endCommandSelection = function() {2244 this._partyCommandWindow.close();2245 this._actorCommandWindow.close();2246 this._statusWindow.deselect();2247};2248//-----------------------------------------------------------------------------2249// Scene_Gameover2250//2251// The scene class of the game over screen.2252function Scene_Gameover() {2253 this.initialize.apply(this, arguments);2254}2255Scene_Gameover.prototype = Object.create(Scene_Base.prototype);2256Scene_Gameover.prototype.constructor = Scene_Gameover;2257Scene_Gameover.prototype.initialize = function() {2258 Scene_Base.prototype.initialize.call(this);2259};2260Scene_Gameover.prototype.create = function() {2261 Scene_Base.prototype.create.call(this);2262 this.playGameoverMusic();2263 this.createBackground();2264};2265Scene_Gameover.prototype.start = function() {2266 Scene_Base.prototype.start.call(this);2267 this.startFadeIn(this.slowFadeSpeed(), false);2268};2269Scene_Gameover.prototype.update = function() {2270 if (this.isActive() && !this.isBusy() && this.isTriggered()) {2271 this.gotoTitle();2272 }2273 Scene_Base.prototype.update.call(this);2274};2275Scene_Gameover.prototype.stop = function() {2276 Scene_Base.prototype.stop.call(this);2277 this.fadeOutAll();2278};2279Scene_Gameover.prototype.terminate = function() {2280 Scene_Base.prototype.terminate.call(this);2281 AudioManager.stopAll();2282};2283Scene_Gameover.prototype.playGameoverMusic = function() {2284 AudioManager.stopBgm();2285 AudioManager.stopBgs();2286 AudioManager.playMe($dataSystem.gameoverMe);2287};2288Scene_Gameover.prototype.createBackground = function() {2289 this._backSprite = new Sprite();2290 this._backSprite.bitmap = ImageManager.loadSystem('GameOver');2291 this.addChild(this._backSprite);2292};2293Scene_Gameover.prototype.isTriggered = function() {2294 return Input.isTriggered('ok') || TouchInput.isTriggered();2295};2296Scene_Gameover.prototype.gotoTitle = function() {2297 SceneManager.goto(Scene_Title);...
RadWindow.js
Source:RadWindow.js
1/************************************************2 *3 * Class RadWindow4 *5 ************************************************/6function RadWindow(id)7{8 this.IsIE = (null != document.all) && (window.opera == null); 9 this.IsQuirksMode = (document.all && !window.opera && "CSS1Compat" != document.compatMode);10 11 this.Id = id;12 this.Width = 0;13 this.Height = 0; 14 this.OnClientClosing = null;15 //Private members16 this.ContentWindow = null; 17 this.ContentWrapperTable = null;18 this.Caption = null;19 this.X = 0;20 this.Y = 0;21 this.ShowContentWhenMoving = true; 22 this.CanMove = true;23 this.CanResize = true;2425 this.DragMode = ""; // "move" "size"2627 // dialogs-related stuff28 this.IsModal = false;29 this.Container = null;30 this.Parent = null;3132 this.Argument = null;33 this.ReturnValue = null;34 this.ExitCode = null; // OK, CANCEL, etc.35 this.ZIndex = 0;36 this.AdjustPosInterval = -1;37 this.CallbackFunc = null; // signature: function CallbackFunc() { }38 this.OnLoadFunc = null;39 this.Param = null;4041 this.ModalSetCapture = false;4243 this.UseRadWindow = true;44 this.Window = null; // IHTMLWindow object - this.UseRadWindow == true45 this.InnerHTML = null;46 this._overImage = null;47}4849RadWindow.prototype.OnLoad = function()50{51 if (this.Window && "" != this.Window.document.title)52 {53 this.SetCaption(this.Window.document.title);54 }5556 if (this.OnLoadFunc)57 {58 this.OnLoadFunc();59 }60}6162RadWindow.prototype.SetCapture = function(bContainerCapture)63{64 if (this.UseRadWindow)65 {66 if (null != bContainerCapture)67 {68 this.bContainerCapture = bContainerCapture;69 }70 else if (null != this.bContainerCapture)71 {72 bContainerCapture = this.bContainerCapture;73 }74 else75 {76 bContainerCapture = false;77 }7879 if (this.ModalSetCapture && this.IsIE)80 {81 this.ContentWrapperTable.setCapture(bContainerCapture);82 }83 }84}8586RadWindow.prototype.ReleaseCapture = function()87{88 if (this.UseRadWindow)89 {90 if (this.ModalSetCapture && this.IsIE)91 {92 if (this.ContentWrapperTable)93 this.ContentWrapperTable.releaseCapture();94 }95 }96}9798RadWindow.prototype.SetZIndex = function(zIndex)99{100 this.ZIndex = zIndex;101 if (this.ContentWrapperTable)102 {103 this.ContentWrapperTable.style.zIndex = this.ZIndex;104 }105}106107RadWindow.prototype.ToggleContent = function()108{109 if (this.UseRadWindow && this.IsIE)110 {111 var displayStyle = "";112 if (parseInt(this.Height) == parseInt(this.ContentWrapperTable.style.height))113 {114 this.SetHeight(0);115 displayStyle = "none";116 }117 else118 {119 this.SetHeight(this.Height);120 displayStyle = "inline";121 } 122 }123}124125RadWindow.prototype.IsVisible = function()126{127 if (this.ContentWrapperTable)128 {129 return this.ContentWrapperTable.style.display == "";130 }131 return false;132}133134RadWindow.prototype.ShowWindow = function(show, x, y)135{136 if (null == show)137 {138 show = true;139 }140 var displayStyle = show ? "" : "none";141142 if (this.ContentWrapperTable)143 {144 this.ContentWrapperTable.style.display = displayStyle;145 }146147 if (show)148 { 149 if (null != x && null != y)150 {151 x += 10;152 if (this.ContentWrapperTable)153 {154 this.ContentWrapperTable.style.left = x + 'px';155 this.ContentWrapperTable.style.top = y + 'px';156 }157 } 158 }159160 if (this.Parent)161 {162 this.Parent.OnShowWindow(this, show);163 }164}165166RadWindow.prototype.Initialize2 = function(contentElem, show, containerElem, modal, zIndex)167{168 this.Initialize(contentElem, show);169170 this.IsModal = modal;171 this.Container = containerElem;172173 this.SetZIndex(zIndex);174}175176RadWindow.prototype.Initialize = function(contentElem, show)177{178 //Use the Id to get a reference to the ContentWindow179 if (this.Id)180 {181 this.ContentWrapperTable = document.getElementById("RadWindowContentWrapper" + this.Id);182 this.ContentWindow = document.getElementById("RadWindowContentWindow" + this.Id); 183 this.Caption = document.getElementById("RadWindowCaption" + this.Id);184 185 if (null == show)186 {187 var show = true;188 }189190 this.ShowWindow(show);191 }192 else193 {194 alert ("No window Id provided");195 }196};197198RadWindow.prototype.SetContentWindowSize = function (width, height)199{200 this.Width = width;201 this.Height = height; 202};203204RadWindow.prototype.SetContentVisible = function (visible)205{206 if (this.ContentWindow)207 {208 this.ContentWindow.style.visibility = visible ? "visible" : "hidden";209 }210};211212RadWindow.prototype.Close = function(exitCode, dialogCallbackFunction, execCallBack)213{214 if (null != this.OnClientClosing215 && (this.OnClientClosing(exitCode) == false))216 {217 return;218 }219220 this.ShowWindow(false);221222 this.ExitCode = exitCode;223224 if (this.AdjustPosInterval > -1)225 {226 window.clearInterval(this.AdjustPosInterval);227 this.AdjustPosInterval = -1;228 }229230 if (this.IsModal)231 this.ReleaseCapture();232233 try234 {235 if (this.CallbackFunc && false != execCallBack)236 this.CallbackFunc(this.ReturnValue, this.Param);237 if (dialogCallbackFunction)238 {239 dialogCallbackFunction(this.ReturnValue, this.Param);240 }241 }242 catch (ex)243 {244 }245246 if (this.Parent)247 this.Parent.DestroyWindow(this);248249 if (!this.UseRadWindow && this.Window)250 this.Window.close();251};252253RadWindow.prototype.ToggleCanMove = function(oDiv)254{255 if (!this.UseRadWindow)256 return;257258 this.CanMove = !this.CanMove;259260 oDiv.className = this.CanMove ? "RadERadWindowButtonPinOff" : "RadERadWindowButtonPinOn";261262 if (!this.CanMove)263 {264 if (this.IsIE)265 {266 this.TopOffset = parseInt(this.ContentWrapperTable.style.top) - RadGetScrollTop(document);267 this.StartUpdatePosTimer(100);268 }269 else270 {271 this.ContentWrapperTable.style.position = "fixed";272 }273 }274 else275 {276 if (this.IsIE)277 {278 window.clearInterval(this.AdjustPosInterval);279 this.TopOffset = null;280 }281 else282 {283 this.ContentWrapperTable.style.position = "absolute";284 }285 }286}287288RadWindow.prototype.StartUpdatePosTimer = function(iInterval)289{290 if (!this.UseRadWindow) return;291 this.AdjustPosInterval = window.setInterval("UpdateWindowPos('" + this.Id + "')", iInterval);292}293294function UpdateWindowPos(wndId)295{296 var wnd = GetEditorRadWindowManager().LookupWindow(wndId);297 if (wnd)298 wnd.SetPosition();299}300301RadWindow.prototype.CanDrag = function()302{303 if (!this.UseRadWindow)304 return true;305306 return ("move" == this.DragMode && this.CanMove)307 || ("size" == this.DragMode && this.CanResize);308}309310RadWindow.prototype.OnDragStart = function(e)311{312 this.SetActive(true); //RadWindowActiveWindow = this;313314 if (!this.CanDrag()) return;315316 this.X = (e.offsetX == null) ? e.layerX : e.offsetX;317 this.Y = (e.offsetY == null) ? e.layerY : e.offsetY;318319 MousePosX = e.clientX;320 MousePosY = e.clientY;321322 this.SetContentVisible(this.ShowContentWhenMoving);323 RadWindowDragStart();324};325326RadWindow.prototype.SetActive = function(activate)327{328 if (!this.UseRadWindow) return;329330 if (activate)331 {332 if (null != RadWindowActiveWindow && RadWindowActiveWindow != this)333 RadWindowActiveWindow.SetActive(false);334335 RadWindowActiveWindow = this;336337 if (this.Parent)338 this.Parent.ActivateWindow(this);339 }340 else341 {342 if (this == RadWindowActiveWindow)343 RadWindowActiveWindow = null;344 }345}346347RadWindow.prototype.HitTest = function(x, y)348{349 var left = parseInt(this.ContentWrapperTable.style.left);350 if (isNaN(left))351 return false;352353 var top = parseInt(this.ContentWrapperTable.style.top);354 if (isNaN(top))355 return false;356357 return left <= x358 && x <= (left + this.Width)359 && top <= y360 && y <= (top + this.Height);361}362363RadWindow.prototype.SetPosition = function(left, top)364{365 if (!this.UseRadWindow)366 {367 if (this.Window)368 {369 this.Window.dialogLeft = left;370 this.Window.dialogTop = top;371 }372 }373 else374 {375 if (!left)376 left = this.ContentWrapperTable.style.left;377378 if (!top)379 {380 if (this.TopOffset != null)381 top = parseInt(this.TopOffset) + RadGetScrollTop(document);382 else383 top = this.ContentWrapperTable.style.top;384 }385386 left = parseInt(left);387 top = parseInt(top);388389 if (!isNaN(left) && !isNaN(top))390 {391 if (left <= 0) left = 0;392 if (top <= 0) top = 0;393394 this.ContentWrapperTable.style.left = left + 'px';395 this.ContentWrapperTable.style.top = top + 'px';396 }397 }398}399400RadWindow.prototype.GetWidth = function()401{402 var width = 0;403 if (!this.UseRadWindow)404 {405 if (this.Window) width = this.Window.dialogWidth;406 }407 else408 {409 if (this.IsIE)410 {411 width = parseInt(this.ContentWrapperTable.clientWidth);412 }413 else414 {415 width = parseInt(this.ContentWrapperTable.scrollWidth);416 }417 418 if (isNaN(width)) width = 0; 419 }420 return width;421}422423RadWindow.prototype.SetWidth = function(width)424{425 width = parseInt(width);426 if (isNaN(width)) return;427428 if (!this.UseRadWindow)429 {430 if (this.Window)431 {432 if (this.Window.dialogWidth)433 {434 this.Window.dialogTop = this.Window.screenTop - 30;435 this.Window.dialogLeft = this.Window.screenLeft - 4;436437 this.Window.dialogWidth = width + "px";438 }439 else440 {441 this.Window.outerWidth = width;442 }443 }444 }445 else446 { 447 if (width) this.ContentWrapperTable.style.width = width + "px"; 448 }449}450451RadWindow.prototype.GetHeight = function()452{453 var height = 0;454 if (!this.UseRadWindow)455 {456 if (this.Window)457 height = this.Window.dialogHeight;458 }459 else460 {461 if (this.IsIE)462 {463 height = parseInt(this.ContentWrapperTable.clientHeight);464 if (isNaN(height)) height = 0; 465 }466 else467 {468 height = this.ContentWrapperTable.scrollHeight;469 }470 }471 return height;472}473474RadWindow.prototype.SetHeight = function(height)475{476 height = parseInt(height);477 if (isNaN(height))478 return;479480 if (!this.UseRadWindow)481 {482 if (this.Window)483 {484 if (this.Window.dialogWidth)485 {486 this.Window.dialogTop = this.Window.screenTop - 30;487 this.Window.dialogLeft = this.Window.screenLeft - 4;488 this.Window.dialogHeight = height + "px";489 }490 else491 {492 this.Window.outerHeight = height;493 }494 }495 }496 else497 {498 var oTable = this.ContentWrapperTable; 499 500 //IE HACK!501 var oFirstTable = oTable.getElementsByTagName("TABLE")[0]; 502 if (oFirstTable) oFirstTable.setAttribute("border","1");503 504 this.ContentWrapperTable.style.height = height + "px"; 505 506 //IE HACK!507 this.FixIeHeight(this.ContentWrapperTable, height); 508 oFirstTable.setAttribute("border","0"); 509 }510}511512RadWindow.prototype.FixIeHeight = function(oElem, height)//BUGS in IE in DOCTYPE strict mode513{514 if (this.IsIE && "CSS1Compat" == document.compatMode)515 { 516 var oHeight = oElem.offsetHeight;517 // ie table issue covered518 if (oHeight != 0 && oHeight != height) 519 {520 var difference = (oHeight - height);521 var newHeight = (height - difference);522 523 if (newHeight > 0) 524 {525 oElem.style.height = (newHeight + 4) + "px";//4 is because of the border526 }527 } 528 }529};530531function RadWindowUnInitializeDrag(targetWindow)532{533 var oSpan = RadWindowActiveWindowSpan;534 targetWindow.SetPosition(oSpan.style.left, oSpan.style.top); 535 536 //TEKI: Very quick ugly and dirty hack to handle the IE resizing problem with not taking into account borders when non-XHTML doctype is set 537 var extra = targetWindow.IsQuirksMode ? 6 : 0 ;538 extra += targetWindow.IsIE ? 2 : 0;539 extraHeight = extra;540 if (targetWindow.IsIE && !targetWindow.IsQuirksMode && extraHeight > 0) extraHeight -= 2;541 542 targetWindow.SetSize(extra + (oSpan.clientWidth ? oSpan.clientWidth : oSpan.offsetWidth),543 extraHeight + (oSpan.clientHeight ? oSpan.clientHeight: oSpan.offsetHeight) ); 544 545 if (RadWindowActiveWindowSpan)546 RadWindowActiveWindowSpan.style.visibility = "hidden";547}548549RadWindow.prototype.SetSize = function(width, height)550{551 //TEKI - Safari, etc 552 if (!this.UseRadWindow && !document.all && this.Window && this.Window.resizeTo)553 {554 this.Window.resizeTo(width, height); 555 }556 else557 {558 this.SetWidth(width);559 this.SetHeight(height); 560 }561562 if (width > 0)563 this.Width = width;564565 if (height > 0)566 this.Height = height;567}568569RadWindow.prototype.SetCaption = function(caption)570{571 if (this.Caption)572 {573 this.Caption.innerHTML = caption;574 }575}576577//-------------------------------------MOVEMENT RELATED---------------------------------//578var RadWindowActiveWindow = null; //Points to the active window579var RadWindowActiveWindowSpan = null;580var MousePosX = 0;581var MousePosY = 0;582583//Attach Event Handlers584function RadWindowDragStart()585{586 if (!RadWindowActiveWindow.CanDrag())587 return;588589 if (document.all && document.body.attachEvent)590 {591 document.body.setCapture();592 document.body.attachEvent ("onmousemove", RadWindowDrag);593 document.body.attachEvent ("onmouseup", RadWindowDragEnd);594 }595 else if (document.addEventListener)596 {597 document.addEventListener("mousemove", RadWindowDrag, false);598 document.addEventListener("mouseup", RadWindowDragEnd, false);599 }600601 RadWindowInitializeDrag(RadWindowActiveWindow);602}603604/*Detach Event Handlers*/605function RadWindowDragEnd()606{607 if (document.all && document.body.detachEvent)608 {609 document.body.detachEvent("onmousemove", RadWindowDrag);610 document.body.detachEvent("onmouseup", RadWindowDragEnd);611 document.body.releaseCapture();612 }613 else if (document.removeEventListener)614 {615 document.removeEventListener("mousemove", RadWindowDrag, false);616 document.removeEventListener("mouseup", RadWindowDragEnd, false);617 }618619 if (RadWindowActiveWindow.IsModal)620 RadWindowActiveWindow.SetCapture();621622 RadWindowUnInitializeDrag(RadWindowActiveWindow); 623 RadWindowActiveWindow.SetContentVisible(true);624}625626function RadWindowDrag(e)627{628 if (RadWindowActiveWindow.CanDrag())629 {630 switch (RadWindowActiveWindow.DragMode)631 {632 case "move": 633 RadWindowMove(e);634 break;635636 case "size": 637 RadWindowSize(e);638 break;639 }640 }641 e.cancelBubble = true;642 e.returnValue = false; 643 if (e.preventDefault) e.preventDefault();644645 MousePosX = e.clientX;646 MousePosY = e.clientY;647648 return false;649}650651function RadWindowInitializeDrag(targetWindow)652{653 if (!targetWindow) return;654655 if (!RadWindowActiveWindowSpan)656 {657 RadWindowActiveWindowSpan = document.createElement("DIV"); 658 RadWindowActiveWindowSpan.className = "RadETableWrapperResizeSpan"; 659 RadWindowActiveWindowSpan.style.position = "absolute";660 RadWindowActiveWindowSpan.style.zIndex = 50000;661 document.body.appendChild(RadWindowActiveWindowSpan);662 }663664 RadWindowActiveWindowSpan.style.visibility = "visible";665 RadWindowActiveWindowSpan.style.top = targetWindow.ContentWrapperTable.style.top;666 RadWindowActiveWindowSpan.style.left = targetWindow.ContentWrapperTable.style.left;667 RadWindowActiveWindowSpan.style.width = parseInt(targetWindow.GetWidth()) + "px";668 RadWindowActiveWindowSpan.style.height = parseInt(targetWindow.GetHeight()) + "px";669670 switch (targetWindow.DragMode)671 {672 case "move":673 RadWindowActiveWindowSpan.style.cursor = "default";674 break;675676 case "size":677 RadWindowActiveWindowSpan.style.cursor = "se-resize";678 break;679 }680}681682function RadWindowMove(e)683{684 var RadWindowX = RadWindowActiveWindow.X;685 var RadWindowY = RadWindowActiveWindow.Y;686687 var el = RadWindowActiveWindowSpan;688689 var left = 0;690 var top = 0;691692 if (document.all)693 {694 left = e.clientX * 1 + RadGetScrollLeft(document) - RadWindowX;695 top = e.clientY * 1 + RadGetScrollTop(document) - RadWindowY;696 }697 else698 {699 left = e.pageX * 1 - RadWindowX;700 top = e.pageY * 1 - RadWindowY;701 }702703 if (left < 0)704 {705 left = 0;706 }707708 if (top < 0)709 {710 top = 0;711 }712713 el.style.left = left + "px";714 el.style.top = top + "px";715}716717var minWidth = 155;718var minHeight = 43;719720function RadWindowSize(e)721{722 var offsetX = e.clientX - MousePosX;723 var offsetY = e.clientY - MousePosY;724725 var oSpan = RadWindowActiveWindowSpan;726 727 var width = oSpan.clientWidth ? oSpan.clientWidth : oSpan.offsetWidth;728 var height = oSpan.clientHeight ? oSpan.clientHeight : oSpan.offsetHeight;729 730 //IE HACK731 if (document.all && !window.opera && "CSS1Compat" != document.compatMode)732 {733 width = oSpan.offsetWidth;734 height = oSpan.offsetHeight;735 }736 737 width += offsetX;738 height += offsetY;739740 if (width < minWidth)741 width = minWidth;742743 if (height < minHeight)744 height = minHeight;745746 RadWindowActiveWindowSpan.style.width = width + "px"; 747 RadWindowActiveWindowSpan.style.height = height + "px";748}749750751function GetTopWindow()752{753 var topWindow = null;754755 var argumentsContainParentWindow = false;756 try757 {758 if (window.dialogArguments.parentWindow && argumentsContainParentWindow)759 {760 argumentsContainParentWindow = true;761 }762 }763 catch(ex)764 {765 argumentsContainParentWindow = false;766 }767 if (window.dialogArguments != null && argumentsContainParentWindow)768 {769 topWindow = window.dialogArguments.parentWindow;770 }771 else if (window.opener && !document.all && window.isRadWindow)772 { // NS773 topWindow = opener;774 }775 else776 {777 topWindow = window;778 }779780 var stopLoop = false;781 while (topWindow.parent && !stopLoop)782 {783 try784 {785 topWindowTagName = topWindow.parent.tagName.toUpperCase()786 }787 catch (exception)788 {789 topWindowTagName = "";790 }791792 if (topWindow.parent == topWindow)793 {794 break;795 }796797 try798 {799 /*This check is needed because of the Access denied error when cross-site scripting*/800 if (topWindow.parent.document.domain != window.document.domain)801 {802 break;803 }804 }805 catch(exc)806 {807 stopLoop = true;808 continue;809 }810811 try812 {813 if (topWindow.frameElement != null814 && (topWindow.frameElement.tagName != "IFRAME"815 || topWindow.frameElement.name != "RadWindowContent"))816 {817 break;818 }819 }820 catch(exc)821 {822 alert('in the Exception!');823 stopLoop = true;824 }825826 topWindow = topWindow.parent;827 }828 return topWindow;829}830831function Document_OnFocus(e)832{833 if (!e)834 {835 e = window.event;836 }837 GetEditorRadWindowManager().ActivateWindow();838}839840function Document_OnKeyDown(e)841{842 if (!e)843 {844 e = window.event;845 }846 return GetEditorRadWindowManager().OnKeyDown(e);847}848849function RadWindowInfo()850{851 this.IsIE = (null != document.all);852 this.ID = null;853 this.Url = "";854 this.InnerHtml = "";855 this.InnerObject = null;856 this.Width = 300;857 this.Height = 200;858 this.Caption = "";859 this.IsVisible = true;860 this.Argument = null;861 this.CallbackFunc = null;862 this.OnLoadFunc = null;863 this.Param = null; // callback func param864 this.Resizable = true;865 this.Movable = true;866 this.CloseHide = false; // true - close X hides the window; otherwise close it867 this.UseClassicDialogs = true;868}869870/***********************************************871 *872 * RadWindowManager873 *874 ***********************************************/875function GetEditorRadWindowManager()876{877 //SINGLETON878 var topWindow = GetTopWindow();879 if (!topWindow.radWindowManager)880 {881 topWindow.radWindowManager = new RadEditorWindowManager();882 }883 return topWindow.radWindowManager;884}885886887function RadEditorWindowManager()888{889 this.ChildWindows = new Array();890 this.ActiveWindow = null;891 this.TopWindowZIndex = 10001;892893 this.ContainerPool = new Array();894 this.IsIE = (null != document.all) && (window.opera == null);895896 this._overImage = null;897898 document.body.onfocus = Document_OnFocus;899900 if (this.IsIE && document.body.attachEvent)901 {902 document.body.attachEvent("onkeydown", Document_OnKeyDown);903 }904 else if (document.body.addEventListener)905 {906 document.body.addEventListener("keydown", Document_OnKeyDown, false);907 }908909 /*910 //TEKI - Add dispose mechanism to avoid memory leaks 911 var disposeWindows = function()912 { 913 var manager = GetEditorRadWindowManager();914 if (manager) //Destroy all windows and references915 {916 }917 }918 919 if (window.attachEvent)920 { 921 window.attachEvent("onunload", disposeWindows);922 }923 else if (document.addEventListener)924 {925 window.addEventListener("unload", disposeWindows, false); 926 }*/927}928929930RadEditorWindowManager.prototype.ShowModalWindow = function(radWindowInfo)931{932 var wnd = this.CreateWindow(true, radWindowInfo);933 return wnd;934}935936RadEditorWindowManager.prototype.ShowModallessWindow = function(radWindowInfo)937{938 var wnd = this.CreateWindow(false, radWindowInfo);939 return wnd;940}941942/////////////////////////////////////////////////943// WINDOWS OPERATIONS944RadEditorWindowManager.prototype.CreateWindow = function(bIsModal, radWindowInfo)945{946 if (!radWindowInfo)947 return null;948949 /* TEKI - Under Opera we should always display the classic dialogs because at present there are issues with the IFRAME - params are not passed correctly, the window does not move either.*/ 950 if (window.opera) radWindowInfo.UseClassicDialogs = true;951 952 /********* THIS CODE MAKES MOZILLA USE REGULAR WINDOWS INSTEAD OF RAD WINDOW *********/953 /*954 radWindowInfo.UseClassicDialogs = (this.IsIE && radWindowInfo.UseClassicDialogs)955 || (!this.IsIE && ((null != radWindowInfo.Url && "" != radWindowInfo.Url)956 || (null != radWindowInfo.InnerHtml && "" != radWindowInfo.InnerHtml && radWindowInfo.UseClassicDialogs)));957 */958959 var id = "";960 if (!radWindowInfo.ID || radWindowInfo.ID == "")961 {962 id = this.ChildWindows.length;963 }964 else965 {966 id = radWindowInfo.ID;967 }968969 var caption = "";970 if (null == radWindowInfo.Caption)971 {972 caption = "[" + id + "]";973 }974 else975 {976 caption = radWindowInfo.Caption;977 }978979 var radWindow = this.GetWindow(id);980981 radWindow.Argument = radWindowInfo.Argument;982 radWindow.Width = radWindowInfo.Width;983 radWindow.Height = radWindowInfo.Height;984 radWindow.CallbackFunc = radWindowInfo.CallbackFunc;985 radWindow.Param = radWindowInfo.Param;986 radWindow.CanResize = radWindowInfo.Resizable;987 radWindow.CanMove = radWindowInfo.Movable;988 radWindow.OnLoadFunc = radWindowInfo.OnLoadFunc;989 radWindow.UseRadWindow = !radWindowInfo.UseClassicDialogs;990991 if (radWindowInfo.UseClassicDialogs && this.IsIE)992 {993 var features = "status:no;"994 + "resizable:yes;"995 + "center:yes;"996 + "help:no;"997 + "minimize:no;"998 + "maximize:no;"999 + "scroll:no;"1000 + "border:thin;"1001 + "statusbar:no;"1002 + "dialogWidth:" + radWindowInfo.Width + "px;"1003 + "dialogHeight:" + radWindowInfo.Height + "px";10041005 if (radWindowInfo.InnerHtml && radWindowInfo.InnerHtml != "")1006 {1007 radWindow.InnerHTML = radWindowInfo.InnerHtml;1008 }10091010 if (!radWindowInfo.Url || "" == radWindowInfo.Url)1011 radWindowInfo.Url = "javascript:''";10121013 var dialogArguments = {1014 parentWindow : window1015 , radWindow : radWindow1016 ,IsRadWindowArgs : true //TEKI - A problem with mixing IE dialogAruments with our own!1017 };10181019 window.showModalDialog(radWindowInfo.Url, dialogArguments, features);1020 }1021 else if (radWindowInfo.UseClassicDialogs && !this.IsIE)1022 {1023 if (!radWindowInfo.Url || "" == radWindowInfo.Url)1024 radWindowInfo.Url = "javascript:''";1025 window.childRadWindow = radWindow;1026 radWindow.Window = window.open(radWindowInfo.Url1027 , "_blank"1028 , "status=no,toolbar=no,location=no,resizable=yes,menubar=no,width=" + radWindowInfo.Width + ",height=" + radWindowInfo.Height + ",modal=yes");1029 }1030 else if (!radWindowInfo.UseClassicDialogs)1031 {1032 var container = null;1033 if (this.ContainerPool.length > 0)1034 {1035 container = this.ContainerPool.pop();1036 }1037 else1038 {1039 container = document.createElement("SPAN"); 1040 document.body.appendChild(container);1041 }1042 var oHtml = this.BuildWrapperTableHtml(id1043 , radWindowInfo.Width1044 , radWindowInfo.Height1045 , caption1046 , bIsModal1047 , radWindowInfo.CloseHide);10481049 container.innerHTML = oHtml;1050 var contentElem = (null != radWindowInfo.InnerObject)1051 ? radWindowInfo.InnerObject1052 : document.getElementById("RadWindowContentFrame" + id);1053 radWindow.Initialize2(contentElem, true, container, bIsModal, ++this.TopWindowZIndex);1054 1055 var frm = document.getElementById("RadWindowContentFrame" + id);1056 1057 /*** NS toolbar when toolOnPage = false and content element is DIV ***/1058 radWindow.Window = null != frm ? frm.contentWindow : null;1059 1060 //IE CRASH1061 radWindow.Iframe = frm;1062 1063 if (radWindowInfo.InnerHtml && radWindowInfo.InnerHtml != "")1064 {1065 var doc = frm.contentWindow.document;10661067 doc.open();1068 doc.write(radWindowInfo.InnerHtml);1069 doc.close();1070 }1071 else if (radWindowInfo.Url && radWindowInfo.Url != "")1072 {1073 frm.src = radWindowInfo.Url;1074 }10751076 if (bIsModal)1077 {1078 this.SetCapture(radWindow, false);1079 }10801081 if (null == radWindowInfo.IsVisible)1082 {1083 radWindowInfo.IsVisible = false;1084 }10851086 var windowStartPosition = this.GetWindowStartPosition(radWindowInfo);10871088 radWindow.SetSize(radWindowInfo.Width, radWindowInfo.Height);1089 radWindow.ShowWindow(radWindowInfo.IsVisible, windowStartPosition.horizontal, windowStartPosition.vertical);1090 }10911092 return radWindow;1093}10941095RadEditorWindowManager.prototype.GetWindowStartPosition = function(radWindowInfo)1096{1097 var vcenterDeclination = parseInt(radWindowInfo.Height) / 2;1098 var hcenterDeclination = parseInt(radWindowInfo.Width) / 2;1099 var documentCenterPositions = this.GetDocumentVisibleCenter();11001101 return {1102 horizontal:documentCenterPositions.horizontal - hcenterDeclination,1103 vertical:documentCenterPositions.vertical - vcenterDeclination};1104};11051106RadEditorWindowManager.prototype.GetDocumentVisibleCenter = function()1107{1108 var innerWidth = 0;1109 var innerHeight = 0;1110 1111 var canvas = document.body;11121113 if (RadControlsNamespace.Browser.StandardsMode && !RadControlsNamespace.Browser.IsSafari)1114 {1115 canvas = document.documentElement;1116 }11171118 if (window.innerWidth) 1119 {1120 innerWidth = window.innerWidth;1121 innerHeight = window.innerHeight;1122 } 1123 else1124 {1125 innerWidth = canvas.clientWidth;1126 innerHeight = canvas.clientHeight;1127 }11281129 var documentVisibleCenterX = this.GetVisibleCenterCoordinate(canvas.scrollLeft, innerWidth);1130 var documentVisibleCenterY = this.GetVisibleCenterCoordinate(canvas.scrollTop, innerHeight);11311132 return {1133 horizontal:documentVisibleCenterX,1134 vertical:documentVisibleCenterY1135 };1136};11371138RadEditorWindowManager.prototype.GetVisibleCenterCoordinate = function(documentStartDeclination, visibleSize)1139{1140 var visibleAreaMiddle = parseInt(visibleSize) / 2;1141 return parseInt(documentStartDeclination) + visibleAreaMiddle;1142};11431144RadEditorWindowManager.prototype.DestroyWindow = function(childWindow)1145{1146 var nextWndToActivate = this.GetPrevWindow(childWindow.Id);11471148 this.UnregisterChild(childWindow);11491150 if (nextWndToActivate != childWindow)1151 {1152 this.ActivateWindow(nextWndToActivate);1153 }11541155 //IE CRASH - Force onunload1156 if (childWindow.Iframe)1157 {1158 childWindow.Iframe.src = "javascript:'';";1159 }11601161 eval(this.GetWindowVarName(childWindow.Id) + " = null;");11621163 if (childWindow.Container)1164 {1165 this.ContainerPool.push(childWindow.Container);1166 }1167}11681169RadEditorWindowManager.prototype.GetPrevWindow = function(id)1170{1171 var bNeedPrev = false;1172 var retWnd = null;1173 for (var i = this.ChildWindows.length - 1; i >= 0; i--)1174 {1175 var wnd = this.ChildWindows[i];1176 if (wnd && wnd.Id == id)1177 {1178 bNeedPrev = true;1179 }1180 else if (wnd && bNeedPrev)1181 {1182 return wnd;1183 }1184 else if (null == retWnd)1185 {1186 retWnd = wnd;1187 }1188 }1189 return retWnd;1190}11911192RadEditorWindowManager.prototype.CloseWindow = function(id)1193{1194 var wnd = this.LookupWindow(id);1195 if (wnd)1196 {1197 wnd.Close();1198 }1199}12001201RadEditorWindowManager.prototype.ActivateWindow = function(radWindow)1202{1203 if (!radWindow)1204 {1205 radWindow = this.ActiveWindow;1206 }1207 if (radWindow)1208 {1209 if (radWindow.IsModal)1210 {1211 this.SetCapture(radWindow, false);1212 }12131214 if (radWindow != this.ActiveWindow)1215 {1216 if (this.ActiveWindow)1217 {1218 this.ActiveWindow.SetZIndex(this.TopWindowZIndex - 1);1219 }1220 radWindow.SetZIndex(this.TopWindowZIndex);12211222 this.ActiveWindow = radWindow;1223 }12241225 if (radWindow.IsModal)1226 {1227 this.ShowOverImage(radWindow, true);1228 }1229 }1230}12311232RadEditorWindowManager.prototype.RegisterChild = function(childWindow)1233{1234 this.ChildWindows[this.ChildWindows.length] = childWindow;1235}12361237RadEditorWindowManager.prototype.UnregisterChild = function(childWindow)1238{1239 for (var i = 0; i < this.ChildWindows.length; i++)1240 {1241 var wnd = this.ChildWindows[i];1242 if (wnd == childWindow)1243 {1244 this.ChildWindows[i] = null;1245 return;1246 }1247 }1248}12491250RadEditorWindowManager.prototype.SetCapture = function(childWindow, bContainerCapture)1251{1252 try1253 {1254 if (childWindow)1255 {1256 childWindow.SetCapture(bContainerCapture);1257 }1258 }1259 catch (ex)1260 {1261 }1262}12631264RadEditorWindowManager.prototype.LookupWindow = function(id)1265{1266 for (var i = 0; i < this.ChildWindows.length; i++)1267 {1268 var wnd = this.ChildWindows[i];1269 if (wnd && id == wnd.Id)1270 {1271 return wnd;1272 }1273 }1274 return null; //this.ChildWindows[id];1275}12761277RadEditorWindowManager.prototype.LookupRadWindowByBrowserWindowRef = function(browserWindow)1278{1279 for (var i = 0; i < this.ChildWindows.length; i++)1280 {1281 var radWindow = this.ChildWindows[i];1282 if (null != radWindow && browserWindow == radWindow.Window)1283 {1284 return radWindow;1285 }1286 }1287 return null;1288}12891290RadEditorWindowManager.prototype.GetCurrentRadWindow = function(browserWindow)1291{1292 if (browserWindow.dialogArguments && (true == browserWindow.dialogArguments.IsRadWindowArgs))//TEKI - A problem with mixing IE dialogAruments with our own!1293 {1294 return browserWindow.dialogArguments.radWindow;1295 }1296 else if (browserWindow.opener != null && browserWindow.opener.childRadWindow != null)1297 {1298 return browserWindow.opener.childRadWindow;1299 }1300 else1301 {1302 var oLast = this.LookupRadWindowByBrowserWindowRef(browserWindow);1303 return oLast;1304 }1305}13061307// If already exists a window with same id - returns it;1308// Otherwise creates a new window and returns it1309RadEditorWindowManager.prototype.GetWindow = function(id)1310{1311 var wnd = this.LookupWindow(id);1312 if (!wnd)1313 {1314 var varName = this.GetWindowVarName(id);1315 eval(varName + " = new RadWindow('" + id + "');");1316 wnd = eval(varName);1317 wnd.Parent = this;13181319 this.RegisterChild(wnd);1320 }1321 return wnd;1322}13231324RadEditorWindowManager.prototype.GetWindowVarName = function(id)1325{1326 return "window.radWindow_" + id;1327}13281329RadEditorWindowManager.prototype.GetWindowFromPos = function(x, y)1330{1331 var wnd = null;1332 for (var i = 0; i < this.ChildWindows; i++)1333 {1334 var childWnd = this.ChildWindows[i];1335 if (childWnd && childWnd.HitText(x, y))1336 {1337 if (!wnd || wnd.ZIndex < childWnd.ZIndex)1338 {1339 wnd = childWnd;1340 }1341 }1342 }1343 return wnd;1344}13451346RadEditorWindowManager.prototype.OnShowWindow = function(childWindow, visible)1347{1348 if (visible)1349 {1350 this.ActiveWindow = childWindow;1351 }1352 else1353 {1354 if (this.ActiveWindow == childWindow)1355 {1356 this.ActiveWindow = null;1357 }1358 }13591360 if (childWindow.IsModal)1361 {1362 this.ShowOverImage(childWindow, visible);1363 }1364}13651366RadEditorWindowManager.prototype.OnKeyDown = function(evt)1367{1368 switch (evt.keyCode)1369 {1370 case 115: //F41371 if (evt.altKey && this.ActiveWindow)1372 {1373 //this.ActiveWindow.Close();1374 }1375 else if (evt.ctrlKey && this.ActiveWindow)1376 {1377 //alert("CTRL+F4");1378 }1379 evt.keyCode = 8;1380 break;13811382 case 27: //ESC1383 if (this.ActiveWindow)1384 {1385 this.ActiveWindow.Close();1386 }1387 break;13881389 default:1390 return;1391 }13921393 evt.cancelBubble = true;1394 evt.returnValue = false;1395}13961397RadEditorWindowManager.prototype.BuildWrapperTableHtml = function(id, width, height, caption, bIsModal, bHide)1398{1399 var url = document.all ? "javascript:'';" : "";14001401 var closeFunc = bHide ? "ShowWindow(false)" : "Close()";14021403 var html = "";1404 html += " <table border='0' id='RadWindowContentWrapper" + id + "' class='RadETableWrapper' style='width: " + width+ ";height:" + height + ";z-index:1000; position:absolute;' cellspacing='0' cellpadding='0' >\n"//width='" + width + "px' height='" + height + "px'1405 + " <tr style='height:1px;'>\n"1406 + " <td width='1' class='RadETableWrapperHeaderLeft' nowrap></td>\n"1407 + " <td width='100%' class='RadETableWrapperHeaderCenter' nowrap='true' onmousedown='radWindow_" + id + ".DragMode=\"move\"; return radWindow_" + id + ".OnDragStart(event);' onselectstart='return false;'>\n"1408 + " <span id='RadWindowCaption" + id + "' onselectstart='return false;' class='RadERadWindowHeader'>" + caption + "</span>\n"1409 + " </td>\n";141014111412 if (!bIsModal)1413 {1414 html += " <td width='1' class='RadETableWrapperHeaderCenter' nowrap>\n"1415 + " <span class='RadERadWindowButtonPinOff' id='ButtonPin' onclick='radWindow_" + id + ".ToggleCanMove(this)'> </span>"1416 + " </td>\n";1417 }14181419 html += " <td width='1' class='RadETableWrapperHeaderCenter' nowrap>\n"1420 + " <span class='RadERadWindowButtonClose' id='ButtonClose' onclick='radWindow_" + id + "." + closeFunc + "'> </span>\n"1421 + " </td>\n"1422 + " <td width='1' class='RadETableWrapperHeaderRight' nowrap></td>\n"1423 + " </tr>\n"1424 + " <tr style='height:100%' >\n"1425 + " <td style='height:100%;' colspan='5'>\n"1426 + " <table height='100%' style='height:100%' border='0' width='100%' cellspacing='0' cellpadding='0'>\n"1427 + " <tr style='height:100%'>\n"1428 + " <td width='1' class='RadETableWrapperBodyLeft' nowrap></td>\n"1429 + " <td id='RadWindowContentWindow" + id + "' style='height:100%;border:0px solid blue;' height='100%' width='100%' class='RadETableWrapperBodyCenter' align='left' valign='top' onselectstart='return false;'>\n" 1430 + " <iframe name='RadWindowContent' frameborder='0px' style='height:100%;width:100%;border:0px solid green' id='RadWindowContentFrame" + id + "' src='" + url + "' scrolling='no' border='no' ></iframe>\n"14311432 + " </td>\n"1433 + " <td width='1' class='RadETableWrapperBodyRight' nowrap></td>\n"1434 + " </tr>\n"1435 + " </table>\n"1436 + " </td>\n"1437 + " </tr>\n"1438 + " <tr style='height:1px;'>\n"1439 + " <td colspan='5' width='100%' style='height:1px;' >\n"1440 + " <table border='0' width='100%' height='1' cellspacing='0' cellpadding='0'>\n"1441 + " <tr>\n"1442 + " <td width='1' class='RadETableWrapperFooterLeft' nowrap> </td>\n"1443 + " <td colspan='3' id='BorderBottom' width='100%' class='RadETableWrapperFooterCenter' nowrap> </td> \n"1444 + " <td width='1' id='CornerBottomRight' class='RadETableWrapperFooterRight' onmousedown='radWindow_" + id + ".DragMode=\"size\"; return radWindow_" + id + ".OnDragStart(event);' onselectstart='return false;' nowrap> </td>\n"1445 + " </tr>\n"1446 + " </table>\n"1447 + " </td>\n"1448 + " </tr>\n"1449 + " </table>\n"; 1450 return html;1451}14521453RadEditorWindowManager.prototype.SetOverImage = function(imageId)1454{1455 this._overImage = document.getElementById(imageId);1456}14571458RadEditorWindowManager.prototype.GetOverImage = function()1459{1460 if (!this._overImage)1461 {1462 this._overImage = document.getElementById("OVER_IMG");1463 }1464 return this._overImage;1465}14661467RadEditorWindowManager.prototype.ShowOverImage = function(wnd, visible)1468{1469 var overImage = this.GetOverImage();1470 if (overImage)1471 {1472 if (wnd && visible)1473 {1474 var viewPortSize = RadControlsNamespace.Screen.GetViewPortSize();14751476 overImage.style.position = "absolute";1477 overImage.style.left = 0;1478 overImage.style.top = 0;14791480 overImage.style.width = viewPortSize.width + "px";1481 overImage.style.height = viewPortSize.height + "px";14821483 overImage.style.zIndex = wnd.ZIndex;1484 overImage.style.display = "";//block1485 }1486 else1487 {1488 overImage.style.display = "none";1489 }1490 }1491}14921493/*************************************************1494 *1495 * RadGetScrollTop1496 *1497 *************************************************/1498function RadGetScrollTop(oDocument)1499{1500 if (oDocument.documentElement1501 && oDocument.documentElement.scrollTop)1502 {1503 return oDocument.documentElement.scrollTop;1504 }1505 else1506 {1507 return oDocument.body.scrollTop;1508 }1509}15101511/*************************************************1512 *1513 * RadGetScrollLeft1514 *1515 *************************************************/1516function RadGetScrollLeft(oDocument)1517{1518 if (oDocument.documentElement1519 && oDocument.documentElement.scrollLeft)1520 {1521 return oDocument.documentElement.scrollLeft;1522 }1523 else1524 {1525 return oDocument.body.scrollLeft;1526 }1527}15281529function CloseDlg(returnValue, callbackFunction, execCallBack)1530{1531 if (window.radWindow)1532 {1533 window.radWindow.ReturnValue = returnValue;1534 window.radWindow.Close(null, callbackFunction, execCallBack);1535 }1536}153715381539/*1540* function InitializeRadWindow - called in a dialog to initialize the RadWindow objects1541*1542*/1543function InitializeRadWindow(editorID)1544{1545 window["GetDialogArguments"] = function(isInSpell)1546 {1547 if (window["radWindow"]) 1548 {1549 if (isInSpell)1550 {1551 return window["radWindow"].Argument.CustomArguments;1552 }1553 else1554 {1555 return window["radWindow"].Argument;1556 }1557 }1558 else1559 {1560 return null;1561 }1562 }15631564 window["isRadWindow"] = true;1565 window["radWindow"] = GetEditorRadWindowManager().GetCurrentRadWindow(window);1566 if (window["radWindow"])1567 { 1568 if (window.dialogArguments) 1569 { 1570 window["radWindow"].Window = window;1571 } 1572 window["radWindow"].OnLoad(); 1573 }15741575 var dialogArguments = GetDialogArguments();1576 if (dialogArguments)1577 { 1578 if (dialogArguments.HideEditorStatusBar)1579 {1580 dialogArguments.HideEditorStatusBar(editorID);1581 }1582 }15831584 /* NEW: In Mozilla, clicking on a button will submit the form by default! We want to avoid it!*/1585 if (document.addEventListener)1586 {1587 document.onclick = function(e)1588 {1589 var eventTarget = e.target;1590 if (eventTarget && (eventTarget.tagName == "BUTTON" || (eventTarget.tagName == "INPUT" && eventTarget.type.toLowerCase() == "button" )))1591 {1592 e.cancelBuble = true;1593 e.returnValue = false;1594 if (e.preventDefault) e.preventDefault();1595 return false;1596 }1597 };1598 }1599} ...
window.js
Source:window.js
1import { module, test } from "qunit";2import { buildOwner, runDestroy } from "test-utils";3import { setupStore } from "store-utils";4import sinon from "sinon";5import { run } from "@ember/runloop";6import Adapter from "ember-data/adapter";7import { EventEmitter } from "events";8import Window from "data/models/window/model";9import resetWindowInjector from "inject-loader!nwjs/Window/reset";10import windowInitializerInjector11// eslint-disable-next-line max-len12 from "inject-loader?config&nwjs/Window&nwjs/Window/reset&nwjs/Screen&utils/node/platform!init/instance-initializers/nwjs/window";13module( "init/instance-initializers/nwjs/window", {14 beforeEach() {15 this.owner = buildOwner();16 this.env = setupStore( this.owner );17 this.fakeTimer = sinon.useFakeTimers({18 //toFake: [ "Date", "setTimeout", "clearTimeout" ],19 target: window20 });21 const manifest = {22 window: {23 width: 960,24 height: 54025 }26 };27 const nwWindow = new EventEmitter();28 nwWindow.x = 0;29 nwWindow.y = 0;30 nwWindow.width = manifest.window.width;31 nwWindow.height = manifest.window.height;32 nwWindow.maximize = () => {33 nwWindow.emit( "maximize" );34 };35 nwWindow.minimize = () => {36 nwWindow.emit( "minimize" );37 };38 nwWindow.restore = () => {39 nwWindow.emit( "restore" );40 };41 nwWindow.moveTo = ( x, y ) => {42 nwWindow.x = x;43 nwWindow.y = y;44 nwWindow.emit( "move", x, y );45 };46 nwWindow.resizeTo = ( width, height ) => {47 nwWindow.width = width;48 nwWindow.height = height;49 nwWindow.emit( "resize", width, height );50 };51 const nwScreen = new EventEmitter();52 nwScreen.screens = [53 {54 bounds: {55 x: 0,56 y: 0,57 width: 1920,58 height: 108059 }60 },61 {62 bounds: {63 x: 1920,64 y: 0,65 width: 1920,66 height: 108067 }68 }69 ];70 this.nwWindow = nwWindow;71 this.nwScreen = nwScreen;72 this.saveStub = sinon.stub().callsFake( async function() {73 return this;74 });75 this.owner.register( "model:window", Window.extend({76 save: this.saveStub77 }) );78 const { default: resetWindow } = resetWindowInjector({79 "nwjs/App": { manifest },80 "nwjs/Window": nwWindow,81 "nwjs/Screen": nwScreen82 });83 this.subject = async ( findAll, isWin = false ) => {84 this.findAllStub = sinon.stub().callsFake( async () => findAll ? [ findAll ] : [] );85 this.owner.register( "adapter:window", Adapter.extend({86 findAll: this.findAllStub87 }) );88 const { default: windowInitializer } = windowInitializerInjector({89 "config": {90 "vars": {91 "time-window-event-debounce": 1000,92 "time-window-event-ignore": 200093 }94 },95 "nwjs/Window": nwWindow,96 "nwjs/Window/reset": resetWindow,97 "nwjs/Screen": nwScreen,98 "utils/node/platform": { isWin }99 });100 await windowInitializer( this.owner );101 };102 },103 afterEach() {104 runDestroy( this.owner );105 this.owner = this.env = this.nwWindow = this.nwScreen = null;106 this.fakeTimer.restore();107 }108});109test( "Non-existing window record", async function( assert ) {110 await this.subject();111 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );112 const windowRecord = this.env.store.peekRecord( "window", 1 );113 assert.propEqual(114 windowRecord.toJSON({ includeId: true }),115 {116 id: "1",117 x: null,118 y: null,119 width: null,120 height: null,121 maximized: false122 },123 "A window record has been created"124 );125 assert.strictEqual( this.nwWindow.x, 0, "x property has not been updated" );126 assert.strictEqual( this.nwWindow.y, 0, "y property has not been updated" );127 assert.strictEqual( this.nwWindow.width, 960, "width property has not been updated" );128 assert.strictEqual( this.nwWindow.height, 540, "height property has not been updated" );129});130test( "Existing window record with postition on first screen", async function( assert ) {131 const maximizeSpy = sinon.spy();132 const restoreSpy = sinon.spy();133 this.nwWindow.on( "maximize", maximizeSpy );134 this.nwWindow.on( "restore", restoreSpy );135 await this.subject({136 id: "1",137 x: 100,138 y: 100,139 width: 1440,140 height: 810,141 maximized: false142 });143 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );144 assert.notOk( maximizeSpy.called, "Doesn't call maximize" );145 assert.notOk( restoreSpy.called, "Doesn't call restore" );146 const windowRecord = this.env.store.peekRecord( "window", 1 );147 assert.propEqual(148 windowRecord.toJSON({ includeId: true }),149 {150 id: "1",151 x: 100,152 y: 100,153 width: 1440,154 height: 810,155 maximized: false156 },157 "A window record with id 1 exists"158 );159 assert.strictEqual( this.nwWindow.x, 100, "x property has been updated" );160 assert.strictEqual( this.nwWindow.y, 100, "y property has been updated" );161 assert.strictEqual( this.nwWindow.width, 1440, "width property has been updated" );162 assert.strictEqual( this.nwWindow.height, 810, "height property has been updated" );163 // move window off the screen164 run( () => this.nwWindow.moveTo( 481, 271 ) );165 // wait for the debounce time of the move event166 this.fakeTimer.tick( 1000 );167 assert.ok( this.saveStub.notCalled, "Doesn't update record if moved off the screen" );168 assert.propEqual(169 windowRecord.toJSON({ includeId: true }),170 {171 id: "1",172 x: 100,173 y: 100,174 width: 1440,175 height: 810,176 maximized: false177 },178 "The window record doesn't get updated if moved off the screen"179 );180 assert.strictEqual( this.nwWindow.x, 481, "x property has been updated" );181 assert.strictEqual( this.nwWindow.y, 271, "y property has been updated" );182 assert.strictEqual( this.nwWindow.width, 1440, "width property has been updated" );183 assert.strictEqual( this.nwWindow.height, 810, "height property has been updated" );184 // resize window so that parts of it are off the screen185 run( () => {186 this.nwWindow.x = this.nwWindow.y = 100;187 this.nwWindow.resizeTo( 1920, 1080 );188 });189 // wait for the debounce time of the resize event190 this.fakeTimer.tick( 1000 );191 assert.ok( this.saveStub.notCalled, "Doesn't update record if resized off the screen" );192 assert.propEqual(193 windowRecord.toJSON({ includeId: true }),194 {195 id: "1",196 x: 100,197 y: 100,198 width: 1440,199 height: 810,200 maximized: false201 },202 "The window record doesn't get updated if resized off the screen"203 );204 assert.strictEqual( this.nwWindow.x, 100, "x property has been updated" );205 assert.strictEqual( this.nwWindow.y, 100, "y property has been updated" );206 assert.strictEqual( this.nwWindow.width, 1920, "width property has been updated" );207 assert.strictEqual( this.nwWindow.height, 1080, "height property has been updated" );208});209test( "Existing window record with position on second screen", async function( assert ) {210 const maximizeSpy = sinon.spy();211 const restoreSpy = sinon.spy();212 this.nwWindow.on( "maximize", maximizeSpy );213 this.nwWindow.on( "restore", restoreSpy );214 await this.subject({215 id: "1",216 x: 2020,217 y: 100,218 width: 1440,219 height: 810,220 maximized: true221 });222 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );223 assert.ok( maximizeSpy.calledOnce, "Calls maximize once" );224 assert.notOk( restoreSpy.called, "Doesn't call restore" );225 const windowRecord = this.env.store.peekRecord( "window", 1 );226 assert.propEqual(227 windowRecord.toJSON({ includeId: true }),228 {229 id: "1",230 x: 2020,231 y: 100,232 width: 1440,233 height: 810,234 maximized: true235 },236 "A window record with id 1 exists"237 );238 assert.strictEqual( this.nwWindow.x, 2020, "x property has been updated" );239 assert.strictEqual( this.nwWindow.y, 100, "y property has been updated" );240 assert.strictEqual( this.nwWindow.width, 1440, "width property has been updated" );241 assert.strictEqual( this.nwWindow.height, 810, "height property has been updated" );242 // remove second screen (window is now out of bounds)243 const secondScreen = this.nwScreen.screens.pop();244 // require all three events to be triggered after triggering displayBoundsChanged245 let resolveMove, resolveResize;246 const promise = Promise.all([247 new Promise( r => resolveMove = r ),248 new Promise( r => resolveResize = r )249 ]);250 const moveStub = sinon.stub().callsFake( resolveMove );251 const resizeStub = sinon.stub().callsFake( resolveResize );252 this.nwWindow.once( "move", moveStub );253 this.nwWindow.once( "resize", resizeStub );254 run( () => this.nwScreen.emit( "displayBoundsChanged" ) );255 await promise;256 assert.ok( moveStub.calledOnce, "Emits move event once" );257 assert.ok( resizeStub.calledOnce, "Emits resize event once" );258 assert.notOk( this.saveStub.called, "Hasn't called updateRecord yet" );259 // wait for the debounce time of the events260 this.fakeTimer.tick( 1000 );261 assert.ok( this.saveStub.calledTwice, "Has called updateRecord twice (resize+move)" );262 assert.propEqual(263 windowRecord.toJSON({ includeId: true }),264 {265 id: "1",266 x: 480,267 y: 270,268 width: 960,269 height: 540,270 maximized: true271 },272 "Resets the window record if the screens change and the window is out of bounds"273 );274 assert.strictEqual( this.nwWindow.x, 480, "x property has been reset" );275 assert.strictEqual( this.nwWindow.y, 270, "y property has been reset" );276 assert.strictEqual( this.nwWindow.width, 960, "width property has been reset" );277 assert.strictEqual( this.nwWindow.height, 540, "height property has been reset" );278 this.saveStub.resetHistory();279 // move window between two screens280 this.nwScreen.screens.push( secondScreen );281 this.nwWindow.x = 1440;282 run( () => this.nwWindow.emit( "move", this.nwWindow.x, this.nwWindow.y ) );283 // wait for the debounce time of the move event284 this.fakeTimer.tick( 1000 );285 assert.notOk( this.saveStub.called, "Hasn't called updateRecord" );286 assert.propEqual(287 windowRecord.toJSON({ includeId: true }),288 {289 id: "1",290 x: 480,291 y: 270,292 width: 960,293 height: 540,294 maximized: true295 },296 "Doesn't upgrade the window record if the windows gets moved between two screens"297 );298 assert.strictEqual( this.nwWindow.x, 1440, "x property has been set" );299 assert.strictEqual( this.nwWindow.y, 270, "y property has been set" );300 assert.strictEqual( this.nwWindow.width, 960, "width property has been set" );301 assert.strictEqual( this.nwWindow.height, 540, "height property has been set" );302});303test( "Existing window record with position off screen", async function( assert ) {304 const maximizeSpy = sinon.spy();305 const restoreSpy = sinon.spy();306 this.nwWindow.on( "maximize", maximizeSpy );307 this.nwWindow.on( "restore", restoreSpy );308 await this.subject({309 id: "1",310 x: -10000,311 y: -10000,312 width: 1920,313 height: 1080,314 maximized: true315 });316 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );317 assert.ok( maximizeSpy.calledOnce, "Calls maximize once" );318 assert.notOk( restoreSpy.called, "Doesn't call restore" );319 assert.notOk( this.saveStub.called, "Hasn't called updateRecord" );320 // wait for the debounce time of the events321 this.fakeTimer.tick( 2000 );322 assert.ok( this.saveStub.calledTwice, "Has called updateRecord twice (move+resize)" );323 const windowRecord = this.env.store.peekRecord( "window", 1 );324 assert.propEqual(325 windowRecord.toJSON({ includeId: true }),326 {327 id: "1",328 x: 480,329 y: 270,330 width: 960,331 height: 540,332 maximized: true333 },334 "Resets the window record when resetting the application window"335 );336 assert.strictEqual( this.nwWindow.x, 480, "x property has been updated" );337 assert.strictEqual( this.nwWindow.y, 270, "y property has been updated" );338 assert.strictEqual( this.nwWindow.width, 960, "width property has been updated" );339 assert.strictEqual( this.nwWindow.height, 540, "height property has been updated" );340});341test( "Maximize and restore", async function( assert ) {342 await this.subject({343 id: "1",344 x: 480,345 y: 270,346 width: 960,347 height: 540,348 maximized: false349 });350 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );351 const windowRecord = this.env.store.peekRecord( "window", 1 );352 run( () => this.nwWindow.maximize() );353 assert.ok( this.saveStub.calledOnce, "Updates window record on maximize" );354 assert.propEqual(355 windowRecord.toJSON({ includeId: true }),356 {357 id: "1",358 x: 480,359 y: 270,360 width: 960,361 height: 540,362 maximized: true363 },364 "Saves maximized state on maximize"365 );366 this.saveStub.resetHistory();367 run( () => this.nwWindow.restore() );368 assert.ok( this.saveStub.calledOnce, "Updates window record on restore" );369 assert.propEqual(370 windowRecord.toJSON({ includeId: true }),371 {372 id: "1",373 x: 480,374 y: 270,375 width: 960,376 height: 540,377 maximized: false378 },379 "Saves maximized state on restore"380 );381});382test( "Debounce events", async function( assert ) {383 await this.subject({384 id: "1",385 x: 480,386 y: 270,387 width: 960,388 height: 540,389 maximized: false390 });391 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );392 for ( let i = 0; i < 3; i++ ) {393 run( () => {394 this.nwWindow.emit( "move", 0, 0 );395 this.nwWindow.emit( "resize", 1920, 1080 );396 });397 this.fakeTimer.tick( 999 );398 }399 assert.notOk( this.saveStub.called, "Hasn't called updateRecord yet" );400 this.fakeTimer.tick( 1 );401 assert.ok( this.saveStub.calledTwice, "Has called updateRecord twice (move+resize)" );402 const windowRecord = this.env.store.peekRecord( "window", 1 );403 assert.propEqual(404 windowRecord.toJSON({ includeId: true }),405 {406 id: "1",407 x: 0,408 y: 0,409 width: 1920,410 height: 1080,411 maximized: false412 },413 "Updates the window record only once for each event type"414 );415});416test( "Ignore events on minimize", async function( assert ) {417 await this.subject({418 id: "1",419 x: 480,420 y: 270,421 width: 960,422 height: 540,423 maximized: false424 });425 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );426 // minimize427 run( () => this.nwWindow.minimize() );428 assert.notOk( this.saveStub.called, "Hasn't called updateRecord yet" );429 // those events will be ignored430 run( () => {431 this.nwWindow.emit( "move", 0, 0 );432 this.nwWindow.emit( "resize", 1920, 1080 );433 });434 this.fakeTimer.tick( 1000 );435 assert.notOk( this.saveStub.called, "Hasn't called updateRecord yet" );436 // these events won't be ignored437 run( () => {438 this.nwWindow.emit( "move", 0, 0 );439 this.nwWindow.emit( "resize", 1920, 1080 );440 });441 this.fakeTimer.tick( 1000 );442 assert.ok( this.saveStub.calledTwice, "Has called updateRecord twice" );443 const windowRecord = this.env.store.peekRecord( "window", 1 );444 assert.propEqual(445 windowRecord.toJSON({ includeId: true }),446 {447 id: "1",448 x: 0,449 y: 0,450 width: 1920,451 height: 1080,452 maximized: false453 },454 "Updates the window record only after the event ignore time expires"455 );456});457test( "Ignore events on maximize", async function( assert ) {458 await this.subject({459 id: "1",460 x: 480,461 y: 270,462 width: 960,463 height: 540,464 maximized: false465 });466 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );467 // maximize (calls updateRecord() separately)468 run( () => this.nwWindow.maximize() );469 assert.ok( this.saveStub.calledOnce, "Has called updateRecord once" );470 // those events will be ignored471 run( () => {472 this.nwWindow.emit( "move", 0, 0 );473 this.nwWindow.emit( "resize", 1920, 1080 );474 });475 this.fakeTimer.tick( 1000 );476 assert.ok( this.saveStub.calledOnce, "Has called updateRecord still once" );477 // these events won't be ignored478 run( () => {479 this.nwWindow.emit( "move", 0, 0 );480 this.nwWindow.emit( "resize", 1920, 1080 );481 });482 this.fakeTimer.tick( 1000 );483 assert.ok( this.saveStub.calledThrice, "Has called updateRecord thrice" );484 const windowRecord = this.env.store.peekRecord( "window", 1 );485 assert.propEqual(486 windowRecord.toJSON({ includeId: true }),487 {488 id: "1",489 x: 0,490 y: 0,491 width: 1920,492 height: 1080,493 maximized: true494 },495 "Updates the window record only after the event ignore time expires"496 );497});498test( "Special window coordinates on Windows", async function( assert ) {499 this.nwScreen.screens = [500 {501 bounds: {502 x: -64000,503 y: -64000,504 width: 128000,505 height: 128000506 }507 }508 ];509 await this.subject({510 id: "1",511 x: 480,512 y: 270,513 width: 960,514 height: 540,515 maximized: false516 }, true );517 assert.ok( this.findAllStub.calledOnce, "Calls findAll once" );518 const windowRecord = this.env.store.peekRecord( "window", 1 );519 run( () => {520 this.nwWindow.x = -8;521 this.nwWindow.y = -8;522 this.nwWindow.emit( "move", this.nwWindow.x, this.nwWindow.y );523 });524 this.fakeTimer.tick( 1000 );525 assert.propEqual(526 windowRecord.toJSON({ includeId: true }),527 {528 id: "1",529 x: 480,530 y: 270,531 width: 960,532 height: 540,533 maximized: false534 },535 "Doesn't update the window record"536 );537 run( () => {538 this.nwWindow.x = -32000;539 this.nwWindow.y = -32000;540 this.nwWindow.emit( "move", this.nwWindow.x, this.nwWindow.y );541 });542 this.fakeTimer.tick( 1000 );543 assert.propEqual(544 windowRecord.toJSON({ includeId: true }),545 {546 id: "1",547 x: 480,548 y: 270,549 width: 960,550 height: 540,551 maximized: false552 },553 "Doesn't update the window record"554 );...
browserWindow.js
Source:browserWindow.js
1/*******************************************************************************2 * Copyright (c) 2008, 2009 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 *8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11function BarProp(){};12BarProp.prototype = new Array();13/**14 * Object Window()15 * @super Global16 * @constructor17 * @since Common Usage, no standard18*/19function Window(){};20Window.prototype = new Global();21Window.prototype.self = new Window();22Window.prototype.window = new Window();23Window.prototype.frames = new Array();24/**25 * Property closed26 * @type Boolean27 * @memberOf Window28 */29Window.prototype.closed = new Boolean();30/**31 * Property defaultStatus32 * @type String33 * @memberOf Window34 */35Window.prototype.defaultStatus = "";36/**37 * Property document38 * @type Document39 * @memberOf Window40 */41Window.prototype.document= new HTMLDocument();42/**43 * Property history44 * @type History45 * @memberOf Window46 */47Window.prototype.history= new History();48/**49 * Property location50 * @type Location51 * @memberOf Window52 */53Window.prototype.location=new Location();54/**55 * Property name56 * @type String57 * @memberOf Window58 */59Window.prototype.name = "";60/**61 * Property navigator62 * @type Navigator63 * @memberOf Window64 */65Window.prototype.navigator = new Navigator();66/**67 * Property opener68 * @type Window69 * @memberOf Window70 */71Window.prototype.opener = new Window();72/**73 * Property outerWidth74 * @type Number75 * @memberOf Window76 */77Window.prototype.outerWidth = 0;78/**79 * Property outerHeight80 * @type Number81 * @memberOf Window82 */83Window.prototype.outerHeight = 0;84/**85 * Property pageXOffset86 * @type Number87 * @memberOf Window88 */89Window.prototype.pageXOffset = 0;90/**91 * Property pageYOffset92 * @type Number93 * @memberOf Window94 */95Window.prototype.pageYOffset = 0;96/**97 * Property parent98 * @type Window99 * @memberOf Window100 */101Window.prototype.parent = new Window();102/**103 * Property screen104 * @type Screen105 * @memberOf Window106 */107Window.prototype.screen = new Screen();108/**109 * Property status110 * @type String111 * @memberOf Window112 */113Window.prototype.status = "";114/**115 * Property top116 * @type Window117 * @memberOf Window118 */119Window.prototype.top = new Window();120/*121 * These properties may need to be moved into a browswer specific library.122 */123 /**124 * Property innerWidth125 * @type Number126 * @memberOf Window127 */128Window.prototype.innerWidth = 0;129/**130 * Property innerHeight131 * @type Number132 * @memberOf Window133 */134Window.prototype.innerHeight = 0;135/**136 * Property screenX137 * @type Number138 * @memberOf Window139 */140Window.prototype.screenX = 0;141/**142 * Property screenY143 * @type Number144 * @memberOf Window145 */146Window.prototype.screenY = 0;147/**148 * Property screenLeft149 * @type Number150 * @memberOf Window151 */152Window.prototype.screenLeft = 0;153/**154 * Property screenTop155 * @type Number156 * @memberOf Window157 */158Window.prototype.screenTop = 0;159//Window.prototype.event = new Event();160Window.prototype.length = 0;161Window.prototype.scrollbars= new BarProp();162Window.prototype.scrollX=0;163Window.prototype.scrollY=0;164Window.prototype.content= new Window();165Window.prototype.menubar= new BarProp();166Window.prototype.toolbar= new BarProp();167Window.prototype.locationbar= new BarProp();168Window.prototype.personalbar= new BarProp();169Window.prototype.statusbar= new BarProp();170Window.prototype.directories= new BarProp();171Window.prototype.scrollMaxX=0;172Window.prototype.scrollMaxY=0;173Window.prototype.fullScreen="";174Window.prototype.frameElement="";175Window.prototype.sessionStorage="";176/* End properites */177/**178 * function alert() 179 * @param {String} arg180 * @memberOf Window181 */182Window.prototype.alert = function(arg){};183/**184 * function blur() 185 * @memberOf Window186 */187Window.prototype.blur = function(){};188/**189 * function clearInterval(arg) 190 * @param arg191 * @memberOf Window192 */193Window.prototype.clearInterval = function(arg){};194/**195 * function clearTimeout(arg) 196 * @param arg197 * @memberOf Window198 */199Window.prototype.clearTimeout = function(arg){};200/**201 * function close() 202 * @memberOf Window203 */204Window.prototype.close = function(){};205/**206 * function confirm() 207 * @param {String} arg208 * @memberOf Window209 * @returns {Boolean}210 */211Window.prototype.confirm = function(arg){return false;};212/**213 * function focus() 214 * @memberOf Window215 */216Window.prototype.focus = function(){};217/**218 * function getComputedStyle(arg1, arg2) 219 * @param {Element} arg1220 * @param {String} arg2221 * @memberOf Window222 * @returns {Object}223 */224Window.prototype.getComputedStyle = function(arg1,arg2){return new Object();};225/**226 * function moveTo(arg1, arg2) 227 * @param {Number} arg1228 * @param {Number} arg2229 * @memberOf Window230 */231Window.prototype.moveTo = function(arg1,arg2){};232/**233 * function moveBy(arg1, arg2) 234 * @param {Number} arg1235 * @param {Number} arg2236 * @memberOf Window237 */238Window.prototype.moveBy = function(arg1,arg2){};239/**240 * function open(optionalArg1, optionalArg2, optionalArg3, optionalArg4) 241 * @param {String} optionalArg1242 * @param {String} optionalArg2243 * @param {String} optionalArg3244 * @param {Boolean} optionalArg4245 * @memberOf Window246 * @returns {Window}247 */248Window.prototype.open = function(optionalArg1, optionalArg2, optionalArg3, optionalArg4){return new Window();};249/**250 * function print() 251 * @memberOf Window252 */253Window.prototype.print = function(){};254/**255 * function prompt(arg1, arg2) 256 * @param {String} arg1257 * @param {String} arg2258 * @memberOf Window259 * @returns {String}260 */261Window.prototype.prompt = function(){return "";};262/**263 * function resizeTo(arg1, arg2) 264 * @param {Number} arg1265 * @param {Number} arg2266 * @memberOf Window267 */268Window.prototype.resizeTo=function(arg1,arg2){};269/**270 * function resizeBy(arg1, arg2) 271 * @param {Number} arg1272 * @param {Number} arg2273 * @memberOf Window274 */275Window.prototype.resizeBy=function(arg1,arg2){};276/**277 * function scrollTo(arg1, arg2) 278 * @param {Number} arg1279 * @param {Number} arg2280 * @memberOf Window281 */282Window.prototype.scrollTo=function(arg1,arg2){};283/**284 * function scrollBy(arg1, arg2) 285 * @param {Number} arg1286 * @param {Number} arg2287 * @memberOf Window288 */289Window.prototype.scrollBy=function(arg1,arg2){};290/**291 * function setInterval(arg1, arg2) 292 * @param {Object} arg1293 * @param {Number} arg2294 * @memberOf Window295 * @returns {Object}296 */297Window.prototype.setInterval=function(arg1, arg2){return new Object();};298/**299 * function setTimeout(arg1, arg2) 300 * @param {Object} arg1301 * @param {Number} arg2302 * @memberOf Window303 * @returns {Object}304 */305Window.prototype.setTimeout=function(arg1, arg2){return new Object();};306/**307 * function atob(arg) 308 * @param {String} arg309 * @memberOf Window310 * @returns {String}311 */312Window.prototype.atob=function(arg){return "";};313/**314 * function btoa(arg) 315 * @param {String} arg316 * @memberOf Window317 * @returns {String}318 */319Window.prototype.btoa=function(arg){return "";};320/**321 * function setResizable(arg) 322 * @param {Boolean} arg323 * @memberOf Window324 */325Window.prototype.setResizable=function(arg){};326Window.prototype.captureEvents=function(arg1){};327Window.prototype.releaseEvents=function(arg1){};328Window.prototype.routeEvent=function(arg1){};329Window.prototype.enableExternalCapture=function(){};330Window.prototype.disableExternalCapture=function(){};331Window.prototype.find=function(){};332Window.prototype.back=function(){};333Window.prototype.forward=function(){};334Window.prototype.home=function(){};335Window.prototype.stop=function(){};336Window.prototype.scroll=function(arg1,arg2){};337/*338 * These functions may need to be moved into a browser specific library.339 */340Window.prototype.dispatchEvent=function(arg1){};341Window.prototype.removeEventListener=function(arg1,arg2,arg3){};342/* End functions */343/**344 * Object History()345 * @super Object346 * @constructor347 * @since Common Usage, no standard348 */349function History(){};350History.prototype=new Object();351History.prototype.history = new History();352/**353 * Property length354 * @type Number355 * @memberOf History356 */357History.prototype.length = 0;358/**359 * function back()360 * @memberOf History361 */362History.prototype.back = function(){};363/**364 * function forward()365 * @memberOf History366 */367History.prototype.forward = function(){};368/**369 * function back()370 * @param arg371 * @memberOf History372 */373History.prototype.go = function(arg){};374/**375 * Object Location()376 * @super Object377 * @constructor378 * @since Common Usage, no standard379 */380function Location(){};381Location.prototype = new Object();382Location.prototype.location = new Location();383/**384 * Property hash385 * @type String386 * @memberOf Location387 */388Location.prototype.hash = "";389/**390 * Property host391 * @type String392 * @memberOf Location393 */394Location.prototype.host = "";395/**396 * Property hostname397 * @type String398 * @memberOf Location399 */400Location.prototype.hostname = "";401/**402 * Property href403 * @type String404 * @memberOf Location405 */406Location.prototype.href = "";407/**408 * Property pathname409 * @type String410 * @memberOf Location411 */412Location.prototype.pathname = "";413/**414 * Property port415 * @type String416 * @memberOf Location417 */418Location.prototype.port = "";419/**420 * Property protocol421 * @type String422 * @memberOf Location423 */424Location.prototype.protocol = "";425/**426 * Property search427 * @type String428 * @memberOf Location429 */430Location.prototype.search = "";431/**432 * function assign(arg)433 * @param {String} arg434 * @memberOf Location435 */436Location.prototype.assign = function(arg){};437/**438 * function reload(optionalArg)439 * @param {Boolean} optionalArg440 * @memberOf Location441 */442Location.prototype.reload = function(optionalArg){};443/**444 * function replace(arg)445 * @param {String} arg446 * @memberOf Location447 */448Location.prototype.replace = function(arg){};449/**450 * Object Navigator()451 * @super Object452 * @constructor453 * @since Common Usage, no standard454*/455function Navigator(){};456Navigator.prototype = new Object();457Navigator.prototype.navigator = new Navigator();458/**459 * Property appCodeName460 * @type String461 * @memberOf Navigator462 */463Navigator.prototype.appCodeName = "";464/**465 * Property appName466 * @type String467 * @memberOf Navigator468 */469Navigator.prototype.appName = "";470/**471 * Property appVersion472 * @type String473 * @memberOf Navigator474 */475Navigator.prototype.appVersion = "";476/**477 * Property cookieEnabled478 * @type Boolean479 * @memberOf Navigator480 */481Navigator.prototype.cookieEnabled = new Boolean();482/**483 * Property mimeTypes484 * @type Array485 * @memberOf Navigator486 */487Navigator.prototype.mimeTypes = new Array();488/**489 * Property platform490 * @type String491 * @memberOf Navigator492 */493Navigator.prototype.platform = "";494/**495 * Property plugins496 * @type Array497 * @memberOf Navigator498 */499Navigator.prototype.plugins = new Array();500/**501 * Property userAgent502 * @type String503 * @memberOf Navigator504 */505Navigator.prototype.userAgent = "";506/**507 * function javaEnabled()508 * @returns {Boolean}509 * @memberOf Navigator510 */511Navigator.prototype.javaEnabled = function(){return false;};512/**513 * Object Screen()514 * @super Object515 * @constructor516 * @since Common Usage, no standard517*/518function Screen(){};519Screen.prototype = new Object();520Screen.prototype.screen = new Screen();521/**522 * Property availHeight523 * @type Number524 * @memberOf Screen525 */526Navigator.prototype.availHeight = 0;527/**528 * Property availWidth529 * @type Number530 * @memberOf Screen531 */532Navigator.prototype.availWidth = 0;533/**534 * Property colorDepth535 * @type Number536 * @memberOf Screen537 */538Navigator.prototype.colorDepth = 0;539/**540 * Property height541 * @type Number542 * @memberOf Screen543 */544Navigator.prototype.height = 0;545/**546 * Property width547 * @type Number548 * @memberOf Screen549 */...
window-manager.es6
Source:window-manager.es6
1import _ from 'underscore';2import {app} from 'electron';3import WindowLauncher from './window-launcher';4const MAIN_WINDOW = "default"5const WORK_WINDOW = "work"6const SPEC_WINDOW = "spec"7const ONBOARDING_WINDOW = "onboarding"8// const CALENDAR_WINDOW = "calendar"9export default class WindowManager {10 constructor({devMode, benchmarkMode, safeMode, specMode, resourcePath, configDirPath, initializeInBackground, config}) {11 this.initializeInBackground = initializeInBackground;12 this._windows = {};13 const onCreatedHotWindow = (win) => {14 this._registerWindow(win);15 this._didCreateNewWindow(win);16 }17 this.windowLauncher = new WindowLauncher({devMode, benchmarkMode, safeMode, specMode, resourcePath, configDirPath, config, onCreatedHotWindow});18 }19 get(windowKey) {20 return this._windows[windowKey];21 }22 getOpenWindows() {23 const values = [];24 Object.keys(this._windows).forEach((key) => {25 const win = this._windows[key];26 if (win.windowType !== WindowLauncher.EMPTY_WINDOW) {27 values.push(win);28 }29 });30 const score = (win) =>31 (win.loadSettings().mainWindow ? 1000 : win.browserWindow.id);32 return values.sort((a, b) => score(b) - score(a));33 }34 getAllWindowDimensions() {35 const dims = {}36 Object.keys(this._windows).forEach((key) => {37 const win = this._windows[key];38 if (win.windowType !== WindowLauncher.EMPTY_WINDOW) {39 const {x, y, width, height} = win.browserWindow.getBounds()40 const maximized = win.browserWindow.isMaximized()41 const fullScreen = win.browserWindow.isFullScreen()42 dims[key] = {x, y, width, height, maximized, fullScreen}43 }44 });45 return dims46 }47 newWindow(options = {}) {48 const win = this.windowLauncher.newWindow(options);49 const existingKey = this._registeredKeyForWindow(win);50 if (existingKey) {51 delete this._windows[existingKey];52 }53 this._registerWindow(win);54 if (!existingKey) {55 this._didCreateNewWindow(win);56 }57 return win;58 }59 _registerWindow = (win) => {60 if (!win.windowKey) {61 throw new Error("WindowManager: You must provide a windowKey");62 }63 if (this._windows[win.windowKey]) {64 throw new Error(`WindowManager: Attempting to register a new window for an existing windowKey (${win.windowKey}). Use 'get()' to retrieve the existing window instead.`);65 }66 this._windows[win.windowKey] = win;67 }68 _didCreateNewWindow = (win) => {69 win.browserWindow.on("closed", () => {70 delete this._windows[win.windowKey];71 this.quitWinLinuxIfNoWindows();72 });73 // Let the applicationMenu know that there's a new window available.74 // The applicationMenu automatically listens to the `closed` event of75 // the browserWindow to unregister itself76 global.application.applicationMenu.addWindow(win.browserWindow);77 }78 _registeredKeyForWindow = (win) => {79 for (const key of Object.keys(this._windows)) {80 const otherWin = this._windows[key];81 if (win === otherWin) {82 return key;83 }84 }85 return null;86 }87 ensureWindow(windowKey, extraOpts) {88 const win = this._windows[windowKey];89 if (!win) {90 this.newWindow(this._coreWindowOpts(windowKey, extraOpts));91 return;92 }93 if (win.loadSettings().hidden) {94 return;95 }96 if (win.isMinimized()) {97 win.restore();98 win.focus();99 } else if (!win.isVisible()) {100 win.showWhenLoaded();101 } else {102 win.focus();103 }104 }105 sendToAllWindows(msg, {except}, ...args) {106 for (const windowKey of Object.keys(this._windows)) {107 const win = this._windows[windowKey];108 if (win.browserWindow === except) {109 continue;110 }111 if (!win.browserWindow.webContents) {112 continue;113 }114 win.browserWindow.webContents.send(msg, ...args);115 }116 }117 destroyAllWindows() {118 this.windowLauncher.cleanupBeforeAppQuit();119 for (const windowKey of Object.keys(this._windows)) {120 this._windows[windowKey].browserWindow.destroy();121 }122 this._windows = {}123 }124 cleanupBeforeAppQuit() {125 this.windowLauncher.cleanupBeforeAppQuit();126 }127 quitWinLinuxIfNoWindows() {128 // Typically, N1 stays running in the background on all platforms, since it129 // has a status icon you can use to quit it.130 // However, on Windows and Linux we /do/ want to quit if the app is somehow131 // put into a state where there are no visible windows and the main window132 // doesn't exist.133 // This /shouldn't/ happen, but if it does, the only way for them to recover134 // would be to pull up the Task Manager. Ew.135 if (['win32', 'linux'].includes(process.platform)) {136 this.quitCheck = this.quitCheck || _.debounce(() => {137 const visibleWindows = _.filter(this._windows, (win) => win.isVisible())138 const mainWindow = this.get(WindowManager.MAIN_WINDOW);139 const noMainWindowLoaded = !mainWindow || !mainWindow.isLoaded();140 if (visibleWindows.length === 0 && noMainWindowLoaded) {141 app.quit();142 }143 }, 25000);144 this.quitCheck();145 }146 }147 focusedWindow() {148 return _.find(this._windows, (win) => win.isFocused());149 }150 _coreWindowOpts(windowKey, extraOpts = {}) {151 const coreWinOpts = {}152 coreWinOpts[WindowManager.MAIN_WINDOW] = {153 windowKey: WindowManager.MAIN_WINDOW,154 windowType: WindowManager.MAIN_WINDOW,155 title: "Message Viewer",156 neverClose: true,157 bootstrapScript: require.resolve("../window-bootstrap"),158 mainWindow: true,159 width: 640, // Gets reset once app boots up160 height: 396, // Gets reset once app boots up161 center: true, // Gets reset once app boots up162 resizable: false, // Gets reset once app boots up163 initializeInBackground: this.initializeInBackground,164 };165 coreWinOpts[WindowManager.WORK_WINDOW] = {166 windowKey: WindowManager.WORK_WINDOW,167 windowType: WindowManager.WORK_WINDOW,168 coldStartOnly: true, // It's a secondary window, but not a hot window169 title: "Activity",170 hidden: true,171 neverClose: true,172 width: 800,173 height: 400,174 }175 coreWinOpts[WindowManager.ONBOARDING_WINDOW] = {176 windowKey: WindowManager.ONBOARDING_WINDOW,177 windowType: WindowManager.ONBOARDING_WINDOW,178 title: "Account Setup",179 hidden: true, // Displayed by PageRouter::_initializeWindowSize180 frame: false, // Always false on Mac, explicitly set for Win & Linux181 toolbar: false,182 resizable: false,183 width: 900,184 height: 600,185 }186 // The SPEC_WINDOW gets passed its own bootstrapScript187 coreWinOpts[WindowManager.SPEC_WINDOW] = {188 windowKey: WindowManager.SPEC_WINDOW,189 windowType: WindowManager.SPEC_WINDOW,190 title: "Specs",191 frame: true,192 hidden: true,193 isSpec: true,194 devMode: true,195 benchmarkMode: false,196 toolbar: false,197 }198 const defaultOptions = coreWinOpts[windowKey] || {};199 return Object.assign({}, defaultOptions, extraOpts);200 }201}202WindowManager.MAIN_WINDOW = MAIN_WINDOW;203WindowManager.WORK_WINDOW = WORK_WINDOW;204WindowManager.SPEC_WINDOW = SPEC_WINDOW;205// WindowManager.CALENDAR_WINDOW = CALENDAR_WINDOW;...
high-contrast-theme.js
Source:high-contrast-theme.js
1/* *2 *3 * (c) 2009-2019 Ãystein Moseng4 *5 * Default theme for Windows High Contrast Mode.6 *7 * License: www.highcharts.com/license8 *9 * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!10 *11 * */12'use strict';13var theme = {14 chart: {15 backgroundColor: 'window'16 },17 title: {18 style: {19 color: 'windowText'20 }21 },22 subtitle: {23 style: {24 color: 'windowText'25 }26 },27 colorAxis: {28 minColor: 'windowText',29 maxColor: 'windowText',30 stops: []31 },32 colors: ['windowText'],33 xAxis: {34 gridLineColor: 'windowText',35 labels: {36 style: {37 color: 'windowText'38 }39 },40 lineColor: 'windowText',41 minorGridLineColor: 'windowText',42 tickColor: 'windowText',43 title: {44 style: {45 color: 'windowText'46 }47 }48 },49 yAxis: {50 gridLineColor: 'windowText',51 labels: {52 style: {53 color: 'windowText'54 }55 },56 lineColor: 'windowText',57 minorGridLineColor: 'windowText',58 tickColor: 'windowText',59 title: {60 style: {61 color: 'windowText'62 }63 }64 },65 tooltip: {66 backgroundColor: 'window',67 borderColor: 'windowText',68 style: {69 color: 'windowText'70 }71 },72 plotOptions: {73 series: {74 lineColor: 'windowText',75 fillColor: 'window',76 borderColor: 'windowText',77 edgeColor: 'windowText',78 borderWidth: 1,79 dataLabels: {80 connectorColor: 'windowText',81 color: 'windowText',82 style: {83 color: 'windowText',84 textOutline: 'none'85 }86 },87 marker: {88 lineColor: 'windowText',89 fillColor: 'windowText'90 }91 },92 pie: {93 color: 'window',94 colors: ['window'],95 borderColor: 'windowText',96 borderWidth: 197 },98 boxplot: {99 fillColor: 'window'100 },101 candlestick: {102 lineColor: 'windowText',103 fillColor: 'window'104 },105 errorbar: {106 fillColor: 'window'107 }108 },109 legend: {110 backgroundColor: 'window',111 itemStyle: {112 color: 'windowText'113 },114 itemHoverStyle: {115 color: 'windowText'116 },117 itemHiddenStyle: {118 color: '#555'119 },120 title: {121 style: {122 color: 'windowText'123 }124 }125 },126 credits: {127 style: {128 color: 'windowText'129 }130 },131 labels: {132 style: {133 color: 'windowText'134 }135 },136 drilldown: {137 activeAxisLabelStyle: {138 color: 'windowText'139 },140 activeDataLabelStyle: {141 color: 'windowText'142 }143 },144 navigation: {145 buttonOptions: {146 symbolStroke: 'windowText',147 theme: {148 fill: 'window'149 }150 }151 },152 rangeSelector: {153 buttonTheme: {154 fill: 'window',155 stroke: 'windowText',156 style: {157 color: 'windowText'158 },159 states: {160 hover: {161 fill: 'window',162 stroke: 'windowText',163 style: {164 color: 'windowText'165 }166 },167 select: {168 fill: '#444',169 stroke: 'windowText',170 style: {171 color: 'windowText'172 }173 }174 }175 },176 inputBoxBorderColor: 'windowText',177 inputStyle: {178 backgroundColor: 'window',179 color: 'windowText'180 },181 labelStyle: {182 color: 'windowText'183 }184 },185 navigator: {186 handles: {187 backgroundColor: 'window',188 borderColor: 'windowText'189 },190 outlineColor: 'windowText',191 maskFill: 'transparent',192 series: {193 color: 'windowText',194 lineColor: 'windowText'195 },196 xAxis: {197 gridLineColor: 'windowText'198 }199 },200 scrollbar: {201 barBackgroundColor: '#444',202 barBorderColor: 'windowText',203 buttonArrowColor: 'windowText',204 buttonBackgroundColor: 'window',205 buttonBorderColor: 'windowText',206 rifleColor: 'windowText',207 trackBackgroundColor: 'window',208 trackBorderColor: 'windowText'209 }210};...
window-launcher.es6
Source:window-launcher.es6
1import NylasWindow from './nylas-window'2const DEBUG_SHOW_HOT_WINDOW = process.env.SHOW_HOT_WINDOW || false;3let winNum = 0;4/**5 * It takes a full second or more to bootup a Nylas window. Most of this6 * is due to sheer amount of time it takes to parse all of the javascript7 * and follow the require tree.8 *9 * Since popout windows need to be more responsive than that, we pre-load10 * "hot" windows in the background that have most of the code loaded. Then11 * all we need to do is load the handful of packages the window12 * requires and show it.13 */14export default class WindowLauncher {15 static EMPTY_WINDOW = "emptyWindow"16 constructor({devMode, benchmarkMode, safeMode, specMode, resourcePath, configDirPath, onCreatedHotWindow, config}) {17 this.defaultWindowOpts = {18 frame: process.platform !== "darwin",19 hidden: false,20 toolbar: true,21 devMode,22 safeMode,23 benchmarkMode,24 resizable: true,25 windowType: WindowLauncher.EMPTY_WINDOW,26 bootstrapScript: require.resolve("../secondary-window-bootstrap"),27 resourcePath,28 configDirPath,29 }30 this.config = config;31 this.onCreatedHotWindow = onCreatedHotWindow;32 if (specMode) return;33 this.createHotWindow();34 }35 newWindow(options) {36 const opts = Object.assign({}, this.defaultWindowOpts, options);37 let win;38 if (this._mustUseColdWindow(opts)) {39 win = new NylasWindow(opts)40 } else {41 // Check if the hot window has been deleted. This may happen when we are42 // relaunching the app43 if (!this.hotWindow) {44 this.createHotWindow()45 }46 win = this.hotWindow;47 const newLoadSettings = Object.assign({}, win.loadSettings(), opts)48 if (newLoadSettings.windowType === WindowLauncher.EMPTY_WINDOW) {49 throw new Error("Must specify a windowType")50 }51 // Reset the loaded state and update the load settings.52 // This will fire `NylasEnv::populateHotWindow` and reload the53 // packages.54 win.windowKey = opts.windowKey || `${opts.windowType}-${winNum}`;55 winNum += 1;56 win.windowType = opts.windowType;57 if (options.bounds) {58 win.browserWindow.setBounds(options.bounds);59 }60 if (options.width && options.height) {61 win.browserWindow.setSize(options.width, options.height);62 }63 win.setLoadSettings(newLoadSettings);64 setTimeout(() => {65 // We need to regen a hot window, but do it in the next event66 // loop to not hang the opening of the current window.67 this.createHotWindow();68 }, 0)69 }70 if (!opts.hidden && !opts.initializeInBackground) {71 // NOTE: In the case of a cold window, this will show it once72 // loaded. If it's a hotWindow, since hotWindows have a73 // `hidden:true` flag, nothing will show. When `setLoadSettings`74 // starts populating the window in `populateHotWindow` we'll show or75 // hide based on the windowOpts76 win.showWhenLoaded()77 }78 return win79 }80 createHotWindow() {81 this.hotWindow = new NylasWindow(this._hotWindowOpts());82 this.onCreatedHotWindow(this.hotWindow);83 if (DEBUG_SHOW_HOT_WINDOW) {84 this.hotWindow.showWhenLoaded();85 }86 }87 // Note: This method calls `browserWindow.destroy()` which closes88 // windows without waiting for them to load or firing window lifecycle89 // events. This is necessary for the app to quit promptly on Linux.90 // https://phab.nylas.com/T128291 cleanupBeforeAppQuit() {92 if (this.hotWindow != null) {93 this.hotWindow.browserWindow.destroy()94 }95 this.hotWindow = null96 }97 // Some properties, like the `frame` or `toolbar` can't be updated once98 // a window has been setup. If we detect this case we have to bootup a99 // plain NylasWindow instead of using a hot window.100 _mustUseColdWindow(opts) {101 const {bootstrapScript, frame} = this.defaultWindowOpts;102 const usesOtherBootstrap = opts.bootstrapScript !== bootstrapScript;103 const usesOtherFrame = (!!opts.frame) !== frame;104 const requestsColdStart = opts.coldStartOnly;105 return usesOtherBootstrap || usesOtherFrame || requestsColdStart;106 }107 _hotWindowOpts() {108 const hotWindowOpts = Object.assign({}, this.defaultWindowOpts);109 hotWindowOpts.packageLoadingDeferred = true;110 hotWindowOpts.hidden = DEBUG_SHOW_HOT_WINDOW;111 return hotWindowOpts112 }...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation