; $VER: Install 1.1 (21.11.2026)
;
; Installer script for Formbrod. This file is ISO-8859-1, like Installer
; expects; keep it that way when editing.
; It sits at the top of the unpacked archive, next to the Formbrod drawer,
; and copies that drawer with everything in it, and its icon, to wherever
; the user chooses.

(set #name "Formbrod")

; ---- Strings ------------------------------------------------------------
(if (= @language "svenska")
    (
        (set #welcome
            (cat "Det hr installerar Formbrd, en videoredigerare fr AmigaOS 4.\n\n"
                 "En lda som heter " #name " skapas dr du vljer."))
        (set #ask-dest "Var ska Formbrd installeras? En lda som heter Formbrod skapas hr.")
        (set #ask-help
            (cat "Vlj ldan som Formbrd ska installeras i. Installationen skapar "
                 "ldan " #name " dr, med programmet, dess ikon och katalogerna "
                 "fr versttningarna.\n\nFinns ldan redan skrivs filerna i den "
                 "ver, s du kan installera en ny version ovanp en gammal."))
        (set #copying "Kopierar Formbrd...")
        (set #same-dir "Formbrd r redan uppackat dr. Vlj en annan lda.")
        (set #done "Formbrd r installerat i\n")
    )
    (
        (set #welcome
            (cat "This installs Formbrod, a video editor for AmigaOS 4.\n\n"
                 "A drawer called " #name " is created where you choose."))
        (set #ask-dest "Where should Formbrod be installed? A drawer called Formbrod is created here.")
        (set #ask-help
            (cat "Choose the drawer to install Formbrd in. The installation creates "
                 "the drawer " #name " there, holding the program, its icon and the "
                 "catalogs for the translations.\n\nIf the drawer already exists, "
                 "its files are replaced, so you can install a new version over an "
                 "old one."))
        (set #copying "Copying Formbrod...")
        (set #same-dir "Formbrod is already unpacked there. Choose another drawer.")
        (set #done "Formbrod is installed in\n")
    )
)

; ---- Where we are -------------------------------------------------------
; The Formbrod drawer and its icon, next to this script.
(set #here    (expandpath (pathonly @icon)))
(set #srcdir  (tackon #here #name))
(set #srcicon (tackon #here (cat #name ".info")))

(message #welcome)

; ---- Where to ---------------------------------------------------------
(set #parent
    (askdir
        (prompt #ask-dest)
        (help #ask-help)
        (default @default-dest)
    )
)
(set #dest (tackon #parent #name))

(if (= (exists #dest) 2)
    (if (= (expandpath #dest) #srcdir)
        (abort #same-dir)
    )
)

; ---- Copy -------------------------------------------------------------
(complete 10)
(working #copying)

(if (<> (exists #dest) 2)
    (makedir #dest)
)

; The drawer icon.
(if (exists #srcicon)
    (copyfiles
        (source #srcicon)
        (dest #parent)
        (newname (cat #name ".info"))
        (nogauge)
    )
)

; Everything in the drawer, subdrawers (such as Catalogs) included.
(copyfiles
    (prompt #copying)
    (help @copyfiles-help)
    (source #srcdir)
    (dest #dest)
    (all)
)

(complete 100)

(set @default-dest #dest)
(exit (cat #done #dest))
