@echo off
chcp 65001 >nul
title ComfyUI Tam Paket Kurulum - Ana Menu

:menu
cls
echo.
echo  ================================================================
echo                 ComfyUI TAM PAKET KURULUM SiHiRBAZI
echo                 RTX 4090 - Ticari + NSFW + Video
echo  ================================================================
echo.
echo   Bir islem secin:
echo.
echo   [1] TAM OTOMATiK KURULUM (tum adimlari sirasiyla calistirir)
echo       yaklasik 2-4 saat, 250 GB disk
echo.
echo   --- VEYA ADIMLARI TEK TEK CALISTIRIN ---
echo.
echo   [2] Sadece ComfyUI + Custom Nodes kur (adim 1)
echo   [3] Modelleri indir (adim 2)     - yaklasik 200 GB
echo   [4] LoRA egitim araci (Kohya_ss) - yaklasik 20 GB
echo   [5] ComfyUI'yi baslat
echo   [6] Guncelle (ComfyUI + nodes)
echo.
echo   [7] On gereksinim kontrolu (Git, Python, NVIDIA)
echo   [8] Cikis
echo.
set /p choice="Seciminiz (1-8): "

if "%choice%"=="1" goto full_install
if "%choice%"=="2" call "%~dp01_ANA_KURULUM.bat" && goto menu
if "%choice%"=="3" call "%~dp02_MODEL_INDIR.bat" && goto menu
if "%choice%"=="4" call "%~dp04_LORA_EGITIM_KURULUM.bat" && goto menu
if "%choice%"=="5" call "%~dp03_COMFYUI_BASLAT.bat" && goto menu
if "%choice%"=="6" call "%~dp05_GUNCELLE.bat" && goto menu
if "%choice%"=="7" goto precheck
if "%choice%"=="8" exit /b 0
goto menu

:full_install
cls
echo.
echo  Tam otomatik kurulum baslayacak. Bu 2-4 saat surebilir.
echo  Son seferlik onay: Devam edilsin mi? (E/H)
set /p confirm=""
if /i not "%confirm%"=="E" goto menu

call "%~dp01_ANA_KURULUM.bat"
call "%~dp02_MODEL_INDIR.bat"
call "%~dp04_LORA_EGITIM_KURULUM.bat"
echo.
echo  ==== TUM KURULUM TAMAMLANDI ====
echo  Baslatmak icin: 3_COMFYUI_BASLAT.bat
pause
goto menu

:precheck
cls
echo.
echo  ============ ON GEREKSiNiM KONTROLU ============
echo.

where git >nul 2>&1
if %errorLevel%==0 (echo  [OK]   Git yuklu) else (echo  [HATA] Git bulunamadi - https://git-scm.com/download/win)

where python >nul 2>&1
if %errorLevel%==0 (
    echo  [OK]   Python yuklu:
    python --version
) else (
    echo  [HATA] Python bulunamadi - https://www.python.org/downloads/release/python-31011/
    echo         Kurulumda "Add Python to PATH" isaretleyin
)

where nvidia-smi >nul 2>&1
if %errorLevel%==0 (
    echo  [OK]   NVIDIA surucusu yuklu
    nvidia-smi --query-gpu=name,driver_version,memory.total --format=csv
) else (
    echo  [HATA] NVIDIA surucusu bulunamadi
)

where aria2c >nul 2>&1
if %errorLevel%==0 (
    echo  [OK]   aria2c yuklu (hizli indirme)
) else (
    echo  [ONERI] aria2c yok - indirme yavas olacak
    echo          https://aria2.github.io/ adresinden indirip PATH'e ekleyin
)

echo.
echo  D: surucusu kontrolu...
if exist "D:\" (echo  [OK]   D: surucusu mevcut) else (echo  [HATA] D: surucusu yok!)

echo.
pause
goto menu
