;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 PageStream 3.1 beta 1 hard drive installation to the 3.1 Pre-Release beta 2 version.\n\nYour original PageStream3 disks will not be modified by this update.\n\nYou MUST have 3.1 beta 1 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 PageStream 3.1 beta 1 before applying this update patch.")
)
(set PGSsize (getsize "PageStream3:PageStream3"))
(if (<> PGSsize 1379472)
	(abort "You have the wrong version of PageStream 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 FILTERS
(working "Installing Updated Filters...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Filters x Filters.lha")
(delete "Filters.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))

;UPDATE TIPS
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Help x Tips.LHA")
(delete "Tips.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 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))

;PATCH EXTRAS TO LATEST VERSION IF APPLICABLE

(run "ram:lhex >NIL: <NIL: -qfw=ram: x Extras.LHA")
(set JPsize (getsize "SoftLogik:Filters/JPEG.gfilter"))

(if (= JPsize 95272)
	(
		(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:JPEG.pch" (safe))
(delete "ram:JPEG.gfilter" (safe))

;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")
