From aaa81b1eb5c42be93f135324547bc4073642bf39 Mon Sep 17 00:00:00 2001 From: krmbn0576 Date: Mon, 15 May 2017 15:19:06 +0900 Subject: [PATCH 1/4] pause when retry button is displayed --- js/rpg_core/Bitmap.js | 3 ++- js/rpg_core/Input.js | 4 +++- js/rpg_core/ResourceHandler.js | 2 ++ js/rpg_managers/SceneManager.js | 12 ++++++++---- plugins/Debug_FailLoading.js | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/js/rpg_core/Bitmap.js b/js/rpg_core/Bitmap.js index 81374f3d..0f5a41a4 100644 --- a/js/rpg_core/Bitmap.js +++ b/js/rpg_core/Bitmap.js @@ -896,7 +896,8 @@ Bitmap.prototype.decode = function(){ this._decodeAfterRequest = true; if (!this._loader) { this._loader = ResourceHandler.createLoader(this._url, this._requestImage.bind(this, this._url), this._onError.bind(this)); - this._image.onerror = this._loader; + this._image.removeEventListener('error', this._errorListener); + this._image.addEventListener('error', this._errorListener = this._loader); } break; diff --git a/js/rpg_core/Input.js b/js/rpg_core/Input.js index 9192952b..9c305c59 100644 --- a/js/rpg_core/Input.js +++ b/js/rpg_core/Input.js @@ -287,7 +287,9 @@ Input._onKeyDown = function(event) { this.clear(); } var buttonName = this.keyMapper[event.keyCode]; - if (buttonName) { + if (ResourceHandler.exists() && buttonName === 'ok') { + ResourceHandler.retry(); + } else if (buttonName) { this._currentState[buttonName] = true; } }; diff --git a/js/rpg_core/ResourceHandler.js b/js/rpg_core/ResourceHandler.js index 6157d0a5..43e111ee 100644 --- a/js/rpg_core/ResourceHandler.js +++ b/js/rpg_core/ResourceHandler.js @@ -26,6 +26,7 @@ ResourceHandler.createLoader = function(url, retryMethod, resignMethod, retryInt if (url) { if (reloaders.length === 0) { Graphics.printLoadingError(url); + SceneManager.stop(); } reloaders.push(function() { retryCount = 0; @@ -43,6 +44,7 @@ ResourceHandler.exists = function() { ResourceHandler.retry = function() { if (this._reloaders.length > 0) { Graphics.eraseLoadingError(); + SceneManager.resume(); this._reloaders.forEach(function(reloader) { reloader(); }); diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index be1919eb..75e4412a 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -248,10 +248,6 @@ SceneManager.changeScene = function() { }; SceneManager.updateScene = function() { - if (ResourceHandler.exists() && Input.isTriggered('ok')) { - ResourceHandler.retry(); - this.updateInputData(); - } if (this._scene) { if (!this._sceneStarted && this._scene.isReady()) { this._scene.start(); @@ -355,3 +351,11 @@ SceneManager.snapForBackground = function() { SceneManager.backgroundBitmap = function() { return this._backgroundBitmap; }; + +SceneManager.resume = function() { + this._stopped = false; + this.requestUpdate(); + if (!Utils.isMobileSafari()) { + this._currentTime = this._getTimeInMsWithoutMobileSafari(); + } +}; diff --git a/plugins/Debug_FailLoading.js b/plugins/Debug_FailLoading.js index a52138f2..aa4a8946 100644 --- a/plugins/Debug_FailLoading.js +++ b/plugins/Debug_FailLoading.js @@ -54,7 +54,7 @@ var _Bitmap_onLoad = Bitmap.prototype._onLoad; Bitmap.prototype._onLoad = function() { if (Math.random() < failImage) { - this._image.onerror(); + this._errorListener(); } else { _Bitmap_onLoad.apply(this, arguments); } From 8b6e2f0905b7e3570dfb635c798a1b17145c893d Mon Sep 17 00:00:00 2001 From: krmbn0576 Date: Tue, 16 May 2017 00:05:07 +0900 Subject: [PATCH 2/4] fix accumulator --- js/rpg_managers/SceneManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index 75e4412a..3a506805 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -357,5 +357,6 @@ SceneManager.resume = function() { this.requestUpdate(); if (!Utils.isMobileSafari()) { this._currentTime = this._getTimeInMsWithoutMobileSafari(); + this._accumulator = 0; } }; From 5c55c2a4c9004890a3ff9e3a3dcb307c2db7e1d8 Mon Sep 17 00:00:00 2001 From: krmbn0576 Date: Tue, 16 May 2017 00:23:05 +0900 Subject: [PATCH 3/4] fix duplicate listener --- js/rpg_core/Bitmap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/rpg_core/Bitmap.js b/js/rpg_core/Bitmap.js index 0f5a41a4..b108e6d2 100644 --- a/js/rpg_core/Bitmap.js +++ b/js/rpg_core/Bitmap.js @@ -976,7 +976,8 @@ Bitmap.prototype._requestImage = function(url){ Decrypter.decryptImg(url, this); } else { this._image.src = url; - + this._image.removeEventListener('load', this._loadListener); + this._image.removeEventListener('error', this._errorListener); this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this)); this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this)); } From dff3f7d0080bcc008f79304bc2244aabff7e0560 Mon Sep 17 00:00:00 2001 From: krmbn0576 Date: Tue, 16 May 2017 15:58:07 +0900 Subject: [PATCH 4/4] revert previous --- js/rpg_core/Bitmap.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/rpg_core/Bitmap.js b/js/rpg_core/Bitmap.js index b108e6d2..0f5a41a4 100644 --- a/js/rpg_core/Bitmap.js +++ b/js/rpg_core/Bitmap.js @@ -976,8 +976,7 @@ Bitmap.prototype._requestImage = function(url){ Decrypter.decryptImg(url, this); } else { this._image.src = url; - this._image.removeEventListener('load', this._loadListener); - this._image.removeEventListener('error', this._errorListener); + this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this)); this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this)); }