; Caligari Installation Script
; Version 1.1
; April 27, 1992
; by J.W. Lockhart, Michael Plitkins and Stan Ziel
; Copyright 1991 by Octree Software, Inc. and GVP, Inc.
;
; John gets credit for the original script which I hacked up in a
; few hours to work with Caligari24; thus I take credit for all
; of the nonsense. MMP
;
; Written for use with Commodore Install (Version 1.6)
;
; Please note:  Novice mode is disabled in the icon tooltype for
; this script.
;
; History:
;
; 1.0	initial release
; 1.1	Fixed to (hopefully) work under WB 1.3.
;	So now there are two scripts: one for 1.3, one for 2.0
; 1.2   Caligari24 release
; 1.3   Caligari24 release
;

; set up Caligari vars
(set cal_dsk		"Caligari_disk1:")					; disk volume name
(set cal_dst		(tackon @default-dest "CaligariBroadcast"))	; Destination for utils.
(set cal_def		(tackon @default-dest "CaligariBroadcast"))	; default destination
(set cal_drv		"Caligari")							; note no ':'
(set cal_drv2		"Caligari:")
(set cal_dskname1	"Caligari disk 1")					; sticky paper label
(set cal_volname1	"Caligari_disk1")					; c:label
(set cal_dskname2	"Caligari disk 2")					; sticky paper label
(set cal_volname2	"Caligari_disk2")					; c:label
(set cal_dskname3	"Caligari disk 3")					; sticky paper label
(set cal_volname3	"Caligari_disk3")					; c:label
(set cal_dskname4	"Caligari disk 4")					; sticky paper label
(set cal_volname4	"Caligari_disk4")					; c:label
(set cal_tmpfile	"ram:caligari.asgns")
(set cal_renddi		"Rend_di")
(set cal_rendnull	"Rend_null")
(set cal_material	"Materials")
(set cal_environ	"Environments")
(set cal_texture	"Textures")
(set cal_data		"Caldata")
(set cal_scratch	"Scratch")
(set cal_eurofont	"Eurofont")
(set cal_objects	"Objects")
(set cal_makermp	"Makermp")
(set vid_font		"FONTS:video")
(set cal_tools		"Tools")

; Common Vars
(set archiver		"lharc")				; de-archive utility
(set archPath		(tackon cal_dsk "c"))	; where archiver lives
(set archDest		"ram:")					; where to store copy of lharc
(set look_here		"")						; where to look for s/w packages

(if (exists (tackon archPath archiver))
	(
	  	(run "copy " (tackon archPath archiver) " " archDest)
		(set archPath archDest)
	)
	; else
	(set archPath "")						; we can check this elsewhere
)

;;;;;;
;;;;;;     Install to Hard Disk
;;;;;;
	(
		(set cal_def (tackon @default-dest "Caligari"))
		(set cal_dst (askdir (prompt "Where shall I install the "
                                     "Caligari Broadcast disks?\n"
                                     "Create a new drawer if you like.")
                             (help @askdir-help) (default cal_def)
                     )
        )

        ; Create main directory if necessary...

        (if (NOT (exists cal_dst)) (
			(makedir cal_dst (prompt (cat "Creating" cal_dst))
                             (infos)
							 (help @makedir-help))
        ))

        ; Create CalData directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_data))) (
            (makedir (tackon cal_dst cal_data) (prompt (cat "Creating" (tackon cal_dst cal_data)))
                     (help @makedir-help))
        ))

        ; Create Scratch directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_scratch))) (
            (makedir (tackon cal_dst cal_scratch) (prompt (cat "Creating" (tackon cal_dst cal_scratch)))
                     (help @makedir-help))
        ))

        ; Create Materials directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_material))) (
            (makedir (tackon cal_dst cal_material) (prompt (cat "Creating" (tackon cal_dst cal_material)))
                     (help @makedir-help))
        ))

        ; Create Textures directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_texture))) (
            (makedir (tackon cal_dst cal_texture) (prompt (cat "Creating" (tackon cal_dst cal_texture)))
                     (help @makedir-help))
        ))

        ; Create Environments directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_environ))) (
            (makedir (tackon cal_dst cal_environ) (prompt (cat "Creating" (tackon cal_dst cal_environ)))
                     (help @makedir-help))
        ))

        ; Create Rend_null directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_rendnull))) (
            (makedir (tackon cal_dst cal_rendnull) (prompt (cat "Creating" (tackon cal_dst cal_rendnull)))
                     (help @makedir-help))
        ))

        ; Create Rend_di directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_renddi))) (
            (makedir (tackon cal_dst cal_renddi) (prompt (cat "Creating" (tackon cal_dst cal_renddi)))
                     (help @makedir-help))
        ))

        ; Create Tools directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_tools))) (
            (makedir (tackon cal_dst cal_tools) (prompt (cat "Creating" (tackon cal_dst cal_tools)))
                     (help @makedir-help))
        ))

        ; Create eurofont directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_eurofont))) (
            (makedir (tackon cal_dst cal_eurofont) (prompt (cat "Creating" (tackon cal_dst cal_eurofont)))
                     (help @makedir-help))
        ))

        ; Create objects directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_objects))) (
            (makedir (tackon cal_dst cal_objects) (prompt (cat "Creating" (tackon cal_dst cal_objects)))
                     (help @makedir-help))
        ))

        ; Create makermp directory if necessary...

        (if (NOT (exists (tackon cal_dst cal_makermp))) (
            (makedir (tackon cal_dst cal_makermp) (prompt (cat "Creating" (tackon cal_dst cal_makermp)))
                     (help @makedir-help))
        ))

        ; Create fonts:video directory if necessary...

        (if (NOT (exists vid_font)) (
            (makedir vid_font (prompt (cat "Creating" vid_font))
                     (help @makedir-help))
        ))

		; Assigns for user-startup / startup-sequence / temp execute file
		; There are eleven of 'em...
	    (set cal_assigns (cat
        		        "if exists \"" cal_dst "\"\n"
            		    "   assign Caligari: \"" cal_dst "\"\n"
		                "   assign CalData:       Caligari:CalData\n"
        		        "   assign CalScripts:    Caligari:\n"
            		    "   assign CalScenes:     Caligari:\n"
		                "   assign CalRender:     Caligari:\n"
        		        "   assign CalTexture:    Caligari:Textures\n"
            		    "   assign CalEnviron:    Caligari:Environments\n"
                		"   assign CalMaterial:   Caligari:Materials\n"
		                "   assign CalScratch:    Caligari:Scratch\n"
		                "   assign CalTools:      Caligari:Tools\n"
        		        "   assign RenditionDI:   Caligari:Rend_DI\n"
		                "   assign RenditionDD:   Caligari:Rend_Null\n"
        		        "endif\n"
	    ))

	    ; Don't try to assign stuff to directories that won't exist
	    ; in pretend mode, though...
	    (if (not @pretend)
		(
         	(textfile (dest cal_tmpfile)
					  (append cal_assigns)
					  (help @textfile-help)
					  (prompt "Creating temporary file for needed assigns"))
			(execute cal_tmpfile
					 (prompt "Executing temporary file for needed assigns")
					 (help @execute-help))
		))

		(if (askbool (prompt "Do you want to install the 68040 or "
							"Standard Accelerated version of Caligari Broadcast?")
                	 (help "The 68040 version is optimized for the 68040 "
                      	   "CPU and is somewhat faster than the Standard "
						   "version. The Standard version will run on any "
						   "accelerated machine. "
					 )
					 (default "Std Accelerated")
					 (choices "Std Accelerated" "68040 Optimized"))
		(
	        (askdisk   (prompt "Please insert disk 1, \n'" cal_dskname1 "'")
    	               (dest cal_volname1)
        	           (help @askdisk-help))

	        (working "\nUnpacking archive of\n"
					 "Caligari Executable")
        	(if archPath
            	(run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":Calig881 Caligari: *"))
        	    ; else
       	     	(run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":Calig881 Caligari: *"))
            	; -mn means no confirmation messages or progress indicator.
	        )
		)
		(
	        (askdisk   (prompt "Please insert disk 3, \n'" cal_dskname3 "'")
    	               (dest cal_volname3)
        	           (help @askdisk-help))

	        (working "\nUnpacking archive of\n"
					 "Caligari Executable")
	        (if archPath
    	        (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname3 ":Calig040 Caligari: *"))
        	    ; else
            	(run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname3 ":Calig040 Caligari: *"))
	            ; -mn means no confirmation messages or progress indicator.
    	    )
		))

        (askdisk   (prompt "Please insert disk 1, \n'" cal_dskname1 "'")
   	               (dest cal_volname1)
       	           (help @askdisk-help))

        (working "\nUnpacking archive of\n"
				 "Caligari Sphere Files")
        (if archPath
            ((run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":spheres CalData: *")))
            ; else
            ((run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":spheres CalData: *")))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Rendition Renderer")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":Rend_null RenditionDD: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":Rend_null RenditionDD: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Materials")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mnx x " cal_volname1 ":Materials CalMaterial: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mnx x " cal_volname1 ":Materials CalMaterial: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Euro 2D polygon font")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":eurofont Caligari:eurofont/ *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":eurofont Caligari:eurofont/ *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari 1D Environment Tool")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":makermp Caligari:makermp/ *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":makermp Caligari:makermp/ *"))
            ; -mn means no confirmation messages or progress indicator.
        )

		(if (askbool (prompt "Do you want to install the HAME libraries?")
                	 (help "In order to use the HAME device with Caligari, "
                      	   "you need to install the HAME libraries. If you "
						   "don't have a HAME, don't know what one is or "
						   "have already installed BOTH HAME libraries, you "
						   "can say No."
					 )
					 (default "Yes")
					 (choices "Yes" "No"))
		(
	        (working "\nUnpacking archive of\n"
					 "HAME libraries")
	        (if archPath
    	        (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":libs LIBS: hame.library renderhame.library"))
            	; else
            	(run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":libs LIBS: hame.library renderhame.library"))
            ; -mn means no confirmation messages or progress indicator.
			)
		))

		(if (askbool (prompt "Do you want to install the DCTV library?")
                	 (help "In order to use DCTV with Caligari, you need "
						   "to install the DCTV.library. If you don't "
						   "have DCTV, don't know what it is or have "
						   "already installed the DCTV library, you "
						   "can say No."
					 )
					 (default "Yes")
					 (choices "Yes" "No"))
		(
	        (working "\nUnpacking archive of\n"
					 "DCTV.library")
	        (if archPath
    	        (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname1 ":libs LIBS: dctv.library"))
            	; else
            	(run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname1 ":libs LIBS: dctv.library"))
            ; -mn means no confirmation messages or progress indicator.
			)
		))

        (askdisk   (prompt "Please insert disk 2, \n'" cal_dskname2 "'")
                   (dest cal_volname2)
                   (help @askdisk-help))

        (working "\nUnpacking archive of\n"
				 "Caligari Data Files")
        (if archPath
            ((run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":CalData CalData: *")))
            ; else
            ((run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":CalData CalData: *")))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Environment Maps")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":Environments CalEnviron: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":Environments CalEnviron: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Rendition Pipeline")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":Rend_di RenditionDI: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":Rend_di RenditionDI: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Tools")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":Tools CalTools: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":Tools CalTools: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Video bitmap font")
        (if archPath
   	        ((run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":fonts1 FONTS: *"))
       	     (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname2 ":fonts2 FONTS:video/ *")))
            ; else
   	        ((run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":fonts1 FONTS: *"))
       	     (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname2 ":fonts2 FONTS:video/ *")))
           	; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Sample Objects")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mnx x " cal_volname2 ":Objects CalScenes:objects/ *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mnx x " cal_volname2 ":Objects CalScenes:objects/ *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (askdisk   (prompt "Please insert disk 3, \n'" cal_dskname3 "'")
                   (dest cal_volname3)
                   (help @askdisk-help))

        (working "\nUnpacking archive of\n"
				 "Caligari Sample Objects")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mnx x " cal_volname3 ":Objects CalScenes:objects/ *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mnx x " cal_volname3 ":Objects CalScenes:objects/ *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (working "\nUnpacking archive of\n"
				 "Caligari Texture Maps")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x " cal_volname3 ":Textures CalTexture: *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mn x " cal_volname3 ":Textures CalTexture: *"))
            ; -mn means no confirmation messages or progress indicator.
        )

        (askdisk   (prompt "Please insert disk 4, \n'" cal_dskname4 "'")
                   (dest cal_volname4)
                   (help @askdisk-help))

        (working "\nUnpacking archive of\n"
				 "Caligari Sample Objects")
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mnx x " cal_volname4 ":Objects CalScenes:objects/ *"))
            ; else
            (run (cat cal_volname1 ":c/" archiver " >nil: -mnx x " cal_volname4 ":Objects CalScenes:objects/ *"))
            ; -mn means no confirmation messages or progress indicator.
        )

	    (set mods_ok 1)
	    (if (= @user-level 1)     ; average users aren't prompted by (startup...)
    	    (set mods_ok
        	    (askbool (help "Answering 'Yes' means that it is "
            		          "okay for the Installer to modify your "
                    		  "startup procedure (s:user-startup and "
              		          "s:startup-sequence, if appropriate) so "
                      		  "that the Caligari software works properly. "
                      		  "In this case, there are 11 "
                      		  "ASSIGN commands which the Caligari package "
                      		  "requires.  To use Caligari, these commands "
                      		  "must be given every time you boot your "
                      		  "Amiga.  It is recommended to add these lines.  "
                          	  "These are as follows:\n\n" cal_assigns
                     	 )
	                     (prompt "Is it okay to add a few lines at the "
        	                     "end of your startup procedure so that "
    	                         "the system has the proper Assigns for "
            	                 "the Caligari package?  Press HELP "
                	             "for more details.")
                    	 (default 1)
    	)))

	    (if mods_ok
    	    (startup "Caligari"
                     (prompt "Is it okay to add a few lines at the "
                             "end of your startup file, s:user-startup, so "
                             "that the system has the proper Assigns for "
                             "the Caligari package?  Press HELP "
                             "for more details."
					 )
            		 (help "Caligari won't work properly without the following assigns:\n\n"
    		       		   cal_assigns
                  		   "\n\nIf these lines are not added, "
                  		   "you will need to click on the file 'Caligari:Caligari-Setup' "
                  		   "each time you boot your machine, before you start using "
                  		   "the Caligari software."
            		 )
         			 (command cal_assigns)
        	)
        	( ; else
            	(message "You will need to click on the file 'Caligari:Caligari-Setup' "
                	     "each time you start your machine, when you want to use "
                    	 "the Caligari software.")
        		)
	    ) ; mods_ok

	    ; Update "Caligari-Setup"
    	(textfile (dest "Caligari:Caligari-Setup")
        	      (append cal_assigns)
            	  (help "Currently updating 'Caligari:Caligari-Setup' so that "
                	    "it will contain the proper assigns and Caligari will "
                    	"be properly set up when the setup is executed.  This "
                   	 	"operation is highly recommended.")
              	  (prompt "Currently updating 'Caligari:Caligari-Setup' so that "
                    	  "the commands are customized to your installation.")
    	) ; textfile
	)

; Caligari hard disk ========================================================

; Remove temporary assign file.
(if (exists cal_tmpfile)
       (delete cal_tmpfile (prompt "Deleting temporary assign file")
                           (help @delete-help)))

; If our archiver wound up in ram:, delete it.
(if (exists (tackon archDest archiver))
        (delete (tackon archDest archiver)
                (prompt "Deleting temporary file in " archDest ".")
                (help @delete-help)))

; This bit must go last---its purpose in life is to inform the user
; where all the software wound up.  Since that can be in over four
; different places, we're going to have to make @default-dest unusable
; for anything else, just to get the message across...

(set @default-dest look_here)
