#!/usr/bin/env bash
# Реестр GOG для JA3 (innoextract не запускает Inno-скрипт с ключами).
set -euo pipefail
GOG_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=config.sh
source "${GOG_DIR}/config.sh"

GAME_ID='1556263729'
JA3_WIN='C:\GOG Games\Jagged Alliance 3'
JA3_EXE="${JA3_WIN}\\JA3.exe"
KEY="HKLM\\Software\\WOW6432Node\\GOG.com\\Games\\${GAME_ID}"

gog_wine_check
export_wine_env_gog

"${WINE64}" reg add "${KEY}" /v gameName /t REG_SZ /d 'Jagged Alliance 3' /f
"${WINE64}" reg add "${KEY}" /v exe /t REG_SZ /d 'JA3.exe' /f
"${WINE64}" reg add "${KEY}" /v path /t REG_SZ /d "${JA3_WIN}\\" /f
"${WINE64}" reg add "${KEY}" /v startMenu /t REG_SZ /d 'Jagged Alliance 3\' /f
"${WINE64}" reg add "${KEY}" /v version /t REG_SZ /d '1.5.2' /f
"${WINE64}" reg add "${KEY}" /v language /t REG_SZ /d 'English' /f
"${WINE64}" reg add "${KEY}" /v launchParam /t REG_SZ /d '' /f
"${WINE64}" reg add 'HKLM\Software\WOW6432Node\GOG.com\DefaultPackPath' /ve /t REG_SZ /d 'C:\GOG Games' /f 2>/dev/null || true

bash "${GOG_DIR}/register-galaxy-registry.sh" 2>/dev/null || true

echo "OK: GOG registry → ${KEY}"
