@echo off
REM halo configuration
set TARGET_FILE=main\textures\BaboHalo.tga
set SOURCE_DIR=main\textures\halos\
set SOURCE_FILE=Classic.tga
set OBJ_NAME=Classic Pro Client
REM run-time configuration
REM construct babo path
set BABO_PATH=%~dp0..\..\
REM switch drive
%~d0
REM change directory
cd %BABO_PATH%
REM set text color
color 0c
REM clear screen
cls
echo Babo Violent 2 Prozac Mod (halo switcher)
echo.
REM check for halos folder
if exist "%BABO_PATH%%SOURCE_DIR%" goto check_source
echo Halos folder not found.
goto suggestion
:check_source
REM check for halo itself
if exist "%BABO_PATH%%SOURCE_DIR%%SOURCE_FILE%" goto check_target
:source_not_found
echo Prozac style halo texture file (%BABO_PATH%%SOURCE_DIR%%SOURCE_FILE%) not found.
goto suggestion
:check_target
REM if working halo texture already exists,
REM there's check if it is already Prozac style
if not exist "%BABO_PATH%%TARGET_FILE%" goto copy_file
fc "%BABO_PATH%%TARGET_FILE%" "%BABO_PATH%%SOURCE_DIR%%SOURCE_FILE%" > nul
if errorlevel 1 goto copy_file
REM pring error message
echo You're already using %OBJ_NAME% halos.
echo.
pause
goto self_rename
:copy_file
echo CAUTION:
echo You're going to switch halos to %OBJ_NAME%.
echo You may cancel switching by closing this window, if you've changed your mind.
echo.
echo Press any key to set %OBJ_NAME% halos...
pause>nul
REM clear file attributes
attrib -H -S -R "%BABO_PATH%%TARGET_FILE%" > nul
REM trying xcopy
xcopy "%BABO_PATH%%SOURCE_DIR%%SOURCE_FILE%" "%BABO_PATH%%TARGET_FILE%" /V /Q /G /H /R /Y
echo.
REM 9009 = "file not found"
if errorlevel 9009 goto use_copy
REM 1 = No files were found to copy.
if errorlevel 1 goto source_not_found
REM 2 = The user pressed CTRL+C to terminate xcopy.
if not errorlevel 2 goto is_other_error
echo You have terminated %OBJ_NAME% halos installation!
echo.
pause
goto term
:is_other_error
if not errorlevel 0 goto xcopy_error
echo %OBJ_NAME% halos is successfully set!
goto new_halos
:xcopy_error
echo %errorlevel%
echo.
echo Unexpected error (%errorlevel%) occured.
echo Please make screenshots and contact <ketamine@warlabs.ru>
echo.
pause
goto term
:use_copy
REM this routine is using 'copy' command to replace halo file
REM sadly, copy doesn't set errorlevel, so we'll never know if it was successful
echo Note: Xcopy utility not found.
echo Nothing to be worried for, but we'll use old school 'copy' command.
echo.
REM use plain copy with every possibly useful switch set
copy /B /D /V /Y "%BABO_PATH%%SOURCE_DIR%%SOURCE_FILE%" "%BABO_PATH%%TARGET_FILE%" > nul
echo.
echo If you see "1 file(s) copied" string above, everything is fine.
goto new_halos
:new_halos
echo Run bv2launcher.exe (the one with red icon) to check your new halos!
echo.
pause
goto self_rename
:self_rename
REM rename self just before exit
REM nothing below next line will be executed
REM return to own folder
cd Customization\Halos
REM determine own name without extension
set SELF_NAME=%~n0
REM search for files with "(Active)" in their name
REM call :for_each
for %%f in (*Active?.cmd) do call :for_each "%%f"
REM wiping out "(Active)" tag from own filename
set NEW_NAME=%SELF_NAME: (Active)=%
color 07
REM no need to rename if already tagged
if not "%NEW_NAME%"=="%SELF_NAME%" goto :eof
REM hard way, because 'rename' bugs when trying to rename oneself
copy %0 "%SELF_NAME% (Active).cmd">nul
del %0>nul
REM "The batch file cannot be found."
goto :term
REM start :for_each
:for_each
REM skip empty rows
if [%1]==[] goto :eof
REM skip self
set TEST_NAME="%~n1"
if %TEST_NAME%==%SELF_NAME% goto :eof
REM fix name
set NEW_NAME=%TEST_NAME: (Active)=%.cmd
REM rename file
ren %1 %NEW_NAME%>nul
REM skipping to the end of file to jump into next iteration
goto :eof
REM end :for_each
:suggestion
echo.
echo Probably you should download fresh Prozac copy from http://prozac.warlabs.ru.
echo Unpack it into different directory and copy your config file (main\bv2.cfg).
echo.
pause
goto :term
:term
color 07