; Install imageio.library
; $VER: Install-imageio.library V1.0 (3.5.2000)
; © 2000 Paul Huxham

(set #catalog 0) ; english language is default

; Find the current language
(set #i 0)
(while (set #thisfile (select #i
		"english" "italiano" "deutsch" "español" "czech" "català" "dansk" "français"
		"hrvatski" "nederlands" "norsk" "polski" "português"
		"russian" "srpski" "suomi" "svenska" "ÃeÓtina"
		""))
	(
		(if (= @language #thisfile)
			(
				(set #catalog #i)
				(set #catalogname #thisfile)
			)
		)
		(set #i (+ #i 1))
	)
)

; Query user for their language, using system as default
(set #catalog
	(askchoice
		(prompt "Select your native language (language for installer)")
		(help @askoptions-help)
		(choices "English" "Italiano" "Deutsch" "Español" "Czech")
		(default #catalog)
	)
)

; Reset #catalogname as the user may have changed the language above
(if (< #catalog 5)
	(
		(set #catalogname (select #catalog "english" "italiano" "deutsch" "español" "czech"))
	)
)

; Some string defaults common for all languages
(set #HOMEPAGE "http://mafeking.scouts.org.au/photofolio")
(set #BLANK "\n")


; ************************** English texts ******************************
(set #INITIAL_MESSAGE
  (cat "\nWelcome to the imageio.library installer\n\n\n"
	"You can obtain updates and other information\nabout imageio.library from the homepage\n\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nYou need at least version 42.9 of Installer\nto install imageio.library")
(set #WRONG_CPU "\n\n\n\nYou need a 68020 CPU or better\nto use imageio.library")
(set #WRONG_OS_VERSION "\n\n\n\nYou need at least AmigaOS V2.0\nto use imageio.library")
(set #INSTALLING "\nInstalling")
(set #INSTALL_WHICH_VERSION "\nInstall version for which CPU?")
(set #PROMPT_INSTALL_IMAGEIOPREFS "\nInstall imageio.library prefs?\n\n(Used to alter the loading formats and\nother parameters of image loading)")
(set #INSTALLING_IMAGEIOPREFS "\nInstalling imageio.library prefs")
(set #PROMPT_INSTALL_CATALOG "\nWhich language catalogs would you like to install?")
(set #INSTALLING_CATALOG "\nInstalling ImageIOLibraryPrefs catalog")
(set #UPDATES_AVAILABLE "\nYou can get the latest version\nof imageio.library from the homepage")
(set #YES "Yes")
(set #NO "No")

; ************************** Italiano texts *****************************
(if (= #catalog 1)
(
(set #INITIAL_MESSAGE
  (cat "\nBenvenuto nell'installazione di imageio.library\n\n\n"
     "Puoi ottenere gli aggiornamenti, la mailing list e altre informazioni\nsu imageio.library alla homepage\n"
     #HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nNecessiti almeno della versione 42.9 dell'Installer\nper installare imageio.library")
(set #WRONG_CPU "\n\n\n\nNecessiti di una CPU 68020 o superiore\nper usare imageio.library")
(set #WRONG_OS_VERSION "\n\n\n\nNecessiti almeno di AmigaOS V2.0\nper usare imageio.library")
(set #INSTALLING "\nInstallazione")
(set #INSTALL_WHICH_VERSION "\nInstall version for which CPU?")
(set #PROMPT_INSTALL_IMAGEIOPREFS "\nInstallare preferenze per l'imageio.library?\n\n(Usata per alterare i formati di caricamento e\naltri paramentri del caricamento delle immagini)")
(set #INSTALLING_IMAGEIOPREFS "\nInstallazione preferenze imageio.library in corso")
(set #PROMPT_INSTALL_CATALOG "\nQuale catalogo della lingua desideri installare?")
(set #INSTALLING_CATALOG "\nInstallazione catalogo ImageIOLibraryPrefs")
(set #UPDATES_AVAILABLE "\nAggiornamenti di imageio.library e le librarie richieste\n\nsono disponibili sulla home page")
(set #YES "Sì")
(set #NO "No")
)
)

; ************************** Deutsch texts ******************************
(if (= #catalog 2)
(
(set #INITIAL_MESSAGE
  (cat "\nWillkommen zur Installation von imageio.library\n\n\n"
    "Updates, und weitere Information\nüber imageio.library gibt es auf der Homepage\n"
    #HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nSie benötigen mind. Version 42.9 des Installers\num imageio.library zu installieren")
(set #WRONG_CPU "\n\n\n\nSie benötigen einen 68020 oder höher\num imageio.library ausführen zu können")
(set #WRONG_OS_VERSION "\n\n\n\nSie benötigen mind. AmigaOS V2.0\num imageio.library ausführen zu können")
(set #INSTALLING "\nInstalliert")
(set #INSTALL_WHICH_VERSION "\nInstall version for which CPU?")
(set #PROMPT_INSTALL_IMAGEIOPREFS "\nImageio.library Prefs installieren?\n\n(Zum Ändern des Ladeformats und\nanderer Parameter des Ladens von Bildern)")
(set #INSTALLING_IMAGEIOPREFS "\nImageIOLibraryPrefs wird installiert")
(set #PROMPT_INSTALL_CATALOG "\nWelche Sprachen wollen Sie installieren?")
(set #INSTALLING_CATALOG "\nImageIOLibraryPrefs Sprachdatei wird installiert")
(set #UPDATES_AVAILABLE "\nUpdates für imageio.library und den dazugehörigen libraries\n\ngibt es auf der Homepage")
(set #YES "Ja")
(set #NO "Nein")
)
)

; ************************** Español texts ******************************
(if (= #catalog 3)
(
(set #INITIAL_MESSAGE
  (cat "\nBienvenido a la instalación de imageio.library\n\n\n"
	"Podrás obtener actualizaciones, acceder a listas de correo y tener más información\nsobre imageio.library en la página web de Homepage\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nNecesitas al menos la versión 42.9 del Installer\npara instalar imageio.library")
(set #WRONG_CPU "\n\n\n\nNecesitas un 68020 o superior\npara utilizar imageio.library")
(set #WRONG_OS_VERSION "\n\n\n\nNecesitas al menos AmigaOS V2.0\npara utilizar imageio.library")
(set #INSTALLING "\nInstalando")
(set #INSTALL_WHICH_VERSION "\nInstall version for which CPU?")
(set #PROMPT_INSTALL_IMAGEIOPREFS "\n¿Instalo imageio.library prefs?\n\n(Utilizada para los diferentes formatos y\notros parámetros de carga de imágenes)")
(set #INSTALLING_IMAGEIOPREFS "\nInstalando preferencias de imageio.library")
(set #PROMPT_INSTALL_CATALOG "\n¿Qué catalogos (lenguajes) quieres instalar?")
(set #INSTALLING_CATALOG "\nInstalando catálogo de ImageIOLibraryPrefs")
(set #UPDATES_AVAILABLE "\nLas actualizaciones de imageio.library y librerías necesarias\n\nestán disponibles en la página web de homepage")
(set #YES "Sí")
(set #NO "No")
)
)

; ************************** Czech texts ******************************
(if (= #catalog 4)
(
(set #INITIAL_MESSAGE
  (cat "\nVítejte pêi instalaci programu imageio.library!\n\n\n"
	"Dalîí informace, kontakt na ostatní uùivatele a aktualizace\nmûùete zdarma získat staùením z domovské stránky\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nK instalaci programu imageio.library\npotêebujete Installer V42.9 nebo vyîîí")
(set #WRONG_CPU "\n\n\n\nKe spuîtëní programu imageio.library\npotêebujete alespoñ CPU68020 nebo lepîí")
(set #WRONG_OS_VERSION "\n\n\n\nProgram imageio.library vyùaduje\nke spuîtëní AmigaOS V2.0")
(set #INSTALLING "\nInstalace")
(set #INSTALL_WHICH_VERSION "\nInstall version for which CPU?")
(set #PROMPT_INSTALL_IMAGEIOPREFS "\nInstall imageio.library prefs?\n\n(Used to alter the loading formats and\nother parameters of image loading)")
(set #INSTALLING_IMAGEIOPREFS "\nInstalace nastavení knihovny imageio.library")
(set #PROMPT_INSTALL_CATALOG "\nKterý z pêekladû chcete nainstalovat?")
(set #INSTALLING_CATALOG "\nInstalace pêekladu programu ImageIOLibraryPrefs")
(set #UPDATES_AVAILABLE "\n\nAktualizace programu imageio.library a pêísluîných\n\nknihoven jsou dostupné z domovské stránky")
(set #YES "Ano")
(set #NO "Ne")
)
)


; ************************* Global procedures ***************************
(procedure P_copylib lib destpath newlibname
	(
		(copylib
			(prompt (cat (cat #INSTALLING " ") (fileonly newlibname)))
			(help @copylib-help)
			(newname newlibname)
			(source lib)
			(dest destpath)
			(confirm)
			(optional askuser)
		)
	)
)


; *********************** imageio.library install

(if (< @installer-version (+ (* 65536 42) 9))
	(abort #WRONG_INSTALLER_VERSION)
)

(if (< (database "cpu") 68020 )
	(abort #WRONG_CPU)
)

(set os_version (/ (getversion "exec.library" (resident)) 65536))
(if (< os_version 37)
	(abort #WRONG_OS_VERSION)
)

; All essential version numbers are correct, continue installation
(message #INITIAL_MESSAGE)

(complete 0)


; *********************** Sort out what the user has where

; Establish CPU type

(set #ourcpu (database "cpu"))

(if (= #ourcpu "68020") (set #ourcpu 0))
(if (= #ourcpu "68030") (set #ourcpu 0))
(if (= #ourcpu "68040") (set #ourcpu 1))
(if (= #ourcpu "68060") (set #ourcpu 2))

(complete 0)

; *********************** Install imageio.library

(set #cpu_install
	(askchoice
		(help @askchoice-help)
		(prompt #INSTALL_WHICH_VERSION)
		(choices "68020" "68040" "68060")
		(default #ourcpu)
	)
)

(set #entry (select #cpu_install "020" "040" "060" ""))
(set #entry (cat "libs/imageio.library_" #entry))

(set @default-dest "Libs:")

(if (= @user-level 2) ;If expert user, ask directory
	(
		(set @default-dest
			(askdir
				(prompt #SELECT_INSTALL_DIRECTORY)
				(help @askdir-help)
				(default @default-dest)
			)
		)
	)
)

(P_copylib #entry @default-dest "imageio.library")

(complete 70)

(if (=
	(askchoice
		(help @askchoice-help)
		(prompt #PROMPT_INSTALL_IMAGEIOPREFS)
		(choices #YES #NO)
		(default 0)
	)	0 )
	(
		(copyfiles
			(prompt #INSTALLING_IMAGEIOPREFS)
			(source "prefs")
			(choices "ImageIOLibraryPrefs" "ImageIOLibraryPrefs.info" )
	    (help @copyfiles-help)
			(dest @default-dest)
			(files)
			(noposition)
			(optional askuser)
			(confirm)
		)

		(complete 80)

		; *********************** Install locale catalog


		(set #localedest "LOCALE:Catalogs")

		(if (<> #catalog 0)
			(
				(set #localesrc 1) ; Defaults to first entry
				(set #i 0)
				(while (set #thiscat (select #i "italiano" "deutsch" "español" "czech" ""))
					(
						(if (= #catalogname #thiscat)
							(
								(set #x #i)
								(while (> #x 0)
									(set #localesrc (* #localesrc 2))

									(set #x (- #x 1))
								)
							)
						)

						(set #i (+ #i 1))
					)
				)
			)
			(
				(set #localesrc 0)
			)
		)

		(set #installcat
			(askoptions
				(prompt #PROMPT_INSTALL_CATALOG)
				(choices "Italiano" "Deutsch" "Español" "Czech")
				(default #localesrc)
				(help @askoptions-help)
			)
		)

		(set #i 0)
		(while (< #i 4)
			(set #x #i)
			(set #y 1)

			(while (> #x 0)
				(set #y (* #y 2))

				(set #x (- #x 1))
			)

			(if (bitand #installcat #y)
				(
					(set #localecat (select #i "Italiano" "Deutsch" "Español" "Czech"))

					(copyfiles
						(prompt (cat (cat #INSTALLING_CATALOG " " ) #localecat))
						(help @copyfiles-help)
						(source (tackon "prefs/catalogs" #localecat))
						(choices "ImageIOLibraryPrefs.catalog")
						(dest (tackon #localedest #localecat))
						(confirm)
						(optional askuser)
						(files)
					)
				)
			)

			(set #i (+ #i 1))
		)
	)
)

(complete 100)

; *********************** Finished installation

(message (cat #UPDATES_AVAILABLE #BLANK #BLANK #HOMEPAGE))
