; Installation script for AmiMDC800 1.0+ ©1999 by Frank Fenn

(effect "lower_right" "radial" $00FFFF $0000FF)

(set @app-name "AmiMDC800")
(set #def_lang_English 0)
(set #def_lang_Deutsch 1)

(set #nomui (cat "\n\nAmiMDC800 uses Magic User Interface (MUI).\n\nThe installer has not found MUI: to be assigned, "
                 "therefore AmiMDC800 will not work.\nYou will need to install MUI before running AmiMDC800."
            )
)

(showmedia 'runningpic' 'images/800_logo.image' 'upper_left' 'none' 0)

; English is the default language 

    (set #Welcome
      (cat "   Welcome to the Amiga Mustek MDC800 installation\n\n"
           "         Copyright 1999-2000 by Frank Fenn\n"
      )
    )

    (set #WhatCatalog
      (cat "Which catalog file do you want to install?\n"
           "(English language is built-in)"))

    (set #WhatDir
      (cat "Choose AmiMDC800 home directory\n"
           "(NO extra drawer will be created!)"))

    (set #WhatInstall "What do you want to install?")
    (set #WhatDevice  "Which serial device do you want to use?")
    (set #WhatUnit    "Which serial unit do you want to use?")
    (set #WhatBaud    "Which baud rate do you want to use?")
    (set #WhatAuto    "Do you want an automatic init of the camera?")

    (set #AlreadyInstalled1 " is already installed\n\n")
    (set #AlreadyInstalled2 " is the installed version\n\n")
    (set #AlreadyInstalled3 " should be copied")

    (set #SerDec1     "serial.device")
    (set #SerDec2     "ioblixser.device")

    (set #IProg       "AmiMDC800 program")
    (set #IGuide      "AmiMDC800 guide")
    (set #IMUI        "MUI custom classes")

    (set #CopyProg    "\nCopying program files to %s.")
    (set #CopyDocs    "\nCopying guide files")
    (set #CopyMUI     "\nCopying MUI classes")

    (set #DocDir      "Select the directory where you want to put\nthe guide file.")
    (set #DocDirHelp  "This should be the directory where you normally put your guides.\n\n")
    (set #CopyGuide   "\nCopying AmiMDC800.guide to ")

    (set #Yes         "Yes")
    (set #No          "No")

(welcome #Welcome)

(if (< (exists "mui:" (noreq)) 2)
  (
    (message #nomui)
    (abort "\n\nPlease install MUI and restart this installation")
  )
)

(set Catalog_lang
   (askoptions
      (prompt  #WhatCatalog)
      (help    @askoptions-help)
      (choices "Deutsch")
      (default #def_cat_lang)
   )
)

(if (= 0 @user-level)
  (set install_level %000111)
  (set install_level (askoptions
                        (prompt #WhatInstall)
                        (help   @askoptions-help)
                        (choices #IProg #IGuide #IMUI)
                     )
  )
)

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

(user my_level)

(set copy_prog   (BITAND %000001 install_level))
(set copy_guide  (BITAND %000010 install_level))
(set copy_mui    (BITAND %000100 install_level))

(complete 0)

(if copy_prog
  (
    (set mdc800dest
      (askdir (prompt #WhatDir)
              (help   @askdir-help)
              (default @default-dest)
              (disk)
      )
    )
  )
)

(if copy_guide
  (
    (set guidedest
      (askdir (prompt #DocDir)
              (help   @askdir-help)
              (default mdc800dest)
              (disk)
      )
    )
  )
)

(set devicename
  (askstring (prompt #WhatDevice)
             (help   @askstring-help)
             (default "serial.device")
  )
)

(set unit
  (askchoice
    (prompt #WhatUnit)
    (help   @askchoice-help)
    (choices "0" "1" "2" "3")
    (default 0)
  )
)

(set baud
  (askchoice
    (prompt #WhatBaud)
    (help   @askchoice-help)
    (choices "19200" "57600" "115200")
    (default 1)
  )
)

(set autoinit
  (askchoice
    (prompt #WhatAuto)
    (help   @askchoice-help)
    (choices "Yes" "No")
    (default 0)
  )
)

(if copy_prog
  (
    (set @default-dest mdc800dest)
    (set mdc800tacked (tackon mdc800dest "AmiMDC800"))

    (copyfiles (prompt (#CopyProg mdc800dest))
               (help     def_help @copyfiles-help)
               (choices  "AmiMDC800" "AmiMDC800.info")
               (source   "")
               (dest     mdc800dest)
    )

    (set icon (tackon mdc800dest "AmiMDC800"))

    (tooltype (dest icon)
              (settooltype "DEVICE"   devicename)
              (settooltype "UNIT"   ("%ld" unit))
              (settooltype "BAUD"     (select baud
                                        "19200"
                                        "57600"
                                        "115200"
                                      ))
              (settooltype "AUTOINIT" (select autoinit
                                        "YES"
                                        "NO"
                                      ))
    )

    (complete 35)

    (set #imagedir (tackon mdc800dest "images"))
    (makedir #imagedir)

    (copyfiles (prompt (#CopyProg mdc800dest))
               (help     def_help @copyfiles-help)
               (pattern  "#?.image")
               (source   "images")
               (dest     #imagedir)
    )

  )
)

(showmedia 'runningpic' 'images/800_program' 'upper_left' 'none' 0)

(complete 50)

(if (> Catalog_lang 0)
  (
    (set Cat_dir "LOCALE:catalogs")
    (if (bitand Catalog_lang #def_lang_Deutsch)
      (
        (set lang "deutsch")
        (copyfiles (source (tackon "catalogs" lang))
                   (choices "amimdc800.catalog")
                   (dest (tackon Cat_dir lang))
        )
      )
    )
  )
)

(complete 70)

(if copy_guide
  (
    (set @default-dest guidedest)
    (set guidetacked (tackon guidedest "AmiMDC800"))

    (copyfiles (prompt (#CopyProg mdc800dest))
               (help     def_help @copyfiles-help)
               (pattern  "AmiMDC800.guide#?")
               (source   "")
               (dest     guidedest)
    )
  )
)

(complete 90)

(if (<> (getassign "mui") "")
  (
    (if (> (exists "mui:libs/mui") 0)
      (
        (set mui_localdir "libs/MUI")

        (foreach mui_localdir "#?.mcp"
          (copylib (source (tackon mui_localdir @each-name)) (dest "mui:libs/mui") (optional "nofail"))
          (copylib (source (tackon mui_localdir @each-name)) (dest "mui:libs/mui") (optional "nofail"))
        )

        (foreach mui_localdir "#?.mcc"
          (copylib (source (tackon mui_localdir @each-name)) (dest "mui:libs/mui") (optional "nofail")) 
          (copylib (source (tackon mui_localdir @each-name)) (dest "mui:libs/mui") (optional "nofail")) 
        )
      )
    )
  )
)

(complete 100)
