RomPatcher.js icon indicating copy to clipboard operation
RomPatcher.js copied to clipboard

Make Portable

Open jet082 opened this issue 3 years ago • 14 comments

Currently, this patcher is heavily tied to the interface that you see publicly in the demo. So much so that it even calls specific DOM elements by id in the main patcher js.

It would be nice to separate the logic of the actual patcher itself from the GUI elements so that it can be easily imported and used on other websites and not, very specifically, the one provided.

Additionally, the patcher seems to require a very specific structure, with a js folder at root, etc. Quite a few of the internal scripts (particularly as it relates to creating workers in RomPatcher.js for example) rely on this specific structure. It would be nice if imports were a lot less absolute and more relative, so that we might be able to import these in arbitrary folders irrespective of position relative to the root directory (so, for example, static/Rompatcher/js/RomPatcher.js should work rather than just /js/RomPatcher.js).

jet082 avatar Sep 19 '20 18:09 jet082

I'm aware the code structure is a mess haha

But the whole patch creation/application logic is outside RomPatcher.js, inside the js/formats folder there is a single .js for every patch format. MarcFile.js and crc.js would be the only additional files needed to make them work.

Any way, my idea was to create a package that could be just downloaded from here and reuploaded somewhere else, so any translation team could easily offer a simple drag and drop solution in their websites for their own patches, without having to mess with paths nor code. They would only need to specify a PREDEFINED_PATCHES object in index.html and customize the css file. The only paths that need be changed are the service workers references. I had to use absolute paths in order to make it work correctly in GitHub Pages.

But I'm open to hear any ideas in order to improve it. As I said, I'd like it to become a copy-and-paste solution for everyone, so any suggestions are welcome.

marcrobledo avatar Sep 22 '20 10:09 marcrobledo

Seconding this request. I'm working on a Python batch patcher (something that takes a folder of patches as input and applies them to the appropriate roms in your rom directory) and it would be great if I could simply call applyPatch() from RomPatcher.js instead of having to hunt down multiple CLI-compatible patchers.

Mode8fx avatar Mar 28 '21 21:03 Mode8fx

@GateGuy, you can easily call Marc's patcher from Python using selenium. I actually created a CLI interface with just 162 lines of code. Please let me know if you're interested and I'll publish it.

PS. Anyway, I completely agree that ideally the patcher should already be divided into front/back ends so you can completely forget the web interface when not manually using the patcher.

HeuristicPerson avatar Mar 28 '21 23:03 HeuristicPerson

@HeuristicPerson If you don't mind, that would be great. I wrote a (messy) downloader about a year ago that uses selenium with the Romhacking.net version of Marc's patcher, but I want to make something that works offline and doesn't rely on a specific browser being installed (mine used a Chrome driver).

Mode8fx avatar Mar 29 '21 03:03 Mode8fx

Published here, @GateGuy: https://github.com/HeuristicPerson/RomPatcherCLI Please note I haven't used it for a long time so I could not work at all. Let me know any problem you may have and I'll take a look.

Regards

HeuristicPerson avatar Apr 02 '21 21:04 HeuristicPerson

@HeuristicPerson Thanks! I was able to combine my old implementation with how you initialized the driver to automate a local copy of Marc's patcher through both Chrome and Firefox. https://github.com/GateGuy/BatchRomPatcher

Mode8fx avatar Apr 04 '21 22:04 Mode8fx

having a node-based CLI interface not requiring a browser engine would be nice...

eadmaster avatar May 03 '21 16:05 eadmaster

having a node-based CLI interface not requiring a browser engine would be nice...

actually it could be an npm package which is then consumed by CLI, WebApp, Electron App etc.

theMK2k avatar Sep 15 '22 17:09 theMK2k

#61 should address this as well

unsupo avatar Jun 30 '23 18:06 unsupo