;
; Blanker Installation Script $VER:Blanker 37.3 (24.6.93)
;

(set @default-dest "SYS:WBStartup")
(set @module-dest "SYS:WBStartup")
(set @pref-dest "SYS:Prefs")
(set @envarc-dest "ENVARC:")
(set @env-dest "ENV:")
(set installBlanker 1)
(set installReqTools 1)

(if (> @user-level 1)
	(set @default-dest
		(askdir
			(prompt "Where would you like Blanker installed?")
			(help "The WBStartup directory on your boot disk is likely the best place to put blanker. "
			      "This will insure that Blanker is run automatically when you boot your computer."
			)
			(default @default-dest)
		)
	)
)

(working "Checking for previously installed version of Blanker.")

(if (<= (getversion (tackon (pathonly @icon) "Blanker")) (getversion (tackon @default-dest "Blanker")))
	(if 	(askbool
			(prompt "An equal or newer version of Blanker already installed. "
				"Install anyway?"
			)
			(default 0)
			(help "An equal or newer version of Blanker is already installed. "
			      "If you would like to install Blanker anyhow, click 'Yes'. "
			      "If you don't want to install Blanker, click 'No'."
			)
		)
		(set installBlanker 1)
		(set installBlanker 0)
	)
)

(if (= 1 installBlanker )
	(copyfiles
		(prompt ("Copying Blanker to %s" @default-dest))
		(help @copyfiles-help)
		(source (pathonly @icon))
		(dest @default-dest)
		(choices "Blanker")
		(infos)
	)
	(if (< @user-level 1)
		(set temp @user-level)
		(user 2)
		(message "Not installing Blanker because an equal or newer version is already installed.")
		(user temp)
	)
)

(if (and (> @user-level 1) (= 1 installBlanker))
	((set @module-dest
		(askdir
			(prompt "Where would you like the Blanker modules installed?")
			(help "You can put the blankers anywhere and Blanker will look for them there." )
			(default @module-dest)
		)
	)
	(copyfiles
		(prompt ("Copying Blanker modules to %s" @module-dest))
		(help @copyfiles-help)
		(source (pathonly @icon))
		(dest @module-dest)
		(choices "Blankers")
	)
	(tooltype
		(prompt ("Informing Blanker that the blanker modules are in %s." (tackon @module-dest "Blankers")))
		(help "Setting Blanker's BLANKERDIR tooltype to the directory in which the modules were installed.")
		(dest (tackon @default-dest "Blanker"))
		(settooltype "BLANKERDIR" (tackon @module-dest "Blankers"))
	))
)
 
(working "Copying Blanker presets into Prefs/Presets/Blanker/ drawer.")

(if (= 1 installBlanker)
	(copyfiles
		(prompt ("Copying Blanker presets to %s" @pref-dest ))
		(help @copyfiles-help)
		(source (pathonly @icon))
		(dest @pref-dest)
		(confirm)
		(choices "Presets")
	)
)

(if (= 1 installBlanker)
	((copyfiles
		(prompt ("Copying Blanker presets default icon to %s" @envarc-dest ))
		(help @copyfiles-help)
		(source (tackon (pathonly @icon) "env-archive"))
		(dest @envarc-dest)
		(confirm)
		(choices "sys" "Blanker.prefs")
	)
	(copyfiles
		(prompt ("Copying Blanker presets default icon to %s" @env-dest ))
		(help @copyfiles-help)
		(source (tackon (pathonly @icon) "env-archive"))
		(dest @env-dest)
		(choices "sys" "Blanker.prefs")
	))
)

(working "Checking for previously installed version of ReqTools.")

(if (<= (getversion (tackon (pathonly @icon) "ReqTools/reqtools.library")) (getversion "LIBS:reqtools.library"))
	(if 	(askbool
			(prompt "An equal or newer version of ReqTools already installed. "
				"Install anyway?"
			)
			(default 0)
			(help "An equal or newer version of ReqTools is already installed. "
			      "If you would like to install ReqTools anyhow, click 'Yes'. "
			      "If you don't want to install ReqTools, click 'No'."
			)
		)
		(set installReqTools 1)
		(set installReqTools 0)
	)
)

(if (= 1 installReqTools)
	(copyfiles
		(prompt "Copying ReqTools library to LIBS:")
		(source (tackon (pathonly @icon) "ReqTools/reqtools.library"))
		(dest "LIBS:")
	)
	(if (< @user-level 1)
		(set temp @user-level)
		(user 2)
		(message "Not installing reqtools.library because an equal or newer version is already installed.")
		(user temp)
	)
)

(if (= 1 installReqTools)
	(copyfiles
		(prompt "Copying ReqTools preferences editor to SYS:Prefs")
		(source (tackon (tackon (pathonly @icon) "ReqTools") "ReqTools"))
		(dest "SYS:Prefs")
		(infos)
	)
)
