; Install_RayStorm - RayStorm installation script for Installer
;
; Copyright  1995 Andreas Heumann
;
; $Id: Install_RayStorm,v 1.1 1995/28/11
;
;     Installer and Installer project icon
;     (c) Copyright 1991-93 Commodore-Amiga, Inc.  All Rights Reserved.
;     Reproduced and distributed under license from Commodore.
;
;     INSTALLER SOFTWARE IS PROVIDED "AS-IS" AND SUBJECT TO CHANGE;
;     NO WARRANTIES ARE MADE.  ALL USE IS AT YOUR OWN RISK.  NO LIABILITY
;     OR RESPONSIBILITY IS ASSUMED.
;
;
(welcome "    Welcome to the " @app-name " 1.15 installation.\n")

; What we are?
(set app-name (cat @app-name " 1.15"))

; "Needs"
(set need-version 37)  ; version of operating system need by RayStorm

; These directories are always present
(set dir-pat (cat "(" "anims" "|" "docs" "|" "arexx" "|" "examples" "|" "brushes" "|" "objects" ")"))

; The source directory name
(set source-dir
 (if (= 1 (exists @icon))
  (pathonly (expandpath @icon))
  (expandpath @icon)
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 check-system-version
 ;; is your Exec recent enough?
 (set exec-version (/ (getversion) 65536))
 (transcript "Running on exec version " exec-version ".")
 (if (< exec-version need-version)	; check operating system version
  (
   (message "The " @app-name " needs at least Exec version " need-version
	         " to run.\nYou have only version " exec-version ".\n"
	         "You can proceed with the installation, but consider "
	         "installing the " @app-name " with proper version of "
	         "the operating system."
	 (help "    The " @app-name " uses some system functions "
			"that are not present or functional in earlier system "
			"versions. Consider updating your system.\n"
			"    If you have a later version of operating system "
			"and are only now using older version: be sure to use "
			"only release 2.04 or newer with the " @app-name ". "
			"No damage happens if you run the " @app-name " with an "
			"earlier operating system, however. It just "
			"refuses to start.\n"
			"    If you decide to continue, no changes will be made to "
			"system startup files, so you must edit them yourself. "
			"Refer instructions for manual installation."
	 )
	)
   (transcript "User decided to continue installation while running "
		         "on operating system release earlier than 2.04."
	)
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 ;; select cpu type
 check-cpu
 (set cpu (database "cpu"))
 (if (OR (= cpu "68000") (= cpu "68010"))
  (set selcpu
   (askchoice
    (prompt (cat "Select the version of " app-name " to install."))
    (help "Select the version you want to install. The files for your"
          "CPU will be copied.")
    (choices "68000" "68020 and above")
    (default 0)
   )
  )
  (set selcpu
   (askchoice
    (prompt (cat "Select the version of " app-name " to install."))
    (help "Select the version you want to install. The files for your"
          "CPU will be copied.")
    (choices "68000" "68020 and above")
    (default 1)
   )
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure select-destination-directory
 ;; Select destination directory for the installation. We suggest the user
 ;; to install to the place from where the installer was started. This is
 ;; since normally this software will be unarchived to its proper location
 ;; and the files don't have to be copied any more.
 ;;
 (transcript "Selecting destination directory for the installation.")
 (while
  (
	(set @default-dest
	 (askdir
	  (prompt "Select directory where to install " app-name ".\n"
	          "You have to create a directory for " app-name " yourself."
     )
	  (help "    Here you can specify location where to install "
			  "the " app-name ".\n"
			  "    Installation can be made on-place. "
			  "This is recommended if you have already unarchived "
			  "the " app-name " archive to its final location. "
			  "In this case "
			  "most of the files are left where they are. "
			  "Only necessary files are copied to different "
			  "positions.\n"
     )
	  (newpath)
	  (default source-dir)
    )
   )
   (if (= 2 (exists @default-dest))
	 0
	 (makedir @default-dest
	  (infos)
	 )
	)
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 copy-files-to-destination ;;; Copy all files if not installing on-place
 ;;
 (if (= source-dir (expandpath @default-dest))
  (message "\nSource and destination directories are the same, "
	        "not copying."
	(help "    The " app-name " files don't have to be copied, "
		   "since the source and the destination directories are "
		   "the same."
	)
  )
  ((transcript "Copying " app-name " files from " source-dir " to "
	            @default-dest "."
	)
	(if (= selcpu 1)
    (
     (copyfiles
      (source (tackon source-dir "RayStorm_020"))
	   (dest @default-dest)
	   (prompt "Copying files to the selected location.")
      (newname "RayStorm")
      (optional "askuser")
     )
     (copyfiles
      (source (tackon source-dir "RayStorm_020.info"))
	   (dest @default-dest)
	   (prompt "Copying files to the selected location.")
      (newname "RayStorm.info")
	   (optional "askuser")
     )
     (set dest-dir (tackon @default-dest "textures"))
	  (if (NOT (exists dest-dir))
	   (makedir dest-dir)
	  )
	  (copyfiles (all)
		(source (tackon source-dir "textures_020"))
		(dest dest-dir)
		(prompt "Copying files to the selected location.")
		(optional "askuser")
	  )
     (set dest-dir (tackon @default-dest "modules"))
	  (if (NOT (exists dest-dir))
	   (makedir dest-dir)
	  )
	  (copyfiles (all)
		(source (tackon source-dir "modules_020"))
		(dest dest-dir)
		(prompt "Copying files to the selected location.")
		(optional "askuser")
	  )
    )
    (
     (copyfiles
      (source (tackon source-dir "RayStorm_000"))
	   (dest @default-dest)
	   (prompt "Copying files to the selected location.")
      (newname "RayStorm")
	   (optional "askuser")
     )
     (copyfiles
      (source (tackon source-dir "RayStorm_000.info"))
	   (dest @default-dest)
	   (prompt "Copying files to the selected location.")
      (newname "RayStorm.info")
	   (optional "askuser")
     )
     (set dest-dir (tackon @default-dest "textures"))
	  (if (NOT (exists dest-dir))
	   (makedir dest-dir)
	  )
	  (copyfiles (all)
		(source (tackon source-dir "textures_000"))
		(dest dest-dir)
		(prompt "Copying files to the selected location.")
		(optional "askuser")
	  )
    )
   )
   (foreach source-dir dir-pat
    (
     (set dest-dir (tackon @default-dest @each-name))
	  (if (NOT (exists dest-dir))
	   (makedir dest-dir)
	  )
	  (copyfiles (all)
		(source (expandpath @each-name))
		(dest dest-dir)
		(prompt "Copying files to the selected location.")
		(optional "askuser")
	  )
	 )
	)
   (copyfiles (source source-dir)
	 (dest @default-dest)
	 (prompt "Copying files to the selected location.")
	 (choices "anims.info" "Examples.jpg" "Modeller preview.iff" "Readme" "Readme.mui" "Register" "Whats new.txt" "Docs.info")
	 (files)
	 (infos)
	 (optional "askuser")
   )
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Installatation sequence
;;;
(message "Please remember during this installation:\n\n"
	 "    Read the instructions provided behind the \"Help\" "
	 "buttons, if you are not absolutely sure what you are doing.\n"
)

(complete 00)
(transcript "On making " app-name ".")
(check-system-version)
(check-cpu)
(complete 10)
(select-destination-directory)
(complete 20)
(copy-files-to-destination)
(complete 100)

;;; All done!

; EOF

