#!/usr/bin/env bash
# Bottle только для JA3 (offline GOG installer + игра). Без Galaxy CEF.
set -euo pipefail
GOG_DIR="$(cd "$(dirname "$0")" && pwd)"
GAMES_DIR="$(cd "${GOG_DIR}/.." && pwd)"

# shellcheck source=config.sh
source "${GOG_DIR}/config.sh"
gog_swap_guard "${GOG_SWAP_MAX_MB:-400}" || exit 1
gog_disk_guard 10 || exit 1

if [[ ! -f "${GOG_DIR}/bottle.env" ]]; then
  echo "Сначала: Whisky → New Bottle → bash ${GOG_DIR}/create-bottle.sh GOG-Install"
  exit 1
fi

echo "=== Подготовка bottle для JA3 (без Galaxy) ==="
bash "${GOG_DIR}/setup-bottle.sh"
bash "${GOG_DIR}/install-dxvk.sh" 2>/dev/null || bash "${GAMES_DIR}/install-dxvk-macos.sh" 2>/dev/null || \
  echo "⚠️  DXVK не установлен — JA3 может не стартовать (D3D11). Повторите install-dxvk."

echo ""
echo "OK. Дальше:"
echo "  bash ${GOG_DIR}/install-ja3-offline.sh ~/Downloads/setup_jagged_alliance_3_*.exe"
