diff --git a/_cache_service_worker.js b/_cache_service_worker.js
index b16a7a4..ee9cddf 100644
--- a/_cache_service_worker.js
+++ b/_cache_service_worker.js
@@ -6,7 +6,7 @@
*/
var PRECACHE_ID = 'rom-patcher-js';
-var PRECACHE_VERSION = 'v31';
+var PRECACHE_VERSION = 'v32';
var PRECACHE_URLS = [
'/RomPatcher.js/', '/RomPatcher.js/index.html',
'/RomPatcher.js/manifest.json',
diff --git a/index.html b/index.html
index f0f1021..001603f 100644
--- a/index.html
+++ b/index.html
@@ -131,6 +131,11 @@
+
diff --git a/rom-patcher-js/RomPatcher.js b/rom-patcher-js/RomPatcher.js
index e9e0151..8d2c1ad 100644
--- a/rom-patcher-js/RomPatcher.js
+++ b/rom-patcher-js/RomPatcher.js
@@ -230,7 +230,7 @@ const RomPatcher = (function () {
return patchedRom;
},
- createPatch: function (originalFile, modifiedFile, format) {
+ createPatch: function (originalFile, modifiedFile, format, metadata) {
if (!(originalFile instanceof BinFile))
throw new Error('Original ROM file is not an instance of BinFile');
else if (!(modifiedFile instanceof BinFile))
@@ -253,9 +253,10 @@ const RomPatcher = (function () {
} else if (format === 'aps') {
patch = APS.buildFromRoms(originalFile, modifiedFile);
} else if (format === 'rup') {
- patch = RUP.buildFromRoms(originalFile, modifiedFile);
+ if(metadata)
+ patch = RUP.buildFromRoms(originalFile, modifiedFile, metadata && metadata.Description? metadata.Description : null);
} else if (format === 'ebp') {
- patch = IPS.buildFromRoms(originalFile, modifiedFile, true);
+ patch = IPS.buildFromRoms(originalFile, modifiedFile, metadata);
} else {
throw new Error('Invalid patch format');
}
diff --git a/rom-patcher-js/RomPatcher.webapp.js b/rom-patcher-js/RomPatcher.webapp.js
index 0a33be2..f5aa3fa 100644
--- a/rom-patcher-js/RomPatcher.webapp.js
+++ b/rom-patcher-js/RomPatcher.webapp.js
@@ -7,7 +7,7 @@
*
* MIT License
*
-* Copyright (c) 2016-2024 Marc Robledo
+* Copyright (c) 2016-2025 Marc Robledo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -1559,6 +1559,23 @@ const PatchBuilderWeb = (function (romPatcherWeb) {
}
};
+ const _getMetadataFields = function (patchFormat) {
+ if (patchFormat === 'rup') {
+ return ['Description'];
+ } else if (patchFormat === 'ebp') {
+ return ['Author', 'Title', 'Description'];
+ }
+ return [];
+ };
+ const _buildMetadataObject = function (patchFormat) {
+ return _getMetadataFields(patchFormat).reduce((metadata, field) => {
+ const input = document.getElementById('patch-builder-input-metadata-' + field.toLowerCase().replace(/\s+/g, '-'));
+ if (input && input.value.trim())
+ metadata[field] = input.value.trim();
+ return metadata;
+ }, {});
+ };
+
var webWorkerCreate;
var initialized = false;
@@ -1644,18 +1661,35 @@ const PatchBuilderWeb = (function (romPatcherWeb) {
_setToastError(_('Patch creation is not compatible with zipped ROMs'), 'warning');
});
});
+ document.getElementById('patch-builder-select-patch-type').addEventListener('change', function () {
+ if (!document.getElementById('patch-builder-container-metadata-inputs'))
+ return;
+
+ document.getElementById('patch-builder-container-metadata-inputs').innerHTML = '';
+
+ _getMetadataFields(this.value).forEach(function (field) {
+ const input = document.createElement('input');
+ input.id = 'patch-builder-input-metadata-' + field.toLowerCase().replace(/\s+/g, '-');
+ input.className = 'patch-builder-input-metadata';
+ input.type = 'text';
+ input.placeholder = _(field);
+ document.getElementById('patch-builder-container-metadata-inputs').appendChild(input);
+ });
+ });
document.getElementById('patch-builder-button-create').addEventListener('click', function () {
+ const patchFormat=document.getElementById('patch-builder-select-patch-type').value;
_setElementsStatus(false);
_setCreateButtonSpinner(true);
webWorkerCreate.postMessage(
{
originalRomU8Array: originalRom._u8array,
modifiedRomU8Array: modifiedRom._u8array,
- format: document.getElementById('patch-builder-select-patch-type').value
+ format: patchFormat,
+ metadata: _buildMetadataObject(patchFormat)
}, [
- originalRom._u8array.buffer,
- modifiedRom._u8array.buffer
- ]
+ originalRom._u8array.buffer,
+ modifiedRom._u8array.buffer
+ ]
);
});
@@ -1780,6 +1814,9 @@ const ROM_PATCHER_LOCALE = {
'Modified ROM:': 'ROM modificada:',
'Patch type:': 'Tipo de parche:',
'Creating patch...': 'Creando parche...',
+ 'Author': 'Autor',
+ 'Title': 'Título',
+ 'Description': 'Descripción',
'Source ROM checksum mismatch': 'Checksum de ROM original no válida',
'Target ROM checksum mismatch': 'Checksum de ROM creada no válida',
@@ -1914,6 +1951,9 @@ const ROM_PATCHER_LOCALE = {
'Modified ROM:': 'ROM modificada:',
'Patch type:': 'Tipus de pedaç:',
'Creating patch...': 'Creant pedaç...',
+ 'Author': 'Autor',
+ 'Title': 'Títol',
+ 'Description': 'Descripció',
'Source ROM checksum mismatch': 'Checksum de ROM original no vàlida',
'Target ROM checksum mismatch': 'Checksum de ROM creada no vàlida',
diff --git a/rom-patcher-js/RomPatcher.webworker.create.js b/rom-patcher-js/RomPatcher.webworker.create.js
index 9fde1d7..dff6d9e 100644
--- a/rom-patcher-js/RomPatcher.webworker.create.js
+++ b/rom-patcher-js/RomPatcher.webworker.create.js
@@ -17,8 +17,9 @@ self.onmessage = event => { // listen for messages from the main thread
const originalFile=new BinFile(event.data.originalRomU8Array);
const modifiedFile=new BinFile(event.data.modifiedRomU8Array);
const format=event.data.format;
+ const metadata=event.data.metadata;
- const patch=RomPatcher.createPatch(originalFile, modifiedFile, format);
+ const patch=RomPatcher.createPatch(originalFile, modifiedFile, format, metadata);
const patchFile=patch.export('my_patch');
self.postMessage(
diff --git a/rom-patcher-js/modules/RomPatcher.format.rup.js b/rom-patcher-js/modules/RomPatcher.format.rup.js
index 322c841..9cf70dc 100644
--- a/rom-patcher-js/modules/RomPatcher.format.rup.js
+++ b/rom-patcher-js/modules/RomPatcher.format.rup.js
@@ -1,4 +1,4 @@
-/* RUP module for Rom Patcher JS v20241102 - Marc Robledo 2018-2024 - http://www.marcrobledo.com/license */
+/* RUP module for Rom Patcher JS v20250430 - Marc Robledo 2018-2025 - http://www.marcrobledo.com/license */
/* File format specification: http://www.romhacking.net/documents/288/ */
const RUP_MAGIC='NINJA2';
@@ -332,11 +332,13 @@ RUP.prototype.export=function(fileName){
-RUP.buildFromRoms=function(original, modified){
+RUP.buildFromRoms=function(original, modified, description){
var patch=new RUP();
var today=new Date();
patch.date=(today.getYear()+1900)+RUP.padZeroes(today.getMonth()+1, 1)+RUP.padZeroes(today.getDate(), 1);
+ if(description)
+ patch.description=description;
var file={
fileName:'',
diff --git a/webapp/style.css b/webapp/style.css
index 7a4f01c..cf5380c 100644
--- a/webapp/style.css
+++ b/webapp/style.css
@@ -193,7 +193,7 @@ hr{border:none;border-top:1px dotted #bbb;margin:15px 0}
/* forms */
-input[type=file], input[type=checkbox], select{
+input[type=file], input[type=text], input[type=checkbox], select{
box-sizing:border-box;
max-width:100%;
font-family:inherit;
@@ -204,20 +204,24 @@ input[type=file], input[type=checkbox], select{
background-color:#edefef;
}
input[type=file]:focus:not(:disabled),
+input[type=text]:focus:not(:disabled),
select:focus:not(:disabled),
input[type=checkbox].styled:focus:not(:disabled){
box-shadow: var(--rom-patcher-color-primary-focus) 0 0 0 2px;
}
#rom-patcher-container input[type=file],
#rom-patcher-container select,
-#patch-builder-container input[type=file]
+#patch-builder-container input[type=file],
+#patch-builder-container input[type=text]
{width:100%}
-input[type=file]{padding:6px 10px}
+input[type=file],input[type=text]{padding:6px 10px}
+#patch-builder-container-metadata-inputs input[type=text]:not(:last-child){margin-bottom:8px;}
input[type=file].no-file-selector-button::file-selector-button{display:none}
select{
padding:6px 18px 6px 10px;
-webkit-appearance:none;
-moz-appearance:none;
+ appearance:none;
text-overflow:'';
background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMTJweCIgeT0iMHB4IiB3aWR0aD0iMjRweCIgaGVpZ2h0PSIzcHgiIHZpZXdCb3g9IjAgMCA2IDMiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDYgMyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBvbHlnb24gcG9pbnRzPSI1Ljk5MiwwIDIuOTkyLDMgLTAuMDA4LDAgIi8+PC9zdmc+");
@@ -225,7 +229,8 @@ select{
background-repeat:no-repeat;
}
select::-ms-expand{display:none}
-input[type=file]:hover:not(:disabled),select:hover:not(:disabled){cursor:pointer;background-color:#dee1e1}
+input[type=file]:hover:not(:disabled),input[type=text]:hover:not(:disabled),select:hover:not(:disabled){background-color:#dee1e1}
+input[type=file]:hover:not(:disabled),select:hover:not(:disabled){cursor:pointer;}
input[type=file]:disabled,select:disabled{color:var(--rom-patcher-color-muted)}
/* select:focus > option{background-color:#fff} */