diff --git a/step/clean_game_prefix.sh b/step/clean_game_prefix.sh index 56096fc..d68af85 100644 --- a/step/clean_game_prefix.sh +++ b/step/clean_game_prefix.sh @@ -12,7 +12,7 @@ EOF create_clean_prefix_text=$( \ cat << EOF -Your existing prefix was deleted. Now you need to create a clean one: +Now you need to create a clean prefix: 1. On Steam: right click the game > Properties > Compatibility 2. Check the option "Force the use of a specific Steam Play compatibility tool" @@ -32,9 +32,7 @@ function delete_existing_prefix() { fi } -function clean_game_prefix() { - delete_existing_prefix - +function create_new_prefix() { confirmation=$( \ "$dialog" \ radio \ @@ -46,23 +44,36 @@ function clean_game_prefix() { echo "$confirmation" } -confirm_cleaning=$("$dialog" question "$confirm_cleaning_text") -if [ "$confirm_cleaning" == "0" ]; then - cleaning_status=$(clean_game_prefix) - if [ "$cleaning_status" != "0" ]; then - log_error "installation cancelled by the user" - exit 1 +function load_prefix_locations() { + game_prefix=$("$utils/protontricks.sh" get-prefix "$game_appid") + if [ -n "$game_prefix" ]; then + game_compatdata=$(dirname "$game_prefix") fi +} - log_info "user confirmed prefix setup" -else - log_info "proceeding with existing prefix" +load_prefix_locations +if [ -n "$game_prefix" ]; then + confirm_cleaning=$("$dialog" question "$confirm_cleaning_text") + if [ "$confirm_cleaning" == "0" ]; then + delete_existing_prefix + else + log_info "proceeding with existing prefix" + fi +fi + +confirm_new_prefix=$(create_new_prefix) +if [ "$confirm_new_prefix" != "0" ]; then + log_error "installation cancelled by the user" + exit 1 fi +log_info "user confirmed prefix setup" -if [ ! -d "$game_prefix" ]; then +load_prefix_locations +if [ -z "$game_prefix" ]; then + log_error "no prefix found" "$dialog" \ errorbox \ - "A prefix for the selected game could not be found.\nMake sure you have followed the instructions\non cleaning your prefix" + "A prefix for the selected game could not be found.\nMake sure you have followed the instructions\non creating a clean prefix" exit 1 fi diff --git a/step/load_gameinfo.sh b/step/load_gameinfo.sh index 4a2300f..c2c5b77 100644 --- a/step/load_gameinfo.sh +++ b/step/load_gameinfo.sh @@ -28,7 +28,9 @@ if [ ! -d "$steam_library" ]; then exit 1 fi -game_prefix=$("$utils/protontricks.sh" get-prefix "$game_appid") -game_compatdata=$(dirname "$game_prefix") game_installation="$steam_library/steamapps/common/$game_steam_subdirectory" +# defer loading these variables to step/clean_game_prefix.sh +game_prefix='' +game_compatdata='' + diff --git a/utils/protontricks.sh b/utils/protontricks.sh index 459f594..bd2f296 100755 --- a/utils/protontricks.sh +++ b/utils/protontricks.sh @@ -47,8 +47,13 @@ function apply() { } function get_prefix() { - do_protontricks -c 'echo $WINEPREFIX' "$1" - return $? + prefix=$( \ + do_protontricks -c 'echo $WINEPREFIX' "$1" 2>/dev/null || \ + true \ + ) + if [ -d "$prefix" ]; then + echo "$prefix" + fi } action=$1