;PAGESTREAM 3.1 BETA 2 ONLINE UPDATE PATCH INSTALLATION SCRIPT
;COPYRIGHT 1996 SOFTLOGIK PUBLISHING CORPORATION

;WARN WEENIES TO GET LOST
(message "\n\nThis is a pre-release BETA version of PageStream 3.1. Stop now if you haven't read the Read.1st! file. Clicking Proceed indicates that you are knowingly installing beta software on your system.")

;QUIT PROGRAMS
(message "\n\nIf PageStream, BME or PageLiner are running now, quit them before continuing.")
(run "avail flush" (safe))

;USE ASSIGNS TO AVOID THE STUPID INSTALLER'S CRASH BUG
(run "CD PageStream3:" (safe))
(run "CD SoftLogik:" (safe))
(run "assign fonts: softlogik:fonts add" (safe))

;CONFIRM CORRECT VERSION IS INSTALLED, SET DESTINATION
(message ("\n\nThis patch will update your German PageStream3.0i hard drive installation to the 3.1 American Pre-Release beta 2 version.\n\nYour original PageStream3 disks will not be modified by this update.\n\nYou MUST have German 3.0i installed to use this patch."))
(if (<> (exists "PageStream3:PageStream3") 1)
	(abort "PageStream3 is not in the PageStream3: directory. You must properly install PageStream3.0i before applying this update patch.")
)
;get destination
(set PGSdest (getassign "PageStream3" "a"))
(set SLdest (getassign "SoftLogik" "a"))
(if (OR (= PGSdest "") (= SLdest ""))
	(abort "PageStream3: and/or SoftLogik: are not assigned. You must properly install PageStream3.0i before applying this update patch.")
)
(set PGSsize (getsize "PageStream3:PageStream3"))
(set BMEsize (getsize "PageStream3:BME"))

(if (<> PGSsize 1522840)
	(abort "You have the wrong version of PageStream installed. Please read the Read.1st! file for instructions.")
)
(if (<> BMEsize 117456)
	(abort "You have the wrong version of BME installed. Please read the Read.1st! file for instructions.")
)
(set @default-dest PGSdest)

;MAKE REQUIRED DIRECTORIES IF THEY DON'T EXIST
(if (<> (exists "SoftLogik:Engines") 2) (makedir "SoftLogik:Engines" (infos)))
(if (<> (exists "SoftLogik:Libs") 2) (makedir "SoftLogik:Libs" (infos)))
(if (<> (exists "SoftLogik:Printers") 2) (makedir "SoftLogik:Printers" (infos)))
(if (<> (exists "SoftLogik:Filters") 2) (makedir "SoftLogik:Filters" (infos)))
(if (<> (exists "SoftLogik:Effects") 2) (makedir "SoftLogik:Effects" (infos)))
(if (<> (exists "PageStream3:Help") 2) (makedir "PageStream3:Help" (infos)))
(if (= (exists "PageStream3:Macros") 2) (rename "PageStream3:Macros" "PageStream3:Scripts"))
(if (= (exists "PageStream3:Macros.info") 1) (rename "PageStream3:Macros.info" "PageStream3:Scripts.info"))
(if (<> (exists "PageStream3:Scripts") 2) (makedir "PageStream3:Scripts" (infos)))
(if (<> (exists "PageStream3:Scripts/TextClips") 2) (makedir "PageStream3:Scripts/TextClips" (infos)))
(if (<> (exists "PageStream3:Documents") 2) (makedir "PageStream3:Documents" (infos)))

;COPY THE LHEX PROGRAM TO RAM:
(copyfiles (source "PageStream3Disk1:lhex") (dest "ram:") (nogauge))

;UPDATE PRINTER DRIVERS
(working "Installing Updated Printer Drivers...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Printers x Printers.LHA")
(delete "Printers.LHA" (safe))

;UPDATE FILTERS
(working "Installing Updated Filters...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Filters x Filters.lha")
(delete "Filters.LHA" (safe))

;DELETE OLD FILTERS
(delete "SoftLogik:Filters/IFFDTXT.tfilter" (safe))
(delete "SoftLogik:Filters/Word.tfilter" (safe))
(delete "SoftLogik:Filters/WordPerfect5.tfilter" (safe))

;UPDATE EFFECTS
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Effects x Effects.lha")
(delete "Effects.LHA" (safe))

;UPDATE LIBS
(working "Installing Updated Libraries...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Libs x Libs.lha")
(delete "Libs.LHA" (safe))

;UPDATE ENGINES
(working "Installing Updated Engines...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Engines x Engines.lha")
(delete "Engines.LHA" (safe))

;DELETE OLD ENGINES
(delete "SoftLogik:Engines/XPress.codes" (safe))

;UPDATE HELP
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Help x Tips.LHA")
(delete "Tips.LHA" (safe))
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Help x Help.LHA")
(delete "Help.LHA" (safe))

;UPDATE SCRIPTS
(working "Installing Updated Scripts...")
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Scripts x Scripts.lha")
(delete "Scripts.LHA" (safe))

;UPDATE STYLES AND COLORS
(if
	(askbool
		(prompt
			"PageStream 3.1's style and color files are stored in a new format. If you have not added colors or styles to your default color and style files, click Update to install new files.\n\nIf you have changed these files, click Skip, but you should re-save your files with this version of PageStream to avoid problems in the future.")
		(help
			"If you don't save your files in the new format, or install the updated default ones, PageStream will have to convert these files every time you create a new document.")
		(choices "Update" "Skip")
		(default 0)
	)
	(
		(working "Installing Updated Styles...")
		(run "ram:lhex >NIL: <NIL: -qfw=PageStream3: x Styles.lha")
	)
	(
		("Don't forget to choose Save from the Color and Style palette pop-up menus to save your files in 3.1 format.")
	)
)
(delete "Styles.LHA" (safe))

;UPDATE BME
(if (exists "PageStream3:BME")
	(
		(working "Patching BME to 3.1...")
		(run "ram:lhex >NIL: <NIL: -qfw=ram: x BMEpatch.LHA")
		(run "spatch >NIL: <NIL: -oPageStream3:BME3.1 -pram:BME.pch PageStream3:BME")
		(if (exists "PageStream3:BME3.1")
			(
				(delete "PageStream3:BME")
				(rename "PageStream3:BME3.1" "PageStream3:BME")
			)
			(message "\nThe patch to BME was not successful. Refer to the Read.1st! file for further instructions.")
		)
		(delete "ram:BME.pch" (safe))
	)
)
(delete "BMEpatch.LHA" (safe))

;UPDATE PAGESTREAM3
(working "Patching PageStream to 3.1 Beta 2...\n\nThis will take a while...")
(run "ram:lhex >NIL: <NIL: -qfw=ram: x PGSpatch.LHA")
(delete "PGSpatch.LHA" (safe))
(run "spatch >NIL: <NIL: -oPageStream3:PageStream3.1 -pram:PageStream.pch PageStream3:PageStream3")
(if (exists "PageStream3:PageStream3.1")
		(
				(delete "PageStream3:PageStream3")
				(rename "PageStream3:PageStream3.1" "PageStream3:PageStream3")
		)
		(abort "The patch to PageStream3 was not successful. Refer to the Read.1st! file for instructions.")
)
(delete "ram:PageStream.pch" (safe))
;If they have TextFX 1 German, they'll have an exteran rsrc file incompatible with 3.1.
(delete "PageStream3:PageStream3.rsrc" (safe))

;PATCH EXTRAS TO LATEST VERSION IF APPLICABLE

(run "ram:lhex >NIL: <NIL: -qfw=ram: x Extras.LHA")
(set FXsize (getsize "SoftLogik:Engines/TextFX.extension"))
(set TTsize (getsize "SoftLogik:Engines/TTF.font"))
(set JPsize (getsize "SoftLogik:Filters/JPEG.gfilter"))

(if (= FXsize 32800)
	(
		(working "Updating TextFX extension to the latest version...")
		(run "spatch >NIL: <NIL: -oram:TextFX.extension -pram:TextFX.pch SoftLogik:Engines/TextFX.extension")
		(if (exists "ram:TextFX.extension")
			(copyfiles (source "ram:TextFX.extension") (dest "SoftLogik:Engines"))
		)
	)
)
(if (= TTsize 37176)
	(
		(working "Updating TrueType font engine to the latest version...")
		(run "spatch >NIL: <NIL: -oram:TTF.font -pram:TTF.pch SoftLogik:Engines/TTF.font")
		(if (exists "ram:TTF.font")
			(copyfiles (source "ram:TTF.font") (dest "SoftLogik:Engines"))
		)
	)
)
(if (= JPsize 95160)
	(
		(working "Updating JPEG Filter to the latest version...")
		(run "spatch >NIL: <NIL: -oram:JPEG.gfilter -pram:JPEG.pch SoftLogik:Filters/JPEG.gfilter")
		(if (exists "ram:JPEG.gfilter")
			(copyfiles (source "ram:JPEG.gfilter") (dest "SoftLogik:Filters"))
		)
	)
)
(delete "Extras.LHA" (safe))
(delete "ram:TTF.pch" (safe))
(delete "ram:TTF.font" (safe))
(delete "ram:JPEG.pch" (safe))
(delete "ram:JPEG.dfilter" (safe))
(delete "ram:TextFX.pch" (safe))
(delete "ram:TextFX.extension" (safe))

;WARN ABOUT SCRIPT PATH
;(message ("\nYour PageStream3:Macros directory has been renamed to PageStream3:Scripts. It is important that you choose Preferences from the File menu after starting PageStream 3.1, click on the Files tab, and set the path for Scripts to 'Scripts' instead of 'Macros' or whatever it is currently set to."))

;DISPLAY README (Try 3 different ways!)
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3: x Read.LHA")
(delete "Read.LHA" (safe))
(IF (> (run "Sys:Utilities/MultiView PageStream3:ReadMe.Now") 0)
		(IF (> (run "Sys:Utilities/AmigaGuide PageStream3:ReadMe.Now") 0)
				(run "More PageStream3:ReadMe.Now")
		)
)

;REMOVE THE LHEX PROGRAM
(delete "ram:lhex" (safe))
(delete "spatch" (safe))
(delete "Install-Beta1.info" (safe))

;DONE
(exit "Finished Installation")
