From 296caa939d6dee92df4d0783e091a8ef2b993068 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Fri, 7 Feb 2025 09:48:05 +0900 Subject: [PATCH] FRAMEWORK: added "--open" to open a component found in features.json + help fix --- functions/other_functions.sh | 42 ++++++++++++++++++++++++++++++++++++ retrodeck.sh | 7 +++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 6e893469..bbf8109f 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -1010,3 +1010,45 @@ portmaster_show(){ log e "\"$1\" is not a valid choice, quitting" fi } + +open_component(){ + + if [[ -z "$1" ]]; then + cmd=$(jq -r '.emulator[] | select(.ponzu != true) | .name' "$features" | sort) + if [[ "$akai_ponzu" == "true" ]]; then + cmd+="\n$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .name' "$features")" + fi + if [[ "$kiroi_ponzu" == "true" ]]; then + cmd+="\n$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .name' "$features")" + fi + echo -e "This command expects one of the following components as arguments:\n$(echo -e "$cmd" | sort)" + return + fi + + if [[ "$1" == "--getlist" ]]; then + cmd=$(jq -r '.emulator[] | select(.ponzu != true) | .name' "$features" | sort) + if [[ "$akai_ponzu" == "true" ]]; then + cmd+="\n$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .name' "$features")" + fi + if [[ "$kiroi_ponzu" == "true" ]]; then + cmd+="\n$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .name' "$features")" + fi + echo -e "$cmd" | sort + return + fi + + cmd=$(jq -r --arg name "$1" '.emulator[] | select(.name == $name and .ponzu != true) | .launch' "$features") + if [[ -z "$cmd" && "$akai_ponzu" == "true" && "$1" == "citra" ]]; then + cmd=$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .launch' "$features") + fi + if [[ -z "$cmd" && "$kiroi_ponzu" == "true" && "$1" == "yuzu" ]]; then + cmd=$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .launch' "$features") + fi + + if [[ -n "$cmd" ]]; then + eval "$cmd" "${@:2}" + else + echo "Invalid component name: $1" + echo "Please be sure that the casing is correct and if a space is present, the name is quoted." + fi +} diff --git a/retrodeck.sh b/retrodeck.sh index 6b988d12..cb2f7e5d 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -29,7 +29,8 @@ Arguments: --reset-component \t Reset one or more component or emulator configs to the default values --reset-retrodeck \t Starts the initial RetroDECK installer (backup your data first!) --test-upgrade \t Test upgrading RetroDECK to a specific version, developer use only - --set [value] \t Set or toggle a preset. Examples: --set borders, --set borders true, --set borders gba false. --set help for more help + --set [value] \t Set or toggle a preset. Examples: --set borders, --set borders all true, --set borders gba false. --set help for more help + --open \t Open a specific component or emulator, --open --getlist for a list of available components Game Launch: [] \t Start a game using the default emulator or\n\t\t\t\t\t\t the one defined in ES-DE for game or system @@ -165,6 +166,10 @@ for i in "$@"; do make_preset_changes "$preset" "$value" exit 0 ;; + --open*) + open_component "${@:2}" + exit 0 + ;; *) # Assume unknown arguments are game start arguments if [ -f "$i" ]; then