;
; $VER: Install BurnIt V2.00 Demo (22.12.1997)
; This Install-script contains to BurnIt V2.04 Demo 1996-1998 by DnS
;
(if (= (exists "Env:Language") 1)
	; GetEnv reports "String too long" if the variable doesn't exist! :(
	(set @language (getenv "language"))
)

;**************************************************************************
; Procedures
(procedure copy-catalog
	(set catalog
		(tackon "T:Catalogs"
		(tackon language "BurnIt_V2.catalog")
		)
	)
	(set destination (tackon "Locale:Catalogs" language))

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

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

(set default-lang 1)

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

(set #bad-cpu
	"You must have a 68020 CPU or biger to use BurnIt V2.0."
)

(set #welcome
	(cat
		"\n\n\nWelcome to the BurnIt V2.0 installation.\n\n"
		"   BurnIt V2.0 Demo 1996-1998, DnS."
	)
)

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

(set #item-BurnIt_V2 "BurnIt_V2")

(set #item-BurnIt_V2-guide "T:BurnIt_E_V2.guide")

(set #item-locale "Translations")

(set #item-prefs "Clear old prefs")

(set #where-BurnIt_V2
	(cat
		"Where do you wish to install BurnIt V2.0.\n The directory 'BurnIt_V2' will be created if it is not there."
	)
)

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

(set #copy "Copying %s to %s...")

(set #help "no help available...")

(set #regis "BurnIt V2.0 Registration")

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

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

		(set #bad-kick
			(cat
				"Tut mir Leid!\n"
				"Aber Sie men AmigaOS Release 3.0 oder neur haben fr BurnIt V2.0."
			)
		)
		(set #bad-cpu
			(cat
				"Tut mir Leid!\n"
				"Aber Sie men eine 68020 CPU oder grer haben fr BurnIt V2.0."
			)
		)
		(set #welcome
			(cat
				"\n\n\nWillkommen zu der Installation von BurnIt V2.0.\n\n"
				"BurnIt V2.0 Demo 1996-1998 DnS."
			)
		)

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

		(set #item-BurnIt_V2 "BurnIt_V2")

		(set #item-BurnIt_V2-guide "T:BurnIt_D_V2.guide")

		(set #item-locale "Kataloge")

		(set #item-prefs "Lsche alte Preferences")

		(set #where-BurnIt_V2 "Wo wollen sie BurnIt V2.0 installieren ?\n Ein Verzeichnis 'BurnIt_V2' wird erstellt.")

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

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

		(set #help "Keine Hilfe verfgbar...")

		(set #regis "BurnIt V2.0 registrieren...")

	)
)

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

(set @default-dest "")
;(set @default-source "")

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

; Check CPU. Exit if < 60020
(if (patmatch "68020" (database "cpu"))
        (abort #bad-cpu)
)

(message #welcome)

(welcome)

(set install-files
	(askoptions
		(prompt #install-parts)
		(help   @askoptions-help)
		(choices
			#item-BurnIt_V2
			#item-BurnIt_V2-guide
			#item-locale
			#item-prefs
		)
		(default 15)
	)
)

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

(set where BurnIt_V2-dest)

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

(if
	(<
		(exists
			(tackon BurnIt_V2-dest "BurnIt_V2/Operators")
		)
	2)
	(makedir
		(tackon BurnIt_V2-dest "BurnIt_V2/Operators")
		(infos)
	)
)

(if
	(<
		(exists
			(tackon BurnIt_V2-dest "BurnIt_V2/BurnIt_Drivers")
		)
	2)
	(makedir
		(tackon BurnIt_V2-dest "BurnIt_V2/BurnIt_Drivers")
		(infos)
	)
)

(set where (tackon BurnIt_V2-dest "BurnIt_V2"))
(set drivers (tackon BurnIt_V2-dest "BurnIt_V2/BurnIt_Drivers"))
(set operators (tackon BurnIt_V2-dest "BurnIt_V2/Operators"))

(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"
				"French"
			)
			(default default-lang)
		)
	)
)

; And now do the actual installation

(complete 0)

(if (IN install-files 0)
	(copyfiles
		(prompt #copy "BurnIt V2.0")
		(help   @copyfiles-help)
		(source "BurnIt_V2")
		(dest   @default-dest)
		(infos)
		(noposition)
		(confirm)
	)
)

(complete 25)

(if (IN install-files 0)
	(copylib
		(prompt (#copy "dragdrop.library" "Libs:"))
		(help @copylib-help)
		(source "libs/dragdrop.library")
		(dest "Libs:")
		(confirm)
	)
)

(complete 30)

(if (IN install-files 0)
	(copyfiles
		(source "c/lhex")
		(dest "T:")
		(nogauge)
	)
)

(if (IN install-files 0)
	(copyfiles
		(source "BurnIt_AddOn.lha")
		(dest "T:")
		(nogauge)
	)
)

(complete 35)

(if (IN install-files 0)
	(working "Decompressing AddOns...\n\n\n")
)

(if (IN install-files 0)
	(run "T:lhex >NIL: <NIL: -qfw=T: x T:BurnIt_AddOn.lha")
)

(complete 40)

(if (IN install-files 0)
	(copyfiles
		(prompt (#copy "Drivers" @default-dest))
		(source "T:BurnIt_Drivers")
		(all)
		(dest   drivers)
		(help   @copyfiles-help)
		(confirm)
	)
)

(if (IN install-files 0)
	(copyfiles
		(prompt (#copy "Operators" @default-dest))
		(source "T:Operators")
		(all)
		(dest   operators)
		(help   @copyfiles-help)
		(confirm)
	)
)

(complete 50)

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

(complete 75)

(if (IN install-files 2)
	(
		(if (IN lang 1)
			(
				(set language "Deutsch")
				(copy-catalog)
			)
		)
		(if (IN lang 2)
			(
				(set language "French")
;				(copy-catalog)
			)
		)
	)
)
(set BurnIticon_V2-dest (tackon @default-dest "BurnIt_V2"))

(complete 90)

(if (IN install-files 3)
	(
		(if
			(=
				(exists (tackon @default-dest "Settings_V2/BurnItPrefs.pref"))
			1)
			(delete (tackon @default-dest "Settings_V2/BurnItPrefs.pref"))
		)
		(if
			(=
				(exists (tackon @default-dest "Settings_V2/BurnItISOPrefs.pref"))
			1)
			(delete (tackon @default-dest "Settings_V2/BurnItISOPrefs.pref"))
		)
	)
)

(complete 95)

; Clean Up

(delete "T:" (all) (safe))

(complete 100)
(exit)

