; $VER: Install_WarpPNG 1.0 (28.12.99)
;   by Oliver Roberts (oliver.roberts@iname.com)

(if (= (exists "Env:Language") 1)
	(set @language (getenv "Language"))
)

;*****************
; English strings
;
(set #str-kick3 "You must be running Kickstart 3.0 or higher to use datatypes.")
(set #str-installdt "Installing Datatype")
(set #str-installclass "Installing WarpPNG.datatype class")
(set #str-installdes "Installing Descriptor")
(set #str-wrongcpu "You must have at least a 68040 and PowerPC processor to use this datatype.")
(set #str-oldpicdt (cat
	"WarpPNG.datatype needs picture.datatype v43 or higher.\n\n"
	"Such a datatype is supplied with AmigaOS 3.5, P96 and CyberGraphX."
))
(set #str-noppc (cat
	"WarpPNG.datatype requires a PowerPC processor and WarpUp Release "
	"4 or higher."
))
(set #str-backupdesc (cat
	"You already have a PNG datatype descriptor installed.  Would you "
	"like to keep a backup for safe-keeping?\n\n(if this is your first "
	"time installing WarpPNG.datatype, you probably should)"
))
(set #str-backup "Backup")
(set #str-overwrite "Overwrite")
(set #str-backupdir "Where should the PNG descriptor be backed up to?")
(set #str-backingup "Backing up files")
(set #str-reboot (cat
	"You may need to reboot for the changes to take effect.\n\n"
	"Also, if you have any other PNG datatypes in DEVS:Datatypes, "
	"you will probably have to remove them manually."
))

;**********************
; Compatibility checks
;
(set @default-dest "")
(set #cpu (database "cpu"))

(if (< (/ (getversion) 65536) 39)
	(abort #str-kick3)
)

(if (NOT (OR (= #cpu "68040") (= #cpu "68060")))
	(abort #str-wrongcpu)
)

(set #ppc 0)
(if (exists "LIBS:powerpc.library")
	(
		(set #ppcver (/ (getversion "LIBS:powerpc.library") 65536))
		(if (>= #ppcver 15) (set #ppc 1))
	)
)
(if (= #ppc 0)
	(abort #str-noppc)
)

(set #picdt-ok 0)
(if (exists "SYS:Classes/Datatypes/picture.datatype")
	(
		(set #pdtver (/ (getversion "SYS:Classes/Datatypes/picture.datatype") 65536))
		(if (>= #pdtver 43) (set #picdt-ok 1))
	)
)
(if (= #picdt-ok 0)
	(abort #str-oldpicdt)
)

;*************
; Here we go!
;
(welcome "")

(working #str-installdt)

(copylib
	(help @copylib-help)
	(prompt #str-installclass)
	(source "Classes/Datatypes/WarpPNG.datatype")
	(dest "SYS:Classes/DataTypes")
	(confirm)
)

(if (exists "DEVS:Datatypes/PNG")
	(if	(askbool
			(prompt #str-backupdesc)
			(help "")
			(default 0)
			(choices #str-backup #str-overwrite)
		)
		(
			(set #bakdir
				(askdir
					(prompt #str-backupdir)
					(help @askdir-help)
					(default "SYS:Storage/Datatypes")
				)
			)
			(copyfiles
				(help @copyfiles-help)
				(prompt #str-backingup)
				(source "DEVS:DataTypes/PNG")
				(dest #bakdir)
				(infos)
				(confirm)
			)
		)
	)
)

(copyfiles
	(help @copyfiles-help)
	(prompt #str-installdes)
	(source "Devs/DataTypes/PNG")
	(dest "DEVS:DataTypes")
	(infos)
	(confirm)
)

(run "C:AddDataTypes >NIL: REFRESH")

(exit #str-reboot)
