Jubeat prop support, multi-DLL support, remove globals, dynamic UI creation, fix SDVX score

This commit is contained in:
William Toohey
2017-02-08 16:22:19 +10:00
parent 6fb581f44b
commit 2c5a91dcea
6 changed files with 154 additions and 86 deletions
+1 -7
View File
@@ -10,7 +10,7 @@
<script type="text/javascript" src="js/dllpatcher.js"></script> <script type="text/javascript" src="js/dllpatcher.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener("load", function() { window.addEventListener("load", function() {
DllPatcher("bm2dx", [ new DllPatcher("bm2dx", [
{ {
name : "Timer Freeze", name : "Timer Freeze",
shortname : "freeze", shortname : "freeze",
@@ -78,11 +78,5 @@
</head> </head>
<body> <body>
<h1>IIDX Copula DLL Modder</h1> <h1>IIDX Copula DLL Modder</h1>
<input class="fileInput" type="file" name="files[]" id="file" />
<label for="file"><strong>Choose a file</strong> or drag and drop.</label>
<div id="success"></div>
<div id="error"></div>
<div id="patches"></div>
<button id="save" onclick="saveDll();">Save DLL</button>
</body> </body>
</html> </html>
+15 -3
View File
@@ -2,18 +2,30 @@
display: none display: none
} }
#error { .fileLabel {
cursor: pointer;
}
.error {
color: red; color: red;
} }
#success { .success {
color: DarkGreen; color: DarkGreen;
} }
#success.hidden { .success.hidden {
display: none; display: none;
} }
.patchContainer {
background-color: white;
}
.dragover {
background-color: rgb(200,200,200);
}
body { body {
margin: 40px auto; margin: 40px auto;
max-width: 650px; max-width: 650px;
+95 -59
View File
@@ -1,12 +1,10 @@
dllFile = null; (function(window, document) {
mods = null; "use strict";
filename = null;
errorLog = "";
// Each unique kind of patch should have createUI, validatePatch, applyPatch, // Each unique kind of patch should have createUI, validatePatch, applyPatch,
// updateUI // updateUI
StandardPatch = function(options) { var StandardPatch = function(options) {
this.name = options.name; this.name = options.name;
this.shortname = options.shortname; this.shortname = options.shortname;
this.patches = options.patches; this.patches = options.patches;
@@ -37,7 +35,7 @@ StandardPatch.prototype.validatePatch = function(file) {
}; };
StandardPatch.prototype.applyPatch = function(file) { StandardPatch.prototype.applyPatch = function(file) {
id = this.shortname; var id = this.shortname;
var enabled = document.getElementById(id).checked; var enabled = document.getElementById(id).checked;
this.replaceAll(file, enabled); this.replaceAll(file, enabled);
return enabled ? this.shortname : ""; return enabled ? this.shortname : "";
@@ -77,7 +75,7 @@ StandardPatch.prototype.checkPatchBytes = function(file) {
// updateUI // updateUI
// The DEFAULT state is always the 1st element in the patches array // The DEFAULT state is always the 1st element in the patches array
UnionPatch = function(options) { var UnionPatch = function(options) {
this.name = options.name; this.name = options.name;
this.shortname = options.shortname; this.shortname = options.shortname;
this.offset = options.offset; this.offset = options.offset;
@@ -133,84 +131,135 @@ UnionPatch.prototype.getSelected = function() {
return null; return null;
} }
DllPatcher = function(fname, args) { var DllPatcher = function(fname, args) {
mods = []; this.mods = [];
for(var i = 0; i < args.length; i++) { for(var i = 0; i < args.length; i++) {
mod = args[i]; var mod = args[i];
if(mod.type) { if(mod.type) {
if(mod.type == "union") { if(mod.type == "union") {
mods.push(new UnionPatch(mod)); this.mods.push(new UnionPatch(mod));
} }
} else { // standard patch } else { // standard patch
mods.push(new StandardPatch(mod)); this.mods.push(new StandardPatch(mod));
} }
} }
filename = fname; this.filename = fname;
loadPatchUI(); this.createUI();
this.loadPatchUI();
}; };
loadFile = function(file) { DllPatcher.prototype.createUI = function() {
var self = this;
var container = $("<div>", {"class": "patchContainer"});
container.html('<h3>' + this.filename + '.dll</h3>');
container.on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
e.preventDefault();
e.stopPropagation();
})
.on('drop', function(e) {
var files = e.originalEvent.dataTransfer.files;
if(files && files.length > 0)
self.loadFile(files[0]);
})
.on('dragover dragenter', function() {
container.addClass('dragover');
})
.on('dragleave dragend drop', function() {
container.removeClass('dragover');
});
this.fileInput = $("<input>",
{"class": "fileInput",
"id" : this.filename + '-file',
"type" : 'file'});
var label = $("<label>", {"class": "fileLabel", "for": this.filename + '-file'});
label.html('<strong>Choose a file</strong> or drag and drop.');
this.fileInput.on('change', function(e) {
if(this.files && this.files.length > 0)
self.loadFile(this.files[0]);
});
this.successDiv = $("<div>", {"class": "success"});
this.errorDiv = $("<div>", {"class": "error"});
this.patchDiv = $("<div>", {"class": "patches"});
var saveButton = $("<button>");
saveButton.text('Save DLL');
saveButton.on('click', this.saveDll.bind(this));
container.append(this.fileInput);
container.append(label);
container.append(this.successDiv);
container.append(this.errorDiv);
container.append(this.patchDiv);
container.append(saveButton);
$('body').append(container);
}
DllPatcher.prototype.loadFile = function(file) {
var reader = new FileReader(); var reader = new FileReader();
var self = this;
reader.onload = function(e) { reader.onload = function(e) {
dllFile = new Uint8Array(e.target.result); self.dllFile = new Uint8Array(e.target.result);
if(validatePatches()) { if(self.validatePatches()) {
$("#success").removeClass("hidden"); self.successDiv.removeClass("hidden");
$("#success").html("DLL loaded successfully!"); self.successDiv.html("DLL loaded successfully!");
} else { } else {
$("#success").addClass("hidden"); self.successDiv.addClass("hidden");
} }
$('#error').html(errorLog); self.errorDiv.html(self.errorLog);
updatePatchUI(); self.updatePatchUI();
}; };
reader.readAsArrayBuffer(file); reader.readAsArrayBuffer(file);
}; };
saveDll = function() { DllPatcher.prototype.saveDll = function() {
if(!dllFile || !mods || !filename) if(!this.dllFile || !this.mods || !this.filename)
return; return;
var fname = filename; var fname = this.filename;
for(var i = 0; i < mods.length; i++) { for(var i = 0; i < this.mods.length; i++) {
var enabledStr = mods[i].applyPatch(dllFile); var enabledStr = this.mods[i].applyPatch(this.dllFile);
if(enabledStr) { if(enabledStr) {
fname += '-' + enabledStr; fname += '-' + enabledStr;
} }
} }
fname += '.dll'; fname += '.dll';
var blob = new Blob([dllFile], {type: "application/octet-stream"}); var blob = new Blob([this.dllFile], {type: "application/octet-stream"});
saveAs(blob, fname); saveAs(blob, fname);
} }
loadPatchUI = function() { DllPatcher.prototype.loadPatchUI = function() {
var patchDiv = $('#patches'); for(var i = 0; i < this.mods.length; i++) {
for(var i = 0; i < mods.length; i++) { this.mods[i].createUI(this.patchDiv);
mods[i].createUI(patchDiv);
} }
} }
updatePatchUI = function() { DllPatcher.prototype.updatePatchUI = function() {
for(var i = 0; i < mods.length; i++) { for(var i = 0; i < this.mods.length; i++) {
mods[i].updateUI(dllFile); this.mods[i].updateUI(this.dllFile);
} }
} }
validatePatches = function() { DllPatcher.prototype.validatePatches = function() {
errorLog = ""; this.errorLog = "";
success = true; var success = true;
for(var i = 0; i < mods.length; i++) { for(var i = 0; i < this.mods.length; i++) {
var error = mods[i].validatePatch(dllFile); var error = this.mods[i].validatePatch(this.dllFile);
if(error) { if(error) {
errorLog += error + "<br/>"; this.errorLog += error + "<br/>";
success = false; success = false;
} }
} }
return success; return success;
} }
bytesMatch = function(buffer, offset, bytes) { var bytesMatch = function(buffer, offset, bytes) {
for(var i = 0; i < bytes.length; i++) { for(var i = 0; i < bytes.length; i++) {
if(buffer[offset+i] != bytes[i]) if(buffer[offset+i] != bytes[i])
return false; return false;
@@ -218,13 +267,13 @@ bytesMatch = function(buffer, offset, bytes) {
return true; return true;
}; };
replace = function(buffer, offset, bytes) { var replace = function(buffer, offset, bytes) {
for(var i = 0; i < bytes.length; i++) { for(var i = 0; i < bytes.length; i++) {
buffer[offset+i] = bytes[i]; buffer[offset+i] = bytes[i];
} }
} }
whichBytesMatch = function(buffer, offset, bytesArray) { var whichBytesMatch = function(buffer, offset, bytesArray) {
for(var i = 0; i < bytesArray.length; i++) { for(var i = 0; i < bytesArray.length; i++) {
if(bytesMatch(buffer, offset, bytesArray[i])) if(bytesMatch(buffer, offset, bytesArray[i]))
return i; return i;
@@ -232,19 +281,6 @@ whichBytesMatch = function(buffer, offset, bytesArray) {
return -1; return -1;
} }
$( document ).ready(function() { window.DllPatcher = DllPatcher;
$('html').on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
e.preventDefault();
e.stopPropagation();
})
.on('drop', function(e) {
var files = e.originalEvent.dataTransfer.files;
if(files && files.length > 0)
loadFile(files[0]);
});
$('#file').on('change', function(e) { })(window, document);
if(this.files && this.files.length > 0)
loadFile(this.files[0]);
});
});
+33
View File
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jubeat prop DLL Modder</title>
<link rel="stylesheet" href="css/style.css">
<!-- don't hate -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="js/FileSaver.min.js"></script>
<script type="text/javascript" src="js/dllpatcher.js"></script>
<script type="text/javascript">
window.addEventListener("load", function() {
new DllPatcher("jubeat", [
{
name : "Disable tutorial",
shortname : "notut",
patches : [{offset : 0x81F79, off: [0x0F, 0x85, 0xC7], on : [0xE9, 0xC6, 0x01]}]
},
]);
new DllPatcher("music_db", [
{
name : "Unlock all songs",
shortname : "unlock",
patches : [{offset : 0x266D, off: [0x02], on : [0x1f]}]
},
]);
});
</script>
</head>
<body>
<h1>jubeat prop DLL Modder</h1>
</body>
</html>
+1 -7
View File
@@ -10,7 +10,7 @@
<script type="text/javascript" src="js/dllpatcher.js"></script> <script type="text/javascript" src="js/dllpatcher.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener("load", function() { window.addEventListener("load", function() {
DllPatcher("popn22", [ new DllPatcher("popn23", [
{ {
name : "Song/EX unlock", name : "Song/EX unlock",
shortname : "unlock", shortname : "unlock",
@@ -111,11 +111,5 @@
</head> </head>
<body> <body>
<h1>pop'n music éclale DLL Modder</h1> <h1>pop'n music éclale DLL Modder</h1>
<input class="fileInput" type="file" name="files[]" id="file" />
<label for="file"><strong>Choose a file</strong> or drag and drop.</label>
<div id="success"></div>
<div id="error"></div>
<div id="patches"></div>
<button id="save" onclick="saveDll();">Save DLL</button>
</body> </body>
</html> </html>
+7 -8
View File
@@ -10,7 +10,8 @@
<script type="text/javascript" src="js/dllpatcher.js"></script> <script type="text/javascript" src="js/dllpatcher.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener("load", function() { window.addEventListener("load", function() {
DllPatcher("soundvoltex", [ // all patches made by DJH unless specified otherwise
new DllPatcher("soundvoltex", [
{ {
name : "All difficulties unlocked", name : "All difficulties unlocked",
shortname : "unlocked", shortname : "unlocked",
@@ -22,6 +23,7 @@
patches : [{offset : 0x1554F7, off: [0x32, 0xC0], on : [0xB0, 0x01]}] patches : [{offset : 0x1554F7, off: [0x32, 0xC0], on : [0xB0, 0x01]}]
}, },
{ {
// Created by mon
name : "No \"Safe\" banner on jackets", name : "No \"Safe\" banner on jackets",
shortname : "nobanner", shortname : "nobanner",
patches : [{offset : 0x28F4AC, off: [0x73], on : [0x00]}] patches : [{offset : 0x28F4AC, off: [0x73], on : [0x00]}]
@@ -38,6 +40,7 @@
patches : [{offset : 0x170092, off : [0x00], on : [0x01]}] patches : [{offset : 0x170092, off : [0x00], on : [0x01]}]
}, },
{ {
// Ported from the S1 PFree by mon
name : "PFree (Unlimited plays)", name : "PFree (Unlimited plays)",
shortname : "pfree", shortname : "pfree",
patches : [{offset : 0x196BDF, off : [0x00], on : [0x02]}, patches : [{offset : 0x196BDF, off : [0x00], on : [0x02]},
@@ -64,6 +67,7 @@
0xD1, 0x00, 0x89, 0x85, 0x50], 0xD1, 0x00, 0x89, 0x85, 0x50],
}, },
{ {
// Created by mon
name : "Subtractive (NEAR+ERROR subtract score from 10,000,000)", name : "Subtractive (NEAR+ERROR subtract score from 10,000,000)",
shortname : "subtract", shortname : "subtract",
patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x5C, 0x6A, 0x00, 0x99, 0x6A, patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x5C, 0x6A, 0x00, 0x99, 0x6A,
@@ -72,9 +76,10 @@
0x21, 0x00, 0x8B, 0xFA, 0x8B, 0x56, 0x18, 0x8B, 0xC8, 0x8B, 0x82, 0x80, 0x2C, 0x00, 0x00, 0x01, 0x21, 0x00, 0x8B, 0xFA, 0x8B, 0x56, 0x18, 0x8B, 0xC8, 0x8B, 0x82, 0x80, 0x2C, 0x00, 0x00, 0x01,
0xC0, 0x99, 0x52, 0x50, 0x57, 0x51, 0xE8, 0xAC, 0x36, 0x21, 0x00, 0xB9, 0x80, 0x96, 0x98, 0x00, 0xC0, 0x99, 0x52, 0x50, 0x57, 0x51, 0xE8, 0xAC, 0x36, 0x21, 0x00, 0xB9, 0x80, 0x96, 0x98, 0x00,
0xBF, 0x00, 0x00, 0x00, 0x00, 0x29, 0xC1, 0x19, 0xD7, 0x8B, 0xDF, 0x8B, 0xF9, 0x59, 0x5A, 0x8B, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x29, 0xC1, 0x19, 0xD7, 0x8B, 0xDF, 0x8B, 0xF9, 0x59, 0x5A, 0x8B,
0x45, 0x08, 0x8B, 0x40, 0x04] 0x45, 0x08, 0x8B, 0x40, 0x04, 0xEB, 0x57]
}, },
{ {
// Created by mon
name : "Average (Osu style % display)", name : "Average (Osu style % display)",
shortname : "avg", shortname : "avg",
patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x54, 0x99, 0x6A, 0x00, 0x6A, patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x54, 0x99, 0x6A, 0x00, 0x6A,
@@ -94,11 +99,5 @@
</head> </head>
<body> <body>
<h1>SDVX III Season 2 DLL Modder</h1> <h1>SDVX III Season 2 DLL Modder</h1>
<input class="fileInput" type="file" name="files[]" id="file" />
<label for="file"><strong>Choose a file</strong> or drag and drop.</label>
<div id="success"></div>
<div id="error"></div>
<div id="patches"></div>
<button id="save" onclick="saveDll();">Save DLL</button>
</body> </body>
</html> </html>