Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
triacontane committed Mar 10, 2017
1 parent be267df commit 955220c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 37 deletions.
36 changes: 17 additions & 19 deletions FontLoad.js
Expand Up @@ -6,6 +6,7 @@
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.1.0 2017/03/11 本体v1.3.5(コミュニティ版)で機能しなくなる問題を修正
// 1.0.0 2016/06/02 初版
// ----------------------------------------------------------------------------
// [Blog] : http://triacontane.blogspot.jp/
Expand Down Expand Up @@ -132,33 +133,30 @@
// Scene_Boot
// 必要なフォントをロードします。
//=============================================================================
var _Scene_Boot_create = Scene_Boot.prototype.create;
Scene_Boot.prototype.create = function() {
_Scene_Boot_create.apply(this, arguments);
var _Scene_Boot_isGameFontLoaded = Scene_Boot.prototype.isGameFontLoaded;
Scene_Boot.prototype.isGameFontLoaded = function() {
if (!_Scene_Boot_isGameFontLoaded.apply(this)) {
return false;
}
if (!this._customFontLoading) {
this.loadCustomFonts();
}
return this.isCustomFontLoaded();
};

Scene_Boot.prototype.loadCustomFonts = function() {
paramFonts.forEach(function(fontInfo) {
if (fontInfo.name && fontInfo.url) {
Graphics.loadFont(fontInfo.name, fontInfo.url);
}
}.bind(this));
this._customFontLoading = true;
};

var _Scene_Boot_isGameFontLoaded = Scene_Boot.prototype.isGameFontLoaded;
Scene_Boot.prototype.isGameFontLoaded = function() {
if (!_Scene_Boot_isGameFontLoaded.apply(this)) {
return false;
}
var result = !paramWaitLoadComplete || paramFonts.every(function(fontInfo) {
return Graphics.isFontLoaded(fontInfo.name) || !fontInfo.name || !fontInfo.url;
Scene_Boot.prototype.isCustomFontLoaded = function() {
return !paramWaitLoadComplete || paramFonts.every(function(fontInfo) {
return !fontInfo.name || !fontInfo.url || Graphics.isFontLoaded(fontInfo.name);
}.bind(this));
if (result) {
return true;
} else {
var elapsed = Date.now() - this._startDate;
if (elapsed >= 20000) {
throw new Error('Failed to load custom font');
}
return false;
}
};
})();

5 changes: 3 additions & 2 deletions PerformanceRefine.js
Expand Up @@ -6,6 +6,7 @@
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.2.1 2017/03/11 コミュニティ版で動作しない問題を修正
// 1.2.0 2017/01/21 1フレーム中に実行したイベントの総数をログ出力する機能を追加
// 1.1.0 2017/01/09 ローカル環境以外でも動作するよう修正
// 実行中のイベントの更新時間を出力できる機能を追加
Expand Down Expand Up @@ -237,9 +238,9 @@
return callBack();
}
const averageInfo = this._getAverageInfo(processName);
const beforeTime = this._getTimeInMs();
const beforeTime = performance.now();
const result = callBack();
const processTime = this._getTimeInMs() - beforeTime;
const processTime = performance.now() - beforeTime;
const count = averageInfo.count;
averageInfo.value = (averageInfo.value * count + processTime) / (count + 1);
averageInfo.count++;
Expand Down
56 changes: 40 additions & 16 deletions ThroughFailedToLoad.js
Expand Up @@ -6,6 +6,7 @@
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 2.1.0 2017/03/11 本体v1.3.5(コミュニティ版)で機能しなくなる問題を修正
// 2.0.0 2016/08/05 本体v1.3.0対応(1.2.0では使えなくなります)
// 1.0.0 2016/06/25 初版
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -87,22 +88,44 @@
// ロード失敗した画像ファイルを空の画像に差し替えます。
//=============================================================================
var _ImageManager_isReady = ImageManager.isReady;
ImageManager.isReady = function() {
var result = false;
try {
result = _ImageManager_isReady.apply(this, arguments);
} catch (e) {
for (var key in this.cache._inner) {
if (!this.cache._inner.hasOwnProperty(key)) continue;
var bitmap = this.cache._inner[key].item;
if (bitmap.isError()) {
bitmap.eraseError();
this.cache.setItem(key, new Bitmap());
if (Utils.RPGMAKER_ENGINE) {
ImageManager.isReady = function() {
this._imageCache.eraseBitmapError();
return _ImageManager_isReady.apply(this, arguments);
};
} else {
ImageManager.isReady = function() {
var result = false;
try {
result = _ImageManager_isReady.apply(this, arguments);
} catch (e) {
for (var key in this.cache._inner) {
if (!this.cache._inner.hasOwnProperty(key)) continue;
var bitmap = this.cache._inner[key].item;
if (bitmap.isError()) {
bitmap.eraseError();
this.cache.setItem(key, new Bitmap());
}
}
result = _ImageManager_isReady.apply(this, arguments);
}
result = _ImageManager_isReady.apply(this, arguments);
}
return result;
return result;
};
}

//=============================================================================
// ImageCache
// ロード失敗した画像ファイルを空の画像に差し替えます。
//=============================================================================
ImageCache.prototype.eraseBitmapError = function() {
var items = this._items;
Object.keys(items).forEach(function(key) {
var bitmap = items[key].bitmap;
if (bitmap.isError()) {
bitmap.eraseError();
items[key].bitmap = new Bitmap();
}
});
};

//=============================================================================
Expand All @@ -116,8 +139,9 @@
// エラー発生用のフラグをキャンセルします。
//=============================================================================
Bitmap.prototype.eraseError = function() {
this._hasError = false;
this._isLoading = false;
this._hasError = false;
this._isLoading = false;
this._loadingState = 'loaded';
};
})();

0 comments on commit 955220c

Please sign in to comment.