; *******************************************************************
;
; $VER: Install_NewChange 1.3 (25.4.97)
; 
; Install script for NewChange copyright © 1996-1997 Martin Wulffeld
;
; *******************************************************************

(set old_level @user-level)
(set @default-dest "")

(set default_lang 64)

(set #bad-kick
(cat "You must at least have Kickstart 3.0 to install NewChange!"
))

(set #copying-reqtools		"\nCopying reqtools.library 38.1436 to LIBS:...")
(set #copying-newchangeexe	"\nCopying NewChange executable...")
(set #copying-documentation	"\nCopying NewChange documentation...")
(set #copying-regfiles		"\nCopying registration files...")
(set #copying-catalogs		"\nCopying catalogs...")
(set #select-dest			"Please select the path where you want to install NewChange. A drawer named NewChange will be created there.")
(set #select-destguide		"Please select the path where you want to install the NewChange documentation. It has already been installed along with the main program.")
(set #select-language       "Which languages should be installed?")

;=============================================================================
; Make sure we are running under a 3.0 ROM

(if (< (/ (getversion) 65536) 39)
(
    (abort #bad-kick)
))

;=============================================================================

;*** Required libraries

(copylib
	(prompt #copying-reqtools)
	(help @copylib-help)
	(source "Libs/reqtools.library")
	(dest "LIBS:")
	(confirm)
)

;*** NewChange executable

(set programdir
	(tackon
		(askdir
			(prompt #select-dest)
			(help @askdir-help)
			(default "SYS:")
			(newpath)
		)
		"NewChange"
	)
)

(set @default-dest programdir)

(copyfiles
	(prompt #copying-newchangeexe)
	(source "NewChange")
	(dest programdir)
	(infos)
)

;*** Copy Catalogs to NewChange dir for backup

(copyfiles
	(prompt #copying-catalogs)
	(source "")
	(dest programdir)
	(pattern "Catalogs#?")
)

;*** Copy registration files

(copyfiles
	(prompt #copying-regfiles)
	(source "")
	(dest programdir)
	(pattern "Registration#?")
)

;*** Documentation files

; Backup

(copyfiles
	(prompt #copying-documentation)
	(source "")
	(dest programdir)
	(pattern "Documentation#?")
)

; Ask if documentation should be installed elsewhere

(set tempdocdir
	(tackon
		programdir
		"Documentation"
	)
)

(set docdir
	(askdir
		(prompt #select-destguide)
		(help @askdir-help)
		(default tempdocdir)
		(newpath)
	)
)

(copyfiles
	(prompt #copying-documentation)
	(source "Documentation/NewChange.guide")
	(dest docdir)
	(infos)
)

;*** Install locale file

(if (exists "SYS:Locale")
(
	(if (exists "LOCALE:")
	(
		(set lang (askoptions (prompt #select-language)
								(help #which-language-help)
								(choices
									"Dansk"
									"Italiano"
									"Nederlands"
									"Norsk"
									"Suomi"
									"Svenska"
									"English")
								(default default_lang)
					)
		)
		
		(set n 0)
		(while
			(set language (select n
								"dansk"
								"italiano"
								"nederlands"
								"norsk"
								"suomi"
								"svenska"
								"")
			)
		(
			(if (IN lang n)
			(
				(if (< n 7)
				(
					(makedir (cat "LOCALE:Catalogs/" language))
					(copyfiles (source (cat "Catalogs/" language))
								(dest (cat "LOCALE:Catalogs/" language))
								(all)
					)
				))
			))
			(set n (+ n 1))
		))
	))
))

(exit "Please reboot or flush your memory. Some older versions of the installed files might be present in memory."
)
