; ************************************************
; *
; * Install-Operators
; *
; * $VER: Install-Operators 1.0 (20.1.95)
; *
; * This is the installation script for MovieShop Effects from MacroSystem GmbH
; *
; * Copyright © 1994 MS MacroSystem Computer GmbH
; * All Rights Reserved
; *
; * written by Ibrahim Tertemiz
; *
; ************************************************

;
;
;

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

(set OSVersion		(/ (getversion) 65536))
(set Locale       (exists "libs:locale.library" (noreq)))
(set TotalFiles   0)
(set ActualFiles  0)
(set MovieShop "MovieShop")

(set DirPath (@default-dest))

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

(if (patmatch @language "deutsch")
; german language
  (
   (set language 2)
   (set MSG_MSHOPDIR "Bitte geben Sie das Verzeichnis an, in dem MovieShop installiert ist.")
   (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 MSG_GETOPERATORDISK "Bitte legen Sie die Diskette \"Operator_Disk\" in ein beliebiges Laufwerk")
   (set HLP_GETOPERATORDISK "Die Diskette \"Operator_Disk\" wird benötigt, um die Operator auf Festplatte zu kopieren.")
   (set MSG_OPERATORPATH "Bitte geben Sie das Verzeichnis an, in dem sich die MovieShop Operator befinden...")
   (set MSG_COPYFILE "Kopiere Datei %s nach %s...")
   (set MSG_FALSEOSVERSION ("%s benötigt unbedingt AmigaOS 2.04 oder höher.\n" MovieShop))
  )

; default language
  (
   (set language 4)
   (set MSG_MSHOPDIR "")
   (set HLP_SETDIRPATH (cat "NOTE: If you will using the Installer program's "
               		      ("function to create a new directory using \"Make New Drawer...\"")
					            ("it is highly recommended that you DO NOT include ")
					            ("spaces in the drawer name.  Following this advice ")
					            ("will avoid any problems accessing the directory, ")
					            ("especially from ARexx scripts.\n\n")))
   (set MSG_GETOPERATORDISK "Please insert Disk \"Operator_Disk\" in any drive...")
   (set HLP_GETOPERATORDISK "The disk \"Operator_Disk\" is needed for the installation of your new Operators.")
   (set MSG_OPERATORPATH "Please select the directory for the MovieShop operators...")
   (set MSG_COPYFILE "Copying file %s in directory %s")
   (set HLP_COPYFILE "This file is needed by MovieShop")
   (set MSG_FALSEOSVERSION "MovieShop needs at least Kickstart 2.04")
  )
)

(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)
			)
		)
		)
	)

)

(procedure InstallOperator
;
; ******************************
; * Install all effect operators
; ******************************
;
   (set existsrc (getassign "Operator_Disk" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETOPERATORDISK)
               (help HLP_GETOPERATORDISK @askdisk-help)
               (dest "Operator_Disk")
      )
   )

   (Set DirPath (tackon MShopDir "Operators"))
   (Set DirPathTitle MSG_OPERATORPATH)
   (Set DirPathHelp  HLP_SETDIRPATH)
;   (SetDirPath)

   (copyfiles
      (prompt (MSG_COPYFILE "Operators" DirPath))
      (help MSG_COPYFILE @copyfiles-help)
      (source "Operator_Disk:Operators/")
      (pattern "#?")
      (dest DirPath)
      (files)
      (optional fail force)
   )
)

(procedure InstallMacro
;
; ******************************
; * Install new Macros
; ******************************
;
   (set existsrc (getassign "Operator_Disk" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETOPERATORDISK)
               (help HLP_GETOPERATORDISK @askdisk-help)
               (dest "Operator_Disk")
      )
   )

   (Set DirPath (tackon MShopDir "Macros"))
   (Set DirPathTitle MSG_MACROSPATH)
   (Set DirPathHelp  HLP_SETDIRPATH  )
;   (SetDirPath)

   (copyfiles
      (prompt (MSG_COPYFILE "Macros" DirPath))
      (help MSG_COPYFILE @copyfiles-help)
      (source "Operator_Disk:Macros/")
      (pattern "#?")
      (dest DirPath)
      (files)
      (infos)
      (optional fail force)
   )
)

(procedure InstallReadMe
;
; ******************************
; * Install ReadMe
; ******************************
;
   (set existsrc (getassign "Operator_Disk" "v"))
   (if (= existsrc "")
      (askdisk (prompt MSG_GETOPERATORDISK)
               (help HLP_GETOPERATORDISK @askdisk-help)
               (dest "Operator_Disk")
      )
   )

   (copyfiles
      (prompt MSG_COPYFILE)
      (help MSG_COPYFILE @copyfiles-help)
      (source "Operator_Disk:")
      (pattern "#?.txt")
      (dest MShopDir)
      (files)
      (infos )
      (optional fail force)
   )
)

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

(onerror
	(exit (quiet))
)

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

   (set DirPathTitle MSG_MSHOPDIR)
   (set DirPathHelp HLP_SETDIRPATH)
   (SetDirPath)
   (Set MShopDir DirPath)
   (Set @default-dest MShopDir)

   (InstallOperator)

   (InstallMacro)

   (InstallReadMe)
