@echo off
echo ============================================
echo  Unlimited Fuel System v1.2.1 (HUD FIX)
echo  Easy Installer by Izzy86
echo ============================================
echo.

:: Detect GTA V folder
set "GTA="
if exist "G:\Steam\steamapps\common\Grand Theft Auto V\GTA5.exe" (
    set "GTA=G:\Steam\steamapps\common\Grand Theft Auto V"
)
if "%GTA%"=="" (
    for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\Rockstar Games\Grand Theft Auto V" /v "InstallFolder" 2^>nul ^| findstr "InstallFolder"') do (
        for /f "tokens=2*" %%b in ("%%a") do set "GTA=%%c"
    )
)
if "%GTA%"=="" (
    echo [!] Could not detect GTA V folder automatically.
    set /p GTA="Enter your GTA V folder path: "
)

echo [OK] GTA V folder: %GTA%
echo.

:: Copy ASI
echo [1/3] Installing FuelAndNozzle.asi...
copy /Y "FuelAndNozzle.asi" "%GTA%\FuelAndNozzle.asi" >nul
if errorlevel 1 (
    echo [ERROR] Failed to copy ASI. Run as Administrator?
    pause
    exit /b 1
)
echo      Done.

:: Copy textures (won't overwrite user's saved INI in game root)
echo [2/3] Installing textures and assets...
if not exist "%GTA%\FuelAndNozzle" mkdir "%GTA%\FuelAndNozzle"
xcopy /Y /Q "FuelAndNozzle\*.png" "%GTA%\FuelAndNozzle\" >nul
xcopy /Y /Q "FuelAndNozzle\*.wav" "%GTA%\FuelAndNozzle\" >nul
echo      Done. (%GTA%\FuelAndNozzle\)

:: Copy default INI only if user doesn't have one yet
echo [3/3] Checking settings...
if not exist "%GTA%\FuelAndNozzle\settings.ini" (
    copy /Y "FuelAndNozzle\settings.ini" "%GTA%\FuelAndNozzle\settings.ini" >nul
    echo      Default settings.ini created.
) else (
    echo      Existing settings.ini preserved (not overwritten).
)
if not exist "%GTA%\FuelAndNozzle\FuelAndNozzle.ini" (
    copy /Y "FuelAndNozzle\FuelAndNozzle.ini" "%GTA%\FuelAndNozzle\FuelAndNozzle.ini" >nul
    echo      Default FuelAndNozzle.ini created.
) else (
    echo      Existing FuelAndNozzle.ini preserved (not overwritten).
)

echo.
echo ============================================
echo  Installation complete!
echo  Your saved HUD style, positions, and
echo  settings are preserved.
echo ============================================
echo.
echo  Press INSERT in-game to open the menu.
echo.
pause
