; *************************************************************************
; ********************  EXTRAINFO INSTALLATION SCRIPT  ********************
; *************************************************************************
;
; $VER: ExtraInfo.install 1.0 (9.5.95)
;
; Copyright ©1995 Nick Christie
;
; *************************************************************************
;
; Find out about program version, etc

; get version of EI in distribution
(set vernum-ei (getversion "ExtraInfo"))
(set ver-ei    (/ vernum-ei 65536))
(set rev-ei    (- vernum-ei (* ver-ei 65536) ) )

(set @default-dest "")
(set defeidir "SYS:WBStartup")
(set catsdir "Locale:Catalogs")
(set libsdir "Libs:")

; 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 2)

(set #yes-msg "Yes")

(set #no-msg "No")

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

(set #hello-msg
	(cat
		("Welcome to ExtraInfo V%ld.%ld\n\n" ver-ei rev-ei)
		"This script will install ExtraInfo 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 ExtraInfo at this time, "
		"select the 'Abort Install' button now. "
	)
)

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

(set #keepicon-msg "\nDo you wish to keep your existing ExtraInfo icon?")

(set #keepicon-help
	(cat
		"If you select 'Yes', your existing ExtraInfo icon will not "
		"be overwritten. If you select 'No', a new icon for ExtraInfo "
		"will be installed."
	)
)

(set #bgui-askdir-msg
	(cat
		"Select the directory to install bgui.library in. "
		"(Will *not* overwrite any existing newer version.)"
	)
)

(set #eiai-ask-msg "\nDo you wish to install the standard AppIcon?")

(set #eiai-ask-help
	(cat
		"If you select 'Yes' the standard AppIcon will be installed "
		"in a directory of your choice. Select 'No' if you do not wish "
		"to use the AppIcon facility, or if you will be providing your "
		"own AppIcon image."
	)
)

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

(set #eiguide "ExtraInfo.guide")

(set #eiguide-ask-msg
	(cat
		"\nInstall ExtraInfo 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 ExtraInfo to "
		"its fullest. "
	)
)

(set #eiguide-askdir-msg
	"Please select the directory to install ExtraInfo.guide in."
)

(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
		"\ExtraInfo 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 ExtraInfo.\n\n"
		"Simply specify the languages you prefer and the "
		"required catalog files will be copied to the "
		"Locale:Catalogs directory."
	)
)

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

(if (= @language "xxxx")
	(
	(set default_lang ?)

	(set #yes-msg "Yes")

	(set #no-msg "No")

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

	(set #hello-msg
		(cat
			("Welcome to ExtraInfo V%ld.%ld\n\n" ver-ei rev-ei)
			"This script will install ExtraInfo 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 ExtraInfo at this time, "
			"select the 'Abort Install' button now. "
		)
	)

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

	(set #keepicon-msg "\nDo you wish to keep your existing ExtraInfo icon?")

	(set #keepicon-help
		(cat
			"If you select 'Yes', your existing ExtraInfo icon will not "
			"be overwritten. If you select 'No', a new icon for ExtraInfo "
			"will be installed."
		)
	)

	(set #eiai-ask-msg "\nDo you wish to install the standard AppIcon?")

	(set #eiai-ask-help
		(cat
			"If you select 'Yes' the standard AppIcon will be installed "
			"in a directory of your choice. Select 'No' if you do not wish "
			"to use the AppIcon facility, or if you will be providing your "
			"own AppIcon image."
		)
	)

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

	(set #eiguide "ExtraInfo.guide")

	(set #eiguide-ask-msg
		(cat
			"\nInstall ExtraInfo 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 ExtraInfo to "
			"its fullest. "
		)
	)

	(set #eiguide-askdir-msg
			"Please select the directory to install ExtraInfo.guide in."
	)

	(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
			"\ExtraInfo 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 ExtraInfo.\n\n"
			"Simply specify the languages you prefer and the "
			"required catalog files will be copied to the "
			"Locale:Catalogs directory."
		)
	)

	) ; 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 ExtraInfo.

(set eidir
	(askdir
		(prompt #ei-askdir-msg)
		(help @askdir-help)
		(default defeidir)
	)
)

; ------------------------------------------------------------------------
; If there is an icon for ExtraInfo there already, ask the user if we
; should keep it. If yes then copy just the program, else copy both
; the program and icon.

(if (exists (tackon eidir "ExtraInfo.info"))
	; then
	(if (askbool
			(prompt #keepicon-msg)
			(choices #yes-msg #no-msg)
			(help #keepicon-help)
			(default 1)
		)
		; then
		(copyfiles (source "ExtraInfo") (dest eidir) )
		; else
		(copyfiles (source "ExtraInfo") (dest eidir) (infos) )
	)
	; else no info there
	(copyfiles (source "ExtraInfo") (dest eidir) (infos) )
)

(set @default-dest eidir)

; ------------------------------------------------------------------------
; Install BGUI library. If expert, ask for directory.

(if (= 2 @user-level)
	(set libsdir
		(askdir
			(prompt #bgui-askdir-msg)
			(help @askdir-help)
			(default libsdir)
		)
	)
)

(copylib (source "Libs/bgui.library") (dest libsdir)
)

; ------------------------------------------------------------------------
; Install ExtraInfo.appicon. Ask yes/no first, then ask for directory.

(set aidir eidir)

(if (askbool
		(prompt #eiai-ask-msg)
		(help #eiai-ask-help)
		(default 1)
		(choices #yes-msg #no-msg)
	)
	; then
	(
	(set aidir
		(askdir
			(prompt #eiai-askdir-msg)
			(help @askdir-help)
			(default aidir)
		)
	)
	(copyfiles (source "ExtraInfo.appicon.info") (dest aidir) )
	(tooltype
		(dest (tackon eidir "ExtraInfo"))
		(settooltype "APPICONNAME" (tackon aidir "ExtraInfo.appicon"))
	)
	)
)

; ------------------------------------------------------------------------
; Install ExtraInfo.guide. Ask yes/no first, then ask for directory.

(set guidedir eidir)

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

; ------------------------------------------------------------------------
; install catalog(s) - none available yet
;
;(if (exists "libs:locale.library")
;	(
;	(if (exists catsdir)
;		(
;		(user 2)	 
;		(set lang
;			(askoptions
;				(prompt #locale-msg)
;				(help #locale-help)
;				(choices
;					"English"
;				)
;				(default default_lang)
;			)
;		)
;		(user old-user-level)
;		(set n 0)
;		(while
;			(set language
;				(select n
;					"english"
;					""
;				)
;			)
;			(
;				(if (in lang n)
;					(
;					(if (<> 2 n)
;						(
;						(makedir (cat catsdir "/" language))
;						(copyfiles
;							(source (cat "Catalogs/" language))
;							(dest (cat catsdir "/" language))
;							(all)
;						)
;						)
;					)
;					)
;				)
;				(set n (+ n 1))
;			)
;		) ; endwhile pick language n
;		) ; endthen
;	) ; endif exists catsdir
;	) ; endthen
;
;) ; endif exists locale lib

