;
; $VER: Install-Rainboot3 (22.11.00)
;
; by Andreas Falkenhahn & Kimmo Pekkola
;

(set ver 3)
(set rev 1) 

;---------------------------- Global Strings ---------------------------------
(set #hello-msg (cat "\nRainboot3\n-\nMultimedia's Got A Name\n\nVersion " ver "." rev "\n\n(C) Copyright 1996-2000 Andreas Falkenhahn & Kimmo Pekkola"))
(set #locale-msg (cat "Select a language to use\nWhlen Sie eine Sprache aus"))
(set #identifyn "Libs/identify.library")
(set #thxplayn "Libs/thxplay.library")
(set #dirname "Rainboot")
;----------------------------------------------------------------------------

(message #hello-msg)

(set #locale
	(askchoice
		(prompt #locale-msg)
		(help @askoptions-help)
		(choices "english" "deutsch")
	)
)

(if (= #locale 0) (
   (set #guide1 "Rainboot3.guide")
   (set #guide2 "RCC.guide")
   (set #keys-msg (cat "\nThe installer has found Rainboot 2.x keyfiles on your harddisk! "
                       "To use Rainboot3 in an uncrippled way, you've to upgrade for only "
                       "10 DM/$8 USD.\n\nPlease have a look at the documentation to see "
                       "how to purchase your personal upgrade. Thank you!"
   ))                    
   (set #kick39-msg "Sorry, you need at least Kickstart 3.0 to use Rainboot 3.")
   (set #destdir-msg "Where you want Rainboot3 to be installed? A drawer called Rainboot will be created.")
   (set #libs-msg "Copying libraries...")
   (set #copyil-msg "\nCopying iff.library to LIBS:...")
   (set #copyrbl-msg "\nCopying Rainboot.library to LIBS:...")
   (set #copympl-msg "\nCopying medplayer.library to LIBS:...")
   (set #copypll-msg "\nCopying player61.library to LIBS:...")
   (set #copyprl-msg "\nCopying ptreplay.library to LIBS:...")
   (set #copytl-msg "\nCopying thxplay.library to LIBS:...")
   (set #copyidl-msg "\nCopying identify.library to LIBS:...")
   (set #copyrb-msg "\nCopying Rainboot3 to C:...")
   (set #copyrbd-msg "\nCopying Rainboot3.data to C:...")
   (set #copygm "\nThe GetModeID tool can be used to find out the modeid for a screenmode! Do you want to install it?")
   (set #copygm-msg "\nCopying GetModeID to C:...")
   (set #copy-msg "Copying files...")
   (set #example-msg "Which of these example configs do you want to install?")
   (set #fonts-msg "Do you want to install the fonts also? The examples won't work correctly without these fonts.")
   (set #fonts-help "FuturaB, FuturaL and GoudyB are going to be installed in your FONTS: drawer")
   (set #start-msg "Do you want Rainboot3 to be copied in your WBstartup drawer?")
   (set #start-help "Copying Rainboot3 to your WBStartup drawer closes the bootscreen at the end of the booting. This does not start a new Rainboot2 even if one isn't running. It only stops it.")
   (set #wbstart-msg "Where is your WBStartup drawer?")
   (set #edit-msg "Now you still have to edit your s:startup-sequence. Just put the line (one line!):\n\n")
   (set #edit-msg2 "\n\nsomewhere after the monitordrivers and reset your Amiga.\n(You might also need a MODEID or CGFX argument so check the docs for details)")
   (set #edit2-msg "If you want to use Rainboot3 you must first create a config-file (check the docs and the examples) and the put Rainboot2 in your startup-sequence. Somewhere after the monitordrivers is probably a good place")
   (set #tools-msg "Which tools do you want to install?")
   (set #startmenu "What do you want to do?")
   (set #choice1 "Install Rainboot")
   (set #choice2 "Configure Rainboot")
   (set #configintro "\nRainboot wasn`t found in your S:Startup-Sequence. Do you want the Installer to add it to your Startup-Sequence?")
   (set #found1 "Rainboot has been found in your Startup-Sequence in the following line:")
   (set #found2 "What to do with this line now?")
   (set #found3 "Change line")
   (set #found4 "Delete line")
   (set #found5 "Nothing")
   (set #sconfig "Which configuration do you want to use while booting?")
   (set #wargs "Which options do you want to use?")
   (set #arg1 "RTG - for usage under CGfx and Picasso96")
   (set #arg2 "BESTFIT - use bestpossible screenmode")
   (set #arg3 "PUBLIC - open a public screen")
   (set #arg4 "USEDEFAULTS - use default settings (recommended)")
   (set #try1 "\nShall the selected configuration ")
   (set #try2 " now be displayed so that you can check if it works on your system?")
   (set #ftry (cat "\nIf the configuration has been displayed correctly, you can click on Continue "
                   "now, it`ll be added to your Startup-Sequence. If there have been errors occured "
                   "please look in the documentation or contact me for help!"
   )) 
   (set #warn (cat "\nWARNING! Are you sure that Rainboot shall be added to your Startup-Sequence? "
                   "If you want this click on Continue now. A backup of your current Startup-Sequence "
                   "will be saved to S:Startup-Sequence.rainboot!"
   ))
   (set #fini (cat "\nRainboot has been successfully installed in your Startup-Sequence! "
                   "You should reboot your Amiga now and look, if they config is displayed "
                   "correctly. If this is not the case, you can look in the documentation "
                   "or contact me for help. To restore your old Startup-Sequence, open a Shell "
                   "and type in:\n\n"
                   "Copy S:Startup-Sequence.rainboot S:Startup-Sequence\n\n"
                   "Have fun!"
   ))
   (set #ifi (cat "\nThe installation has been finished successfully. You can configure Rainboot "
                  "now if you`ll click on Continue. If you don`t want that, you`ll have to click "
                  "on Abort."
   ))
))

(if (= #locale 1) (
   (set #guide1 "Deutsch/Rainboot3.guide")
   (set #guide2 "Deutsch/RCC.guide")
   (set #keys-msg (cat "\nDer Installer hat auf Ihrem System Rainboot 2.x Keyfiles gefunden. "
                       "Um Rainboot3 uneingeschrnkt nutzen zu knnen, mssen Sie jedoch fr "
                       "10 DM upgraden.\n\nBitte schauen Sie in die Dokumentation, um zu "
                       "erfahren, wie Sie Ihr Upgrade bestellen knnen."
   ))                    
   (set #kick39-msg "Sie bentigen mindestens Kickstart 3.0, um Rainboot 3 benutzen zu knnen.")
   (set #destdir-msg "Wo mchten Sie Rainboot3 installiert haben? Ein Verzeichnis namens Rainboot wird dort angelegt!")
   (set #libs-msg "Kopiere Libraries...")
   (set #copyil-msg "\nKopiere iff.library nach LIBS:...")
   (set #copyrbl-msg "\nKopiere Rainboot.library nach LIBS:...")
   (set #copympl-msg "\nKopiere medplayer.library nach LIBS:...")
   (set #copypll-msg "\nKopiere player61.library nach LIBS:...")
   (set #copyprl-msg "\nKopiere ptreplay.library nach LIBS:...")
   (set #copytl-msg "\nKopiere thxplay.library nach LIBS:...")
   (set #copyidl-msg "\nKopiere identify.library nach LIBS:...")
   (set #copyrb-msg "\nKopiere Rainboot3 nach C:...")
   (set #copyrbd-msg "\nKopiere Rainboot3.data nach C:...")
   (set #copy-msg "Kopiere Dateien...")
   (set #copygm "\nDas GetModeID Tool kann benutzt werden, um herauszufinden, welcher ModeID zu welchen Bildschirmmodus gehrt. Mchten Sie es installieren?")
   (set #copygm-msg "\nKopiere GetModeID nach C:...")
   (set #example-msg "Welche dieser Beispiele mchten Sie installieren?")
   (set #fonts-msg "Mchten Sie auch die Schriften installieren? Die Beispiele funktionieren ohne diese Schriften nicht korrekt.")
   (set #fonts-help "FuturaB, FuturaL und GoudyB werden in Ihrem FONTS: Verzeichnis abgelegt!")
   (set #start-msg "Soll Rainboot3 in Ihre WBStartup gelegt werden?")
   (set #start-help "Rainboot3 in Ihrem WBStartup Verzeichnis schliet den Bootbildschirm, wenn Sie den Befehl %W in Ihrer Konfiguration benutzen.")
   (set #wbstart-msg "Wo ist Ihr WBStartup Verzeichnis?")
   (set #edit-msg "Jetzt mssen Sie noch Ihre Startup-Sequence edieren. Fgen Sie einfach diese Zeile (nur eine Zeile!):\n\n")
   (set #edit-msg2 "\n\nirgendwo nach den Monitortreiber ein und starten Sie Ihren Amiga neu.\n(Mglicherweise mssen Sie auch das MODEID oder RTG Argument benutzen, schauen Sie in die Dokumentation!)")
   (set #edit2-msg (cat "Wenn Sie Rainboot3 benutzen mchten, mssen Sie zuerst eine Konfiguration "
                        "erstellen. Schauen Sie sich einfach mal die Beispiele an oder schauen Sie "
                        "in die Dokumentation. Auerdem muss Rainboot in Ihre Startup-Sequence "
                        "eingefgt werden!"
   ))
   (set #tools-msg "Welche Tools mchten Sie installieren?")
   (set #startmenu "Was mchten Sie machen?")
   (set #choice1 "Rainboot installieren")
   (set #choice2 "Rainboot konfigurieren")
   (set #configintro "\nRainboot wurde nicht in Ihrer Startup-Sequence gefunden. Mchten Sie, dass der Installer Rainboot dort einfgt?")
   (set #found1 "Rainboot wurde in Ihrer Startup-Sequence in folgender Zeile gefunden:")
   (set #found2 "Was soll mit dieser Zeile passieren?")
   (set #found3 "Zeile ndern")
   (set #found4 "Zeile lschen")
   (set #found5 "Nichts")
   (set #sconfig "Welche Konfiguration mchten Sie whrend dem Booten verwenden?")
   (set #wargs "Welche Optionen mchten Sie verwenden?")
   (set #arg1 "RTG - fr die Verwendung unter CGfx und Picasso96")
   (set #arg2 "BESTFIT - besten Bildschirmmodus nutzen")
   (set #arg3 "PUBLIC - ffentlichen Bildschirm ffnen")
   (set #arg4 "USEDEFAULTS - Standardeinstellungen benutzen (empfohlen)")
   (set #try1 "\nSoll die ausgewhlte Boot-Konfiguration ")
   (set #try2 " jetzt probeweise angezeigt werden, damit Sie berprfen knnen, ob Rainboot auf Ihrem System luft?")
   (set #ftry (cat "\nWenn die Konfiguration problemlos angezeigt wurde, knnen Sie jetzt auf Weiter "
                   "klicken, dann wird Sie in Ihre Startup-Sequence eingetragen. Sollte es Fehler "
                   "gegeben haben, kontakten Sie bitte mich oder schauen in der Dokumentation nach!"
   )) 
   (set #warn (cat "\nACHTUNG! Sind Sie sicher, dass Rainboot in Ihre Startup-Sequence "
                   "eingefgt werden soll? Wenn Sie das mchten, klicken Sie auf Weiter."
                   "Es wird dann ein Backup Ihrer Startup-Sequence nach S:Startup-Sequence.rainboot "
                   "gespeichert. "
   ))
   (set #fini (cat "\nRainboot wurde erfolgreich in Ihrer Startup-Sequence installiert! "
                   "Sie sollten Ihren Amiga mal neustarten und schauen, ob Rainboot nun "
                   "funktioniert. Sollte dies nicht der Fall sein, schauen Sie in die "
                   "Dokumentation und kontakten ggf. mich. Um Ihre alte Startup-Sequence "
                   "wiederherzustellen ffnen Sie eine Shell und geben folgendes ein:\n\n"
                   "Copy S:Startup-Sequence.rainboot S:Startup-Sequence\n\n"
                   "Viel Spa!"
   ))
   (set #ifi (cat "\nDie Installation wurde erfolgreich abgeschlossen. Als nchtes knnen Sie Rainboot "
                  "konfigurieren, klicken Sie dazu auf Weiter. Wenn Sie nichts mehr machen wollen, "
                  "klicken Sie auf Abbrechen."
   ))
   (set #dlocale (cat "\nSoll Rainboot3 immer das deutsche Datumsformat (Tag. Monat Jahr) benutzen? "
                      "Es wird dann die von mir schon mit dem RBLocaleCreator fr deutsche Benutzer "
                      "erstellte Datei installiert."
   ))
)) 

(procedure config

   (run "Tools/RBSSAdder SEARCH")
   
   (if (exists "ENV:RBENTRY") (
      (set #rbpath (getenv "RBENTRY"))
      (set wsmd
          (askchoice
                (prompt (cat #found1 "\n\n" #rbpath "\n\n" #found2))
                (choices #found3 #found5)
                (help @askchoice-help)
          )
      )    

      (if (= wsmd 1) (
         (exit (quiet))
      ))           
      
      (delete "env:RBENTRY")
   ) (
      (set ychoice
          (askbool
             (prompt #configintro)
             (help @askbool-help)
          )
      )
      
      (if (= ychoice 0) (
         (exit (quiet))
      ))   
   ))   
   
   (set #rconfig
       (askfile
          (prompt #sconfig)
          (help   @askfile-help)
          (default "sys:")
       )
   )
   
   (set args
       (askoptions       
         (prompt #wargs)
         (help @askoptions-help)
         (choices #arg1 #arg2 #arg3 #arg4)
         (default 0)
       )
   )      

   (if (in args 0)
      (set #argy1 "RTG ")
   )

   (if (in args 1)
      (set #argy2 "BESTFIT ")
   )

   (if (in args 2)
      (set #argy3 "PUBLIC ")
   )

   (if (in args 3)
      (set #argy4 "USEDEFAULTS ")
   )

   (set ttry
       (askbool
          (prompt #try1 #rconfig #try2)
          (help @askbool-help)
       )
   )

   (if (= ttry 1) (
      (run "Rainboot3 " #rconfig " " #argy1 #argy2 #argy3 #argy4)
      (message #ftry)
   ))

   (message #warn)

   (copyfiles
      (source "S:Startup-Sequence")
      (dest "S:")
      (newname "Startup-Sequence.rainboot")
      (nogauge)
   )

   (run "Tools/RBSSAdder \"Rainboot3 " #rconfig #argy1 #argy2 #argy3 #argy4 "\"") 

   (message #fini)
  
   (exit (quiet))

)         

(welcome)

(if (< (/ (getversion) 65536) 39)
	(abort #kick39-msg)
)

(set #selection
	(askchoice
		(prompt #startmenu)
		(help @askoptions-help)
		(choices #choice1 #choice2)
	)
)

(if (= #selection 1) (
   (config)
))   

(set #destdir
	(askdir
		(prompt	#destdir-msg)
		(help	@askdir-help)
		(default "SYS:")
	)
)

(set @default-dest #destdir)

(makedir (tackon #destdir #dirname))

(copyfiles
   (source "/Rainboot3.info")
   (dest #destdir)
   (newname "Rainboot.info")
)
   
(copyfiles
	(prompt #copy-msg)
	(help @copyfiles-help)
	(source "")
	(dest (tackon #destdir #dirname))
	(choices "Rainboot3" "Rainboot3.data" "RCC" #guide1 #guide2 "Rainboot3.guide.info" "RCC.guide.info")
	(infos)
)

(copyfiles
	(source "Rainboot3")
	(dest "C:")
)

(copyfiles
	(source "Rainboot3.data")
	(dest "C:")
)

(copyfiles
	(source "InstallRainboot")
        (infos)
	(dest (tackon #destdir #dirname))
)

(makedir (tackon (tackon #destdir #dirname) "Catalogs"))

(copyfiles
       (source "Catalogs")
       (dest (tackon (tackon #destdir #dirname) "Catalogs"))
       (all)
)

(if (< (database "cpu") 68020) (
   (set #identifyn "Libs/identify.library_000")
   (set #thxplayn "Libs/thxplay.library_000")
))

(copylib
	(prompt #copyprl-msg)
	(source "Libs/ptreplay.library")
	(dest "LIBS:")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
	(prompt #copyrbl-msg)
	(source "Libs/Rainboot.library")
	(dest "LIBS:")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
	(prompt #copympl-msg)
	(source "Libs/medplayer.library")
	(dest "LIBS:")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
	(prompt #copytl-msg)
	(source #thxplayn)
	(dest "LIBS:")
        (newname "thxplay.library")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
	(prompt #copypll-msg)
	(source "Libs/player61.library")
	(dest "LIBS:")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
	(prompt #copyil-msg)
	(source "Libs/iff.library")
	(dest "LIBS:")
	(help @copylib-help)
	(confirm)
        (optional force askuser)
)

(copylib
        (prompt #copyidl-msg)
        (source #identifyn)
        (dest "LIBS:")
        (newname "identify.library")
        (help @copylib-help)
        (confirm)
        (optional force askuser)
)

(if (exists "Tools") (

   (makedir (tackon (tackon #destdir #dirname) "Tools"))

   (copyfiles
	(source "Tools.info")
	(dest (tackon #destdir #dirname))
	(infos)
   )

   (set #tools
	(askoptions
		(prompt #tools-msg)
		(help @askoptions-help)
		(choices "GetModeID" "LoginMaker" "RainCreator" "RBLocaleCreator" "RBSSAdder")
	)
   )

   (if (in #tools 0)

	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "Tools/GetModeID")
		(dest (tackon (tackon #destdir #dirname) "Tools"))
		(pattern "GetModeID#?")
		(infos)
	)
   )

   (if (in #tools 1)

	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "Tools/LoginMaker")
		(dest (tackon (tackon #destdir #dirname) "Tools"))
		(pattern "LoginMaker#?")
		(infos)
	)
  )

  (if (in #tools 2)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Tools/RainCreator")
                (dest (tackon (tackon #destdir #dirname) "Tools"))
                (pattern "RainCreator#?")
                (infos)
        )
  )

  (if (in #tools 3)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Tools/RBLocaleCreator")
                (dest (tackon (tackon #destdir #dirname) "Tools"))
                (pattern "RBLocaleCreator#?")
                (infos)
        )
  )

  (if (in #tools 4)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Tools/RBSSAdder")
                (dest (tackon (tackon #destdir #dirname) "Tools"))
                (pattern "RBSSAdder#?")
                (infos)
        )
  )

))

(if (exists "Configs") (

   (makedir (tackon (tackon #destdir #dirname) "Configs") (infos))

   (set #example
	(askoptions
		(prompt #example-msg)
		(help @askoptions-help)
		(choices "AmigaCD32 Boot" "AmigaOS3.5 Boot" "Demo" "MultipleAnims" "RainbootManual")
		(default 2)
	)
   )

   (if (in #example 0)

	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "Configs")
		(dest (tackon (tackon #destdir #dirname) "Configs"))
		(pattern "AmigaCD32Boot#?")
	)
   )

   (if (in #example 1)

	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "Configs")
		(dest (tackon (tackon #destdir #dirname) "Configs"))
		(pattern "AmigaOS35#?")
	)
  )

  (if (in #example 2)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Configs")
                (dest (tackon (tackon #destdir #dirname) "Configs"))
                (pattern "Demo#?")
        )
  )

  (if (in #example 3)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Configs")
                (dest (tackon (tackon #destdir #dirname) "Configs"))
                (pattern "MultipleAnims#?")
        )
  )

  (if (in #example 4)

        (copyfiles
                (prompt #copy-msg)
                (help @copyfiles-help)
                (source "Configs")
                (dest (tackon (tackon #destdir #dirname) "Configs"))
                (pattern "RainbootManual#?")
        )
  )

  (copyfiles
     (source "Configs/ReadMe.txt")
     (dest (tackon (tackon #destdir #dirname) "Configs"))
     (infos)
  )
  
  (copyfiles
     (source "Configs.info")
     (dest (tackon #destdir #dirname))
  )      
))

(if (exists "Fonts") (

   (set #fonts #example)

   (set #fonts
	(askbool
		(prompt #fonts-msg)
		(help #fonts-help)
		(default 1)
	)
   )

   (if #fonts
	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "Fonts")
		(dest "FONTS:")
		(all)
	)
   )
))

(set #start
	(askbool
		(prompt #start-msg)
		(help #start-help)
		(default 1)
	)
)

(if #start
	((set #wbdir 
		(askdir
			(prompt	#wbstart-msg)
			(help	@askdir-help)
			(default "SYS:WBStartup")
		)
	)

	(copyfiles
		(prompt #copy-msg)
		(help @copyfiles-help)
		(source "")
		(dest #wbdir)
		(choices "Rainboot3" "Rainboot3.info")
	))
)

(if (= #locale 1) (
   (set dloc
       (askbool
          (prompt #dlocale)
          (help   @askbool-help)
       )
   )

   (if (= dloc 1) (
      (copyfiles
         (source "Rainboot3.dlocale")
         (dest "S:")
         (newname "Rainboot3.locale")
      )
   ))
))   

(message #ifi)

(config)
(exit (quiet))
;(message #edit-msg (tackon (tackon #destdir #dirname) "Rainboot2") (tackon (tackon #destdir #dirname) "Configs/Cloudboot.config") #edit-msg2)
;(message #edit2-msg)
