@echo off
setlocal EnableExtensions
cd /d "%~dp0"
title iikarachoko CN Patch Installer v9

echo ==============================================================
echo iikarachoko CN Patch Installer v9 - forced xiaolai font
echo ==============================================================
echo This patch does not require Python or 7-Zip.
echo It uses Windows PowerShell to create iikarachoko_cn.exe.
echo.

if not exist "install_cn_patch.ps1" (
    echo [ERROR] install_cn_patch.ps1 was not found. Extract the patch zip first.
    echo.
    pause
    exit /b 1
)

if not exist "patch_payload.bin" (
    echo [ERROR] patch_payload.bin was not found. Extract the patch zip first.
    echo.
    pause
    exit /b 1
)

where powershell.exe >nul 2>nul
if errorlevel 1 (
    echo [ERROR] powershell.exe was not found.
    echo This installer needs the Windows built-in PowerShell.
    echo.
    pause
    exit /b 1
)

echo Starting installer...
echo.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0install_cn_patch.ps1" %*
set "RC=%errorlevel%"

echo.
if "%RC%"=="0" (
    echo [DONE] Patch finished.
) else (
    echo [FAILED] Patch failed. Error code: %RC%
    echo Please send the text above to the patch maker.
)
echo.
pause
exit /b %RC%
