(set vernum (getversion))
(set ver (/ vernum 65536))
(set rev (- vernum (* ver 65536) ) )

(if (< ver 36)
   (
   (message
      "Due to restrictions with Installer and Workbench 1.3, "
      "you will need to execute the script \"GDS_Install1.3\" "
      "in order to install GameSmith.  This script is located "
      "on the \"GDS System:\" diskette.\n\n"
      "Before executing this script, make sure you first assign "
      "\"GameSmith:\" to the directory where you would "
      "like the GameSmith Development System installed."
   )
   (exit (quiet))
   )
)

(copyfiles
	(source "GDS_System:lha")
	(dest "t:")
)

(copyfiles
	(source "GDS_System:Devpac_GS.lha")
	(dest "t:")
)


(set @execute-dir "t:")

(until continue
	(set GDS_path
		(askdir
		(prompt "Where should the GameSmith system be installed?")
			(help "The installation utility will create a new directory called "
				"\"GameSmith\" under the specified device or directory.  All GameSmith "
				"files will be copied to this new directory.\n\n")
			(default @default-dest)
		)
	)
	(set continue
		(askbool
			(prompt"The GameSmith Development System will be installed to\n\n"
			(tackon GDS_path "GameSmith")"\n\n"
			"The install process may take some time to unpack the GameSmith "
			"archives.  Please be patient.")
			(help "All GameSmith files will be copied to " (tackon GDS_path "GameSmith")
			". If the directory does not exist, it will be created.\n\n"
			"To change your directory selection, click on NO.  To proceed "
			"with the installation, select OK.")
			(choices "OK, let's install." "NO!  Go back!")
		)
	)
)

(set GDS_dir (tackon GDS_path "GameSmith"))

(if (NOT (exists GDS_dir))
	(makedir GDS_dir (infos))
)

(set @default-dest GDS_dir)

(if (NOT @pretend)
   (
	(makeassign "GameSmith" GDS_dir)
   (working "Unpacking System Files...")
	(run "lha x -q \"GDS_System:GDS_System.lha\" GameSmith:")
   )
)

(set @execute-dir "t:")

(set tut (askbool
	(prompt
	"Do you want to install the GameSmith Tutorial "
	"and Examples contained on Disk 2?")
	(help " ")
	(choices "Yes" "No")
))
(if tut
	(	 
		(askdisk
			(dest "GDS_Tutorial")
			(prompt "Please Insert the Disk Labeled \"GDS_Tutorial\" Into Any Drive.")
			(help " ")
		)
	
   		(if (NOT @pretend)
      		(
      			(working "Unpacking GDS Tutorial Disk...")
   				(run "lha x -q \"GDS_Tutorial:GDS_tutorial.lha\" GameSmith:")
      		)
   		)
	)
)

(set dice (askbool
	(prompt
	"DICE GS is a special version of the DICE C Compiler and development "
	"system from Obvious Implementations INC. provided for GameSmith owners. "
	"Full installation will require additional steps detailed within the DICE GS " 
	"documentation\n\n"
	"Do you want to install DICE GS?")
	(help "DICE GS is a special version of the DICE C Compiler and development "
	"system from Obvious Implementations INC. provided for GameSmith owners. "
	"A special price on the full commercial verison is available to GameSmith owners. "
	"Please contact Obvious Implementations for more information")
	(choices "Yes" "No")
))
(if dice
	(	 
		(askdisk
			(dest "GDS_Tutorial")
			(prompt "Please Insert the Disk Labeled \"GDS_Tutorial\" Into Any Drive.")
			(help " ")
		)
   		(if (NOT @pretend)
      		(
      			(working "Unpacking DICE GS...")
   				(run "lha x -q \"GDS_Tutorial:DICE_GS.lha\" GameSmith:")
      		)
   		)
	)
)
	

(set dpgs (askbool
	(prompt
	"Devpac GS is a special version of the Devpac 3 680x0 Assembly language "
	"development system from HiSoft and Oregon Research provided for GameSmith owners.\n\n"
	"Do you want to install Devpac GS?")
	(help "Devpac GS is a limited version of the commercial assembler Devpac 3.  Special discounts "
	"are available on the full version for GameSmith owners.  Contact Oregon Research or HiSoft "
	"more information.")
	(choices "Yes" "No")
))

(if dpgs
	(	 
  		(if (NOT @pretend)
      		(
      			(working "Unpacking Devpac GS...")
   				(run "lha x -q \"t:Devpac_GS.lha\" GameSmith:")
      		)
   		)
	)
)
	

(set exampl (askbool
	(prompt
	"Do you want to install the GameSmith Examples "
	"contained on Disk 3?")
	(help " ")
	(choices "Yes" "No")
))
(if exampl
	(	 
		(askdisk
			(dest "GDS_Examples")
			(prompt "Please Insert the Disk Labeled \"GDS_Examples\" Into Any Drive.")
			(help " ")
		)
   		(if (NOT @pretend)
      		(
      			(working "Unpacking GDS Examples Disk...")
   				(run "lha x -q \"GDS_Examples:GDS_examples.lha\" GameSmith:")
      		)
   		)
	)
)		
	

	
(delete "t:lha")
(delete "t:Devpac_GS.lha")

(startup "GameSmith"
	(prompt
		"The \"GameSmith:\" device assignment needs to be added to your "
		"startup sequence.  If you choose not to automatically add the assignment now, "
		"then you must manually add the line:\n\n"
		"   assign GameSmith: " GDS_dir"\n\n"
		"somewhere in your startup scripts.\n\n"
		"Do you want to automatically add the assignment to your \"S:user-startup\ file?")
	(help "Both CITAS and the include files expect the logical device \"GameSmith:\" "
	"to be assigned.  If it is not assigned to the directory in which your GameSmith "
	"system resides, CITAS will not run, and the include files will cause a compilation "
	"error.")
	(command "assign GameSmith: " GDS_dir"\n")
)


(set sas65 (askbool
	(prompt "One of the GameSmith include files needs to be customized in order "
	"to work properly with SAS C version 6.5 or higher.\n\n"
	"Will you be using SAS C version 6.5 or higher to compile "
	"GameSmith programs?")
	(help "Refer Should you purchase SAS C version 6.5 or higher at a "
	"later date, you will need to use the file libptrsSAS65.h instead "
	"of libptrs.h as it is currently set up now.  Selecting YES here "
	"will rename libptrs.h to libptrs.h.old, and replace it with "
	"libptrsSAS65.h.  These files can be found in the subdirectory "
	"GameSmith:include/libraries, and may be manually modified at any "
	"time.")
	(choices "Yes" "No")
	)
)

(if sas65
   (
	(rename "GameSmith:include/libraries/libptrs.h" "GameSmith:include/libraries/libptrs.h.old")
	(rename "GameSmith:include/libraries/libptrsSAS65.h" "GameSmith:include/libraries/libptrs.h")
   )
)


(if (AND (> ver 38) (exists "sys:utilities/MultiView"))
   (run "sys:utilities/MultiView GameSmith:ReadMe.Now")
   (run "more GameSmith:ReadMe.Now")
)
