; *************************************************************************
; *******************  SHELLBENCH INSTALLATION SCRIPT  ********************
; *************************************************************************
;
; $VER: InstallShellBench 1.1 (30.11.95)
;
; Copyright ©1995 Nick Christie
;
; *************************************************************************
;
; Find out about program version, etc

; get version of SB in distribution
(set vernum-sb (getversion "ShellBench"))
(set ver-sb    (/ vernum-sb 65536))
(set rev-sb    (- vernum-sb (* ver-sb 65536) ) )

(set @default-dest "")
(set defsbdir "SYS:WBStartup")
(set catsdir "Locale:Catalogs")

; if novice user-level, bump up to average
(if (= 0 @user-level)
	(
	(set @user-level 1)
	(user 1)
	)
)

(set old-user-level @user-level)

; ************************************************************************
; English strings
; ************************************************************************

(set default_lang 1)

(set #yes-msg "Yes")

(set #no-msg "No")

(set #bad-kick-msg "ShellBench requires AmigaOS 2.04 or better!")

(set #hello-msg
	(cat
		("Welcome to ShellBench V%ld.%ld\n\n" ver-sb rev-sb)
		"This script will install ShellBench and "
		"related files on your Amiga.\n\n"
		"You will need to answer a few questions such as "
		"where you would like the program installed.\n\n"
		"If you do not wish to install ShellBench at this time, "
		"select the 'Abort Install' button now. "
	)
)

(set #sb-askdir-msg "Please select the directory to install ShellBench in.")

(set #sbguide "ShellBench.guide")

(set #sbguide-ask-msg
	(cat
		"\nInstall ShellBench documentation?\n\n"
		"(This is an AmigaGuide file, and you will be asked "
		"for the directory in which to install it.)\n\n"
		"I recommend installing this, and reading it too, "
		"so that you know how to utilitise ShellBench to "
		"its fullest."
	)
)

(set #sbguide-askdir-msg
	(cat
		"\nPlease select the directory "
		"to install ShellBench.guide in.\n"
	)
)

(set #guide-help
	(cat
		"AmigaGuide is the Amiga's standard hypertext format.\n\n"
		"If you have AmigaOS 3.0 or better, you can use MultiView "
		"to read this documentation, otherwise you must use the AmigaGuide "
		"program, which is available on AmiNet and Fred Fish disk #870.\n\n"
		"Both of these viewer programs have a 'search path', a set "
		"of directories they search for AmigaGuide documents. "
		"You should place this guide somewhere in that path."
	)
)

(set #locale-msg
	(cat
		"\nShellBench is localized, which means you may use "
		"the program in several different languages. "
		"Please choose your preferred languages.\n"
	)
)

(set #locale-help
	(cat
		"These are the languages supported by ShellBench.\n\n"
		"Simply specify the languages you prefer and the "
		"required catalog files will be copied to the "
		"Locale:Catalogs directory.\n\nThis feature is "
		"only available under AmigaOS 2.1 and later."
	)
)

; ************************************************************************
; xxxx strings - template for other languages
; ************************************************************************

(if (= @language "xxxx")			; fill in language name
	(
	(set default_lang x)			; I will fill this in

	(set #yes-msg "Yes")

	(set #no-msg "No")

	(set #bad-kick-msg "ShellBench requires AmigaOS 2.04 or better!")

	(set #hello-msg
		(cat
			("Welcome to ShellBench V%ld.%ld\n\n" ver-sb rev-sb)
			"This script will install ShellBench and "
			"related files on your Amiga.\n\n"
			"You will need to answer a few questions such as "
			"where you would like the program installed.\n\n"
			"If you do not wish to install ShellBench at this time, "
			"select the 'Abort Install' button now. "
		)
	)

	(set #sb-askdir-msg "Please select the directory to install ShellBench in.")

; if guide is translated, uncomment second line & fill in language
;	(set #sbguide "ShellBench.guide")
;	(set #sbguide "/Guides/xxxx/ShellBench.guide")

	(set #sbguide-ask-msg
		(cat
			"\nInstall ShellBench documentation?\n\n"
			"(This is an AmigaGuide file, and you will be asked "
			"for the directory in which to install it.)\n\n"
			"I recommend installing this, and reading it too, "
			"so that you know how to utilitise ShellBench to "
			"its fullest."
		)
	)

	(set #sbguide-askdir-msg
		(cat
			"\nPlease select the directory "
			"to install ShellBench.guide in.\n"
		)
	)

	(set #guide-help
		(cat
			"AmigaGuide is the Amiga's standard hypertext format.\n\n"
			"If you have AmigaOS 3.0 or better, you can use MultiView "
			"to read this documentation, otherwise you must use the AmigaGuide "
			"program, which is available on AmiNet and Fred Fish disk #870.\n\n"
			"Both of these viewer programs have a 'search path', a set "
			"of directories they search for AmigaGuide documents. "
			"You should place this guide somewhere in that path."
		)
	)

	(set #locale-msg
		(cat
			"\nShellBench is localized, which means you may use "
			"the program in several different languages. "
			"Please choose your preferred languages.\n"
		)
	)

	(set #locale-help
		(cat
			"These are the languages supported by ShellBench.\n\n"
			"Simply specify the languages you prefer and the "
			"required catalog files will be copied to the "
			"Locale:Catalogs directory.\n\nThis feature is "
			"only available under AmigaOS 2.1 and later."
		)
	)
	) ; endif xxxx language
)

; ************************************************************************
; Begin actual installation
; ************************************************************************

; Check for KickV37 or better

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

; ------------------------------------------------------------------------
; Show welcome msg

(user 2)
(message #hello-msg)
(user old-user-level)

; ------------------------------------------------------------------------
; Ask the user where we should install ShellBench and copy the program.

(if
	(set sbdir
		(askdir
			(prompt #sb-askdir-msg)
			(help @askdir-help)
			(default defsbdir)
		)
	)
	(
	(copyfiles (source "ShellBench") (dest sbdir) (infos) )
	)
)

(set @default-dest sbdir)

; ------------------------------------------------------------------------
; Install ShellBench.guide. Ask yes/no first, then ask for directory.
; If installed, set GUIDENAME tooltype of ShellBench.

(set guidedir sbdir)

(if (askbool
		(prompt #sbguide-ask-msg)
		(help #guide-help)
		(default 1)
		(choices #yes-msg #no-msg)
	)
	; then
	(
	(set guidedir
		(askdir
			(prompt #sbguide-askdir-msg)
			(help @askdir-help)
			(default guidedir)
		)
	)
	(copyfiles (source #sbguide) (dest guidedir) (infos) )
	(tooltype
		(dest (tackon sbdir "ShellBench"))
		(settooltype "GUIDENAME" (tackon guidedir "ShellBench.guide"))
	)
	)
)

;------------------------------------------------------------------------
; install catalog(s)
;

(if (exists "libs:locale.library")
	(
	(if (exists catsdir)
		(
		(user 2)
		(set lang
			(askoptions
				(prompt #locale-msg)
				(help #locale-help)
				(choices
					"English"
					"Français"
					"Italiano"
				)
				(default default_lang)
			)
		)
		(user old-user-level)
		(set n 0)
		(while
			(set language
				(select n
					"English"
					"Français"
					"Italiano"
					""
				)
			)
			(
				(if (in lang n)
					(
					(if (<> 0 n)
						(
						(makedir (cat catsdir "/" language))
						(copyfiles
							(source (cat "Catalogs/" language "/ShellBench.catalog"))
							(dest (cat catsdir "/" language))
						)
						)
					)
					)
				)
				(set n (+ n 1))
			)
		) ; endwhile pick language n
		) ; endthen
	) ; endif exists catsdir
	) ; endthen

) ; endif exists locale lib

