(welcome "Welcome to CU Amiga Magazine's installation.")

(set @app-name "CUAmiga")
(set tmp @user-level)
(user 2)

;------------------------------------------
(copyfiles
	(source "CU_126:c/UnLZX")
	(dest "ram:")
	(files)
)
;------------------------------------------
(set instdir
	(askdir
		(prompt "Please select a destination path for CUTools126.")
		(help @askdir-help)
		(default "Work:CUTools126")
		(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 from \"CU_126.\"")
		(help @askoptions-help)
		(choices "Amiga E Sources" "Bluff Titler" "Deverb 1.0" "Imagine Objects" "Mandel-92" "TextureStudio") 
		(default 63)
	)
)

;******************************************
;de-arc program file...

(if installmask
(
	(askdisk sourcedrive
		(prompt "\nPlease insert the disk called \"CU_126\" in any drive.")
		(help @askdisk-help)
		(dest "CU_126")
		(assigns)
	)

	(if (BITAND installmask 1)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/AmigaE.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Amiga E Sources...")
		)
	)

	(if (BITAND installmask 2)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/BluffTitler.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Bluff Titler...")
		)
	)

	(if (BITAND installmask 4)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/Deverb.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Deverb...")
		)
	)

	(if (BITAND installmask 8)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/ImagineObjects.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Imagine Objects...")
		)
	)

	(if (BITAND installmask 8)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/ImagineObjects2.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Imagine Objects 2...")
		)
	)

	(if (BITAND installmask 16)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/Mandel-92.lzx \"%s/\"" instdir)
			(prompt "De-Arcing Mandel-92...")
		)
	)

	(if (BITAND installmask 32)
		(run ("ram:unlzx >nil: -m -q x CU_126:Archives/TextureStudio.lzx \"%s/\"" instdir)
			(prompt "De-Arcing TextureStudio...")
		)
	)
)
)

;******************************************
;Script by Grants Computing
;delete ram buffer
(delete "ram:unlzx")
;(delete "ram:format")
;(delete "ram:nl")

(set @default-dest instdir)
