Add MAME options to patching system

NOTE: Currently only works for MAME .ini files, not the XML-based .cfg files
This commit is contained in:
icenine451 2024-02-21 13:29:15 -05:00
parent de6740d280
commit 5a7b4aa13a

View file

@ -52,6 +52,11 @@ set_setting_value() {
xml ed -L -u "//$current_section_name/$setting_name_to_change" -v "$setting_value_to_change" "$1" xml ed -L -u "//$current_section_name/$setting_name_to_change" -v "$setting_value_to_change" "$1"
fi 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" ) "es_settings" )
sed -i 's^'"$setting_name_to_change"'" value=".*"^'"$setting_name_to_change"'" value="'"$setting_value_to_change"'"^' "$1" 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' 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^\\$^^' 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 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" ) "es_settings" )
echo $(grep -o -P "(?<=$current_setting_name\" value=\").*(?=\")" "$1") echo $(grep -o -P "(?<=$current_setting_name\" value=\").*(?=\")" "$1")
;; ;;