mirror of
https://github.com/the-sane/lug-helper.git
synced 2024-12-29 07:44:19 +00:00
Improve getdirs: Try to detect the game directory
This commit is contained in:
parent
2cdef0f1c4
commit
61e14ed4de
@ -35,13 +35,21 @@ wine_conf="winedir.conf"
|
|||||||
game_conf="gamedir.conf"
|
game_conf="gamedir.conf"
|
||||||
backup_conf="backupdir.conf"
|
backup_conf="backupdir.conf"
|
||||||
|
|
||||||
# Use the XDG config directory if defined
|
# Use XDG base directories if defined
|
||||||
if [ -z "$XDG_CONFIG_HOME" ]; then
|
if [ -z "$XDG_CONFIG_HOME" ]; then
|
||||||
conf_dir="$HOME/.config"
|
conf_dir="$HOME/.config"
|
||||||
else
|
else
|
||||||
conf_dir="$XDG_CONFIG_HOME"
|
conf_dir="$XDG_CONFIG_HOME"
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$XDG_DATA_HOME" ]; then
|
||||||
|
data_dir="$HOME/.local/share"
|
||||||
|
else
|
||||||
|
data_dir="$XDG_DATA_HOME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# .config subdirectory
|
||||||
conf_subdir="starcitizen-lug"
|
conf_subdir="starcitizen-lug"
|
||||||
|
|
||||||
tmp_dir="/tmp"
|
tmp_dir="/tmp"
|
||||||
|
|
||||||
# The game's user subdirectory name
|
# The game's user subdirectory name
|
||||||
@ -52,11 +60,7 @@ keybinds_export_path="Controls/Mappings"
|
|||||||
dxvk_cache_file="StarCitizen.dxvk-cache"
|
dxvk_cache_file="StarCitizen.dxvk-cache"
|
||||||
|
|
||||||
# Lutris wine runners directory
|
# Lutris wine runners directory
|
||||||
if [ -z "$XDG_DATA_HOME" ]; then
|
runners_dir="$data_dir/lutris/runners/wine"
|
||||||
runner_dir="$HOME/.local/share/lutris/runners/wine"
|
|
||||||
else
|
|
||||||
runner_dir="$XDG_DATA_HOME/lutris/runners/wine"
|
|
||||||
fi
|
|
||||||
# URLs for downloading Lutris runners
|
# URLs for downloading Lutris runners
|
||||||
# Elements in this array must be added in quoted pairs of: "description" "url"
|
# Elements in this array must be added in quoted pairs of: "description" "url"
|
||||||
# The first string in the pair is expected to contain the runner description
|
# The first string in the pair is expected to contain the runner description
|
||||||
@ -332,11 +336,12 @@ getdirs() {
|
|||||||
# If we don't have the directory paths we need yet,
|
# If we don't have the directory paths we need yet,
|
||||||
# ask the user to provide them
|
# ask the user to provide them
|
||||||
if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then
|
if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then
|
||||||
message info "You will now be asked to provide some directories needed by the helper.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/"
|
message info "You will now be asked to provide some directories needed by the helper.\n\nThey will be saved for future use in:\n$conf_dir/$conf_subdir/"
|
||||||
if [ "$has_zen" -eq 1 ]; then
|
if [ "$has_zen" -eq 1 ]; then
|
||||||
|
# Using Zenity file selection menus
|
||||||
# Get the wine prefix directory
|
# Get the wine prefix directory
|
||||||
if [ -z "$wine_prefix" ]; then
|
if [ -z "$wine_prefix" ]; then
|
||||||
wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine" 2>/dev/null)"
|
wine_prefix="$(zenity --file-selection --directory --title="Select your Star Citizen WINE prefix directory" --filename="$HOME/.wine" 2>/dev/null)"
|
||||||
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
|
||||||
@ -349,6 +354,10 @@ 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" ] &&
|
||||||
|
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then
|
||||||
|
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||||
|
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/drive_c/Program Files/Roberts Space Industries/StarCitizen" 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."
|
||||||
@ -367,6 +376,7 @@ getdirs() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the backup directory
|
# Get the backup directory
|
||||||
if [ -z "$backup_path" ]; then
|
if [ -z "$backup_path" ]; then
|
||||||
@ -389,10 +399,11 @@ getdirs() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# No Zenity, use terminal-based menus
|
||||||
clear
|
clear
|
||||||
# Get the wine prefix directory
|
# Get the wine prefix directory
|
||||||
if [ -z "$wine_prefix" ]; then
|
if [ -z "$wine_prefix" ]; then
|
||||||
echo -e "Enter the full path to your WINE prefix directory (case sensitive)"
|
echo -e "Enter the full path to your Star Citizen WINE prefix directory (case sensitive)"
|
||||||
echo -e "ie. /home/USER/.wine/"
|
echo -e "ie. /home/USER/.wine/"
|
||||||
while read -rp ": " wine_prefix; do
|
while read -rp ": " wine_prefix; do
|
||||||
if [ ! -d "$wine_prefix" ]; then
|
if [ ! -d "$wine_prefix" ]; then
|
||||||
@ -401,9 +412,14 @@ getdirs() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# 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" ] &&
|
||||||
|
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then
|
||||||
|
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||||
|
else
|
||||||
echo -e "\nEnter the full path to your Star Citizen installation directory\n(case sensitive)"
|
echo -e "\nEnter the full path to your Star Citizen installation directory\n(case sensitive)"
|
||||||
echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/StarCitizen/"
|
echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/StarCitizen/"
|
||||||
while read -rp ": " game_path; do
|
while read -rp ": " game_path; do
|
||||||
@ -416,6 +432,7 @@ getdirs() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the backup directory
|
# Get the backup directory
|
||||||
if [ -z "$backup_path" ]; then
|
if [ -z "$backup_path" ]; then
|
||||||
@ -432,7 +449,6 @@ getdirs() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Save the paths for later use
|
# Save the paths for later use
|
||||||
echo "$wine_prefix" > "$conf_dir/$conf_subdir/$wine_conf"
|
echo "$wine_prefix" > "$conf_dir/$conf_subdir/$wine_conf"
|
||||||
@ -722,8 +738,8 @@ runner_select_delete() {
|
|||||||
unset menu_options
|
unset menu_options
|
||||||
unset menu_actions
|
unset menu_actions
|
||||||
|
|
||||||
# Create an array containing all directories in the runner_dir
|
# Create an array containing all directories in the runners_dir
|
||||||
for runners_list in "$runner_dir"/*; do
|
for runners_list in "$runners_dir"/*; do
|
||||||
if [ -d "$runners_list" ]; then
|
if [ -d "$runners_list" ]; then
|
||||||
installed_runners+=("$runners_list")
|
installed_runners+=("$runners_list")
|
||||||
fi
|
fi
|
||||||
@ -808,14 +824,14 @@ runner_install() {
|
|||||||
case "$first_filepath" in
|
case "$first_filepath" in
|
||||||
# If the files in the archive begin with ./ there is no subdirectory
|
# If the files in the archive begin with ./ there is no subdirectory
|
||||||
./*)
|
./*)
|
||||||
debug_echo continue "Installing runner into $runner_dir/$runner_name..."
|
debug_echo continue "Installing runner into $runners_dir/$runner_name..."
|
||||||
mkdir -p "$runner_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runner_dir/$runner_name"
|
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name"
|
||||||
lutris_needs_restart="true"
|
lutris_needs_restart="true"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Runners with a subdirectory in the archive
|
# Runners with a subdirectory in the archive
|
||||||
debug_echo continue "Installing runner into $runner_dir..."
|
debug_echo continue "Installing runner into $runners_dir..."
|
||||||
mkdir -p "$runner_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runner_dir"
|
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir"
|
||||||
lutris_needs_restart="true"
|
lutris_needs_restart="true"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -884,7 +900,7 @@ runner_select_install() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Add the runner names to the menu
|
# Add the runner names to the menu
|
||||||
if [ -d "$runner_dir/$runner_name" ]; then
|
if [ -d "$runners_dir/$runner_name" ]; then
|
||||||
menu_options+=("$runner_name [installed]")
|
menu_options+=("$runner_name [installed]")
|
||||||
else
|
else
|
||||||
menu_options+=("$runner_name")
|
menu_options+=("$runner_name")
|
||||||
@ -919,6 +935,10 @@ runner_manage() {
|
|||||||
message info "Lutris does not appear to be installed."
|
message info "Lutris does not appear to be installed."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
if [ ! -d "$runners_dir" ]; then
|
||||||
|
message info "Lutris runners directory not found. Unable to continue.\n\n$runners_dir"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# The runner management menu will loop until the user cancels
|
# The runner management menu will loop until the user cancels
|
||||||
managing_runners="true"
|
managing_runners="true"
|
||||||
|
Loading…
Reference in New Issue
Block a user