;
; Garshneblanker Installation Script $VER:Garshneblanker 38.3 (28.6.94)
;

(set oldUserLevel (user 3))
(message
 "\nWelcome to the Garshneblanker 3.3 installer script.\n\n"
 "This version of Garshneblanker is SO easy to use that there is NO documentation. Simply follow "
 "the installer script's instructions and the rest is intuitive. Once Garshneblanker is running, "
 "you can simply press the popup hotkey (which you'll specify later) to bring up its new "
 "intuitive 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 "Workbench:WBStartup")
(set @default-popkey "Alt Help")
(set @default-blankkey "Alt Delete")
(set @default-timeout 180)
(set @from "SYS:")
(set @libs "SYS:libs/")
(set @gb "SYS:")
(set @bl "SYS:blankers/")

(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 (tackon @libs "Garshnelib.library"))
 (dest (tackon @default-dest "libs"))
 )
(Complete 40)

(copylib
 (source (tackon @libs "reqtools.library"))
 (dest (tackon @default-dest "libs"))
 )
(Complete 50)


(copyfiles
 (prompt ("Copying Garshneblanker to %s" @default-dest))
 (help @copyfiles-help)
 (source (tackon @gb "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_Magic")
   )
  
  (copyfiles
   (prompt ("Copying icon for %s" @default-dest))
   (help @copyfiles-help)
   (source @icon-choice)
   (dest @default-dest)
   )
  
  (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"))

(copyfiles
 (prompt ("Copying Garshneblanker modules to %s" @module-dest))
 (help @copyfiles-help)
 (source @bl)
 (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))
