;
; $VER: Install ReadCDDA V1.10 (02.07.1996)
; This Install-script contains to ReadCDDA V1.10 ©1996 by Michael Siegel
;
(if (= (exists "Env:Language") 1)
	; GetEnv reports "String too long" if the variable doesn't exist! :(
	(set @language (getenv "language"))
)

;**************************************************************************
; English Installation

(set default-lang 1)

(set #bad-kick
	"You must have AmigaOS Release 3.0 or newer to use ReadCDDA."
)

(set #welcome
	(cat
		"\n\n\nWelcome to the ReadCDDA installation.\n\n"
		"   ReadCDDA ©1996  Michael Siegel."
	)
)

(set #install-parts "Please select the parts you wish to install")

(set #item-readcdda "ReadCDDA")

(set #item-readcdda-guide "ReadCDDA.guide")

(set #item-locale "Translations")

(set #where-readcdda
	(cat
		"Where do you wish to install ReadCDDA.\n The directory 'ReadCDDA' will be created if it is not there. If a copy of Voyager is found it will be backed up."
	)
)

(set #which-language "Which languages should be installed?")

(set #copy "Copying %s to %s...")
(set #tooltype-step "Specifies the Stepsize\n for read CD-Blocks\n (one Step is 2048 bytes)")
(set #tooltype-iobuffer "Specifies the IO Buffer\n in bytest")

;**************************************************************************
; Deutsche Installation

(if (= @language "deutsch")
	(
		(set default-lang 2)

		(set #bad-kick
			(cat
				"Tut mir Leid!\n"
				"Aber Sie müßen AmigaOS Release 3.0 oder neur haben für ReadCDDA."
			)
		)
		(set #welcome
			(cat
				"\n\n\nWillkommen zu der Installation von ReadCDDA.\n\n"
				"ReadCDDA ©1996  Michael Siegel."
			)
		)

		(set #install-parts "Wählen Sie bitte die Teile, die Sie installieren wollen.")

		(set #item-readcdda "ReadCDDA")

		(set #item-readcdda-guide "ReadCDDA.guide")

		(set #item-locale "Kataloge")

		(set #where-readcdda "Wo wollen sie ReadCDDA installieren ?\n Ein Verzeichnis 'ReadCDDA' wird erstellt.")

		(set #which-language "Welche Sprachen sollen installiert werden?")

		(set #copy "Kopiere %s nach %s...")

		(set #tooltype-step "Setzt die Schrittweite\n für das Lesen der CD-Blöcke\n (Ein Schritt entspricht 2048 Bytes)")

		(set #tooltype-iobuffer "Setzt den IO Buffer\n in Bytes")
	)
)

;**************************************************************************
; the installaion script

(set @default-dest "")

; Check Kickstart version. Exit if not at least 3.0
(if (< (/ (getversion) 65536) 39)
        (abort #bad-kick)
)

(message #welcome)

(welcome)

(set install-files
	(askoptions
		(prompt #install-parts)
		(help   @askoptions-help)
		(choices
			#item-readcdda
			#item-readcdda-guide
			#item-locale
		)
		(default 7)
	)
)

(if (IN install-files 0)
	(set readcdda-dest
		(askdir
			(prompt  #where-readcdda)
			(help    @askdir-help)
			(default "Work:")
		)
	)
)

(set where readcdda-dest)

(if
	(<
		(exists
			(tackon readcdda-dest "ReadCDDA")
		)
	2)
	(makedir
		(tackon readcdda-dest "ReadCDDA")
		(infos)
	)
)

(set where (tackon readcdda-dest "ReadCDDA"))
(set @default-dest where)

(if (IN install-files 1)
	(set guide-dest @default-dest)
)

(set languages 0)

(if (IN install-files 2)
	(set lang
		(askoptions
			(prompt  #which-language)
			(help    @askoptions-help)
			(choices
				"English"
				"Deutsch"
			)
			(default default-lang)
		)
	)
)

; And now do the actual installation

(complete 0)
(if (IN install-files 0)
	(if (not(patmatch "68000|68010" (database "cpu")))
		(copyfiles
			(prompt (#copy "ReadCDDA Turbo" @default-dest))
			(source "ReadCDDA_020")
			(dest   @default-dest)
			(help   @copyfiles-help)
			(newname "ReadCDDA")
			(infos)
			(confirm)
		)
		(copyfiles
			(prompt (#copy "ReadCDDA" @default-dest))
			(source "ReadCDDA")
			(dest   @default-dest)
			(help   @copyfiles-help)
			(infos)
			(confirm)
		)
	)
)
(complete 25)

(if (IN install-files 1)
	(
		(copyfiles
			(prompt (#copy "ReadCDDA.guide" guide-dest))
			(source "ReadCDDA.guide")
			(help   @copyfiles-help)
			(dest   guide-dest)
			(infos)
			(confirm)
		)
	)
)

(complete 55)

(if (IN install-files 2)
	(
		(set n 0)

		(while
			(set language
				(select n
					"English"
					"Deutsch"
					""
				)
			)

			(
				(if (AND (IN lang n) (<> 0 n))
					(
						(set catalog
							(tackon "Catalogs"
								(tackon language "readcdda.catalog")
							)
						)
						(set destination (tackon "Locale:Catalogs" language))

						(copyfiles
							(prompt (#copy catalog destination))
							(source catalog)
							(dest   destination)
							(help @copyfiles-help)
						)
					)
				)

				(set n (+ n 1))
			)
		)
	)
)
(complete 80)
(set readcddaicon-dest (tackon @default-dest "ReadCDDA"))

(set #step
	(asknumber step
		(prompt (#tooltype-step))
		(help @asknumber-help)
		(range 1 65536)
		(default 32)
	)
)
(tooltype
	(dest readcddaicon-dest)
	(settooltype "STEP" (cat #step))
)
(complete 90)

(set #iobuffer
	(asknumber
		(prompt (#tooltype-iobuffer))
		(help @asknumber-help)
		(default 8192)
	)
)

(tooltype
	(dest readcddaicon-dest)
	(settooltype "IO_BUFFER" (cat #iobuffer))
)

(complete 100)
(exit)
