; 
; ====================
; PERFORMANCE SOFTWARE
; ====================
; 
; GRAAL 2.0 Beta Installer Script
; (c) 1996 Per Thulin
; 
(welcome)

; Set up some variables
; 
(set #diskname_a "GRAAL 2.0 - Disk A")
(set #diskname_b "GRAAL 2.0 - Disk B")
(set #diskname_c "GRAAL 2.0 - Disk C")
(set #source_a (cat #diskname_a ":"))
(set #source_b (cat #diskname_b ":"))
(set #source_c (cat #diskname_c ":"))
(set #diskprompt_a (cat "Please insert disk " #diskname_a))
(set #diskprompt_b (cat "Please insert disk " #diskname_b))
(set #diskprompt_c (cat "Please insert disk " #diskname_c))
(set #helpdisk
  (cat
    "The installation procedure requires the disks to be named exactly"
    " as requested. If you have created the disks from the Aminet archives,"
    " just rename them properly before running the installer."
    )
  )

(select
  (askchoice
    (prompt "Please select the type of installation you want to perform:")
    (help
      (cat "Install the GRAAL 2.0 system:\n\n"
        "Choose this if you have not installed or used GRAAL before,"
        " or if you want to install the new demo adventure.\n\n"
        "Update a development drawer:\n\n"
        "Choose this if you just want to update the GRAAL tools and"
        " documentation in an existing directory, without harming the rest"
        " of its contents."
        ) ; end cat
      ) ; end help
    (choices
      "Install the GRAAL 2.0 system"
      "Update a development drawer"
      ) ; end choices
    (default 0)
    ) ; end askdir

  ( ; Installation sequence
    (complete 5)
    (set #instoptions
      (askoptions
        (prompt "Please select the parts you wish to install:")
        (help
          (cat
            "All selected parts will be copied to the same (new)"
            " hard disk drawer.\n\n"
            "Demo Adventure:\n\n"
            "This installs the graal driver program and all files"
            " necessary to run the demo adventure.\n\n"
            "Developer files:\n\n"
            "This installs all programs and documentation necessary"
            " to develop GRAAL adventures.\n\n"
            "Tutorial\n\n"
            "This installs the beginner's tutorial. Experienced GRAAL 1.0"
            " and 1.2 users will perhaps not need this edition:"
            ) ; end cat
          ) ; end help
          (choices
            "Demo adventure"
            "Developer files"
            "Tutorial"
            ) ; end choices
        ) ; end askoptions
      ) ; end set #instoptions
    ; 
    ; Set the installation directory
    ; 
    (complete 10)
    (set #instdir
      (askdir
        (prompt
          (cat
            "Please select the place where GRAAL should be installed."
            " A new drawer called GRAAL_2 will be created in the chosen"
            " location."
            ) ; end cat
          ) ; end prompt
        (help
          (cat
            "You do not need to make any assigns to use GRAAL. However,"
            " keeping the GRAAL tools and the adventure script files in"
            " the same drawer is important.)"
            ) ; end cat
          ) ; end help
        (default @default-dest)
        ) ; end askdir
      ) ; end set #instdir
    ; 
    ; Check if drawer needs to be created
    ; 
    (complete 15)
    (set #instdir (tackon #instdir "GRAAL_2"))
    (set @default-dest #instdir)
    (if (not (exists #instdir))
      (makedir #instdir (infos))
      ) ; end if
    ; 
    ; Check if we should install demo files
    ; 
    (if (in #instoptions 0)
      ( ; demo installation sequence
        (askdisk
          (prompt #diskprompt_a)
          (help #helpdisk)
          (dest #diskname_a)
          ) ; end askdisk
        (copyfiles
          (source #source_a)
          (dest #instdir)
          (all)
          (infos)
          ) ; end copyfiles
        (askdisk
          (prompt #diskprompt_b)
          (help #helpdisk)
          (dest #diskname_b)
          ) ; end askdisk
        (copyfiles
          (source #source_b)
          (dest #instdir)
          (all)
          (infos)
          ) ; end copyfiles
        (if (not (in #instoptions 1))
          (delete (tackon #instdir "gpro") (infos))
          ) ; endif
        ) ; end demo installation sequence
      ) ; end if
    ; 
    ; Check if we should install developer files
    ; 
    (complete 50)
    (if (in #instoptions 1)
      ( ; developer installation sequence
        ; check if GRAAL_2 has been copied already
        (if (not (exists (tackon #instdir "GRAAL_2")))
          ( ; install driver
            (askdisk
              (prompt #diskprompt_a)
              (help #helpdisk)
              (dest #diskname_a)
              ) ; end askdisk
            (copyfiles
              (source #source_a)
              (dest #instdir)
              (choices "GRAAL_2")
              (infos)
              ) ; end copyfiles
            ) ; end install driver
          ) ; end if
        (if (not (exists (tackon #instdir "gpro")))
          ; check if gpro has been copied already
          ( ; install gpro
            (askdisk
              (prompt #diskprompt_b)
              (help #helpdisk)
              (dest #diskname_b)
              ) ; end askdisk
            (copyfiles
              (source #source_b)
              (dest #instdir)
              (pattern "gpro")
              (infos)
              ) ; end copyfiles
            ) ; end install gpro
          ) ; end if
        (askdisk
          (prompt #diskprompt_c)
          (help #helpdisk)
          (dest #diskname_c)
          ) ; end askdisk
        (copyfiles
          (source #source_c)
          (dest #instdir)
          (choices
            "GRAAL_Editor"
            "gdc"
            "GRAAL.guide"
            "GRAAL_2.readme"
            "Prod.text"
            "Editor.text"
            ) ; end choices
          (infos)
          ) ; end copyfiles
        ) ; end developer installation sequence
      ) ; end if
    ; 
    ; Check if we should install tutorial
    ; 
    (complete 90)
    (if (in #instoptions 2)
      ( ; tutorial installation sequence
        (askdisk
          (prompt #diskprompt_c)
          (help #helpdisk)
          (dest #diskname_c)
          ) ; end askdisk
        (copyfiles
          (source #source_c)
          (dest #instdir)
          (choices "GRAAL_Tutorial.text")
          (infos)
          ) ; end copyfiles
        ) ; end tutorial installation sequence
      ) ; end if

    ) ; end of installation sequence

  ( ; Update sequence
    (complete 5)
    (set #instdir
      (askdir
        (prompt
          (cat
            "Please point to the development directory to be updated with"
            " the new GRAAL tools and documentation."
            ) ; end cat
          ) ; end prompt
        (help
          (cat
            "All old GRAAL tools and documentation files will be removed"
            " and replaced with the new versions. However, renamed copies of"
            " GRAAL_Dev or GRAAL_Run will NOT be handled automatically."
            " When the installation has finished, you must deal with them"
            " and rename the GRAAL_2 file to your liking manually."
            ) ; end cat
          ) ; end help
        (default @default-dest)
        ) ; end askdir
      ) ; end set #instdir
    (set @default-dest #instdir)
    (complete 10)
    (delete (tackon #instdir "GRAAL_Run") (infos))
    (delete (tackon #instdir "GRAAL_Dev") (infos))
    (delete (tackon #instdir "GRAAL_Tutorial.text") (infos))
    (delete (tackon #instdir "GRAAL_Editor") (infos))
    (delete (tackon #instdir "Editor.text") (infos))
    (delete (tackon #instdir "GRAAL.guide") (infos))
    ( ; developer installation sequence
      (askdisk
        (prompt #diskprompt_a)
        (help #helpdisk)
        (dest #diskname_a)
        ) ; end askdisk
      (copyfiles
        (source #source_a)
        (dest #instdir)
        (choices "GRAAL_2")
        (infos)
        ) ; end copyfiles
      (complete 20)
      (askdisk
        (prompt #diskprompt_b)
        (help #helpdisk)
        (dest #diskname_b)
        ) ; end askdisk
      (copyfiles
        (source #source_b)
        (dest #instdir)
        (pattern "gpro")
        (infos)
        ) ; end copyfiles
      (complete 30)
      (askdisk
        (prompt #diskprompt_c)
        (help #helpdisk)
        (dest #diskname_c)
        ) ; end askdisk
      (copyfiles
        (source #source_c)
        (dest #instdir)
        (all)
        (infos)
        ) ; end copyfiles
      ) ; end developer installation sequence
    ) ; end of update sequence

  ) ; end select

(complete 100)
