mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 07:25:38 +00:00
RUN_GAME: code prettyfication
This commit is contained in:
parent
24b35b7175
commit
51485497ae
|
@ -895,9 +895,10 @@ start_retrodeck() {
|
|||
find_emulator() {
|
||||
local emulator_name=$1
|
||||
local found_path=""
|
||||
local es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml"
|
||||
|
||||
# Search the es_find_rules.xml file for the emulator
|
||||
emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "/app/share/es-de/resources/systems/linux/es_find_rules.xml" 2>/dev/null)
|
||||
emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null)
|
||||
|
||||
if [ -z "$emulator_section" ]; then
|
||||
log e "Emulator not found: $emulator_name"
|
||||
|
@ -938,13 +939,15 @@ find_emulator() {
|
|||
# TODO: add the logic of alt emulator and default emulator
|
||||
|
||||
run_game() {
|
||||
# call me with (-e emulator) (-s system) game/path, examples:
|
||||
# run_game -e gambatte_libretro ~/retrodeck/roms/gb/Capumon.gb
|
||||
# run_game ~/retrodeck/roms/gb/Capumon.gb
|
||||
# run_game -s gbc ~/retrodeck/roms/gb/Capumon.gb
|
||||
|
||||
# Initialize variables
|
||||
emulator=""
|
||||
system=""
|
||||
|
||||
# Path to the es_systems.xml file
|
||||
xml_file="/app/share/es-de/resources/systems/linux/es_systems.xml"
|
||||
es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml"
|
||||
|
||||
# Parse options
|
||||
while getopts ":e:s:" opt; do
|
||||
|
@ -965,8 +968,8 @@ run_game() {
|
|||
|
||||
# Check for game argument
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Game file is required."
|
||||
echo "Usage: $0 --run [-e emulator] [-s system] game"
|
||||
log e "Game path is required."
|
||||
log i "Usage: $0 start [-e emulator] [-s system] game"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -981,6 +984,8 @@ run_game() {
|
|||
log d "System: \"$system\""
|
||||
|
||||
# Function to handle the %INJECT% placeholder
|
||||
# When %INJECT%=filename is found in the game command it will check for the existence of the file
|
||||
# If the file is found the "%INJECT%=file" will be replaced with the contents of the found file
|
||||
handle_inject_placeholder() {
|
||||
local cmd="$1"
|
||||
local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path
|
||||
|
@ -1086,7 +1091,7 @@ replace_emulator_placeholder() {
|
|||
find_system_commands() {
|
||||
local system_name=$system
|
||||
# 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']" "$es_systems" 2>/dev/null)
|
||||
|
||||
if [ -z "$system_section" ]; then
|
||||
log e "System not found: $system_name"
|
||||
|
|
Loading…
Reference in a new issue