');
for(var i = 0; i < this.patches.length; i++) {
var patch = this.patches[i];
var id = this.shortname + '-' + patch.shortname;
var label = patch.name;
var patchDiv = $('
', {'class' : 'patch'});
patchDiv.append('
');
if(patch.tooltip) {
patchDiv.append('
' + patch.tooltip + '
');
}
container.append(patchDiv);
}
parent.append(container);
};
UnionPatch.prototype.updateUI = function(file) {
for(var i = 0; i < this.patches.length; i++) {
if(bytesMatch(file, this.offset, this.patches[i].patch)) {
document.getElementById(this.shortname + '-' + this.patches[i].shortname).checked = true;
return;
}
}
// Default fallback
document.getElementById(this.shortname + '-' + this.patches[0].shortname).checked = true;
};
UnionPatch.prototype.validatePatch = function(file) {
for(var i = 0; i < this.patches.length; i++) {
if(bytesMatch(file, this.offset, this.patches[i].patch)) {
console.log(this.name, "has", this.patches[i].name, "enabled");
return;
}
}
return '"' + this.name + '" doesn\'t have a valid patch! Have you got the right dll?';
};
UnionPatch.prototype.applyPatch = function(file) {
var patch = this.getSelected();
var name = this.shortname + patch.shortname;
replace(file, this.offset, patch.patch);
return patch.shortname == "default" ? "" : name;
};
UnionPatch.prototype.getSelected = function() {
for(var i = 0; i < this.patches.length; i++) {
if(document.getElementById(this.shortname + '-' + this.patches[i].shortname).checked) {
return this.patches[i];
}
}
return null;
}
var DllPatcher = function(fname, args) {
this.mods = [];
for(var i = 0; i < args.length; i++) {
var mod = args[i];
if(mod.type) {
if(mod.type == "union") {
this.mods.push(new UnionPatch(mod));
}
} else { // standard patch
this.mods.push(new StandardPatch(mod));
}
}
this.filename = fname;
this.createUI();
this.loadPatchUI();
};
DllPatcher.prototype.createUI = function() {
var self = this;
var container = $("
", {"class": "patchContainer"});
container.html('
' + this.filename + '.dll
');
$('html').on('dragover dragenter', function() {
container.addClass('dragover');
return true;
})
.on('dragleave dragend drop', function() {
container.removeClass('dragover');
return true;
})
.on('dragover dragenter dragleave dragend drop', function(e) {
e.preventDefault();
});
container.on('drop', function(e) {
var files = e.originalEvent.dataTransfer.files;
if(files && files.length > 0)
self.loadFile(files[0]);
})
this.fileInput = $("
",
{"class": "fileInput",
"id" : this.filename + '-file',
"type" : 'file'});
var label = $("