;; $VER: Install_cdxNetLaunch 1.0 (20.5.1995)
;;
;; Install cdxNetLaunch to target system
;; (c)1996 by Hans Bühler, Codex Design Software
;;    codex@studi.mathematik.hu-berlin.de
;; ============================================
;;
;; TABSIZE = 3


;; ============================================

(set @default-dest	"SYS:Commodities")
(set @pretend			0)
(set @user-level		2)
(set #docdir			"HELP:")
(set #defPrefsDir		"S:cdxNetLaunch")
(set #prefsdir			#defPrefsDir)				;; if == #defPrefsDir, it will be created !

;; where to find what
(set #localprefsdir	"cdxData")
(set #localdir			"")
(set #localguideName	"doc/cdxNetLaunch.guide")
(set #localCdxName	"cdxNetLaunch")
(set #netdir			"DEVS:networks")			;; directory of network devices

;; other strings
(set s_OtherDir		"Other directory")

;; ============================================ HELLO

(welcome	"·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·\n"
			"presents:\n"
			"\n"
			"cdxNetLaunch V1.00.ß\n"
			"\n"
			"Welcome to its installation utility !\n")

;; ============================================ FIND AMITCP (SYSTEM)

(if (= 0 (exists "AmiTCP:bin" (noreq)))
	(	(abort	"Error !\n"
					"\n"
					"Can't find AmiTCP/IP !!!\n"
					"You need AmiTCP/IP to make use of this program !"
		)
	)
)

;; ============================================ LOOP 1 !!

(set Confirmed 0)

(until (= Confirmed 1)
(
	;; ============================================ SELECT PROGRAM DESTINATION

	(if (NOT (askbool		(prompt	"The installer will copy cdxNetLaunch to your\n"
											@default-dest " directory.\n"
											"\n"
											"Is that okay for you ?")
								(help		"If you don't want to copy cdxNetLaunch to "
											@default-dest ", select \"" s_OtherDir "\" in order "
											"to choose another target directory !\n"
											"No other files will be copied there thus you don't need "  
											"to create a new directory for cdxNetLaunch itself, I think.")
								(default 1)
								(choices "Yes" s_OtherDir)
				)	)
		(
			(set @default-dest (askdir
								(prompt	"Where should I copy cdxNetLaunch to ?\n"
											"(NO NEW DIRECTORY WILL BE CREATED !!)")
								(help		"Select a directory from where you want to start "
											"cdxNetLaunch, later.\n"
											"Choose SYS:WbStartup/ if you want to start "
											"cdxNetLaunch automatically.\n"
											"\n"
											@askdir-help)
								(default	@default-dest)
								(newpath)
								)
			)
		)
	)

	(complete 10)

	;; ============================================ SELECT PREFS DIR

	(if (NOT (askbool		(prompt	"cdxNetLaunch need a directory where it can save its "
											"preferences files to.\n"
											"Since there will be several files saved to this directory "
											"it would be the best that you create a new one !\n"
											"\n"
											"By default, the installation script would "
											"create a directory " #prefsdir ".\n"
											"\n"
											"Is that okay for you ?")
								(help		"If you want that cdxNetLaunch saves its files to " #prefsdir ","
											"click at \"Yes\", otherwise click at \"" s_OtherDir "\" and"
											"a directory-requester will enable you to choose another "
											"directory.\n"
											"You can even create directories from there !")
								(default 1)
								(choices "Yes" s_OtherDir)
				)	)
		(
			(set #prefsdir (askdir
								(prompt	"Where do you want to save the preferences files of cdxNetLaunch to ?\n"
											"(NO NEW DIRECTORY WILL BE CREATED !!!!)")
								(help		"Please select a target directory for the preferences files cdxNetLaunch will "
											"create.\n"
											"It is possible (and recommended) to select a directory which is already been used by "
											"a former version of cdxNetLaunch.\n"
											"\n"
											"Please note that cdxNetLaunch WON'T create a new sub-directory in the "
											"directory you selected so please create one using this Installer "
											"session !\n"
											"\n"
											@askdir-help)
								(default	@default-dest)
								(newpath)
								(disk))
			)
		)
	)

	(complete 20)

	;; ============================================ SELECT GUIDE DIR

	(set xAskDoc 0)

	(if (<> 0 (exists #docdir) )
		(
			(set xAskDoc (askbool
								(prompt	"Do you want to copy the file cdxNetLaunch.guide to "
											"the standard helpfiles-directory " #docdir "?")
								(help		"The installation script will copy the guide for cdxNetLaunch "
											"to" #docdir " if you don't like to choose another directory for "
											"that documentation file.")
								(default 1)
								(choices "Yes" s_OtherDir)
							 )
			)
		)
		(
			(set #docdir @default-dest)		;; if no HELP:, copy to default dest !
		)
	)

	(if (= xAskDoc 0)
		(
			(set #docdir (askdir
								(prompt	"Where you do you want to copy the documentation file "
											"\"cdxNetLaunch.guide\" to ?\n"
											"(NO NEW DIRECTORY WILL BE CREATED !)")
								(help		"Select any directory where you want to copy the "
											"documentation to (guidefile means AmigaGuide-formatted "
											"file).\n"
											"\n"
											@askdir-help)
								(default @default-dest)
								(newpath)
							 )
			)
		)
	)

	(complete 30)

	;; ============================================ WHERE TO COPY ADD SOFTWARE ?

	(complete 50)

	;; ============================================ LET USER CONFIRM INPUT

	(if (> @user-level 0)
		(
			(set Confirmed (askbool
								(prompt	"Please confirm your choices:\n"
											"\n"
											"Copy cdxNetLaunch to \"" @default-dest "\"\n"
											"Copy guide to: \"" #docdir "\"\n"
											"Preferences dir: \"" #prefsDir "\"\n"
											"\n"
											"Is that correct ?")
								(help		"Please check your choices.\n"
											"Choose \"" No "\" to change them.")
								(default	1)
							  )
			)
		)
		(
			(set Confirmed 1)
		)
	)
))			;; Until (= confirmed 1)

(complete 60)

;; ============================================ Copy program
;; ============================================ Copy program
;; ============================================ Copy program

;; ============================================ Create prefsdir & copy def prefs ?

(if (NOT (exists (#prefsdir (noreq))))
    (
		(makedir	#prefsdir
					(prompt	"Creating preferences directory '" #prefsdir "'...")
					(help		"I'll make a directory for my prefs ;-)")
		)
	 )
)

(copyfiles	(prompt	"Copying default preferences files & modules...")
				(help		"These default files are preferences for applications that _belong_ "
							"to AmiTCP/IP.\n"
							"cdxNetLaunch needs the information that these files are neccessary "
							"for AmiTCP/IP and shouldn't be influenced by it.\n"
							"Read the relating chapter \"Usage/New Application Window\" in the "
							"guide !!\n"
							"\n"
							@copyfiles-help)
				(source	#localprefsdir)
				(dest		#prefsdir)
				(all)
				(optional	"nofail" "askuser")
)

(complete 70)

;; ============================================ Copy guide

(copyfiles	(prompt	"Copying cdxNetLaunch.guide to" #docdir "...")
				(help		@copyfiles-help)
				(source	#localguideName)
				(dest		#docdir)
				(files)
				(infos)
				(optional "force")
)

(complete 80)

;; ============================================ change tooltypes & copy main

(copyfiles	(prompt	"Copying cdxNetLaunch to" @default-dest "...")
				(help		@copyfiles-help)
				(source	#localCdxName)
				(dest		@default-dest)
				(files)
				(infos)
				(optional "force")
)

(complete 85)

;; set tooltypes

(tooltype	(prompt	"Adjusting tooltypes of cdxNetLaunch...")
				(help		"I gonna store your settings into the icon of cdxNetLaunch so that "
							"the program can find its preferences and stuff.")
				(dest		(tackon @default-dest #localCdxName))
				(settooltype "PREFSDIR" #prefsdir)
				(settooltype "AMIGAGUIDEFILE" (tackon #docdir #localguideName))
				(noposition)
)

(complete 90)

;; ============================================ copy libs

(copylib	(prompt	"Copying libraries...")
			(help		"These libraries are needed to run cdxNetLaunch !")
			(source	"libs/gadtoolsbox.library")
			(dest		"t:libs")
			(optional "nofail" "askuser")
)

(copylib	(prompt	"Copying libraries...")
			(help		"These libraries are needed to run cdxNetLaunch !")
			(source	"libs/nofrag.library")
			(dest		"t:libs")
			(optional "nofail" "askuser")
)

(complete 95)

;; ============================================ Run program
;; ============================================
;; ============================================



(if (askbool (prompt	"Do you want to start cdxNetLaunch now in order to configurate it ?\n"
							"If you are configurating cdxNetLaunch, please read the " 
							"documents if you are not sure what you are doing !")
				 (help	"cdxNetLaunch will start its configuration program the first " 
				 			"time you start it.\n"
				 			"Read the docs for further information, chapter configuration !")
				 (default 1)
	 )
	 (
		(run (tackon @default-dest #localCdxName)
						(prompt	"Running cdxNetLaunch...")
						(help		"Configurate now !")
		)
	 )
)

(exit "Installation of cdxNetLaunch is complete !\n"
		"\n"
		"·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·\n"
		"thanks for trying a program from us.\n"
)
