;******************************************************************************
; DTprefV3.x Insallscript
; Written by Swen K. Stullich/UFT   11.04.96
;******************************************************************************

; Initialize a few things
(set docbits 0)
(set usedt 0)			; internal datatypes
(set usedtext 0)		; external datatypes


;******************************************************************************
; Willkommen ;-)
(welcome "DTprefV4-Installer")
(message
	"Welcome to the DTprefV4-Install-Script\n"
	"This script will install and set the\n"
	"preferences (Tooltypes) of DTpref\n\n"
	"DTpref is ©1995-96\n"
	"Swen K. Stullich\n"
	"United Forces Tools"
)

;******************************************************************************
; Prompt for the used internal datatypes
; and set then the tooltype

; Bitmaske herstellen
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/binary.datatype")  0)))
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/exe.datatype")     1)))
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/font.datatype")    2)))
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/hwgpost.datatype") 3)))
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/jfif.datatype")    4)))
(set usedt (+ usedt (shiftleft (exists "LIBS:Datatypes/photocd.datatype") 5)))

; Bitmaske abfragen
(set usedt
	(askoptions
		(prompt "Which internal datatypes should I install")
		(help "The marked datatypes will be shown in DTpref. The other datatypes will be skipped.")
		(choices "binary.datatype" "exe.datatype" "font.datatype" "hwgpost.datatype" "jfif.datatype" "photocd.datatype")
		(default usedt)
	)
)

;Icon-Tooltype setzen
(set tooltext "")
(if (NOT (BITAND usedt (shiftleft 1 0))) (set tooltext (cat tooltext "binary|")))
(if (NOT (BITAND usedt (shiftleft 1 1))) (set tooltext (cat tooltext "exe|")))
(if (NOT (BITAND usedt (shiftleft 1 2))) (set tooltext (cat tooltext "font|")))
(if (NOT (BITAND usedt (shiftleft 1 3))) (set tooltext (cat tooltext "hwgpost|")))
(if (NOT (BITAND usedt (shiftleft 1 4))) (set tooltext (cat tooltext "jfif|")))
(if (NOT (BITAND usedt (shiftleft 1 5))) (set tooltext (cat tooltext "photocd|")))
(if (tooltext) (set tooltext (substr tooltext 0 (- (strlen tooltext) 1))))
(if (tooltext)
	(tooltype
		(dest "DTpref/DTpref")
		(settooltype "DisableDT" tooltext)
	)
)

;******************************************************************************
; Prompt for components and their directories

; Prefs
(set prefsdir
	(askdir
		(prompt "Where do the Preferences belong")
		(help @askdir-help)
		(default "SYS:Prefs")
	)
)

; Objects
(if usedtext
	(set objdir
		(askdir
			(prompt "Where do the Objects belong")
			(help @askdir-help)
			(newpath)
			(default (tackon prefsdir "DTObjects"))
		)
	)
)

; Docs
(set docsdir
	(askdir
		(prompt "Where do the Documentations belong")
		(help @askdir-help)
		(default "SYS:Docs")
	)
)

;******************************************************************************
;******************************************************************************
;******************************************************************************

;**********************************************************************
; Install
;**********************************************************************
(
	; Show what we are doing
	(working "Installing " @app-name)

	; Install the library
	(copylib
		(prompt "Copying gtlayout.library")
		(help @copylib-help)
		(source "libs/gtlayout.library")
		(dest "LIBS:")
		(confirm)
	)

	; Install the Editor
	(copyfiles
		(prompt "Copying the Preferenceseditor")
		(help @copyfiles-help)
		(source "DTpref/")
		(dest prefsdir)
		(pattern "#?")
		(infos)
	)

	; Install the DTObjects
	(if objdir
		(copyfiles
			(prompt "Copying the Datatypeobjects")
			(help @copyfiles-help)
			(source "DTObjects/")
			(dest objdir)
			(pattern "#?")
			(infos)
			(confirm)
		)
	)

	; Install the Docs
	(copyfiles
		(prompt "Copying the Documentations")
		(help @copyfiles-help)
		(source "Docs/")
		(dest docsdir)
		(pattern "#?")
		(infos)
		(confirm)
	)
)

(set @default-dest prefsdir)

(if (> (exists ("c:multiview")) 0) (set #mpath "c:") )
(if (> (exists ("sys:Utilities/multiview")) 0) (set #mpath "sys:Utilities") )
(run (cat "run " #mpath "/multiview DTpref.readme") )
