1
0
Fork 0
mirror of https://github.com/marcrobledo/RomPatcher.js.git synced 2025-06-27 16:25:54 +00:00

new features explained

Marc Robledo 2024-08-14 20:17:45 +02:00
parent 6b3eb8f688
commit 7aee9c413f

@ -20,7 +20,8 @@ Take a look at [`index_template.html`](https://github.com/marcrobledo/RomPatcher
window.addEventListener('load', function(){
const myPatcherSettings={
language: 'en',
allowDropFiles: false /* if true, it adds drag and drop support,*/
requireValidation: false, /* if true, user won't be able to apply patch if the provided ROM is not valid*/
allowDropFiles: false /* if true, it adds basic drag and drop support */
};
RomPatcherWeb.initialize(myPatcherSettings, 'my_patch.ips');
});
@ -64,6 +65,31 @@ RomPatcherWeb.initialize(myPatcherSettings, {
]
});
```
You can define some patches as optional. They won't appear in the select dropdown but as checkboxes. User will be able to choose and combine several patches.
```js
RomPatcherWeb.initialize(myPatcherSettings, {
file: 'my_patches.zip', //zip containing patches
patches: [ //information about patches inside the zip
{
file: 'my_main_patch.ips', //required
name: 'My game improvement hack (Base)',
},
{
file: 'my_optional_patch_1.ips',
name: 'Alternate colors',
description: 'Check this to change main characters\' colors',
optional: true
},
{
file: 'my_optional_patch_2.ips',
name: 'Hard mode',
description: 'Check this to alter game\'s difficulty',
optional: true
},
/* ... */
]
});
```
 
@ -73,22 +99,25 @@ If you want to go further, you can run your own code via events:
const myPatcherSettings={
language: 'en',
oninitialize: function (romFile) {
/* triggered when Rom Patcher JS has been initialized */
},
onloadrom: function (romFile) {
/* this event is triggered when user provides a ROM and before validating it */
/* triggered when user provides a ROM and before validating it */
/* can be used to: */
/* - modify it before validation (e.g. add/remove/fix header, change endianness...) */
/* - to switch to another patch file in the dropdown selector */
},
onvalidaterom: function (romFile, isRomValid) {
/* this event is triggered after ROM is validated */
/* triggered after ROM is validated */
/* can be used to show a custom error message if provided ROM is not valid */
},
onloadpatch: function (patchFile, embededPatchInformation) {
/* this event is triggered when user selects a patch from the dropdown */
/* triggered when user selects a patch from the dropdown */
/* can be used to toggle HTML elements in your site depending on the selected patch */
},
onpatch: function (romFile) {
/* this event is triggered a ROM is patched */
/* triggered a ROM is patched */
/* can be used to modify it before the patched ROM file is saved */
}
};
@ -143,7 +172,7 @@ If your zip file contains several patches for different ROMs, you can make Rom P
```js
const SML2_CHECKSUM_WORLD = 0xd5ec24e4;
const SML2_CHECKSUM_JAPAN = 0xa715daf5;
const SML2_CHECKSUMS_INVALID = [0xe6f886e5, 0x635a9112, 0xbf733e10, 0x29e0911a];
const SML2_CHECKSUMS_INVALID = [0xe6f886e5, 0x635a9112, 0xbf733e10, 0x29e0911a]; /* incompatible SML2 revisions */
RomPatcher.initialize(
{
@ -241,3 +270,16 @@ By detecting which patch the user selected, you can do cool things in your site
}
);
```
 
## Example: Change embeded patches
You can reset the embeded patches easily, so you could offer a Rom Patcher JS compatible with different games.
```js
RomPatcher.setEmbededPatches({
file: 'other_patches.zip',
name: 'Other patches',
patches: [
/* ... */
]
});
```