;******************************************************************************
; Installation script for DataTypes Collection #2 (AMS)
; Written by David N. Junod
;******************************************************************************

; Initialize a few things
(set docbits 0)

;******************************************************************************
; Ask the user if we are installing or removing

(set mode
	(askchoice
		(prompt @app-name)
		(help @askchoice-help)
		(choices "Install" "Remove")
	)
)

; Set the prompt string
(if mode
	(set pmode "Remove")
	(set pmode "Install")
)

;******************************************************************************
; Prompt for components and their directories

; Classes
(set classdir
	(askdir
		(prompt "Where do the Classes belong")
		(help @askdir-help)
		(default "SYS:Classes")
	)
)

;******************************************************************************
;******************************************************************************
;******************************************************************************

(if mode
        ;**********************************************************************
	; Remove
        ;**********************************************************************
	(
		; Show what we are doing
		(working "Removing " @app-name)

		; Remove the non-standard pieces
		(delete (tackon classdir "datatypes/sunau.datatype"))
		(delete (tackon classdir "datatypes/xbm.datatype"))
		(delete "devs:datatypes/Sun Audio" (infos))
		(delete "devs:datatypes/X-Bitmap" (infos))

		; Don't want to use the confusing "Installation Complete" message
		; when what we really did was remove things...
		(message "The \"" @app-name "\" components "
			 "that you specified have been successfully removed")
		(exit (quiet))
	)

        ;**********************************************************************
	; Install
        ;**********************************************************************
	(
		; Show what we are doing
		(working "Installing " @app-name)

		; Install the classes
		(copylib
			(prompt "Copying Sun audio DataType")
			(help @copylib-help)
			(source "classes/datatypes/sunau.datatype")
			(dest (tackon classdir "DataTypes"))
			(confirm)
		)
		(copylib
			(prompt "Copying X-Bitmap picture DataType")
			(help @copylib-help)
			(source "classes/datatypes/xbm.datatype")
			(dest (tackon classdir "DataTypes"))
			(confirm)
		)
		(copylib
			(prompt "Updating the Picture DataType")
			(help @copylib-help)
			(source "classes/datatypes/picture.datatype")
			(dest (tackon classdir "DataTypes"))
			(confirm)
		)

		; Install the descriptors
		(copyfiles
			(prompt "Copying the Descriptors")
			(help @copyfiles-help)
			(source "devs")
			(dest "DEVS:")
			(pattern "#?")
			(infos)
			(confirm)
		)

		; Tell the system about the new descriptors
		(run "C:AddDataTypes Refresh")

		; See if they are running Amiga Mosaic.  If they are, then give a little
		; personalized message :-)
		(if (= (exists "ENVARC:Mosaic") 2)
			(message "Update your ENVARC:Mosaic/MailCap so that it will use MultiView for all audio.\n\naudio/*; sys:Utilities/MultiView %s")
		)
	)
)

(set @default-dest classdir)
