; F1GP-Ed Installer script
; $VER: F1GP-Ed_Install 3.05 (11.11.95)
; written by Oliver Roberts
;
; Please report any bugs this script has :-)

(set OSVersion (/ (getversion) 65536))

(if (NOT (askbool
      (prompt "This Installer script will attempt to install F1GP-Ed to your "
              "hard drive.  It can install F1GP-Ed for the first time or update "
              "a version which you already have installed.  Please report any "
              "bugs in this script.\n\n"
              "Make sure you have booted from your hard drive, before "
              "continuing with this installation!\n\nDo you want to continue?"
      )
      (default 0)
      (help "")
   ))
   (exit (quiet))
)
      
(welcome "")

(complete 0)

(set destdir
   (askdir
      (prompt "Select where the \"F1GP-Ed\" drawer should be created (or where it already exists)")
      (help @askdir-help)
      (default @default-dest)
   )
)

(set @default-dest (tackon destdir "F1GP-Ed"))
(if (NOT (exists @default-dest))
   (makedir @default-dest (infos))
)

(if (<> 2 (exists @default-dest)) (
   (message "Could not create the \"F1GP-Ed\" drawer - make sure "
            "there are no FILES called \"F1GP-Ed\" in the destination "
            "you selected.\n\n\nInstallation Failed!")
   (exit (quiet)))
)

(set libdir "LIBS:")

(copylib
   (prompt "Installing newer version of f1gp.library")
   (source "Libs13/f1gp.library")
   (dest libdir)
   (help @copylib-help)
   (newname "f1gp.library")
   (confirm)
)

(if (< OSVersion 36) 
   (  (set ReqToolsSource "Libs13/reqtools.library")
      (copylib
         (prompt "Installing newer version of gadtools13.library")
         (source "Libs13/gadtools13.library")
         (dest libdir)
         (help @copylib-help)
         (newname "gadtools13.library")
         (confirm)
      )
   )
   (  (set ReqToolsSource "Libs20/reqtools.library")
      (set asllib (tackon libdir "asl.library"))
      (if (exists asllib)
         (  (set aslver (/ (getversion asllib) 65536))
            (if (>= aslver 38)
               (set ReqToolsSource "")
            )
	 )
      )
   )
)

(complete 10)

(if ReqToolsSource
   (copylib
      (prompt "Installing newer version of reqtools.library")
      (source ReqToolsSource)
      (dest libdir)
      (help @copylib-help)
      (newname "reqtools.library")
      (confirm)
   )
)

(complete 20)

(copylib
   (prompt "Installing F1GP-Ed executable...")
   (source "F1GP-Ed")
   (dest @default-dest)
   (help @copylib-help)
   (infos)
   (confirm)
)

(complete 30)

(if (exists "F1GP-Ed.key")
   (copyfiles
      (source "F1GP-Ed.key")
      (dest @default-dest)
      (help @copyfiles-help)
   )
)

(complete 35)

(copyfiles
   (source "")
   (choices "F1GP-Ed.guide" "History.txt" "Reg_Form")
   (files)
   (dest @default-dest)
   (help @copyfiles-help)
   (infos)
)

(complete 50)

(set opts
   (askoptions
      (prompt "Please confirm if you'd like to install these")
      (help @askoptions-help)
      (choices "1995 season data"
               "1994 season data"
               "Sound related files (Sound drawer)"
               "Graphics related files (Graphics drawer)"
               "Files in the Extras drawer"
               "Locale Catalogs (Workbench 2.1+)")
      (default 31)
   )
)

(if (IN opts 0)
   (copyfiles
      (prompt "Copying 1995 datafile...")
      (source "1995.f1gp")
      (dest @default-dest)
      (help @copyfiles-help)
      (infos)
   )
)

(if (IN opts 1)
   (copyfiles
      (prompt "Copying 1994 datafile...")
      (source "1994.f1gp")
      (dest @default-dest)
      (help @copyfiles-help)
      (infos)
   )
)

(complete 60)

(if (IN opts 2)
   (copyfiles
      (prompt "Copying Sound drawer...")
      (source "Sound")
      (dest (tackon @default-dest "Sound"))
      (help @copyfiles-help)
      (all)
      (infos)
   )
)

(complete 70)

(if (IN opts 3)
   (copyfiles
      (prompt "Copying Graphics drawer...")
      (source "Graphics")
      (dest (tackon @default-dest "Graphics"))
      (help @copyfiles-help)
      (all)
      (infos)
   )
)

(complete 80)

(if (IN opts 4)
   (copyfiles
      (prompt "Copying Extras drawer...")
      (source "Extras")
      (dest (tackon @default-dest "Extras"))
      (help @copyfiles-help)
      (all)
      (infos)
   )
)

(complete 90)

(if (IN opts 5)
   (copyfiles
      (prompt "Copying catalogs to LOCALE:Catalogs")
      (help @copyfiles-help)
      (source "Catalogs")
      (dest "LOCALE:Catalogs")
      (pattern "~(NewCatalog#?|#?.info)")
      (confirm)
   )
)

(complete 100)

(exit
   "Enjoy using F1GP-Ed!\n"
   "If you had problems running this installer\n"
   "please let me know.\n\n"
   "Oliver Roberts (O.J.C.Roberts@essex.ac.uk)\n"
   "http://cswww2.essex.ac.uk/users/robeoy/"
)
