; ************************************************
; *
; * Install-MovieShop
; *
; * $VER: Install-MovieShop 1.0 (19.6.94)
; *
; * This is the installation script for VLAB-Motion from MacroSystem GmbH
; * version 1.0
; *
; * Copyright © 1994 MacroSystem GmbH
; * All Rights Reserved
; *
; ************************************************

; ********************************
; * Set up some global variables.
; ********************************
;

(set ProductName  "VLab-Motion")
(set MovieShop    "MovieShop")
(set Toccata      "Toccata")
(set Retina       "Retina")
(set Macros       "Macros")
(set OSVersion		(/ (getversion) 65536))
(set Locale       (exists "libs:locale.library" (noreq)))
(set TotalFiles   0)
(set ActualFiles  0)

(set DirPath (@default-dest))

; ****************************
; * Set up some messages.
; ****************************
;

(if (patmatch @language "deutsch")
; german language
  (
   (set language 2)
   (set MSG_DEVELOPER         "Entwickler")
   (set MSG_SELECTPARTS       ("Bitte wählen Sie welche Teile der %s Software installiert werden sollen." ProductName))
   (set HLP_SELECTPARTS1       (cat ("Dieser Teil der Installation läßt Sie entscheiden, welche Teile ")
                               ("der %s Software sie auf Ihrer Festplatte installieren möchten.\n" ProductName)
                               ("\n")))
   (set HLP_SELECTPARTS2      (cat ("*** %s\n" MovieShop)
                              ("Dieser Teil beinhaltet das Hauptprogramm, mit welchem Sie ")
                              ("mit der %s Videos aufzeichenen, bearbeiten und " ProductName)
                              ("wieder abspielen können\n")
                              ("\n")))
   (set HLP_SELECTPARTS3      (cat ("*** %s\n" Toccata)
                              ("Dieser Teil beinhaltet alle notwendigen Programme und Dateien ")
                              ("um mit %s gleichzeitig Bild und Ton aufnehmen zu können\n" MovieShop)
                              ("Dies ist aber nur sinnvoll, wenn Sie eine %s besitzen.\n" Toccata)
                              ("\n")))
   (set HLP_SELECTPARTS4      (cat ("*** %s\n" Retina)
                              ("Dieser Teil beinhaltet alle notwendigen Programm und Dateien ")
                              ("um mit %s die Vorteile der Retina-Grafikarte (24Bit Workbench) " MovieShop)
                              ("nutzen zu können.\n")
                              ("Dies ist aber nur sinnvoll, wenn Sie eine %s-Grafikkarte besitzen\n" Retina)
                              ("\n")))
   (set HLP_SELECTPARTS5      (cat ("*** %s\n" Macros)
                              ("Dieser Teil bewirkt, daß die mitgelieferten Tastatus-Macros ")
                              ("in Ihrer %s-Version installiert werden. Eine genauere Beschreibung " MovieShop)
                              ("entnehmen Sie bitte dem %s-Handbuch.\n" MovieShop)
                              ("\n")))
   (set HLP_SELECTPARTS6      (cat ("*** %s\n" Developer)
                              ("Dieser Teil installiert alle notwendigen Dateien, um die %s " ProducName)
                              ("selber programmieren zu können. Unsertstützt werden hierbei die ")
                              ("Programmiersprachen \"C\" und \"Assembler\"")
                              ("\n\n")))
   (set HLP_SETDIRPATH        (cat "Wenn Sie mit dem Installer ein Verzeichnis anlegen, ist es "
                              ("sehr sinnvoll, daß sie in den Namen kein Leerzeichen einfügen. ")
                              ("Dieses erleichtert den späteren Umgang, besonders beim arbeiten ")
                              ("in der Shell und mit AREXX.\n")))
   (set HLP_COPYLIB           ("Wenn bereits eine Library mit diesem Namen besteht, so wird"
                              "diese nur überschrieben, wenn sie eine ältere Version ist.\n"))
   (set MSG_FALSEOSVERSION    ("%s benötigt unbedingt AmigaOS 2.04 oder höher.\n" MovieShop))
   (set MSG_MOVIESHOPPATH     "Geben Sie bitte das Zielverzeichnis für MovieShop an.")
   (set MSG_TOCCATAPATH       "Geben Sie bitte das Zielverzeichnis für die Toccata Hilfsprogramme an.")
   (set MSG_RETINAPATH        "Geben Sie bitte das Zielverzeichnis für die Retina Hilfsprogramme an.")
   (set MSG_MACROPATH         "Geben Sie bitte das Zielverzeichnis für die MovieShop Macro Datei an.")
   (set MSG_DEVELOPERPATH     "Geben Sie bitte das Zielverzeichnis für die VLab-Motion Entwickler Dateien an.")
   (set MSG_GETMOVIESHOPDISK  "Bitte legen Sie die Diskette mit dem Namen \"MovieShop\" in ein beliebiges Laufwerk")
   (Set HLP_GETMOVIESHOPDISK  (cat MSG_GETMOVIESHOPDISK "\nIch benötige diese Diskette, um die Installation vornehmen zu können!\n"))
   (set MSG_COPYLIB           "Kopiere Library %s nach %s")
   (set MSG_COPYFILE          "Kopiere Datei %s nach %s")
  )
; default language
  (
   (set language 4)
   (set MSG_DEVELOPER         "Developer")
   (set MSG_SELECTPARTS       ("Bitte wählen Sie welche Teile der %s Software installiert werden sollen." ProductName))
   (set HLP_SELECTPARTS1       (cat ("Dieser Teil der Installation läßt Sie entscheiden, welche Teile ")
                               ("der %s Software sie auf Ihrer Festplatte installieren möchten.\n" ProductName)
                               ("\n")))
   (set HLP_SELECTPARTS2      (cat ("*** %s\n" MovieShop)
                              ("Dieser Teil beinhaltet das Hauptprogramm, mit welchem Sie ")
                              ("mit der %s Videos aufzeichenen, bearbeiten und " ProductName)
                              ("wieder abspielen können\n")
                              ("\n")))
   (set HLP_SELECTPARTS3      (cat ("*** %s\n" Toccata)
                              ("Dieser Teil beinhaltet alle notwendigen Programme und Dateien ")
                              ("um mit %s gleichzeitig Bild und Ton aufnehmen zu können\n" MovieShop)
                              ("Dies ist aber nur sinnvoll, wenn Sie eine %s besitzen.\n" Toccata)
                              ("\n")))
   (set HLP_SELECTPARTS4      (cat ("*** %s\n" Retina)
                              ("Dieser Teil beinhaltet alle notwendigen Programm und Dateien ")
                              ("um mit %s die Vorteile der Retina-Grafikarte (24Bit Workbench) " MovieShop)
                              ("nutzen zu können.\n")
                              ("Dies ist aber nur sinnvoll, wenn Sie eine %s-Grafikkarte besitzen\n" Retina)
                              ("\n")))
   (set HLP_SELECTPARTS5      (cat ("*** %s\n" Macros)
                              ("Dieser Teil bewirkt, daß die mitgelieferten Tastatus-Macros ")
                              ("in Ihrer %s-Version installiert werden. Eine genauere Beschreibung " MovieShop)
                              ("entnehmen Sie bitte dem %s-Handbuch.\n" MovieShop)
                              ("\n")))
   (set HLP_SELECTPARTS6      (cat ("*** %s\n" Developer)
                              ("Dieser Teil installiert alle notwendigen Dateien, um die %s " ProducName)
                              ("selber programmieren zu können. Unsertstützt werden hierbei die ")
                              ("Programmiersprachen \"C\" und \"Assembler\"")
                              ("\n\n")))
   (set HLP_SETDIRPATH        (cat "Wenn Sie mit dem Installer ein Verzeichnis anlegen, ist es "
                              ("sehr sinnvoll, daß sie in den Namen kein Leerzeichen einfügen. ")
                              ("Dieses erleichtert den späteren Umgang, besonders beim arbeiten ")
                              ("in der Shell und mit AREXX.\n")))
   (set HLP_COPYLIB           ("Wenn bereits eine Library mit diesem Namen besteht, so wird"
                              "diese nur überschrieben, wenn sie eine ältere Version ist.\n"))
   (set MSG_FALSEOSVERSION    ("%s benötigt unbedingt AmigaOS 2.04 oder höher.\n" MovieShop))
   (set MSG_MOVIESHOPPATH     "Geben Sie bitte das Zielverzeichnis für MovieShop an.")
   (set MSG_TOCCATAPATH       "Geben Sie bitte das Zielverzeichnis für die Toccata Hilfsprogramme an.")
   (set MSG_RETINAPATH        "Geben Sie bitte das Zielverzeichnis für die Retina Hilfsprogramme an.")
   (set MSG_MACROPATH         "Geben Sie bitte das Zielverzeichnis für die MovieShop Macro Datei an.")
   (set MSG_DEVELOPERPATH     "Geben Sie bitte das Zielverzeichnis für die VLab-Motion Entwickler Dateien an.")
   (set MSG_GETMOVIESHOPDISK  "Bitte legen Sie die Diskette mit dem Namen \"MovieShop\" in ein beliebiges Laufwerk")
   (Set HLP_GETMOVIESHOPDISK  (cat MSG_GETMOVIESHOPDISK "\nIch benötige diese Diskette, um die Installation vornehmen zu können!\n"))
   (set MSG_COPYLIB           "Kopiere Library %s nach %s")
   (set MSG_COPYFILE          "Kopiere Datei %s nach %s")

  )
)

(procedure ChooseParts
;
; ****************************
; * Ask the user which parts of the package should be installed.
; ****************************
;
	(
	(set Parts
		(askoptions
			(prompt
			   (MSG_SELECTPARTS)
			)
			(help
            (HLP_SELECTPARTS1)
            (HLP_SELECTPARTS2)
            (HLP_SELECTPARTS3)
            (HLP_SELECTPARTS4)
            (HLP_SELECTPARTS5)
            (HLP_SELECTPARTS6)
				@askoptions-help
			)
			(choices
				; bit position 0 -- todo & 1
				;
				("%s" MovieShop)

				; bit position 1 -- todo & 2
				;
				("%s" Toccata)

				; bit position 2 -- todo & 4
				;
				("%s" Retina)

				; bit position 3 -- todo & 8
				;
				("%s" Macros)

				; bit position 4 -- todo & 16
				;
;				("%s" MSG_DEVELOPER)
;
				; bit position 5 -- todo & 32
				;
			)
		)
	)
	)
)

(procedure SetDirPath

; ****************************
; * Ask the user for a directory name.
; ****************************
;
; these variables must be defined before calling this procedure:
;
;    DirPathTitle
;    DirPathHelp
;    DirPath
;
; this procedure returns the selected directory in DirPath

   (if (= (exists DirPath) 0)
      (
		(set DirPath
			(askdir
				(prompt DirPathTitle)
				(help	DirPathHelp @askdir-help)
				(newpath DirPath)
				(default DirPath)
			)
		)
		)
		(
		(set DirPath
			(askdir
				(prompt DirPathTitle)
				(help	DirPathHelp @askdir-help)
				(default DirPath)
			)
		)
		)
	)
   (if (= (exists DirPath) 0)
		(makedir DirPath)
		(set moveon	TRUE)
	)
)

(procedure CopyLibFile

; ****************************
; * Copy the specific library file to the LIBS: directory.
; ****************************
;
; these variables must be defined before calling this procedure:
;
;    CopyLibFileName
;    CopyLibFilePath
;    DirPath

	(
	(if (= (exists (tackon DirPath CopyLibFileName)) 1)
		(
		(protect (tackon DirPath CopyLibFileName) "+rwed")
		)
	)
	(copylib
		(prompt	(MSG_COPYLIB CopyLibFileName DirPath))
		(help @copylib-help
		)
		(source (tackon CopyLibFilePath CopyLibFileName))
		(dest DirPath)
		(confirm)
	)
	)
)

(procedure IncrementMeter
;
; ****************************
; * Set the Percent indicator.
; ****************************
;
;    AddToMeter

	(
	(set PctDone	(/ (* ActualFiles 100) TotalFiles))
	(set ActualFiles	(+ ActualFiles AddToMeter))
	(complete PctDone)
	)
)


(procedure InstallMovieShop
;
; ****************************
; * Install all MovieShop files
; ****************************
;

   (set existsrc (getassign "MovieShop" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETMOVIESHOPDISK)
               (help HLP_GETMOVIESHOPDISK @askdisk-help)
               (dest "MovieShop")
      )
   )

   (Set DirPath (tackon @default-dest "MovieShop"))
   (Set DirPathTitle MSG_MOVIESHOPPATH)
   (Set DirPathHelp  HLP_SETDIRPATH)
   (SetDirPath)

   (set AddToMeter	1)
   (IncrementMeter)

   (if (= Locale 1)
      (
;
; locale is installed
;
         (if (= language 2)
;
; german language
;
            (if (= (exists "Locale:Catalogs/deutsch") 2)
               (
                  (copyfiles
                     (prompt (MSG_COPYFILE "movieshop.catalog" "Locale:catalogs/deutsch/"))
                     (help "")
                     (source "MovieShop:MovieShop/movieshop.catalog")
                     (dest "Locale:Catalogs/deutsch")
                     (files)
                     (optional fail force)
                  )
               )
            )
         )
      )
      (
         (if (= language 2)
            (
;
; minloc.library will be installed
;
               (copyfiles
                  (prompt (MSG_COPYFILE movieshop.catalog DirPath))
                  (source ("MovieShop:MovieShop/movieshop.catalog"))
                  (dest DirPath)
                  (files)
                  (optional fail force)
               )
               (set DirPath "Libs:")
               (set CopyLibFilePath "MovieShop:MovieShop")
               (set CopyLibFileName "minloc.library")
               (CopyLibFile)
               (textfile (prompt MSG_CreateMLL)
                         (help HLP_CreateMLL)
                         (dest "ENVARC:MINLOCLANGUAGE")
                         (append "deutsch\n")
               )
            )
         )
      )
   )

   (set AddToMeter	2)
   (IncrementMeter)

;
; install main Programm
;

   (copyfiles
      (prompt (MSG_COPYFILE "MovieShop" DirPath))
      (source ("MovieShop:MovieShop/MovieShop"))
      (dest DirPath)
      (infos)
      (files)
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; install VJPEG
;

   (copyfiles
      (prompt (MSG_COPYFILE "vjpeg" DirPath))
      (source ("MovieShop:MovieShop/vjpeg"))
      (dest DirPath)
      (files)
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; install default prefs
;

   (makedir "ENVARC:MovieShop")

   (if (= (exists "ENVARC:MovieShop/MovieShop.prefs") 0)
      (
         (copyfiles
            (prompt (MSG_COPYFILE "movieshop.prefs" "ENVARC:MovieShop/"))
            (source ("MovieShop:MovieShop/MovieShop.prefs"))
            (dest "ENVARC:MovieShop/")
            (files)
            (optional fail force)
         )   
      )
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; install default icons
;

   (copyfiles
      (prompt (MSG_COPYFILE "Icons" "ENVARC:MovieShop/"))
      (source ("MovieShop:MovieShop/"))
      (dest "ENVARC:MovieShop/")
      (files)
      (pattern "def_#?")
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; finaly all needed library
;

   (set CopyLibFilePath "MovieShop:MovieShop")
   (set DirPath "Libs:")

   (set CopyLibFileName "vmotion.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
   (set CopyLibFileName "multipic.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
   (set CopyLibFileName "pfile.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
   (set CopyLibFileName "asl.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
)

(procedure InstallToccata
;
; ****************************
; * Install all Toccata files
; ****************************
;

   (set existsrc (getassign "MovieShop" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETMOVIESHOPDISK)
               (help HLP_GETMOVIESHOPDISK @askdisk-help)
               (dest "MovieShop")
      )
   )

   (Set DirPath (tackon @default-dest "Toccata"))
   (Set DirPathTitle MSG_TOCCATAPATH)
   (Set DirPathHelp  HLP_SETDIRPATH)
   (SetDirPath)

   (set AddToMeter	1)
   (IncrementMeter)

   (if (= Locale 1)
      (
;
; locale is installed
;
         (if (= language 2)
;
; german language
;
            (if (= (exists "Locale:Catalogs/deutsch") 2)
               (
                  (copyfiles
                     (prompt (MSG_COPYFILE "toco.catalog" "Locale:catalogs/deutsch/"))
                     (help "")
                     (source "MovieShop:Toccata/toco.catalog")
                     (dest "Locale:Catalogs/deutsch/toccata")
                     (files)
                     (optional fail force)
                  )
               )
            )
         )
      )
      (
         (if (= language 2)
            (
;
; minloc.library will be installed
;
               (copyfiles
                  (prompt (MSG_COPYFILE toco.catalog DirPath))
                  (source ("MovieShop:Toccata/toco.catalog"))
                  (dest DirPath)
                  (files)
                  (optional fail force)
               )
               (set DirPath "Libs:")
               (set CopyLibFilePath "MovieShop:MovieShop")
               (set CopyLibFileName "minloc.library")
               (CopyLibFile)
            )
         )
      )
   )

   (set AddToMeter	2)
   (IncrementMeter)

;
; install Toccata-Control
;

   (copyfiles
      (prompt (MSG_COPYFILE "ToccataControl" DirPath))
      (source ("MovieShop:Toccata/ToccataControl"))
      (dest DirPath)
      (files)
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; finaly toccata.library
;

   (set CopyLibFilePath "MovieShop:Toccata")
   (set DirPath "Libs:")

   (set CopyLibFileName "toccata.library")
   (CopyLibFile)

   (set AddToMeter	1)
   (IncrementMeter)
)

(procedure InstallRetina
;
; ****************************
; * Install all Retina files
; ****************************
;

   (set existsrc (getassign "MovieShop" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETMOVIESHOPDISK)
               (help HLP_GETMOVIESHOPDISK @askdisk-help)
               (dest "MovieShop")
      )
   )

   (set AddToMeter	1)
   (IncrementMeter)

;
; install retina.library
;

   (set CopyLibFilePath "MovieShop:Retina")
   (set DirPath "Libs:")

   (set CopyLibFileName "retina.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
   (set CopyLibFileName "retinaemu.library")
   (CopyLibFile)
   (set AddToMeter	1)
   (IncrementMeter)
)

(procedure InstallMacros
;
; ****************************
; * Install all Macro files
; ****************************
;

   (set existsrc (getassign "MovieShop" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETMOVIESHOPDISK)
               (help HLP_GETMOVIESHOPDISK @askdisk-help)
               (dest "MovieShop")
      )
   )

   (Set DirPath "ENVARC:MovieShop")
   (Set DirPathTitle MSG_MACROPATH)
   (Set DirPathHelp  HLP_SETDIRPATH)
   (SetDirPath)

   (set AddToMeter	1)
   (IncrementMeter)

;
; install MovieShop.macros
;

   (copyfiles
      (prompt (MSG_COPYFILE "MovieShop.macros" DirPath))
      (source ("MovieShop:Macros/MovieShop.macros"))
      (dest DirPath)
      (files)
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

)

(procedure InstallDeveloper
;
; ****************************
; * Install all Developer files
; ****************************
;

   (set existsrc (getassign "MovieShop" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETMOVIESHOPDISK)
               (help HLP_GETMOVIESHOPDISK @askdisk-help)
               (dest "MovieShop")
      )
   )

   (Set DirPath (tackon @default-dest "MovieShop/Developer"))
   (Set DirPathTitle MSG_DEVELOPERPATH)
   (Set DirPathHelp  HLP_SETDIRPATH)
   (SetDirPath)

   (set AddToMeter	1)
   (IncrementMeter)

;
; install all include files
;

   (copyfiles
      (prompt (MSG_COPYFILE (cat MSG_DEVELOPER "-Dateien") DirPath))
      (source ("MovieShop:Developer"))
      (dest DirPath)
      (all)
      (optional fail force)
   )

   (set AddToMeter	1)
   (IncrementMeter)

)

; *************************************************************************
; *                             MAIN OF SCRIPT
; *************************************************************************

(onerror
	(exit (quiet))
)

(if (< OSVersion 37)
	(abort (MSG_FALSEOSVERSION)))

(ChooseParts)

; count number of files to be installed
;
(if (BITAND Parts 1)
   (set TotalFiles (+ TotalFiles 11)))
(if (BITAND Parts 2)
   (set TotalFiles (+ TotalFiles 5)))
(if (BITAND Parts 4)
   (set TotalFiles (+ TotalFiles 3)))
(if (BITAND Parts 8)
   (set TotalFiles (+ TotalFiles 2)))
;(if (BITAND Parts 16)
;   (set TotalFiles (+ TotalFiles 6)))

(complete 0)

(if (BITAND Parts 1)
   (InstallMovieShop))
(if (BITAND Parts 2)
   (InstallToccata))
(if (BITAND Parts 4)
   (InstallRetina))
(if (BITAND Parts 8)
   (InstallMacros))
;(if (BITAND Parts 16)
;   (InstallDeveloper))

(complete 100)
