mirror of
https://github.com/mon/BemaniPatcher.git
synced 2026-08-01 14:10:40 -07:00
Allow force-loading incomplete matches in multi patchers
This commit is contained in:
+14
-2
@@ -168,7 +168,7 @@ h1 a {
|
|||||||
text-decoration: inherit;
|
text-decoration: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button, .fileLabel > strong {
|
||||||
transition-duration: 0.2s;
|
transition-duration: 0.2s;
|
||||||
transition-timing-function: cubic-bezier(0.25, 0.5, 0.5, 1);
|
transition-timing-function: cubic-bezier(0.25, 0.5, 0.5, 1);
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -196,11 +196,23 @@ button:disabled {
|
|||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover:enabled {
|
button:hover:enabled, .fileLabel > strong:hover {
|
||||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.25), 0px 0px 4px rgba(0, 0, 0, 0.125);
|
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.25), 0px 0px 4px rgba(0, 0, 0, 0.125);
|
||||||
background-color: #5dbe3c;
|
background-color: #5dbe3c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.matchPercent {
|
||||||
|
font-size: 15px;
|
||||||
|
font-style: italic;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
li > button {
|
||||||
|
height: 24px;
|
||||||
|
padding: 0 7px;
|
||||||
|
line-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.patches {
|
.patches {
|
||||||
margin: 1em auto;
|
margin: 1em auto;
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-10
@@ -182,8 +182,18 @@ DllPatcherContainer.prototype.createUI = function () {
|
|||||||
|
|
||||||
var supportedDlls = $("<ul>");
|
var supportedDlls = $("<ul>");
|
||||||
var versions = this.getSupportedVersions();
|
var versions = this.getSupportedVersions();
|
||||||
|
this.forceLoadTexts = [];
|
||||||
|
this.forceLoadButtons = [];
|
||||||
for (var i = 0; i < versions.length; i++) {
|
for (var i = 0; i < versions.length; i++) {
|
||||||
$("<li>").text(versions[i]).appendTo(supportedDlls);
|
var listItem = $("<li>");
|
||||||
|
$('<span>').text(versions[i]).appendTo(listItem);
|
||||||
|
var matchPercent = $('<span>').addClass('matchPercent');
|
||||||
|
this.forceLoadTexts.push(matchPercent);
|
||||||
|
matchPercent.appendTo(listItem);
|
||||||
|
var forceButton = $('<button>').text('Force load?').hide();
|
||||||
|
this.forceLoadButtons.push(forceButton);
|
||||||
|
forceButton.appendTo(listItem);
|
||||||
|
listItem.appendTo(supportedDlls);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("html").on("dragover dragenter", function () {
|
$("html").on("dragover dragenter", function () {
|
||||||
@@ -233,6 +243,18 @@ DllPatcherContainer.prototype.createUI = function () {
|
|||||||
$("body").append(container);
|
$("body").append(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DRY
|
||||||
|
var loadPatch = function(_this, self, patcher) {
|
||||||
|
patcher.loadPatchUI();
|
||||||
|
patcher.updatePatchUI();
|
||||||
|
patcher.container.show();
|
||||||
|
var successStr = patcher.filename + ".dll"
|
||||||
|
if ($.type(_this.description) === "string") {
|
||||||
|
successStr += "(" + patcher.description + ")";
|
||||||
|
}
|
||||||
|
self.successDiv.html(successStr + " loaded successfully!");
|
||||||
|
}
|
||||||
|
|
||||||
DllPatcherContainer.prototype.loadFile = function (file) {
|
DllPatcherContainer.prototype.loadFile = function (file) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -252,19 +274,33 @@ DllPatcherContainer.prototype.loadFile = function (file) {
|
|||||||
patcher.loadBuffer(e.target.result);
|
patcher.loadBuffer(e.target.result);
|
||||||
if (patcher.validatePatches()) {
|
if (patcher.validatePatches()) {
|
||||||
found = true;
|
found = true;
|
||||||
patcher.loadPatchUI();
|
loadPatch(this, self, patcher);
|
||||||
patcher.updatePatchUI();
|
|
||||||
patcher.container.show();
|
|
||||||
var successStr = patcher.filename + ".dll"
|
|
||||||
if ($.type(this.description) === "string") {
|
|
||||||
successStr += "(" + patcher.description + ")";
|
|
||||||
}
|
|
||||||
self.successDiv.html(successStr + " loaded successfully!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
self.errorDiv.html("No patches found matching the given DLL.");
|
// let the user force a match
|
||||||
|
for (var i = 0; i < self.patchers.length; i++) {
|
||||||
|
var patcher = self.patchers[i];
|
||||||
|
|
||||||
|
var valid = patcher.validPatches;
|
||||||
|
var percent = (valid / patcher.totalPatches * 100).toFixed(1);
|
||||||
|
|
||||||
|
self.forceLoadTexts[i].text(' ' + valid + ' of ' + patcher.totalPatches + ' patches matched (' + percent + '%) ');
|
||||||
|
self.forceLoadButtons[i].show();
|
||||||
|
self.forceLoadButtons[i].off('click');
|
||||||
|
self.forceLoadButtons[i].click(function(i) {
|
||||||
|
// reset old text
|
||||||
|
for(var j = 0; j < self.patchers.length; j++) {
|
||||||
|
self.forceLoadButtons[j].hide();
|
||||||
|
self.forceLoadTexts[j].text('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
loadPatch(this, self, self.patchers[i]);
|
||||||
|
}.bind(this, i));
|
||||||
|
}
|
||||||
|
self.errorDiv.html("No patch set was a 100% match.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -416,11 +452,15 @@ DllPatcher.prototype.updatePatchUI = function() {
|
|||||||
DllPatcher.prototype.validatePatches = function() {
|
DllPatcher.prototype.validatePatches = function() {
|
||||||
this.errorLog = "";
|
this.errorLog = "";
|
||||||
var success = true;
|
var success = true;
|
||||||
|
this.validPatches = 0;
|
||||||
|
this.totalPatches = this.mods.length;
|
||||||
for(var i = 0; i < this.mods.length; i++) {
|
for(var i = 0; i < this.mods.length; i++) {
|
||||||
var error = this.mods[i].validatePatch(this.dllFile);
|
var error = this.mods[i].validatePatch(this.dllFile);
|
||||||
if(error) {
|
if(error) {
|
||||||
this.errorLog += error + "<br/>";
|
this.errorLog += error + "<br/>";
|
||||||
success = false;
|
success = false;
|
||||||
|
} else {
|
||||||
|
this.validPatches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
Reference in New Issue
Block a user