From 5a7b4aa13a3cbf3110ddb03d2244b574b54edcf9 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 21 Feb 2024 13:29:15 -0500 Subject: [PATCH] Add MAME options to patching system NOTE: Currently only works for MAME .ini files, not the XML-based .cfg files --- functions/patching.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/functions/patching.sh b/functions/patching.sh index c732163c..4af54660 100644 --- a/functions/patching.sh +++ b/functions/patching.sh @@ -52,6 +52,11 @@ set_setting_value() { xml ed -L -u "//$current_section_name/$setting_name_to_change" -v "$setting_value_to_change" "$1" fi ;; + + "mame" ) # This only works for mame .ini files, not the .cfg XML files + local mame_current_value=$(get_setting_value $1 "$setting_name_to_change" $4) + sed -i '\^\^'"$setting_name_to_change"'\s^s^'"$mame_current_value"'^'"$setting_value_to_change"'^' "$1" + ;; "es_settings" ) sed -i 's^'"$setting_name_to_change"'" value=".*"^'"$setting_name_to_change"'" value="'"$setting_value_to_change"'"^' "$1" @@ -76,6 +81,10 @@ get_setting_name() { echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g' ;; + "mame" ) # This only works for mame .ini files, not the .cfg XML files + echo "$current_setting_line" | awk '{print $1}' + ;; + * ) echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?=\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g;s^\\$^^' ;; @@ -132,6 +141,10 @@ get_setting_value() { fi ;; + "mame" ) # This only works for mame .ini files, not the .cfg XML files + echo $(sed -n '\^\^'"$current_setting_name"'\s^p' "$1" | awk '{print $2}') + ;; + "es_settings" ) echo $(grep -o -P "(?<=$current_setting_name\" value=\").*(?=\")" "$1") ;;