; *************************************************************************
; ******************  Untitled III Installation Script  *******************
; *************************************************************************
;
; $VER: Untitled III.install 1.5 (01.04.97)
;
; Copyright ©1997 Harald Zottmann
;
; *************************************************************************
;


; ------------------------------------------------------------------------
; Find out about program version

	(set vernum-vca    (getversion "Untitled"))
	(set version-vca   (/ vernum-vca 65536))
	(set revision-vca  (- vernum-vca (* version-vca 65536) ) )

; ------------------------------------------------------------------------
; Set default destination directory

	(set def-vca-dir "SYS:")

; ------------------------------------------------------------------------
; Set default language

	(set default_lang 1)

; ------------------------------------------------------------------------
; Init some strings

	(set #yes-msg "Yes")
	(set #no-msg "No")

	(set #new-msg "New Requester Look")
	(set #old-msg "Old Requester Look")

	(set #mc-msg "MC - Music Cassettes")
	(set #cd-msg "CD - Compact Discs")
	(set #phono-msg "Phono - Longplayers")
	(set #video-msg "Video - Video Tapes")

	(set #bad-kick-msg 
		"Untitled III requires AmigaOS 2.04 or better !"
	)

	(set #hello-msg
		(cat
		("Welcome to Untitled V%ld.%ld\n\n" version-vca revision-vca)
		"This script will install Untitled III and "
		"related files on your Amiga.\n\n"
		"You will need to answer a few questions such as "
		"where you would like the program installed.\n\n"
		"If you do not wish to install Untitled at this time, "
		"select the 'Abort Install' button now. "
		)
	)

	(set #goodbye-msg
		(cat
		"The installation of Untitled III is now complete. "
		"Have a look at the guides to get more information "
		"about this powerful tool. If you have TeX installed "
		"on your Amiga, you can print the DVI-file with the "
		"complete program description.\n\n"
		"Don`t forget to register if you use Untitled III "
		"frequently. See the docs for more information.\n\n"
		"Have fun..."
		)
	)

	(set #shortbye-msg
		(cat
		"Don`t forget to register if you use Untitled III "
		"frequently. See the docs for more information.\n\n"
		"Have fun..."
		)
	)

	(set #vca-askdir-msg 
		(cat
		"Select the directory to install Untitled III in. "
		"If you want to create a new directory for this "
		"application, do so now.\n"
		)
	)

	(set #processor-msg
		(cat
		"Untitled III is optimized for the listed "
		"processor types. Please indicate "
		"which processor you have in your machine."
		"\n--------------------------\n"
		"The Installer found out that you have a\n"
		"MC " (database "cpu") " CPU\n"
		)
	)

	(set #processor-help
		(cat
		"There are three optimized versions of "
		"Untitled III available. "
		"Simply specify the processor (CPU) of your machine. "
		"For example if you have a stock A1200 or "
		"A4000/030, choose MC 68020. For an A4000/040 "
		"you may choose MC 68040. Older machines without "
		"accelerator boards, like A500 or A2000 must "
		"choose the MC 68000. "
		"The Installer program however found out that "
		"your machine is equipped with a MC "
		(database "cpu") " CPU. "
		"If you are not sure about that, choose the "
		"MC 68000 version, that runs on every machine."
		)
	)

	(set #locale-msg
		(cat
		"Untitled III is localized and has been translated "
		"into the following languages. Please indicate "
		"which translation you wish to install.\n"
		)
	)

	(set #locale-help
		(cat
		"English and Deutsch are the languages which are "
		"supported by Untitled III. "
		"Simply specify the language you prefer. "
                "You can change your selection later, "
                "by modifying the corresponding Tooltype. "
		"The AmigaGuide files for Untitled III will "
		"be present for both languages, regardless of "
		"your present selection."
		)
	)

	(set #examples-msg
		(cat
		"Untitled III comes with several example files. "
		"Please select whether you want them to be "
		"installed for training purposes. "
		"You can delete them later, if you want.\n"
		"Note that already existing data files will not be "
		"overwritten by the installation script.\n"
		)
	)

	(set #examples-help
		(cat
		"These files provide some examples on how to "
		"work with Untitled III. If you have a "
		"previous version of Untitled III installed "
		"and this is only an update, you should not "
		"install these examples. "
		)
	)

	(set #su-mode-msg
		(cat
		"\Untitled III manages your MCs, CDs, "
		"Longplayers and Videos. Please select the "
		"default mode of Untitled III on program start. "
		"You can change this selection later, if you want.\n"
		)
	)

	(set #su-mode-help
		(cat
		"This option gives you the choice between the four "
		"different modes (MC, CD, Phono, Video) of Untitled III. "
		"The selected mode will be invoked on every program start, "
		"but you can alter the mode during run time, whenever you want. "
		"If you are not sure, the best decision is to "
		"select the mode which you intend to use most often. "
		)
	)

	(set #su-req-msg
		(cat
		"Untitled III provides two different requester styles. "
		"The new OS2.x requester look and an old internal one. "
		"The advantage of the old one is, that you can "
		"confirm it with the <RETURN> key, and cancel it "
		"with the <ESCAPE> key. The new one however looks much neater.\n"
		)
	)

	(set #su-req-help
		(cat
		"This option gives you the choice between two "
		"different requester styles. "
		"If you are not sure, select the new one. "
		"You can change this selection later, if you want.\n"
		)
	)


; ************************************************************************
; Begin actual installation
; ************************************************************************

; ------------------------------------------------------------------------
; Check for KickV37 or better

	(if (< (/ (getversion) 65536) 37)
		(
		(abort #bad-kick-msg)
		)
	)


; ------------------------------------------------------------------------
; Print the welcome message

	(message #hello-msg)


; ------------------------------------------------------------------------
; Ask the user where we should install Untitled III

	(if (= 0 @user-level)
		(
		(set vcadir        (tackon @default-dest "VCArchive") )
		(set @default-dest vcadir)
		(makedir vcadir)
		(copyfiles (source "/VCArchive") (dest vcadir) (infos) (all))
		(exit (#shortbye-msg)) 
		)
	)


	(set vcadir
		(askdir
			(prompt #vca-askdir-msg)
			(help @askdir-help)
			(default def-vca-dir)
		)
	)

	(set @default-dest vcadir)


; ------------------------------------------------------------------------
; Ask which processor version to be installed

	(set procversion
		(askchoice
			(prompt #processor-msg)
			(help #processor-help)
			(choices
				"MC 68000"
				"MC 68020"
				"MC 68040"
			)
			(default 0)
		)
	)
	(if (= 0 procversion)
		((copyfiles (source "Untitled") (dest vcadir) (infos))
		)
	)
	(if (= 1 procversion)
		((copyfiles (source "Untitled_020")  (dest vcadir))
		 (copyfiles (source "Untitled.info") (dest vcadir))
		 (rename (tackon vcadir "Untitled_020") (tackon vcadir "Untitled"))
		)
	)
	(if (= 2 procversion)
		((copyfiles (source "Untitled_040")  (dest vcadir))
		 (copyfiles (source "Untitled.info") (dest vcadir))
		 (rename (tackon vcadir "Untitled_040") (tackon vcadir "Untitled"))
		)
	)

; ------------------------------------------------------------------------
; Check if there are old configurations

	(if (NOT(exists (tackon vcadir "VCA.CFG") ) )
		(copyfiles (source "VCA.CFG") (dest vcadir) )
	)
	(if (NOT(exists (tackon vcadir "VCA.FNK") ) )
		(copyfiles (source "VCA.FNK") (dest vcadir) )
	)


; ------------------------------------------------------------------------
; Install Hypertext Guide

	(copyfiles (source "VCA_E.guide") (dest vcadir) (infos) )
	(copyfiles (source "VCA_D.guide") (dest vcadir) (infos) )


; ------------------------------------------------------------------------
; Install Tools

	(set toolsdrw (tackon vcadir "Tools"))
	(makedir toolsdrw)
	(copyfiles (source "Tools.info") (dest vcadir) )

	(copyfiles (source "Tools/Tools.ReadMe")  (dest toolsdrw) (infos) )
	(copyfiles (source "Tools/VideoCounter")  (dest toolsdrw) (infos) )
	(copyfiles (source "Tools/Backup")        (dest toolsdrw) (infos) )
	(copyfiles (source "Tools/Restore")       (dest toolsdrw) (infos) )
	(copyfiles (source "Tools/Requester")     (dest toolsdrw) )
	(copyfiles (source "Tools/FUnCopy")       (dest toolsdrw) )


; ------------------------------------------------------------------------
; Install Docs

	(set docsdrw (tackon vcadir "Docs"))
	(makedir docsdrw)
	(copyfiles (source "Docs.info") (dest vcadir) )

	(copyfiles (source "Docs/VCA_E.dvi")      (dest docsdrw) (infos) )
	(copyfiles (source "Docs/VCA.ReadMe")     (dest docsdrw) (infos) )

	(copyfiles (source "Docs/VCA_D.dvi")      (dest docsdrw) (infos) )
	(copyfiles (source "Docs/VCA.LiesMich")   (dest docsdrw) (infos) )

	(copyfiles (source "Docs/ORDERFORM.TXT")     (dest docsdrw) (infos) )
	(copyfiles (source "Docs/REGISTRIERUNG.TXT") (dest docsdrw) (infos) )
	(copyfiles (source "Docs/HISTORY.TXT")       (dest docsdrw) (infos) )
	(copyfiles (source "Docs/DISCLAIMER.TXT")    (dest docsdrw) (infos) )


; ------------------------------------------------------------------------
; Install Export-Filters

	(set filtersdrw  (tackon vcadir "Filters"))
	(makedir filtersdrw)
	(copyfiles (source "Filters/")        (dest filtersdrw)  (all) (infos) )
	(copyfiles (source "Filters.info")    (dest vcadir) )


; ------------------------------------------------------------------------
; Install tool to support making own Export-Filters


	(set mkfilterdrw (tackon vcadir "MakeFilter"))
	(makedir mkfilterdrw)
	(copyfiles (source "MakeFilter/")     (dest mkfilterdrw) (all) (infos) )
	(copyfiles (source "MakeFilter.info") (dest vcadir) )


; ------------------------------------------------------------------------
; Ask which built in language should be invoked for Untitled III

	(set lang
		(askchoice
			(prompt #locale-msg)
			(help #locale-help)
			(choices
				"English"
				"Deutsch"
			)
			(default default_lang)
		)
	)
	(if (= 0 lang)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "LANGUAGE" "1")
		)
	)
	(if (= 1 lang)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "LANGUAGE" "0")
		)
	)


; ------------------------------------------------------------------------
; Update from a version, previous to Untitled Version 3.0

		(if (exists (tackon vcadir "Ordner_1") )
			(rename (tackon vcadir "Ordner_1") (tackon vcadir "MC_Ordner_1") )
		
		)
		(if (exists (tackon vcadir "Ordner_2") )
			(rename (tackon vcadir "Ordner_2") (tackon vcadir "MC_Ordner_2") )
		
		)
		(if (exists (tackon vcadir "Ordner_3") )
			(rename (tackon vcadir "Ordner_3") (tackon vcadir "MC_Ordner_3") )
		
		)
		(if (exists (tackon vcadir "Ordner_1.List") )
			(rename (tackon vcadir "Ordner_1.List") (tackon vcadir "MC_Ordner_1.Liste") )
		
		)
		(if (exists (tackon vcadir "Ordner_2.List") )
			(rename (tackon vcadir "Ordner_2.List") (tackon vcadir "MC_Ordner_2.Liste") )
		
		)
		(if (exists (tackon vcadir "Ordner_3.List") )
			(rename (tackon vcadir "Ordner_3.List") (tackon vcadir "MC_Ordner_3.Liste") )
		
		)


; ------------------------------------------------------------------------
; Ask whether examples should be installed

	(set examples
		(askchoice
			(prompt #examples-msg)
			(help #examples-help)
			(choices
				#yes-msg
				#no-msg
			)
			(default 0)
		)
	)
	(if (= 0 examples)
	    ( 
		(if (NOT(exists (tackon vcadir "MC_Ordner_1") ) )
			( (copyfiles (source "MC_Ordner_1")       (dest vcadir) )
		  	  (copyfiles (source "MC_Ordner_1.Liste") (dest vcadir) )
			)

		)
		(if (NOT(exists (tackon vcadir "CD_Ordner_1") ) )
		  	( (copyfiles (source "CD_Ordner_1")       (dest vcadir) )
		  	  (copyfiles (source "CD_Ordner_1.Liste") (dest vcadir) )
			)
		)
		(if (NOT(exists (tackon vcadir "Phono_Ordner_1") ) )
		  	( (copyfiles (source "Phono_Ordner_1")       (dest vcadir) )
		  	  (copyfiles (source "Phono_Ordner_1.Liste") (dest vcadir) )
			)
		)
		(if (NOT(exists (tackon vcadir "Video_Ordner_1") ) )
		  	( (copyfiles (source "Video_Ordner_1")       (dest vcadir) )
	  		  (copyfiles (source "Video_Ordner_1.Liste") (dest vcadir) )
			)
		)
	    )
	)


; ------------------------------------------------------------------------
; Ask for startup mode

	(set su-mode
		(askchoice
			(prompt #su-mode-msg)
			(help #su-mode-help)
			(choices
				#mc-msg
				#cd-msg
				#phono-msg
				#video-msg
			)
			(default 0)
		)
	)
	(if (= 0 su-mode)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "MODUS" "1")
		)

	)
	(if (= 1 su-mode)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "MODUS" "2")
		)

	)
	(if (= 2 su-mode)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "MODUS" "3")
		)

	)
	(if (= 3 su-mode)
		(tooltype
			(dest (tackon vcadir "Untitled"))
			(settooltype "MODUS" "4")
		)

	)


; ------------------------------------------------------------------------
; Ask for requester style

	(set su-req
		(askchoice
			(prompt #su-req-msg)
			(help #su-req-help)
			(choices
				#new-msg
				#old-msg
			)
			(default 0)
		)
	)
	(if (= 0 su-req)
		(tooltype (dest (tackon vcadir "Untitled")) (settooltype "STYLE" "1") )
		(tooltype (dest (tackon vcadir "Untitled")) (settooltype "STYLE" "0") )
	)


; ------------------------------------------------------------------------
; Print the goodbye message and quit

	(message #goodbye-msg)

