mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 05:55:38 +00:00
RUN_GAME: if the emulator is only one just skip the zenity and run it
This commit is contained in:
parent
6496e1f051
commit
e80c30a1d9
|
@ -936,7 +936,6 @@ find_emulator() {
|
||||||
|
|
||||||
|
|
||||||
# TODO: add the logic of alt emulator and default emulator
|
# TODO: add the logic of alt emulator and default emulator
|
||||||
# TODO: if the emulator is only one just skip the zenity and run it
|
|
||||||
|
|
||||||
run_game() {
|
run_game() {
|
||||||
|
|
||||||
|
@ -1085,38 +1084,44 @@ replace_emulator_placeholder() {
|
||||||
|
|
||||||
# Extracting the commands from es_systems.xml for the selected system
|
# Extracting the commands from es_systems.xml for the selected system
|
||||||
find_system_commands() {
|
find_system_commands() {
|
||||||
local system_name=$system
|
local system_name=$system
|
||||||
# Use xmllint to extract the system commands from the XML
|
# Use xmllint to extract the system commands from the XML
|
||||||
system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null)
|
system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null)
|
||||||
|
|
||||||
if [ -z "$system_section" ]; then
|
if [ -z "$system_section" ]; then
|
||||||
log e "System not found: $system_name"
|
log e "System not found: $system_name"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract commands and labels
|
# Extract commands and labels
|
||||||
commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null)
|
commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null)
|
||||||
|
|
||||||
# Prepare Zenity command list
|
# Prepare Zenity command list
|
||||||
command_list=()
|
command_list=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p')
|
label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p')
|
||||||
command=$(echo "$line" | sed -n 's/.*<command[^>]*>\(.*\)<\/command>.*/\1/p')
|
command=$(echo "$line" | sed -n 's/.*<command[^>]*>\(.*\)<\/command>.*/\1/p')
|
||||||
|
|
||||||
# Substitute placeholders in the command
|
# Substitute placeholders in the command
|
||||||
command=$(substitute_placeholders "$command")
|
command=$(substitute_placeholders "$command")
|
||||||
|
|
||||||
# Add label and command to Zenity list (label first, command second)
|
# Add label and command to Zenity list (label first, command second)
|
||||||
command_list+=("$label" "$command")
|
command_list+=("$label" "$command")
|
||||||
done <<< "$commands"
|
done <<< "$commands"
|
||||||
|
|
||||||
# Show the list with Zenity and return the **command** (second column) selected
|
# Check if there's only one command
|
||||||
selected_command=$(zenity --list \
|
if [ ${#command_list[@]} -eq 2 ]; then
|
||||||
--title="Select an emulator for $system_name" \
|
log d "Only one command found for $system_name, running it directly: ${command_list[1]}"
|
||||||
--column="Emulator" --column="Hidden Command" "${command_list[@]}" \
|
selected_command="${command_list[1]}"
|
||||||
--width=800 --height=400 --print-column=2 --hide-column=2)
|
else
|
||||||
|
# Show the list with Zenity and return the **command** (second column) selected
|
||||||
|
selected_command=$(zenity --list \
|
||||||
|
--title="Select an emulator for $system_name" \
|
||||||
|
--column="Emulator" --column="Hidden Command" "${command_list[@]}" \
|
||||||
|
--width=800 --height=400 --print-column=2 --hide-column=2)
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$selected_command"
|
echo "$selected_command"
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the emulator is not specified, ask the user to select it or get it from the XML file
|
# If the emulator is not specified, ask the user to select it or get it from the XML file
|
||||||
|
|
Loading…
Reference in a new issue