dllFile = null; mods = null; filename = null; errorLog = ""; // Each unique kind of patch should have createUI, validatePatch, applyPatch, // updateUI StandardPatch = function(options) { this.name = options.name; this.shortname = options.shortname; this.patches = options.patches; }; StandardPatch.prototype.createUI = function(parent) { var id = this.shortname; var label = this.name; parent.append('
'); }; StandardPatch.prototype.updateUI = function(file) { var id = this.shortname; var elem = document.getElementById(id); elem.checked = this.checkPatchBytes(file) == "on"; }; StandardPatch.prototype.validatePatch = function(file) { var status = this.checkPatchBytes(file); if(status == "on") { console.log('"' + this.name + '"', "is enabled!"); } else if(status == "off") { console.log('"' + this.name + '"', "is disabled!"); } else { success = false; return '"' + this.name + '" is neither on nor off! Have you got the right dll?'; } }; StandardPatch.prototype.applyPatch = function(file) { id = this.shortname; var enabled = document.getElementById(id).checked; this.replaceAll(file, enabled); return enabled ? this.shortname : ""; }; StandardPatch.prototype.replaceAll = function(file, featureOn) { for(var i = 0; i < this.patches.length; i++) { replace(file, this.patches[i].offset, featureOn? this.patches[i].on : this.patches[i].off); } } StandardPatch.prototype.checkPatchBytes = function(file) { var patchStatus = ""; for(var i = 0; i < this.patches.length; i++) { var patch = this.patches[i]; if(bytesMatch(file, patch.offset, patch.off)) { if(patchStatus == "") { patchStatus = "off"; } else if(patchStatus != "off"){ return "on/off mismatch within patch"; } } else if(bytesMatch(file, patch.offset, patch.on)) { if(patchStatus == "") { patchStatus = "on"; } else if(patchStatus != "on"){ return "on/off mismatch within patch"; } } else { return "patch neither on nor off"; } } return patchStatus; } // Each unique kind of patch should have createUI, validatePatch, applyPatch, // updateUI // The DEFAULT state is always the 1st element in the patches array UnionPatch = function(options) { this.name = options.name; this.shortname = options.shortname; this.offset = options.offset; this.patches = options.patches; }; UnionPatch.prototype.createUI = function(parent) { var container = $("