Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# OneLoader
High performance mod loader for OMORI

![](https://img.colon-three.com/onebanner-2.png)

<sup>OneLoader mascot art by [bajamaid](https://twitter.com/bajamaid)</sup>

## Credits/Licensing
This project contains in part or in full the following projects:

Expand Down
2 changes: 1 addition & 1 deletion www/modloader/_oneloader_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
};

Expand Down
48 changes: 47 additions & 1 deletion www/modloader/early_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = [];

Expand All @@ -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));

Expand Down Expand Up @@ -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.");
Expand All @@ -1080,6 +1125,7 @@
}
}

$modLoader.pluginOrderingRules = pluginOrderingRules;
$modLoader.pluginLocks = pluginLocks;

window._logLine("Installing VFS handler (1/2) [Chrome DevTools mode]");
Expand Down
51 changes: 51 additions & 0 deletions www/modloader/oneloader-loading-gui2.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 = `
<div class="header-container" style="display: flex; justify-content: center; position: fixed; top: 0; left: 0; right: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif">
<span class="e" style="font-size: 2em; font-weight: 900; margin: 0; position: relative;"><span style="color: #0089D7">One</span>Loader</span>
Expand Down Expand Up @@ -46,6 +59,43 @@ window.$oneLoaderGui = new (class OneLoaderGui {
<div style="position: fixed; bottom: 0; left: 0; color: #666; ">
v<span data-ol="vernum">???</span>
</div>
<style>
#__oneloader_catgirl__ {
animation: ${pickedOption[0]} ${pickedOption[1]} infinite;
transform-origin: center;
}
@keyframes __oneloader_catgirl__1_ {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
@keyframes __oneloader_catgirl__2_ {
0% {
transform: scale(1);
}
50% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes __oneloader_catgirl__3_ { /* Credit: @kodicraft */
0% {
transform: translate(0px, 0px) scale(1.0, 1.0);
}
25% {
transform: translate(0px, -128px) scale(1.0, 1.0);
}
50% {
transform: translate(0px, 0px) scale(1.0, 1.0);
}
}
</style>
<img id="__oneloader_catgirl__" width="${catgirlScale * 32}" height="${catgirlScale * 32}" src="${hot_catgirl}" style="position: fixed; bottom: 0; right: 0; image-rendering: pixelated; z-index: 0;">
`;
this.vernum = this.container.querySelector("[data-ol=vernum]");
this.percentage = this.container.querySelector("[data-ol=percentage]");
Expand All @@ -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;
}

Expand Down
79 changes: 72 additions & 7 deletions www/modloader/patchplugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion www/mods/oneloader/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 14 additions & 2 deletions www/mods/oneloader/oneloader-fix-videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down