Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Merge pull request #569 from rockerbacon/fix-gameprefix-location
Browse files Browse the repository at this point in the history
Fix loading prefix information when game does not have a prefix
  • Loading branch information
rockerbacon authored Jan 27, 2024
2 parents a33cdae + c976f45 commit 9a6ddd8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
41 changes: 26 additions & 15 deletions step/clean_game_prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -32,9 +32,7 @@ function delete_existing_prefix() {
fi
}

function clean_game_prefix() {
delete_existing_prefix

function create_new_prefix() {
confirmation=$( \
"$dialog" \
radio \
Expand All @@ -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

6 changes: 4 additions & 2 deletions step/load_gameinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=''

9 changes: 7 additions & 2 deletions utils/protontricks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a6ddd8

Please sign in to comment.