From 3b2e2de01da2cc7e444b3ff359861b26d720e84a Mon Sep 17 00:00:00 2001 From: rev2nym Date: Sun, 26 Aug 2018 21:56:46 +0900 Subject: [PATCH 1/4] #175 count frames at SceneManager Remove accessing to $gameSystem by Scene_Base. --- js/rpg_managers/SceneManager.js | 14 ++++++++++++++ js/rpg_objects/Game_System.js | 15 +++++---------- js/rpg_scenes/Scene_Base.js | 1 - 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index 77fc95c1..851c2615 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -30,6 +30,7 @@ SceneManager._boxHeight = 624; SceneManager._deltaTime = 1.0 / 60.0; if (!Utils.isMobileSafari()) SceneManager._currentTime = SceneManager._getTimeInMsWithoutMobileSafari(); SceneManager._accumulator = 0.0; +SceneManager._frameCount = 0; SceneManager.run = function(sceneClass) { try { @@ -130,6 +131,14 @@ SceneManager.setupErrorHandlers = function() { document.addEventListener('keydown', this.onKeyDown.bind(this)); }; +SceneManager.frameCount = function() { + return this._frameCount; +}; + +SceneManager.setFrameCount = function(frameCount) { + this._frameCount = frameCount; +}; + SceneManager.requestUpdate = function() { if (!this._stopped) { requestAnimationFrame(this.update.bind(this)); @@ -263,6 +272,7 @@ SceneManager.updateScene = function() { this.onSceneStart(); } if (this.isCurrentSceneStarted()) { + this.updateFrameCount(); this._scene.update(); } } @@ -276,6 +286,10 @@ SceneManager.renderScene = function() { } }; +SceneManager.updateFrameCount = function() { + this._frameCount++; +}; + SceneManager.onSceneCreate = function() { Graphics.startLoading(); }; diff --git a/js/rpg_objects/Game_System.js b/js/rpg_objects/Game_System.js index 0f7a98c2..6c5ee36c 100644 --- a/js/rpg_objects/Game_System.js +++ b/js/rpg_objects/Game_System.js @@ -16,9 +16,9 @@ Game_System.prototype.initialize = function() { this._winCount = 0; this._escapeCount = 0; this._saveCount = 0; - this._frameCount = 0; this._versionId = 0; this._framesOnSave = 0; + this._sceneFramesOnSave = 0; this._bgmOnSave = null; this._bgsOnSave = null; this._windowTone = null; @@ -118,7 +118,7 @@ Game_System.prototype.saveCount = function() { }; Game_System.prototype.frameCount = function() { - return this._frameCount; + return SceneManager.frameCount(); }; Game_System.prototype.versionId = function() { @@ -169,29 +169,24 @@ Game_System.prototype.onBattleEscape = function() { this._escapeCount++; }; -Game_System.prototype.onFrameUpdate = function() { - this._frameCount++; -}; - Game_System.prototype.onBeforeSave = function() { this._saveCount++; this._versionId = $dataSystem.versionId; this._framesOnSave = Graphics.frameCount; + this._sceneFramesOnSave = SceneManager.frameCount(); this._bgmOnSave = AudioManager.saveBgm(); this._bgsOnSave = AudioManager.saveBgs(); }; Game_System.prototype.onAfterLoad = function() { - if (!this._frameCount) { - this._frameCount = this._framesOnSave; - } Graphics.frameCount = this._framesOnSave; + SceneManager.setFrameCount(this._sceneFramesOnSave); AudioManager.playBgm(this._bgmOnSave); AudioManager.playBgs(this._bgsOnSave); }; Game_System.prototype.playtime = function() { - return Math.floor(this._frameCount / 60); + return Math.floor(SceneManager.frameCount() / 60); }; Game_System.prototype.playtimeText = function() { diff --git a/js/rpg_scenes/Scene_Base.js b/js/rpg_scenes/Scene_Base.js index 88b97374..4ab0e6a6 100644 --- a/js/rpg_scenes/Scene_Base.js +++ b/js/rpg_scenes/Scene_Base.js @@ -105,7 +105,6 @@ Scene_Base.prototype.start = function() { * @memberof Scene_Base */ Scene_Base.prototype.update = function() { - $gameSystem.onFrameUpdate(); this.updateFade(); this.updateChildren(); }; From 9875c94cb92c655f4ff919458740bf1eb503ee0f Mon Sep 17 00:00:00 2001 From: rev2nym Date: Tue, 28 Aug 2018 05:57:47 +0900 Subject: [PATCH 2/4] #175 reset scene frame count at setup new game --- js/rpg_managers/DataManager.js | 1 + js/rpg_managers/SceneManager.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/js/rpg_managers/DataManager.js b/js/rpg_managers/DataManager.js index 8c59e044..9ddcc62f 100644 --- a/js/rpg_managers/DataManager.js +++ b/js/rpg_managers/DataManager.js @@ -217,6 +217,7 @@ DataManager.setupNewGame = function() { $gamePlayer.reserveTransfer($dataSystem.startMapId, $dataSystem.startX, $dataSystem.startY); Graphics.frameCount = 0; + SceneManager.resetFrameCount(); }; DataManager.setupBattleTest = function() { diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index 851c2615..5b1f13ce 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -139,6 +139,10 @@ SceneManager.setFrameCount = function(frameCount) { this._frameCount = frameCount; }; +SceneManager.resetFrameCount = function() { + this._frameCount = 0; +}; + SceneManager.requestUpdate = function() { if (!this._stopped) { requestAnimationFrame(this.update.bind(this)); From 579ef7122317906f600db7c18719b769838d0a9b Mon Sep 17 00:00:00 2001 From: rev2nym Date: Tue, 28 Aug 2018 06:10:43 +0900 Subject: [PATCH 3/4] #175 recovery of the save data compatibility On after load, if scene frame count is undefined, it is initialized by graphics frame count. --- js/rpg_objects/Game_System.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/rpg_objects/Game_System.js b/js/rpg_objects/Game_System.js index 6c5ee36c..10767424 100644 --- a/js/rpg_objects/Game_System.js +++ b/js/rpg_objects/Game_System.js @@ -180,7 +180,7 @@ Game_System.prototype.onBeforeSave = function() { Game_System.prototype.onAfterLoad = function() { Graphics.frameCount = this._framesOnSave; - SceneManager.setFrameCount(this._sceneFramesOnSave); + SceneManager.setFrameCount(this._sceneFramesOnSave || this._framesOnSave); AudioManager.playBgm(this._bgmOnSave); AudioManager.playBgs(this._bgsOnSave); }; From 1c42b55f86605c6dd75dfdeca77efcdeda5dd520 Mon Sep 17 00:00:00 2001 From: rev2nym Date: Tue, 28 Aug 2018 06:15:11 +0900 Subject: [PATCH 4/4] #175 remove unused method --- js/rpg_objects/Game_System.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/js/rpg_objects/Game_System.js b/js/rpg_objects/Game_System.js index 10767424..1613581d 100644 --- a/js/rpg_objects/Game_System.js +++ b/js/rpg_objects/Game_System.js @@ -117,10 +117,6 @@ Game_System.prototype.saveCount = function() { return this._saveCount; }; -Game_System.prototype.frameCount = function() { - return SceneManager.frameCount(); -}; - Game_System.prototype.versionId = function() { return this._versionId; };