(transcript "Installing DreamTerm...")

(set @default-dest "SYS:")

(set #bad_kick "You must be using KickStart 3.0+ to use DreamTerm!")
(set #dterm13_msg
(cat "\nConfig file format changed after 1.3 and support for "
     "automatic conversion is now removed. You should delete DT_current & "
     "DT_config files and reconfigure everything."
))

;----------------------------------------------------------------------------

; Running under V39?

(if (< (/ (getversion) 65536) 39)
  (
    (abort #bad_kick)
  )
)

; Copy program files & documentation etc...

(set destination
  (askdir
    (prompt "Please select a place for the DreamTerm. A sub drawer called \"DreamTerm\" will be created here.")
    (help @askdir-help)
    (default "SYS:")
    (newpath)
  )
)

(set @default-dest (tackon destination "DreamTerm"))

(makedir destination)
(makedir (tackon destination "DreamTerm"))
(makedir (tackon destination "DreamTerm/Character sets"))
(makedir (tackon destination "DreamTerm/Conversion tables"))
(makedir (tackon destination "DreamTerm/Phonebooks"))
(makedir (tackon destination "DreamTerm/Protocols"))
(makedir "FONTS:Antique")
(makedir "FONTS:DT_IBM01")
(makedir "FONTS:DT_IBM02")
(makedir "LIBS:compressors")

(copyfiles
  (source "BugReport.txt")
  (dest (tackon destination "DreamTerm"))
  (infos)
)

(copyfiles
  (source "DreamTerm")
  (dest (tackon destination "DreamTerm"))
  (infos)
)

(copyfiles
  (source "DreamTerm.guide")
  (dest (tackon destination "DreamTerm"))
  (infos)
)

(copyfiles
  (source "Help.guide")
  (dest (tackon destination "DreamTerm"))
  (infos)
)

(copyfiles
  (source "ReadMe.txt")
  (dest (tackon destination "DreamTerm"))
  (infos)
)

(copyfiles
  (source "PhoneBooks/NewUser.pb")
  (dest (tackon destination "DreamTerm/PhoneBooks"))
)

(copyfiles
  (source "FONTS/Antique.font")
  (dest   "FONTS:")
)
(copyfiles
  (source "FONTS/DT_IBM01.font")
  (dest   "FONTS:")
)
(copyfiles
  (source "FONTS/DT_IBM02.font")
  (dest   "FONTS:")
)
(copyfiles
  (source "FONTS/Antique/8")
  (dest   "FONTS:Antique")
)
(copyfiles
  (source "FONTS/DT_IBM01/8")
  (dest   "FONTS:DT_IBM01")
)
(copyfiles
  (source "FONTS/DT_IBM02/8")
  (dest   "FONTS:DT_IBM02")
)

(copyfiles
  (source "Conversion tables/ISO->ISO_capture.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)
(copyfiles
  (source "Conversion tables/ISO->SF7.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)
(copyfiles
  (source "Conversion tables/ISO->SF8.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)
(copyfiles
  (source "Conversion tables/NoConversion.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)
(copyfiles
  (source "Conversion tables/SF8->ISO.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)
(copyfiles
  (source "Conversion tables/SF8->ISO_capture.ct")
  (dest (tackon destination "DreamTerm/Conversion tables"))
)

(complete 33)

; Copy libraries

(foreach "LIBS" "#?.library"
  (copylib
    (prompt "Installing library: " @each-name)
    (source (tackon "LIBS" @each-name))
    (help @copylib-help)
    (dest "LIBS:")
    (confirm)
  )
)

(foreach "LIBS/compressors" "#?.library"
  (copylib
    (prompt "Installing library: " @each-name)
    (source (tackon "LIBS/compressors" @each-name))
    (help @copylib-help)
    (dest "LIBS:compressors")
    (confirm)
  )
)

(complete 66)

; Copy config files

(if (askbool (help @askbool-help) (prompt "Do you want to install default config files? This will override your old settings! However default phonebook and droplist will be left alone."))

  (foreach "" "DT_config.#?"
    (copyfiles
      (prompt "Installing configuration files...")
      (source (tackon "" @each-name))
      (help @copyfiles-help)
      (dest (tackon destination "DreamTerm"))
    )
  )
)

(complete 99)

(if (exists (tackon destination "DreamTerm/DT_config")) (message #dterm13_msg) )

(complete 100)

(exit "Done! Just run and fun...")
