(set #lib "libs/reqtools.library")
(set #tf "gadgets/textfield.gadget")

(if (= "deutsch" @language)
(
    (set #welcome "\nDieses Skript installiert AFiloFaxPro und alle dazugehrigen Dateien auf Ihrer Festplatte.\n\nAFiloFaxPro  1995-96 by Frank Weber.")
    (set #destprompt "Bitte Zielverzeichnis whlen.\n(Ein Verzeichnis 'AFiloFaxPro' wird dort erstellt.)")
    (set #desthelp "Sie mssen hier das Verzeichnis whlen, in dem die 'AFiloFaxPro'-Schublade erstellt werden soll.\n\nIn diese Schublade werden dann AFiloFaxPro und alle dazugehrigen Dateien kopiert.")
    (set #overwritemsg "\nAFiloFaxPro wurde bereits in dieses Verzeichnis installiert.\n\nAltes AFiloFaxPro-Verzeichnis lschen ???")
    (set #overwritehelp "In dem Verzeichnis, das Sie ausgewhlt haben, existiert bereits ein Verzeichnis mit dem Namen 'AFiloFaxPro'.\n\nAntworten Sie 'Ja', wenn Sie das alte Verzeichnis komplett lschen mchten, bevor diese Version installiert wird.")
    (set #copyafc "Wohin soll das Hintergrundprogramm AFiloCron kopiert werden?")
    (set #copyafchelp "AFiloCron ist das Hintergrundprogramm, das stndig ber evtl. auftretende Termine wacht und auch die Statistikdateien erstellt.\n\nEs sollte immer aktiv sein, darum sollten Sie es im WBStartup-Verzeichnis installieren.")
    (set #copysampletext "\nMchten Sie die mitgelieferten Samples installieren ???")
    (set #copysamplehelp "AFiloCron kann bei einem auftretenden Ereignis ein Soundsample abspielen.\n\nEs werden einige Samples mitgeliefert, Sie verbrauchen ca. 100 KB an Platz auf der Festplatte.")
    (set #copyreqtools "\nReqtools.library kopieren...")
    (set #copytf "\ntextfield.gadget kopieren...")
    (set #demouser "Bitte denken Sie daran, da das AFiloFaxPro-Paket Shareware ist. Wenn Sie es kennengelernt haben und regelmig benutzen, sollten Sie sich bei mir fr nur 25 DM registrieren lassen. Nur durch Ihre Untersttzung wird die Weiterentwicklung von AFiloFaxPro sichergestellt.")
    (set #keyfileuser "Nochmals vielen Dank fr Ihre Registration. Bitte geben Sie das Keyfile, das Ihren Namen und Ihre Adresse enthlt, nicht weiter. Nur durch Ihre Untersttzung wird die Weiterentwicklung von AFiloFaxPro sichergestellt.")
)
(
    (set #welcome "\nThis script will install AFiloFaxPro and all supported files onto your Harddisk.\n\nAFiloFaxPro  1995-96 by Frank Weber.")
    (set #destprompt "Please choose destination path.\n(A drawer called 'AFiloFaxPro' will be created there.)")
    (set #desthelp "Here you have to choose where the 'AFiloFaxPro' drawer should be created.\n\nAFiloFaxPro and all supported files will be copied into the 'AFiloFaxPro' directory.")
    (set #overwritemsg "\nAFiloFaxPro has already been installed into this directory.\n\nDelete old directory ???")
    (set #overwritehelp "There is already a directory called 'AFiloFaxPro' in the directory chosen by you.\n\nSelect yes if you want the whole directory to be deleted before this version is installed.")
    (set #copyafc "Where is the AFiloCron to be installed?")
    (set #copyafchelp "AFiloCron is the background task waiting for events to occur.\n\nIs it should always be running, so you should place it in your 'WBStartup' drawer.")
    (set #copysampletext "\nWould you like to install the supported samples ???")
    (set #copysamplehelp "AFiloCron can play a soundsample when an event occurs.\n\nSome samples are supported in this archive, they will use about 100 KB of space.")
    (set #copyreqtools "\nInstalling reqtools.library")
    (set #copytf "\nInstalling textfield.gadget")
))
(set #nohelp " ")

(complete 0)
(message #welcome)
(complete 8)

(set #default-dir "SYS:")
(set @default-dest "SYS:")

(set #dest (askdir (prompt #destprompt)
                   (help #desthelp)
                   (default @default-dest)
           )
)

(set #affdrawer (tackon #dest "AFiloFaxPro"))
(set @default-dest #dest)

(complete 18)

(if (exists #affdrawer)
(
  (if (> @user-level 1)
  (
    (set #overwrite (askbool
                           (prompt #overwritemsg)
                           (help #overwritehelp)
                           (default 0)
                   )
    )
    (if (= 1 #overwrite)
      (run (cat "c:delete QUIET ALL " #affdrawer))
    )
  ))
))

(complete 30)

(makedir #affdrawer (infos))

(copyfiles  (source "AFiloFax")
            (dest #affdrawer)
            (infos)
)

(complete 38)

(copyfiles  (source "Anleitung.guide")
            (dest #affdrawer)
            (infos)
)

(complete 44)

(copyfiles  (source "Readme")
            (dest #affdrawer)
            (infos)
)

(copyfiles  (source "Liesmich")
            (dest #affdrawer)
            (infos)
)

(copyfiles  (source "RegiTool")
            (dest #affdrawer)
            (infos)
)

(complete 50)

(makedir (tackon #affdrawer "pics"))

(copyfiles (source "pics/")
           (dest (tackon #affdrawer "pics"))
           (pattern "#?")
)

(complete 57)

(set #afcdest (askdir (prompt #copyafc)
                     (help #copyafchelp)
                     (default "SYS:WBStartup")
             )
)

(complete 61)

(copyfiles  (source "AFiloCron")
            (dest #afcdest)
            (infos)
)

(complete 68)

(if (askbool (prompt #copysampletext)
             (help #copysamplehelp)
    )
(
    (makedir (tackon #affdrawer "samples"))
    (copyfiles (source "samples/")
               (dest (tackon #affdrawer "samples"))
               (pattern "#?")
    )
))

(complete 78)

(copylib    (prompt #copyreqtools)
            (help #nohelp)
            (source #lib)
            (dest "LIBS:")
            (confirm)
)

(complete 84)

(copylib    (prompt #copytf)
            (help #nohelp)
            (source #tf)
            (dest "LIBS:gadgets")
            (confirm)
)

(complete 90)

(tooltype (dest (tackon #affdrawer "AFiloFax"))
          (settooltype "REGITOOL" (tackon #affdrawer "RegiTool"))
)

(tooltype (dest (tackon #afcdest "AFiloCron"))
          (settooltype "REGITOOL" (tackon #affdrawer "RegiTool"))
)

(tooltype (dest (tackon #affdrawer "AFiloFax"))
          (settooltype "DOC" (tackon #affdrawer "Anleitung.guide"))
)

(tooltype (dest (tackon #afcdest "AFiloCron"))
          (settooltype "DOC" (tackon #affdrawer "Anleitung.guide"))
)

(tooltype (dest (tackon #afcdest "AFiloCron"))
          (settooltype "AFILOFAX" (tackon #affdrawer "AFiloFax"))
)

(complete 93)

(if (< (/ (getversion) 65536) 38)
    (tooltype (dest (tackon #affdrawer "Anleitung.guide"))
              (setdefaulttool "sys:utilities/AmigaGuide")
    )

    (tooltype (dest (tackon #affdrawer "Anleitung.guide"))
              (setdefaulttool "sys:utilities/Multiview")
    )

)

(complete 95)

(if (not (exists "s:aff_data"))
  (makedir "s:aff_data")
)

(complete 96)

(set #keycopied 0)

(if (exists "AFF.key")
(
    (set #keycopied 1)
    (copyfiles (source "AFF.key")
               (dest "S:")
    )

    (tooltype (dest (tackon #affdrawer "AFiloFax"))
              (settooltype "KEYFILE" "S:AFF.key")
    )
    (tooltype (dest (tackon #afcdest "AFiloCron"))
              (settooltype "KEYFILE" "S:AFF.key")
    )


))

(complete 100)

(if #keyfilecopied
    (set #schlusstext #keyfileuser)
    (set #schlusstext #demouser)
)

(exit (cat ("Installation abgeschlossen!\n\"%s\" finden Sie nun in Ihrer Schublade (oder Partition)\n\"%s\".\n\nZustzlich zu diesem Archiv gibt es noch ein Support-Archiv, das eine Anleitung im HTML-Format und das Extra-Samples Paket Nr. 1 enthlt.\n\n" @app-name @default-dest) #schlusstext) (quiet))

