diff --git a/README.md b/README.md index e4d6d14..83c06c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # OneLoader High performance mod loader for OMORI +![](https://img.colon-three.com/onebanner-2.png) + +OneLoader mascot art by [bajamaid](https://twitter.com/bajamaid) + ## Credits/Licensing This project contains in part or in full the following projects: diff --git a/www/modloader/_oneloader_configuration.js b/www/modloader/_oneloader_configuration.js index 25e9ecf..7fd7275 100644 --- a/www/modloader/_oneloader_configuration.js +++ b/www/modloader/_oneloader_configuration.js @@ -3,7 +3,7 @@ if (window.nw.App.argv[0] !== "test") { const MAX_MANIFEST_VERSION = 1; const ID_BLACKLIST = ["gomori"]; const EXTENSION_RULES = { - "png": { "encrypt": "rpgmaker", "target_extension": "rpgmvp" }, + "png": { "encrypt": "rpgmaker", "target_extension": "rpgmvp", "raw": ["img/system/window.png", "img/system/loading.png"] }, "ogg": { "encrypt": "rpgmaker", "target_extension": "rpgmvo" } }; diff --git a/www/modloader/early_loader.js b/www/modloader/early_loader.js index 722236d..a6f0fad 100644 --- a/www/modloader/early_loader.js +++ b/www/modloader/early_loader.js @@ -39,7 +39,9 @@ "pre_plugin_injection": [], "pre_window_onload": [], "when_discovered_2": [], - "when_discovered_3": [] + "when_discovered_3": [], + "exclusion_processor": [], + "exclusion_processor2": [] }, async $runRequire(data, p) { native_fs.writeFileSync(path.join(base, "temp_ONELOADER.js"), data); @@ -296,6 +298,11 @@ } get extensionRule() { + if (EXTENSION_RULES[this.srcExtension] && EXTENSION_RULES[this.srcExtension].raw && EXTENSION_RULES[this.srcExtension].raw.includes( + (this.srcPath + "/" + this.srcFile).toLowerCase() + )) { + return null; + } return EXTENSION_RULES[this.srcExtension] || null; } } @@ -490,6 +497,15 @@ } } + if (this.json._flags && this.json._flags.includes("randomize_plugin_name")) { + if (this.json.plugins_ordered) { + throw new Error("Randomized plugin names or plugins_ordered. Choose one."); + } + } + if (!this.json.plugins_ordered) { + this.json.plugins_ordered = {}; + } + await this.processAsyncExecV1(); if (this.json.files.assets) { await this.processAssetsV1(this.json.files.assets); @@ -970,6 +986,11 @@ window._logLine("Exclusions: " + JSON.stringify(Array.from(exclusions.entries()))); window._logLine("Rquirements: " + JSON.stringify(Array.from(requirements.entries()))); + await $modLoader.$runScripts("exclusion_processor", { + exclusions, + requirements + }); + let exclusionFailures = []; let requirementFailures = []; @@ -988,6 +1009,13 @@ console.log(exclusionFailures, requirementFailures); console.log(exclusions, requirements); + await $modLoader.$runScripts("exclusion_processor2", { + exclusions, + requirements, + exclusionFailures, + requirementFailures + }); + window._logLine("Exclusion failures: " + JSON.stringify(exclusionFailures)); window._logLine("Requirement failures: " + JSON.stringify(requirementFailures)); @@ -1061,17 +1089,34 @@ window._logLine("Looking for plugin conflicts..."); let pluginLocks = new Set(); + let pluginOrderingRules = new Map(); for (let modEntry of $modLoader.knownMods.values()) { for (let pluginName of modEntry.pluginsDelta) { + alert(`The mod ${modEntry.json.id} is using an UNSUPPORTED, DEPRECATED FEATURE. (Plugin Deltas)\nPlease contact the author of ${modEntry.json.id} (Name: ${modEntry.json.name}) in order to get this resolved.`); let fileName = pluginName.match(/[^\/\\]*$/)[0].toLowerCase(); fileName = fileName.match(/(.*)\.[a-z]*$/)[1]; pluginLocks.add(fileName); + pluginOrderingRules.set(fileName, { + culprit: modEntry, + rule: {"at":-1} + }); } } for (let modEntry of $modLoader.knownMods.values()) { for (let pluginName of modEntry.plugins) { let fileName = pluginName.match(/[^\/\\]*$/)[0].toLowerCase(); fileName = fileName.match(/(.*)\.[a-z]*$/)[1]; + if (modEntry.json.plugins_ordered[fileName]) { + pluginOrderingRules.set(fileName, { + culprit: modEntry, + rule: modEntry.json.plugins_ordered[fileName] + }); + } else { + pluginOrderingRules.set(fileName, { + culprit: modEntry, + rule: {"at":-1} + }); + } if (pluginLocks.has(fileName)) { alert("Plugin conflict: " + fileName + " was already replaced when " + modEntry.json.id + " tried to replace it."); throw new Error("Plugin conflicts can't be auto-resolved."); @@ -1080,6 +1125,7 @@ } } + $modLoader.pluginOrderingRules = pluginOrderingRules; $modLoader.pluginLocks = pluginLocks; window._logLine("Installing VFS handler (1/2) [Chrome DevTools mode]"); diff --git a/www/modloader/oneloader-loading-gui2.js b/www/modloader/oneloader-loading-gui2.js index f13aa28..952d7c6 100755 --- a/www/modloader/oneloader-loading-gui2.js +++ b/www/modloader/oneloader-loading-gui2.js @@ -1,3 +1,6 @@ +// Image credit: Bajamaid +const hot_catgirl = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAZlBMVEX///8yNz5AQlGVqMEAAAD1+f/rv66/cV4cHSSetM/99+52WUcqLD7B0uCut8KAk8f/3NZwcHD++/X029LM4PXNwdY+VXCSs9x9nMKszOxqdd0hLFQdITCZsP/q+P/D1N1vfpI8SXYiyUzWAAAAAXRSTlMAQObYZgAAANtJREFUeNp0jIUWBCEIAA10e6+78P9/8rAuYTaMmYf6ILxXlnALdRWCazTkr2KACTnARwJRCIqPieDvxd/5AslkHlLwRg5QCqJHAPAY/w8MgQlg3qzAw/54gnC7BS5YrQFgKwUW5uUSetgdD3CJ/i+wAND3Pf0vZzYgmoi1XIDR6nGcxtFiODMDmsZ7bZxzxqL/913X9T0FxhkKmn/vXOeHIQda/dNN0zBYq7XThOKKhSVv4oQ4ggOrF4voK1r2ciEG70K/NedjUlESjffxVSKtMfFVMm37HAiRBgAiGRaKlPJ1XQAAAABJRU5ErkJggg==`; + window.$oneLoaderGui = new (class OneLoaderGui { constructor() { this.easterEgg = { @@ -9,6 +12,16 @@ window.$oneLoaderGui = new (class OneLoaderGui { this.container.style = "font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #222; color: white; width: 100vw; height: 100vh; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;"; requestAnimationFrame(() => { this.tryMount(); }); + let catgirlScale = Math.floor(Math.floor(Math.min(window.innerWidth, window.innerHeight) / 3) / 32); + + let catgirlAnimationOptions = [ + ["__oneloader_catgirl__1_", "2s linear"], + ["__oneloader_catgirl__2_", "2s cubic-bezier(0.68, 1.1, 0.59, 0.79)"], + ["__oneloader_catgirl__3_", "1s ease"] + ]; + + let pickedOption = catgirlAnimationOptions[Math.floor(Math.random() * catgirlAnimationOptions.length)]; + this.container.innerHTML = `
OneLoader @@ -46,6 +59,43 @@ window.$oneLoaderGui = new (class OneLoaderGui {
v???
+ + `; this.vernum = this.container.querySelector("[data-ol=vernum]"); this.percentage = this.container.querySelector("[data-ol=percentage]"); @@ -58,6 +108,7 @@ window.$oneLoaderGui = new (class OneLoaderGui { if ((new Date()).getDate() === this.easterEgg.day && (new Date()).getMonth() === this.easterEgg.month) { v = v + " || " + this.easterEgg.text; } + v = v + " || OneLoader catgirl by bajamaid" this.vernum.innerText = v; } diff --git a/www/modloader/patchplugins.js b/www/modloader/patchplugins.js index 78908bf..c55a034 100644 --- a/www/modloader/patchplugins.js +++ b/www/modloader/patchplugins.js @@ -10,18 +10,83 @@ window._logLine("Patching $plugins"); let game_supplied_plugins = $plugins.map( a=>a.name.toLowerCase()); + + let injections = Array.from(new Array($plugins.length + 1), () => ([])); + console.log(injections); + + for (let [name, {rule}] of $modLoader.pluginOrderingRules.entries()) { + if (rule.after) { + let point = $plugins.indexOf($plugins.find(a => a.name.toLowerCase() === rule.after.toLowerCase())); + console.log(point); + rule.at = point + 1; + } + + if (rule.at < 0) continue; + if (rule.at >= injections.length) rule.at = (injections.length - 1); + + injections[rule.at].push({ + name, + status: true, + description: "Modded plugin", + parameters: {}, + _w: rule.weight || 0 + }); + } + + for (let i = (injections.length - 1); i >= 0; i--) { + if (injections[i].length === 0) continue; + + injections[i].sort((a,b)=>(b._w - a._w)); + $plugins.splice(i, 0, ...injections[i]); + } + + + + let postPluginsNeg = []; + let postPlugins = []; + let postPluginsPos = []; + for (let name of Array.from($modLoader.pluginLocks)) { - if (!game_supplied_plugins.includes(name)) { - $plugins.push({ - name, - status: true, - description: "Modded plugin", - parameters: {} - }); + let orderingRule = $modLoader.pluginOrderingRules.get(name); + + let wght = orderingRule.rule.weight || 0; + + if (!game_supplied_plugins.includes(name) && orderingRule.rule.at === -1) { + if (wght < 0) { + postPluginsNeg.push({ + name, + status: true, + description: "Modded plugin", + parameters: {}, + _w: wght + }); + } + if (wght > 0) { + postPluginsPos.push({ + name, + status: true, + description: "Modded plugin", + parameters: {}, + _w: wght + }); + } + if (wght === 0) { + postPlugins.push({ + name, + status: true, + description: "Modded plugin", + parameters: {} + }); + } window._logLine("[PLUGIN_LOADER] Injected " + name); } } + postPluginsNeg = postPluginsNeg.sort((a, b) => (b._w - a._w)) + postPluginsPos = postPluginsPos.sort((a, b) => (b._w - a._w)) + + $plugins.push(...postPluginsPos, ...postPlugins, ...postPluginsNeg); + $modLoader.knownMods.forEach(mod => { if (mod.json.plugin_parameters) { for (let plugin in mod.json.plugin_parameters) { diff --git a/www/mods/oneloader/mod.json b/www/mods/oneloader/mod.json index 8e4deec..ba6d8d1 100644 --- a/www/mods/oneloader/mod.json +++ b/www/mods/oneloader/mod.json @@ -4,7 +4,7 @@ "name":"OneLoader assistant", "description": "A helper mod for OneLoader", "manifestVersion": 1, - "version": "1.4.1", + "version": "1.5", "_flags":[ "prevent_disable", "randomize_plugin_name" diff --git a/www/mods/oneloader/oneloader-fix-videos.js b/www/mods/oneloader/oneloader-fix-videos.js index 366482b..30aee67 100644 --- a/www/mods/oneloader/oneloader-fix-videos.js +++ b/www/mods/oneloader/oneloader-fix-videos.js @@ -9,10 +9,11 @@ if ($modLoader.$nwMajor < 45) { let objectURL = URL.createObjectURL(b); let vidObj = old.call(this, {src: objectURL, mime: "video/" + videoSrc.split(".")[videoSrc.split(".").length - 1]}, scaleMode, crossorigin, autoPlay); let a = setInterval(function( ){ - if (vidObj.source.readyState === 4 && (vidObj.source.buffered.end(0) >= vidObj.source.duration) && vidObj.source.ended) { - window._logLine("YANFLY VIDEO Revoking object url"); + if (!vidObj || !vidObj.source) { + window._logLine("YANFLY VIDEO some bullshit happened"); URL.revokeObjectURL(objectURL); clearInterval(a); + return; } }, 300); return vidObj; @@ -21,6 +22,17 @@ if ($modLoader.$nwMajor < 45) { } }; + let oldDestroy = PIXI.VideoBaseTexture.destroy; + PIXI.VideoBaseTexture.destroy = function() { + let cs = this.source.src; + console.log(cs); + if (cs.startsWith("blob:")) { + window._logLine("YANFLY VIDEO Revoking object url"); + URL.revokeObjectURL(cs); + } + oldDestroy.call(this, ...arguments); + } + let old_stock_playvideo = Graphics._playVideo; let old_onvideoend = Graphics._onVideoEnd; let ourl = Symbol("ObjectURL");