;$VER: MasterISO v2.0 (25.1.98) 
;installer routine Copyright ©1994-1998 Asimware Innovations Inc.

(onerror (makeassign "MasterISOInst") )

(set #wbversion (getversion "libs:version.library"))
(set #wbversion (/ #wbversion 65536) )

(set @default-dest "Work:")

(set #theirlevel @user-level )

(set #English 0)
(set #Deutsch 1)
(set #Français 2)
(set #Svenska 3)
(set #Italiano 4)

;*****
; set the language we will be using
;
(if (= @language "english") 
	(set #our_language #English) 
)
(if (= @language "deutsch") 
	(set #our_language #Deutsch) 
)
(if (= @language "nederlands") 
	(set #our_language #Nederlands) 
)
(if (= @language "italiano") 
	(set #our_language #Italiano) 
)
(if (= @language "svenska") 
	(set #our_language #Svenska) 
)
(if (= @language "français") 
	(set #our_language #Français) 
)



;****************************
; set English language strings
(if (= #our_language #English) (
(set #text_needwb_2 			(cat "\n\nAmigaDOS 2.0 or higher is required for MasterISO v2.x"
			 						"\n\nAn upgrade will be needed for your Amiga."
			 						"\n\nYou are currently running version " #wbversion "."
))


(set #tp_insert_disk 		"Please insert the disk labeled \"MasterISO_v2_Install\"." )
(set #th_insert_disk 		"The MasterISO program will be copied from this disk into your system.")


(set #text_abort1				"\n\nApproximately ")
(set #text_abort2				"K of disk space is needed on your SYS: volume.\n\nYou only have ")
(set #text_abort3				"K free.\n\nDelete or transfer some files from the SYS: volume and try again.")


(set #tp_ask_iso 				"Specify where the MasterISO_v2 directory will be created:" )
(set #th_ask_iso 				"A drawer called MasterISO_v2 will be created in this specified directory." )

(set #tp_create_iso			"Creating the MasterISO_v2: directory..." )
(set #th_create_iso 			"This will create the specified directory for the program." )

(set #tp_ask_installiso 	"\n\nShould MasterISO be installed?" )
(set #th_ask_installiso_1 	"\n\nThis will copy over the MasterISO program to the ")
(set #th_ask_installiso_2 	" directory\n\nIf you do not wish the MasterISO program to be transferred to your system, skip this step.\n" )

(set #tp_copying_iso_1		"\n\nCopying the MasterISO program to the " )
(set #tp_copying_iso_2		" directory.\n" )
(set #th_copying_iso_1		"\n\nThis will copy over the MasterISO program to your")
(set #th_copying_iso_2		" directory.\n" )

(set #tp_set_iso_icon 		"\n\Setting MasterISO icon.\n")
(set #th_set_iso_icon 		"\n\nThis will reset the MasterISO icon.\n")

(set #tp_make_projects 		"Creating the MasterISO:Projects directory..." )
(set #th_make_projects 		"This will create a sub-directory which will be used to store saved projects.")

(set #tp_make_addendum 		"Creating the MasterISO:Addendum directory..." )
(set #th_make_addendum 		"This will create a sub-directory which will be used to store any manual addendums and other supplementary text files.")

(set #tp_copying_addendum	"\n\nCopying addendums to the MasterISO:Addendum directory.\n" )
(set #th_copying_addendum	"\n\nThis will copy over any addendum and supplementary text files to the MasterISO:Addendum directory.\n" )

(set #tp_startup 				"Inserting assignment command into the startup-sequence:\n\n" )
(set #th_startup 				(cat "Assignment commands are being inserted into your "
									"\"S:Startup-Sequence\" or \"S:User-Startup\" file to "
									"allow MasterISO to find the needed files.") )


(set #tp_catalogs				"Which alternate language catalogs would you like installed?")
(set #th_catalogs				(cat "MasterISO has been been configured to the following "
									"alternate languages:\n\n    Deutsch and Italiano\n\n"
									"Select which languages you would like to use with our software.  English "
									"language support is automatically provided as standard within the software.")
)

(set #tp_bigscreen			"Please note that the alternate language translations provided with MasterISO are considerably longer than their English equivalents.\n\nIn order to use these translations, you will need to select either a smaller font or a screen resolution of at least 800x600.\n\nThinpazB, by Daniel Mealha Cabrita, will be automatically installed as your default font for MasterISO v2.")

(set #tp_copylocale1			"\n\nCopying locale ")
(set #tp_copylocale2			" language catalogs.\n")
(set #th_copylocale			"\n\nThis will copy over the desired language file.")

(set #tp_copying_atapi		"\n\nCopying asim_atapi.device\n")
(set #th_copying_atapi		"\n\nThis will copy over the asim_atapi.device driver needed to use ATAPI CD-R and CD-RW drives.")

(set #tp_copying_sound 		"\n\nCopying sound effects\n")
(set #th_copying_sound 		"\n\nThis will copy over the bing and crash sound effects.")

(set #tp_copying_fonts		"\n\nCopying the ThinpazB font\n")
(set #th_copying_fonts		"\n\nThis will copy over the ThinpazB font needed to use the verbose catalogue files in regular screen resolutions.")

(set #tp_setting_defaults	"\n\Setting MasterISO defaults\n")
(set #th_setting_defaults	"\n\nThis will set the default settings file for MasterISO to properly run on your system configuration.")
))


;****************************
; set German language strings
;(if (= #our_language #Deutsch) (
;))

;****************************
; set French language strings
;(if (= #our_language #Français) (
;))

;****************************
; set Swedish language strings
;(if (= #our_language #Svenska) (
;))

;****************************
; set Italian language strings
;(if (= #our_language #Italiano) (
;))

;****************************
; set Nederlands language strings
;(if (= #our_language #Nederlands) (
;))






;****************************
;  Need WB 2.0 or higher.
(if (< #wbversion 37)
	(abort #text_needwb_2)
)


;****************************
;  Lock our install disk
(askdisk
	(prompt #tp_insert_disk)
	(help	#th_insert_disk)
	(dest  "MasterISO_v2_Install")
	(newname "MasterISOInst")
)




;****************************
; compute our space required
(set #installsize 0)
(set #installsize (+ #installsize (getsize "MasterISOInst:MasterISO") ))





;****************************
;  ask for MasterISO
(user 2)
(set #MasterISODir
	(askdir
		(prompt #tp_ask_iso )
		(help #th_ask_iso)
		(default @default-dest)
		(newpath)
	)
)
(user #theirlevel)



;****************************
; make sure there is enough space 

(if (< (getdiskspace #MasterISODir) #installsize)
	(abort  #text_abort1 (/ #installsize 1024) #text_abort2 (/ (getdiskspace "SYS:") 1024)	#text_abort3 )
)


(set #MasterISODir (tackon #MasterISODir "MasterISO_v2"))
(set @default-dest #MasterISODir)




;****************************
;  create directory if it doesn't exist
(if (not (exists #MasterISODir (noreq)))
	(makedir #MasterISODir
		(prompt #tp_create_iso)
		(help #th_create_iso)
		(infos)
		)
)
(makeassign "MasterISODest" #MasterISODir)



;****************************
;  Install MasterISO?
(set #instMasterISO
	(askbool
		(prompt #tp_ask_installiso)
		(help #th_ask_installiso_1 #MasterISODir #th_ask_installiso_2 )
		(default 1)
	)
)

(if #instMasterISO
	((protect "MasterISODest:MasterISO" "rwed" )
	(protect "MasterISODest:MasterISO.info" "rwed" )




;***************************************************
; copy over main program 
	(run "MasterISOInst:c/lx e MasterISOInst:MasterISO.lha MasterISODest:"
		(prompt #tp_copying_iso_1 #MasterISODir #tp_copying_iso_2 )
		(confirm)
		(help  #th_copying_iso_1 #MasterISODir #th_copying_iso_2 )
	)


	(tooltype
		(prompt #tp_set_iso_icon)
		(dest "MasterISODest:MasterISO")
		(noposition)
		(help #th_set_iso_icon)
		(confirm)
	)


;***************************************************
; copy over sound effects
	(run "MasterISOInst:c/lx e MasterISOInst:SoundEffects.lha MasterISODest:"
		(prompt #tp_copying_sound )
		(confirm)
		(help  #th_copying_sound )
	)



;***************************************************
; make Projects directory
	(set #temp "MasterISODest:Projects")
	(if (not (exists #temp (noreq)))
		(makedir #temp
			(prompt #tp_make_projects)
			(help #th_make_projects )
			(infos)
			)
	)



	
;***************************************************
; make Addendum directory
	(set #temp "MasterISODest:Addendum")
	(if (not (exists #temp (noreq)))
		(makedir #temp
			(prompt #tp_make_addendum)
			(help #th_make_addendum)
			(infos)
			)
	)


;***************************************************
; and copy over any addendum files that may be present
	(copyfiles
		(prompt #tp_copying_addendum)
		(source "MasterISOInst:Addendum")
		(dest "MasterISODest:Addendum")
		(infos)
		(pattern "#?.txt")
		(help  #th_copying_addendum)
		(confirm)
	)
	




;***************************************************
; set assignments 
	(makeassign "MasterISO" #MasterISODir)

	(protect "S:User-Startup" "rwed" )
	(protect "S:Startup-Sequence" "rwed" )
	(set #assign_cmd (cat "assign MasterISO: \"" #MasterISODir "\"\n"))

	(startup "MasterISO"
		(command #assign_cmd)
		(prompt (cat #tp_startup #assign_cmd))
		(help #th_startup)
	)



;***************************************************
; copy over asim_atapi.device for ATAPI CD-R drives
	(run "MasterISOInst:c/lx e MasterISOInst:devs.lha devs:"
		(prompt #tp_copying_atapi )
		(confirm)
		(help  #th_copying_atapi )
	)
))







;***************************************************
;  ask which languages to be added
;
(if (exists "LOCALE:" (noreq))
	((user 2)
	(set #language
		(askoptions
			(prompt #tp_catalogs)
			(help #th_catalogs )
			(choices "Deutsch" "Italiano")
			(default 1)
		)
	)
	
	
	(if (not (= 0 #language))
		(
		;***************************************************
		;  tell about the verbose languages
		;	
		(message #tp_bigscreen)
		(user #theirlevel)
		

		;***************************************************
		;  copy and setup the ThinpazB font.
		;	
		(run "MasterISOInst:c/lx e MasterISOInst:fonts.lha fonts:"
			(prompt #tp_copying_fonts )
			(confirm)
			(help  #th_copying_fonts )
		)

		(run "MasterISOInst:c/lx e MasterISOInst:default_thinpazfont.lha MasterISODest:"
			(prompt #tp_setting_defaults)
			(confirm)
			(help  #th_setting_defaults)
		)
		
	))
	
	(user #theirlevel)
	

	
	;***************************************************
	;  copy any requested catalogue files
	;	
	(set n 0)
	(while
		(set #langdir
			(select n "Deutsch"
				       "Italiano"
				       ""
				)
			)
		(
		
		(if (IN #language n)
			((set #langdest (cat (tackon "LOCALE:catalogs/" #langdir) "/") )
			(set #langsrc (cat (tackon "MasterISOInst:catalogs/" #langdir) ".lha"))
			
			(run (cat "MasterISOInst:c/lx e " #langsrc " " #langdest)
				(prompt #tp_copylocale1 #langdir #tp_copylocale2 )
				(help #th_copylocale)
				(confirm))
			)
		)
	
		(set n (+ n 1))
		)
	)
))	


	
(makeassign "MasterISOInst")
