; *******************************************************************
;
; $VER: Install_Vinci 2.5 (31.3.97)
; 
; Install script for Vinci copyright © 1995-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 2.04 to install Vinci!"
))

(set #copying-reqtools		"\nCopying reqtools.library 38.1413 to LIBS:...")
(set #copying-unpack		"\nCopying unpack.library 42.71 to LIBS:...")
(set #copying-vinci			"\nCopying Vinci...")
(set #copying-tools			"\nCopying Support Tools...")
(set #copying-documentation	"\nCopying Vinci documentation...")
(set #copying-icons			"\nCopying icons...")
(set #copying-catalogs		"\nCopying catalogs...")
(set #copying-regfiles		"\nCopying registration files...")
(set #copying-rexxscripts	"\nCopying rexx scripts...")
(set #exchange-icons		"\nWould you like to exchange the standard icons with the MagicWB icons ?")
(set #which-kind			"\nWhich kind?")
(set #select-dest			"Please select the path where you want to install Vinci. A drawer named Vinci will be created there.")
(set #select-destguide		"Please select the path where you want to install the Vinci documentation. It has already been installed along with the main program.")
(set #select-destrexx		"Please select the path where you want to install the Rexx scripts. A drawer named Vinci will be created there.")
(set #which-language        "\nWhich languages should be installed ?\n")
(set #which-language-help
 (cat "\nThe Amiga can be operated in many different"
	  " languages. If you want Vinci to use the"
      " same language as the Amiga Workbench"
	  " then a catalog file must be copied to your"
	  " harddisk for each language supported.\n\n"
	  "To reduce the amount of space consumed by the"
	  " language files, you can select to have only the"
	  " files of specific languages copied.\n\n"
	  "Simply check the boxes of the languages you wish"
	  " to have available on your system.\n\n"
	  @askoptions-help
))

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

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

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

;*** Required libraries

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

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

;*** Vinci executable

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

(makedir programdir
	(infos)
)

(set @default-dest programdir)

(copyfiles
	(prompt #copying-vinci)
	(source "Vinci")
	(dest programdir)
	(infos)
)

;*** Copy Vinci AppIcon

(copyfiles
	(prompt #copying-vinci)
	(source "Vinci_APPICON.info")
	(dest programdir)
)

;*** Copy Support tools

(copyfiles
	(prompt #copying-tools)
	(source "")
	(dest programdir)
	(pattern "Support Tools#?")
)

;*** Copy Catalogs to Vinci 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/Vinci.guide")
	(dest docdir)
	(infos)
)

;*** Copy icons

(set iconsdir
	(tackon
		programdir
		"MagicWB Icons"
	)
)

(copyfiles
	(prompt #copying-icons)
	(source "MagicWB Icons")
	(pattern "#?")
	(dest iconsdir)
	(infos)
)

; Copy icon for MagicWB Icons drawer

(copyfiles
	(prompt #copying-icons)
	(source "MagicWB Icons.info")
	(dest programdir)
)

;*** Exchange with MagicWB icons

(set mwbicons
	(askbool
		(prompt #exchange-icons)
		(help "")
	)
)

(if mwbicons
(
	(set whichkind
		(askchoice
			(prompt #which-kind)
			(help "")
			(choices "Ancient" "Modern")
		)
	)
	
	(if (= whichkind 0)
		(
			(set magicwbdir
				(tackon
					iconsdir
					"Ancient"
				)
			)
			(copyfiles
				(prompt #copying-icons)
				(source magicwbdir)
				(pattern "#?")
				(dest programdir)
			)
		)
		(
			(set magicwbdir
				(tackon
					iconsdir
					"Modern"
				)
			)
			(copyfiles
				(prompt #copying-icons)
				(source magicwbdir)
				(pattern "#?")
				(dest programdir)
			)
		)
	)
))

;*** Copy rexx scripts

(set rexxdir
	(tackon
		(askdir
			(prompt #select-destrexx)
			(help @askdir-help)
			(default "REXX:")
			(newpath)
		)
		"Vinci"
	)
)

(makedir rexxdir
)

(copyfiles
	(prompt #copying-rexxscripts)
	(source "Rexx")
	(pattern "#?")
	(dest rexxdir)
)

;*** Install locale file

(if (exists "SYS:Locale")
(
	(if (exists "LOCALE:")
	(
		(set lang (askoptions (prompt #which-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! Some older versions of the installed files might be present in memory."
)
