Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions js/rpg_managers/DataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ DataManager.setupNewGame = function() {
$gamePlayer.reserveTransfer($dataSystem.startMapId,
$dataSystem.startX, $dataSystem.startY);
Graphics.frameCount = 0;
SceneManager.resetFrameCount();
};

DataManager.setupBattleTest = function() {
Expand Down
18 changes: 18 additions & 0 deletions js/rpg_managers/SceneManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -130,6 +131,18 @@ SceneManager.setupErrorHandlers = function() {
document.addEventListener('keydown', this.onKeyDown.bind(this));
};

SceneManager.frameCount = function() {
return this._frameCount;
};

SceneManager.setFrameCount = function(frameCount) {
this._frameCount = frameCount;
};

SceneManager.resetFrameCount = function() {
this._frameCount = 0;
};

SceneManager.requestUpdate = function() {
if (!this._stopped) {
requestAnimationFrame(this.update.bind(this));
Expand Down Expand Up @@ -263,6 +276,7 @@ SceneManager.updateScene = function() {
this.onSceneStart();
}
if (this.isCurrentSceneStarted()) {
this.updateFrameCount();
this._scene.update();
}
}
Expand All @@ -276,6 +290,10 @@ SceneManager.renderScene = function() {
}
};

SceneManager.updateFrameCount = function() {
this._frameCount++;
};

SceneManager.onSceneCreate = function() {
Graphics.startLoading();
};
Expand Down
17 changes: 4 additions & 13 deletions js/rpg_objects/Game_System.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,10 +117,6 @@ Game_System.prototype.saveCount = function() {
return this._saveCount;
};

Game_System.prototype.frameCount = function() {
return this._frameCount;
};

Game_System.prototype.versionId = function() {
return this._versionId;
};
Expand Down Expand Up @@ -169,29 +165,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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do not erase this for save data compatibility.

If this does not exist, SceneManager.setFrameCount(undefined) may occur. 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that to raise the complexity of scripts for save data compatibility is not good. Though I respect your policy.

Graphics.frameCount = this._framesOnSave;
SceneManager.setFrameCount(this._sceneFramesOnSave || this._framesOnSave);
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() {
Expand Down
1 change: 0 additions & 1 deletion js/rpg_scenes/Scene_Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Scene_Base.prototype.start = function() {
* @memberof Scene_Base
*/
Scene_Base.prototype.update = function() {
$gameSystem.onFrameUpdate();
this.updateFade();
this.updateChildren();
};
Expand Down