; Emerald Mine install script for AGA
; $VER: Install-EmeraldMine-AGA 1.0
;
; v1.00 RIS 21-04-95 1st version

(set expert_user_level 2)
(set orig_user_level @user-level)
(set app_disk1 "V6a")
(set app_disk2 "V6b")
(set app_volume1 (cat app_disk1 ":"))
(set app_volume2 (cat app_disk2 ":"))

; standard amiga error codes
(set RC_OK     0
     RC_WARN   5
     RC_ERROR 10
     RC_FATAL 20
     )

;--------------------------------------------------------------------
; sub-routine to install script
;--------------------------------------------------------------------
(procedure do_libs
    (set lib_error
        (run ("version >nil: iff.library 23")))
    (if (> lib_error RC_OK)
        (
           (copyfiles
           (source  (cat app_volume2 "libs"))
           (dest    "libs:")
           (choices "iff.library")
           (help @copyfiles-help)
           (infos))
        )
    )
    (complete 85)
    (set lib_error
        (run ("version >nil: asl.library 39")))
    (if (> lib_error RC_OK)
        (
           (copyfiles
           (source  (cat app_volume2 "libs"))
           (dest    "libs:")
           (choices "asl.library")
           (help @copyfiles-help)
           (infos))
        )
    )
    (complete 90)
    (set lib_error
        (run ("version >nil: powerpacker.library 35")))
    (if (> lib_error RC_OK)
        (
           (copyfiles
           (source  (cat app_volume2 "libs"))
           (dest    "libs:")
           (choices "powerpacker.library")
           (help @copyfiles-help)
           (infos))
        )
    )
    (complete 95)
    (set lib_error
        (run ("version >nil: req.library 2")))
    (if (> lib_error RC_OK)
        (
           (copyfiles
           (source  (cat app_volume2 "libs"))
           (dest    "libs:")
           (choices "req.library")
           (help @copyfiles-help)
           (infos))
        )
    )
)

;--------------------------------------------------------------------
; sub-routine to install script
;--------------------------------------------------------------------
(procedure setup_hd_install
   (message
      "\nYour copy of Emerald Mine will be installed in a new drawer named "
      "\"EM\". You will be asked where on your hard drive (or "
      "storage device) you want this drawer created.\n\n"

      "You must have booted from your HardDisk for this script to work "
      "properly. Type \"V6b:Install\" to install Emerald Mine.\n\n")

   (set app_locate
      (askdir
         (prompt "Please indicate where you want the Emerald Mine drawer "
                 "to be located.")
         (help @askdir-help)
         (default @default-dest)
         ))

   (set app_path (tackon app_locate "EM"))
   (makedir app_path (infos))
)

; --------------------------------------------------------------------
; do_exit
; --------------------------------------------------------------------
(procedure do_exit
   (startup @app-name
      (prompt "\nAdd Emerald Mine to your path in s:user-startup?")
      (help   "To allow all programs to be accessed while you work in another "
              "directory, the programs must be somewhere in your PATH so "
              "your Amiga can find them. To do this, the following statement "
              "will be added: \nPath WORK:EM Add.\n\n"
               @startup-help
      )
      (command ("Path \"%s\" Add" app_path))
   )
   (complete 100)
   (exit)
)

;--------------------------------------------------------------------
; Real install program
;--------------------------------------------------------------------
(user expert_user_level)
(setup_hd_install)
(complete 5)
(set program_options
    (askoptions
       (prompt "Which applications do you wish to install?")
       (choices "Game" "Editor" "Tools")
       (help  " Game   -- installs the Emerald MineGame\n"
              " Editor -- installs the Emerald MineEditor\n"
              " Tools  -- installs various Emerald Mine Tools\n\n"
              @askoptions-help)
    )
)
(if (bitand 1 program_options)
    (
       (message ("\nMake sure disk \"%s\" is available in any drive\n" app_volume1))
       (copyfiles
           (source  app_volume1)
           (dest    app_path)
           (choices "AGAGame" "Gfx-AGA" "Cave" "High" "Names")
           (help    @copyfiles-help)
           (infos)
       )
    )
)
(complete 33)

(if (bitand 2 program_options)
    (
       (if (bitand 1 program_options)
          (copyfiles
              (source  app_volume1)
              (dest    app_path)
              (choices "AGAMine" "AGAShow")
              (help    @copyfiles-help)
              (infos)
          )
          (
             (message ("\nMake sure disk \"%s\" is available in any drive\n" app_volume1))
             (copyfiles
                (source  app_volume1)
                (dest    app_path)
                (choices "AGAMine" "AGAShow" "Names" "Cave" "High")
                (help    @copyfiles-help)
                (infos)
             )
          )
       )
    )
)
(complete 66)

(if (bitand 4 program_options)
    (
       (message ("\nMake sure disk \"%s\" is available in any drive\n" app_volume2))
       (copyfiles
           (source  (cat app_volume2 "c"))
           (dest    app_path)
           (choices "AddPic2Game" "ClearCaves" "ClearHigh" "GameName" "GfxEd-AGA" "NamesEd" "RecoverEMcaves" "TimeDouble" "V5_to_V6")
           (help    @copyfiles-help)
           (infos)
       )
       (complete 70)
       (copyfiles
           (source  app_volume2)
           (dest    app_path)
           (choices "DOX" "IFF")
           (help    @copyfiles-help)
           (infos)
       )
       (complete 80)
       (do_libs)
    )
)
(complete 99)
(user orig_user_level)
(do_exit)
