@echo off
be.exe sa bold white on blue /cls
echo Welcome to the EGYPTIAN DOOM installation utility!
echo ...
echo ...

if not exist ..\egypt\egypt.wad goto dirfail
if not exist ..\doom2.exe goto d2exefail
if not exist ..\doom2.wad goto d2wadfail

:menu
echo Please select an action:
echo ...
echo 1 - View install.txt.
echo 2 - Begin installation.
echo 3 - Exit.
echo ...

choice /c:123
if errorlevel 3 goto end
if errorlevel 2 goto install

 :view
 be.exe sa bold white on green /cls
 type install.txt|more
 pause
 be.exe sa bold white on blue /cls
 goto menu

 :install
 if exist status0.dum goto begin
 echo ...
 echo Egyptian Doom has already been installed, install anyway?
 choice /c:yn
 if errorlevel 2 goto quickend
 rename status*.dum status0.dum
 echo ...

 :begin
 cls
 echo Installation.
 echo ...
 echo ...
 echo Your doom2.wad will be modified, make sure you have a backup.
 echo ...
 echo You will not be able to use the original doom2 without uninstalling
 echo Egyptian Doom, but temporary uninstall/reinstall will only take a few
 echo seconds with the included egypt.bat!
 echo ...
 echo Installation will require a total of 2.7 Mb diskspace.
 echo ...
 choice /c:yn Ok to continue the installation 
 if errorlevel 2 goto menu

 be.exe sa bold white on blue /cls
 echo Checking for old dehacked exe-file...
 if not exist ..\doomhack.exe goto nohackbackup
 echo Storing old dehacked exe temporarily...
 move ..\doomhack.exe doomhack.tmp
 echo ...
 pause
 echo ...

 :nohackbackup
 echo Making base for egyptian exe-file...
 copy ..\doom2.exe ..\doomhack.exe
 echo ...
 pause
 cls
 echo Running dehacked...
 dehacked.exe .. -reload -load egypt.deh
 echo ...
 pause
 cls
 echo Storing egyptian exe-file...
 move ..\doomhack.exe ..\egyptian.exe
 echo ...

 if not exist doomhack.tmp goto nohackrestore
 echo Restoring old dehacked exe...
 move doomhack.tmp ..\doomhack.exe
 echo ...

 :nohackrestore
 echo Copying egypt.bat...
 copy egypt.bat ..
 echo ...
 pause

 cls
 cd..
 echo Running NWT...
 egypt\nwt.exe -merge egypt\egyptspr.wad
 cd egypt
 echo ...
 pause

 be.exe sa bold white on green /cls
 echo Installation complete!
 echo ...
 echo ...
 echo The following files have been added to your doom2 directory:
 echo  egyptian.exe
 echo  egypt.bat
 echo ...
 echo Type 'egypt' in the ...\doom2 dir to start/uninstall EGYPTIAN DOOM.
 echo ...
 echo ...
 pause
 rename status0.dum status1.dum
 cd..
 cls
 echo Type 'egypt' to start.
 goto end


:dirfail
be.exe sa bright white on red /cls
echo *** EGYPTIAN DIRECTORY NOT FOUND - MAKE SURE THE UNZIPPED DATA IS
echo                                    PRESENT IN THE DIRECTORY
echo                                    x:\...\doom2\egypt.
echo ...
echo *** READ THE INSTALL.TXT FOR MORE INFO.
goto failend

:d2exefail
be.exe sa bright white on red /cls
echo *** DOOM2.EXE NOT FOUND - READ THE INSTALL.TXT FOR INSTRUCTIONS.
goto failend

:d2wadfail
be.exe sa bright white on red /cls
echo *** DOOM2.WAD NOT FOUND - READ THE INSTALL.TXT FOR INSTRUCTIONS.
goto failend

:failend
echo ...
pause
:quickend
echo Installation aborted.

:end
be.exe sa white on black
