Skip to content

Commit

Permalink
Add support for non-yml RPCS3 ini files in framework
Browse files Browse the repository at this point in the history
  • Loading branch information
icenine451 committed May 3, 2024
1 parent 63b29f2 commit 1869b88
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions functions/framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ set_setting_value() {
fi
;;

"rpcs3" | "vita3k" ) # This does not currently work for settings with a $ in them
if [[ -z $current_section_name ]]; then
sed -i 's^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' "$1"
else
sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' "$1"
"rpcs3" | "vita3k" )
# This does not currently work for settings with a $ in them

if [[ "$1" =~ (.ini)$ ]]; then # If this is a RPCS3 .ini file
if [[ -z $current_section_name ]]; then
sed -i 's^\^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' "$1"
else
sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'=^s^\^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' "$1"
fi
elif [[ "$1" =~ (.yml)$ ]]; then # If this is an YML-based file
if [[ -z $current_section_name ]]; then
sed -i 's^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' "$1"
else
sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' "$1"
fi
fi
;;

Expand All @@ -55,7 +65,9 @@ set_setting_value() {
fi
;;

"mame" ) # In this option, $current_section_name is the <system name> in the .cfg file.
"mame" )
# In this option, $current_section_name is the <system name> in the .cfg file.

local mame_current_value=$(get_setting_value "$1" "$setting_name_to_change" "$4" "$current_section_name")
if [[ "$1" =~ (.ini)$ ]]; then # If this is a MAME .ini file
sed -i '\^\^'"$setting_name_to_change"'\s^s^'"$mame_current_value"'^'"$setting_value_to_change"'^' "$1"
Expand Down Expand Up @@ -84,7 +96,11 @@ get_setting_name() {
;;

"rpcs3" | "vita3k" )
echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g'
if [[ "$1" =~ (.ini)$ ]]; then # If this is a RPCS3 .ini file
echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?=\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g;s^\\$^^'
elif [[ "$1" =~ (.yml)$ ]]; then # If this is an YML-based file
echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g'
fi
;;

"mame" ) # This only works for mame .ini files, not the .cfg XML files
Expand Down

0 comments on commit 1869b88

Please sign in to comment.