@echo off
cls
echo.
echo      Installation of Red Alert Campaign:
echo.
echo.
echo      * * * * * * * * * * * * * * * * * *
echo      * In The Line of Fire Version 1.0 *
echo      * * * * * * * * * * * * * * * * * *
echo.
echo.
echo.
if not exist redalert.mix goto ERROR1
if not exist flinev10.dat goto ERROR2
if not exist flinev10.000 goto ERROR3
echo.
echo 1)  Install
echo 2)  Uninstall
echo 3)  Cancel
echo.
choice /c:123 Choose an Option:

   if errorlevel 3 goto CANCEL
   if errorlevel 2 goto UNINST

echo.
echo Choose which version of Red Alert you use:
echo.
echo 1)  DOS version
echo 2)  Win95 version
echo 3)  Quit
echo.
set oper=dos
choice /c:123 Choose an Option

   if errorlevel 3 goto CANCEL
   if errorlevel 2 set oper=w95

:INST

   echo.
   echo.
   echo Installing...  Please wait.
   set var=beta
   if exist tempk\nul goto NOINST
   if not exist sc-fline.mix set var=nobeta
   if exist fireline.bat del fireline.*   >nul
   if exist flinev02.bat del flinev02.*   >nul
   if exist flinev25.bat del flinev25.*   >nul
   if exist flinev03.bat del flinev03.*   >nul
   if exist flinev31.bat del flinev31.*   >nul
      
   echo.
   echo.
   
   if %var%==nobeta goto INST2

      del tutorial.ini >nul
      del rules.ini    >nul
      del mission.ini  >nul
      del version.txt  >nul
      del title.*      >nul
      del sc-*.mix     >nul
      if exist scg05ea.ini del scg*.ini      >nul
      cd tempj
      for %%f in (*.*) do move %%f ..\%%f >nul
      cd..
      rd tempj
      goto INST2


   :INST2

      md tempk
      for %%f in (*.mix scg*.ini version.txt title.*) do move %%f tempk\%%f >nul
      for %%f in (tutorial.ini rules.ini mission.ini) do move %%f tempk\%%f >nul
      cd tempk
      move redalert.mix ..\redalert.mix >nul
      cd..
      rename flinev10.000 pura.exe
      pura flinev10.dat >nul
      rename pura.exe flinev10.000
         
      if %oper%==w95 goto W95

      ren sc-dos.mix expand.mix
      del sc-win95.mix
      del title.cps
      

      :W95

          ren sc-win95.mix expand.mix
          del sc-dos.mix
          del title.cps

   :INST3

      if not exist music1.dat goto OHI
      cls
      echo.
      echo.
      echo Music data founded. Installing music files...
      ren music.000 add.exe                 
      ren music1.dat credit.aud
      ren music2.dat intro.aud
      add +expand.mix credit.aud intro.aud  >nul
      ren add.exe music.000
      ren credit.aud music1.dat
      ren intro.aud music2.dat

:OHI

   cls
   echo.
   echo Installation complete.
   echo.
   echo View flinev10.txt for more information.
   echo.
   echo.
   echo.
   echo To start the campaign you have to click 'Start new Game' button at
   echo the start menu and choose Allies.
   echo.
   echo.
   echo.
   echo I hope you have lots of fun with the campaign :)
   echo.
   goto END

:UNINST

   if not exist tempk\nul goto NOT
   del tutorial.ini >nul
   del rules.ini    >nul
   del mission.ini  >nul
   del version.txt  >nul
   del title.*      >nul
   del sc-*.mix     >nul
   del expand.mix   >nul
   if exist scg05ea.ini del scg*.ini     >nul
   
   cd tempk
   for %%f in (*.*) do move %%f ..\%%f >nul
   cd..
   rd tempk
   cls
   echo.
   echo In the Line of Fire is uninstalled
   echo.
   goto END

:ERROR1

   echo.
   echo Cannot found REDALERT.MIX in this directory.
   echo.
   echo You have to install this campaign in your Red Alert directory.
   echo.
   goto END

:ERROR2

   echo.
   echo Cannot found FLINEV10.DAT this directory.
   echo.
   goto END

:ERROR3

   echo.
   echo Cannot found FLINEV10.000 this directory.
   echo.
   goto END

:NOINST

   echo.
   echo Campaign is already installed!
   echo.
   goto END


:NOT

   echo.
   echo Campaign is not installed!
   echo.
   goto END

:CANCEL

   echo.
   echo Installation aborted.
   echo.
  :END
