Skip to content

Commit 907fd44

Browse files
author
Nathan Bolton
committed
Move plugins
1 parent c5e0d56 commit 907fd44

File tree

4 files changed

+570
-0
lines changed

4 files changed

+570
-0
lines changed

js/plugins/Community_Basic.js

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
/*:
2+
* @plugindesc Basic plugin for manipulating important parameters.
3+
* @author RM CoreScript team
4+
*
5+
* @help
6+
* Basic plugin for manipulating important parameters.
7+
* There is no plugin command.
8+
*
9+
* Caching images improves performance but increases memory allocation.
10+
* On mobile devices, a lot of memory allocation causes the browser to crash.
11+
* Therefore, the upper limit of memory allocation is set with cacheLimit.
12+
*
13+
* If you want to regain high performance, just increase cacheLimit.
14+
* There is no need to revert to 1.4.
15+
*
16+
* @param cacheLimit
17+
* @type number
18+
* @desc The upper limit of images' cached size (MPixel)
19+
* @default 10
20+
*
21+
* @param screenWidth
22+
* @type number
23+
* @desc The resolution of screen width
24+
* @default 816
25+
*
26+
* @param screenHeight
27+
* @type number
28+
* @desc The resolution of screen height
29+
* @default 624
30+
*
31+
* @param changeWindowWidthTo
32+
* @type number
33+
* @desc If set, change window width to this value
34+
*
35+
* @param changeWindowHeightTo
36+
* @type number
37+
* @desc If set, change window height to this value
38+
*
39+
* @param renderingMode
40+
* @type select
41+
* @option canvas
42+
* @option webgl
43+
* @option auto
44+
* @desc The rendering mode (canvas/webgl/auto)
45+
* @default auto
46+
*
47+
* @param alwaysDash
48+
* @type boolean
49+
* @desc The initial value whether the player always dashes (on/off)
50+
* @on ON
51+
* @off OFF
52+
* @default false
53+
*
54+
* @param textSpeed
55+
* @type number
56+
* @desc The text speed on "Show Text". The larger this parameter is, the slower text speed. (0: show all texts at once)
57+
* @default 1
58+
*
59+
* @param autoSaveFileId
60+
* @type number
61+
* @desc The file number to auto save when "Transfer Player" (0: off)
62+
* @default 0
63+
*
64+
* @param errorMessage
65+
* @type string
66+
* @desc The message when error occurred
67+
* @default Error occurred. Please ask to the creator of this game.
68+
*
69+
* @param showErrorDetail
70+
* @type boolean
71+
* @desc Show where the error is caused and stack trace when error
72+
* @default true
73+
*
74+
* @param enableProgressBar
75+
* @type boolean
76+
* @desc Show progress bar when it takes a long time to load resources
77+
* @default true
78+
*
79+
* @param maxRenderingFps
80+
* @type number
81+
* @desc The maximum value of rendering frame per seconds (0: unlimited)
82+
* @default 0
83+
*/
84+
85+
/*:ja
86+
* @plugindesc 基本的なパラメーターを設定するプラグインです。
87+
* @author RM CoreScript team
88+
*
89+
* @help
90+
* 基本的なパラメーターを設定するプラグインです。
91+
* このプラグインにはプラグインコマンドはありません。
92+
*
93+
* 画像をキャッシュするとパフォーマンスは向上しますが、その分メモリ確保も増大します。
94+
* モバイルデバイスでは、たくさんのメモリ確保はブラウザをクラッシュさせます。
95+
* そこで、メモリ確保の上限を「画像キャッシュ上限値」で設定しています。
96+
*
97+
* もし高いパフォーマンスを取り戻したければ、ただ画像キャッシュ上限値を増加させればよいです。
98+
* 1.4に戻す必要はありません。
99+
*
100+
* @param cacheLimit
101+
* @type number
102+
* @text 画像キャッシュ上限値
103+
* @desc 画像のメモリへのキャッシュの上限値 (MPix)
104+
* @default 10
105+
*
106+
* @param screenWidth
107+
* @type number
108+
* @text ゲーム画面の幅
109+
* @default 816
110+
*
111+
* @param screenHeight
112+
* @type number
113+
* @text ゲーム画面の高さ
114+
* @default 624
115+
*
116+
* @param changeWindowWidthTo
117+
* @type number
118+
* @text ウィンドウの幅
119+
* @desc 値が設定されなかった場合、ゲーム画面の幅と同じ
120+
*
121+
* @param changeWindowHeightTo
122+
* @type number
123+
* @text ウィンドウの高さ
124+
* @desc 値が設定されなかった場合、ゲーム画面の高さと同じ
125+
*
126+
* @param renderingMode
127+
* @type select
128+
* @option canvas
129+
* @option webgl
130+
* @option auto
131+
* @text レンダリングモード
132+
* @default auto
133+
*
134+
* @param alwaysDash
135+
* @type boolean
136+
* @text 「常時ダッシュ」の初期値
137+
* @on ON
138+
* @off OFF
139+
* @default false
140+
*
141+
* @param textSpeed
142+
* @type number
143+
* @text 「文章の表示」のスピード
144+
* @desc 数字が大きいほど文章の表示スピードが遅くなります (0を指定した場合は一度に全文を表示します)
145+
* @default 1
146+
*
147+
* @param autoSaveFileId
148+
* @type number
149+
* @text オートセーブ番号
150+
* @desc 「場所移動」の際に指定したファイル番号にオートセーブします(0を指定した場合はオートセーブしません)
151+
* @default 0
152+
*
153+
* @param errorMessage
154+
* @type string
155+
* @text エラーメッセージ
156+
* @desc エラー時にプレイヤーに向けて表示するメッセージです
157+
* @default エラーが発生しました。ゲームの作者にご連絡ください。
158+
*
159+
* @param showErrorDetail
160+
* @type boolean
161+
* @text エラー詳細表示
162+
* @desc ONにすると、エラー時にエラーを発生させたイベントの情報とスタックトレースを表示します
163+
* @default true
164+
*
165+
* @param enableProgressBar
166+
* @type boolean
167+
* @text ロード進捗バー有効化
168+
* @desc ONにすると、読み込みに時間がかかっている時にロード進捗バーを表示します
169+
* @default true
170+
*
171+
* @param maxRenderingFps
172+
* @type number
173+
* @text 描画FPS上限値
174+
* @desc 描画FPSの上限値を設定します (0を指定した場合は制限なし)
175+
* @default 0
176+
*/
177+
178+
(function() {
179+
'use strict';
180+
function isNumber(str) {
181+
return !!str && !isNaN(str);
182+
}
183+
184+
function toNumber(str, def) {
185+
return isNumber(str) ? +str : def;
186+
}
187+
188+
var parameters = PluginManager.parameters('Community_Basic');
189+
var cacheLimit = toNumber(parameters['cacheLimit'], 10);
190+
var screenWidth = toNumber(parameters['screenWidth'], 816);
191+
var screenHeight = toNumber(parameters['screenHeight'], 624);
192+
var renderingMode = parameters['renderingMode'].toLowerCase();
193+
var alwaysDash = (parameters['alwaysDash'] === 'true') ||(parameters['alwaysDash'] === 'on');
194+
var textSpeed = toNumber(parameters['textSpeed'], 1);
195+
var windowWidthTo = toNumber(parameters['changeWindowWidthTo'], 0);
196+
var windowHeightTo = toNumber(parameters['changeWindowHeightTo'], 0);
197+
var maxRenderingFps = toNumber(parameters['maxRenderingFps'], 0);
198+
var autoSaveFileId = toNumber(parameters['autoSaveFileId'], 0);
199+
var errorMessage = parameters['errorMessage'];
200+
var showErrorDetail = parameters['showErrorDetail'] === 'true';
201+
var enableProgressBar = parameters['enableProgressBar'] === 'true';
202+
203+
var windowWidth;
204+
var windowHeight;
205+
206+
if(windowWidthTo){
207+
windowWidth = windowWidthTo;
208+
}else if(screenWidth !== SceneManager._screenWidth){
209+
windowWidth = screenWidth;
210+
}
211+
212+
if(windowHeightTo){
213+
windowHeight = windowHeightTo;
214+
}else if(screenHeight !== SceneManager._screenHeight){
215+
windowHeight = screenHeight;
216+
}
217+
218+
219+
ImageCache.limit = cacheLimit * 1000 * 1000;
220+
SceneManager._screenWidth = screenWidth;
221+
SceneManager._screenHeight = screenHeight;
222+
SceneManager._boxWidth = screenWidth;
223+
SceneManager._boxHeight = screenHeight;
224+
225+
SceneManager.preferableRendererType = function() {
226+
if (Utils.isOptionValid('canvas')) {
227+
return 'canvas';
228+
} else if (Utils.isOptionValid('webgl')) {
229+
return 'webgl';
230+
} else if (renderingMode === 'canvas') {
231+
return 'canvas';
232+
} else if (renderingMode === 'webgl') {
233+
return 'webgl';
234+
} else {
235+
return 'auto';
236+
}
237+
};
238+
239+
var _ConfigManager_applyData = ConfigManager.applyData;
240+
ConfigManager.applyData = function(config) {
241+
_ConfigManager_applyData.apply(this, arguments);
242+
if (config['alwaysDash'] === undefined) {
243+
this.alwaysDash = alwaysDash;
244+
}
245+
};
246+
247+
var _Window_Message_clearFlags = Window_Message.prototype.clearFlags;
248+
Window_Message.prototype.clearFlags = function(textState) {
249+
_Window_Message_clearFlags.apply(this, arguments);
250+
this._textSpeed = textSpeed - 1;
251+
};
252+
253+
var _SceneManager_initNwjs = SceneManager.initNwjs;
254+
SceneManager.initNwjs = function() {
255+
_SceneManager_initNwjs.apply(this, arguments);
256+
257+
if (Utils.isNwjs() && windowWidth && windowHeight) {
258+
var dw = windowWidth - window.innerWidth;
259+
var dh = windowHeight - window.innerHeight;
260+
window.moveBy(-dw / 2, -dh / 2);
261+
window.resizeBy(dw, dh);
262+
}
263+
};
264+
265+
if (maxRenderingFps) {
266+
var currentTime = Date.now();
267+
var deltaTime = 1000 / maxRenderingFps;
268+
var accumulator = 0;
269+
var _SceneManager_renderScene = SceneManager.renderScene;
270+
SceneManager.renderScene = function() {
271+
var newTime = Date.now();
272+
accumulator += newTime - currentTime;
273+
currentTime = newTime;
274+
if (accumulator >= deltaTime) {
275+
accumulator -= deltaTime;
276+
_SceneManager_renderScene.apply(this, arguments);
277+
}
278+
};
279+
}
280+
281+
DataManager.setAutoSaveFileId(autoSaveFileId);
282+
Graphics.setErrorMessage(errorMessage);
283+
Graphics.setShowErrorDetail(showErrorDetail);
284+
Graphics.setProgressEnabled(enableProgressBar);
285+
})();

js/plugins/Debug_FailLoading.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*:
2+
* @plugindesc Fail to load images, audio, movies and map data.
3+
* @author RM CoreScript team
4+
*
5+
* @param failImage
6+
* @desc Probability of image loading failure (0-1)
7+
* @default 0.5
8+
*
9+
* @param failAudio
10+
* @desc Probability of audio loading failure (0-1)
11+
* @default 0.5
12+
*
13+
* @param failMovie
14+
* @desc Probability of movie loading failure (0-1)
15+
* @default 0.5
16+
*
17+
* @param failMapData
18+
* @desc Probability of map data loading failure (0-1)
19+
* @default 0.5
20+
*/
21+
22+
/*:ja
23+
* @plugindesc 画像や音声、動画やマップデータの読み込みに失敗します。
24+
* @author RM CoreScript team
25+
*
26+
* @param failImage
27+
* @desc 画像の読み込みに失敗する確率 (0-1)
28+
* @default 0.5
29+
*
30+
* @param failAudio
31+
* @desc 音声の読み込みに失敗する確率 (0-1)
32+
* @default 0.5
33+
*
34+
* @param failMovie
35+
* @desc 動画の読み込みに失敗する確率 (0-1)
36+
* @default 0.5
37+
*
38+
* @param failMapData
39+
* @desc マップデータ読み込みに失敗する確率 (0-1)
40+
* @default 0.5
41+
*/
42+
43+
(function() {
44+
function toNumber(str, def) {
45+
return isNaN(str) ? def : +(str || def);
46+
}
47+
48+
var parameters = PluginManager.parameters('Debug_FailLoading');
49+
var failImage = toNumber(parameters['failImage'], 0.5);
50+
var failAudio = toNumber(parameters['failAudio'], 0.5);
51+
var failMovie = toNumber(parameters['failMovie'], 0.5);
52+
var failMapData = toNumber(parameters['failMapData'], 0.5);
53+
54+
var _Bitmap_onLoad = Bitmap.prototype._onLoad;
55+
Bitmap.prototype._onLoad = function() {
56+
if (Math.random() < failImage) {
57+
this._errorListener();
58+
} else {
59+
_Bitmap_onLoad.apply(this, arguments);
60+
}
61+
};
62+
63+
WebAudio.prototype._load = function(url) {
64+
if (WebAudio._context) {
65+
var xhr = new XMLHttpRequest();
66+
if(Decrypter.hasEncryptedAudio) url = Decrypter.extToEncryptExt(url);
67+
xhr.open('GET', url);
68+
xhr.responseType = 'arraybuffer';
69+
xhr.onload = function() {
70+
if (Math.random() < failAudio) {
71+
xhr.onerror();
72+
} else if (xhr.status < 400) {
73+
this._onXhrLoad(xhr);
74+
}
75+
}.bind(this);
76+
xhr.onerror = this._loader;
77+
xhr.send();
78+
}
79+
};
80+
81+
var _Graphics_onVideoLoad = Graphics._onVideoLoad;
82+
Graphics._onVideoLoad = function() {
83+
if (Math.random() < failMovie) {
84+
this._video.onerror();
85+
} else {
86+
_Graphics_onVideoLoad.apply(this, arguments);
87+
}
88+
};
89+
90+
DataManager.loadDataFile = function(name, src) {
91+
var xhr = new XMLHttpRequest();
92+
var url = 'data/' + src;
93+
xhr.open('GET', url);
94+
xhr.overrideMimeType('application/json');
95+
xhr.onload = function() {
96+
if (name === '$dataMap' && Math.random() < failMapData) {
97+
xhr.onerror();
98+
} else if (xhr.status < 400) {
99+
window[name] = JSON.parse(xhr.responseText);
100+
DataManager.onLoad(window[name]);
101+
}
102+
};
103+
xhr.onerror = this._mapLoader || function() {
104+
DataManager._errorUrl = DataManager._errorUrl || url;
105+
};
106+
window[name] = null;
107+
xhr.send();
108+
};
109+
})();

0 commit comments

Comments
 (0)