;
; $VER: Install BurnIT V2.21 (09.11.1999)
; This Install-script contains to BurnIT V2.67 ©1996-1999 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)

(if (= @language "français")
	(set default-lang 4)
)

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

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

(set #welcome
	(cat
		"\n\n\nWelcome to the BurnIT V2.67 installation.\n\n"
		"   BurnIT V2.67 ©1996-2000, DnS.\n\n"
                "aNOTHER fINE · F · A · I · T · H · rELEASE"
	)
)

(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.67\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.67 Registration")

(set #old "Already installed version: ")

(set #new "Version to install: ")

(set #overwritelib "The library is already installed.\nDo you want to overwrite it?")

(set #yes "Yes")

(set #no "No")

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

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

		(set #bad-kick
			(cat
				"Tut mir Leid!\n"
				"Aber Sie müssen AmigaOS Release 3.0 oder neuer haben für BurnIT V2.67"
			)
		)
		
		
		(set #welcome
			(cat
				"\n\n\nWillkommen zu der Installation von BurnIT V2.67\n\n"
				"BurnIT V2.67 ©1996-2000 DnS.\n\n"
                                "aNOTHER fINE · F · A · I · T · H · rELEASE"
			)
		)

		(set #install-parts "Wählen 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 "Lösche alte Einstellungen")

		(set #where-BurnIT_V2 "Wo wollen sie BurnIT V2.67 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 verfügbar...")

		(set #regis "BurnIT V2.67 registrieren...")

		(set #old "Bereits installierte Version: ")

		(set #new "Zu installierende Version: ")

		(set #overwritelib "Die Library ist bereits installiert.\nMöchten Sie sie überschreiben?")

		(set #yes "Ja")

		(set #no "Nein")
	)
)

;**************************************************************************
; 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 < 60030
;(if (patmatch "68030" (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)
	)
)

(if
	(<
		(exists
			(tackon BurnIT_V2-dest "BurnIT_V2/BurnIT_Sfx")
		)
	2)
	(makedir
		(tackon BurnIT_V2-dest "BurnIT_V2/BurnIT_Sfx")
		(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 sfx (tackon BurnIT_V2-dest "BurnIT_V2/BurnIT_Sfx"))

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

; And now do the actual installation

(complete 0)

(if (IN install-files 0)
	(copyfiles
		(prompt #copy "BurnIT V2")
		(help @copyfiles-help)
		(source "BurnIT_V2")
		(dest "T:")
		(infos)
		(confirm)
	)
)
(complete 25)

(if (IN install-files 0)
	(copyfiles
		(prompt (#copy "BurnIT V2" @default-dest))
		(source "T:BurnIT_V2")
		(dest   @default-dest)
		(help   @copyfiles-help)
		(infos)
		(noposition)
		(confirm)
	)
)

(if (IN install-files 0)
	(delete "T:BurnIT_V2"
		(delopts (infos))
	)
)

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

(if (IN install-files 0)
	(if (> (exists "libs/gtlayout.library") 0)
	(
		(if (> (exists (tackon "Libs:" "gtlayout.library")) 0)
		(
			(set gtlversion1 (getversion "LIBS:gtlayout.library"))
			(set gtlver1 (/ gtlversion1 65536))
			(set gtlrev1 (- gtlversion1 (* gtlver1 65536)))
			(set gtlversion2 (getversion "libs/gtlayout.library"))
			(set gtlver2 (/ gtlversion2 65536))
			(set gtlrev2 (- gtlversion2 (* gtlver2 65536)))
			(set overwrite
				(askbool
					(prompt (cat #overwritelib "\n\n" #old gtlver1 "." gtlrev1 "\n" #new gtlver2 "." gtlrev2))
					(help "No help")
					(default 1)
					(choices
						#yes
						#no
					)
				)
			)

			(if (= overwrite 1)
			(
				(copyfiles
					(source "libs/gtlayout.library")
					(dest "Libs:")
					(optional "nofail")
				)

				(if (= (exists ("C:avail")) 0)
					(run "avail flush >NIL:")
				)
			)
			)
		)
		)

    		(if (= (exists (tackon "Libs:" "gtlayout.library")) 0)
			(copylib
				(source "libs/gtlayout.library")
				(dest "Libs:")
				(optional "nofail")
			)
		)
  	)
	)
)

(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 45)

(if (IN install-files 0)
	(copyfiles
		(prompt (#copy "Sfx" @default-dest))
		(source "T:BurnIT_Sfx")
		(all)
		(dest   sfx)
		(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)
		)
	)
)
(if (IN install-files 0)
        

        (
		(copyfiles
			(prompt (#copy "BurnIT_CDCover REXX" @default-dest))
			(source "t:BurnIT_CDCover.rexx")
			(dest   @default-dest)
			(help   @copyfiles-help)
			(confirm)
		)
	)
)

(complete 75)

(if (IN install-files 2)
	(
		(if (IN lang 1)
			(
				(set language "deutsch")
				(copy-catalog)
			)
		)
		(if (IN lang 2)
			(
				(set language "français")
;				(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)

