; $VER: Install_CFM 2.1 (15.10.95)
; Script to install ColorFontMaster

(complete 0)

(set ProductName	"ColorFontMaster")	; product name
(set ProductBaseName	"CFM")			; product base name
(set VersionNum		"2.1")			; product version number

(set @default-dest 	"")
(set InstOpt 		0)
(set old_level @user-level)

(set rtlib	"LIBS/reqtools.library")
(set catdir	"Locale/Catalogs/")
(set source_dir "CFM/")
(set files_dir "Files/")
(set fonts_dir "Fonts/")
(set TheDir "")
(set CurrentEntry 0)
(set CFMVersion 0)
(set TheVersion 0)

;=============================================================================
  (
	(set default_lang 0)

	(set #bad-kick ("ColorFontMaster requires AmigaDOS version 2.04 or higher. If you have AmigaDOS 1.3 or earlier you must purchase an upgrade to AmigaDOS before using ColorFontMaster."))

	(set #ask-drawer ("In which drawer should CFM be installed?"))
	(set #ask-drawer-help
	   (cat "\nChoose the destination partition or directory "
		"into which ColorFontMaster will be copied. "
		"Unexisting drawers will be created automatically. "
	   )
	)

	(set #which-language ("\nWhich languages should be installed?"))
	(set #which-language-help
	   (cat "\nThe Amiga can be operated in many different "
		"languages. Several files must be copied to your "
		"hard drive for each language supported.\n\n"
		"To reduce the amount of space consumed by the "
		"language files, you can select only the "
		"files of specific languages to be copied.\n\n"
		"Check the boxes of the languages you wish "
		"to have available on your system.\n\n"

		"CFM uses the system default language if "
		"the catalog file is available. Otherwise or "
		"if the locale.library is unavailable, it will use "
		"its built-in language which is English.\n\n"
		@askoptions-help
	   )
	)
  )

;=============================================================================
; make sure we are running under V37+

(if (< (/ (getversion) 65536) 37)
  (
	abort #bad-kick
  )
)

;=============================================================================
; ask for CFM drawer

(set target_dir (askdir (prompt #ask-drawer)
			(help #ask-drawer-help @help-drawer)
			(default "SYS:")
		)
)

;=============================================================================
; copy CFM binaries:
;
;(
;	(user 2)
	(set InstOpt 
		(askoptions 
			(prompt
				("Select the version of %s you want to use. " ProductName))
			(help
				"This part of the installation procedure lets you select the "
				("version of the %s package you want to install at this time.\n" ProductName)
				"\n"
				"68000 version\n"
				"This option lets you install the standard version made "
                "for Amigas equiped with a standard MC68000 processor."
				"\n"
				"680x0 version\n"
				"This option lets you install the version for machines "
				"equiped with a MC68020, MC68030 or MC68040 processor: "
				"like A1200 and A4000"
				"\n"
				"\n"
				@askoptions-help
		  		)
	    	(choices 
				"68000 version"				; bit position 0 -- todo & 1
				"680x0 version (x=2,3,4)"	; bit position 1 -- todo & 2
			)
			(default 1)
		)
	)

;	(user old_level)	
	(set comp 5)
	(set CFMVersion 0)
	(while 	(set TheVersion (select CFMVersion  "CFM"
								  "CFM.020"
								  ""))
	  (
		(complete comp)
		(set comp (+ comp 5))
		(if (IN InstOpt CFMVersion)				; if bit position n is on
		  (
			(copyfiles 	(source (cat source_dir TheVersion))
			  	 		(dest target_dir)
						(help @copyfiles-help)
			)
			(copyfiles 	(source (cat source_dir TheVersion ".info"))
			  	 		(dest target_dir)
						(help @copyfiles-help)
			)
		  )
		)
    	(set CFMVersion (+ CFMVersion 1))
	  )
	)
	(complete comp)

(copyfiles 	
		(prompt "Copying all documentation and pictures.")
		(help @copyfiles-help)
		(source  files_dir)
		(dest target_dir)
		(pattern "#?")
		(files)
		(infos)
		(confirm)
)

(complete 20)

(makedir (cat  target_dir "/Convolutions"))
(makedir (cat  target_dir "/Colors"))
(makedir (cat  target_dir "/PixFonts"))
(makedir (cat  target_dir "/Patterns"))
(makedir (cat  target_dir "/Brush"))
(makedir (cat  target_dir "/Textures"))


; copy the extra disks
(complete 25)

(
;	(user 2)
	(set InstOpt 
		(askoptions 
			(prompt
				("Select the extra parts of the %s package you want to install. " ProductName))
			(help
				"This part of the installation procedure lets you select the "
				("parts of the %s package you want to install at this time.\n" ProductName)
				"\n"
				"*** Colorfonts\n"
				"This option lets you install the ready made Colorfonts. "
				"These Colorfonts can be made by yourself, so just install "
				"them if you're sure of plenty harddisk space! "
				"\n"
				"*** Patterns\n"
				"This option lets you install the ready made patterns, "
				"matching to the Pix Font pictures, delivered in this "
				"package."
				"\n"
				"*** Colormaps\n"
				"This option lets you install the ready made colormaps "
				"\n"
				"*** Convolution matrices\n"
				"This option lets you install the matrices, to be used "
				"in ColorFontMaster's F/X option"
				"\n"
				"*** Textures & Brushes\n"
				"This option lets you install the ready made brushes and "
				"multi-colored textures"
				"\n"
				"*** PixFonts\n"
				"This option lets you install the pictures containing "
				"drawn characters in several resolutions and colors"
				"\n"
				"\n"
				@askoptions-help
		  		)
	    	(choices 
				"Colorfonts"			; bit position 0 -- todo & 1
				"Patterns"				; bit position 1 -- todo & 2
				"Colormaps"				; bit position 2 -- todo & 4
				"Convolution matrix"	; bit position 3 -- todo & 8
				"Brushes"				; bit position 4 -- todo & 16
				"Textures"				; bit position 5 -- todo & 32
				"PixFonts"				; bit position 6 -- todo & 64
			)
			(default 127)
		)
	)
;	(user old_level)	
	(set comp 25)

	(if (IN InstOpt 0)				; if bit position 0 is on
	(
	(copyfiles
		(help @copyfiles-help)
		(source fonts_dir)
		(dest "FONTS:")
   		(all)
	)
	))
	(set CurrentEntry 1)
	(while 	(set TheDir (select CurrentEntry  "Fonts"
								  "Patterns"
								  "Colors"
								  "Convolutions"
								  "Brush"
								  "Textures"
								  "PixFonts"
								  ""))
	  (
		(complete comp)
		(set comp (+ comp 10))
		(if (IN InstOpt CurrentEntry)				; if bit position n is on
		  (
			(copyfiles 	(source TheDir)
			  	 		(dest (cat target_dir (cat "/" TheDir)))
						(help @copyfiles-help)
						(all))
		  )
		)
    	(set CurrentEntry (+ CurrentEntry 1))
	  )
	)
	(complete comp)
)

(complete 80)
;=============================================================================
; copy reqtools.library to LIBS:
;
(copylib
	(prompt "The ReqTools library is copied ...")
	(help	
		"The ReqTools library is needed to produce file-, color- and "
		"confirmation requesters. If you have already an installed "
		"version; here's a new version.\n\n"
		@copyfiles-help	)
	(source rtlib)
	(dest "LIBS:")
	(confirm)
)
(complete 85)
;=============================================================================
; copy amigaguide.library to LIBS:
;
(copylib
	(prompt "The AmigaGuide library is copied ...")
	(help	@copyfiles-help)
	(source rtlib)
	(dest "LIBS:")
	(confirm)
)
(complete 88)
;=============================================================================
; copy catalog files (only relevant on v38+ machines)
;
(if (exists "LOCALE:")
(
    (user 2)
    (set lang (askoptions (prompt #which-language)
			  (help #which-language-help)
			  (choices "Deutsch" "Nederlands")
			  (default default_lang)
	  )
    )
    (user old_level)

    (set n 0)
    (while (set language (select n "deutsch"
				   "nederlands"
				   ""
			 )
	   )
    (
	(if (IN lang n)
	(
		    (makedir (cat "LOCALE:Catalogs/" language))
		    (copyfiles (source (cat catdir language))
			       (dest (cat "LOCALE:Catalogs/" language))
			       (all)
		    )
	))
	(set n (+ n 1))
    ))
))

(transcript "Ask for permission to alter the \"S:User-Startup\" file")

(startup "ColorFontMaster"
   (prompt "An Assign to ColorFontMaster: is added to the \"S:User-Startup\" file so that your system"
           (" will be properly configured to use %s." ProductName))
   (help @startup-help)
   (command (cat "Assign ColorFontMaster: " target_dir))
)
(transcript "\"S:User-Startup\" was altered")
(transcript "Setting up \"ColorFontMaster:\" assign if not already assigned")
(makeassign ProductName target_dir)
(transcript "Installation complete")
(complete 100)

