From 0dece7163e3dd6ebe2e2d7bde938686ae158649b Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Thu, 18 Jan 2024 14:31:47 +0100 Subject: [PATCH 1/8] Game Downloader: Add ability to view compatible patches --- functions/crc32.py | 11 ++++++ functions/game_downloader.sh | 57 +++++++++++++++++++++++++++++++ tools/configurator.sh | 66 +++++++++++++++++++++++++++++++++++- 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 functions/crc32.py create mode 100755 functions/game_downloader.sh diff --git a/functions/crc32.py b/functions/crc32.py new file mode 100644 index 00000000..4dc8bf46 --- /dev/null +++ b/functions/crc32.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +import os, sys +import zlib + +def crc32(fileName): + prev = 0 + for eachLine in open(fileName,"rb"): + prev = zlib.crc32(eachLine, prev) + return "%X"%(prev & 0xFFFFFFFF) + +print(crc32(sys.argv[1]).lower()) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh new file mode 100755 index 00000000..d85015da --- /dev/null +++ b/functions/game_downloader.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +game_downloader_setup() { + crc32_cmd="python3 /app/libexec/crc32.py" + + # "hacks" is the general name which includes ROM Hacks, Homebrew and Ports + hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/main" + hacks_db_path="$HOME/.var/app/net.retrodeck.retrodeck/data/hacks_metadata.db" + + # set up hacks database + sqlite3 $hacks_db_path < <(curl -sL "$hacks_repo_url"/db_setup.sql) + + declare -g hacks_db_cmd="sqlite3 $hacks_db_path" +} + +collect_base_rom_crc32s() { + # Register all crc32 checksums of potential base ROMs and their paths into the dictionary "base_roms" + + declare -gA base_roms + + for rom in ${roms_folder}/*/*; do + if [[ "$(basename "$rom")" != "systeminfo.txt" ]]; then + crc32="$($crc32_cmd "$rom")" + base_roms["$crc32"]="$rom" + fi + done +} + +build_patches_array() { + # Set up array that contains the names of patches compatible with available base ROMs + + declare -ga compatible_romhack_patches=() + + for base_crc32 in "${!base_roms[@]}"; do + + current_base_compatible_patches="$($hacks_db_cmd "SELECT name FROM main WHERE base_crc32 = '""$base_crc32""'")" + + if [[ ! -z "$(printf "$current_base_compatible_patches")" ]]; then # if there are compatible patches for this base + # Add available patches to array + + # TODO: Remove redundancy within this line. Puts the patches names separated by newlines into an array + IFS='|' read -r -a array_of_compatible_patches <<< $(echo "$current_base_compatible_patches" | tr '\n' '|') + + for patch in "${array_of_compatible_patches[@]}"; do + compatible_romhack_patches+=("$patch") + done + fi + done +} + +get_compatible_romhacks() { + # Provide global array "compatible_romhack_patches" which contains names of available, compatible romhack patches + + game_downloader_setup + collect_base_rom_crc32s + build_patches_array +} diff --git a/tools/configurator.sh b/tools/configurator.sh index cebebeab..470343bf 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -97,6 +97,7 @@ source /app/libexec/global.sh # - Browse the wiki # - USB Import tool # - Install: RetroDECK Starter Pack +# - Game Downloader # DIALOG TREE FUNCTIONS @@ -1176,7 +1177,8 @@ configurator_developer_dialog() { "Change Update Channel" "Change between normal and cooker builds" \ "Browse the Wiki" "Browse the RetroDECK wiki online" \ "USB Import" "Prepare a USB device for ROMs or import an existing collection" \ - "Install RetroDECK Starter Pack" "Install the optional RetroDECK starter pack" ) + "Install RetroDECK Starter Pack" "Install the optional RetroDECK starter pack" \ + "Game Downloader" "Install ROM Hacks, Homebrew or Ports" ) case $choice in @@ -1204,6 +1206,10 @@ configurator_developer_dialog() { configurator_developer_dialog ;; + "Game Downloader" ) + configurator_game_downloader_dialog + ;; + "" ) # No selection made or Back button clicked configurator_welcome_dialog ;; @@ -1355,6 +1361,64 @@ configurator_usb_import_dialog() { } +configurator_game_downloader_dialog() { + choice=$(zenity --list --title="RetroDECK Configurator Utility - Game Downloader" --cancel-label="Back" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ + --column="Choice" --column="Description" \ + "ROM Hack Downloader" "Install ROM Hacks which are compatible with your ROMs (Right now: Only shows compatible ROMs with Super Mario World (USA) and Super Mario Bros. (World). Can't download.)" \ + "Homebrew Downloader" "Install Homebrew (Not yet functional)" \ + "Ports Downloader" "Install Ports (Not yet functional)" ) + + case $choice in + + "ROM Hack Downloader" ) + configurator_romhack_downloader_dialog + ;; + + "Homebrew Downloader" ) + configurator_developer_dialog + ;; + + "Ports Downloader" ) + configurator_developer_dialog + ;; + + "" ) # No selection made or Back button clicked + configurator_welcome_dialog + ;; + + esac +} + +configurator_romhack_downloader_dialog() { + + get_compatible_romhacks # creates compatible_romhack_patches array + + zenity_columns=() + for hack_name in "${compatible_romhack_patches[@]}"; do + + # Get romhack info + sanitized_name="$(echo "$hack_name" | sed -e "s/'/''/g")" + hack_info="$($hacks_db_cmd "SELECT released,retro_achievements,description FROM main WHERE name = '""$sanitized_name""'")" + IFS='|' read -r -a hack_info_array <<< "$hack_info" + + # Add row of hack info + zenity_columns+=("$hack_name") + for info in "${hack_info_array[@]}"; do + zenity_columns+=("$info") + done + done + + choice=$(zenity --list --title="RetroDECK Configurator Utility - Game Downloader: ROM Hacks" --cancel-label="Back" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ + --column="ROM Hack Name" --column="Released" --column="Retro Achievements" --column="Description" \ + "${zenity_columns[@]}" ) + + echo "$choice" + + configurator_welcome_dialog +} + # START THE CONFIGURATOR configurator_welcome_dialog From c5c7e4694cbd6c9ca094e965134898f68b9967a6 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Mon, 22 Jan 2024 16:53:17 +0100 Subject: [PATCH 2/8] Pin db setup file to commit --- functions/game_downloader.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh index d85015da..2de14925 100755 --- a/functions/game_downloader.sh +++ b/functions/game_downloader.sh @@ -4,7 +4,7 @@ game_downloader_setup() { crc32_cmd="python3 /app/libexec/crc32.py" # "hacks" is the general name which includes ROM Hacks, Homebrew and Ports - hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/main" + hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/b6e2163e9707a23b209f2e3dd082fff29fb6e8c5" hacks_db_path="$HOME/.var/app/net.retrodeck.retrodeck/data/hacks_metadata.db" # set up hacks database From 6d1437e5003fe332d1e8f09986eb793da9d5f280 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Fri, 26 Jan 2024 17:00:29 +0100 Subject: [PATCH 3/8] Fix global.sh --- functions/global.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/global.sh b/functions/global.sh index 954acdda..cb8f76e3 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -7,6 +7,7 @@ source /app/libexec/checks.sh source /app/libexec/compression.sh source /app/libexec/dialogs.sh source /app/libexec/functions.sh +source /app/libexec/game_downloader.sh source /app/libexec/multi_user.sh source /app/libexec/patching.sh source /app/libexec/post_update.sh From 60fa87c16bf26cef900dc5505fcc2e9c83d120cf Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Fri, 26 Jan 2024 19:47:19 +0100 Subject: [PATCH 4/8] Use db for data sharing between configurator and game_downloader.sh --- functions/game_downloader.sh | 46 ++++++++---------------------------- tools/configurator.sh | 41 ++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh index 2de14925..49b95d32 100755 --- a/functions/game_downloader.sh +++ b/functions/game_downloader.sh @@ -1,57 +1,31 @@ #!/bin/bash -game_downloader_setup() { +hacks_db_setup() { crc32_cmd="python3 /app/libexec/crc32.py" # "hacks" is the general name which includes ROM Hacks, Homebrew and Ports - hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/b6e2163e9707a23b209f2e3dd082fff29fb6e8c5" + hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/main" hacks_db_path="$HOME/.var/app/net.retrodeck.retrodeck/data/hacks_metadata.db" # set up hacks database + rm $hacks_db_path sqlite3 $hacks_db_path < <(curl -sL "$hacks_repo_url"/db_setup.sql) + sqlite3 $hacks_db_path < <(echo "ALTER TABLE bases ADD COLUMN local_path;") declare -g hacks_db_cmd="sqlite3 $hacks_db_path" } -collect_base_rom_crc32s() { +check_romhacks_compatibility() { # Register all crc32 checksums of potential base ROMs and their paths into the dictionary "base_roms" - declare -gA base_roms + for rom_path in ${roms_folder}/*/*; do + if [[ "$(basename "$rom_path")" != "systeminfo.txt" ]]; then - for rom in ${roms_folder}/*/*; do - if [[ "$(basename "$rom")" != "systeminfo.txt" ]]; then - crc32="$($crc32_cmd "$rom")" - base_roms["$crc32"]="$rom" - fi - done -} - -build_patches_array() { - # Set up array that contains the names of patches compatible with available base ROMs - - declare -ga compatible_romhack_patches=() - - for base_crc32 in "${!base_roms[@]}"; do + crc32="$($crc32_cmd "$rom_path")" + sanitized_path="$(echo "$rom_path" | sed -e "s/'/''/g")" - current_base_compatible_patches="$($hacks_db_cmd "SELECT name FROM main WHERE base_crc32 = '""$base_crc32""'")" - - if [[ ! -z "$(printf "$current_base_compatible_patches")" ]]; then # if there are compatible patches for this base - # Add available patches to array - - # TODO: Remove redundancy within this line. Puts the patches names separated by newlines into an array - IFS='|' read -r -a array_of_compatible_patches <<< $(echo "$current_base_compatible_patches" | tr '\n' '|') - - for patch in "${array_of_compatible_patches[@]}"; do - compatible_romhack_patches+=("$patch") - done + $hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$sanitized_path""' WHERE crc32 = '""$crc32""'") fi done } -get_compatible_romhacks() { - # Provide global array "compatible_romhack_patches" which contains names of available, compatible romhack patches - - game_downloader_setup - collect_base_rom_crc32s - build_patches_array -} diff --git a/tools/configurator.sh b/tools/configurator.sh index 470343bf..a2d25e32 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -91,6 +91,7 @@ source /app/libexec/global.sh # - Version-specific changelogs # - RetroDECK Credits # - Add to Steam +# - ROM Hack Downloader # - Developer Options (Hidden) # - Change Multi-user mode # - Change Update channel @@ -109,6 +110,7 @@ configurator_welcome_dialog() { "RetroDECK: Troubleshooting" "Backup data, perform BIOS / multi-disc file checks checks and emulator resets" \ "RetroDECK: About" "Show additional information about RetroDECK" \ "Sync with Steam" "Sync with Steam all the favorites games" \ + "ROM Hack Downloader" "Install ROM Hacks which are compatible with your ROMs" \ "Developer Options" "Welcome to the DANGER ZONE") else welcome_menu_options=("Presets & Settings" "Here you find various presets, tweaks and settings to customize your RetroDECK experience" \ @@ -150,6 +152,10 @@ configurator_welcome_dialog() { configurator_add_steam ;; + "ROM Hack Downloader" ) + configurator_romhack_downloader_dialog + ;; + "Developer Options" ) configurator_generic_dialog "RetroDECK Configurator - Developer Options" "The following features and options are potentially VERY DANGEROUS for your RetroDECK install!\n\nThey should be considered the bleeding-edge of upcoming RetroDECK features, and never used when you have important saves/states/roms that are not backed up!\n\nYOU HAVE BEEN WARNED!" configurator_developer_dialog @@ -1392,26 +1398,35 @@ configurator_game_downloader_dialog() { configurator_romhack_downloader_dialog() { - get_compatible_romhacks # creates compatible_romhack_patches array + hacks_db_setup + check_romhacks_compatibility # add paths of available base roms to db + + available_bases_crc32s="$($hacks_db_cmd "SELECT crc32 FROM bases WHERE local_path NOT NULL;")" zenity_columns=() - for hack_name in "${compatible_romhack_patches[@]}"; do - # Get romhack info - sanitized_name="$(echo "$hack_name" | sed -e "s/'/''/g")" - hack_info="$($hacks_db_cmd "SELECT released,retro_achievements,description FROM main WHERE name = '""$sanitized_name""'")" - IFS='|' read -r -a hack_info_array <<< "$hack_info" + while IFS= read -r base_crc32; do - # Add row of hack info - zenity_columns+=("$hack_name") - for info in "${hack_info_array[@]}"; do - zenity_columns+=("$info") - done - done + # Get info of the available hacks for this base crc32 + info_of_hacks_compatible_with_base="$($hacks_db_cmd "SELECT name,released,retro_achievements,description FROM rhacks WHERE base_crc32 = '""$base_crc32""'")" + + while IFS= read -r single_hack_info; do + + # Turn db output into array + IFS='|' read -r -a single_hack_info_array <<< "$single_hack_info" + + # Add row of hack info to zenity choices + for info in "${single_hack_info_array[@]}"; do + zenity_columns+=("$info") + done + + done <<< "$info_of_hacks_compatible_with_base" + + done <<< "$available_bases_crc32s" choice=$(zenity --list --title="RetroDECK Configurator Utility - Game Downloader: ROM Hacks" --cancel-label="Back" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ - --column="ROM Hack Name" --column="Released" --column="Retro Achievements" --column="Description" \ + --column="ROM Hack Name" --column="Released" --column="RetroAchievements" --column="Description" \ "${zenity_columns[@]}" ) echo "$choice" From 9377502a9fd95c3789a5f4f8e2243d220a666064 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Sat, 27 Jan 2024 00:37:01 +0100 Subject: [PATCH 5/8] Patches can now get downloaded --- functions/game_downloader.sh | 29 ++++++++++++++++++++++++++--- tools/configurator.sh | 3 +++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh index 49b95d32..16c79cc1 100755 --- a/functions/game_downloader.sh +++ b/functions/game_downloader.sh @@ -15,17 +15,40 @@ hacks_db_setup() { declare -g hacks_db_cmd="sqlite3 $hacks_db_path" } +db_sanitize() { + echo "$(echo "$1" | sed -e "s/'/''/g")" +} + check_romhacks_compatibility() { - # Register all crc32 checksums of potential base ROMs and their paths into the dictionary "base_roms" + # Add paths of locally available base roms to db for rom_path in ${roms_folder}/*/*; do if [[ "$(basename "$rom_path")" != "systeminfo.txt" ]]; then crc32="$($crc32_cmd "$rom_path")" - sanitized_path="$(echo "$rom_path" | sed -e "s/'/''/g")" - $hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$sanitized_path""' WHERE crc32 = '""$crc32""'") + $hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$(db_sanitize "$rom_path")""' WHERE crc32 = '""$crc32""'") fi done } +install_romhack() { + # $1: name of romhack + + set -exo pipefail + + hack_name="$1" + infos=$($hacks_db_cmd "SELECT bases.system,bases.name,bases.local_path \ + FROM bases JOIN rhacks ON bases.crc32 = rhacks.base_crc32 \ + WHERE rhacks.name = '""$(db_sanitize "$1")""'") + + IFS='|' read -r system base_name base_local_path <<< $infos + + # download patchfile + wget -q "https://github.com/Libretto7/best-romhacks/raw/main/rhacks/$system/$base_name/$hack_name/patch.tar.xz" -O "/tmp/patch.tar.xz" + + patchfile_name=$(tar -xvf "/tmp/patch.tar.xz" --directory="$roms_folder/$system") + echo "$patchfile_name" + + flips="flatpak-spawn --host flatpak run com.github.Alcaro.Flips" +} diff --git a/tools/configurator.sh b/tools/configurator.sh index a2d25e32..e9775850 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -103,6 +103,8 @@ source /app/libexec/global.sh # DIALOG TREE FUNCTIONS configurator_welcome_dialog() { + configurator_romhack_downloader_dialog + if [[ $developer_options == "true" ]]; then welcome_menu_options=("Presets & Settings" "Here you find various presets, tweaks and settings to customize your RetroDECK experience" \ "Open Emulator" "Launch and configure each emulators settings (for advanced users)" \ @@ -1430,6 +1432,7 @@ configurator_romhack_downloader_dialog() { "${zenity_columns[@]}" ) echo "$choice" + install_romhack "$choice" && echo "success" configurator_welcome_dialog } From 50ee06784d097c318f2d843ebd35e6a830df67b8 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Sat, 27 Jan 2024 15:32:42 +0100 Subject: [PATCH 6/8] Romhacks are now fully installable --- functions/game_downloader.sh | 29 +++++++++++++------------ tools/configurator.sh | 41 ++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh index 16c79cc1..10c2eb60 100755 --- a/functions/game_downloader.sh +++ b/functions/game_downloader.sh @@ -4,15 +4,12 @@ hacks_db_setup() { crc32_cmd="python3 /app/libexec/crc32.py" # "hacks" is the general name which includes ROM Hacks, Homebrew and Ports - hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/main" hacks_db_path="$HOME/.var/app/net.retrodeck.retrodeck/data/hacks_metadata.db" - # set up hacks database - rm $hacks_db_path - sqlite3 $hacks_db_path < <(curl -sL "$hacks_repo_url"/db_setup.sql) - sqlite3 $hacks_db_path < <(echo "ALTER TABLE bases ADD COLUMN local_path;") - + # Set up hacks database declare -g hacks_db_cmd="sqlite3 $hacks_db_path" + $hacks_db_cmd < <(curl -sL "https://raw.githubusercontent.com/Libretto7/best-romhacks/main/db_setup.sql") + $hacks_db_cmd "ALTER TABLE bases ADD COLUMN local_path;" } db_sanitize() { @@ -35,8 +32,6 @@ check_romhacks_compatibility() { install_romhack() { # $1: name of romhack - set -exo pipefail - hack_name="$1" infos=$($hacks_db_cmd "SELECT bases.system,bases.name,bases.local_path \ FROM bases JOIN rhacks ON bases.crc32 = rhacks.base_crc32 \ @@ -44,11 +39,19 @@ install_romhack() { IFS='|' read -r system base_name base_local_path <<< $infos - # download patchfile - wget -q "https://github.com/Libretto7/best-romhacks/raw/main/rhacks/$system/$base_name/$hack_name/patch.tar.xz" -O "/tmp/patch.tar.xz" + # Download patchfile + wget -q "https://github.com/Libretto7/best-romhacks/raw/main/rhacks/$system/$base_name/$hack_name/patch.tar.xz" \ + -O "/tmp/patch.tar.xz" + # Extract patchfile patchfile_name=$(tar -xvf "/tmp/patch.tar.xz" --directory="$roms_folder/$system") - echo "$patchfile_name" - - flips="flatpak-spawn --host flatpak run com.github.Alcaro.Flips" + + # Create the hack + base_name="$(basename "$base_local_path")" + ext="$(echo "${base_name##*.}")" + flatpak-spawn --host flatpak run com.github.Alcaro.Flips \ + --apply "$roms_folder/$system/$patchfile_name" "$base_local_path" "$roms_folder/$system/$hack_name.$ext" >/dev/null + + # Cleanup + rm "$roms_folder/$system/$patchfile_name" } diff --git a/tools/configurator.sh b/tools/configurator.sh index e9775850..09bd28f7 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -103,8 +103,6 @@ source /app/libexec/global.sh # DIALOG TREE FUNCTIONS configurator_welcome_dialog() { - configurator_romhack_downloader_dialog - if [[ $developer_options == "true" ]]; then welcome_menu_options=("Presets & Settings" "Here you find various presets, tweaks and settings to customize your RetroDECK experience" \ "Open Emulator" "Launch and configure each emulators settings (for advanced users)" \ @@ -155,6 +153,7 @@ configurator_welcome_dialog() { ;; "ROM Hack Downloader" ) + configurator_generic_dialog "RetroDECK Configurator - ROM Hack Downloader" "In order to download ROM Hacks you need to have the ROMs the hacks are based on already available. Your base ROMs need to be compatible with the hacks, otherwise those hacks will not be shown.\n\nRight now, your base ROMs need to be uncompressed for this to work.\n\nThe compatible ROM Hacks will now be listed." configurator_romhack_downloader_dialog ;; @@ -1373,13 +1372,14 @@ configurator_game_downloader_dialog() { choice=$(zenity --list --title="RetroDECK Configurator Utility - Game Downloader" --cancel-label="Back" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ --column="Choice" --column="Description" \ - "ROM Hack Downloader" "Install ROM Hacks which are compatible with your ROMs (Right now: Only shows compatible ROMs with Super Mario World (USA) and Super Mario Bros. (World). Can't download.)" \ + "ROM Hack Downloader" "Install ROM Hacks which are compatible with your ROMs" \ "Homebrew Downloader" "Install Homebrew (Not yet functional)" \ "Ports Downloader" "Install Ports (Not yet functional)" ) case $choice in "ROM Hack Downloader" ) + configurator_generic_dialog "RetroDECK Configurator - ROM Hack Downloader" "In order to download ROM Hacks you need to have the ROMs the hacks are based on already available. Your base ROMs need to be compatible with the hacks, otherwise those hacks will not be shown.\n\nRight now, your base ROMs need to be uncompressed for this to work.\n\nThe compatible ROM Hacks will now be listed." configurator_romhack_downloader_dialog ;; @@ -1399,18 +1399,18 @@ configurator_game_downloader_dialog() { } configurator_romhack_downloader_dialog() { - hacks_db_setup check_romhacks_compatibility # add paths of available base roms to db available_bases_crc32s="$($hacks_db_cmd "SELECT crc32 FROM bases WHERE local_path NOT NULL;")" zenity_columns=() - while IFS= read -r base_crc32; do # Get info of the available hacks for this base crc32 - info_of_hacks_compatible_with_base="$($hacks_db_cmd "SELECT name,released,retro_achievements,description FROM rhacks WHERE base_crc32 = '""$base_crc32""'")" + info_of_hacks_compatible_with_base="$($hacks_db_cmd "SELECT rhacks.name,bases.system,rhacks.released,rhacks.retro_achievements,rhacks.description \ + FROM bases JOIN rhacks ON bases.crc32 = rhacks.base_crc32 + WHERE bases.crc32 = '""$base_crc32""'")" while IFS= read -r single_hack_info; do @@ -1426,15 +1426,30 @@ configurator_romhack_downloader_dialog() { done <<< "$available_bases_crc32s" - choice=$(zenity --list --title="RetroDECK Configurator Utility - Game Downloader: ROM Hacks" --cancel-label="Back" \ - --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ - --column="ROM Hack Name" --column="Released" --column="RetroAchievements" --column="Description" \ - "${zenity_columns[@]}" ) + if [[ ${#zenity_columns[@]} != 0 ]]; then # Compatible base ROMs found + + choice=$(zenity --list --title="RetroDECK Configurator Utility - ROM Hack Downloader" --cancel-label="Back" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ + --column="ROM Hack Name" --column="System" --column="Released" --column="RetroAchievements" --column="Description" \ + "${zenity_columns[@]}" ) - echo "$choice" - install_romhack "$choice" && echo "success" + if [[ -z "$choice" ]]; then # no selection or back button + configurator_welcome_dialog + else + install_romhack "$choice" + rc=$? + if [[ $rc == "0" ]]; then + configurator_generic_dialog "RetroDECK Configurator - ROM Hack Downloader" "$choice was installed successfully!" + else + configurator_generic_dialog "RetroDECK Configurator - ROM Hack Downloader" "Something went wrong :(" + fi - configurator_welcome_dialog + configurator_romhack_downloader_dialog + fi + else # No compatible base ROMs + configurator_generic_dialog "RetroDECK Configurator - ROM Hack Downloader" "You have no uncompressed ROMs which are compatible with the available patches." + configurator_welcome_dialog + fi } # START THE CONFIGURATOR From 63df0fa9570658d83d235487b89d6aa111794d71 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Sat, 27 Jan 2024 15:38:15 +0100 Subject: [PATCH 7/8] Remove blank lines --- tools/configurator.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/configurator.sh b/tools/configurator.sh index 09bd28f7..cc1688c3 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -1423,11 +1423,9 @@ configurator_romhack_downloader_dialog() { done done <<< "$info_of_hacks_compatible_with_base" - done <<< "$available_bases_crc32s" if [[ ${#zenity_columns[@]} != 0 ]]; then # Compatible base ROMs found - choice=$(zenity --list --title="RetroDECK Configurator Utility - ROM Hack Downloader" --cancel-label="Back" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ --column="ROM Hack Name" --column="System" --column="Released" --column="RetroAchievements" --column="Description" \ From 9b504c9284fb9ef9c7f19dcb05884e09ae8e6139 Mon Sep 17 00:00:00 2001 From: Libretto <> Date: Sat, 27 Jan 2024 23:37:30 +0100 Subject: [PATCH 8/8] Add flips module --- functions/game_downloader.sh | 3 +-- net.retrodeck.retrodeck.yml | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/functions/game_downloader.sh b/functions/game_downloader.sh index 10c2eb60..ce137e9a 100755 --- a/functions/game_downloader.sh +++ b/functions/game_downloader.sh @@ -49,8 +49,7 @@ install_romhack() { # Create the hack base_name="$(basename "$base_local_path")" ext="$(echo "${base_name##*.}")" - flatpak-spawn --host flatpak run com.github.Alcaro.Flips \ - --apply "$roms_folder/$system/$patchfile_name" "$base_local_path" "$roms_folder/$system/$hack_name.$ext" >/dev/null + flips --apply "$roms_folder/$system/$patchfile_name" "$base_local_path" "$roms_folder/$system/$hack_name.$ext" >/dev/null # Cleanup rm "$roms_folder/$system/$patchfile_name" diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index 62c2b843..75b7ffa6 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -470,6 +470,16 @@ modules: commit: b33d965f227fe971fd590cb022f608521b506ef3 - rd-submodules/boilr/cargo-lock.json + - name: flips + buildsystem: simple + build-commands: + - sh make.sh --cflags=-DFLATPAK + - make install PREFIX=/app + sources: + - type: git + url: https://github.com/Alcaro/Flips.git + commit: 96df78fd733ebc56d64bcfcaee7d127bfd6643d6 + # RetroArch - START # https://github.com/flathub/org.libretro.RetroArch @@ -1403,4 +1413,4 @@ modules: sources: - type: git url: https://github.com/XargonWan/RetroDECK.git - branch: THISBRANCH \ No newline at end of file + branch: THISBRANCH