;
;	Type o'Negative Installer v2.1
;

(set @abort-button 	"Quit Game")
(set @app-name 		"Small!Wall v0.6")
(set @copyfileshelp 	"Ton!Help\n---------\n\nSelect the files you want to copy and push the proceed button.")
(set @gettondoorsdir	"Ton!Help\n---------\n\nSelect the directory where the Small!Wall directory will be created. (Usually Doors:Ton!Doors/ or similar)")
(set @bbscmdhelp	"Ton!Help\n---------\n\nNow give me the name of the BBSCMD the installer shall create.")
(set @accesslevelhelp	"Ton!Help\n---------\n\nEnter the minimum accesslevel that will be needed to call Small!Wall in your bbs.")

(set #accesslevelprompt	"Enter the minimum accesslevel for Small!Wall" bbscmd)
(set #exitmsg 		"\n\nA BBSCMD has been created.\n\nPlease read the guide now.\n\nFor bugreports, suggestions, gifts:\ntolpan@skom.rhein.de")
(set #welcometext 	"Installation for Small!Wall v0.6 - Go on to start installation.\n")
(set #gettondoorsdir	"Select your Ton!Doors directory (a Small!Wall dir will be created)")
(set #copyfilesprompt 	"Select the files you want to be copied.")
(set #bbscmdnameprompt	"Enter the name of the BBSCMD that will be created")
(set #file1		"Wall Executable (FIM)")
(set #file2		"Wall Config Executable (FIM)")
(set #file3		"Wall Documentation (Guide)")

(welcome #welcometext)


;	asking for install dir (where a Small!Wall dir will be created).

(set tondoors	(askdir		(prompt #gettondoorsdir)
		(help		@gettondoorsdir)
		(default	"Doors:Ton!Doors/" (newpath))
		)
)

(if (= (exists "Files/Small!Wall.Fim") 0)
	(set #file1 (cat #file1 "        [N/A]"))
)
(if (= (exists "Files/Small!WallEd.Fim") 0)
	(set #file2 (cat #file2 " [N/A]"))
)
(if (= (exists "Documentation/Small!Wall.Guide") 0)
	(set #file3 (cat #file3 "   [N/A]"))
)

(set files2copy	(askoptions	(choices #file1 #file2 #file3)
		(prompt #copyfilesprompt)
		(help @copyfileshelp)
		(default 7)
		)
)

(set destdir	(tackon tondoors	"Small!Wall"))
(makedir	destdir)

(makedir (tackon destdir "Data"))

(set	bbscmdname	(askstring (prompt #bbscmdnameprompt)
			(help	@bbscmdhelp)
			(default	"WALL"))
)


(set	accesslevel	(asknumber (prompt #accesslevelprompt)
			(help	@accesslevelhelp)
			(range	0 255)
			(default	"0"))
)

(if (<> files2copy 0)
	(
		(if	(AND (IN files2copy 0) (exists "Files/Small!Wall.Fim")
			)
			(
			(copyfiles (source "Files/Small!Wall.Fim")
				(dest destdir)
				(nogauge)
			)
			(set	doorcmd		(tackon	destdir	"Small!Wall.Fim"))
			(set	makebbscmd	("Files/MakeCMD NAME=%s PATH=%s SERVERNAME=Small!Wall STACK=4096 ACSLEVEL=%ld CMDTYPE=-1 MULTINODE PRI=0 DOORTYPE=0 NR NC CF SR SC AR AC RD" bbscmdname doorcmd accesslevel))
			(run	makebbscmd)
			)
		)

		(if	(AND (IN files2copy 1) (exists "Files/Small!WallEd.Fim")
			)
			(
			(copyfiles (source "Files/Small!WallEd.Fim")
				(dest destdir)
				(nogauge)
			)
			(set	doorconfig		(tackon	destdir	"Small!WallEd.Fim"))
			(set	makedoorconfig	("Files/DoorConfig NAME=Small!WallConfig PATH=%s %ld PRI=0 NR NC CF SR SC AR AC RD UNUSED" doorconfig accesslevel))
			(run	makedoorconfig)
			)
		)

		(if 	(AND (IN files2copy 2) (exists "Documentation/Small!Wall.Guide")
			)
			(
				(makedir (tackon destdir "Documentation"))
				(copyfiles (source "Documentation/")
				(dest (tackon destdir "Documentation/"))
				(all)
				(nogauge)
				)
			)
		)

	)
)

(exit #exitmsg)
