; $VER: AMIPopUp Install V1.0 (24.06.98) - written by Sascha "SieGeL" Pfalz
; Installer and Installer project icon
; (c) Copyright 1985-98 Amiga International Inc.  All Rights Reserved.
;
; For best view set TAB to 2
;
; This script follows the rules for the Installer, all text vars have a 
; t_ preceeding the var name, all other vars have the # in front of the
; names and all sub procedures (if any) will start with P_ .
;
; V1.0 (24.06.98) - Initial Version, Script is able to update or full install
                    

;===================
;= Check-Variables =
;===================

(set #MUI "MUI")
(set #MUIMASTER_VMIN 11)
(set #MUIMASTER_PATH "MUI:Libs/muimaster.library")
(set #AMIPOPUP "AMIPopUp")
(set #AMIGUIDE "AMIPopUp.guide")
(set #AMIGUIDE_GER "AMIPopUp_ger.guide")
(set #AMIHIST "AMIPopUp.history")
(set #PREPHIST "PrepMail.history")
(set #AMICATDE "catalogs/deutsch/AMIPopUp.catalog")
(set #AMICATSW "catalogs/svenska/AMIPopUp.catalog")
(set #PREPMAIL "PrepMail")


;================
;= GERMAN TEXTS =
;================

(IF (= @language "deutsch")
	(
	(set default_lang 2)

	(set t_StartMsg			(cat		"\nInstallations-Skript fr AMIPopUp & PrepMail\n\n"
															"Dieses Skript installiert AMIPopUp und alle relevanten\n"
															"Dateien auf Ihrem System.\n\n"
															"AMIPopUp ist  1998 by Sascha 'SieGeL' Pfalz\n"
															"MUI ist  1993-98 by Stefan Stuntz"))
	(set t_bad-kick			(cat		"\nSie bentigen mindestens AmigaOS V3.0 oder\n\n"
															"hher, um AMIPopUp zu benutzen !\n\n"
															"-> Bitte updaten Sie Ihr System <-"))
	(set t_wrong_mui		(cat		"Falsche MuiMaster.library Version!\n\n"
															"Installiert ist V%ld.%ld, bentigt wird aber mind. V11 !\n\n"
															"Bitte updaten Sie Ihr MUI System auf V3.6+\n(Library-Version 11+) !"))
	(set t_no_mui				(cat		"Konnte MUI nicht finden !\n"
															"User-Editor bentigt unbedingt MUI V3.6+ um zu arbeiten !\n\n"
															"Bitte erst das MUI System installieren (es lohnt sich) und\n"
															"dann diese Installation nochmal beginnen !"))
	(set t_AskForDest						"Bitte Ziel-Pfad fr %s angeben:")
	(set t_copyfile							"Kopiere jetzt %s...")
	(set t_selectlocale	(cat		"Bitte Sprache(n) zum Installieren/Updaten auswhlen:\n"
															"(Alle Kataloge werden nach PROGDIR:Catalogs/ kopiert)"))
	(set t_askfordocs						"Dokumentation installieren/updaten ?")
	(set t_selectdocs						"Bitte auswhlen, welche Teile der Dokumentation installiert/geupdated werden sollen:")
	(set t_askforddest					"Bitte Zielverzeichnis fr die Dokumentation auswhlen:")
	(set t_copycatalog					"Kopiere Katalog Datei...")
	(set t_askdocshelp	(cat		"Wenn Sie wnschen kann der Installer die mitgelieferten\n"
															"Dokumentationen installieren. Sie haben dann die Mglichkeit,"
															"ein Verzeichnis fr die Doks anzugeben."))
	(set t_lastnotice		(cat		"\nInstallation erfolgreich.\n\n"
															"Bitte lesen Sie UNBEDINGT die Hinweise in der Dokumentation "
															"nach, wie PrepMail in Ihre smb.conf Datei eingetragen werden muss!!!\n\n"
															"Sollte die TextInput.mcc Klasse noch nicht installiert sein,\n"
															"dann entpacken Sie das beigefgte Archiv (textinput_13.36.lzx) und installieren es."))
	))

;=================
;= ENGLISH TEXTS =
;=================

(IF (= @language "english")
	(
	(set default_lang 4)

	(set t_StartMsg 	(cat			"\nInstallation Script of AMIPopUp & PrepMail\n\n"
															"This script will install AMIPopUp and all required\n"
															"files to your System.\n\n"
															"AMIPopUp is  1998 by Sascha 'SieGeL' Pfalz\n"
															"MUI is  1993-98 by Stefan Stuntz"))
	(set t_bad-kick			(cat		"\n\nYou must be using AmigaOS V3.0 or higher\n\n"
															"to use AMIPopUp !\n\n"
															"-> Please update your machine ! <-"))
	(set t_wrong_mui		(cat		"Wrong MuiMaster.library Version !\n\n"
															"Installed is V%ld.%ld, required is at least V11 !\n\n"
															"Please update your MUI System to at least V3.6+\nLibrary-Version 11+) !"))
	(set t_no_mui				(cat		"Unable to find MUI System !\n"
															"AMIPopUp requires MUI V3.6+ to work !\n"
															"Please install first the MUI System and restart this Installation\n"
															"after the MUI system is installed."))
	(set t_AskForDest						"Specify destination for %s:")
	(set t_copyfile							"Now copying file %s...")
	(set t_selectlocale	(cat		"Please choose language(s) to install/update:\n"
															"(English is built-in, all other catalogs will be copied to PROGDIR:Catalogs/"))
	(set t_askfordocs						"Do you wish to install/update the documentation ?")
	(set t_selectdocs						"Please choose which parts of the documentation should be installed/updated:")
	(set t_askforddest					"Select Destination directory for the documentation:")
	(set t_copycatalog					"Copy catalog file...")
	(set t_askdocshelp	(cat		"If you wish Installer will copy the supplied docs in a\n"
															"directory of your choice."))
	(set t_lastnotice		(cat		"\nInstallation successful.\n\n"
															"Please make sure that you read the docs about adding PrepMail "
															"to your smb.conf file !!!\n\n"
															"If you haven't installed the TextInput.mcc class yet, you should "
															"extract the supplied archive (textinput_13.36.lzx) and install it, too."))

	))

;****************************************************************************
;***                  MAIN INSTALLATION SCRIPT STARTS HERE !              ***
;****************************************************************************

(set #osver (/ (getversion) 65536))				; Determine OS Version...
(if (< #osver 37) ( (ABORT t_bad-kick)))	; ...and stop if OS < 37
(complete 0)
(message t_StartMsg)
(complete 1)
(welcome)

;======================================================================
;= FIRST SYSTEM-CHECKS TO DETERMINE USED AMIGA AND INSTALLED SOFTWARE =
;======================================================================

(set #MUI_ASSIGN (getassign #MUI))				; Check if MUI exists!

(if (<> #MUI_ASSIGN "")
	(
	(set #muiver (/ (getversion #MUIMASTER_PATH) 65536)) 	; Get Version
	(set #muirev (* (getversion #MUIMASTER_PATH) 65536))	; ???
	(set #muirev (/ #muirev 65536))												; Get Revision
	(if (< #muiver #MUIMASTER_VMIN) (ABORT (t_wrong_mui #muiver #muirev)))
	(complete 6)
	)
	(
	(abort t_no_mui)
	))


;======================================================================
;=       PROMPT FOR THE DESTINATION DIRECTORY & COPY MAIN FILE        =
;======================================================================

(if (<> 0 (exists #AMIPOPUP))
	(

	(set #mypath "")

	(until (<> #mypath "")
		(
		(set #mypath
			(askdir (prompt (t_AskForDest #AMIPOPUP))
							(default "MUI:")
							(help @askdir-help)))
		))
	(complete 12)

	(set @default-dest #mypath)


	(copylib 	(prompt (t_copyfile #AMIPOPUP))
						(source "AMIPopUp")
						(dest		@default-dest)
						(confirm)
						(help	@copylib-help)
						(infos))
	)
	(
	(set @default-dest "MUI:")
	)
)
(complete 20)

;======================================================================
;=              CHECK FOR PREPMAIL AND INSTALL IT, TOO                =
;======================================================================

(if (<> 0 (exists #PREPMAIL))
	(

	(set #preppath "")

	(until (<> #preppath "")
		(
		(set #preppath
			(askdir (prompt (t_AskForDest #PREPMAIL))
							(default "AmiTCP:bin")
							(help @askdir-help)))
		))

	(complete 22)

	(copylib 	(prompt (t_copyfile #PREPMAIL))
						(source "PrepMail")
						(dest		#preppath)
						(confirm)
						(help	@copylib-help))
))		

;======================================================================
;=                      INSTALL LOCALE CATALOGS                       =
;======================================================================

(set #def 0)	; Init var

(if (<> 0 (exists #AMICATDE))	
	(
	(set #choice1 "[2pdeutsch")
	(if (= @language "deutsch") (set #def (+ #def 1)))
	)
	(
	(set #choice1 "[2p")
	))

(if (<> 0 (exists #AMICATSW))	
	(
	(set #choice2 "svenska")
	(if (= @language "svenska") (set #def (+ #def 2)))
	)
	(
	(set #choice2 "")
	))

(set #catalogs
	(askoptions	(prompt t_selectlocale)
							(help @askoptions-help)
							(choices	#choice1
												#choice2)
							(default #def)))

(complete 30)

(if (IN #catalogs 0) 
	(
	(set #mkpath (tackon @default-dest "catalogs/deutsch"))
	(makedir #mkpath)
	(copylib 	  (prompt t_copycatalog)
							(source "catalogs/deutsch/AMIPopUp.catalog")
							(dest 	#mkpath)
							(help @copyfiles-help))))

(complete 40)

(if (IN #catalogs 1) 
	(
	(set #mkpath (tackon @default-dest "catalogs/svenska"))
	(makedir #mkpath)
	(copylib 	  (prompt t_copycatalog)
							(source "catalogs/svenska/AMIPopUp.catalog")
							(dest 	#mkpath)
							(help @copyfiles-help))))

;======================================================================
;=        INSTALL AMIGA-GUIDE DOCUMENTATION & HISTORY FILE            =
;======================================================================

(complete 55)

(set #myguide (exists #AMIGUIDE))
(set #myhist (exists #AMIHIST))
(set #mygerguide (exists #AMIGUIDE_GER))
(set #myprephist (exists #PREPHIST))

(set #docdef 0)

(if (OR (<> 0 #myguide) (<> 0 #myhist) (<> 0 #mygerguide) (<> 0 #myprephist))
	(
	(if (= 1 (AskBool	(prompt t_askfordocs)	(help	t_askdocshelp)))
		(

		(if (<> 0 #myguide) 
			(              
			(set #selguide "AmigaGuide Manual - English (19kb)")
			(set #docdef (+ #docdef 1))
			)
			(
			(set #selguide "")
			)
		)

		(if (<> 0 #mygerguide) 
			(
			(set #selgerguide "AmigaGuide Manual - Deutsch (N/A!)")
			(set #docdef (+ #docdef 2))
			)
			(
			(set #selgerguide "")
			)
		)


		(if (<> 0 #myhist) 	
			(            
			(set #selhis "AMIPopUp.History            ( 1kb)")
			(set #docdef (+ #docdef 4))
			)
			(
			(set #selhis "")
			)
		)

		(if (<> 0 #myprephist) 	
			(            
			(set #prephis "PrepMail.History            ( 1kb)")
			(set #docdef (+ #docdef 8))
			)
			(
			(set #prephis "")
			)
		)

		(complete 60)


		(set #docparts
			(askoptions (prompt		t_selectdocs)
									(help			@askoptions-help)
									(choices #selguide
													 #selgerguide
												   #selhis
													 #prephis)
									(default #docdef)))
		(complete 70)

		(if (<> 0 #docparts)
			(
			(set #docdest
				(askdir (prompt 	t_askforddest)
								(help			@askdir-help)
								(default	@default-dest)))

			(complete 75)

			(if (<> "" #docdest)
				(
				(if (IN #docparts 0)
					(
					(copyfiles 	(prompt "Install AmigaGuide...")
											(help		@copyfiles-help)
											(source	"AMIPopUp.guide")
											(dest		#docdest)
											(infos))

					(complete 85)

					))

				(if (IN #docparts 1)
					(
					(copyfiles 	(prompt "Install AmigaGuide...")
											(help		@copyfiles-help)
											(source	"AMIPopUp_ger.guide")
											(dest		#docdest)
											(infos))

					(complete 90)

					))

				(if (IN #docparts 2)
					(
					(copyfiles 	(prompt "Install History...")
											(help		@copyfiles-help)
											(source	"AMIPopUp.history")
											(dest		#docdest)
											(infos))
					))

				(if (IN #docparts 3)
					(
					(copyfiles 	(prompt "Install History...")
											(help		@copyfiles-help)
											(source	"PrepMail.history")
											(dest		#docdest)
											(infos))

					(complete 95)

					))
				))
			))
		))
	))


;======================================================================
;=    END OF INSTALLATION - NOTICE USER ABOUT SMB.CONF ADDING !!!     =
;======================================================================


(complete 99)

(message t_lastnotice)

(complete 100)
(exit)
