@echo off
setlocal EnableExtensions DisableDelayedExpansion
title CSS Taiwan Noto Sans TC HUD - Safe Install Preview

set "SOURCE=%~dp0"
set "GAME_ROOT=%ProgramFiles(x86)%\Steam\steamapps\common\Counter-Strike Source"
set "CUSTOM_ROOT=%GAME_ROOT%\cstrike\custom"
set "DEST=%CUSTOM_ROOT%\css_taiwan_hud"

echo ================================================================
echo CSS Taiwan Noto Sans TC HUD - INSTALLATION PREVIEW
echo ================================================================
echo.
echo Source:
echo   %SOURCE%
echo.
echo Destination:
echo   %DEST%
echo.
echo Safety summary:
echo   - No network downloads or uploads
echo   - No registry changes
echo   - No game launch
echo   - No deletion, folder mirroring, or cleanup
echo   - Copies only the HUD files shown below
echo.

if not exist "%SOURCE%resource\ClientScheme.res" goto missing_source
if not exist "%SOURCE%resource\NotoSansTC-CSS.ttf" goto missing_source
if not exist "%GAME_ROOT%\cstrike" goto missing_game

echo Files that will be copied:
for /r "%SOURCE%" %%F in (*) do (
  if /I not "%%~nxF"=="INSTALL-WINDOWS.txt" if /I not "%%~nxF"=="INSTALL-WINDOWS.bat" echo   %%F
)
echo.
echo NO FILES HAVE BEEN COPIED YET.
echo A Windows Yes/No confirmation dialog will open now.
echo.

powershell.exe -NoProfile -Command "Add-Type -AssemblyName System.Windows.Forms; $answer = [System.Windows.Forms.MessageBox]::Show('Copy the displayed CSS Taiwan HUD files to the default Counter-Strike Source custom folder? This script does not download, upload, delete files, or modify the registry.', 'CSS Taiwan HUD installation confirmation', [System.Windows.Forms.MessageBoxButtons]::YesNo, [System.Windows.Forms.MessageBoxIcon]::Question); if ($answer -eq [System.Windows.Forms.DialogResult]::Yes) { exit 0 } else { exit 1 }"
if errorlevel 1 goto cancelled

echo Copying approved files...
robocopy "%SOURCE%" "%DEST%" /E /R:1 /W:1 /COPY:DAT /DCOPY:DAT /XF "INSTALL-WINDOWS.txt" "INSTALL-WINDOWS.bat"
set "COPY_RESULT=%ERRORLEVEL%"
if %COPY_RESULT% GEQ 8 goto failed

echo.
echo Installation completed successfully.
echo Final check:
echo   %DEST%\resource\ClientScheme.res
echo.
echo Fully restart Counter-Strike: Source to apply the HUD.
pause
exit /b 0

:cancelled
echo.
echo Installation cancelled. No files were copied.
pause
exit /b 1

:missing_source
echo ERROR: Required HUD source files are missing.
echo Keep this renamed batch file inside the extracted css_taiwan_hud folder.
echo Nothing was copied.
pause
exit /b 2

:missing_game
echo ERROR: The default Steam game folder was not found:
echo   %GAME_ROOT%
echo.
echo Nothing was copied. Use the manual instructions in README.md for a Steam
echo library stored on another drive or in another folder.
pause
exit /b 3

:failed
echo.
echo ERROR: Windows could not copy the HUD files. Robocopy code: %COPY_RESULT%
echo Nothing was deleted. If access was denied, right-click this batch file
echo and choose Run as administrator, or follow README.md manually.
pause
exit /b %COPY_RESULT%
