; $VER: Install-MUI 3.0 (05.10.95)
; Script to install MagicUserInterface Release 3

(complete 0)



;=============================================================================
; German strings

(if (= @language "deutsch")
(

(set #intro
(cat "Mit diesem Programm wird Version 3 von MagicUserInterface im "
  	  "System installiert. Bereits vorhandene Versionen von MUI werden "
     "ersetzt. MUI 3 ist abwrtskompatibel mit alten Versionen, alle "
     "sauber geschriebenen MUI Programme werden weiter funktionieren "
     "und automatisch von den neuen Features profitieren."
))

(set #oldmui "\nEs existiert eine alte Version von MUI im Verzeichnis ")

(set #oldmuibak
(cat "Das Installationsprogramm wird dieses Verzeichnis umbenennen in "
     "'MUI_old' und fr MUI 3 ein neues Verzeichnis erstellen. Alle "
     "Dateien aus der alten Installation bleiben erhalten."
     "\n\nWenn Ihnen MUI 3 gefllt, sollten Sie das 'MUI_old' nach "
     "einiger Zeit lschen."
))

(set #oldmuidel
(cat "Auerdem wurde eine Sicherheitkopie ('MUI_old') einer frheren "
     "MUI Installation gefunden. Es wird angenommen, da diese Kopie "
     "aktuell ist, deswegen wird keine neue mehr angelegt. "
     "Falls Sie fortfahren, werden demnach alle Dateien im Verzeichnis "
))

(set #oldmuidel2 "gelscht und ersetzt.")

(set #destdir
(cat "Bitte whlen Sie einen Platz fr MUI 3. "
     "Ein Verzeichnis namens 'MUI' wird automatisch erzeugt. "
     "Der minimale Platzbedarf betrgt 500 kB, "
     "eine Komplett-Installation bentigt etwa 2.5 MB."
))

(set #destexists
(cat "Im gewhlten Zielverzeichnis existiert bereits eine MUI-Schublade. "
     "Wenn Sie fortfahren, wird der Inhalt dieser Schublade gelscht und "
     "durch die neuen Dateien ersetzt."
))

(set #guideask
(cat "Bitte whlen Sie die Sprache(n) fr die AmigaGuide Dokumentation aus. "
     "Diese wird unter anderem fr die Online-Hilfe im Voreinsteller und "
     "Screen Manager bentigt."
))

(set #dviask
(cat "Bitte whlen Sie die Sprache(n) fr die DVI Dokumentation aus. "
     "DVI Dokumentationen werden hauptschlich zum Ausdrucken bentigt."
))

(set #imgask
(cat "Whlen Sie die zustzlichen Image-Pakete aus, die Sie installieren mchten."
))

(set #nainfo1 "Mit")
(set #nainfo2 "(n/a)")
(set #nainfo3 "markierte Elemente sind aus Platzmangel im aktuellen Installations-Archiv nicht verfgbar.")

(set #copydoc1 "Kopiere")
(set #copydoc2 "Dokumentation")

(set #copydoc3
(cat "ist im aktuellen Installations-Archiv nicht verfgbar, sie "
     "wurden aus Platzmangel weggelassen. MUI bentigt diese "
     "Dateien nicht zur korrekten Funktion."
))

))



;=============================================================================
; English strings

(if (= @language "english")
(

(set #intro
(cat "This program lets you install release 3 of MagicUserInterface "
  	  "on your system. It can be used to upgrade an older release or to "
     "install from scratch. MUI 3 is backwards compatible with previous "
     "versions, all properly written MUI applications will continue to "
     "work and will automatically benefit from several new features."
))

(set #oldmui "\nThere is already a version of MUI installed in the directory ")

(set #oldmuibak
(cat "The installer program will rename this directory away to "
     "'MUI_old' and create a different directory for the new MUI 3 "
     "installation. No files of your old installation will be overwritten."
     "\n\nYou should delete the 'MUI_old' directory after you have given "
     "MUI 3 a try and decided that you like it!"
))

(set #oldmuidel
(cat "Furthermore, a backup of a previously installed MUI was found. "
     "The installation utility assumes that this backup is current "
     "and will not backup your MUI installation again. If you proceed, "
     "all the files in the directory"
))

(set #oldmuidel2 "will be deleted and updated.")

(set #destdir
(cat "Please select a place for the MUI 3 package. "
     "A drawer called 'MUI' will be created here. "
     "The minimum space required is about 500 kB, "
     " a complete installation takes 2.5 MB."
))

(set #destexists
(cat "A MUI drawer does already exists in your selected destination directory. "
     "By proceeding, you indicate that you wish to delete the "
     "contents of this drawer and replace them with the new "
     "installation."
))

(set #guideask
(cat "Select the language(s) of AmigaGuide documentations you wish "
     "to install. You must choose at least one language if you want "
     "to use online help with the MUI preferences programs."
))

(set #dviask
(cat "Select the language(s) of DVI documentations you wish "
     "to install. DVI docs are mainly useful for printing."
))

(set #imgask
(cat "Select the image set(s) you wish to install."
))

(set #nainfo1 "Items marked as")
(set #nainfo2 "(n/a)")
(set #nainfo3 "are not available in the current installation archive due to space considerations.")

(set #copydoc1 "Copying")
(set #copydoc2 "documenation")

(set #copydoc3
(cat "is not present in the current installation archive. "
     "It has probably been left out due to space considerations. "
     "However, MUI will run fine without those files."
))

))



;=============================================================================
; procedure COPYDOC
;
; cd_language - language
; cd_name     - "MUI.guide" or "MUI.dvi"

(procedure COPYDOC
(
	(set cdsrc (cat "/Docs/" cd_language "/" cd_name))
	(set cddst (tackon (tackon destination "Docs") cd_language))

	(if (<> (exists cdsrc (noreq)) 0)
	(
		(run (cat "copy " "/Docs/" cd_language ".info " (cat cddst ".info") ))

		(copyfiles
			(prompt (cat #copydoc1 " " cd_language " " cd_name " " #copydoc2 "..."))
			(source cdsrc)
			(dest cddst)
			(infos)
			(help @copyfiles-help)
		)
	)
	(
		(message cd_name " (" cd_language ") " #copydoc3)
	))
))



;=============================================================================
; procedure COPYIMAGEDIR
;
; ci_dir - image dir name

(procedure COPYIMAGEDIR
(
	(set cdsrc (cat "/Images/" ci_dir))
	(set cddst (tackon (tackon destination "Images") ci_dir))

	(if (<> (exists cdsrc (noreq)) 0)
	(
		(copyfiles
			(prompt (cat #copydoc1 " " ci_dir "..."))
			(source cdsrc)
			(dest cddst)
			(all)
			(help @copyfiles-help)
		)
	)
	(
		(message ci_dir " " #copydoc3)
	))
))



;=============================================================================
; Say hello

(set @default-dest "SYS:")
(message #intro)



;=============================================================================
; Check for an old MUI installation

(complete 4)

(if (<> (exists "mui:" (noreq)) 0)
(
	(set @default-dest (expandpath "mui:/"))
	(set muidir (tackon @default-dest "MUI"))
	(set olddir (tackon @default-dest "MUI_old"))

	(run "assign mui: remove")

	(if (<> (exists olddir (noreq)) 0)
	(
		(message #oldmui "'" @default-dest "'. " #oldmuidel " '" muidir "' " #oldmuidel2)
		(run (cat "delete " muidir " all >nil:"))
		(run (cat "delete " muidir ".info >nil:"))
	)
	(
		(message #oldmui "'" @default-dest "'." #oldmuibak)
		(rename muidir olddir)
		(rename (cat muidir ".info") (cat olddir ".info"))
	))
))



;=============================================================================
; Ask for destination directory

(set @default-dest
	(askdir
		(prompt #destdir)
		(help @askdir-help)
		(default @default-dest)
	)
)

(set @default-dest (expandpath @default-dest))
(set destination (tackon @default-dest "MUI"))

(if (<> (exists destination) 0)
(
	(message #destexists)
	(run (cat "delete " destination " all >nil:"))
	(run (cat "delete " destination ".info >nil:"))
))



;=============================================================================
; Lets go, create destination directory, copy main files and libs

(complete 4)

(makedir destination (help @makedir-help))
(run (cat "copy " "//MUI.info \"" destination ".info\""))

(complete 8)

(copyfiles
	(prompt "Copying main files...")
	(source "/")
	(pattern "(ReadMe|LiesMich|MUI|PSI)")
	(dest destination)
	(infos)
	(help @copyfiles-help)
)

(complete 12)

(copyfiles
	(prompt "Copying libraries and classes...")
	(source "/Libs")
	(all)
	(dest (tackon destination "Libs"))
	(infos)
	(help @copyfiles-help)
)
(run (cat "copy " "/Libs.info \"" destination "\""))


;=============================================================================
; Icons Drawer

(complete 16)

(if (<> (exists "/Icons" (noreq)) 0)
(
	(copyfiles
		(prompt "Copying default icons...")
		(source "/Icons")
		(dest (tackon destination "Icons"))
		(all)
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Icons.info \"" destination "\""))
)
)


;=============================================================================
; Docs Drawer

(complete 20)

(if (<> (exists "/Docs" (noreq)) 0)
(
	(copyfiles
		(prompt "Creating Docs Drawer...")
		(source "/Docs")
		(dest (tackon destination "Docs"))
		(choices "Registration" "Changes" "ImageDesign" "Preview")
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Docs.info \"" destination "\""))

	(if (<> (exists "/Docs/English/MUI.guide") 0)
	((set guide_english "English") (if (= @language "English") ((set defchoice 1))) )
	((set guide_english (cat "English " #nainfo2))))

	(if (<> (exists "/Docs/Deutsch/MUI.guide") 0)
	((set guide_german "Deutsch") (if (= @language "Deutsch") ((set defchoice 2))) )
	((set guide_german (cat "Deutsch " #nainfo2))))

	(if (<> (exists "/Docs/Franais/MUI.guide") 0)
	((set guide_french "Franais") (if (= @language "Franais") ((set defchoice 4))) )
	((set guide_french (cat "Franais " #nainfo2))))

	(set choice
		(askoptions
			(prompt (cat #guideask " " #nainfo1 " " #nainfo2 " " #nainfo3))
			(choices guide_english guide_german guide_french)
			(default defchoice)
			(help @askoptions-help)
		)
	)

	(set cd_name "MUI.guide")

	(complete 24)

	(if (<> 0 (BITAND choice 1))
	(
		(set cd_language "English")
		(COPYDOC)
	))

	(complete 28)

	(if (<> 0 (BITAND choice 2))
	(
		(set cd_language "Deutsch")
		(COPYDOC)
	))

	(complete 32)

	(if (<> 0 (BITAND choice 4))
	(
		(set cd_language "Franais")
		(COPYDOC)
	))

	(complete 36)

	(if (<> (exists "/Docs/English/MUI.dvi") 0)
	((set dvi_english "English"))
	((set dvi_english (cat "English " #nainfo2))))

	(if (<> (exists "/Docs/Deutsch/MUI.dvi") 0)
	((set dvi_german "Deutsch"))
	((set dvi_german (cat "Deutsch " #nainfo2))))

	(if (<> (exists "/Docs/Franais/MUI.dvi") 0)
	((set dvi_french "Franais"))
	((set dvi_french (cat "Franais " #nainfo2))))

	(set choice
		(askoptions
			(prompt (cat #dviask " " #nainfo1 " " #nainfo2 " " #nainfo3))
			(choices dvi_english dvi_german dvi_french)
			(default defchoice)
			(help @askoptions-help)
		)
	)

	(set cd_name "MUI.dvi")

	(complete 40)

	(if (<> 0 (BITAND choice 1))
	(
		(set cd_language "English")
		(COPYDOC)
	))

	(complete 44)

	(if (<> 0 (BITAND choice 2))
	(
		(set cd_language "Deutsch")
		(COPYDOC)
	))

	(complete 48)

	(if (<> 0 (BITAND choice 4))
	(
		(set cd_language "Franais")
		(COPYDOC)
	))
)
)



;=============================================================================
; Images Drawer

(complete 52)

(if (<> (exists "/Images" (noreq)) 0)
(
	(if (<> (exists "/Images/XEN") 0)
	((set img_xen "Martin 'MagicWB' Huttenloher"))
	((set img_xen (cat "Martin 'MagicWB' Huttenloher " #nainfo2))))

	(if (<> (exists "/Images/Goonie") 0)
	((set img_goonie "Andreas 'Goonie' Schildbach"))
	((set img_goonie (cat "Andreas 'Goonie' Schildbach " #nainfo2))))

	(if (<> (exists "/Images/KT") 0)
	((set img_kt "Christian 'Kochtopf' Scholz"))
	((set img_kt (cat "Christian 'Kochtopf' Scholz " #nainfo2))))

	(if (<> (exists "/Images/WD") 0)
	((set img_wd "Walter Drwald"))
	((set img_wd (cat "Walter Drwald " #nainfo2))))

	(if (<> (exists "/Images/kmel") 0)
	((set img_kmel "Klaus 'kmel' Melchior"))
	((set img_kmel (cat "Klaus 'kmel' Melchior " #nainfo2))))

	(set choice
		(askoptions
			(prompt (cat #imgask " " #nainfo1 " " #nainfo2 " " #nainfo3))
			(choices img_xen img_goonie img_kt img_wd img_kmel)
			(help @askoptions-help)
		)
	)

	(complete 56)

	(makedir (tackon destination "Images"))
	(run (cat "copy " "/Images.info \"" destination "\""))

	(complete 60)

	(if (<> 0 (BITAND choice 1))
	(
		(set ci_dir "XEN")
		(COPYIMAGEDIR)
	))

	(complete 64)

	(if (<> 0 (BITAND choice 2))
	(
		(set ci_dir "Goonie")
		(COPYIMAGEDIR)
	))

	(complete 68)

	(if (<> 0 (BITAND choice 4))
	(
		(set ci_dir "KT")
		(COPYIMAGEDIR)
	))

	(complete 72)

	(if (<> 0 (BITAND choice 8))
	(
		(set ci_dir "WD")
		(COPYIMAGEDIR)
	))

	(complete 76)

	(if (<> 0 (BITAND choice 16))
	(
		(set ci_dir "kmel")
		(COPYIMAGEDIR)
	))

	(complete 80)

	(set ci_dir "Misc")
	(COPYIMAGEDIR)
)
)



;=============================================================================
; Rexx Drawer

(complete 84)

(if (<> (exists "/Rexx" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing example ARexx scripts...")
		(source "/Rexx")
		(dest (tackon destination "Rexx"))
		(infos)
		(all)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Rexx.info \"" destination "\""))
)
)


;=============================================================================
; Catalogs

(complete 86)

(if (<> (exists "/Locale" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing catalogs...")
		(source "/Locale")
		(dest (tackon destination "Locale"))
		(all)
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Locale.info \"" destination "\""))
)
)



;=============================================================================
; Presets

(complete 88)

(if (<> (exists "/Presets" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing presets...")
		(source "/Presets")
		(dest (tackon destination "Presets"))
		(all)
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Presets.info \"" destination "\""))
)
)



;=============================================================================
; Presets

(complete 89)

(if (<> (exists "/Goodies" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing Goodies...")
		(source "/Goodies")
		(dest (tackon destination "Goodies"))
		(all)
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Goodies.info \"" destination "\""))
)
)



;=============================================================================
; Patterns

(complete 90)

(if (<> (exists "/Patterns" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing patterns...")
		(source "/Patterns")
		(dest (tackon destination "Patterns"))
		(all)
		(infos)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Patterns.info \"" destination "\""))
)
)



;=============================================================================
; Demos

(complete 92)

(if (<> (exists "/Demos" (noreq)) 0)
(
	(copyfiles
		(prompt "Installing demonstration programs...")
		(source "/Demos")
		(dest (tackon destination "Demos"))
		(infos)
		(all)
		(help @copyfiles-help)
	)
	(run (cat "copy " "/Demos.info \"" destination "\""))
)
)



;=============================================================================
; Startup Sequence

(complete 96)

(startup "MUI"
	(prompt "Some commands will be added to your \"s:user-startup\" file.")
	(help @startup-help)
	(command "if exists \"" destination "\"\n")
	(command "   assign MUI: \"" destination "\"\n")
	(command "   if exists MUI:Libs\n")
	(command "      assign add LIBS: MUI:Libs\n")
	(command "   endif\n")
	(command "   if exists MUI:Locale\n")
	(command "      assign add LOCALE: MUI:Locale\n")
	(command "   endif\n")
	(command "   version >nil: exec.library 39\n")
	(command "   if not warn\n")
	(command "      if exists MUI:Docs\n")
	(command "         if exists HELP:dummy ; do not remove\n")
	(command "         endif                ; this entry!\n")
	(command "         assign add HELP: MUI:Docs\n")
	(command "      endif\n")
	(command "   endif\n")
	(command "endif")
)


;=============================================================================
; Finish

(complete 99)

(run (cat "assign mui: " "\"" destination "\""))


;***** Finished

(complete 100)

(exit "Please reboot your computer before trying to start any MUI programs.")
