;
; Install script for MUI Fido File Request
;
; $VER: Installation MUIFFR V1.2 (10.04.94)
;

(set @default-dest "")

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

(set default_lang 1)

(set #bad-kick "MUIFFR only runs under OS 2.04 or higher!\n")

(set #install-msg
    (cat "\n\nMUI Fido File Request installation script.\n"
         "This script installs MUIFFR on your Amiga.\n\n"
         "Read the documentation for\n"
         "further information on MUIFFR.\n\n"
         "MUI Fido File Request  1994 Martin Steppler\n"
         "All rights reserved."
    )
)

(set #update-msg
    (cat "\nIf this is an update from 1.1 to 1.2 you\n"
         "may install 1.2 over 1.1. Your old 1.1 configuation\n"
         "file will *NOT* be overwritten.\n\n"
         "You only have to adapt your configuration to 1.2\n"
         "after the installation, if you want to make use of\n"
         "the new 1.2 features. (See ReadMe file)\n"
    )
)

(set #ask-destination
    (cat "Enter the name of the destination-directory!"
    )
)

(set #ask-destination-msg
    (cat "\nEnter the name of the directory, you wish to\n"
         "install MUIFFR to. A directory called MUIFFR will\n"
         "automatically be created in this directory\n"
         "All other files will be stored in the directory MUIFFR.\n\n"
         "This is why you do not have to create a directory\n"
         "on your own.\n"
    )
)

(set #which-language
    (cat "Which languages (incl. documentation) are to\n"
         "be installed?\n"
    )
)

(set #ask-font
    (cat "Do you want to install an IBM font, too?")
)

(set #ask-dest_font
    (cat "Where do you want to install the IBM font to?")
)

(set #yes "Yes")
(set #no "No")

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

(if (= @language "deutsch")
(

    (set default_lang 2)

    (set #bad-kick "MUIFFR luft nur unter OS 2.04 oder besser!\n")

    (set #install-msg
        (cat "\n\nMUI Fido File Request Installationsskript.\n"
             "Diese Befehlsdatei installiert MUIFFR auf Ihrem\n"
             "Amiga. Lesen Sie die Dokumentation fr\n"
             "weitere Informationen ber MUIFFR.\n\n"
             "MUI Fido File Request  1994 Martin Steppler\n"
             "All rights reserved."
        )
    )

    (set #update-msg
        (cat "\nIm Falle eines Updates von 1.1 auf 1.2, knnen\n"
             "Sie 1.2 ber 1.1 installieren. Ihre alte 1.1 Kon-\n"
             "figuration wird *NICHT* berschrieben.\n\n"
             "Sie mssen nur nach der Installation Ihre Konfigu-\n"
             "ration auf 1.2 anpassen, wenn Sie von den neuen 1.2\n"
             "Funktionen Gebrauch machen wollen. (Siehe LiesMich)\n"
        )
    )

    (set #ask-destination
        (cat "Geben Sie das Zielverzeichnis an!"
        )
    )

    (set #ask-destination-msg
        (cat "\nGeben Sie den Namen des Verzeichnisses an, wohin\n"
             "MUIFFR installiert werden soll. In diesem\n"
             "Verzeichnis wird automatisch ein Verzeichnis MUIFFR\n"
             " erzeugt, in dem die weiteren Dateien abgelegt werden.\n\n"
             "Sie brauchen also kein Verzeichnis selbst anlegen."
        )
    )

    (set #which-language
        (cat "Welche Sprachen (inkl. Dokumentation) sollen\n"
             "installiert werden?\n"
        )
    )

    (set #ask-font
        (cat "Soll der IBM-Zeichensatz ebenfalls installiert werden?")
    )

    (set #ask-dest_font
        (cat "Wohin soll der IBM-Zeichensatz installiert werden?")
    )

    (set #yes "Ja")
    (set #no "Nein")
))

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

(complete 0)

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

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

(message #install-msg)

(complete 5)

(message #update-msg)

(complete 10)

(message #ask-destination-msg)

(complete 15)

; ask user where to install MUIFFR to
(set @default-dest
    (tackon
        (askdir
            (prompt #ask-destination)
            (help @askdir-help)
            (default "Work:")
        )
        "MUIFFR"
    )
)

(complete 20)

; ask user which languages are to be installed
(set lang
    (askoptions
        (prompt #which-language)
        (help @askoptions-help)
        (choices "english"
                 "deutsch"
        )
        (default default_lang)
    )
)

(complete 30)

(set inst_font
    (askbool
        (prompt #ask-font)
        (help @askbool-help)
        (choices #yes #no)
    )
)

(complete 35)

(if (= 1 inst_font)
(
    (set dest_font
        (askdir
            (prompt #ask-dest_font)
            (help @askdir-help)
            (default "Fonts:")
        )
    )
))

(complete 40)

;-----------------------------------------------------------------------------
; copy all language non-specific files

(copyfiles
    (source "/")
    (dest @default-dest)
    (pattern "(MUIFidoFileRequest|ReadMe.mui|List)#?")
    (infos)
)

(complete 50)

; copy configuration file if it does not already exist
(if (= 0 (exists (cat @default-dest "/muiffr.config") (noreq)))
(
    (copyfiles
        (source "/muiffr.config")
        (dest @default-dest)
    )
))

(complete 60)

; no catalogs, if only "deutsch" or nothing was specified
; do not create dir if dir already exists
(set catalogsdir (cat @default-dest "/Catalogs"))
(if (AND (<> 2 lang) (<> 0 lang))
(
    (if (= 0 (exists catalogsdir (noreq)))
    (
        (makedir catalogsdir)
    ))
))

(complete 70)

; copy all language specific files
(set n 0)
(while
    (set language
        (select n "english"
                  "deutsch"
                  ""
        )
    )
(
    (if (IN lang n)
    (
        ; copy Catalog files
        (if (<> 1 n)
        (
            (copyfiles
                (source
                    (cat "/Catalogs/" language)
                )
                (dest
                    (cat @default-dest "/Catalogs/" language)
                )
                (all)
            )
        ))

        ; copy readme file
        (copyfiles
            (source
                (select n "/ReadMe"
                          "/LiesMich"
                )
            )
            (dest @default-dest)
            (infos)
        )
    ))
    (set n (+ n 1))
))

(complete 90)

; install IBM fonts
(if (= 1 inst_font)
(
    (copyfiles
        (source "/Fonts")
        (dest dest_font)
        (pattern "IBM")
        (fonts)
    )
))

; so long and thanks for all the fish
(complete 100)
