dyreschlock / pocket-utils

Collection of Java programs and Shell scripts to update and manage the content on my Analogue Pocket
3 stars 0 forks source link

Refactor Programs with better, more consistent workflows #10

Closed dyreschlock closed 1 year ago

dyreschlock commented 1 year ago

The overall flow of programs should be refactored now that we can easily make command line calls from Java. Update_Cores.sh should be the only command line script left.

CreatePocketEntries

This should first create database objects for any new cores. New cores are found by looking at every folder in the Assets directory, and checking the database for an existing match. If there is none, a new core object will be made. Secondly, it should go through every core listed in PocketCoreInfo and look for sorted roms. If a sorted rom doesn't have a database object, it should create it.

ProcessPlatforms

This will go through every core in the database with a complete set of information and write platform JSON in the Pocket's Platform directory. Additionally, it will look at the platform_images directory in the utility directory. All PNGs will be converted to BIN files, and all BIN files in the directory will be copied to the Pocket's platform image directory. When all PNGs and BINs are completed, they'll be moved to a completed directory.

This should be rewritten to remove the need for the overwrite_platform_images shell script.

ProcessLibraryImages

This will recently refactored, but could use a little more work. This program goes through every game in the database. It will try to download the boxart image online, and put it in the boxart directory. If the image already exists in the box art directory, it continues. It will then convert the image to a BMP and put it in the boxart converted directory. It will then run a script which converts the BMP to a BIN file, and copy it into the Pocket's library image directory. When an image exists locally, a boolean will be set true, and when the library image exists on the Pocket, a boolean will be set to true.

Currently the script runs through a specific set of directories, so when a new platform is added, it needs to be added here. The script should be removed, and the program should run an individual command line call for each image that needs to converted.

ProcessArcadeMRAFiles

This will need the most refactoring. This program should run the following processes.

  1. Look through all the MRA files in the mra_processing directory. The MRA files detail which rom ZIPs are required for generation, the name of the core, and the name of the arcade ROM it will generate.

  2. Check the database to see if there's a database object for the core. If not, create one, and then continue to the next MRA. If the core is in the database, it should have a rom directory value set, which says which sub-folder the roms should be copied to. If it doesn't, then continue to the next MRA.

  3. If the rom zip directory exists, check if the required rom ZIPs are in the directory. If not, download the rom ZIPs from the URL in the config file. If any rom zips cannot be found or cannot be downloaded, then write the error to the console, and continue with the next MRA.

  4. If all rom zips are downloaded and exist in the directory without a problem, generate the arcade ROM using the command line. Read the output for any errors. If there are no errors, then move the MRA file to the core's MRA directory.

Overall, the make_arcade_roms should be removed, and the program should make individual calls to the mra shell program to generate the roms.

dyreschlock commented 1 year ago

Refactor complete. Shell scripts have mostly been removed, and command line programs are called singularly to get better feedback, and allow the Java to react to it. Thus, programs can be called once now and complete everything is a single run, rather than calling Java then Script then Java again.

The ReadMe has been updated to explain the current workflows.