@ECHO off
cls

If exist NewData goto Check
echo Error: Install files not found.
echo.
echo Please ensure that you have the ffur2007 directory
echo extracted with subfolders intact and that all 
echo needed files are in ffur2007\NewData.
goto end

:Check
If not exist ..\Res\DTA\HWTL\Data.pbo echo ERROR: ..\Res\DTA\HWTL\Data.pbo not found!
If not exist ..\Res\DTA\HWTL\Data.pbo goto end

If not exist ..\Res\DTA\HWTL\Data3D.pbo echo ERROR: ..\Res\DTA\HWTL\Data3D.pbo not found!
If not exist ..\Res\DTA\HWTL\Data3D.pbo goto end

if not "%os%" =="Windows_NT" goto OSerr

color 0A
echo This will install the ffur2007 Replacement Pack.
echo None of the original OFP files will be modified.
echo.
echo Before proceeding, please make sure that you have
echo at least 400MB free space on this drive.
echo.
echo This installer is for users that have HWTL enabled,
echo if you do not have HWTL then please use the NO_HWTL .bat
echo.
echo.
echo Thanks to Kegety, Mikero, and Llauma 
echo for installer programs.
echo.

echo Press any key to continue or ctrl-c to abort.
pause >NUL
cls

:start
ECHO.
ECHO Type the option you want and then press enter to begin
ECHO installing replacement pack content.

ECHO Press 1 to disable Resistance foliage.
ECHO Press 2 to disable Resistance buildings and foliage.
ECHO Press enter to install all replacement pack content.

set choice=
set /p choice=Please select your install options:
ECHO.

echo Making ffur2007\DTA\HWTL directory...
echo.

mkdir DTA\HWTL >NUL


echo Now installing 3D models.
echo.
echo Making temporary directory ffur2007\DTA\HWTL\Data3D...


If not exist DTA\HWTL\Data3D goto MakeData3D
echo.
echo Error: Directory ffur2007\DTA\HWTL\Data3D exists.
echo.
echo Please ensure that ffur2007\DTA\HWTL\Data3D does not 
echo exist so that existing files are not overwritten.
goto end

:MakeData3D
mkdir DTA\HWTL\Data3D >NUL
del /Q DTA\HWTL\Data3D\*.* >NUL

echo.
echo Copying 3D model pbo: Res\DTA\HWTL\Data3D.pbo to ffur2007\DTA\HWTL\Data3D.pbo...
echo.

copy /Y ..\Res\DTA\HWTL\Data3D.pbo DTA\HWTL

echo.
echo Extracting 3D model pbo: ffur2007\DTA\HWTL\Data3D.pbo to ffur2007\DTA\HWTL\Data3D

bin\ExtractPbo.exe DTA\HWTL\Data3D.pbo >NUL

echo.
echo Done extracting ffur2007\DTA\HWTL\Data3D.pbo.
echo.


if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto nofoliage
if '%choice%'=='2' goto nobuildings
ECHO.
ECHO Installing all replacement pack content.
ECHO.
ECHO Installing Resistance foliage.
ECHO.
echo Copying Resistance foliage: ffur2007\NewData\Res_Foliage to ffur2007\DTA\HWTL\Data3D

copy /Y NewData\Res_Foliage\*.p3D DTA\HWTL\Data3D >NUL

echo.
echo Done copying Resistance foliage.
echo.

:nofoliage
if '%choice%'=='1' ECHO Resistance foliage disabled.
ECHO.
ECHO Installing Resistance buildings
.

ECHO.
echo Copying Resistance buildings: ffur2007\NewData\Res_Buildings to ffur2007\DTA\HWTL\Data3D

copy /Y NewData\Res_Buildings\*.p3D DTA\HWTL\Data3D >NUL

echo.
echo Done copying Resistance buildings.
echo.


:nobuildings
if '%choice%'=='2' ECHO Resistance buildings and foliage disabled.
ECHO.
ECHO Installing other replacement content.
ECHO.
echo Copying 3D models: ffur2007\NewData to ffur2007\DTA\HWTL\Data3D

copy /Y NewData\*.p3D DTA\HWTL\Data3D >NUL

echo.
echo Done copying 3D models.
echo.





echo Making new 3D model pbo: ffur2007\NewData to ffur2007\DTA\HWTL\Data3D.pbo
echo.

bin\cpbo.exe -p DTA\HWTL\Data3D DTA\HWTL\Data3D.pbo

echo.
echo Removing temporary directory ffur2007\DTA\HWTL\Data3D...
echo.

del /Q DTA\HWTL\Data3D\*.* >NUL
rd /Q DTA\HWTL\Data3D\ >NUL





echo.
echo Now installing textures.
echo.
echo Making temporary directory ffur2007\DataTemp...

If not exist DataTemp goto MakeTemp
echo.
echo Error: Directory ffur2007\DataTemp exists.
echo.
echo Please ensure that ffur2007\DataTemp does not 
echo exist so that existing files are not overwritten.
goto end

:MakeTemp
mkdir DataTemp >NUL
del /Q DataTemp\*.* >NUL

echo.
echo Extracting texture pbo: ..\Res\DTA\HWTL\Data.pbo to ffur2007\DataTemp
echo.

bin\cpbo.exe -e ..\Res\DTA\HWTL\Data.pbo DataTemp

echo Copying textures: ffur2007\NewData to ffur2007\DataTemp
echo.

copy /Y NewData\*.pa? DataTemp >NUL

echo Making new texture pbo: ffur2007\DataTemp to ffur2007\DTA\HWTL\Data.pbo 
echo.

bin\cpbo.exe -p DataTemp DTA\HWTL\Data.pbo

echo.
echo Removing temporary directory ffur2007\DataTemp...

del /Q DataTemp\*.* >NUL
rd /Q DataTemp\ >NUL

echo.
echo Done installing textures.
echo.




echo.
echo The ffur2007 Replacement Pack has finished installing.
echo You can now run OFP with the ffur2007 Replacement Pack by using "-mod=ffur2007".

:end
pause