;
; Garshneblanker Installation Script $VER:Garshneblanker 38.4 (18.10.94)
;

(set oldUserLevel (user 3))
(message
 "\nWelcome to the Garshneblanker 3.5 installer script.\n\n"
 "Follow the installer script's instructions to install Garshneblanker on your"
 "system. Once Garshneblanker is running, you can simply press the popup "
 "hotkey (which you'll specify later) to bring up its user interface. The "
 "rest will come naturally. :)\nIf you are already using Garshneblanker 3.0 "
 "or greater, this script will simply install the updated files."
 )
(user oldUserLevel)

(set @default-dest "SYS:WBStartup")
(set @default-popkey "Alt Help")
(set @default-blankkey "Alt Delete")
(set @default-timeout 180)

(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 "Garshneblanker")
(if (exists (tackon @default-dest "Blanker"))
	(set oldBlanker (tackon @default-dest "Blanker"))
	(set oldBlanker (tackon @default-dest "Garshneblanker")))

(set newBlankerVersion (getversion newBlanker))
(if (exists oldBlanker)
	(set oldBlankerVersion (getversion oldBlanker))
	(set oldBlankerVersion (+ (* 65536 37) 0)))

(set oldVer (/ oldBlankerVersion 65536))
(set oldRev (- oldBlankerVersion (* oldVer 65536)))

(set newVer (/ newBlankerVersion 65536))
(set newRev (- newBlankerVersion (* newVer 65536)))

(if (<= newBlankerVersion oldBlankerVersion)
	(if (NOT
		 (askbool
		  (prompt ("Version %ld.%ld of Garshneblanker already installed. Install version %ld.%ld?" oldVer oldRev newVer newRev))
		  (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 "Equal or newer version of Garshneblanker already installed. "
			   "Aborting.")
		)
	)

(delete oldBlanker)
(if (< oldVer 38) (delete (tackon oldBlanker ".info")))

(copylib (source "Libs/reqtools.library") (dest "LIBS:"))

(if (< (/ (getversion) 65536) 39)
 (copylib (source "Libs/V37/Garshnelib.library") (dest "LIBS:"))
 (copylib (source "Libs/V39/Garshnelib.library") (dest "LIBS:"))
 )

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

(if
 (< oldVer 38)
 ((select
   (askchoice
	(prompt "Which icon would you like to have installed for Garshneblanker?")
	(choices "Standard Workbench Icon" "Magic Workbench Icon")
	(help "The magic workbench icon is simply a larger, 8 color icon. The "
		  "standard icon follows Commodore's 4 color and size standard.")
	)
   (set @icon-choice "Garshneblanker_Std")
   (set @icon-choice "Garshneblanker.info")
   )
  
  (copyfiles
   (prompt ("Copying icon for %s" @default-dest))
   (help @copyfiles-help)
   (source @icon-choice)
   (dest @default-dest)
   )
  
  (if (= @icon-choice "Garshneblanker_Std")
	  ((rename (tackon @default-dest @icon-choice)
			  (tackon @default-dest "Garshneblanker.info"))
	   (delete (tackon @default-dest @icon-choice))))
  )
 )

(set @module-dest @default-dest)

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

(set blankersDir (tackon @module-dest "Blankers"))

(run ("Delete %s" (tackon blankersDir "~(#?.prefs)")))

(copyfiles
 (prompt ("Copying Garshneblanker modules to %s" @module-dest))
 (help @copyfiles-help)
 (source "")
 (choices "Blankers")
 (dest @module-dest)
 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "BLANKERDIR" (tackon @module-dest "Blankers"))
 (noposition)
 )

(set BlankKey
	 (askstring
	  (prompt "What key-combination would you like to use to tell "
			  "Garshneblanker to immediately blank the screen? (This key "
			  "combination can be used after Garshneblanker is running to "
			  "blank the screen.)")
	  (help "When you press this combination of keys, Garshneblanker will "
			"tell the current module to blank the screen. This is a standard "
			"Commodities key-combination. This key-combination should be a "
			"text string.\n\nExamples:\nAlt Help, Shift F1, Ctrl a")
	  (default "Alt Delete")
	  )
	 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "BLANKKEY" BlankKey)
 )

(set TimeOut
	 (asknumber
	  (prompt "How long should Garshneblanker wait before automatically "
			  "blanking the screen. (This value is in seconds.)")
	  (help "Garshneblanker will blank the screen if the number of seconds "
			"you specify pass without any user input occurring on your "
			"computer.")
	  (default 180)
	  )
	 )

(tooltype
 (dest (tackon @default-dest "Garshneblanker"))
 (settooltype "TIMEOUT" ("%ld" TimeOut))
 )

(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 is a standard Commodities key-combination. When you press "
			"this combination of keys, Garshneblanker will open up its "
			"preferences window so that you can modify its settings. This "
			"key-combination should be a text string.\n\nExamples:\nAlt Help, "
			"Shift F1, Ctrl a")
	  (default "Alt Help")
	  )
	 )

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

(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 popUpMsg "Garshneblanker will automatically bring up its interface after you have run it.")
  )
 (
  (set cxPopUp "NO")
  (set popUpMsg ("Garshneblanker will not automatically bring up its interface after you have run it. You will have to press the %s key-combination to make the interface come up." cxPopKey))
  )
 )

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

(set oldUserLevel (user 3))
(message
 ("\nGarshneblanker is now installed in your %s directory. You can run it by double clicking on its icon. %s\n\nIf you have any questions at all, feel free to contact me via e-mail at:\n\nmbayne@qualcomm.com" @default-dest popUpMsg)
 )
(user oldUserLevel)

(exit (quiet))
