代码拉取完成,页面将自动刷新
同步操作将从 9梦菌/RMMZ脚本框架中文注释 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//=============================================================================
// main.js v1.0.2
//=============================================================================
// 脚本地址
const scriptUrls = [
"js/libs/pixi.js",
"js/libs/pako.min.js",
"js/libs/localforage.min.js",
"js/libs/effekseer.min.js",
"js/libs/vorbisdecoder.js",
"js/rmmz_core.js",
"js/rmmz_managers.js",
"js/rmmz_objects.js",
"js/rmmz_scenes.js",
"js/rmmz_sprites.js",
"js/rmmz_windows.js",
"js/plugins.js"
];
// Effekseer的 wasm 文件地址
const effekseerWasmUrl = "js/libs/effekseer.wasm";
class Main {
// 构造函数
constructor() {
this.xhrSucceeded = false;
this.loadCount = 0;
this.error = null;
}
// 运行
run() {
this.showLoadingSpinner();
this.testXhr();
this.loadMainScripts();
}
// 显示加载的旋转框
showLoadingSpinner() {
const loadingSpinner = document.createElement("div");
const loadingSpinnerImage = document.createElement("div");
loadingSpinner.id = "loadingSpinner";
loadingSpinnerImage.id = "loadingSpinnerImage";
loadingSpinner.appendChild(loadingSpinnerImage);
document.body.appendChild(loadingSpinner);
}
// 消除加载的旋转框
eraseLoadingSpinner() {
const loadingSpinner = document.getElementById("loadingSpinner");
if (loadingSpinner) {
document.body.removeChild(loadingSpinner);
}
}
// 测试 XMLHttpRequest
testXhr() {
const xhr = new XMLHttpRequest();
xhr.open("GET", document.currentScript.src);
xhr.onload = () => (this.xhrSucceeded = true);
xhr.send();
}
// 加载主脚本
loadMainScripts() {
for (const url of scriptUrls) {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.async = false;
script.defer = true;
script.onload = this.onScriptLoad.bind(this);
script.onerror = this.onScriptError.bind(this);
script._url = url;
document.body.appendChild(script);
}
this.numScripts = scriptUrls.length;
window.addEventListener("load", this.onWindowLoad.bind(this));
window.addEventListener("error", this.onWindowError.bind(this));
}
// 当脚本加载
onScriptLoad() {
if (++this.loadCount === this.numScripts) {
PluginManager.setup($plugins);
}
}
// 当脚本错误
onScriptError(e) {
this.printError("Failed to load", e.target._url);
}
// 打印错误
printError(name, message) {
this.eraseLoadingSpinner();
if (!document.getElementById("errorPrinter")) {
const errorPrinter = document.createElement("div");
errorPrinter.id = "errorPrinter";
errorPrinter.innerHTML = this.makeErrorHtml(name, message);
document.body.appendChild(errorPrinter);
}
}
// 制作错误页面
makeErrorHtml(name, message) {
const nameDiv = document.createElement("div");
const messageDiv = document.createElement("div");
nameDiv.id = "errorName";
messageDiv.id = "errorMessage";
nameDiv.innerHTML = name;
messageDiv.innerHTML = message;
return nameDiv.outerHTML + messageDiv.outerHTML;
}
//当窗口加载
onWindowLoad() {
if (!this.xhrSucceeded) {
const message = "Your browser does not allow to read local files.";
this.printError("Error", message);
} else if (this.isPathRandomized()) {
const message = "Please move the Game.app to a different folder.";
this.printError("Error", message);
} else if (this.error) {
this.printError(this.error.name, this.error.message);
} else {
this.initEffekseerRuntime();
}
}
//当窗口错误
onWindowError(event) {
if (!this.error) {
this.error = event.error;
}
}
// 是否路径随机化
isPathRandomized() {
// [备注] 当网守路径随机化生效时,我们无法正确保存游戏。
// [Note] We cannot save the game properly when Gatekeeper Path
// Randomization is in effect.
return (
Utils.isNwjs() &&
process.mainModule.filename.startsWith("/private/var")
);
}
// 初始化 Effeckseer 运行时库
initEffekseerRuntime() {
const onLoad = this.onEffekseerLoad.bind(this);
const onError = this.onEffekseerError.bind(this);
effekseer.initRuntime(effekseerWasmUrl, onLoad, onError);
}
// 当 Effectseer 加载
onEffekseerLoad() {
this.eraseLoadingSpinner();
SceneManager.run(Scene_Boot);
}
// 当 Effectseer 错误
onEffekseerError() {
this.printError("Failed to load", effekseerWasmUrl);
}
}
const main = new Main();
main.run();
//-----------------------------------------------------------------------------
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。