; $VER: Magic2024-Install 1.1 (15.11.94)
; Install script for MagicA2024 (c) by kMel, Klaus Melchior

(set app_name "MagicA2024")
(set version "1.1")
(set vers_name (cat app_name " v" version))

(set msg_bad_kick (cat "You must even be using Kickstart 2.04 to run " vers_name ".") )
(set msg_info (cat
	"\n" vers_name " installation script.\n\n"
	"This script installs " app_name " to a place, where utilities can be found (e.g. bin:).\n\n"
	"The user startup should be supplemented to start " app_name " automatically.\n\n"
	app_name " © 1994 kmel, Klaus Melchior\n"
	"All rights reserved."
	)
)
(set msg_exit (cat
	"Have fun with MagicWB icons and your A2024 using " app_name "\n\n"
	"And don't forget: It's Giftware!"
	)
)

; -------------------------------------------------------------------------

(transcript (cat "Installing " vers_name " ..."))

(if	(< (/ (getversion) 65536) 37)
(
	(abort (cat msg_info "\n\n\n" msg_bad_kick) )
)
)

; -------------------------------------------------------------------------
(complete 0)

(message msg_info)

; -------------------------------------------------------------------------
(complete 20)

(set destination
	(askdir
		(prompt (cat "Please select a place for " vers_name ) )
		(help @askdir-help)
		(default "bin:")
	)
)

(copylib
 	(prompt (cat "Copying " vers_name) )
 	(confirm)
	(source app_name)
	(dest destination)
	(infos)
	(help @copylib-help)
)

; -------------------------------------------------------------------------
(complete 40)

(if	(NOT	(exists (tackon "Sys:WBStartup/" app_name)))

	(startup app_name
		(command "run >nil: <nil: \"" (tackon destination app_name) "\"")
		(prompt (cat "Now the " app_name " startup line will be included into your user-startup file. ") )
		(help @startup-help)
	)

)

; -------------------------------------------------------------------------
(complete 60)

(set choice
	(askoptions
		(prompt "Please choose which documentation to install")
		(choices
			(cat app_name "_engl.guide")
			(cat app_name "_engl.doc")
		)
		(help @askoptions-help)
	)
)

; -------------------------------------------------------------------------
(complete 70)

(set file_names (cat app_name "_engl.guide") )

(if (<> 0 (BITAND choice 1))
(
	(set destination
		(askdir
			(prompt (cat "Please select a place for the " file_names) )
			(help @askdir-help)
			(default "guide:")
		)
	)

	(copyfiles
	 	(prompt (cat "Copying " file_names) )
		(source file_names)
		(dest destination)
		(infos)
		(help @copyfiles-help)
	)
)
)

; -------------------------------------------------------------------------
(complete 80)

(set file_names (cat app_name "_engl.doc") )

(if (<> 0 (BITAND choice 2))
(
	(set destination
		(askdir
			(prompt (cat "Please select a place for the " file_names) )
			(help @askdir-help)
			(default "Docs:")
		)
	)

	(copyfiles
	 	(prompt (cat "Copying " file_names) )
		(source file_names)
		(infos)
		(dest destination)
		(help @copyfiles-help)
	)
)
)

; -------------------------------------------------------------------------
(complete 100)

(exit msg_exit)
