; $VER: InstallVM 02.00 (23 Nov 1993)  Stephan Srken

; TEXT DEFINITIONS

(set stepsHelp
     (cat "\n"
          "This window lets you choose the steps this script should "
          "perform. It can be used for four main purposes:\n\n"
          " (0) accomplish a minor update\n"
          " (1) accomplish a complete new installation\n"
          " (2) update older VideoMaxe files\n\n"
          " You can freely choose which steps should actually be "
          "performed, except that steps 0 and 1 exclude themselves.\n\n"
          " STEP 0: Will only copy the VideoMaxe program file, "
          "the new documentation files and the language "
          "localization files. You should use this "
          "if you want to install an update without file format "
          "changes. Thus your VideoMaxe configuration "
          "remain as it was (note that hence you will not "
          "recognize new configuration design (e.g. new icons) "
          "of the new release).\n"
          " STEP 1: Will accomlish a complete new instalation "
          "of VideoMaxe. Use this if you are a new user or "
          "updating from the 3.XX version (as you can`t reuse "
          "VideoMaxe 3.XX configuration...).\n"
          "Choose this too if you are not sure what to select, "
          "as this will in any case produce a runable installation "
          "of the new version.\n"
          " STEP 2: Lets you update older VideoMaxe files with "
          "the CLI-Tool VMConvert.\n\n"
          "Note that if you however forgot anything, you can "
          "call this script again, performing only the "
          "furthermore needed steps.\n\n"))

(set destDirHelp
     (cat "\n"
          "Into the directory you choose here all files "
          "important for VideoMaxe are placed during the "
          "installation procedure.\n"
          "Note that this directory must be empty, so "
          "normally you will create a new directory at "
          "this point.\n\n"))

(set langHelp
     (cat "\n"
          "Since OS 2.1, the Amiga can operate in different "
          "languages if the application supports them. VideoMaxe "
          "up to now supports English (as default, `built-in` "
          "language), German (Deutsch) and French (Franais).\n"
          "Simply check the languages you want VideoMaxe to "
          "support.\n\n"))

(set exampleFilesHelp
     (cat "\n"
          "VideoMaxe comes with various example files.\n"
          "`Projects' contains example project files. "
          "`MaskList' contains example mask list files. "
          "`PrtPrefs' contains example printer preferences files. "
          "`VideoRecorder' contains example video recorder files.\n\n"))

(set docsHelp
     (cat "\n"
          "VideoMaxe comes with two differently formatted files "
          "containing its documentation. The first (VideoMaxe.doc) "
          "is a plain ASCII text file (that could for example be "
          "displayed with the standard text viewer More). The "
          "second file (VideoMaxe.guide) is in AmigaGuide format "
          "and can be displayed by any hypertext displayer (e.g. "
          "AmigaGuide).\n"
          "I strongly urge to use the latter if you have the "
          "opportunity to.\n\n"))

(set updateFilesHelp
     (cat "\n"
          "If you have worked with former versions of VideoMaxe "
          "and there have been file format changes, you won't want "
          "to loose the data of these old files.\n"
          "Thus, you have to update these files to the new formats.\n"
          "This task is done by the CLI-Tool `VMConvert', shipped "
          "with every release of VideoMaxe in the `Tools' directory; "
          "to not let you nimble around with that Tool you can "
          "comfortably update old files with this script!! "
          "Simply choose the old file types you want to update; "
          "you will then be asked for source and destination "
          "file names.\n"
          "This procedure won't do no harm as it will only convert "
          "to non-existent destination files.\n\n"))

(set V3XXUpdateHelp
     (cat "\n"
          "Here you are updating files from the 3.XX version "
          "to the format of the current version of VideoMaxe.\n"
          "Choose a _source_ VideoMaxe V3.XX file of the specified "
          "type and a _destination_ file here. The choosen "
          "source file will then be updated into the choosen "
          "destination file.\n"
          "If you have never worked with the 3.XX version "
          "of VideoMaxe, you are completely wrong here.\n"
          "Go away!\n\n"))

(set V420UpdateHelp
     (cat "\n"
          "Here you are updating files from the 4.00-4.20 versions "
          "to the format of the current version of VideoMaxe.\n"
          "Choose a _source_ VideoMaxe V4.00-V4.20 file of the specified "
          "type and a _destination_ file here. The choosen "
          "source file will then be updated into the choosen "
          "destination file.\n"
          "If you have never worked with the 4.00-4.20 versions "
          "of VideoMaxe, you are completely wrong here.\n"
          "Go away!\n\n"))

;------------------
(PROCEDURE CopyCats
; ARGS: destDir

(if (NOT (exists "LOCALE:"))		; `LOCALE:' THERE?
     ((message "\n You have no LOCALE: directory; will copy "
               "catalogs to program directory!")
      (set catDest (tackon destDir "Catalogs"))
     )
     ((set catDest ("LOCALE:Catalogs"))
     )
) ; fi

(makedir catDest); maybe existent
(copyfiles (prompt "Which languages (additionally to the built-in language "
                   "english) should be supported by VideoMaxe?")
           (source "Catalogs")
           (dest catDest)
           (choices "Deutsch"
                    "Franais")
           (confirm)
           (help langHelp @copyfiles-help))

);ENDPROC CopyCats
;-----------------

;------------------
(PROCEDURE CopyDocs
; ARGS: destDir, docsHelp

(copyfiles (prompt "Which documentation files should be copied?")
           (source "Docs")
           (dest (tackon destDir "Docs"))
           (choices "VideoMaxe.doc"
                    "VideoMaxe.guide")
           (confirm)
           (infos)
           (noposition)
           (help docsHelp @copyfiles-help))

);ENDPROC CopyDocs
;------------------

;-----------------------
(PROCEDURE ConvertFiles
; ARGS: fileType,		; the file type to be converted
;       sourceFile, destFile,	; used as dir defaults...
;       versionUpdateHelp	; information texts...


; CALC PROMPTS
(set sourceFileSpecifyPrompt (cat "Please specify the old VideoMaxe "
                                  "file of type: "
                                  fileType))
(set destFileSpecifyPrompt (cat "Please specify the name for "
                                "the updated output file:"))

; WHILE
(set ok 1)
(while ok
       ; GET SOURCE
       (set sourceFile (askfile (prompt sourceFileSpecifyPrompt)
                                (default sourceFile)
                                (help versionUpdateHelp @askfile-help)))
       ; GET DEST
       (set destFile (askfile (prompt destFileSpecifyPrompt)
                              (default destFile)
                              (help versionUpdateHelp @askfile-help)))
       (if (exists destFile)
           ((message "\nCan't convert: Destination file already exists!"))
           ((run ("Tools/VMConvert >CON:20/20/400/200/VMConvert/CLOSE/WAIT %s %s %s" fileType sourceFile destFile)))
       )
       (set ok (askbool (prompt "\nUpdate more files of that type?\n")
                        (help askbool-help)
                        (choices "Yes" "No")))
)

);ENDPROC ConvertFiles
;----------------------


; INITIAL SETTINGS

(set steps %010)
(set destDir "Work:VideoMaxe")
(set @default-dest destDir)

; WELCOME OUT THERE!

(welcome)

; WHICH STEPS?

(set ok 0)
(until ok

       (set steps (askoptions (prompt "Which steps should be performed?")
                              (default steps)
                              (help stepsHelp @askoptions-help)
                              (choices "Minor update"
                                       "New installation"
                                       "Update files")))

       ; STEPS 0 AND 1 SELECTED?

       (set ok (NOT (AND (> (IN steps 0) 0) (> (IN steps 1) 0))))
       (if (NOT ok) ((message "\nYou must not choose step 0 AND step 1!")))
)

(if (IN steps 0)
(
;====================================
(message "\nSTEP ZERO: MINOR UPDATE")
;====================================

; GET DEST DIR

(set ok 0)
(until ok
       (set destDir (askdir (prompt "Please specify the directory VideoMaxe "
                             "is installed in:")
                            (default "VM:")
                            (help askdir-help)))
       (set ok (exists destDir))			; dest dir ok
       (if (NOT ok) (message "\nSpecified directory does not exist!"))
)
(set @default-dest destDir)

; COPY DOC FILES

(CopyDocs)

; COPY LOCALIZATION FILES

(CopyCats)

;===================================
(message "\nMINOR UPDATE COMPLETE.")
;===================================
))


(if (IN steps 1)
(
;=======================================
(message "\nSTEP ONE: NEW INSTALLATION")
;=======================================

; GET DEST DIR

(set ok 0)
(until ok
       (set destDir (askdir (prompt "Please specify the directory VideoMaxe "
                                    "should be installed to (must be empty):")
                            (default "Work:VideoMaxe")
                            (help destDirHelp @askdir-help)))
       (set ok 1)				; dest dir ok
       (foreach destDir "#?" (set ok 0))	; or not? - must be empty!
       (if (NOT ok) (message "\nSpecified directory is not empty!"))
)
(set @default-dest destDir)

; CREATE DIRS

(working "Creating needed sub-directories...")

(makedir (tackon destDir "Config"))
(copyfiles (source "Config.info") (dest destDir))
(makedir (tackon destDir "Projects"))
(copyfiles (source "Projects.info") (dest destDir))
(makedir (tackon destDir "MaskLists"))
(copyfiles (source "MaskLists.info") (dest destDir))
(makedir (tackon destDir "PrtPrefs"))
(copyfiles (source "PrtPrefs.info") (dest destDir))
(makedir (tackon destDir "VideoRecorder"))
(copyfiles (source "VideoRecorder.info") (dest destDir))

; COPY CRUCIAL FILES

(working "Copying crucial files...")

(copyfiles (source "VideoMaxe")	(dest destDir) (infos))	; light version
(copyfiles (source "AssignVM")	(dest destDir) (infos))
(copyfiles (source "Config")	(dest (tackon destDir "Config")) (infos) (all))

; COPY EXAMPLE FILES

(copyfiles (prompt "Which example files should be copied?")
           (source "")
           (dest destDir)
           (choices "Projects"
                    "MaskLists"
                    "PrtPrefs"
                    "VideoRecorder")
           (help exampleFilesHelp @copyfiles-help)
           (confirm)
           (infos))

; COPY DOC FILES

(CopyDocs)

; COPY LOCALIZATION FILES

(CopyCats)

; SYSTEM STARTUP

(startup "VideoMaxe" (Prompt "Should the logical device VM: be assigned "
                             "automatically with your system`s startup?")
                     (help @startup-help)
                     (command "Assign VM: " destDir))

;=======================================
(message "\nNEW INSTALLATION COMPLETE.")
;=======================================
))


(if (IN steps 2)
(
;=====================================
(message "\nSTEP TWO: UPDATING FILES")
;=====================================

; GET SELECTION

(set updates %1111000)
(set updates (askoptions (prompt "Which old file types do you want "
                                 "to update to current version?")
                         (default updates)        
                         (help updateFilesHelp @askoptions-help)
                         (choices "VideoMaxe 3.XX video recorder files"
                                  "VideoMaxe 3.XX project files"
                                  "-----------------------------------"
                                  "VideoMaxe 4.20 mask list files"
                                  "VideoMaxe 4.20 project files"
                                  "VideoMaxe 4.20 video recorder files"
                                  "VideoMaxe 4.20 printer pref. files")))

; ... SELECTION
;
;------
; V3XX
;------
(set versionUpdateHelp V3XXUpdateHelp)
;
(if (IN updates 0)	; V3XXVREC
            (
             ; SET ARGUMENTS
             (set fileType "V3XXVREC")
             (set sourceFile "VM:Treiber")
             (set destFile (tackon destDir "VideoRecorder"))
            
             (ConvertFiles)
            )
)
(if (IN updates 1)	; V3XXPROJECT
            (
             ; SET ARGUMENTS
             (set fileType "V3XXPROJECT")
             (set sourceFile "VM:Projekte")
             (set destFile (tackon destDir "Projects"))
            
             (ConvertFiles)
            )
)

(if (IN updates 2)	; -----
            (
             (message "Seperator `--...--' can't be converted yet - working on it...")
            )
)
;
;------
; V420
;------
(set versionUpdateHelp V420UpdateHelp)
;
(if (IN updates 3)	; V420MASKLIST
            (
             ; SET ARGUMENTS
             (set fileType "V420MASKLIST")
             (set sourceFile "VM:MaskLists")
             (set destFile (tackon destDir "MaskLists"))
            
             (ConvertFiles)
            )
)
(if (IN updates 4)	; V420PROJECT
            (
             ; SET ARGUMENTS
             (set fileType "V420PROJECT")
             (set sourceFile "VM:Projects")
             (set destFile (tackon destDir "Projects"))
            
             (ConvertFiles)
            )
)
(if (IN updates 5)	; V420VREC
            (
             ; SET ARGUMENTS
             (set fileType "V420VREC")
             (set sourceFile "VM:VideoRecorder")
             (set destFile (tackon destDir "VideoRecorder"))
            
             (ConvertFiles)
            )
)
(if (IN updates 6)	; V420PRTPREFS
            (
             ; SET ARGUMENTS
             (set fileType "V420PRTPREFS")
             (set sourceFile "VM:PrtPrefs")
             (set destFile (tackon destDir "PrtPrefs"))
            
             (ConvertFiles)
            )
)

;===============================
(message "\nUPDATING COMPLETE.")
;===============================
))

(exit)
