; This is the Installer-script for AmigaBase.

(set OS_version (/ (getversion) 65536))
(set IsKick20 (>= OS_Version 36))

(transcript "Installing AmigaBase V1.31.")
(complete 0)

(set HD_Installation
   (=
      (askchoice
         (prompt "Choose installation:")
         (help "The harddisk installation installs all files"
               "in a seperate directory, while the floppy installation"
               "only installs the libraries and the catalog files.")
         (choices "Harddisk installation" "Floppy installation")
         (default 1)
      )
      0
   )
)

(if HD_Installation
   (
      (set AB_dest
         (askdir
            (prompt "Select disk/directory where AmigaBase should be installed:")
            (help "The installation program creates the directory "
                  "\"AmigaBase\" in this directory.")
            (default @default-dest)
         )
      )

      ; Make dest directory and create icon
      (makedir (tackon AB_dest "AmigaBase"))
      (copyfiles
         (source "AB_dir.icon")
         (dest AB_dest)
         (newname "AmigaBase.info")
      )

      (complete 10)

      ; now, we want everything to be copied into this sub-dir
      (set AB_dest (tackon AB_dest "AmigaBase"))
      (set @default-dest AB_dest)

      ;copy the AmigaBase drawer over
      (copyfiles
         (prompt "Copying 'AmigaBase' and some text files.")
         (help @copyfiles-help)
         (source "")
         (dest AB_dest)
         (choices "AmigaBase" "ReadMe" "LiesMich" "BUGS" "HISTORY" "TODO")
         (infos)
         (confirm)
      )
   )
)

(complete 20)

;copy reqtools.library
(copylib
   (prompt "Installing 'reqtools.library'.")
	(help @copylib-help)
	(source
      (if IsKick20
         "libs20/reqtools.library"
         "libs13/reqtools.library"
      )
   )
	(dest "libs:")
	(confirm)
)

(complete 30)

;copy gadget.library
(copylib
   (prompt "Installing 'gadget.library'.")
	(help @copylib-help)
	(source "libs13/gadget.library")
	(dest "libs:")
	(confirm)
)

(complete 40)

(if HD_Installation
   (
      ;make AmigaBase assign in startup-sequence

      (startup "AmigaBase"
      	(prompt
	      	"An assign instruction need to be added to the \"S:user-startup\" "
            "so that AmigaBase can be started by double clicking an "
            "AmigaBase project."
         )
      	(help @startup-help)
	      (command (cat "assign AmigaBase: " AB_dest "\n"))
      )
      (makeassign "AmigaBase" AB_dest)
   )
   (if (= (getassign "AmigaBase" "vad") "")
      (
         (set AB_dest (expandpath ""))
         (startup "AmigaBase"
      	   (prompt
	      	   "An assign instruction need to be added to the \"S:user-startup\" "
               "so that AmigaBase can be started by double clicking an "
               "AmigaBase project."
            )
         	(help @startup-help)
	         (command (cat "assign AmigaBase: " AB_dest "\n"))
         )
         (makeassign "AmigaBase" AB_dest)
      )
   )
)
(complete 50)

;copy catalog files
(if IsKick20
   (copyfiles
      (prompt "Which additional languages should AmigaBase support?")
      (help "The builtin language of AmigaBase is 'english'. ")
      (source "Catalogs")
      (dest "LOCALE:Catalogs")
      (pattern "#?")
      (confirm)
   )
)

(complete 60)

(if HD_Installation
   (
      ;create "Data" directory
      (makedir (tackon AB_dest "Data"))
      (copyfiles
         (source "Data.info")
         (dest AB_dest)
         (newname "Data.info")
      )

      (complete 70)

      ;copy optional examples
      (copyfiles
         (prompt "Copying optional examples")
         (help @copyfiles-help)
         (source "Data")
         (dest (tackon AB_dest "Data"))
         (choices "Deutsch" "English" "Graphics")
         (infos)
         (confirm)
      )

      (complete 90)

      ;copy optional AppStrings.source file
      (copyfiles
         (prompt "Copying optional files for translating AmigaBase into another language.")
         (help @copyfiles-help)
         (source "")
         (dest AB_dest)
         (pattern "MakeCat")
         (infos)
         (confirm)
      )
   )
)

(complete 100)

(if (NOT HD_Installation)
   (
      (set @default-dest "")
      (message
         "The Libraries (and catalog files) are installed. "
         "You can now start AmigaBase by double clicking its icon."
      )
   )
)

(exit)

