mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-03-06 14:27:48 +00:00
RUN_GAME: code prettyfication
This commit is contained in:
parent
24b35b7175
commit
51485497ae
|
@ -895,9 +895,10 @@ start_retrodeck() {
|
||||||
find_emulator() {
|
find_emulator() {
|
||||||
local emulator_name=$1
|
local emulator_name=$1
|
||||||
local found_path=""
|
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
|
# 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
|
if [ -z "$emulator_section" ]; then
|
||||||
log e "Emulator not found: $emulator_name"
|
log e "Emulator not found: $emulator_name"
|
||||||
|
@ -938,13 +939,15 @@ find_emulator() {
|
||||||
# TODO: add the logic of alt emulator and default emulator
|
# TODO: add the logic of alt emulator and default emulator
|
||||||
|
|
||||||
run_game() {
|
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
|
# Initialize variables
|
||||||
emulator=""
|
emulator=""
|
||||||
system=""
|
system=""
|
||||||
|
es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml"
|
||||||
# Path to the es_systems.xml file
|
|
||||||
xml_file="/app/share/es-de/resources/systems/linux/es_systems.xml"
|
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
while getopts ":e:s:" opt; do
|
while getopts ":e:s:" opt; do
|
||||||
|
@ -965,8 +968,8 @@ run_game() {
|
||||||
|
|
||||||
# Check for game argument
|
# Check for game argument
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "Error: Game file is required."
|
log e "Game path is required."
|
||||||
echo "Usage: $0 --run [-e emulator] [-s system] game"
|
log i "Usage: $0 start [-e emulator] [-s system] game"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -980,8 +983,10 @@ run_game() {
|
||||||
log d "Game: \"$game\""
|
log d "Game: \"$game\""
|
||||||
log d "System: \"$system\""
|
log d "System: \"$system\""
|
||||||
|
|
||||||
# Function to handle the %INJECT% placeholder
|
# Function to handle the %INJECT% placeholder
|
||||||
handle_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 cmd="$1"
|
||||||
local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path
|
local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path
|
||||||
|
|
||||||
|
@ -1019,11 +1024,11 @@ handle_inject_placeholder() {
|
||||||
|
|
||||||
log d "Returning the command with injected content: $cmd"
|
log d "Returning the command with injected content: $cmd"
|
||||||
echo "$cmd"
|
echo "$cmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator
|
# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator
|
||||||
replace_emulator_placeholder() {
|
replace_emulator_placeholder() {
|
||||||
local placeholder=$1
|
local placeholder=$1
|
||||||
# Extract emulator name from placeholder without changing case
|
# Extract emulator name from placeholder without changing case
|
||||||
local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_
|
local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_
|
||||||
|
@ -1037,7 +1042,7 @@ replace_emulator_placeholder() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "$emulator_exec"
|
echo "$emulator_exec"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to substitute the placeholders
|
# Function to substitute the placeholders
|
||||||
substitute_placeholders() {
|
substitute_placeholders() {
|
||||||
|
@ -1086,7 +1091,7 @@ replace_emulator_placeholder() {
|
||||||
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']" "$es_systems" 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"
|
||||||
|
|
Loading…
Reference in a new issue