;
;   Desaster Installer v3.0
;

(set @abort-button 	"Quit Game")
(set @app-name 		"Small!Wall v1.0")
(set @copyfileshelp 	"Dtr!Help\n---------\n\nSelect the files you want to copy and push the proceed button.")
(set @getdtrdoorsdir	"Dtr!Help\n---------\n\nSelect the directory where the Small!Wall directory will be created. (Usually Doors:Desaster/ or similar)")
(set @olddatahelp	"Dtr!Help\n---------\n\nI'll rename your old data file from Doors:Ton!Doors/Small!Wall/Wall.Dat to the actual installation directory so you can use your old data file without any changes.")
(set @bbscmdhelp	"Dtr!Help\n---------\n\nNow give me the name of the BBSCMD the installer shall create.")
(set @accesslevelhelp	"Dtr!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")
(set #exitmsg 		"\n\nA BBSCMD has been created.\n\nPlease read the guide now.\n\nFor bugreports, suggestions, gifts:\ntolpan@skom.rhein.de\ndtrwebhq@aol.com")
(set #welcometext 	"Installation for Small!Wall v1.0 - Go on to start installation.\n")
(set #getdtrdoorsdir	"Select your Desaster 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 CLI Output (EXE)")
(set #file4		"Wall Documentation (Guide)")

(welcome #welcometext)

(set dtrdoors	(askdir		(prompt #getdtrdoorsdir)
		(help		@getdtrdoorsdir)
		(default	"Doors:Desaster/" (newpath))
		)
)

(if (exists "Doors:Ton!Doors/Small!Wall/Wall.Dat")
	(
	(startup "OldData"
		(prompt	"\nFound an old Small!Wall data file!\n\nI will rename:\n\nDoors:Ton!Doors/Small!Wall/Wall.Dat\n\nto\n\nDoors:Desaster/Small!Wall/Small!Wall.Dat\n\nnow.")
		(help	@olddatahelp)
		(command "rename Doors:Ton!Doors/Small!Wall/Wall.Dat %sSmall!Wall/Small!Wall.Dat" dtrdoors)
	)
	)
)


(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 "Files/Small!Wall.Exe") 0)
	(set #file3 (cat #file3      "   [N/A]"))
)
(if (= (exists "Documentation/Small!Wall.Guide") 0)
	(set #file4 (cat #file4 "   [N/A]"))
)

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

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

(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 "Files/Small!Wall.Exe")
			)
			(
				(copyfiles (source "Files/Small!Wall.Exe")
				(dest destdir)
				(nogauge)
				)
			)
		)
		(if 	(AND (IN files2copy 3) (exists "Documentation/Small!Wall.Guide")
			)
			(
				(makedir (tackon destdir "Documentation"))
				(copyfiles (source "Documentation/")
				(dest (tackon destdir "Documentation/"))
				(all)
				(nogauge)
				)
			)
		)
	)
)

(exit #exitmsg)
