; $VER: Scala InfoChannel Install Version 2.0 (25.1.93)

;----------------------------- Text Strings -------------------------------

(set msg_Utils		"Scala Utilities")
(set msg_Palettes 	"Scala Palettes")
(set msg_Symbols	"Scala Symbols")
(set msg_ARexx 		"Scala Arexx Example")
(set msg_EX		"Scala EX")
(set msg_Fonts		"Scala Fonts")
(set msg_Back	 	"Scala Backgrounds")
(set msg_Demos		"Scala Demo Scripts")
(set msg_ScalaFont	"Scala.font")
(set msg_NoSelect	"You did not select anything. Please try again.")
(set msg_ChooseWhat	("Please select which parts of %s you would like to install:" @app-name))
(set msg_ChooseDest	("Please select where you want %s to be installed:" @app-name))
(set msg_Overscan	"You may resize the Scala Backgrounds to overscan. Please note that selecting %s or %s takes more space on your harddisk, and may reduce the performance of the Scala Wipes.\n\n")
(set msg_ChooseSize	"Please select which size you want the Scala Background pictures:")
(set msg_OldWorkbench	("You need at least Worbench 2.04 to install %s" @app-name))
(set msg_Nor		"Normal")
(set msg_Std		"Standard")
(set msg_Max		"Max")
(set msg_Startup	("Do you want %s to start up automatically every time you turn on your Amiga?" @app-name))
(set msg_ErrorRam	"Error while copying files to Ram Disk.")
(set msg_Insert		"Please insert Disk %ld in any drive")
(set msg_Installing	"Installing %s...")
(set msg_MoveLingua	"Replacing path in %s...")
(set msg_ConvertNTSC	"Converting background %s to NTSC...")
(set msg_ConvertOverscan "Converting background %s to overscan...")

;------------------------------ Constants ---------------------------------

(if (= @app-name "Scala InfoChannel")
    (
	(set opt_Scala		%000000001)
	(set opt_Utils		%000000010)
	(set opt_Palettes	%000000100)
	(set opt_Symbols	%000001000)
	(set opt_ARexx		%000010000)
	(set opt_EX		%000100000)
	(set opt_Fonts		%001000000)
	(set opt_Back	 	%010000000)
	(set opt_Demos		%100000000)
    )
    (
	(set opt_Scala		%000000001)
	(set opt_Symbols	%000000010)
	(set opt_EX		%000000100)
	(set opt_Fonts		%000001000)
	(set opt_Back	 	%000010000)
    )
)

;-------------------------- Utility procedures ----------------------------

(Procedure CheckConfig
    (set OS_Version (/ (getversion) 65536))
    (if (< OS_Version 37)
	(abort msg_OldWorkbench)
    )
    (if (= (database "vblank") 50)
        (   (SET VideoMode "PAL")
            (SET NOR ("640 x 512 (%s)" msg_Nor))
            (SET STD ("704 x 566 (%s)" msg_Std))
            (SET MAX ("736 x 566 (%s)" msg_Max))
	)
        (   (SET VideoMode "NTSC")
            (SET NOR ("640 x 400 (%s)" msg_Nor))
            (SET STD ("704 x 480 (%s)" msg_Std))
            (SET MAX ("736 x 482 (%s)" msg_Max))
	)
    )
)


(Procedure CopyTools
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (copyfiles
	(prompt "")
	(help @copyfiles-help)
	(source "Disk1:Tools")
	(all)
	(dest "RAM:")
    )
    (if (not (and (exists "RAM:LHa") 
		  (exists "RAM:MakeOverscan") 
		  (exists "RAM:MoveLingua")))
	(abort msg_ErrorRam)
    )
)


(Procedure InstallFile
    (working (msg_Installing Installing))
    (run ("RAM:LHa -N x %s \"%s/\"" LhaFile @Dest))
)


(Procedure InstallFontFiles
    (working (msg_Installing Installing))
    (run ("RAM:LHa -N x %s \"%s\"" LhaFile "Fonts:"))
)


(Procedure MoveLingua
    (set i 0)
    (while 
	(set ScriptName 
	    (select i
	    	"InfoChannelIC400.script"
	    	"LaScalatore.script"
	    	"ScalaAGA.script"
	    	"ScalaAirport.script"
	    	"ScalaCableTV.script"
	    	"ScalaComms.script"
	    	"ScalaFeatures.script"
	    	"ScalaFonts.script"
	    	"ScalaHotel.script"
	    	"ScalaQuiz.script"
	    	"ScalaShopping.script"
	    	"ScalaTime.script"
	    	"ScalaTravel.script"
	    	"ScalaVoice.script"
	    	"ScalaWipes.script"
	    	"ScalaWorld.script"
	    	"ScaliniMotor.script"
	    	""
	    )
    	)
	(working (msg_MoveLingua ScriptName))
	(set ScriptName (tackon (tackon @dest "Scripts") ScriptName))
	(run ("RAM:MoveLingua \"%s\" Work:Scala \"%s\" \"%s\"" ScriptName @dest (tackon @dest "Scripts")))
	(set i (+ i 1))
    )
)

(Procedure MakeOverscan
    (set i 0)
    (while 
	(set PictureName 
	    (select i
		"Fabrics001"	"Fabrics002"	"Fabrics003"
		"Fantasy001"	"Grass001"	"NaiveBook"
		"NaiveClock"	"NaiveCoffee"	"NaiveDisk"
		"NaivePencil"	"NaivePhone"	"NaivePiano"
		"NaivePlate"	"Number001"	"Number002"
		"Number003"	"Number004"	"Number005"
		"Number006"	"Number007"	"Number008"
		"Number009"	"Painting001"	"Painting002"
		"Painting003"	"Painting004"	"Paper001"
		"Paper002"	"Paper003"	"Paper004"
		"Paper005"	"Sky001"	"Stones001"
		"Stones002"	"Stones003"	"Stones004"
		"Stones005"	"Stones006"	"Stones007"
		"Stones008"	"Stones009"	"Stones010"
		"Stones011"	"Tech001"	"Tech002"
		"Tech003"	"Tech004"	"Tech005"
		"Tech006"	"Tech007"	"Texture001"
		"Texture002" 	"Texture003"	"Texture004"
		"Texture005" 	"Texture006" 	"Texture007" 
		"Texture008"	"Texture009" 	"Texture010" 	
		"Texture011"	"Texture012" 	"Texture013" 
		"Theme001" 	"Theme002" 	"Theme003" 
		"Theme004"	"Water001" 	"Window001" 
		"World001"	""
	    )
    	)
    	(if (and (= VideoMode "NTSC") (= BackSize 0))
	    (working (msg_ConvertNTSC PictureName))
	    (working (msg_ConvertOverscan PictureName))
	)
	(set PictureName (tackon (tackon @dest "Backgrounds") PictureName))
	(run ("RAM:MakeOverscan \"%s\" \"%s\" %s %s" PictureName PictureName
		VideoMode (select BackSize "NOR" "STD" "MAX")))
	(set i (+ i 1))
    )
)

;-------------------------- Cleanup procedures ----------------------------

(Procedure DeleteTools
    (delete "RAM:MakeOverscan" "RAM:MoveLingua" "RAM:Lha")
)

(onerror (DeleteTools))


;-------------------------- Menu procedures -------------------------------

(Procedure InstallMenu
    (until (<> Selection 0)
        (set Selection
            (askoptions
                (prompt msg_ChooseWhat)
                (help @askoptions-help)
                (if (= @app-name "Scala InfoChannel")
                    (choices @app-name
                         msg_Utils
                         msg_Palettes
                         msg_Symbols
                         msg_ARexx
                         msg_EX
                         msg_Fonts
                         msg_Back
                         msg_Demos
                    )
                    (choices @app-name
                         msg_Symbols
                         msg_EX
                         msg_Fonts
                         msg_Back
                    )
                )
            )
        )
        (if (= Selection 0)    
            (message msg_NoSelect)
        )
    )
)


(Procedure BackMenu
    (set BackSize
        (askchoice
            (prompt (msg_Overscan STD MAX) msg_ChooseSize)
            (help @askchoice-help)
            (choices NOR STD MAX)
	)
    )
)


(Procedure DestMenu
    (set @dest
        (askdir
            (prompt msg_ChooseDest)
            (help @askdir-help)
            (newpath)
            (default @default-dest)
	)
    )
    (if (not (exists (pathonly (@dest))))
    	(
	    (makedir @dest (infos))
            (tooltype (dest @dest) (noposition))
	)
    )
    (set @default-dest @dest)
)



;------------------------- Installation procedures ------------------------
(Procedure InstallScala
    (set System (tackon @dest "System"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir System (infos))
    (tooltype (dest System) (noposition))
    (set Installing @app-name)
    (set LhaFile "Disk1:Scala.lha")
    (InstallFile)
    (set Installing msg_ScalaFont)
    (set LhaFile "Disk1:ScalaFont.lha")
    (InstallFontFiles)
    (if (<> @app-name "Scala InfoChannel")
	(
	    (set Scripts (tackon @dest "Scripts"))
	    (makedir Scripts (infos))
	    (tooltype (dest Scripts) (noposition))
	    (copyfiles (source "Disk1:InfoChannel.script")
		(dest (tackon @dest "Scripts"))
	    )
	    (textfile (dest (tackon @dest "System/InfoChannel.startup"))
	    	(append (tackon @dest "Scripts/InfoChannel.script"))
	    )
	)
    )
    (startup 
    	(prompt msg_Startup)
    	(help @startup-help)
    	"Scala"
    	(if (= @app-name "Scala InfoChannel")
	    (command (tackon @dest "InfoChannel"))
	    (command (tackon @dest "InfoPlayer"))
	)
    )
)

(Procedure InstallUtils
    (set Utilities (tackon @dest "Utilities"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir Utilities (infos))
    (tooltype (dest Utilities) (noposition))
    (set Installing msg_Utils)
    (set LhaFile "Disk1:Utilities.lha")
    (InstallFile)
)

(Procedure InstallPalettes
    (set Palettes (tackon @dest "Palettes"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir Palettes (infos))
    (tooltype (dest Palettes) (noposition))
    (set Installing msg_Palettes)
    (set LhaFile "Disk1:Palettes.lha")
    (InstallFile)
)

(Procedure InstallSymbols
    (set Symbols (tackon @dest "Symbols"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir Symbols (infos))
    (tooltype (dest Symbols) (noposition))
    (set Installing msg_Symbols)
    (set LhaFile "Disk1:Symbols.lha")
    (InstallFile)
)

(Procedure InstallArexx
    (set ARexx (tackon @dest "ARexx"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir ARexx (infos))
    (tooltype (dest ARexx) (noposition))
    (set Installing msg_ARexx)
    (set LhaFile "Disk1:ARexx.lha")
    (InstallFile)
)

(Procedure InstallScripts
    (set Scripts (tackon @dest "Scripts"))
    (askdisk (dest "Disk1") (prompt (msg_Insert 1)) (help @askdisk-help))
    (makedir Scripts (infos))
    (tooltype (dest Scripts) (noposition))
    (set Installing msg_Demos)
    (set LhaFile "Disk1:Scripts.lha")
    (InstallFile)
    (MoveLingua)
)

(Procedure InstallEX
    (set EX (tackon @dest "EX"))
    (askdisk (dest "Disk2") (prompt (msg_Insert 2)) (help @askdisk-help))
    (makedir EX (infos))
    (tooltype (dest EX) (noposition))
    (set Installing msg_EX)
    (set LhaFile "Disk2:EX.lha")
    (InstallFile)
)

(Procedure InstallFonts
    (askdisk (dest "Disk2") (prompt (msg_Insert 2)) (help @askdisk-help))
    (set Installing msg_Fonts)
    (set LhaFile "Disk2:Fonts.lha")
    (InstallFontFiles)
)

(Procedure InstallBack
    (set Back (tackon @dest "Backgrounds"))
    (makedir Back (infos))
    (tooltype (dest Back) (noposition))
    (set Installing msg_Back)

    (askdisk (dest "Disk2") (prompt (msg_Insert 2)) (help @askdisk-help))
    (set LhaFile "Disk2:Backgrounds1.lha")
    (InstallFile)

    (askdisk (dest "Disk3") (prompt (msg_Insert 3)) (help @askdisk-help))
    (set LhaFile "Disk3:Backgrounds2.lha")
    (InstallFile)

    (askdisk (dest "Disk4") (prompt (msg_Insert 4)) (help @askdisk-help))
    (set LhaFile "Disk4:Backgrounds3.lha")
    (InstallFile)

    (askdisk (dest "Disk5") (prompt (msg_Insert 5)) (help @askdisk-help))
    (set LhaFile "Disk5:Backgrounds4.lha")
    (InstallFile)

    (if (or (= VideoMode "NTSC") BackSize)
    	(MakeOverscan)
    )
)

(Procedure InstallDemos
    (set Anim (tackon @dest "Animations"))
    (makedir Anim (infos))
    (tooltype (dest Anim) (noposition))

    (set Sound (tackon @dest "Sound"))
    (makedir Sound (infos))
    (tooltype (dest Sound) (noposition))

    (set Music (tackon @dest "Music"))
    (makedir Music (infos))
    (tooltype (dest Music) (noposition))

    (set Text (tackon @dest "Text"))
    (makedir Text (infos))
    (tooltype (dest Text) (noposition))

    (set Back (tackon @dest "Backgrounds"))
    (makedir Back (infos))
    (tooltype (dest Back) (noposition))

    (set Installing msg_Demos)

    (askdisk (dest "Disk6") (prompt (msg_Insert 6)) (help @askdisk-help))
    (set LhaFile "Disk6:Demos1.lha")
    (InstallFile)

    (askdisk (dest "Disk7") (prompt (msg_Insert 7)) (help @askdisk-help))
    (set LhaFile "Disk7:Demos2.lha")
    (InstallFile)

    (askdisk (dest "Disk8") (prompt (msg_Insert 8)) (help @askdisk-help))
    (set LhaFile "Disk8:Demos3.lha")
    (InstallFile)

    (askdisk (dest "Disk9") (prompt (msg_Insert 9)) (help @askdisk-help))
    (set LhaFile "Disk9:Demos4.lha")
    (InstallFile)

    (askdisk (dest "Disk10") (prompt (msg_Insert 10)) (help @askdisk-help))
    (set LhaFile "Disk10:Demos5.lha")
    (InstallFile)

    (askdisk (dest "Disk11") (prompt (msg_Insert 11)) (help @askdisk-help))
    (set LhaFile "Disk11:Demos6.lha")
    (InstallFile)

    (askdisk (dest "Disk12") (prompt (msg_Insert 12)) (help @askdisk-help))
    (set LhaFile "Disk12:Demos7.lha")
    (InstallFile)

    (askdisk (dest "Disk13") (prompt (msg_Insert 13)) (help @askdisk-help))
    (set LhaFile "Disk13:Demos8.lha")
    (InstallFile)

    (askdisk (dest "Disk14") (prompt (msg_Insert 14)) (help @askdisk-help))
    (set LhaFile "Disk14:Demos9.lha")
    (InstallFile)

)


;------------------------------- Main program -----------------------------

(CheckConfig)
(InstallMenu)
(if (<> Selection opt_Fonts)    	(DestMenu))
(if (bitand Selection opt_Back)     	(BackMenu))
(CopyTools)

; Disk 1
(if (bitand Selection opt_Scala)	(InstallScala))
(if (bitand Selection opt_Utils)	(InstallUtils))
(if (bitand Selection opt_Palettes)	(InstallPalettes))
(if (bitand Selection opt_Symbols)	(InstallSymbols))
(if (bitand Selection opt_ARexx)	(InstallARexx))
(if (bitand Selection opt_Demos)	(InstallScripts))

; Disk 2
(if (bitand Selection opt_EX)		(InstallEX))
(if (bitand Selection opt_Fonts)	(InstallFonts))

; Disk 2-5
(if (bitand Selection opt_Back)		(InstallBack))

; Disk 6-9
(if (bitand Selection opt_Demos)	(InstallDemos))


(DeleteTools)

(exit)
(welcome)
