
(set progname    "VideoArchiv")
(set progversion "2.0")
(set progdir     "VideoArchiv_v2.0")
(set diskname    "")
(set user-level @user-level)
(user 2)

(message (cat "\nWelcome to the installation utility of\n" progname
              " " progversion " !\n\n"
              "This utility installs the program " progname
              "\ncompletely on your harddisk.\n")
)

(user user-level)
(welcome)

(set progpath "WORK:")
(set ok 0)


(set user-level @user-level)
(user 2)

(while (not ok)
  (set progpath (askdir
                (prompt (cat "Where shall " progname " be installed?\n"
                             "(New Directory will be created.)"))
                (help @askdir-help)
                (default progpath)
                (disk)
                )
  )
  (If (= (Exists progpath (noreq)) 0)
    (
    (message (cat "\nPath does not exist!\n\n"
                  "Please select a valid Path."))
    )
    (
    (If (= (Exists (tackon progpath progdir)) 0)
      (
      (set ok 1)
      )
      (
      (message (cat "\nA Directory called " progdir " does already \n"
                    "exist in your Path!\n\n"
                    "Please select another Directory or delete\n"
                    "the " progdir "-Directory from your\n"
                    "selected Path."))
      )
    )
    )
  )
)

(set device (getdevice progpath))
(set progpath (tackon progpath progdir))

(if (= (exists "Locale:" (noreq)) 2)
  (
    (set va "VideoArchiv_v2.0")
  )
  (
    (set va "VideoArchiv_v2.0_Kick13")
  )
)

(copyfiles (prompt "\nCopy Files... please wait.")
           (help @copyfiles-help)
           (source "")
           (dest progpath)
           (choices
             "VA_Data"
             "Formular.txt"
             "VA.config"
             "VA.dat"
             "VA.guide"
             va
           )
           (infos)
)
(if (= (exists "VideoArchiv.key") 1)
  (copyfiles (prompt "\nCopy Files... please wait.")
             (help @copyfiles-help)
             (source "")
             (dest progpath)
             (choices
               "VideoArchiv.key"
             )
  )
)
(rename (tackon progpath "VideoArchiv_v2.0_Kick13") (tackon progpath "VideoArchiv_v2.0")
  (prompt "")
)
(rename (tackon progpath "VideoArchiv_v2.0_Kick13.info") (tackon progpath "VideoArchiv_v2.0.info")
  (prompt "")
) 


(if (= (exists "Locale:" (noreq)) 2)
  (
    (set languages
      (askoptions
        (prompt "\nWhich languages should be installed?")
        (help   @askoptions-help)
        (choices
          "English"
          "Deutsch"
          "Français"
        )
        (default 1)
      )
    )
    (copylib
      (prompt "Copy Library...")
      (source (cat diskname ":Libs/Locale.library"))
      (dest "LIBS:")
    ) 
    (set n 0)
    (while
      (set language
        (select n
          "English"
          "Deutsch"
          "Français"
          ""
        )
      )
      (
        (if (IN languages n)
          (if (<> 0 n)   ; No catalog for english strings...
            (
              (set catalogs (tackon "Locale/Catalogs" language))
              (set destination (tackon "Locale:Catalogs" language))
              (makedir destination)
              (if (exists (tackon catalogs "VideoArchiv.catalog"))
                (copylib
                  (prompt "Copy Translations...")
                  (source (tackon catalogs "VideoArchiv.catalog"))
                  (dest destination)
                )
              )
            )
          )
        )
        (set n (+ n 1))
      )
    )
  )
) 

