;$VER: ReqAttackPackageInstallScript 1.0 (11.02.2001) ©Jaca/Dreamolers-CAPS
(set #MSG_WLCOME "Welcome to the ReqAttack 1.5 Package Installer\n©2001 by Jaca/Dreamolers-CAPS\n\nMake sure you use PatchControl from\nMCP archive!\n\nThis installer will install/update ReqAttack, RAPrefsMUI,\nCyReq and other ReqAttack\nutilities + example sound & gfx.\n\nReqAttack support page:\nhttp://republika.pl/jacadcaps")
(set #MSG_DEST "Where do you wish to install ReqAttack?\nA drawer called \"ReqAttack\" will be created automatically, if not already existing!")
(set #MSG_DONE "Thanks for installing ReqAttack!\n\nPlease read the ReqAttack.guide...\nPlease remove ReqOFF from your system - it's now in ReqAttack!\n\n\nAny questions ???\njacadcaps@poczta.onet.pl")
(set #MSG_NOHELP "No help available. Sorry!")
(set #MSG_COPY_ICON "Copying icon ...")
(set #MSG_RAPATH "Where on your hard disk is your ReqAttack directory?")
(set #MSG_MAKEDIR "\nCreating ReqAttack directory ...")
(set #MSG_COPY_BRUSHDT "Copying ReqAttack Brush Datatype ...")
(set #MSG_COPY_BRUSHDTDESC "Copying ReqAttack Brush Datatype description file ...")
(set #MSG_COPY_ANIMBRUSHDT "Copying ReqAttack Animbrush Datatype ...")
(set #MSG_COPY_ANIMBRUSHDTDESC "Copying ReqAttack Animbrush Datatype description file ...")
(complete 0)
(message #MSG_WLCOME)
;## VERSION CHECK
(set #OSVERSION (/ (getversion) 65536))

(if (< #OSVERSION 39)
	(abort "Sorry\nOS3.0+ required!")
)
;## ASK FOR DIRECTORY
(set #defdir @default-dest)
		
(if (= 1 (exists "S:ReqAttack.installinfo"))
	(
		(copyfiles
			(source "S:ReqAttack.installinfo")
			(dest "ENV:")
			(newname "ReqAttackInstallInfo")
		)
		(set #envdefdir (getenv "ReqAttackInstallInfo"))
		(if (<> "" #envdefdir)
			(set #defdir (pathonly #envdefdir))
		)
		(delete "ENV:ReqAttackInstallInfo")
	)
)
(set #dest
	(expandpath
		(askdir
			(prompt #MSG_DEST)
			(help #MSG_NOHELP)
			(default #defdir)
		)
	)
)
		(if (= 0 (exists (tackon #dest "ReqAttack")))
			(
				(makedir (tackon #dest "ReqAttack")
					(prompt #MSG_MAKEDIR)
					(help #MSG_NOHELP)
					(confirm)
				)
				(copyfiles
					(prompt #MSG_COPY_ICON)
					(source "/ReqAttack.info")
					(dest #dest)
					(help #MSG_NOHELP)
					(confirm)
				)
				(run ("installtools/noiconpos \"%s\"" (tackon #dest "ReqAttack")))
			)
		)

		(set #dest (tackon #dest "ReqAttack"))
		(set @default-dest #dest)
		(textfile
			(dest "S:ReqAttack.installinfo")
			(append #dest)
		)
;##
;## ASK WHAT TO INSTALL (!!!)
;## 
(set #MSG_WHAT "Select the items you want to be installed")
(set #MSG_PROG "Install/Update ReqAttack & RAPrefsMUI")
(set #MSG_TOOLS "Copy the ReqAttack tools")
(set #MSG_DOCS "Copy documentation")
(set #MSG_LOCALE "Copy catalog files")
(set #MSG_GFX "Copy example gfx files")
(set #MSG_SOUNDS "Copy example sounds")
(set #MSG_DT "Install datatypes")
(set #MSG_CR "Install CyReq")
(set #WHAT_PROG 1)
(set #WHAT_TOOLS 2)
(set #WHAT_DOCS 4)
(set #WHAT_LOCALE 8)
(set #WHAT_GFX 16)
(set #WHAT_SOUNDS 32)
(set #WHAT_DT 64)
(set #WHAT_CR 128)
(set #defwhat 255)
(set #what
  (askoptions
    (prompt #MSG_WHAT)
    (choices #MSG_PROG #MSG_TOOLS #MSG_DOCS #MSG_LOCALE #MSG_GFX #MSG_SOUNDS #MSG_DT #MSG_CR)
    (help "No help available")
    (default #defwhat)
  )
)
;##
;## REQATTACK SECTION
;##
(if (<> 0 (bitand #WHAT_PROG #what))
(

	(copyfiles
		(source "ReqAttack")
		(dest #dest)
		(infos)
	)
(set #rapc (askbool
    (prompt "Where to install RAPrefsMUI")
    (help "It's best to install it in SYS:Prefs")
    (choices "SYS:Prefs" "ReqAttack directory")))

(if (= 1 #rapc)
  (
   	(copyfiles
	  	(source "RAPrefsMUI")
		  (dest "SYS:Prefs")
  		(infos)
  	)
  )
)
(if (= 0 #rapc)
(
   	(copyfiles
	  	(source "RAPrefsMUI")
		  (dest #dest)
  		(infos)
  	)
  )
)
))
(complete 10)
;##
;## TOOLS SECTION
;##
(if (<> 0 (bitand #WHAT_TOOLS #what))
(
  (copyfiles
    (source "Tools")
    (dest (tackon #dest "Tools"))
    (all)
  )
  (copyfiles
    (source "ReqReplacers")
    (dest (tackon #dest "ReqReplacers"))
    (all)
  )
))
(complete 20)
;##
;## DOCS SECTION
;##
(if (<> 0 (bitand #WHAT_DOCS #what))
(
  (copyfiles
    (source "Documentation/English/ReqAttack.guide")
    (dest (tackon #dest "Documentation"))
  )
  (copyfiles
    (source "Documentation/English/Tools.guide")
    (dest (tackon #dest "Documentation"))
  )
))
(complete 30)
;##
;## GFX SECTION
;##
(if (<> 0 (bitand #WHAT_GFX #what))
(
  (copyfiles
    (source "AnimLogos")
    (dest (tackon #dest "AnimLogos"))
    (all)
  )
  (copyfiles
    (source "Buttons")
    (dest (tackon #dest "Buttons"))
    (all)
  )
  (copyfiles
    (source "Logos")
    (dest (tackon #dest "Logos"))
    (all)
  )
  (copyfiles
    (source "Patterns")
    (dest (tackon #dest "Patterns"))
    (all)
  )
))
(complete 40)
;##
;## SND SECTION
;##
(if (<> 0 (bitand #WHAT_SOUNDS #what))
(
  (copyfiles
    (source "Sounds")
    (dest (tackon #dest "Sounds"))
    (all)
  )
))
(complete 50)
;##
;## LOCALE SECTION
;##
(if (<> 0 (bitand #WHAT_LOCALE #what))
(
(set #L_WHAT "What locale files you wish to install?\nNOTE: ATO translations will be released\nin separate archives!")
(set #L_PL "polski/RAPrefsMUI.catalog")
(set #L_CD "RAPrefsMUI.cd")
(set #W_PL 1)
(set #W_CD 2)
(set #lwhat
  (askoptions
     (prompt #L_WHAT)(choices #L_PL #L_CD)(help "Sorry, no help :(")(default 2)
  )
)
))
(if (<> 0 (bitand #W_PL #lwhat))
(
  (copyfiles
    (source "Catalogs/polski/RAPrefsMUI.catalog")
    (dest (tackon "LOCALE:Catalogs" "polski/"))
  )
))
(if (<> 0 (bitand #W_CD #lwhat))
(
  (copyfiles
    (source "Catalogs/RAPrefsMUI.cd")
    (dest #dest)
  )
))
(complete 60)
(if (<> 0 (bitand #WHAT_DT #what))
(

		(copylib
			(prompt #MSG_COPY_BRUSHDT)
			(source "DataTypes/Classes/rabrush.datatype")
			(dest   "SYS:classes/datatypes")
			(confirm)
			(help #MSG_NOHELP)
		)
		(copyfiles
			(prompt #MSG_COPY_BRUSHDTDESC)
			(source "DataTypes/Devs/RABrush")
			(dest "DEVS:Datatypes")
			(infos)
			(noposition)
			(confirm)
			(help #MSG_NOHELP)
		)
		(copylib
			(prompt #MSG_COPY_ANIMBRUSHDT)
			(source "DataTypes/Classes/raanimbrush.datatype")
			(dest   "SYS:classes/datatypes")
			(confirm)
			(help #MSG_NOHELP)
		)
		(copyfiles
			(prompt #MSG_COPY_ANIMBRUSHDTDESC)
			(source "DataTypes/Devs/RAAnimBrush")
			(dest "DEVS:Datatypes")
			(infos)
			(noposition)
			(confirm)
			(help #MSG_NOHELP)
		)
))
(complete 70)
;##
;##CYREQ
;##
(set #MSG_COPY_CYREQ "Copying CyReq ...")
(set #MSG_FA "Now a program will be started that allows you to select at which position to insert CyReq in the Startup-Sequence. Change the predefined position only if you really know what you do!")
(set #MSG_FA2 "\n\nIf CyReq is already in your Startup-Sequence you can delete the corresponding lines by using CONTROL + LEFT MOUSE BUTTON.\n\nBefore saving the changed Startup-Sequence a backup of it will be created!")

(if (<> 0 (bitand #WHAT_CR #what))
	(
		(set #actversion 0)
		(set #installversion (getversion "Tools/CyReq"))
		
		(if (= 1 (exists ("C:CyReq")))
			(set #actversion (getversion "SYS:c/CyReq"))
		)
		(if (> #installversion #actversion)
			(
				(copyfiles
					(prompt #MSG_COPY_CYREQ)
					(source "Tools/CyReq")
					(dest "SYS:c")
					(help #MSG_NOHELP)
					(confirm)
				)
			)
		)

		(if (<> 0 (run "installtools/checkprogstart S:Startup-Sequence CyReq"))
			(
				(textfile
					(dest "T:cyreq_Start")
					(append ("CyReq ;one of most important patches in your OS!\n"))
					(safe)
				)
				(message #MSG_FA #MSG_FA2)
				(run "installtools/FileAttack T:cyreq_Start S:Startup-Sequence Backup S:Startup-Sequence.bak DefaultAfter #?SetPatch#?")
				(delete "T:cyreq_Start")
			)
		)
	)
)
(complete 80)
;##
;## PREFS FILES SECTION
;##
(if (=(exists "ENVARC:ReqAttack.prefs" (noreq)) 1)
  (if (askbool 
    (prompt "\n\nInstaller has found a ReqAttack.prefs file!\n\nIf RAPrefsMUI was not used before it is\n"
            "strongly recommended that you install the prefs file\nwhich comes with this archive!\n\n"
            "Install the prefs file?")
    (help "Sorry, no help :(")
    (choices "Yes, install" "No, it's a RAPrefsMUI file")
    )
    (copyfiles
      (source "Prefs/ReqAttack.prefs")
      (dest "ENVARC:")
    )
  )
)
(if (=(exists "ENVARC:ReqAttack.prefs" (noreq)) 0)
  (copyfiles
    (source "Prefs/ReqAttack.prefs")
    (dest "ENVARC:")
  )
)
(complete 85)
;## OS 3.9 ICONS by Raul Silva SECTION
(if (askbool
      (prompt "Do you wish to install OS3.9 alternative icons\ncreated by Raul Silva ?")
      (help "Original icons are in NewIcon format")
      (choices "Yes, install" "No, I use NewIcons©")
    )
(
    (copyfiles(source "Icons/ReqAttack_Drawer.info")(newname "ReqAttack.info")(dest (tackon #dest "/")))
    (copyfiles(source "Icons/ReqAttack.info")(dest #dest))
    (copyfiles(source "Icons/RAPrefsMUI.info")(dest #dest))
)
)
;##TOOLTYPE
(tooltype
	(dest (tackon #dest "ReqAttack"))
	(settooltype "HOMEDIR" #dest)
)
(complete 90)
;##WBSTARTUP
(if (askbool
      (prompt "Do you wish to make a copy of ReqAttack in WBStartup?")
      (help "By default ReqAttack is not installed after\nyou run this installation script")
      (choices "Yes, install!" "No, I'll install RA myself")
    )
(
  (copyfiles
    (source (tackon #dest "ReqAttack"))
    (dest "SYS:WBStartup")
    (infos)
  )
))
(complete 100)
(exit #MSG_DONE (quiet))
