; This script installs the GUIFront library and preferences editor on your
; harddisk. Use Commodore's Installer utility to execute.
;
; Modified by Doug Dyer for generic amiCheck installation needs.

; Default source- and destination files

(set prefs-source	"//prefs/GUIFront")
(set prefs-source020	"//prefs/GUIFront.020")
(set prefs-dest		"SYS:Prefs/")
(set prefscat-source	"Locale/Catalogs/")
(set prefscat-dest	"LOCALE:Catalogs/")
(set lib-source		"//libs/guifront.library")
(set lib-source020	"//libs/guifront.library.020")
(set lib-dest		"LIBS:")
(set lib-destname	"guifront.library")
(set er-source		"//libs/easyrexx.library")
(set er-dest		"LIBS:")
(set er-destname	"easyrexx.library")
(set ac-source		"//storage/amiCheck.68000")
(set ac-source020	"//storage/amiCheck.68020")
(set ac-destname	"amiCheck")
(set ac-dest		"//")

;***************************************************************************
; English strings
;
; Translation: Native
;***************************************************************************

(set default_lang 1)
(set oldlevel @user-level)

(set wrongkickstart	"amiCheck requires at least Kickstart 2.04")
(set prefs-where	(cat "In which directory do you want to install the "
			     "preferences editor?"))
(set prefs-where-help	(cat "The preferences editor allows you to "
			     "customize the visual appearance of "
			     "the application.\n\n"
			     @askdir-help))
(set prefs-cpu		(cat "Which CPU version of the software "
			     "do you want to install?"))
(set prefs-cpu-help	(cat "Two versions of some software have been"
			     "provided. One version runs on any Amiga, "
			     "while the other requires a 68020 or better.\n\n"
			     "Select the version which closest matches "
			     "your hardware. If you do not know what type of "
			     "CPU your Amiga has, simply accept what the "
			     "Installer suggests\n\n"
			     @askoptions-help))
(set cpu000		"68000")
(set cpu020plus		"68020 or better")
(set er-where		(cat "In which directory do you want to install "
			     "easyrexx.library?"))
(set er-where-help	(cat "This library is used by amiCheck to provide "
			     "arexx support.  It is not required, but "
			     "highly recommended.\n\n"
			     @askdir-help))
(set lib-where		(cat "In which directory do you want to install "
			     "guifront.library?"))
(set lib-where-help	(cat "This library is used by every GUIFront "
			     "application, and is absolutely necessary "
			     "to install.\n\n"
			     @askdir-help))
(set which-lang		"Which languages should be installed? (GUIfront Prefs)")
(set which-lang-help	(cat "The Amiga can be operated in many different "
			     "languages. If you want the GUIFront preferences "
			     "editor to use the same language as your Amiga "
			     "Workbench, then a catalog file must be copied "
			     "to your LOCALE: directory 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"
			     "Please check the boxes of the languages you "
			     "wish to have available on your system.\n\n"
			     @askoptions-help))
(set copying-lib	"Copying guifront.library to ")
(set copying-prefs	"Copying GUIFront preferences editor to ")
(set copying-er		"Copying easyrexx.library to ")
(set copying-ac		"Copying amiCheck.680X0 to ")

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

(complete 0)

(if (< (/ (getversion) 65536) 37)
(
	(abort wrongkickstart)
))

; Determine which CPU the user has
;

(set thiscpu (database "cpu"))
(set n 0)
(set ch 1)
(set cpuvers 2)

(while
	(set cpuselstr
		(select n
			"68000"
			"68020"
			""
		)
	)
(
	(if (= thiscpu cpuselstr) (set cpuvers ch))

	(set n (+ n 1))
	(set ch (* 2 ch))
))

; Ask user which CPU version of the software to install
;

(user 2)
(set whatvers
	(askoptions
		(prompt prefs-cpu)
		(help prefs-cpu-help)
		(choices
			cpu000
			cpu020plus
		)
		(default cpuvers)
	)
)
(user oldlevel)

;(complete 5)

; copy the app
;

;(set copyver ac-source)
;
;(if (IN whatvers 1)
;    (set copyver ac-source020))
;
;(copyfiles
;	(prompt (cat copying-ac ac-dest "..."))
;	(source copyver)
;	(dest ac-dest)
;	(help @copyfiles-help)
;	(infos)
;	(newname ac-destname)
;)

(complete 10)





; Ask user where he wants the GUIFront library
;

(set lib-dest
	(askdir
		(prompt lib-where)
		(help lib-where-help)
		(default lib-dest)
	)
)

; Copy guifront.library (the correct CPU version of course)
;

(set n 0)

(while
	(set copyver
		( select n
			lib-source
			lib-source020
			""
		)
	)
(
	(if (IN whatvers n)
	(
		(copylib
			(prompt (cat copying-lib (tackon lib-dest lib-destname) "..."))
			(help @copylib-help)
			(source copyver)
			(dest lib-dest)
			(newname lib-destname)
			(confirm)
		)
	))

	(set n (+ n 1))
))

(complete 30)




; Ask user where he wants the easyrexx library
;

(set er-dest
	(askdir
		(prompt er-where)
		(help er-where-help)
		(default er-dest)
	)
)

; Copy easyrexx.library
;

(copylib
	(prompt (cat copying-er (tackon er-dest er-destname) "..."))
	(help @copylib-help)
	(source er-source)
	(dest er-dest)
	(newname er-destname)
	(confirm)
)

(complete 50)

; Ask user where he wants the GUIFront preferences editor
;

(set prefs-dest
	(askdir
		(prompt prefs-where)
		(help prefs-where-help)
		(default prefs-dest)
	)
)

; Copy the preferences editor (the correct CPU version of course)
;

(set n 0)

(while
	(set copyver
		(select n
			prefs-source
			prefs-source020
			""

		)
	)
(
	(if (IN whatvers n)
	(
		(copyfiles
			(prompt (cat copying-prefs prefs-dest "..."))
			(source copyver)
			(dest prefs-dest)
			(help @copyfiles-help)
			(infos)
		)
	))

	(set n (+ n 1))
))


(complete 75)

; Attempt to install catalog files for preferences editor
;
(if (exists "LOCALE:")
(
	(set lang
		(askoptions
			(prompt which-lang)
			(help which-lang-help)
			(choices
				"English"
				"Dansk"
				"Svenska"
			)
			(default default_lang)
		)
	)
	(user oldlevel)

	(set n 0)

	(while
		(set language
			(select n
				"English"
				"Dansk"
				"Svenska"
				""
			)
		)
	(
		(if (IN lang n)
		(
			(if (<> 0 n)
			(
				(makedir (cat prefscat-dest language))

				(copyfiles
					(source (cat prefscat-source language))
					(dest (cat prefscat-dest language))
					(all)
				)
			))
		))

		(set n (+ n 1))
	))
))

(complete 100)
