; *******************************************************************
;
; $VER: Install-Vinci 1.6 (5.8.95)
; 
; Install script for Vinci copyright © 1995 Martin Wulffeld
;
; *******************************************************************

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

(set default_lang 4)

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

(set #copying-reqtoools		"Copying reqtools.library 38.1266 to LIBS:...")
(set #copying-unpack		"Copying unpack.library 41.60 to LIBS:...")
(set #copying-vinci			"Copying Vinci...")
(set #copying-tools			"Copying Support Tools...")
(set #copying-documentation	"Copying Vinci documentation...")
(set #copying-icons			"Copying icons...")
(set #copying-catalogs		"Copying catalogs...")
(set #exchange-icons		"Would you like to exchange the standard icons with the MagicWB icons?")
(set #which-kind			"Which kind?")
(set #select-dest			"Please select the path where you want to install Vinci along with the acompanying documentation and other files. A drawer will be created.")

(set #which-language
(cat "\nWhich languages should be installed?"
))
(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 "\n" #copying-reqtools)
	(help @copylib-help)
	(source "Libs/reqtools.library")
	(dest "LIBS:")
	(confirm)
)

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

;*** Main files

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

(makedir programdir
	(infos)
)

(set @default-dest programdir)

(copyfiles
	(prompt "\n" #copying-vincifiles)
	(source "Vinci")
	(dest programdir)
	(infos)
)

(copyfiles
	(prompt "\n" #copying-vincifiles)
	(source "Vinci.quotes")
	(dest programdir)
	(infos)
)

(copyfiles
	(prompt "\n" #copying-vincifiles)
	(source "Vinci_APPICON.info")
	(dest programdir)
)

(set toolsdir
	(tackon
		programdir
		"Support Tools"
	)
)

(makedir toolsdir
	(infos)
)

(copyfiles
	(prompt "\n" #copying-tools)
	(source "Support Tools")
	(pattern "#?")
	(dest toolsdir)
	(infos)
)

;*** Documentation files

(set docdir
	(tackon
		programdir
		"Documentation"
	)
)

(makedir docdir
	(infos)
)

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

(copyfiles
	(prompt "\n" #copying-documentation)
	(source "Documentation/Vinci.regform")
	(dest docdir)
	(infos)
)

;*** Copy icons

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

(makedir iconsdir
	(infos)
)

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

;*** Exchange with MagicWB icons

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

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

;*** Copy Catalogs

(set catalogdir
	(tackon
		programdir
		"Catalogs"
	)
)

(makedir catalogdir
)

(copyfiles
	(prompt "\n" #copying-catalogs)
	(source "Catalogs")
	(pattern "#?")
	(dest catalogdir)
)

(if (exists "SYS:Locale")
(
	(if (exists "LOCALE:")
	(
		(set lang (askoptions (prompt #which-language)
								(help #which-language-help)
								(choices
									"Dansk"
									"Français"
									"Italiano"
									"English")
								(default default_lang)
					)
		)
		
		(set n 0)
		(while
			(set language (select n
								"dansk"
								"français"
								"italiano"
								"")
			)
		(
			(if (IN lang n)
			(
				(if (< n 4)
				(
					(makedir (cat "LOCALE:Catalogs/" language))
					(copyfiles (source (cat "Catalogs/" language))
								(dest (cat "LOCALE:Catalogs/" language))
								(all)
					)
				))
			))
			(set n (+ n 1))
		))
	))
))
