Maingron / Open-with-Retroarch

A Windows CMD script that allows to open Roms with Retroarch from within the File Explorer / Open with RetroArch
8 stars 0 forks source link

consider adding support for .chd, .cue & .iso for multiple systems #5

Open esmith13 opened 3 months ago

esmith13 commented 3 months ago

I edited version 0.5-dev of your script myself to have a tradeoff of minor user interaction to get these additional "universal" extensions supported. Could be expanded to handle .zip for various arcade cores by user selection as well.

I added the following code at around line #701, immediately after your line IF NOT DEFINED rom-ext (goto error-no_input_ext) and before goto %rom-ext%

IF "%rom-ext%"==".chd" (
    setlocal enabledelayedexpansion
        echo Choose which system the game is for
        echo.
        echo 1. NEC PC Engine CD
        echo 2. PlayStation
        echo 3. Sega CD
        echo 4. Sega Saturn
        echo 5. Sega Dreamcast
        echo 6. EXIT WITHOUT STARTING GAME
        echo.
        set "answer="
        choice /c 123456 /n /t 5 /d 6 /m "Please enter your choice: "
        set "answer=!errorlevel!"
        IF "!answer!"=="1" goto .pce
        IF "!answer!"=="2" goto .psx
        IF "!answer!"=="3" goto .md
        IF "!answer!"=="4" goto saturn
        IF "!answer!"=="5" goto .gdi
        IF "!answer!"=="6" goto :eof
    )
    IF "%rom-ext%"==".cue" (
    setlocal enabledelayedexpansion
        echo Choose which system the game is for
        echo.
        echo 1. NEC PC Engine CD
        echo 2. PlayStation
        echo 3. Sega CD
        echo 4. Sega Saturn
        echo 5. Sega Dreamcast
        echo 6. EXIT WITHOUT STARTING GAME
        echo.
        set "answer="
        choice /c 123456 /n /t 5 /d 6 /m "Please enter your choice: "
        set "answer=!errorlevel!"
        IF "!answer!"=="1" goto .pce
        IF "!answer!"=="2" goto .psx
        IF "!answer!"=="3" goto .md
        IF "!answer!"=="4" goto saturn
        IF "!answer!"=="5" goto .gdi
        IF "!answer!"=="6" goto :eof
    )
    IF "%rom-ext%"==".iso" (
    setlocal enabledelayedexpansion
        echo Choose which system the game is for
        echo.
        echo 1. NEC PC Engine CD
        echo 2. PlayStation
        echo 3. Sega CD
        echo 4. Sega Saturn
        echo 5. Sega Dreamcast
        echo 6. EXIT WITHOUT STARTING GAME
        echo.
        set "answer="
        choice /c 123456 /n /t 5 /d 6 /m "Please enter your choice: "
        set "answer=!errorlevel!"
        IF "!answer!"=="1" goto .pce
        IF "!answer!"=="2" goto .psx
        IF "!answer!"=="3" goto .md
        IF "!answer!"=="4" goto saturn
        IF "!answer!"=="5" goto .gdi
        IF "!answer!"=="6" goto :eof
    )

I also had to add a ":saturn" section in the ":sega_consoles" area of the batch file, of course. The downside of this is that after double-clicking your .chd/.cue/.iso, you have to press a single digit on your keyboard to tell it what system to run the image for in retroarch. If you press '6' or don't respond within 5 seconds, it simply exits and does nothing. For me, personally, it's still worth it.

PS: thank you SO MUCH for your hard work on this script!!

Maingron commented 3 months ago

Thank you very much for suggesting a solution to this problem. I think a different possible solution would be to consider the directory name (eg if the folder is called "PS2" and you open a ".ISO" file, it's very likely you're trying to run a PS2 game. I will look into it, but due to time constraints, it'll take me a while.