;
; Garshneblanker Installation Script $VER:Garshneblanker 37.4 (31.10.93)
;

(set @default-dest "SYS:WBStartup")
(set @pref-dest "SYS:Prefs")
(set @envarc-dest "ENVARC:")
(set @env-dest "ENV:")
(set installReqTools 1)

(set @default-dest
 (askdir
  (prompt "Where would you like Garshneblanker installed?")
  (help "The WBStartup directory on your boot disk is likely the best place "
   "to put blanker. This will insure that Garshneblanker is run "
   "automatically when you boot your computer."
   )
  (default @default-dest)
  )
 )

(working "Checking for previously installed version of Garshneblanker.")

(set newBlanker (tackon (pathonly @icon) "Garshneblanker"))
(if (exists (tackon @default-dest "Blanker"))
 (set oldBlanker (tackon @default-dest "Blanker"))
 (set oldBlanker (tackon @default-dest "Garshneblanker"))
 )

(if (<= (getversion newBlanker) (getversion oldBlanker))
 (if
  (NOT
   (askbool
    (prompt "An equal or newer version of Garshneblanker already installed. "
     "Install anyway?")
    (default 0)
    (help "An equal or newer version of Garshneblanker is already installed. "
     "If you would like to install Garshneblanker anyhow, click 'Yes'. "
     "If you don't want to install Garshneblanker, click 'No'.")
    )
   )
  (abort "Newer version of Garshneblanker already installed. Aborting.")
  )
 )

(delete oldBlanker)
(delete (tackon oldBlanker ".info"))

(copyfiles
 (prompt ("Copying Garshneblanker to %s" @default-dest))
 (help @copyfiles-help)
 (source (pathonly @icon))
 (dest @default-dest)
 (choices "Garshneblanker")
 (infos)
 )

(set @module-dest @default-dest)

(set @module-dest
 (askdir
  (prompt "Where would you like the Garshneblanker modules installed?")
  (help "You can put the blankers anywhere and Garshneblanker will look for "
   "them there.")
  (default @module-dest)
  )
 )

(if
 (askbool
  (prompt "Would you like to install the 68030 optimized modules?")
  (help "The 68030 modules can ONLY be run on machines with a 68030 processor "
   "or higher.")
  (default 0)
  )
 (set @blanker-choice "Blankers030")
 (set @blanker-choice "Blankers")
 )

(set blankersDir (tackon @module-dest @blanker-choice))
(if (exists blankersDir)
 (run "Delete" (tackon blankersDir "#?") "QUIET" "FORCE")
 )

(copyfiles
 (prompt ("Copying Garshneblanker modules to %s" @module-dest))
 (help @copyfiles-help)
 (source (pathonly @icon))
 (dest @module-dest)
 (choices @blanker-choice)
 )

(if
 (askbool
  (prompt "Would you like Garshneblanker to open its window on startup?")
  (help "This will set the CX_POPUP tooltype to YES or NO depending on your"
   "response. This tooltype dictates whether or not Garshneblanker opens it's"
   "window when it first runs.")
  (default 1)
  )
 (set cxPopUp "YES")
 (set cxPopUp "NO")
 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "CX_POPUP" cxPopUp)
 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "BLANKERDIR" (tackon @module-dest @blanker-choice))
 )

(set cxPopKey
 (askstring
  (prompt "What key-combination shall Garshneblanker use to pop up it's "
   "interface? (This key combination can be used after Garshneblanker is "
   "running to bring it's window to front.")
  (help "This key-combination should be a text string. Examples:\n"
   "Alt Help\nShift F1\nCtrl a")
  (default "Alt Help")
  )
 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "CX_POPKEY" cxPopKey)
 )

(makedir "SYS:Prefs/Presets/Garshneblanker" (infos))

(if (NOT (exists "ENVARC:sys/def_pref.info" (noreq)))
 ((copyfiles
   (source (tackon (pathonly @icon) "env-archive"))
   (dest @envarc-dest)
   (choices "sys")
   )
  (copyfiles
   (source (tackon (pathonly @icon) "env-archive"))
   (dest @env-dest)
   (choices "sys")
   )
  )
 )

(copyfiles
 (source (tackon (pathonly @icon) "env-archive"))
 (dest @envarc-dest)
 (choices "Garshneblanker.prefs")
 (infos)
 )

(copyfiles
 (source (tackon (pathonly @icon) "env-archive"))
 (dest @env-dest)
 (choices "Garshneblanker.prefs")
 (infos)
 )

(working "Checking for previously installed version of ReqTools.")

(set oldReqTools "LIBS:reqtools.library")
(set newReqTools (tackon (pathonly @icon) "ReqTools/reqtools.library"))

(if (<= (getversion newReqTools) (getversion oldReqTools))
 (if
  (askbool
   (prompt "An equal or newer version of ReqTools already installed. "
    "Install anyway?"
    )
   (default 0)
   (help "An equal or newer version of ReqTools is already installed. "
    "If you would like to install ReqTools anyhow, click 'Yes'. "
    "If you don't want to install ReqTools, click 'No'."
    )
   )
  (set installReqTools 1)
  (set installReqTools 0)
  )
 )

(if (= 1 installReqTools)
 (copyfiles
  (prompt "Copying ReqTools library to LIBS:")
  (source (tackon (pathonly @icon) "ReqTools/reqtools.library"))
  (dest "LIBS:")
  )
 (if (< @user-level 1)
  ((set temp @user-level)
   (user 2)
   (message "Not installing reqtools.library because an equal or newer version is already installed.")
   (user temp)
   )
  )
 )

(if (= 1 installReqTools)
 (copyfiles
  (prompt "Copying ReqTools preferences editor to SYS:Prefs")
  (source (tackon (tackon (pathonly @icon) "ReqTools") "ReqTools"))
  (dest "SYS:Prefs")
  (infos)
  )
 )
