Refactor directory paths

Preparation for upcoming changes to the game's directory structure
This commit is contained in:
the Sane 2021-03-13 09:59:28 -05:00 committed by GitHub
parent 8ee730bf35
commit d4e8298743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,13 +75,24 @@ conf_subdir="starcitizen-lug"
tmp_dir="$(mktemp -d --suffix=".lughelper")" tmp_dir="$(mktemp -d --suffix=".lughelper")"
trap 'rm -r "$tmp_dir"' EXIT trap 'rm -r "$tmp_dir"' EXIT
# The game's user subdirectory name ######## Game Directories #################################################
# The game's base directory name
sc_base_dir="StarCitizen"
# The default install location within a WINE prefix:
install_path="drive_c/Program Files/Roberts Space Industries/$sc_base_dir"
# The game's user subdirectory name (within the LIVE or PTU directories)
user_subdir_name="USER" user_subdir_name="USER"
# The location within the USER directory to which the game exports keybinds # The location within the USER directory to which the game exports keybinds
# ie. USER/Controls/Mappings
keybinds_export_path="Controls/Mappings" keybinds_export_path="Controls/Mappings"
dxvk_cache_file="StarCitizen.dxvk-cache" dxvk_cache_file="StarCitizen.dxvk-cache"
# Remaining directory paths are set at the end of the getdirs() function
###########################################################################
# Lutris wine runners directory # Lutris wine runners directory
runners_dir="$data_dir/lutris/runners/wine" runners_dir="$data_dir/lutris/runners/wine"
# URLs for downloading Lutris runners # URLs for downloading Lutris runners
@ -360,7 +371,7 @@ getdirs() {
fi fi
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")" game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
debug_print continue "Unexpected game path found in config file, ignoring." debug_print continue "Unexpected game path found in config file, ignoring."
game_path="" game_path=""
fi fi
@ -387,15 +398,15 @@ getdirs() {
# Get the game path # Get the game path
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
if [ -d "$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" ] && if [ -d "$wine_prefix/$install_path" ] &&
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then message question "Is this your Star Citizen game directory?\n\n$wine_prefix/$install_path"; then
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" game_path="$wine_prefix/$install_path"
else else
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" 2>/dev/null)"; do while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/$install_path" 2>/dev/null)"; do
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message warning "An unexpected error has occurred. The Helper is unable to proceed." message warning "An unexpected error has occurred. The Helper is unable to proceed."
return 1 return 1
elif [ "$(basename "$game_path")" != "StarCitizen" ]; then elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
message warning "You must select the Star Citizen base game directory.\n\nFor Example: prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" message warning "You must select the Star Citizen base game directory.\n\nFor Example: prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
else else
# All good or cancel # All good or cancel
@ -428,17 +439,17 @@ getdirs() {
# Get the game path # Get the game path
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
if [ -d "$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" ] && if [ -d "$wine_prefix/$install_path" ] &&
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then message question "Is this your Star Citizen game directory?\n\n$wine_prefix/$install_path"; then
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" game_path="$wine_prefix/$install_path"
else else
printf "\nEnter the full path to your Star Citizen installation directory (case sensitive)\n" printf "\nEnter the full path to your Star Citizen installation directory (case sensitive)\n"
printf "ie. /home/USER/Games/star-citizen/drive_c/Program Files/Roberts Space Industries/StarCitizen\n" printf "ie. /home/USER/Games/star-citizen/drive_c/Program Files/Roberts Space Industries/StarCitizen\n"
while read -rp ": " game_path; do while read -rp ": " game_path; do
if [ ! -d "$game_path" ]; then if [ ! -d "$game_path" ]; then
printf "That directory is invalid or does not exist. Please try again.\n\n" printf "That directory is invalid or does not exist. Please try again.\n\n"
elif [ "$(basename "$game_path")" != "StarCitizen" ]; then elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
printf "You must enter the full path to the directory named 'StarCitizen'\n\n" printf "You must enter the full path to the directory named '$sc_base_dir'\n\n"
else else
break break
fi fi
@ -452,10 +463,12 @@ getdirs() {
echo "$game_path" > "$conf_dir/$conf_subdir/$game_conf" echo "$game_path" > "$conf_dir/$conf_subdir/$game_conf"
fi fi
# Set some remaining directory paths # Set remaining directory paths
user_dir="$game_path/$live_or_ptu/$user_subdir_name" user_dir="$game_path/$live_or_ptu/$user_subdir_name"
keybinds_dir="$user_dir/$keybinds_export_path" keybinds_dir="$user_dir/$keybinds_export_path"
backup_path="$conf_dir/$conf_subdir" backup_path="$conf_dir/$conf_subdir"
shaders_dir="$user_dir/shaders"
dxvk_cache="$game_path/$live_or_ptu/$dxvk_cache_file"
} }
# Save exported keybinds, wipe the USER directory, and restore keybinds # Save exported keybinds, wipe the USER directory, and restore keybinds
@ -668,8 +681,6 @@ rm_shaders() {
return 0 return 0
fi fi
shaders_dir="$user_dir/shaders"
# Sanity check # Sanity check
if [ ! -d "$shaders_dir" ]; then if [ ! -d "$shaders_dir" ]; then
message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir" message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir"
@ -693,9 +704,7 @@ rm_dxvkcache() {
# or there was an error # or there was an error
return 0 return 0
fi fi
dxvk_cache="$game_path/$live_or_ptu/$dxvk_cache_file"
# Sanity check # Sanity check
if [ ! -f "$dxvk_cache" ]; then if [ ! -f "$dxvk_cache" ]; then
message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache" message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache"