; Installer for Electrostatic. V1.1.
; Copyright © 1999 Neil Cafferkey.
; $VER: "Install Electrostatic" 1.1 (17.6.99)


; Set constants

(set #kick-too-low-msg "Kickstart 3.0 or greater is required.")
(set #askdir-prompt
   "Where should %s be installed?\nA new drawer will be created there."
)
(set #dest-exists-msg "\"%s\" already exists.")
(set #ask-joyride-prompt
   (cat "Where do you want JoyRide, the joystick-handling Commodity,"
      " to be installed?"
   )
)
(set #ask-joyride-help
   (cat "If you select \"SYS:WBStartup\", JoyRide will always be running,"
      " but it may clash with other programs that use the joystick. If you"
      " select \"SYS:Tools/Commodities\", you'll have to manually start"
      " JoyRide before using a game translated by Electrostatic. Select"
      " \"Nowhere\" if JoyRide is already installed."
   )
)
(set #joyride-choice-0 "SYS:WBStartup")
(set #joyride-choice-1 "SYS:Tools/Commodities")
(set #joyride-choice-2 "Nowhere")

; Check Kickstart version

(if (< (/ (getversion) 65536) 39)
   (abort #kick-too-low-msg)
)


; Ask where to install to

(set #default-dest
   (tackon
      (askdir
         (prompt (#askdir-prompt @app-name))
         (default @default-dest)
         (help @askdir-help)
         (disk)
      )
      @app-name
   )
)

(set @default-dest #default-dest)


; Check that destination directory doesn't already exist and create it

(if (OR (exists @default-dest) (exists (cat @default-dest ".info")))
   (abort (#dest-exists-msg @default-dest))
   (
      (makedir @default-dest (infos))
      (onerror
         (run
            ("Delete \"%s\" \"%s\" ALL FORCE"
               @default-dest (cat @default-dest ".info")
            )
         )
      )
   )
)


; Copy program files to destination directory

(copyfiles
   (source "hidden")
   (dest @default-dest)
   (pattern "~(JoyRide#?)")
   (infos)
   (help @copyfiles-help)
)


; Copy manual to destination directory

(copyfiles
   (source "Manual")
   (dest @default-dest)
   (infos)
   (help @copyfiles-help)
)


; Copy Okie Dokie to destination directory

(copyfiles
   (source "")
   (dest @default-dest)
   (pattern "Okie Dokie")
   (infos)
   (help @copyfiles-help)
)


; Install the Atari 2600 library

(copylib
   (source "atari2600.library")
   (dest "LIBS:")
)


; Ask where the user wants to put JoyRide

(select
   (askchoice
      (prompt #ask-joyride-prompt)
      (choices #joyride-choice-0 #joyride-choice-1 #joyride-choice-2)
      (help #ask-joyride-help)
   )
   (copylib (source "hidden/JoyRide") (dest "SYS:WBStartup") (infos))
   (copylib (source "hidden/JoyRide") (dest "SYS:Tools/Commodities") (infos))
   0
)


