#!/usr/bin/env bash
# Launch x64dbg inside FIFA 17's UMU/Proton prefix.
set -euo pipefail

x64dbg_root="${OPENFUT_X64DBG_ROOT:-/home/alex/Games/x64dbg}"
wine_prefix="${OPENFUT_FIFA17_WINEPREFIX:-/home/alex/Games/umu/fifa17}"
proton_path="${OPENFUT_FIFA17_PROTONPATH:-UMU-Proton-10.0-4}"
debugger="${x64dbg_root}/release/x64/x64dbg-unsigned.exe"

[[ -f "$debugger" ]] || {
  printf 'ERROR: x64dbg executable not found: %s\n' "$debugger" >&2
  exit 1
}
command -v umu-run >/dev/null || {
  printf 'ERROR: umu-run is required\n' >&2
  exit 1
}

cd "${x64dbg_root}/release/x64"
exec env \
  GAMEID=fifa17 \
  PROTONPATH="$proton_path" \
  WINEPREFIX="$wine_prefix" \
  QT_OPENGL=desktop \
  umu-run "$debugger" "$@"
