(welcome "Welcome to the Imagine 3.0 installation.")

(set @app-name "Imagine 3.0")
(set tmp @user-level)
(user 2)
(set inttype
	(askchoice
		(prompt "Please select the proper version of Imagine to install on your system.")
		(help @askchoice-help)
		(choices "Imagine 3.0 Floating Point Version" "Imagine 3.0 Integer Version")
		(default 0)
	)
)
(user tmp)


(set instdir
	(askdir
		(prompt "Please select a destination path for Imagine 3.0.")
		(help @askdir-help)
		(default "Work:im30")
		(newpath)
		(disk)
	)
)


(if ( = (exists instdir (noreq)) 1)   ;if selected path is a file...
	;then delete file and make dir
	(
		(set tmp @user-level)
		(user 2)
		(delete instdir 
			(prompt ("\n\"%s\" exists as a file.\n\nDelete and continue?" instdir))
			(help "\nSelecting \"Proceed\" will delete the existing file.  "
				  "Selecting \"Abort Install\" will cancel operation.  "
				  "Install again in either Intermediate or Expert level to change the installation path.")
			(confirm) 
			(optional "askuser")
		)
		(user tmp)
		(makedir instdir
			(prompt ("creating directory \"%s\"" instdir))
			(help @makedir-help)
			(infos)
			(confirm)
		)
	)
	;else
	(
		(if ( = (exists instdir (noreq)) 0)   ;if selected path doesn't exist...
			;then create dir
			(makedir instdir
				(prompt ("creating directory \"%s\"" instdir))
				(help @makedir-help)
				(infos)
				(confirm)
			)
			;else directory is already there - use it.
			;()
		)
	)
)

(set installmask
	(askoptions
		(prompt "Please select the items to install with Imagine 3.0.")
		(help @askoptions-help)
		(choices "Effects" "Textures" "Example Objects" "Example Attributes" "Depth Of Field document" "Texture Document")
		(default 63)
	)
)

(if inttype
	(
		(askdisk sourcedrive
			(prompt "\nPlease insert the disk labeled \"Imagine 3.0  Disk 2\" in any drive.")
			(help @askdisk-help)
			(dest "disk2")
			(assigns)
		)
		(run ("disk2:lharc >nil: -n -m x disk2:im30_2.lzh \"%s/\"" instdir)
			(prompt "\nDe-Arcing integer version program files...");
		)
	)
	;else
	(
		(askdisk sourcedrive
			(prompt "\nPlease insert the disk labeled \"Imagine 3.0  Disk 1\" in any drive.")
			(help @askdisk-help)
			(dest "disk1")
			(assigns)
		)
		(run ("disk1:lharc >nil: -n -m x disk1:im30_1.lzh \"%s/\"" instdir)
			(prompt "\nDe-Arcing floating point version program files...");
		)
	)
)

;de-arc program file...

(if installmask
(
	(askdisk sourcedrive
		(prompt "\nPlease insert the disk labeled \"Imagine 3.0  Disk 3\" in any drive.")
		(help @askdisk-help)
		(dest "disk3")
		(assigns)
	)

	(if (BITAND installmask 1)
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" effects/#?" instdir)
			(prompt "De-Arcing effects...")
		)
	)

	(if (AND (= inttype 0) (BITAND installmask 2))
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" textures/#?" instdir)
			(prompt "De-Arcing textures...")
		)
	)

	(if (BITAND installmask 4)
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" objects/#?" instdir)
			(prompt "De-Arcing objects...")
		)
	)

	(if (BITAND installmask 8)
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" attribs/#?" instdir)
			(prompt "De-Arcing attributes...")
		)
	)

	(if (BITAND installmask 16)
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" dof.txt" instdir)
			(prompt "De-Arcing depth of field document...")
		)
	)

	(if (BITAND installmask 32)
		(run ("disk3:lharc >nil: -n -m x disk3:im30_3.lzh \"%s/\" texture.txt" instdir)
			(prompt "De-Arcing texture document...")
		)
	)

)
)

(set @default-dest instdir)
