Skip to content

Commit 3b2e2de

Browse files
committed
rpgtkoolmv#175 count frames at SceneManager
Remove accessing to $gameSystem by Scene_Base.
1 parent 69db961 commit 3b2e2de

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

js/rpg_managers/SceneManager.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SceneManager._boxHeight = 624;
3030
SceneManager._deltaTime = 1.0 / 60.0;
3131
if (!Utils.isMobileSafari()) SceneManager._currentTime = SceneManager._getTimeInMsWithoutMobileSafari();
3232
SceneManager._accumulator = 0.0;
33+
SceneManager._frameCount = 0;
3334

3435
SceneManager.run = function(sceneClass) {
3536
try {
@@ -130,6 +131,14 @@ SceneManager.setupErrorHandlers = function() {
130131
document.addEventListener('keydown', this.onKeyDown.bind(this));
131132
};
132133

134+
SceneManager.frameCount = function() {
135+
return this._frameCount;
136+
};
137+
138+
SceneManager.setFrameCount = function(frameCount) {
139+
this._frameCount = frameCount;
140+
};
141+
133142
SceneManager.requestUpdate = function() {
134143
if (!this._stopped) {
135144
requestAnimationFrame(this.update.bind(this));
@@ -263,6 +272,7 @@ SceneManager.updateScene = function() {
263272
this.onSceneStart();
264273
}
265274
if (this.isCurrentSceneStarted()) {
275+
this.updateFrameCount();
266276
this._scene.update();
267277
}
268278
}
@@ -276,6 +286,10 @@ SceneManager.renderScene = function() {
276286
}
277287
};
278288

289+
SceneManager.updateFrameCount = function() {
290+
this._frameCount++;
291+
};
292+
279293
SceneManager.onSceneCreate = function() {
280294
Graphics.startLoading();
281295
};

js/rpg_objects/Game_System.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Game_System.prototype.initialize = function() {
1616
this._winCount = 0;
1717
this._escapeCount = 0;
1818
this._saveCount = 0;
19-
this._frameCount = 0;
2019
this._versionId = 0;
2120
this._framesOnSave = 0;
21+
this._sceneFramesOnSave = 0;
2222
this._bgmOnSave = null;
2323
this._bgsOnSave = null;
2424
this._windowTone = null;
@@ -118,7 +118,7 @@ Game_System.prototype.saveCount = function() {
118118
};
119119

120120
Game_System.prototype.frameCount = function() {
121-
return this._frameCount;
121+
return SceneManager.frameCount();
122122
};
123123

124124
Game_System.prototype.versionId = function() {
@@ -169,29 +169,24 @@ Game_System.prototype.onBattleEscape = function() {
169169
this._escapeCount++;
170170
};
171171

172-
Game_System.prototype.onFrameUpdate = function() {
173-
this._frameCount++;
174-
};
175-
176172
Game_System.prototype.onBeforeSave = function() {
177173
this._saveCount++;
178174
this._versionId = $dataSystem.versionId;
179175
this._framesOnSave = Graphics.frameCount;
176+
this._sceneFramesOnSave = SceneManager.frameCount();
180177
this._bgmOnSave = AudioManager.saveBgm();
181178
this._bgsOnSave = AudioManager.saveBgs();
182179
};
183180

184181
Game_System.prototype.onAfterLoad = function() {
185-
if (!this._frameCount) {
186-
this._frameCount = this._framesOnSave;
187-
}
188182
Graphics.frameCount = this._framesOnSave;
183+
SceneManager.setFrameCount(this._sceneFramesOnSave);
189184
AudioManager.playBgm(this._bgmOnSave);
190185
AudioManager.playBgs(this._bgsOnSave);
191186
};
192187

193188
Game_System.prototype.playtime = function() {
194-
return Math.floor(this._frameCount / 60);
189+
return Math.floor(SceneManager.frameCount() / 60);
195190
};
196191

197192
Game_System.prototype.playtimeText = function() {

js/rpg_scenes/Scene_Base.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Scene_Base.prototype.start = function() {
105105
* @memberof Scene_Base
106106
*/
107107
Scene_Base.prototype.update = function() {
108-
$gameSystem.onFrameUpdate();
109108
this.updateFade();
110109
this.updateChildren();
111110
};

0 commit comments

Comments
 (0)