; Install script for PopPhone (Workbench 2.0+)
; (c) Copyright 1996 Jon Rocatis

(set ppdir "")

(set @app-name "PopPhone")

;=============================================================================
; make sure we are running under a 2.04 ROM

(if (< (/ (getversion) 65536) 37)
(
    (abort #bad-kick)
))

;=============================================================================
; which language should be used?

(if (patmatch @language "English") (set langval 0))
(if (patmatch @language "Deutsch") (set langval 1))

(if (= langval 0)
	(set lang 0)
	(set lang 1)
)

(set #bad-kick
        (select langval
                ("You must be using Kickstart 2.04 to install using this script!")
                ("Sie benötigen mindestens Kickstart 2.04, um dieses Installationsskript benutzen zu können!")
))

(set #where-popphone
        (select langval
                ("Where would you like to install PopPhone ?\n(A drawer called \"PopPhone\" will be created)")
                ("Wohin möchten Sie PopPhone installieren?\n(Ein Verzeichnis namens \"PopPhone\" wird automatisch angelegt)")
))

(set #executables
        (select langval
                ("Select the executables to install")
                ("Bitte wählen Sie das zu installierende Programm")
))

(set #executables-help
        (select langval
                (cat
                 "Select the executables to install. The 'executable' is the PopPhone program itself.\n\n"
                 "The different versions are optimized for the different CPUs, to get the most out of your system\n\n"
                 "You can run a 68000-executable on better CPU's, but you can only run the 68020-executable on a 68020 or better!"
                )
                (cat
                 "Wählen Sie die zu installierende Version von PopPhone."
                 "Die verschiedenen Versionen sind für verschiedene CPUs optimiert, um größtmögliche Leistung auf Ihrem System zu bieten.\n\n"
                 "Sie können die 68000-Version auf höheren CPUs starten, aber die 68020-Version läuft nur auf einem 68020 (oder besser)!"
                )

))

(set #which-language
        (select langval
                ("\nWhich additional languages should be installed?")
                ("\nWelche zusätzlichen Sprachen sollen installiert werden?")
))

(set #which-language-help
        (select langval
                (cat
                 "\nThe Amiga can be operated in many different"
                 " languages. If you want PopPhone to use the same"
                 " language as the Amiga Workbench"
                 " then a catalog file must be copied to your"
                 " harddisk for each language supported.\n\n"
                 "To reduce the amount of space consumed by the"
                 " language files, you can select to have only the"
                 " files of specific languages copied.\n\n"
                 "Simply check the boxes of the languages you wish"
                 " to have available on your system.\n\n"
                 "This feature is only available on Workbench 2.1 or better!\n"
                )
                (cat
                 "\nDer Amiga kann in vielen verschiedenen Sprachen"
                 " betrieben werden. Wenn Sie wollen, daß PopPhone"
                 " dieselbe Sprache wie die Workbench benutzt, dann"
                 " muß eine entsprechende Catalog-Datei auf die"
                 " Festplatte kopiert werden.\n\n"
                 "Um Speicherplatz zu sparen, können Sie auswählen,"
                 " welche Sprachen installiert werden sollen und"
                 " welche nicht.\n\n"
                 "Klicken Sie einfach die Sprachen an, die Sie auf"
                 " Ihrem System installiert haben möchten.\n\n"
                 "Die Sprachanpassung wird erst ab WB 2.1 unterstützt!\n"
                )
))

(set #which-doc
        (select langval
                ("\nSelect language for the online help")
                ("\nWählen Sie die Sprache für die Online-Hilfe")
))

(set #which-doc-help
        (select langval
                ("\nPopPhone comes with both English and German online help")
                ("\nPopPhone verfügt über englische und deutsche Online-Hilfe")
))

(set #install-msg
        (select langval
                (cat
                 "\n\nPopPhone installation script.\n"
                 "This script installs PopPhone on your Amiga.\n\n"
                 "Read the PopPhone AmigaGuide for more information\n"
                 "on the distribution of PopPhone.\n\n"
                 "PopPhone © 1995 Jon Rocatis\n"
                 "All rights reserved."
                )
                (cat
                 "\n\nPopPhone Installationsskript.\n"
                 "Dieses Skript installiert PopPhone auf Ihrem Amiga.\n\n"
                 "Lesen Sie die PopPhone AmigaGuide-Datei für mehr\n"
                 "Informationen über das Programm.\n\n"
                 "PopPhone © 1995 Jon Rocatis\n"
                 "Alle Rechte vorbehalten."
                )
))

(set #ctfiles
        (select langval
                ("\nDo you want the necessary files to create your own catalog files?")
                ("\nMöchten Sie die benötigten Dateien, um eigene Übersetzungen zu machen?")
))

(set #ctfiles-help
        (select langval
                ("\nThe files are only needed if you want to translate PopPhone yourself.")
                ("\nDie Dateien werden nur benötigt, falls Sie PopPhone selbst übersetzen wollen.")
))

(set #yes
        (select langval
                ("Yes")
                ("Ja")
))

(set #no
        (select langval
                ("No")
                ("Nein")
))

;=============================================================================

(message #install-msg)

(set ppdestdir
        (tackon
                (askdir
                        (prompt #where-popphone)
                        (help @askdir-help)
                        (default @default-dest)
                )
                "PopPhone"
        )
)

(makedir ppdestdir)

(set @default-dest ppdestdir)

;----

(set helplang
        (askoptions
                (prompt #which-language)
                (help #which-language-help)
                (choices "Deutsch" "Dansk" "Français")
                (default lang)
        )       
)

(if (> helplang 0)
        (
                ;Catalogs wanted..

                (makedir (tackon ppdestdir "Catalogs"))
                (set catdir (tackon ppdestdir "Catalogs"))

                (if (BITAND 1 helplang)
                        (copyfiles
                                (source (tackon "Catalogs" "Deutsch"))
                                (dest (tackon catdir "Deutsch"))
                                (all)
                        )
                )

                (if (BITAND 2 helplang)
                        (copyfiles
                                (source (tackon "Catalogs" "Dansk"))
                                (dest (tackon catdir "Dansk"))
                                (all)
                        )
                )

                (if (BITAND 4 helplang)
                        (copyfiles
                                (source (tackon "Catalogs" "Français"))
                                (dest (tackon catdir "Français"))
                                (all)
                        )
                )
        )
)

; -----------

(set localechoice
        (askbool
                (prompt #ctfiles)
                (help #ctfiles-help)
                (choices #yes #no)
                (default 0)
        )
)

(if (= localechoice 1)
        (copyfiles
                (source (tackon ppdir "Locale"))
                (dest (tackon ppdestdir "Locale"))
                (infos)
                (all)
        )
)

; --------

(set docs
        (askchoice
                (prompt #which-doc)
                (help #which-doc-help)
                (choices "English" "Deutsch")
                (default lang)
        )       
)

;--- Make dir and copy PopPhone itself

(makedir ppdestdir (infos))

(copyfiles
        (source (tackon ppdir "PopPhone"))
        (dest ppdestdir)
        (infos)
)

;-- Copy the online docs

(if (= docs 0)
        (set docext "")
        (set docext ".deutsch")
)

(copyfiles
        (source (tackon ppdir (cat "PopPhone.guide" docext)))
        (dest ppdestdir)
        (newname (tackon ppdestdir "PopPhone.guide"))
)

(copyfiles
        (source (tackon ppdir (cat "PopPhone.guide" docext ".info")))
        (dest ppdestdir)
        (newname (tackon ppdestdir "PopPhone.guide.info"))
)

;-- Use AmigaGuide for guide viewing if user is running KS2.0

(if (< (/ (getversion) 65536) 39)
(
        (tooltype
                (dest (tackon ppdestdir "PopPhone.guide"))
                (setdefaulttool "SYS:Utilities/AmigaGuide")
        )
))

;----

(copyfiles
        (source (tackon ppdir "Readme.mui"))
        (dest ppdestdir)
        (infos)
)

(if (< (/ (getversion) 65536) 39)
(
        (tooltype
                (dest (tackon ppdestdir "Readme.mui"))
                (setdefaulttool "SYS:Utilities/More")
        )
))

;----

