; Installer script for Ensemble Verbes patch
; $VER: Install_Patch 1.0 (28.3.95)

(procedure DOLOCALE
(
	(set n 0)
	(while
		(set language
			(select n ;"dansk"
				  ;"deutsch"
				  "english"
				  "español"
				  "français"
				  ;"italiano"
				  ;"nederlands"
				  "norsk"
				  ;"português"
				  ;"svenska"
				  ""
			)
		)
		(
			(set catpath
				(tackon "Catalogs" language)
			)
			(set srcpath catpath)
			(if (in lang n)
				(
					(if (<> 0 n) ; skip "english"
						(
							(makedir
								(tackon newdest "Catalogs")
								(safe)
							)
							(makedir
								(tackon newdest catpath)
								(safe)
							)
							(if (= 2 n) ; handle 2 cases for français
								(
									(set langopt
										(askbool
											(prompt "Choose the desired version of the français catalog file")
											(choices "French with English" "French only")
											(help "You may choose either:\n"
											      "  French with English menus and error messages, or\n"
											      "  Entirely French"
											)
										)
									)
									(if (= 1 langopt) ; French with English
										(set srcpath
											(tackon "Catalogs" "français2")
										)
									)
								)
							)
							(copyfiles
								(source
									(tackon @execute-dir srcpath)
								)
								(dest
									(tackon newdest catpath)
								)
								(all)
							)
						)
					)
				)
			)
			(set n (+ n 1))
		)
	)
))

(set osver
	(/
		(getversion "exec.library"
			(resident)
		)
		65536
	)
)
(set ks3
	(> osver 38)
)

(set newdest
	(askdir
		(prompt "Select the directory where \"Ensemble Verbes\" was installed")
		(default @default-dest)
		(help "You must tell the installer where \"Ensemble Verbes\" is located.")
		(newpath)
	)
)

(if
	(exists (tackon newdest "Verbes"))
	(
		(working "Patching Ensemble Verbes")
		(copyfiles (source (tackon newdest "Verbes")) (dest "t:"))
		(run (cat "sc:c/spatch -o" (tackon newdest "Verbes") " -pVerbes.pch t:Verbes"))
		(delete "t:Verbes")
		(if ks3
			(copyfiles
				(source "Verbes39.guide")
				(dest newdest)
				(newname "Verbes.guide")
			)
			(copyfiles
				(source "Verbes.guide")
				(dest newdest)
			)
		)
		(set lang
			(askoptions
				(prompt "Which languages should be installed?")
				(choices "English" "Español" "Français" "Norsk")
				(default 15)
				(help "\"Ensemble Verbes\" may be run in any of the languages listed.")
			)
		)
		(DOLOCALE)
	)
)
