;
; Beyond The Dark 1.0 - Install Script
;
; (c) 1995 by Matthias Scheler <tron@lyssa.owl.de>
;

(set ProductName "Beyond The Dark")
(set ProductVers "1.0")

(set MUIName "muimaster.library")
(set MUIVersion 8)
(set MUIRelease "2.1")

(set BTDDrawer "BeyondTheDark" )

(if (= @language "english")
 (
  (set #install "Installing ")

  (set #wrong_os
   (cat
    "Looks like you are running WB 1.3. If this is true, "
    "please consider to update to WB 2.04 or newer real soon. "
    "\"\%s\" does not work with WB 1.3 and below."
   )
  )

  (set #wrong_mui
   (cat
    ProductName " needs at least " MUIName " version " MUIVersion
    " (Release " MUIRelease "). You seem to have installed version %ld.\n\n"
    "Of course you can continue the installation, but don't forget to "
    "update MUI later."
   )
  )
  (set #no_mui
   (cat
    "You don't seem to have MUI installed on your system. Without MUI Release "
    MUIRelease " or newer you won't be able to run the preferences "
    "program.\n\nIf you don't like MUI we are willing to offer you support "
    "to write a preferences program that does not require MUI.\n\n"
    "Of course you can continue the installation, but don't forget to "
    "install MUI later."
   )
  )

  (set #selectplace
   (cat
    "Please select a place for %s. "
    "A directory \"%s\" will be created there."
   )
  )
  (set #selectplacehelp
   (cat
    "About 200KB is required for " ProductName ". "
    "All files will be copied into a single directory."
   )
  )

  (set #commodity "the Commodity" )

  (set #prefs "the Preferences Program")
  (set #catalogs "the Catalog files")

  (set #modules "the Blanker modules")

  (set #startup
   (cat
    "To be able to use %s the file \"S:User-Startup\" must be modified. "
    "The following commands will be added:\n\n%s"
   )
  )

  (set #docchoice "Which documentation do you want to install?")
  (set #docchoice1 "English")
  (set #docchoice2 "German")
  (set #docdefault 0)

  (set #documentation "the Documentation")
 )
)

(if (= @language "deutsch")
 (
  (set #install "Installiere ")

  (set #wrong_os
   (cat
    "Sie benutzen vermutlich WB 1.3. Wenn das zutrifft, sollten "
    "Sie möglichst bald ein Update auf WB 2.04 oder neuer durchführen. "
    "\"\%s\" funktioniert nicht mit WB 1.3 oder älter."
   )
  )

  (set #wrong_mui
   (cat
    ProductName " benötigt mindestens " MUIName " Version " MUIVersion
    " (Release " MUIRelease "). Sie haben aber offensichtlich nur "
    "Version %ld installiert.\n\nNatürlich können Sie mit der Installation "
    "fortfahren, aber vergessen Sie nicht, später eine neuere Version "
    "von MUI zu installieren."
   )
  )
  (set #no_mui
   (cat
    "Sie haben scheinbar MUI nicht auf Ihrem System installiert. Ohne "
    "MUI Release " MUIRelease " oder neuer können Sie den Voreinsteller "
    "nicht benutzen.\n\n Wenn Sie MUI nicht mögen, werden wir Sie "
    "gerne bei der Entwicklung eines Voreinsteller, der ohne MUI auskommt, "
    "unterstützen.\n\nNatürlich können Sie mit der Installation "
    "fortfahren, aber vergessen Sie nicht, später MUI zu installieren."
   )
  )

  (set #selectplace
   (cat
    "Bitte wählen Sie einen Platz für %s aus. "
    "Dort wird ein Verzeichnis \"%s\" angelegt."
   )
  )
  (set #selectplacehelp
   (cat
    "Ungefähr 200KB werden für " ProductName " benötigt. "
    "Alle Dateien werden in einem einzigen Verzeichnis abgelegt."
   )
  )
  (set #commodity "das Commodity" )

  (set #prefs "den Voreinsteller")
  (set #catalogs "die Sprachdateien")

  (set #modules "die Blanker-Module")

  (set #startup
   (cat
    "Um % benutzen zu können, muß die Datei \"S:User-Startup\" modifiziert "
    "werden. Die folgenden Befehle werden hinzugefügt:\n\n%s"
   )
  )

  (set #docchoice "Welche Anleitung wollen Sie installieren?")
  (set #docchoice1 "Englisch")
  (set #docchoice2 "Deutsch")
  (set #docdefault 1)

  (set #documentation "die Dokumentation")
 )
)

(set OSVersion (/ (getversion) 65536))

(transcript #install ProductName " " ProductVers " ...")

(complete 0)

; Check OS version

(if (< OSVersion 37)
 (
  (abort (#wrong_os ProductName))
 )
)

; Check for MUI

(if (exists (tackon "LIBS:" MUIName))
 (
  (set Version (/ (getversion (tackon "LIBS:" MUIName)) 65536))
  (if (< Version MUIVersion)
   (message (#wrong_mui Version))
  )
 )
 (message #no_mui)
)

; Select place for our directory

(set BTDDir
 (tackon
  (askdir 
   (prompt (#selectplace ProductName BTDDrawer))
   (help (#selectplacehelp ProductName ProductName) @askdir-help)
   (default "Work:")
   (newpath)
  )
  BTDDrawer
 )
)

(complete 10)

; Create our directory

(if (NOT (exists BTDDir))
 (makedir 
  (BTDDir)
  (infos)
 )
)

(run (cat "Assign BTD: \"" BTDDir "\""))

(complete 20)

; Commodity

(copyfiles
 (prompt #install #commodity "...")
 (source "Binary")
 (pattern "BTD-CX(%|.info)")
 (help @copyfiles-help)
 (confirm)
 (dest BTDDir)
)

(complete 35)

; Preferences Program and the catalogs

(copyfiles
 (prompt #install #prefs "...")
 (source "Binary")
 (pattern "BTD(%|.info)")
 (help @copyfiles-help)
 (confirm)
 (dest BTDDir)
)

(complete 45)

(copyfiles
 (prompt #install #catalogs "...")
 (source "Binary/Catalogs")
 (pattern "#?")
 (help @copyfiles-help)
 (confirm)
 (dest (tackon BTDDir "Catalogs"))
)

(complete 50)

; Modules

(copyfiles
 (prompt #install #modules "...")
 (source "Binary/Blankers")
 (pattern "#?.btd")
 (help @copyfiles-help)
 (confirm)
 (dest (tackon BTDDir "Blankers"))
)

(complete 70)

; User-Startup

(set Cmd (cat "Assign BTD: \"" BTDDir "\"\nRun >NIL: BTD:BTD-CX >NIL:"))

(startup
 (prompt (#startup ProductName Cmd))
 (ProductName)
 (help @startup-help)
 (command Cmd)
)

(complete 90)

; Documentation

(set Documentation
 (askchoice
  (prompt #docchoice)
  (choices
   #docchoice1
   #docchoice2
  )
  (help @askchoice-help)
  (default #docdefault)
 )
)

(if (= Documentation 0)
 (set DocSourceDir "English")
 (set DocSourceDir "Deutsch")
)

(copyfiles
 (prompt #install #documentation "...")
 (source (tackon "Documentation" DocSourceDir))
 (pattern "#?.guide(%|.info)")
 (help @copyfiles-help)
 (confirm)
 (dest BTDDir)
)

(complete 100)
