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
49 changes: 35 additions & 14 deletions js/rpg_core/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ Graphics.setLoadingImage = function(src) {
this._loadingImage.src = src;
};

/**
* Sets whether the progress bar is enabled.
*
* @static
* @method setEnableProgress
*/
Graphics.setProgressEnabled = function(enable) {
this._progressEnabled = enable;
};

/**
* Initializes the counter for displaying the "Now Loading" image.
*
Expand All @@ -260,30 +270,43 @@ Graphics._setupProgress = function(){
this._progressElement = document.createElement('div');
this._progressElement.id = 'loading-progress';
this._progressElement.width = 600;
this._progressElement.height = 30;
this._progressElement.style.background = 'linear-gradient(to top, gray, lightgray)';
this._progressElement.style.border = '5px solid white';
this._progressElement.style.borderRadius = '15px';
this._progressElement.height = 300;
this._progressElement.style.visibility = 'hidden';

this._barElement = document.createElement('div');
this._barElement.id = 'loading-bar';
this._barElement.style.width = '0%';
this._barElement.style.height = '100%';
this._barElement.style.background = 'linear-gradient(to top, lime, palegreen)';
this._barElement.style.borderRadius = '10px';
this._barElement.style.width = '100%';
this._barElement.style.height = '10%';
this._barElement.style.background = 'linear-gradient(to top, gray, lightgray)';
this._barElement.style.border = '5px solid white';
this._barElement.style.borderRadius = '15px';
this._barElement.style.marginTop = '40%';

this._filledBarElement = document.createElement('div');
this._filledBarElement.id = 'loading-filled-bar';
this._filledBarElement.style.width = '0%';
this._filledBarElement.style.height = '100%';
this._filledBarElement.style.background = 'linear-gradient(to top, lime, honeydew)';
this._filledBarElement.style.borderRadius = '10px';

this._progressElement.appendChild(this._barElement);
this._barElement.appendChild(this._filledBarElement);
this._updateProgress();

document.body.appendChild(this._progressElement);
};

Graphics._showProgress = function(){
this._progressElement.value = 0;
this._progressElement.style.visibility = 'visible';
if (this._progressEnabled) {
this._progressElement.value = 0;
this._progressElement.style.visibility = 'visible';
this._progressElement.style.zIndex = 98;
}
};

Graphics._hideProgress = function(){
this._progressElement.style.visibility = 'hidden';
clearTimeout(this._progressTimeout);
};

Graphics._updateProgressCount = function(countLoaded, countLoading){
Expand All @@ -294,13 +317,11 @@ Graphics._updateProgressCount = function(countLoaded, countLoading){
progressValue = 100;
}

this._barElement.style.width = progressValue + '%';
this._filledBarElement.style.width = progressValue + '%';
};

Graphics._updateProgress = function(){
this._progressElement.style.zIndex = 99;
this._centerElement(this._progressElement);
this._progressElement.style.marginTop = 450 * this._realScale + 'px';
};

/**
Expand All @@ -326,7 +347,6 @@ Graphics.endLoading = function() {
this._clearUpperCanvas();
this._upperCanvas.style.opacity = 0;
this._hideProgress();
clearTimeout(this._progressTimeout);
};

/**
Expand Down Expand Up @@ -380,6 +400,7 @@ Graphics.eraseLoadingError = function() {
*/
Graphics.printError = function(name, message) {
this._errorShowed = true;
this._hideProgress();
this.hideFps();
if (this._errorPrinter) {
this._updateErrorPrinter();
Expand Down
43 changes: 42 additions & 1 deletion plugins/Community_Basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
* @type string
* @desc The message when error occurred
* @default Error occurred. Please ask to the creator of this game.
*
* @param enableProgressBar
* @type boolean
* @desc Show progress bar when it takes a long time to load resources
* @default true
*
* @param maxRenderingFps
* @type number
* @desc The maximum value of rendering frame per seconds (0: unlimited)
* @default 0
*/

/*:ja
Expand Down Expand Up @@ -135,6 +145,18 @@
* @type string
* @text エラーメッセージ
* @default エラーが発生しました。ゲームの作者にご連絡ください。
*
* @param enableProgressBar
* @type boolean
* @text ロード進捗バー有効化
* @desc ONにすると、読み込みに時間がかかっている時にロード進捗バーを表示します
* @default true
*
* @param maxRenderingFps
* @type number
* @text 描画FPS上限値
* @desc 描画FPSの上限値を設定します (0を指定した場合は制限なし)
* @default 0
*/

(function() {
Expand All @@ -152,12 +174,14 @@
var screenWidth = toNumber(parameters['screenWidth'], 816);
var screenHeight = toNumber(parameters['screenHeight'], 624);
var renderingMode = parameters['renderingMode'].toLowerCase();
var alwaysDash = parameters['alwaysDash'].toLowerCase() === 'true';
var alwaysDash = parameters['alwaysDash'] === 'true';
var textSpeed = toNumber(parameters['textSpeed'], 1);
var windowWidthTo = toNumber(parameters['changeWindowWidthTo'], 0);
var windowHeightTo = toNumber(parameters['changeWindowHeightTo'], 0);
var maxRenderingFps = toNumber(parameters['maxRenderingFps'], 0);
var autoSaveFileId = toNumber(parameters['autoSaveFileId'], 0);
var errorMessage = parameters['errorMessage'];
var enableProgressBar = parameters['enableProgressBar'] === 'true';

var windowWidth;
var windowHeight;
Expand Down Expand Up @@ -221,6 +245,23 @@
}
};

if (maxRenderingFps) {
var currentTime = Date.now();
var deltaTime = 1000 / maxRenderingFps;
var accumulator = 0;
var _SceneManager_renderScene = SceneManager.renderScene;
SceneManager.renderScene = function() {
var newTime = Date.now();
accumulator += newTime - currentTime;
currentTime = newTime;
if (accumulator >= deltaTime) {
accumulator -= deltaTime;
_SceneManager_renderScene.apply(this, arguments);
}
};
}

DataManager.setAutoSaveFileId(autoSaveFileId);
Graphics.setErrorMessage(errorMessage);
Graphics.setProgressEnabled(enableProgressBar);
})();