@echo off
title Nostalji Yama

echo.
echo Nostalji Yama - Install
echo.

set "GAME_PATH="
if exist "%PROGRAMFILES(X86)%\Steam\steamapps\common\Ship Simulator Extremes" set "GAME_PATH=%PROGRAMFILES(X86)%\Steam\steamapps\common\Ship Simulator Extremes"
if exist "%PROGRAMFILES%\Steam\steamapps\common\Ship Simulator Extremes" set "GAME_PATH=%PROGRAMFILES%\Steam\steamapps\common\Ship Simulator Extremes"
if exist "%PROGRAMFILES(X86)%\Ship Simulator Extremes" set "GAME_PATH=%PROGRAMFILES(X86)%\Ship Simulator Extremes"
if exist "%PROGRAMFILES%\Ship Simulator Extremes" set "GAME_PATH=%PROGRAMFILES%\Ship Simulator Extremes"

if "%GAME_PATH%"=="" (
    echo ERROR: Game not found
    pause
    exit /b 1
)

echo Game found: %GAME_PATH%
echo.

echo Step 1: Backup
if exist "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\language\Language_EN.xml" (
    if not exist "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\language\Language_EN.xml.bak" (
        copy /Y "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\language\Language_EN.xml" "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\language\Language_EN.xml.bak" >nul
    )
)

for /r "%GAME_PATH%\Projects\ShipSimExtremes\Data\Missions" %%F in (*.EN) do if not exist "%%F.bak" copy /Y "%%F" "%%F.bak" >nul
echo Backup done
echo.

echo Step 2: Copy files
copy /Y "%~dp0Language_EN.xml" "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\language\" >nul
xcopy /E /I /Y "%~dp0Missions" "%GAME_PATH%\Projects\ShipSimExtremes\Data\Missions" >nul

if exist "%~dp0imagesets\MainMenu.png" (
    if not exist "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\imagesets\MainMenu.png.bak" (
        copy /Y "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\imagesets\MainMenu.png" "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\imagesets\MainMenu.png.bak" >nul
    )
    copy /Y "%~dp0imagesets\MainMenu.png" "%GAME_PATH%\Projects\ShipSimExtremes\Data\GUI\imagesets\" >nul
)
echo Copy done
echo.

echo Installation complete!
echo.
echo Nostalji Yama SS Extremes installed!
echo.
pause
